Public Class BPLogo
Inherits System.Windows.Forms.UserControl
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
Me.SetStyle(ControlStyles.UserPaint, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
currentRGB = randomRGB.Next(0, 3)
'Add any initialization after the InitializeComponent() call
End Sub
'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Timer1 As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
'
'Timer1
'
Me.Timer1.Enabled = True
Me.Timer1.Interval = 50
'
'BPLogo
'
Me.Name = "BPLogo"
Me.Size = New System.Drawing.Size(48, 48)
End Sub
#End Region
#Region "Declarations"
'this control will be the Letters BP in the corner of the screen, they will change
' colors at a givin rate, adjust to different sizes
'in the future i plan to use this buttton as my exit/minimize button on a custom form
Private mColor As Color = Color.AliceBlue
Private mSize As Short = 20
Dim myFont As New Font("Sylfaen", mSize, FontStyle.Bold)
Dim myBrush As New SolidBrush(mColor)
Dim randomRGB As New Random(3)
Dim randomIncrementTo As New Random(111)
Dim increment As Short = 1
Dim value As Short
Dim rgb As Short() = {0, 0, 0}
Dim currentRGB As Byte
Dim valueReached As Boolean = True
#End Region
#Region "Properties"
Public Property LogoSize() As Short
Get
Return mSize
End Get
Set(ByVal Value As Short)
mSize = Value
myFont = New Font("Sylfaen", mSize, FontStyle.Bold)
Dim mycolr As Color
End Set
End Property
Public Property StartColor() As Color
Get
Return mColor
End Get
Set(ByVal Value As Color)
mColor = Value
End Set
End Property
#End Region
#Region "Methods"
Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
Me.Height = Me.Width
mSize = (Me.Width / 2)
myFont = New Font("Sylfaen", mSize, FontStyle.Bold)
Me.Refresh()
End Sub
#End Region
#Region "Events"
Private Sub BPLogo_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
e.Graphics.DrawString("BP", myFont, myBrush, 0, 0)
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
myBrush.Color = Drawing.Color.FromArgb(rgb(0), rgb(1), rgb(2))
Me.Refresh()
If valueReached Then
currentRGB = randomRGB.Next(0, 3)
Do While valueReached = True
value = randomIncrementTo.Next(0, 255)
If rgb(currentRGB) < value Then
increment = 1
valueReached = False
ElseIf rgb(currentRGB) > value Then
increment = -1
valueReached = False
Else
valueReached = True
End If
Loop
End If
rgb(currentRGB) += increment
If rgb(currentRGB) = value Then valueReached = True
End Sub
#End Region
End Class