Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Region "imports"
- Imports System, System.IO, System.Collections.Generic
- Imports System.Drawing, System.Drawing.Drawing2D
- Imports System.ComponentModel, System.Windows.Forms
- Imports System.Runtime.InteropServices
- Imports System.Drawing.Imaging
- #End Region
- #Region " Theme Bases"
- MustInherit Class ThemeContainer153
- Inherits ContainerControl
- #Region " Initialization "
- Protected G As Graphics, B As Bitmap
- Sub New()
- SetStyle(DirectCast(139270, ControlStyles), True)
- _ImageSize = Size.Empty
- Font = New Font("Verdana", 8S)
- MeasureBitmap = New Bitmap(1, 1)
- MeasureGraphics = Graphics.FromImage(MeasureBitmap)
- DrawRadialPath = New GraphicsPath
- InvalidateCustimization() 'Remove?
- End Sub
- Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
- InvalidateCustimization()
- ColorHook()
- If Not _LockWidth = 0 Then Width = _LockWidth
- If Not _LockHeight = 0 Then Height = _LockHeight
- If Not _ControlMode Then MyBase.Dock = DockStyle.Fill
- Transparent = _Transparent
- If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
- MyBase.OnHandleCreated(e)
- End Sub
- Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
- MyBase.OnParentChanged(e)
- If Parent Is Nothing Then Return
- _IsParentForm = TypeOf Parent Is Form
- If Not _ControlMode Then
- InitializeMessages()
- If _IsParentForm Then
- ParentForm.FormBorderStyle = _BorderStyle
- ParentForm.TransparencyKey = _TransparencyKey
- End If
- Parent.BackColor = BackColor
- End If
- OnCreation()
- End Sub
- #End Region
- Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- If Width = 0 OrElse Height = 0 Then Return
- If _Transparent AndAlso _ControlMode Then
- PaintHook()
- e.Graphics.DrawImage(B, 0, 0)
- Else
- G = e.Graphics
- PaintHook()
- End If
- End Sub
- #Region " Size Handling "
- Private Frame As Rectangle
- Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
- If _Movable AndAlso Not _ControlMode Then
- Frame = New Rectangle(7, 7, Width - 14, _Header - 7)
- End If
- InvalidateBitmap()
- Invalidate()
- MyBase.OnSizeChanged(e)
- End Sub
- Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
- If Not _LockWidth = 0 Then width = _LockWidth
- If Not _LockHeight = 0 Then height = _LockHeight
- MyBase.SetBoundsCore(x, y, width, height, specified)
- End Sub
- #End Region
- #Region " State Handling "
- Protected State As MouseState
- Private Sub SetState(ByVal current As MouseState)
- State = current
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
- If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
- If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
- End If
- MyBase.OnMouseMove(e)
- End Sub
- Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
- If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
- MyBase.OnEnabledChanged(e)
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- SetState(MouseState.Over)
- MyBase.OnMouseEnter(e)
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- SetState(MouseState.Over)
- MyBase.OnMouseUp(e)
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- SetState(MouseState.None)
- If GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
- If _Sizable AndAlso Not _ControlMode Then
- Cursor = Cursors.Default
- Previous = 0
- End If
- End If
- MyBase.OnMouseLeave(e)
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
- If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
- If _Movable AndAlso Frame.Contains(e.Location) Then
- Capture = False
- WM_LMBUTTONDOWN = True
- DefWndProc(Messages(0))
- ElseIf _Sizable AndAlso Not Previous = 0 Then
- Capture = False
- WM_LMBUTTONDOWN = True
- DefWndProc(Messages(Previous))
- End If
- End If
- MyBase.OnMouseDown(e)
- End Sub
- Private WM_LMBUTTONDOWN As Boolean
- Protected Overrides Sub WndProc(ByRef m As Message)
- MyBase.WndProc(m)
- If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
- WM_LMBUTTONDOWN = False
- SetState(MouseState.Over)
- If Not _SmartBounds Then Return
- If IsParentMdi Then
- CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
- Else
- CorrectBounds(Screen.FromControl(Parent).WorkingArea)
- End If
- End If
- End Sub
- Private GetIndexPoint As Point
- Private B1, B2, B3, B4 As Boolean
- Private Function GetIndex() As Integer
- GetIndexPoint = PointToClient(MousePosition)
- B1 = GetIndexPoint.X < 7
- B2 = GetIndexPoint.X > Width - 7
- B3 = GetIndexPoint.Y < 7
- B4 = GetIndexPoint.Y > Height - 7
- If B1 AndAlso B3 Then Return 4
- If B1 AndAlso B4 Then Return 7
- If B2 AndAlso B3 Then Return 5
- If B2 AndAlso B4 Then Return 8
- If B1 Then Return 1
- If B2 Then Return 2
- If B3 Then Return 3
- If B4 Then Return 6
- Return 0
- End Function
- Private Current, Previous As Integer
- Private Sub InvalidateMouse()
- Current = GetIndex()
- If Current = Previous Then Return
- Previous = Current
- Select Case Previous
- Case 0
- Cursor = Cursors.Default
- Case 1, 2
- Cursor = Cursors.SizeWE
- Case 3, 6
- Cursor = Cursors.SizeNS
- Case 4, 8
- Cursor = Cursors.SizeNWSE
- Case 5, 7
- Cursor = Cursors.SizeNESW
- End Select
- End Sub
- Private Messages(8) As Message
- Private Sub InitializeMessages()
- Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
- For I As Integer = 1 To 8
- Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
- Next
- End Sub
- Private Sub CorrectBounds(ByVal bounds As Rectangle)
- If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
- If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
- Dim X As Integer = Parent.Location.X
- Dim Y As Integer = Parent.Location.Y
- If X < bounds.X Then X = bounds.X
- If Y < bounds.Y Then Y = bounds.Y
- Dim Width As Integer = bounds.X + bounds.Width
- Dim Height As Integer = bounds.Y + bounds.Height
- If X + Parent.Width > Width Then X = Width - Parent.Width
- If Y + Parent.Height > Height Then Y = Height - Parent.Height
- Parent.Location = New Point(X, Y)
- End Sub
- #End Region
- #Region " Base Properties "
- Overrides Property Dock As DockStyle
- Get
- Return MyBase.Dock
- End Get
- Set(ByVal value As DockStyle)
- If Not _ControlMode Then Return
- MyBase.Dock = value
- End Set
- End Property
- Private _BackColor As Boolean
- <Category("Misc")> _
- Overrides Property BackColor() As Color
- Get
- Return MyBase.BackColor
- End Get
- Set(ByVal value As Color)
- If value = MyBase.BackColor Then Return
- If Not IsHandleCreated AndAlso _ControlMode AndAlso value = Color.Transparent Then
- _BackColor = True
- Return
- End If
- MyBase.BackColor = value
- If Parent IsNot Nothing Then
- If Not _ControlMode Then Parent.BackColor = value
- ColorHook()
- End If
- End Set
- End Property
- Overrides Property MinimumSize As Size
- Get
- Return MyBase.MinimumSize
- End Get
- Set(ByVal value As Size)
- MyBase.MinimumSize = value
- If Parent IsNot Nothing Then Parent.MinimumSize = value
- End Set
- End Property
- Overrides Property MaximumSize As Size
- Get
- Return MyBase.MaximumSize
- End Get
- Set(ByVal value As Size)
- MyBase.MaximumSize = value
- If Parent IsNot Nothing Then Parent.MaximumSize = value
- End Set
- End Property
- Overrides Property Text() As String
- Get
- Return MyBase.Text
- End Get
- Set(ByVal value As String)
- MyBase.Text = value
- Invalidate()
- End Set
- End Property
- Overrides Property Font() As Font
- Get
- Return MyBase.Font
- End Get
- Set(ByVal value As Font)
- MyBase.Font = value
- Invalidate()
- End Set
- End Property
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Overrides Property ForeColor() As Color
- Get
- Return Color.Empty
- End Get
- Set(ByVal value As Color)
- End Set
- End Property
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Overrides Property BackgroundImage() As Image
- Get
- Return Nothing
- End Get
- Set(ByVal value As Image)
- End Set
- End Property
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Overrides Property BackgroundImageLayout() As ImageLayout
- Get
- Return ImageLayout.None
- End Get
- Set(ByVal value As ImageLayout)
- End Set
- End Property
- #End Region
- #Region " Public Properties "
- Private _SmartBounds As Boolean = True
- Property SmartBounds() As Boolean
- Get
- Return _SmartBounds
- End Get
- Set(ByVal value As Boolean)
- _SmartBounds = value
- End Set
- End Property
- Private _Movable As Boolean = True
- Property Movable() As Boolean
- Get
- Return _Movable
- End Get
- Set(ByVal value As Boolean)
- _Movable = value
- End Set
- End Property
- Private _Sizable As Boolean = True
- Property Sizable() As Boolean
- Get
- Return _Sizable
- End Get
- Set(ByVal value As Boolean)
- _Sizable = value
- End Set
- End Property
- Private _TransparencyKey As Color
- Property TransparencyKey() As Color
- Get
- If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
- End Get
- Set(ByVal value As Color)
- If value = _TransparencyKey Then Return
- _TransparencyKey = value
- If _IsParentForm AndAlso Not _ControlMode Then
- ParentForm.TransparencyKey = value
- ColorHook()
- End If
- End Set
- End Property
- Private _BorderStyle As FormBorderStyle
- Property BorderStyle() As FormBorderStyle
- Get
- If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
- End Get
- Set(ByVal value As FormBorderStyle)
- _BorderStyle = value
- If _IsParentForm AndAlso Not _ControlMode Then
- ParentForm.FormBorderStyle = value
- If Not value = FormBorderStyle.None Then
- Movable = False
- Sizable = False
- End If
- End If
- End Set
- End Property
- Private _NoRounding As Boolean
- Property NoRounding() As Boolean
- Get
- Return _NoRounding
- End Get
- Set(ByVal v As Boolean)
- _NoRounding = v
- Invalidate()
- End Set
- End Property
- Private _Image As Image
- Property Image() As Image
- Get
- Return _Image
- End Get
- Set(ByVal value As Image)
- If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size
- _Image = value
- Invalidate()
- End Set
- End Property
- Private Items As New Dictionary(Of String, Color)
- Property Colors() As Bloom()
- Get
- Dim T As New List(Of Bloom)
- Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
- While E.MoveNext
- T.Add(New Bloom(E.Current.Key, E.Current.Value))
- End While
- Return T.ToArray
- End Get
- Set(ByVal value As Bloom())
- For Each B As Bloom In value
- If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
- Next
- InvalidateCustimization()
- ColorHook()
- Invalidate()
- End Set
- End Property
- Private _Customization As String
- Property Customization() As String
- Get
- Return _Customization
- End Get
- Set(ByVal value As String)
- If value = _Customization Then Return
- Dim Data As Byte()
- Dim Items As Bloom() = Colors
- Try
- Data = Convert.FromBase64String(value)
- For I As Integer = 0 To Items.Length - 1
- Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
- Next
- Catch
- Return
- End Try
- _Customization = value
- Colors = Items
- ColorHook()
- Invalidate()
- End Set
- End Property
- Private _Transparent As Boolean
- Property Transparent() As Boolean
- Get
- Return _Transparent
- End Get
- Set(ByVal value As Boolean)
- _Transparent = value
- If Not (IsHandleCreated OrElse _ControlMode) Then Return
- If Not value AndAlso Not BackColor.A = 255 Then
- Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
- End If
- SetStyle(ControlStyles.Opaque, Not value)
- SetStyle(ControlStyles.SupportsTransparentBackColor, value)
- InvalidateBitmap()
- Invalidate()
- End Set
- End Property
- #End Region
- #Region " Private Properties "
- Private _ImageSize As Size
- Protected ReadOnly Property ImageSize() As Size
- Get
- Return _ImageSize
- End Get
- End Property
- Private _IsParentForm As Boolean
- Protected ReadOnly Property IsParentForm As Boolean
- Get
- Return _IsParentForm
- End Get
- End Property
- Protected ReadOnly Property IsParentMdi As Boolean
- Get
- If Parent Is Nothing Then Return False
- Return Parent.Parent IsNot Nothing
- End Get
- End Property
- Private _LockWidth As Integer
- Protected Property LockWidth() As Integer
- Get
- Return _LockWidth
- End Get
- Set(ByVal value As Integer)
- _LockWidth = value
- If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
- End Set
- End Property
- Private _LockHeight As Integer
- Protected Property LockHeight() As Integer
- Get
- Return _LockHeight
- End Get
- Set(ByVal value As Integer)
- _LockHeight = value
- If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
- End Set
- End Property
- Private _Header As Integer = 24
- Protected Property Header() As Integer
- Get
- Return _Header
- End Get
- Set(ByVal v As Integer)
- _Header = v
- If Not _ControlMode Then
- Frame = New Rectangle(7, 7, Width - 14, v - 7)
- Invalidate()
- End If
- End Set
- End Property
- Private _ControlMode As Boolean
- Protected Property ControlMode() As Boolean
- Get
- Return _ControlMode
- End Get
- Set(ByVal v As Boolean)
- _ControlMode = v
- Transparent = _Transparent
- If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
- InvalidateBitmap()
- Invalidate()
- End Set
- End Property
- #End Region
- #Region " Property Helpers "
- Protected Function GetPen(ByVal name As String) As Pen
- Return New Pen(Items(name))
- End Function
- Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
- Return New Pen(Items(name), width)
- End Function
- Protected Function GetBrush(ByVal name As String) As SolidBrush
- Return New SolidBrush(Items(name))
- End Function
- Protected Function GetColor(ByVal name As String) As Color
- Return Items(name)
- End Function
- Protected Sub SetColor(ByVal name As String, ByVal value As Color)
- If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
- End Sub
- Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
- SetColor(name, Color.FromArgb(r, g, b))
- End Sub
- Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
- SetColor(name, Color.FromArgb(a, r, g, b))
- End Sub
- Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
- SetColor(name, Color.FromArgb(a, value))
- End Sub
- Private Sub InvalidateBitmap()
- If _Transparent AndAlso _ControlMode Then
- If Width = 0 OrElse Height = 0 Then Return
- B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
- G = Graphics.FromImage(B)
- Else
- G = Nothing
- B = Nothing
- End If
- End Sub
- Private Sub InvalidateCustimization()
- Dim M As New MemoryStream(Items.Count * 4)
- For Each B As Bloom In Colors
- M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
- Next
- M.Close()
- _Customization = Convert.ToBase64String(M.ToArray)
- End Sub
- #End Region
- #Region " User Hooks "
- Protected MustOverride Sub ColorHook()
- Protected MustOverride Sub PaintHook()
- Protected Overridable Sub OnCreation()
- End Sub
- #End Region
- #Region " Offset "
- Private OffsetReturnRectangle As Rectangle
- Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
- OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
- Return OffsetReturnRectangle
- End Function
- Private OffsetReturnSize As Size
- Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
- OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
- Return OffsetReturnSize
- End Function
- Private OffsetReturnPoint As Point
- Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
- OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
- Return OffsetReturnPoint
- End Function
- #End Region
- #Region " Center "
- Private CenterReturn As Point
- Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
- CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
- Return CenterReturn
- End Function
- Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
- CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
- Return CenterReturn
- End Function
- Protected Function Center(ByVal child As Rectangle) As Point
- Return Center(Width, Height, child.Width, child.Height)
- End Function
- Protected Function Center(ByVal child As Size) As Point
- Return Center(Width, Height, child.Width, child.Height)
- End Function
- Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
- Return Center(Width, Height, childWidth, childHeight)
- End Function
- Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
- Return Center(p.Width, p.Height, c.Width, c.Height)
- End Function
- Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
- CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
- Return CenterReturn
- End Function
- #End Region
- #Region " Measure "
- Private MeasureBitmap As Bitmap
- Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
- Protected Function Measure() As Size
- Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
- End Function
- Protected Function Measure(ByVal text As String) As Size
- Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
- End Function
- #End Region
- #Region " DrawPixel "
- Private DrawPixelBrush As SolidBrush
- Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
- If _Transparent Then
- B.SetPixel(x, y, c1)
- Else
- DrawPixelBrush = New SolidBrush(c1)
- G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
- End If
- End Sub
- #End Region
- #Region " DrawCorners "
- Private DrawCornersBrush As SolidBrush
- Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
- DrawCorners(c1, 0, 0, Width, Height, offset)
- End Sub
- Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
- DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
- End Sub
- Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
- DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
- End Sub
- Protected Sub DrawCorners(ByVal c1 As Color)
- DrawCorners(c1, 0, 0, Width, Height)
- End Sub
- Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
- DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
- End Sub
- Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- If _NoRounding Then Return
- If _Transparent Then
- B.SetPixel(x, y, c1)
- B.SetPixel(x + (width - 1), y, c1)
- B.SetPixel(x, y + (height - 1), c1)
- B.SetPixel(x + (width - 1), y + (height - 1), c1)
- Else
- DrawCornersBrush = New SolidBrush(c1)
- G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
- G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
- G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
- G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
- End If
- End Sub
- #End Region
- #Region " DrawBorders "
- Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
- DrawBorders(p1, 0, 0, Width, Height, offset)
- End Sub
- Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
- DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
- End Sub
- Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
- DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
- End Sub
- Protected Sub DrawBorders(ByVal p1 As Pen)
- DrawBorders(p1, 0, 0, Width, Height)
- End Sub
- Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
- DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
- End Sub
- Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- G.DrawRectangle(p1, x, y, width - 1, height - 1)
- End Sub
- #End Region
- #Region " DrawText "
- Private DrawTextPoint As Point
- Private DrawTextSize As Size
- Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
- DrawText(b1, Text, a, x, y)
- End Sub
- Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
- If text.Length = 0 Then Return
- DrawTextSize = Measure(text)
- DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, Header \ 2 - DrawTextSize.Height \ 2)
- Select Case a
- Case HorizontalAlignment.Left
- G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
- Case HorizontalAlignment.Center
- G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
- Case HorizontalAlignment.Right
- G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
- End Select
- End Sub
- Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
- If Text.Length = 0 Then Return
- G.DrawString(Text, Font, b1, p1)
- End Sub
- Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
- If Text.Length = 0 Then Return
- G.DrawString(Text, Font, b1, x, y)
- End Sub
- #End Region
- #Region " DrawImage "
- Private DrawImagePoint As Point
- Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
- DrawImage(_Image, a, x, y)
- End Sub
- Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
- If image Is Nothing Then Return
- DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, Header \ 2 - image.Height \ 2)
- Select Case a
- Case HorizontalAlignment.Left
- G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
- Case HorizontalAlignment.Center
- G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
- Case HorizontalAlignment.Right
- G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
- End Select
- End Sub
- Protected Sub DrawImage(ByVal p1 As Point)
- DrawImage(_Image, p1.X, p1.Y)
- End Sub
- Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
- DrawImage(_Image, x, y)
- End Sub
- Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
- DrawImage(image, p1.X, p1.Y)
- End Sub
- Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
- If image Is Nothing Then Return
- G.DrawImage(image, x, y, image.Width, image.Height)
- End Sub
- #End Region
- #Region " DrawGradient "
- Private DrawGradientBrush As LinearGradientBrush
- Private DrawGradientRectangle As Rectangle
- Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- DrawGradientRectangle = New Rectangle(x, y, width, height)
- DrawGradient(blend, DrawGradientRectangle)
- End Sub
- Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
- DrawGradientRectangle = New Rectangle(x, y, width, height)
- DrawGradient(blend, DrawGradientRectangle, angle)
- End Sub
- Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
- DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
- DrawGradientBrush.InterpolationColors = blend
- G.FillRectangle(DrawGradientBrush, r)
- End Sub
- Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
- DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
- DrawGradientBrush.InterpolationColors = blend
- G.FillRectangle(DrawGradientBrush, r)
- End Sub
- Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- DrawGradientRectangle = New Rectangle(x, y, width, height)
- DrawGradient(c1, c2, DrawGradientRectangle)
- End Sub
- Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
- DrawGradientRectangle = New Rectangle(x, y, width, height)
- DrawGradient(c1, c2, DrawGradientRectangle, angle)
- End Sub
- Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
- DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
- G.FillRectangle(DrawGradientBrush, r)
- End Sub
- Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
- DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
- G.FillRectangle(DrawGradientBrush, r)
- End Sub
- #End Region
- #Region " DrawRadial "
- Private DrawRadialPath As GraphicsPath
- Private DrawRadialBrush1 As PathGradientBrush
- Private DrawRadialBrush2 As LinearGradientBrush
- Private DrawRadialRectangle As Rectangle
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- DrawRadialRectangle = New Rectangle(x, y, width, height)
- DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
- End Sub
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal center As Point)
- DrawRadialRectangle = New Rectangle(x, y, width, height)
- DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
- End Sub
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cx As Integer, ByVal cy As Integer)
- DrawRadialRectangle = New Rectangle(x, y, width, height)
- DrawRadial(blend, DrawRadialRectangle, cx, cy)
- End Sub
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
- DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
- End Sub
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
- DrawRadial(blend, r, center.X, center.Y)
- End Sub
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
- DrawRadialPath.Reset()
- DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
- DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
- DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
- DrawRadialBrush1.InterpolationColors = blend
- If G.SmoothingMode = SmoothingMode.AntiAlias Then
- G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
- Else
- G.FillEllipse(DrawRadialBrush1, r)
- End If
- End Sub
- Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- DrawRadialRectangle = New Rectangle(x, y, width, height)
- DrawRadial(c1, c2, DrawGradientRectangle)
- End Sub
- Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
- DrawRadialRectangle = New Rectangle(x, y, width, height)
- DrawRadial(c1, c2, DrawGradientRectangle, angle)
- End Sub
- Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
- DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
- G.FillRectangle(DrawGradientBrush, r)
- End Sub
- Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
- DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
- G.FillEllipse(DrawGradientBrush, r)
- End Sub
- #End Region
- End Class
- MustInherit Class ThemeControl153
- Inherits Control
- #Region " Initialization "
- Protected G As Graphics, B As Bitmap
- Sub New()
- SetStyle(DirectCast(139270, ControlStyles), True)
- _ImageSize = Size.Empty
- Font = New Font("Verdana", 8S)
- MeasureBitmap = New Bitmap(1, 1)
- MeasureGraphics = Graphics.FromImage(MeasureBitmap)
- DrawRadialPath = New GraphicsPath
- InvalidateCustimization() 'Remove?
- End Sub
- Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
- InvalidateCustimization()
- ColorHook()
- If Not _LockWidth = 0 Then Width = _LockWidth
- If Not _LockHeight = 0 Then Height = _LockHeight
- Transparent = _Transparent
- If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
- MyBase.OnHandleCreated(e)
- End Sub
- Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
- If Parent IsNot Nothing Then OnCreation()
- MyBase.OnParentChanged(e)
- End Sub
- #End Region
- Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- If Width = 0 OrElse Height = 0 Then Return
- If _Transparent Then
- PaintHook()
- e.Graphics.DrawImage(B, 0, 0)
- Else
- G = e.Graphics
- PaintHook()
- End If
- End Sub
- #Region " Size Handling "
- Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
- If _Transparent Then
- InvalidateBitmap()
- End If
- Invalidate()
- MyBase.OnSizeChanged(e)
- End Sub
- Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
- If Not _LockWidth = 0 Then width = _LockWidth
- If Not _LockHeight = 0 Then height = _LockHeight
- MyBase.SetBoundsCore(x, y, width, height, specified)
- End Sub
- #End Region
- #Region " State Handling "
- Private InPosition As Boolean
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- InPosition = True
- SetState(MouseState.Over)
- MyBase.OnMouseEnter(e)
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- If InPosition Then SetState(MouseState.Over)
- MyBase.OnMouseUp(e)
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
- MyBase.OnMouseDown(e)
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- InPosition = False
- SetState(MouseState.None)
- MyBase.OnMouseLeave(e)
- End Sub
- Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
- If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
- MyBase.OnEnabledChanged(e)
- End Sub
- Protected State As MouseState
- Private Sub SetState(ByVal current As MouseState)
- State = current
- Invalidate()
- End Sub
- #End Region
- #Region " Base Properties "
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Overrides Property ForeColor() As Color
- Get
- Return Color.Empty
- End Get
- Set(ByVal value As Color)
- End Set
- End Property
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Overrides Property BackgroundImage() As Image
- Get
- Return Nothing
- End Get
- Set(ByVal value As Image)
- End Set
- End Property
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Overrides Property BackgroundImageLayout() As ImageLayout
- Get
- Return ImageLayout.None
- End Get
- Set(ByVal value As ImageLayout)
- End Set
- End Property
- Overrides Property Text() As String
- Get
- Return MyBase.Text
- End Get
- Set(ByVal value As String)
- MyBase.Text = value
- Invalidate()
- End Set
- End Property
- Overrides Property Font() As Font
- Get
- Return MyBase.Font
- End Get
- Set(ByVal value As Font)
- MyBase.Font = value
- Invalidate()
- End Set
- End Property
- Private _BackColor As Boolean
- <Category("Misc")> _
- Overrides Property BackColor() As Color
- Get
- Return MyBase.BackColor
- End Get
- Set(ByVal value As Color)
- If Not IsHandleCreated AndAlso value = Color.Transparent Then
- _BackColor = True
- Return
- End If
- MyBase.BackColor = value
- If Parent IsNot Nothing Then ColorHook()
- End Set
- End Property
- #End Region
- #Region " Public Properties "
- Private _NoRounding As Boolean
- Property NoRounding() As Boolean
- Get
- Return _NoRounding
- End Get
- Set(ByVal v As Boolean)
- _NoRounding = v
- Invalidate()
- End Set
- End Property
- Private _Image As Image
- Property Image() As Image
- Get
- Return _Image
- End Get
- Set(ByVal value As Image)
- If value Is Nothing Then
- _ImageSize = Size.Empty
- Else
- _ImageSize = value.Size
- End If
- _Image = value
- Invalidate()
- End Set
- End Property
- Private _Transparent As Boolean
- Property Transparent() As Boolean
- Get
- Return _Transparent
- End Get
- Set(ByVal value As Boolean)
- _Transparent = value
- If Not IsHandleCreated Then Return
- If Not value AndAlso Not BackColor.A = 255 Then
- Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
- End If
- SetStyle(ControlStyles.Opaque, Not value)
- SetStyle(ControlStyles.SupportsTransparentBackColor, value)
- If value Then InvalidateBitmap() Else B = Nothing
- Invalidate()
- End Set
- End Property
- Private Items As New Dictionary(Of String, Color)
- Property Colors() As Bloom()
- Get
- Dim T As New List(Of Bloom)
- Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
- While E.MoveNext
- T.Add(New Bloom(E.Current.Key, E.Current.Value))
- End While
- Return T.ToArray
- End Get
- Set(ByVal value As Bloom())
- For Each B As Bloom In value
- If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
- Next
- InvalidateCustimization()
- ColorHook()
- Invalidate()
- End Set
- End Property
- Private _Customization As String
- Property Customization() As String
- Get
- Return _Customization
- End Get
- Set(ByVal value As String)
- If value = _Customization Then Return
- Dim Data As Byte()
- Dim Items As Bloom() = Colors
- Try
- Data = Convert.FromBase64String(value)
- For I As Integer = 0 To Items.Length - 1
- Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
- Next
- Catch
- Return
- End Try
- _Customization = value
- Colors = Items
- ColorHook()
- Invalidate()
- End Set
- End Property
- #End Region
- #Region " Private Properties "
- Private _ImageSize As Size
- Protected ReadOnly Property ImageSize() As Size
- Get
- Return _ImageSize
- End Get
- End Property
- Private _LockWidth As Integer
- Protected Property LockWidth() As Integer
- Get
- Return _LockWidth
- End Get
- Set(ByVal value As Integer)
- _LockWidth = value
- If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
- End Set
- End Property
- Private _LockHeight As Integer
- Protected Property LockHeight() As Integer
- Get
- Return _LockHeight
- End Get
- Set(ByVal value As Integer)
- _LockHeight = value
- If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
- End Set
- End Property
- #End Region
- #Region " Property Helpers "
- Protected Function GetPen(ByVal name As String) As Pen
- Return New Pen(Items(name))
- End Function
- Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
- Return New Pen(Items(name), width)
- End Function
- Protected Function GetBrush(ByVal name As String) As SolidBrush
- Return New SolidBrush(Items(name))
- End Function
- Protected Function GetColor(ByVal name As String) As Color
- Return Items(name)
- End Function
- Protected Sub SetColor(ByVal name As String, ByVal value As Color)
- If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
- End Sub
- Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
- SetColor(name, Color.FromArgb(r, g, b))
- End Sub
- Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
- SetColor(name, Color.FromArgb(a, r, g, b))
- End Sub
- Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
- SetColor(name, Color.FromArgb(a, value))
- End Sub
- Private Sub InvalidateBitmap()
- If Width = 0 OrElse Height = 0 Then Return
- B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
- G = Graphics.FromImage(B)
- End Sub
- Private Sub InvalidateCustimization()
- Dim M As New MemoryStream(Items.Count * 4)
- For Each B As Bloom In Colors
- M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
- Next
- M.Close()
- _Customization = Convert.ToBase64String(M.ToArray)
- End Sub
- #End Region
- #Region " User Hooks "
- Protected MustOverride Sub ColorHook()
- Protected MustOverride Sub PaintHook()
- Protected Overridable Sub OnCreation()
- End Sub
- #End Region
- #Region " Offset "
- Private OffsetReturnRectangle As Rectangle
- Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
- OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
- Return OffsetReturnRectangle
- End Function
- Private OffsetReturnSize As Size
- Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
- OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
- Return OffsetReturnSize
- End Function
- Private OffsetReturnPoint As Point
- Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
- OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
- Return OffsetReturnPoint
- End Function
- #End Region
- #Region " Center "
- Private CenterReturn As Point
- Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
- CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
- Return CenterReturn
- End Function
- Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
- CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
- Return CenterReturn
- End Function
- Protected Function Center(ByVal child As Rectangle) As Point
- Return Center(Width, Height, child.Width, child.Height)
- End Function
- Protected Function Center(ByVal child As Size) As Point
- Return Center(Width, Height, child.Width, child.Height)
- End Function
- Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
- Return Center(Width, Height, childWidth, childHeight)
- End Function
- Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
- Return Center(p.Width, p.Height, c.Width, c.Height)
- End Function
- Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
- CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
- Return CenterReturn
- End Function
- #End Region
- #Region " Measure "
- Private MeasureBitmap As Bitmap
- Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
- Protected Function Measure() As Size
- Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
- End Function
- Protected Function Measure(ByVal text As String) As Size
- Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
- End Function
- #End Region
- #Region " DrawPixel "
- Private DrawPixelBrush As SolidBrush
- Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
- If _Transparent Then
- B.SetPixel(x, y, c1)
- Else
- DrawPixelBrush = New SolidBrush(c1)
- G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
- End If
- End Sub
- #End Region
- #Region " DrawCorners "
- Private DrawCornersBrush As SolidBrush
- Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
- DrawCorners(c1, 0, 0, Width, Height, offset)
- End Sub
- Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
- DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
- End Sub
- Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
- DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
- End Sub
- Protected Sub DrawCorners(ByVal c1 As Color)
- DrawCorners(c1, 0, 0, Width, Height)
- End Sub
- Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
- DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
- End Sub
- Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- If _NoRounding Then Return
- If _Transparent Then
- B.SetPixel(x, y, c1)
- B.SetPixel(x + (width - 1), y, c1)
- B.SetPixel(x, y + (height - 1), c1)
- B.SetPixel(x + (width - 1), y + (height - 1), c1)
- Else
- DrawCornersBrush = New SolidBrush(c1)
- G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
- G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
- G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
- G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
- End If
- End Sub
- #End Region
- #Region " DrawBorders "
- Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
- DrawBorders(p1, 0, 0, Width, Height, offset)
- End Sub
- Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
- DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
- End Sub
- Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
- DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
- End Sub
- Protected Sub DrawBorders(ByVal p1 As Pen)
- DrawBorders(p1, 0, 0, Width, Height)
- End Sub
- Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
- DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
- End Sub
- Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- G.DrawRectangle(p1, x, y, width - 1, height - 1)
- End Sub
- #End Region
- #Region " DrawText "
- Private DrawTextPoint As Point
- Private DrawTextSize As Size
- Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
- DrawText(b1, Text, a, x, y)
- End Sub
- Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
- If text.Length = 0 Then Return
- DrawTextSize = Measure(text)
- DrawTextPoint = Center(DrawTextSize)
- Select Case a
- Case HorizontalAlignment.Left
- G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
- Case HorizontalAlignment.Center
- G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
- Case HorizontalAlignment.Right
- G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
- End Select
- End Sub
- Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
- If Text.Length = 0 Then Return
- G.DrawString(Text, Font, b1, p1)
- End Sub
- Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
- If Text.Length = 0 Then Return
- G.DrawString(Text, Font, b1, x, y)
- End Sub
- #End Region
- #Region " DrawImage "
- Private DrawImagePoint As Point
- Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
- DrawImage(_Image, a, x, y)
- End Sub
- Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
- If image Is Nothing Then Return
- DrawImagePoint = Center(image.Size)
- Select Case a
- Case HorizontalAlignment.Left
- G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
- Case HorizontalAlignment.Center
- G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
- Case HorizontalAlignment.Right
- G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
- End Select
- End Sub
- Protected Sub DrawImage(ByVal p1 As Point)
- DrawImage(_Image, p1.X, p1.Y)
- End Sub
- Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
- DrawImage(_Image, x, y)
- End Sub
- Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
- DrawImage(image, p1.X, p1.Y)
- End Sub
- Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
- If image Is Nothing Then Return
- G.DrawImage(image, x, y, image.Width, image.Height)
- End Sub
- #End Region
- #Region " DrawGradient "
- Private DrawGradientBrush As LinearGradientBrush
- Private DrawGradientRectangle As Rectangle
- Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- DrawGradientRectangle = New Rectangle(x, y, width, height)
- DrawGradient(blend, DrawGradientRectangle)
- End Sub
- Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
- DrawGradientRectangle = New Rectangle(x, y, width, height)
- DrawGradient(blend, DrawGradientRectangle, angle)
- End Sub
- Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
- DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
- DrawGradientBrush.InterpolationColors = blend
- G.FillRectangle(DrawGradientBrush, r)
- End Sub
- Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
- DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
- DrawGradientBrush.InterpolationColors = blend
- G.FillRectangle(DrawGradientBrush, r)
- End Sub
- Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- DrawGradientRectangle = New Rectangle(x, y, width, height)
- DrawGradient(c1, c2, DrawGradientRectangle)
- End Sub
- Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
- DrawGradientRectangle = New Rectangle(x, y, width, height)
- DrawGradient(c1, c2, DrawGradientRectangle, angle)
- End Sub
- Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
- DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
- G.FillRectangle(DrawGradientBrush, r)
- End Sub
- Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
- DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
- G.FillRectangle(DrawGradientBrush, r)
- End Sub
- #End Region
- #Region " DrawRadial "
- Private DrawRadialPath As GraphicsPath
- Private DrawRadialBrush1 As PathGradientBrush
- Private DrawRadialBrush2 As LinearGradientBrush
- Private DrawRadialRectangle As Rectangle
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- DrawRadialRectangle = New Rectangle(x, y, width, height)
- DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
- End Sub
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal center As Point)
- DrawRadialRectangle = New Rectangle(x, y, width, height)
- DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
- End Sub
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cx As Integer, ByVal cy As Integer)
- DrawRadialRectangle = New Rectangle(x, y, width, height)
- DrawRadial(blend, DrawRadialRectangle, cx, cy)
- End Sub
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
- DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
- End Sub
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
- DrawRadial(blend, r, center.X, center.Y)
- End Sub
- Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
- DrawRadialPath.Reset()
- DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
- DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
- DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
- DrawRadialBrush1.InterpolationColors = blend
- If G.SmoothingMode = SmoothingMode.AntiAlias Then
- G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
- Else
- G.FillEllipse(DrawRadialBrush1, r)
- End If
- End Sub
- Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
- DrawRadialRectangle = New Rectangle(x, y, width, height)
- DrawRadial(c1, c2, DrawRadialRectangle)
- End Sub
- Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
- DrawRadialRectangle = New Rectangle(x, y, width, height)
- DrawRadial(c1, c2, DrawRadialRectangle, angle)
- End Sub
- Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
- DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
- G.FillEllipse(DrawRadialBrush2, r)
- End Sub
- Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
- DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
- G.FillEllipse(DrawRadialBrush2, r)
- End Sub
- #End Region
- End Class
- Enum MouseState As Byte
- None = 0
- Over = 1
- Down = 2
- Block = 3
- End Enum
- Structure Bloom
- Public _Name As String
- ReadOnly Property Name() As String
- Get
- Return _Name
- End Get
- End Property
- Private _Value As Color
- Property Value() As Color
- Get
- Return _Value
- End Get
- Set(ByVal value As Color)
- _Value = value
- End Set
- End Property
- Sub New(ByVal name As String, ByVal value As Color)
- _Name = name
- _Value = value
- End Sub
- End Structure
- #End Region
- Class AurumTheme
- Inherits ThemeContainer153
- Sub New()
- Header = 30
- Font = New Font("Verdana", 8.25F)
- End Sub
- Protected Overrides Sub ColorHook()
- End Sub
- Dim C1 As Color = Color.FromArgb(35, 45, 56)
- Dim C2 As Color = Color.FromArgb(33, 43, 53)
- Private P1 As Pen
- Protected Overrides Sub PaintHook()
- G.Clear(Color.FromArgb(21, 31, 40))
- Dim HeaderLGB As New LinearGradientBrush(New Rectangle(0, 0, Width, 15), Color.FromArgb(109, 118, 125), Color.FromArgb(51, 61, 70), 90S)
- G.FillRectangle(HeaderLGB, New Rectangle(0, 0, Width, 15))
- Dim RecLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), C1, C2)
- Dim shadowLGB As New LinearGradientBrush(New Rectangle(9, 33, Width - 19, 20), Color.FromArgb(15, 25, 35), Color.FromArgb(35, 45, 50), 90S)
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(51, 61, 70))), New Rectangle(7, 31, Width - 16, Height - 40))
- G.FillRectangle(RecLGB, New Rectangle(8, 32, Width - 18, Height - 42))
- G.DrawRectangle(New Pen(New SolidBrush(Color.Black)), New Rectangle(8, 32, Width - 18, Height - 42))
- G.FillRectangle(shadowLGB, New Rectangle(9, 33, Width - 19, 20))
- P1 = New Pen(Color.FromArgb(61, 71, 80))
- DrawBorders(P1, 1)
- DrawBorders(New Pen(New SolidBrush(Color.Black)), ClientRectangle)
- DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, 0)
- End Sub
- End Class
- Class AurumButton
- Inherits ThemeControl153
- Sub New()
- Font = New Font("Verdana", 8.25F)
- End Sub
- Protected Overrides Sub ColorHook()
- End Sub
- Protected Overrides Sub PaintHook()
- Select Case State
- Case 0
- G.Clear(Color.FromArgb(39, 49, 59))
- G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(60, 70, 80))), 2, Height - 1, Width - 2, Height - 1)
- Dim BTNLGB As New LinearGradientBrush(New Rectangle(1, 1, Width - 2, Height / 2 - 2), Color.FromArgb(126, 135, 144), Color.FromArgb(76, 86, 96), 90S)
- G.FillRectangle(BTNLGB, New Rectangle(1, 1, Width - 2, Height / 2 - 2))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(66, 77, 84))), New Rectangle(1, 1, Width - 3, Height - 4))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(19, 29, 39))), New Rectangle(0, 0, Width - 1, Height - 2))
- DrawText(New SolidBrush(Color.FromArgb(222, 222, 222)), HorizontalAlignment.Center, 0, -2)
- Case 1
- G.Clear(Color.FromArgb(43, 53, 63))
- G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(40, 50, 60))), 2, Height - 1, Width - 4, Height - 1)
- Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(1, 1, Width - 2, Height / 2 - 2), Color.FromArgb(140, 149, 155), Color.FromArgb(87, 97, 107), 90S)
- G.FillRectangle(BTNLGBOver, New Rectangle(1, 1, Width - 2, Height / 2 - 2))
- DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, -2)
- Case 2
- G.Clear(Color.FromArgb(30, 40, 50))
- Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(1, 1, Width - 2, Height / 2 - 2), Color.FromArgb(99, 108, 115), Color.FromArgb(46, 56, 66), 90S)
- G.FillRectangle(BTNLGBOver, New Rectangle(1, 1, Width - 2, Height / 2 - 2))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(0, 0, 0))), New Rectangle(1, 1, Width - 3, Height - 4))
- DrawText(New SolidBrush(Color.FromArgb(210, 210, 210)), HorizontalAlignment.Center, 0, -2)
- End Select
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(70, 80, 90))), New Rectangle(1, 1, Width - 3, Height - 4))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(21, 31, 41))), New Rectangle(0, 0, Width - 1, Height - 2))
- End Sub
- End Class
- Class AurumButtonOver
- Inherits ThemeControl153
- Sub New()
- Font = New Font("Verdana", 8.25F)
- End Sub
- Protected Overrides Sub ColorHook()
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(Color.FromArgb(43, 53, 63))
- Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(1, 1, Width - 2, Height / 2 - 2), Color.FromArgb(140, 149, 155), Color.FromArgb(87, 97, 107), 90S)
- G.FillRectangle(BTNLGBOver, New Rectangle(1, 1, Width - 2, Height / 2 - 2))
- 'G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(55, 66, 73))), New Rectangle(1, 1, Width - 3, Height - 4))
- 'G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(21, 31, 41))), New Rectangle(0, 0, Width - 1, Height - 2))
- 'DrawBorders(New Pen(Color.FromArgb(63, 74, 81)), 3)
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(55, 66, 73))), New Rectangle(1, 1, Width - 3, Height - 4))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(21, 31, 41))), New Rectangle(0, 0, Width - 1, Height - 2))
- DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, -2)
- End Sub
- End Class
- Class AurumButtonDown
- Inherits ThemeControl153
- Sub New()
- Font = New Font("Verdana", 8.25F)
- End Sub
- Protected Overrides Sub ColorHook()
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(Color.FromArgb(30, 40, 50))
- Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(1, 1, Width - 2, Height / 2 - 2), Color.FromArgb(99, 108, 115), Color.FromArgb(46, 56, 66), 90S)
- G.FillRectangle(BTNLGBOver, New Rectangle(1, 1, Width - 2, Height / 2 - 2))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(0, 0, 0))), New Rectangle(1, 1, Width - 3, Height - 4))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(55, 66, 73))), New Rectangle(1, 1, Width - 3, Height - 4))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(21, 31, 41))), New Rectangle(0, 0, Width - 1, Height - 2))
- DrawText(New SolidBrush(Color.FromArgb(210, 210, 210)), HorizontalAlignment.Center, 0, -2)
- End Sub
- End Class
- Class AurumPGBar
- Inherits ThemeControl153
- Private GlowAnimation As Timer = New Timer
- Private _GlowColor As Color = Color.FromArgb(90, 255, 255, 255)
- Private _Animate As Boolean = True
- Private _Value As Int32 = 0
- Private _HighlightColor As Color = Color.Silver
- Private _BackgroundColor As Color = Color.FromArgb(150, 150, 150)
- Private _StartColor As Color = Color.FromArgb(110, 110, 110)
- #Region "Properties"
- Public Property Color() As Color
- Get
- Return _StartColor
- End Get
- Set(ByVal value As Color)
- _StartColor = value
- Me.Invalidate()
- End Set
- End Property
- Public Property Animate() As Boolean
- Get
- Return _Animate
- End Get
- Set(ByVal value As Boolean)
- _Animate = value
- If value = True Then
- GlowAnimation.Start()
- Else
- GlowAnimation.Stop()
- End If
- Me.Invalidate()
- End Set
- End Property
- Public Property GlowColor() As Color
- Get
- Return _GlowColor
- End Get
- Set(ByVal value As Color)
- _GlowColor = value
- Me.Invalidate()
- End Set
- End Property
- Public Property Value() As Int32
- Get
- Return _Value
- End Get
- Set(ByVal value As Int32)
- If value > 100 Or value < 0 Then Return
- _Value = value
- If value < 100 Then GlowAnimation.Start()
- If value = 100 Then GlowAnimation.Stop()
- Me.Invalidate()
- End Set
- End Property
- Public Property BackgroundColor() As Color
- Get
- Return _BackgroundColor
- End Get
- Set(ByVal value As Color)
- _BackgroundColor = value
- Me.Invalidate()
- End Set
- End Property
- Public Property HighlightColor() As Color
- Get
- Return _HighlightColor
- End Get
- Set(ByVal value As Color)
- _HighlightColor = value
- Me.Invalidate()
- End Set
- End Property
- #End Region
- Sub New()
- If Not InDesignMode() Then
- GlowAnimation.Interval = 15
- If Value < 100 Then GlowAnimation.Start()
- AddHandler GlowAnimation.Tick, AddressOf GlowAnimation_Tick
- End If
- End Sub
- Private Function InDesignMode() As Boolean
- Return (LicenseManager.UsageMode = LicenseUsageMode.Designtime)
- End Function
- Protected Overrides Sub ColorHook()
- End Sub
- Private _mGlowPosition As Integer = -325
- Protected Overrides Sub PaintHook()
- ' -------------------Draw Background for the MBProgressBar--------------------
- Dim BackRectangle As Rectangle = Me.ClientRectangle
- BackRectangle.Width = BackRectangle.Width - 1
- BackRectangle.Height = BackRectangle.Height - 1
- Dim GrafP As GraphicsPath = RoundRect(BackRectangle, 2, 2, 2, 2)
- G.FillPath(New SolidBrush(Me.BackgroundColor), GrafP)
- '--------------------Draw Background Shadows for MBProgrssBar------------------
- Dim BGSH As Rectangle = New Rectangle(2, 2, 10, Me.Height - 5)
- Dim LGBS As LinearGradientBrush = New LinearGradientBrush(BGSH, Color.FromArgb(0, 30, 60, 50), Color.Transparent, LinearGradientMode.Horizontal)
- G.FillRectangle(LGBS, BGSH)
- Dim BGSRectangle As Rectangle = New Rectangle(Me.Width - 12, 2, 10, Me.Height - 5)
- Dim LG As LinearGradientBrush = New LinearGradientBrush(BGSH, Color.FromArgb(150, 150, 150), Color.FromArgb(0, 10, 30, 20), LinearGradientMode.Horizontal)
- G.FillRectangle(LG, BGSRectangle)
- '----------------------Draw MBProgressBar--------------------
- Dim ProgressRect As Rectangle = New Rectangle(1, 2, Me.Width - 3, Me.Height - 3)
- ProgressRect.Width = CInt((Value * 1.0F / (100) * Me.Width))
- G.FillRectangle(New SolidBrush(Me.Color), ProgressRect)
- '----------------------Draw Shadows for MBProgressBar------------------
- Dim SHRect As Rectangle = New Rectangle(1, 2, 15, Me.Height - 3)
- Dim LGSHP As LinearGradientBrush = New LinearGradientBrush(SHRect, Color.White, Color.White, LinearGradientMode.Horizontal)
- Dim BColor As ColorBlend = New ColorBlend(3)
- BColor.Colors = New Color() {Color.Gray, Color.FromArgb(40, 0, 0, 0), Color.Transparent}
- BColor.Positions = New Single() {0.0F, 0.2F, 1.0F}
- LGSHP.InterpolationColors = BColor
- SHRect.X = SHRect.X - 1
- G.FillRectangle(LGSHP, SHRect)
- Dim Rect1 As Rectangle = New Rectangle(Me.Width - 3, 2, 15, Me.Height - 3)
- Rect1.X = CInt((Value * 1.0F / (100) * Me.Width) - 14)
- Dim LGSH1 As LinearGradientBrush = New LinearGradientBrush(Rect1, Color.Black, Color.Black, LinearGradientMode.Horizontal)
- Dim BColor1 As ColorBlend = New ColorBlend(3)
- BColor1.Colors = New Color() {Color.Transparent, Color.FromArgb(70, 0, 0, 0), Color.Transparent}
- BColor1.Positions = New Single() {0.0F, 0.8F, 1.0F}
- LGSH1.InterpolationColors = BColor1
- G.FillRectangle(LGSH1, Rect1)
- '-------------------------Draw Highlight for MBProgressBar-----------------
- Dim HLRect As Rectangle = New Rectangle(1, 1, Me.Width - 1, 6)
- Dim HLGPa As GraphicsPath = RoundRect(HLRect, 2, 2, 0, 0)
- G.SetClip(HLGPa)
- Dim HLGBS As LinearGradientBrush = New LinearGradientBrush(HLRect, Color.White, Color.FromArgb(128, Color.White), LinearGradientMode.Vertical)
- G.FillPath(HLGBS, HLGPa)
- G.ResetClip()
- Dim HLrect2 As Rectangle = New Rectangle(1, Me.Height - 8, Me.Width - 1, 6)
- Dim bp1 As GraphicsPath = RoundRect(HLrect2, 0, 0, 2, 2)
- G.SetClip(bp1)
- Dim bg1 As LinearGradientBrush = New LinearGradientBrush(HLrect2, Color.Transparent, Color.FromArgb(100, Me.HighlightColor), LinearGradientMode.Vertical)
- G.FillPath(bg1, bp1)
- G.ResetClip()
- '--------------------Draw Inner Sroke for MBProgressBar--------------
- Dim Rect20 As Rectangle = Me.ClientRectangle
- Rect20.X = Rect20.X + 1
- Rect20.Y = Rect20.Y + 1
- Rect20.Width -= 3
- Rect20.Height -= 3
- Dim Rect15 As GraphicsPath = RoundRect(Rect20, 2, 2, 2, 2)
- G.DrawPath(New Pen(Color.FromArgb(100, Color.Black)), Rect15)
- '------------------------Draw Glow for MBProgressBar-----------------------
- Dim GlowRect As Rectangle = New Rectangle(_mGlowPosition, 0, 60, 30)
- Dim GlowLGBS As LinearGradientBrush = New LinearGradientBrush(GlowRect, Color.Gray, Color.Transparent, LinearGradientMode.Horizontal)
- Dim BColor3 As ColorBlend = New ColorBlend(4)
- BColor3.Colors = New Color() {Color.Transparent, Me.GlowColor, Me.GlowColor, Color.Transparent}
- BColor3.Positions = New Single() {0.0F, 0.5F, 0.6F, 1.0F}
- GlowLGBS.InterpolationColors = BColor3
- Dim clip As Rectangle = New Rectangle(1, 2, Me.Width - 3, Me.Height - 3)
- clip.Width = CInt((Value * 1.0F / (100) * Me.Width))
- G.SetClip(clip)
- G.FillRectangle(GlowLGBS, GlowRect)
- G.ResetClip()
- '-----------------------Draw Outer Stroke on the Control----------------------------
- Dim StrokeRect As Rectangle = Me.ClientRectangle
- StrokeRect.Width = StrokeRect.Width - 1
- StrokeRect.Height = StrokeRect.Height - 1
- Dim GGH As GraphicsPath = RoundRect(StrokeRect, 2, 2, 2, 2)
- G.DrawPath(New Pen(Color.FromArgb(100, 100, 100)), GGH)
- DrawCorners(Color.FromArgb(5, 15, 25), ClientRectangle)
- End Sub
- Private Function RoundRect(ByVal r As RectangleF, ByVal r1 As Single, ByVal r2 As Single, ByVal r3 As Single, ByVal r4 As Single) As GraphicsPath
- Dim x As Single = r.X, y As Single = r.Y, w As Single = r.Width, h As Single = r.Height
- Dim rr5 As GraphicsPath = New GraphicsPath
- rr5.AddBezier(x, y + r1, x, y, x + r1, y, x + r1, y)
- rr5.AddLine(x + r1, y, x + w - r2, y)
- rr5.AddBezier(x + w - r2, y, x + w, y, x + w, y + r2, x + w, y + r2)
- rr5.AddLine(x + w, y + r2, x + w, y + h - r3)
- rr5.AddBezier(x + w, y + h - r3, x + w, y + h, x + w - r3, y + h, x + w - r3, y + h)
- rr5.AddLine(x + w - r3, y + h, x + r4, y + h)
- rr5.AddBezier(x + r4, y + h, x, y + h, x, y + h - r4, x, y + h - r4)
- rr5.AddLine(x, y + h - r4, x, y + r1)
- Return rr5
- End Function
- Private Sub GlowAnimation_Tick(ByVal sender As Object, ByVal e As EventArgs)
- If Me.Animate Then
- _mGlowPosition += 4
- If _mGlowPosition > Me.Width Then
- _mGlowPosition = -10
- Me.Invalidate()
- End If
- Else
- GlowAnimation.Stop()
- _mGlowPosition = -50
- End If
- End Sub
- End Class
- Class AurumCheckBox
- Inherits ThemeControl153
- Private _CheckedState As Boolean
- Public Property CheckedState() As Boolean
- Get
- Return _CheckedState
- End Get
- Set(ByVal v As Boolean)
- _CheckedState = v
- Invalidate()
- End Set
- End Property
- Sub New()
- Font = New Font("Verdana", 8.25F)
- Size = New Size(90, 15)
- MinimumSize = New Size(16, 16)
- MaximumSize = New Size(600, 16)
- CheckedState = False
- End Sub
- Protected Overrides Sub ColorHook()
- End Sub
- Dim P1 As Pen = New Pen(Color.FromArgb(20, 20, 20))
- Dim P2 As Pen = New Pen(Color.FromArgb(80, 80, 80))
- Dim InnerRectDown As LinearGradientBrush = New LinearGradientBrush(New Rectangle(4, 4, 9, 9), Color.FromArgb(48, 58, 68), Color.FromArgb(85, 85, 85), 90S)
- Dim InnerRect As LinearGradientBrush = New LinearGradientBrush(New Rectangle(4, 4, 9, 9), Color.FromArgb(61, 71, 81), Color.FromArgb(100, 100, 100), 90S)
- Dim InnerRectCheck As LinearGradientBrush = New LinearGradientBrush(New Rectangle(4, 4, 9, 9), Color.FromArgb(111, 121, 131), Color.FromArgb(160, 170, 180), 90S)
- Protected Overrides Sub PaintHook()
- G.Clear(Color.FromArgb(30, 40, 50))
- Select Case CheckedState
- Case True
- 'G.SmoothingMode = SmoothingMode.HighQuality
- G.FillRectangle(InnerRectCheck, 4, 4, 9, 9)
- G.DrawRectangle(P1, 1, 1, 14, 14)
- G.DrawRectangle(P2, 2, 2, 12, 12)
- DrawText(New SolidBrush(Color.White), HorizontalAlignment.Left, 17, 0)
- Case False
- G.DrawRectangle(P1, 1, 1, 14, 14)
- G.DrawRectangle(P2, 2, 2, 12, 12)
- G.FillRectangle(InnerRect, 4, 4, 9, 9)
- DrawText(New SolidBrush(Color.White), HorizontalAlignment.Left, 17, 0)
- End Select
- Select Case State
- Case 2
- G.FillRectangle(InnerRectDown, 4, 4, 9, 9)
- End Select
- End Sub
- Sub changeCheck() Handles Me.Click
- Select Case CheckedState
- Case True
- CheckedState = False
- Case False
- CheckedState = True
- End Select
- End Sub
- End Class
- Class AurumGroupBox
- Inherits ThemeContainer153
- Sub New()
- Font = New Font("Verdana", 8.25F)
- End Sub
- Protected Overrides Sub ColorHook()
- ControlMode = True
- End Sub
- Dim P1 As Pen
- Protected Overrides Sub PaintHook()
- G.Clear(Color.FromArgb(29, 39, 49))
- G.SmoothingMode = SmoothingMode.HighQuality
- Dim HLGBS2 As New LinearGradientBrush(New Rectangle(0, 0, Width, 24), Color.FromArgb(90, 100, 110), Color.FromArgb(57, 67, 77), 90S)
- Dim HLGBS As New LinearGradientBrush(New Rectangle(0, 0, Width, 12), Color.FromArgb(50, 60, 70), Color.FromArgb(70, 80, 90), 90S)
- G.FillRectangle(HLGBS2, New Rectangle(0, 0, Width, 24))
- G.FillRectangle(HLGBS, New Rectangle(0, 0, Width, 12))
- P1 = New Pen(Color.FromArgb(30, 40, 50))
- G.DrawLine(P1, 0, 24, Width, 24)
- G.DrawRectangle((New Pen(New SolidBrush(Color.FromArgb(61, 71, 81)))), New Rectangle(1, 1, Width - 3, Height - 3))
- G.DrawRectangle((New Pen(New SolidBrush(Color.FromArgb(10, 20, 30)))), New Rectangle(0, 0, Width - 1, Height - 1))
- DrawText(New SolidBrush(Color.GhostWhite), HorizontalAlignment.Center, 0, 0)
- End Sub
- End Class
- Class AuRumRadioB
- Inherits ThemeControl153
- Private _Checked As Boolean = False
- Public Property Checked() As Boolean
- Get
- Return _Checked
- End Get
- Set(ByVal checked As Boolean)
- _Checked = checked
- Invalidate()
- End Set
- End Property
- Private P1 As Pen
- Private P2 As Pen
- Private G1, G2 As LinearGradientBrush
- Private B1 As SolidBrush
- Sub New()
- Size = New Size(133, 11)
- MinimumSize = New Size(16, 16)
- MaximumSize = New Size(138, 13)
- Font = New Font("Verdana", 8.25F)
- End Sub
- Protected Overrides Sub ColorHook()
- P1 = New Pen(Color.FromArgb(90, 100, 110))
- P2 = Pens.Black
- G1 = New LinearGradientBrush(New Rectangle(0, 0, 13, 13), Color.FromArgb(80, 90, 100), Color.FromArgb(35, 45, 55), 30S)
- B1 = New SolidBrush(Color.White)
- 'G2 = New LinearGradientBrush(New Rectangle(4, 4, 5, 5), Color.FromArgb(150, 150, 150), Color.FromArgb(180, 180, 180), 90S)
- End Sub
- Dim Rect1, Rect2, Rect3 As New Rectangle
- Protected Overrides Sub PaintHook()
- G.Clear(Color.FromArgb(30, 40, 50))
- Rect1 = New Rectangle(0, 0, 13, 13)
- Rect2 = New Rectangle(1, 1, 11, 11)
- ' Rect3 = New Rectangle(4, 4, 4, 4)
- If (Checked) Then
- G.DrawEllipse(P2, Rect1)
- G.FillEllipse(G1, Rect1)
- Else
- G.FillEllipse(New LinearGradientBrush(New Rectangle(0, 0, 13, 13), Color.FromArgb(30, 40, 50), Color.FromArgb(5, 15, 25), 30S), Rect1)
- End If
- G.DrawEllipse(P1, Rect2)
- G.DrawEllipse(P2, Rect1)
- DrawText(B1, 14, 0)
- End Sub
- Sub RemoveCheck()
- For Each Ctrl As Control In Parent.Controls
- If TypeOf Ctrl Is AuRumRadioB Then
- If Ctrl.Handle = Me.Handle Then Continue For
- DirectCast(Ctrl, AuRumRadioB).Checked = False
- End If
- Next
- End Sub
- Sub Clicked() Handles Me.MouseClick
- Select Case Checked
- Case False
- Checked = True
- RemoveCheck()
- End Select
- End Sub
- End Class
- Class TopBTN
- Inherits ThemeControl153
- Sub New()
- Font = New Font("Verdana", 8.25F)
- Size = New Size(25, 26)
- End Sub
- Protected Overrides Sub ColorHook()
- End Sub
- Protected Overrides Sub PaintHook()
- Select Case State
- Case 0
- G.Clear(Color.FromArgb(21, 31, 40))
- 'G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(70, 80, 90))), 1, Height - 1, Width - 1, Height - 1)
- Dim BTNLGB As New LinearGradientBrush(New Rectangle(1, 1, Width - 2, Height / 2 - 2), Color.FromArgb(119, 128, 135), Color.FromArgb(61, 71, 80), 90S)
- G.FillRectangle(BTNLGB, New Rectangle(1, 1, Width - 2, Height / 2 - 2))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(30, 40, 50))), New Rectangle(1, 1, Width - 3, Height - 4))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(100, 110, 120))), New Rectangle(0, 0, Width - 1, Height - 2))
- Case 1
- G.Clear(Color.FromArgb(26, 36, 46))
- G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(10, 20, 30))), 2, Height - 1, Width - 2, Height - 1)
- Dim BTNLGB As New LinearGradientBrush(New Rectangle(1, 1, Width - 2, Height / 2 - 2), Color.FromArgb(124, 132, 139), Color.FromArgb(66, 76, 86), 90S)
- G.FillRectangle(BTNLGB, New Rectangle(1, 1, Width - 2, Height / 2 - 2))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(40, 50, 60))), New Rectangle(1, 1, Width - 3, Height - 4))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(110, 120, 130))), New Rectangle(0, 0, Width - 1, Height - 2))
- Case 2
- G.Clear(Color.FromArgb(15, 25, 35))
- G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(10, 20, 30))), 2, Height - 1, Width - 2, Height - 1)
- Dim BTNLGB As New LinearGradientBrush(New Rectangle(1, 1, Width - 2, Height / 2 - 2), Color.FromArgb(124, 132, 139), Color.FromArgb(66, 76, 86), 90S)
- G.FillRectangle(BTNLGB, New Rectangle(1, 1, Width - 2, Height / 2 - 2))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(25, 35, 45))), New Rectangle(1, 1, Width - 3, Height - 4))
- G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(95, 105, 115))), New Rectangle(0, 0, Width - 1, Height - 2))
- End Select
- DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, 0)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement