TWIXXZOR

5Gz VB Theme

Nov 27th, 2011
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System, System.IO, System.Collections.Generic
  2. Imports System.Drawing, System.Drawing.Drawing2D
  3. Imports System.ComponentModel, System.Windows.Forms
  4. Imports System.Runtime.InteropServices
  5. Imports System.Drawing.Imaging
  6.  
  7. '------------------
  8. 'ThemeBase Creator: aeonhack
  9. 'Theme Creator: TWIXXZOR
  10. 'Site: elitevs.net
  11. 'Version: 1.5.3
  12. '------------------
  13.  
  14. MustInherit Class ThemeContainer153
  15.     Inherits ContainerControl
  16.  
  17. #Region " Initialization "
  18.  
  19.     Protected G As Graphics, B As Bitmap
  20.  
  21.     Sub New()
  22.         SetStyle(DirectCast(139270, ControlStyles), True)
  23.  
  24.         _ImageSize = Size.Empty
  25.         Font = New Font("Verdana", 8S)
  26.  
  27.         MeasureBitmap = New Bitmap(1, 1)
  28.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  29.  
  30.         DrawRadialPath = New GraphicsPath
  31.  
  32.         InvalidateCustimization() 'Remove?
  33.    End Sub
  34.  
  35.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  36.         InvalidateCustimization()
  37.         ColorHook()
  38.  
  39.         If Not _LockWidth = 0 Then Width = _LockWidth
  40.         If Not _LockHeight = 0 Then Height = _LockHeight
  41.         If Not _ControlMode Then MyBase.Dock = DockStyle.Fill
  42.  
  43.         Transparent = _Transparent
  44.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  45.  
  46.         MyBase.OnHandleCreated(e)
  47.     End Sub
  48.  
  49.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  50.         MyBase.OnParentChanged(e)
  51.  
  52.         If Parent Is Nothing Then Return
  53.         _IsParentForm = TypeOf Parent Is Form
  54.  
  55.         If Not _ControlMode Then
  56.             InitializeMessages()
  57.  
  58.             If _IsParentForm Then
  59.                 ParentForm.FormBorderStyle = _BorderStyle
  60.                 ParentForm.TransparencyKey = _TransparencyKey
  61.             End If
  62.  
  63.             Parent.BackColor = BackColor
  64.         End If
  65.  
  66.         OnCreation()
  67.     End Sub
  68.  
  69. #End Region
  70.  
  71.  
  72.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  73.         If Width = 0 OrElse Height = 0 Then Return
  74.  
  75.         If _Transparent AndAlso _ControlMode Then
  76.             PaintHook()
  77.             e.Graphics.DrawImage(B, 0, 0)
  78.         Else
  79.             G = e.Graphics
  80.             PaintHook()
  81.         End If
  82.     End Sub
  83.  
  84.  
  85. #Region " Size Handling "
  86.  
  87.     Private Frame As Rectangle
  88.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  89.         If _Movable AndAlso Not _ControlMode Then
  90.             Frame = New Rectangle(7, 7, Width - 14, _Header - 7)
  91.         End If
  92.  
  93.         InvalidateBitmap()
  94.         Invalidate()
  95.  
  96.         MyBase.OnSizeChanged(e)
  97.     End Sub
  98.  
  99.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  100.         If Not _LockWidth = 0 Then width = _LockWidth
  101.         If Not _LockHeight = 0 Then height = _LockHeight
  102.         MyBase.SetBoundsCore(x, y, width, height, specified)
  103.     End Sub
  104.  
  105. #End Region
  106.  
  107. #Region " State Handling "
  108.  
  109.     Protected State As MouseState
  110.     Private Sub SetState(ByVal current As MouseState)
  111.         State = current
  112.         Invalidate()
  113.     End Sub
  114.  
  115.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  116.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
  117.             If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  118.         End If
  119.  
  120.         MyBase.OnMouseMove(e)
  121.     End Sub
  122.  
  123.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  124.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  125.         MyBase.OnEnabledChanged(e)
  126.     End Sub
  127.  
  128.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  129.         SetState(MouseState.Over)
  130.         MyBase.OnMouseEnter(e)
  131.     End Sub
  132.  
  133.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  134.         SetState(MouseState.Over)
  135.         MyBase.OnMouseUp(e)
  136.     End Sub
  137.  
  138.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  139.         SetState(MouseState.None)
  140.  
  141.         If GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
  142.             If _Sizable AndAlso Not _ControlMode Then
  143.                 Cursor = Cursors.Default
  144.                 Previous = 0
  145.             End If
  146.         End If
  147.  
  148.         MyBase.OnMouseLeave(e)
  149.     End Sub
  150.  
  151.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  152.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  153.  
  154.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
  155.             If _Movable AndAlso Frame.Contains(e.Location) Then
  156.                 Capture = False
  157.                 WM_LMBUTTONDOWN = True
  158.                 DefWndProc(Messages(0))
  159.             ElseIf _Sizable AndAlso Not Previous = 0 Then
  160.                 Capture = False
  161.                 WM_LMBUTTONDOWN = True
  162.                 DefWndProc(Messages(Previous))
  163.             End If
  164.         End If
  165.  
  166.         MyBase.OnMouseDown(e)
  167.     End Sub
  168.  
  169.     Private WM_LMBUTTONDOWN As Boolean
  170.     Protected Overrides Sub WndProc(ByRef m As Message)
  171.         MyBase.WndProc(m)
  172.  
  173.         If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
  174.             WM_LMBUTTONDOWN = False
  175.  
  176.             SetState(MouseState.Over)
  177.             If Not _SmartBounds Then Return
  178.  
  179.             If IsParentMdi Then
  180.                 CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
  181.             Else
  182.                 CorrectBounds(Screen.FromControl(Parent).WorkingArea)
  183.             End If
  184.         End If
  185.     End Sub
  186.  
  187.     Private GetIndexPoint As Point
  188.     Private B1, B2, B3, B4 As Boolean
  189.     Private Function GetIndex() As Integer
  190.         GetIndexPoint = PointToClient(MousePosition)
  191.         B1 = GetIndexPoint.X < 7
  192.         B2 = GetIndexPoint.X > Width - 7
  193.         B3 = GetIndexPoint.Y < 7
  194.         B4 = GetIndexPoint.Y > Height - 7
  195.  
  196.         If B1 AndAlso B3 Then Return 4
  197.         If B1 AndAlso B4 Then Return 7
  198.         If B2 AndAlso B3 Then Return 5
  199.         If B2 AndAlso B4 Then Return 8
  200.         If B1 Then Return 1
  201.         If B2 Then Return 2
  202.         If B3 Then Return 3
  203.         If B4 Then Return 6
  204.         Return 0
  205.     End Function
  206.  
  207.     Private Current, Previous As Integer
  208.     Private Sub InvalidateMouse()
  209.         Current = GetIndex()
  210.         If Current = Previous Then Return
  211.  
  212.         Previous = Current
  213.         Select Case Previous
  214.             Case 0
  215.                 Cursor = Cursors.Default
  216.             Case 1, 2
  217.                 Cursor = Cursors.SizeWE
  218.             Case 3, 6
  219.                 Cursor = Cursors.SizeNS
  220.             Case 4, 8
  221.                 Cursor = Cursors.SizeNWSE
  222.             Case 5, 7
  223.                 Cursor = Cursors.SizeNESW
  224.         End Select
  225.     End Sub
  226.  
  227.     Private Messages(8) As Message
  228.     Private Sub InitializeMessages()
  229.         Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  230.         For I As Integer = 1 To 8
  231.             Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
  232.         Next
  233.     End Sub
  234.  
  235.     Private Sub CorrectBounds(ByVal bounds As Rectangle)
  236.         If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
  237.         If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
  238.  
  239.         Dim X As Integer = Parent.Location.X
  240.         Dim Y As Integer = Parent.Location.Y
  241.  
  242.         If X < bounds.X Then X = bounds.X
  243.         If Y < bounds.Y Then Y = bounds.Y
  244.  
  245.         Dim Width As Integer = bounds.X + bounds.Width
  246.         Dim Height As Integer = bounds.Y + bounds.Height
  247.  
  248.         If X + Parent.Width > Width Then X = Width - Parent.Width
  249.         If Y + Parent.Height > Height Then Y = Height - Parent.Height
  250.  
  251.         Parent.Location = New Point(X, Y)
  252.     End Sub
  253.  
  254. #End Region
  255.  
  256.  
  257. #Region " Base Properties "
  258.  
  259.     Overrides Property Dock As DockStyle
  260.         Get
  261.             Return MyBase.Dock
  262.         End Get
  263.         Set(ByVal value As DockStyle)
  264.             If Not _ControlMode Then Return
  265.             MyBase.Dock = value
  266.         End Set
  267.     End Property
  268.  
  269.     Private _BackColor As Boolean
  270.     <Category("Misc")> _
  271.     Overrides Property BackColor() As Color
  272.         Get
  273.             Return MyBase.BackColor
  274.         End Get
  275.         Set(ByVal value As Color)
  276.             If value = MyBase.BackColor Then Return
  277.  
  278.             If Not IsHandleCreated AndAlso _ControlMode AndAlso value = Color.Transparent Then
  279.                 _BackColor = True
  280.                 Return
  281.             End If
  282.  
  283.             MyBase.BackColor = value
  284.             If Parent IsNot Nothing Then
  285.                 If Not _ControlMode Then Parent.BackColor = value
  286.                 ColorHook()
  287.             End If
  288.         End Set
  289.     End Property
  290.  
  291.     Overrides Property MinimumSize As Size
  292.         Get
  293.             Return MyBase.MinimumSize
  294.         End Get
  295.         Set(ByVal value As Size)
  296.             MyBase.MinimumSize = value
  297.             If Parent IsNot Nothing Then Parent.MinimumSize = value
  298.         End Set
  299.     End Property
  300.  
  301.     Overrides Property MaximumSize As Size
  302.         Get
  303.             Return MyBase.MaximumSize
  304.         End Get
  305.         Set(ByVal value As Size)
  306.             MyBase.MaximumSize = value
  307.             If Parent IsNot Nothing Then Parent.MaximumSize = value
  308.         End Set
  309.     End Property
  310.  
  311.     Overrides Property Text() As String
  312.         Get
  313.             Return MyBase.Text
  314.         End Get
  315.         Set(ByVal value As String)
  316.             MyBase.Text = value
  317.             Invalidate()
  318.         End Set
  319.     End Property
  320.  
  321.     Overrides Property Font() As Font
  322.         Get
  323.             Return MyBase.Font
  324.         End Get
  325.         Set(ByVal value As Font)
  326.             MyBase.Font = value
  327.             Invalidate()
  328.         End Set
  329.     End Property
  330.  
  331.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  332.     Overrides Property ForeColor() As Color
  333.         Get
  334.             Return Color.Empty
  335.         End Get
  336.         Set(ByVal value As Color)
  337.         End Set
  338.     End Property
  339.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  340.     Overrides Property BackgroundImage() As Image
  341.         Get
  342.             Return Nothing
  343.         End Get
  344.         Set(ByVal value As Image)
  345.         End Set
  346.     End Property
  347.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  348.     Overrides Property BackgroundImageLayout() As ImageLayout
  349.         Get
  350.             Return ImageLayout.None
  351.         End Get
  352.         Set(ByVal value As ImageLayout)
  353.         End Set
  354.     End Property
  355.  
  356. #End Region
  357.  
  358. #Region " Public Properties "
  359.  
  360.     Private _SmartBounds As Boolean = True
  361.     Property SmartBounds() As Boolean
  362.         Get
  363.             Return _SmartBounds
  364.         End Get
  365.         Set(ByVal value As Boolean)
  366.             _SmartBounds = value
  367.         End Set
  368.     End Property
  369.  
  370.     Private _Movable As Boolean = True
  371.     Property Movable() As Boolean
  372.         Get
  373.             Return _Movable
  374.         End Get
  375.         Set(ByVal value As Boolean)
  376.             _Movable = value
  377.         End Set
  378.     End Property
  379.  
  380.     Private _Sizable As Boolean = True
  381.     Property Sizable() As Boolean
  382.         Get
  383.             Return _Sizable
  384.         End Get
  385.         Set(ByVal value As Boolean)
  386.             _Sizable = value
  387.         End Set
  388.     End Property
  389.  
  390.     Private _TransparencyKey As Color
  391.     Property TransparencyKey() As Color
  392.         Get
  393.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
  394.         End Get
  395.         Set(ByVal value As Color)
  396.             If value = _TransparencyKey Then Return
  397.             _TransparencyKey = value
  398.  
  399.             If _IsParentForm AndAlso Not _ControlMode Then
  400.                 ParentForm.TransparencyKey = value
  401.                 ColorHook()
  402.             End If
  403.         End Set
  404.     End Property
  405.  
  406.     Private _BorderStyle As FormBorderStyle
  407.     Property BorderStyle() As FormBorderStyle
  408.         Get
  409.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
  410.         End Get
  411.         Set(ByVal value As FormBorderStyle)
  412.             _BorderStyle = value
  413.  
  414.             If _IsParentForm AndAlso Not _ControlMode Then
  415.                 ParentForm.FormBorderStyle = value
  416.  
  417.                 If Not value = FormBorderStyle.None Then
  418.                     Movable = False
  419.                     Sizable = False
  420.                 End If
  421.             End If
  422.         End Set
  423.     End Property
  424.  
  425.     Private _NoRounding As Boolean
  426.     Property NoRounding() As Boolean
  427.         Get
  428.             Return _NoRounding
  429.         End Get
  430.         Set(ByVal v As Boolean)
  431.             _NoRounding = v
  432.             Invalidate()
  433.         End Set
  434.     End Property
  435.  
  436.     Private _Image As Image
  437.     Property Image() As Image
  438.         Get
  439.             Return _Image
  440.         End Get
  441.         Set(ByVal value As Image)
  442.             If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size
  443.  
  444.             _Image = value
  445.             Invalidate()
  446.         End Set
  447.     End Property
  448.  
  449.     Private Items As New Dictionary(Of String, Color)
  450.     Property Colors() As Bloom()
  451.         Get
  452.             Dim T As New List(Of Bloom)
  453.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  454.  
  455.             While E.MoveNext
  456.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  457.             End While
  458.  
  459.             Return T.ToArray
  460.         End Get
  461.         Set(ByVal value As Bloom())
  462.             For Each B As Bloom In value
  463.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  464.             Next
  465.  
  466.             InvalidateCustimization()
  467.             ColorHook()
  468.             Invalidate()
  469.         End Set
  470.     End Property
  471.  
  472.     Private _Customization As String
  473.     Property Customization() As String
  474.         Get
  475.             Return _Customization
  476.         End Get
  477.         Set(ByVal value As String)
  478.             If value = _Customization Then Return
  479.  
  480.             Dim Data As Byte()
  481.             Dim Items As Bloom() = Colors
  482.  
  483.             Try
  484.                 Data = Convert.FromBase64String(value)
  485.                 For I As Integer = 0 To Items.Length - 1
  486.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  487.                 Next
  488.             Catch
  489.                 Return
  490.             End Try
  491.  
  492.             _Customization = value
  493.  
  494.             Colors = Items
  495.             ColorHook()
  496.             Invalidate()
  497.         End Set
  498.     End Property
  499.  
  500.     Private _Transparent As Boolean
  501.     Property Transparent() As Boolean
  502.         Get
  503.             Return _Transparent
  504.         End Get
  505.         Set(ByVal value As Boolean)
  506.             _Transparent = value
  507.             If Not (IsHandleCreated OrElse _ControlMode) Then Return
  508.  
  509.             If Not value AndAlso Not BackColor.A = 255 Then
  510.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  511.             End If
  512.  
  513.             SetStyle(ControlStyles.Opaque, Not value)
  514.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  515.  
  516.             InvalidateBitmap()
  517.             Invalidate()
  518.         End Set
  519.     End Property
  520.  
  521. #End Region
  522.  
  523. #Region " Private Properties "
  524.  
  525.     Private _ImageSize As Size
  526.     Protected ReadOnly Property ImageSize() As Size
  527.         Get
  528.             Return _ImageSize
  529.         End Get
  530.     End Property
  531.  
  532.     Private _IsParentForm As Boolean
  533.     Protected ReadOnly Property IsParentForm As Boolean
  534.         Get
  535.             Return _IsParentForm
  536.         End Get
  537.     End Property
  538.  
  539.     Protected ReadOnly Property IsParentMdi As Boolean
  540.         Get
  541.             If Parent Is Nothing Then Return False
  542.             Return Parent.Parent IsNot Nothing
  543.         End Get
  544.     End Property
  545.  
  546.     Private _LockWidth As Integer
  547.     Protected Property LockWidth() As Integer
  548.         Get
  549.             Return _LockWidth
  550.         End Get
  551.         Set(ByVal value As Integer)
  552.             _LockWidth = value
  553.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  554.         End Set
  555.     End Property
  556.  
  557.     Private _LockHeight As Integer
  558.     Protected Property LockHeight() As Integer
  559.         Get
  560.             Return _LockHeight
  561.         End Get
  562.         Set(ByVal value As Integer)
  563.             _LockHeight = value
  564.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  565.         End Set
  566.     End Property
  567.  
  568.     Private _Header As Integer = 24
  569.     Protected Property Header() As Integer
  570.         Get
  571.             Return _Header
  572.         End Get
  573.         Set(ByVal v As Integer)
  574.             _Header = v
  575.  
  576.             If Not _ControlMode Then
  577.                 Frame = New Rectangle(7, 7, Width - 14, v - 7)
  578.                 Invalidate()
  579.             End If
  580.         End Set
  581.     End Property
  582.  
  583.     Private _ControlMode As Boolean
  584.     Protected Property ControlMode() As Boolean
  585.         Get
  586.             Return _ControlMode
  587.         End Get
  588.         Set(ByVal v As Boolean)
  589.             _ControlMode = v
  590.  
  591.             Transparent = _Transparent
  592.             If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  593.  
  594.             InvalidateBitmap()
  595.             Invalidate()
  596.         End Set
  597.     End Property
  598.  
  599. #End Region
  600.  
  601.  
  602. #Region " Property Helpers "
  603.  
  604.     Protected Function GetPen(ByVal name As String) As Pen
  605.         Return New Pen(Items(name))
  606.     End Function
  607.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  608.         Return New Pen(Items(name), width)
  609.     End Function
  610.  
  611.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  612.         Return New SolidBrush(Items(name))
  613.     End Function
  614.  
  615.     Protected Function GetColor(ByVal name As String) As Color
  616.         Return Items(name)
  617.     End Function
  618.  
  619.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  620.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  621.     End Sub
  622.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  623.         SetColor(name, Color.FromArgb(r, g, b))
  624.     End Sub
  625.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  626.         SetColor(name, Color.FromArgb(a, r, g, b))
  627.     End Sub
  628.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  629.         SetColor(name, Color.FromArgb(a, value))
  630.     End Sub
  631.  
  632.     Private Sub InvalidateBitmap()
  633.         If _Transparent AndAlso _ControlMode Then
  634.             If Width = 0 OrElse Height = 0 Then Return
  635.             B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  636.             G = Graphics.FromImage(B)
  637.         Else
  638.             G = Nothing
  639.             B = Nothing
  640.         End If
  641.     End Sub
  642.  
  643.     Private Sub InvalidateCustimization()
  644.         Dim M As New MemoryStream(Items.Count * 4)
  645.  
  646.         For Each B As Bloom In Colors
  647.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  648.         Next
  649.  
  650.         M.Close()
  651.         _Customization = Convert.ToBase64String(M.ToArray)
  652.     End Sub
  653.  
  654. #End Region
  655.  
  656.  
  657. #Region " User Hooks "
  658.  
  659.     Protected MustOverride Sub ColorHook()
  660.     Protected MustOverride Sub PaintHook()
  661.  
  662.     Protected Overridable Sub OnCreation()
  663.     End Sub
  664.  
  665. #End Region
  666.  
  667.  
  668. #Region " Offset "
  669.  
  670.     Private OffsetReturnRectangle As Rectangle
  671.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  672.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  673.         Return OffsetReturnRectangle
  674.     End Function
  675.  
  676.     Private OffsetReturnSize As Size
  677.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  678.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  679.         Return OffsetReturnSize
  680.     End Function
  681.  
  682.     Private OffsetReturnPoint As Point
  683.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  684.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  685.         Return OffsetReturnPoint
  686.     End Function
  687.  
  688. #End Region
  689.  
  690. #Region " Center "
  691.  
  692.     Private CenterReturn As Point
  693.  
  694.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  695.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  696.         Return CenterReturn
  697.     End Function
  698.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  699.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  700.         Return CenterReturn
  701.     End Function
  702.  
  703.     Protected Function Center(ByVal child As Rectangle) As Point
  704.         Return Center(Width, Height, child.Width, child.Height)
  705.     End Function
  706.     Protected Function Center(ByVal child As Size) As Point
  707.         Return Center(Width, Height, child.Width, child.Height)
  708.     End Function
  709.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  710.         Return Center(Width, Height, childWidth, childHeight)
  711.     End Function
  712.  
  713.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  714.         Return Center(p.Width, p.Height, c.Width, c.Height)
  715.     End Function
  716.  
  717.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  718.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  719.         Return CenterReturn
  720.     End Function
  721.  
  722. #End Region
  723.  
  724. #Region " Measure "
  725.  
  726.     Private MeasureBitmap As Bitmap
  727.     Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
  728.  
  729.     Protected Function Measure() As Size
  730.         Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  731.     End Function
  732.     Protected Function Measure(ByVal text As String) As Size
  733.         Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  734.     End Function
  735.  
  736. #End Region
  737.  
  738.  
  739. #Region " DrawPixel "
  740.  
  741.     Private DrawPixelBrush As SolidBrush
  742.  
  743.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  744.         If _Transparent Then
  745.             B.SetPixel(x, y, c1)
  746.         Else
  747.             DrawPixelBrush = New SolidBrush(c1)
  748.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  749.         End If
  750.     End Sub
  751.  
  752. #End Region
  753.  
  754. #Region " DrawCorners "
  755.  
  756.     Private DrawCornersBrush As SolidBrush
  757.  
  758.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  759.         DrawCorners(c1, 0, 0, Width, Height, offset)
  760.     End Sub
  761.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  762.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  763.     End Sub
  764.     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)
  765.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  766.     End Sub
  767.  
  768.     Protected Sub DrawCorners(ByVal c1 As Color)
  769.         DrawCorners(c1, 0, 0, Width, Height)
  770.     End Sub
  771.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  772.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  773.     End Sub
  774.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  775.         If _NoRounding Then Return
  776.  
  777.         If _Transparent Then
  778.             B.SetPixel(x, y, c1)
  779.             B.SetPixel(x + (width - 1), y, c1)
  780.             B.SetPixel(x, y + (height - 1), c1)
  781.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  782.         Else
  783.             DrawCornersBrush = New SolidBrush(c1)
  784.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  785.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  786.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  787.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  788.         End If
  789.     End Sub
  790.  
  791. #End Region
  792.  
  793. #Region " DrawBorders "
  794.  
  795.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  796.         DrawBorders(p1, 0, 0, Width, Height, offset)
  797.     End Sub
  798.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  799.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  800.     End Sub
  801.     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)
  802.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  803.     End Sub
  804.  
  805.     Protected Sub DrawBorders(ByVal p1 As Pen)
  806.         DrawBorders(p1, 0, 0, Width, Height)
  807.     End Sub
  808.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  809.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  810.     End Sub
  811.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  812.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  813.     End Sub
  814.  
  815. #End Region
  816.  
  817. #Region " DrawText "
  818.  
  819.     Private DrawTextPoint As Point
  820.     Private DrawTextSize As Size
  821.  
  822.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  823.         DrawText(b1, Text, a, x, y)
  824.     End Sub
  825.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  826.         If text.Length = 0 Then Return
  827.  
  828.         DrawTextSize = Measure(text)
  829.         DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, Header \ 2 - DrawTextSize.Height \ 2)
  830.  
  831.         Select Case a
  832.             Case HorizontalAlignment.Left
  833.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  834.             Case HorizontalAlignment.Center
  835.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  836.             Case HorizontalAlignment.Right
  837.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  838.         End Select
  839.     End Sub
  840.  
  841.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  842.         If Text.Length = 0 Then Return
  843.         G.DrawString(Text, Font, b1, p1)
  844.     End Sub
  845.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  846.         If Text.Length = 0 Then Return
  847.         G.DrawString(Text, Font, b1, x, y)
  848.     End Sub
  849.  
  850. #End Region
  851.  
  852. #Region " DrawImage "
  853.  
  854.     Private DrawImagePoint As Point
  855.  
  856.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  857.         DrawImage(_Image, a, x, y)
  858.     End Sub
  859.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  860.         If image Is Nothing Then Return
  861.         DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, Header \ 2 - image.Height \ 2)
  862.  
  863.         Select Case a
  864.             Case HorizontalAlignment.Left
  865.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  866.             Case HorizontalAlignment.Center
  867.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  868.             Case HorizontalAlignment.Right
  869.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  870.         End Select
  871.     End Sub
  872.  
  873.     Protected Sub DrawImage(ByVal p1 As Point)
  874.         DrawImage(_Image, p1.X, p1.Y)
  875.     End Sub
  876.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  877.         DrawImage(_Image, x, y)
  878.     End Sub
  879.  
  880.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  881.         DrawImage(image, p1.X, p1.Y)
  882.     End Sub
  883.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  884.         If image Is Nothing Then Return
  885.         G.DrawImage(image, x, y, image.Width, image.Height)
  886.     End Sub
  887.  
  888. #End Region
  889.  
  890. #Region " DrawGradient "
  891.  
  892.     Private DrawGradientBrush As LinearGradientBrush
  893.     Private DrawGradientRectangle As Rectangle
  894.  
  895.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  896.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  897.         DrawGradient(blend, DrawGradientRectangle)
  898.     End Sub
  899.     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)
  900.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  901.         DrawGradient(blend, DrawGradientRectangle, angle)
  902.     End Sub
  903.  
  904.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  905.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  906.         DrawGradientBrush.InterpolationColors = blend
  907.         G.FillRectangle(DrawGradientBrush, r)
  908.     End Sub
  909.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  910.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  911.         DrawGradientBrush.InterpolationColors = blend
  912.         G.FillRectangle(DrawGradientBrush, r)
  913.     End Sub
  914.  
  915.  
  916.     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)
  917.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  918.         DrawGradient(c1, c2, DrawGradientRectangle)
  919.     End Sub
  920.     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)
  921.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  922.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  923.     End Sub
  924.  
  925.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  926.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  927.         G.FillRectangle(DrawGradientBrush, r)
  928.     End Sub
  929.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  930.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  931.         G.FillRectangle(DrawGradientBrush, r)
  932.     End Sub
  933.  
  934. #End Region
  935.  
  936. #Region " DrawRadial "
  937.  
  938.     Private DrawRadialPath As GraphicsPath
  939.     Private DrawRadialBrush1 As PathGradientBrush
  940.     Private DrawRadialBrush2 As LinearGradientBrush
  941.     Private DrawRadialRectangle As Rectangle
  942.  
  943.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  944.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  945.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  946.     End Sub
  947.     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)
  948.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  949.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  950.     End Sub
  951.     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)
  952.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  953.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  954.     End Sub
  955.  
  956.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  957.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  958.     End Sub
  959.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  960.         DrawRadial(blend, r, center.X, center.Y)
  961.     End Sub
  962.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  963.         DrawRadialPath.Reset()
  964.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  965.  
  966.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  967.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  968.         DrawRadialBrush1.InterpolationColors = blend
  969.  
  970.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  971.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  972.         Else
  973.             G.FillEllipse(DrawRadialBrush1, r)
  974.         End If
  975.     End Sub
  976.  
  977.  
  978.     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)
  979.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  980.         DrawRadial(c1, c2, DrawGradientRectangle)
  981.     End Sub
  982.     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)
  983.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  984.         DrawRadial(c1, c2, DrawGradientRectangle, angle)
  985.     End Sub
  986.  
  987.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  988.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  989.         G.FillRectangle(DrawGradientBrush, r)
  990.     End Sub
  991.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  992.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  993.         G.FillEllipse(DrawGradientBrush, r)
  994.     End Sub
  995.  
  996. #End Region
  997.  
  998. End Class
  999.  
  1000. MustInherit Class ThemeControl153
  1001.     Inherits Control
  1002.  
  1003.  
  1004. #Region " Initialization "
  1005.  
  1006.     Protected G As Graphics, B As Bitmap
  1007.  
  1008.     Sub New()
  1009.         SetStyle(DirectCast(139270, ControlStyles), True)
  1010.  
  1011.         _ImageSize = Size.Empty
  1012.         Font = New Font("Verdana", 8S)
  1013.  
  1014.         MeasureBitmap = New Bitmap(1, 1)
  1015.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  1016.  
  1017.         DrawRadialPath = New GraphicsPath
  1018.  
  1019.         InvalidateCustimization() 'Remove?
  1020.    End Sub
  1021.  
  1022.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  1023.         InvalidateCustimization()
  1024.         ColorHook()
  1025.  
  1026.         If Not _LockWidth = 0 Then Width = _LockWidth
  1027.         If Not _LockHeight = 0 Then Height = _LockHeight
  1028.  
  1029.         Transparent = _Transparent
  1030.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  1031.  
  1032.         MyBase.OnHandleCreated(e)
  1033.     End Sub
  1034.  
  1035.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  1036.         If Parent IsNot Nothing Then OnCreation()
  1037.         MyBase.OnParentChanged(e)
  1038.     End Sub
  1039.  
  1040. #End Region
  1041.  
  1042.  
  1043.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1044.         If Width = 0 OrElse Height = 0 Then Return
  1045.  
  1046.         If _Transparent Then
  1047.             PaintHook()
  1048.             e.Graphics.DrawImage(B, 0, 0)
  1049.         Else
  1050.             G = e.Graphics
  1051.             PaintHook()
  1052.         End If
  1053.     End Sub
  1054.  
  1055.  
  1056. #Region " Size Handling "
  1057.  
  1058.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  1059.         If _Transparent Then
  1060.             InvalidateBitmap()
  1061.         End If
  1062.  
  1063.         Invalidate()
  1064.         MyBase.OnSizeChanged(e)
  1065.     End Sub
  1066.  
  1067.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  1068.         If Not _LockWidth = 0 Then width = _LockWidth
  1069.         If Not _LockHeight = 0 Then height = _LockHeight
  1070.         MyBase.SetBoundsCore(x, y, width, height, specified)
  1071.     End Sub
  1072.  
  1073. #End Region
  1074.  
  1075. #Region " State Handling "
  1076.  
  1077.     Private InPosition As Boolean
  1078.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  1079.         InPosition = True
  1080.         SetState(MouseState.Over)
  1081.         MyBase.OnMouseEnter(e)
  1082.     End Sub
  1083.  
  1084.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  1085.         If InPosition Then SetState(MouseState.Over)
  1086.         MyBase.OnMouseUp(e)
  1087.     End Sub
  1088.  
  1089.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  1090.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  1091.         MyBase.OnMouseDown(e)
  1092.     End Sub
  1093.  
  1094.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  1095.         InPosition = False
  1096.         SetState(MouseState.None)
  1097.         MyBase.OnMouseLeave(e)
  1098.     End Sub
  1099.  
  1100.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  1101.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  1102.         MyBase.OnEnabledChanged(e)
  1103.     End Sub
  1104.  
  1105.     Protected State As MouseState
  1106.     Private Sub SetState(ByVal current As MouseState)
  1107.         State = current
  1108.         Invalidate()
  1109.     End Sub
  1110.  
  1111. #End Region
  1112.  
  1113.  
  1114. #Region " Base Properties "
  1115.  
  1116.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1117.     Overrides Property ForeColor() As Color
  1118.         Get
  1119.             Return Color.Empty
  1120.         End Get
  1121.         Set(ByVal value As Color)
  1122.         End Set
  1123.     End Property
  1124.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1125.     Overrides Property BackgroundImage() As Image
  1126.         Get
  1127.             Return Nothing
  1128.         End Get
  1129.         Set(ByVal value As Image)
  1130.         End Set
  1131.     End Property
  1132.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1133.     Overrides Property BackgroundImageLayout() As ImageLayout
  1134.         Get
  1135.             Return ImageLayout.None
  1136.         End Get
  1137.         Set(ByVal value As ImageLayout)
  1138.         End Set
  1139.     End Property
  1140.  
  1141.     Overrides Property Text() As String
  1142.         Get
  1143.             Return MyBase.Text
  1144.         End Get
  1145.         Set(ByVal value As String)
  1146.             MyBase.Text = value
  1147.             Invalidate()
  1148.         End Set
  1149.     End Property
  1150.     Overrides Property Font() As Font
  1151.         Get
  1152.             Return MyBase.Font
  1153.         End Get
  1154.         Set(ByVal value As Font)
  1155.             MyBase.Font = value
  1156.             Invalidate()
  1157.         End Set
  1158.     End Property
  1159.  
  1160.     Private _BackColor As Boolean
  1161.     <Category("Misc")> _
  1162.     Overrides Property BackColor() As Color
  1163.         Get
  1164.             Return MyBase.BackColor
  1165.         End Get
  1166.         Set(ByVal value As Color)
  1167.             If Not IsHandleCreated AndAlso value = Color.Transparent Then
  1168.                 _BackColor = True
  1169.                 Return
  1170.             End If
  1171.  
  1172.             MyBase.BackColor = value
  1173.             If Parent IsNot Nothing Then ColorHook()
  1174.         End Set
  1175.     End Property
  1176.  
  1177. #End Region
  1178.  
  1179. #Region " Public Properties "
  1180.  
  1181.     Private _NoRounding As Boolean
  1182.     Property NoRounding() As Boolean
  1183.         Get
  1184.             Return _NoRounding
  1185.         End Get
  1186.         Set(ByVal v As Boolean)
  1187.             _NoRounding = v
  1188.             Invalidate()
  1189.         End Set
  1190.     End Property
  1191.  
  1192.     Private _Image As Image
  1193.     Property Image() As Image
  1194.         Get
  1195.             Return _Image
  1196.         End Get
  1197.         Set(ByVal value As Image)
  1198.             If value Is Nothing Then
  1199.                 _ImageSize = Size.Empty
  1200.             Else
  1201.                 _ImageSize = value.Size
  1202.             End If
  1203.  
  1204.             _Image = value
  1205.             Invalidate()
  1206.         End Set
  1207.     End Property
  1208.  
  1209.     Private _Transparent As Boolean
  1210.     Property Transparent() As Boolean
  1211.         Get
  1212.             Return _Transparent
  1213.         End Get
  1214.         Set(ByVal value As Boolean)
  1215.             _Transparent = value
  1216.             If Not IsHandleCreated Then Return
  1217.  
  1218.             If Not value AndAlso Not BackColor.A = 255 Then
  1219.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  1220.             End If
  1221.  
  1222.             SetStyle(ControlStyles.Opaque, Not value)
  1223.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  1224.  
  1225.             If value Then InvalidateBitmap() Else B = Nothing
  1226.             Invalidate()
  1227.         End Set
  1228.     End Property
  1229.  
  1230.     Private Items As New Dictionary(Of String, Color)
  1231.     Property Colors() As Bloom()
  1232.         Get
  1233.             Dim T As New List(Of Bloom)
  1234.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  1235.  
  1236.             While E.MoveNext
  1237.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  1238.             End While
  1239.  
  1240.             Return T.ToArray
  1241.         End Get
  1242.         Set(ByVal value As Bloom())
  1243.             For Each B As Bloom In value
  1244.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  1245.             Next
  1246.  
  1247.             InvalidateCustimization()
  1248.             ColorHook()
  1249.             Invalidate()
  1250.         End Set
  1251.     End Property
  1252.  
  1253.     Private _Customization As String
  1254.     Property Customization() As String
  1255.         Get
  1256.             Return _Customization
  1257.         End Get
  1258.         Set(ByVal value As String)
  1259.             If value = _Customization Then Return
  1260.  
  1261.             Dim Data As Byte()
  1262.             Dim Items As Bloom() = Colors
  1263.  
  1264.             Try
  1265.                 Data = Convert.FromBase64String(value)
  1266.                 For I As Integer = 0 To Items.Length - 1
  1267.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  1268.                 Next
  1269.             Catch
  1270.                 Return
  1271.             End Try
  1272.  
  1273.             _Customization = value
  1274.  
  1275.             Colors = Items
  1276.             ColorHook()
  1277.             Invalidate()
  1278.         End Set
  1279.     End Property
  1280.  
  1281. #End Region
  1282.  
  1283. #Region " Private Properties "
  1284.  
  1285.     Private _ImageSize As Size
  1286.     Protected ReadOnly Property ImageSize() As Size
  1287.         Get
  1288.             Return _ImageSize
  1289.         End Get
  1290.     End Property
  1291.  
  1292.     Private _LockWidth As Integer
  1293.     Protected Property LockWidth() As Integer
  1294.         Get
  1295.             Return _LockWidth
  1296.         End Get
  1297.         Set(ByVal value As Integer)
  1298.             _LockWidth = value
  1299.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  1300.         End Set
  1301.     End Property
  1302.  
  1303.     Private _LockHeight As Integer
  1304.     Protected Property LockHeight() As Integer
  1305.         Get
  1306.             Return _LockHeight
  1307.         End Get
  1308.         Set(ByVal value As Integer)
  1309.             _LockHeight = value
  1310.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  1311.         End Set
  1312.     End Property
  1313.  
  1314. #End Region
  1315.  
  1316.  
  1317. #Region " Property Helpers "
  1318.  
  1319.     Protected Function GetPen(ByVal name As String) As Pen
  1320.         Return New Pen(Items(name))
  1321.     End Function
  1322.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  1323.         Return New Pen(Items(name), width)
  1324.     End Function
  1325.  
  1326.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  1327.         Return New SolidBrush(Items(name))
  1328.     End Function
  1329.  
  1330.     Protected Function GetColor(ByVal name As String) As Color
  1331.         Return Items(name)
  1332.     End Function
  1333.  
  1334.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  1335.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  1336.     End Sub
  1337.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1338.         SetColor(name, Color.FromArgb(r, g, b))
  1339.     End Sub
  1340.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1341.         SetColor(name, Color.FromArgb(a, r, g, b))
  1342.     End Sub
  1343.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  1344.         SetColor(name, Color.FromArgb(a, value))
  1345.     End Sub
  1346.  
  1347.     Private Sub InvalidateBitmap()
  1348.         If Width = 0 OrElse Height = 0 Then Return
  1349.         B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  1350.         G = Graphics.FromImage(B)
  1351.     End Sub
  1352.  
  1353.     Private Sub InvalidateCustimization()
  1354.         Dim M As New MemoryStream(Items.Count * 4)
  1355.  
  1356.         For Each B As Bloom In Colors
  1357.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1358.         Next
  1359.  
  1360.         M.Close()
  1361.         _Customization = Convert.ToBase64String(M.ToArray)
  1362.     End Sub
  1363.  
  1364. #End Region
  1365.  
  1366.  
  1367. #Region " User Hooks "
  1368.  
  1369.     Protected MustOverride Sub ColorHook()
  1370.     Protected MustOverride Sub PaintHook()
  1371.  
  1372.     Protected Overridable Sub OnCreation()
  1373.     End Sub
  1374.  
  1375. #End Region
  1376.  
  1377.  
  1378. #Region " Offset "
  1379.  
  1380.     Private OffsetReturnRectangle As Rectangle
  1381.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  1382.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  1383.         Return OffsetReturnRectangle
  1384.     End Function
  1385.  
  1386.     Private OffsetReturnSize As Size
  1387.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  1388.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  1389.         Return OffsetReturnSize
  1390.     End Function
  1391.  
  1392.     Private OffsetReturnPoint As Point
  1393.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  1394.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  1395.         Return OffsetReturnPoint
  1396.     End Function
  1397.  
  1398. #End Region
  1399.  
  1400. #Region " Center "
  1401.  
  1402.     Private CenterReturn As Point
  1403.  
  1404.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  1405.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  1406.         Return CenterReturn
  1407.     End Function
  1408.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  1409.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  1410.         Return CenterReturn
  1411.     End Function
  1412.  
  1413.     Protected Function Center(ByVal child As Rectangle) As Point
  1414.         Return Center(Width, Height, child.Width, child.Height)
  1415.     End Function
  1416.     Protected Function Center(ByVal child As Size) As Point
  1417.         Return Center(Width, Height, child.Width, child.Height)
  1418.     End Function
  1419.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  1420.         Return Center(Width, Height, childWidth, childHeight)
  1421.     End Function
  1422.  
  1423.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  1424.         Return Center(p.Width, p.Height, c.Width, c.Height)
  1425.     End Function
  1426.  
  1427.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  1428.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  1429.         Return CenterReturn
  1430.     End Function
  1431.  
  1432. #End Region
  1433.  
  1434. #Region " Measure "
  1435.  
  1436.     Private MeasureBitmap As Bitmap
  1437.     Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
  1438.  
  1439.     Protected Function Measure() As Size
  1440.         Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  1441.     End Function
  1442.     Protected Function Measure(ByVal text As String) As Size
  1443.         Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  1444.     End Function
  1445.  
  1446. #End Region
  1447.  
  1448.  
  1449. #Region " DrawPixel "
  1450.  
  1451.     Private DrawPixelBrush As SolidBrush
  1452.  
  1453.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  1454.         If _Transparent Then
  1455.             B.SetPixel(x, y, c1)
  1456.         Else
  1457.             DrawPixelBrush = New SolidBrush(c1)
  1458.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  1459.         End If
  1460.     End Sub
  1461.  
  1462. #End Region
  1463.  
  1464. #Region " DrawCorners "
  1465.  
  1466.     Private DrawCornersBrush As SolidBrush
  1467.  
  1468.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  1469.         DrawCorners(c1, 0, 0, Width, Height, offset)
  1470.     End Sub
  1471.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  1472.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  1473.     End Sub
  1474.     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)
  1475.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1476.     End Sub
  1477.  
  1478.     Protected Sub DrawCorners(ByVal c1 As Color)
  1479.         DrawCorners(c1, 0, 0, Width, Height)
  1480.     End Sub
  1481.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  1482.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  1483.     End Sub
  1484.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1485.         If _NoRounding Then Return
  1486.  
  1487.         If _Transparent Then
  1488.             B.SetPixel(x, y, c1)
  1489.             B.SetPixel(x + (width - 1), y, c1)
  1490.             B.SetPixel(x, y + (height - 1), c1)
  1491.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  1492.         Else
  1493.             DrawCornersBrush = New SolidBrush(c1)
  1494.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  1495.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  1496.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  1497.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  1498.         End If
  1499.     End Sub
  1500.  
  1501. #End Region
  1502.  
  1503. #Region " DrawBorders "
  1504.  
  1505.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  1506.         DrawBorders(p1, 0, 0, Width, Height, offset)
  1507.     End Sub
  1508.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  1509.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  1510.     End Sub
  1511.     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)
  1512.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1513.     End Sub
  1514.  
  1515.     Protected Sub DrawBorders(ByVal p1 As Pen)
  1516.         DrawBorders(p1, 0, 0, Width, Height)
  1517.     End Sub
  1518.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  1519.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  1520.     End Sub
  1521.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1522.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  1523.     End Sub
  1524.  
  1525. #End Region
  1526.  
  1527. #Region " DrawText "
  1528.  
  1529.     Private DrawTextPoint As Point
  1530.     Private DrawTextSize As Size
  1531.  
  1532.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1533.         DrawText(b1, Text, a, x, y)
  1534.     End Sub
  1535.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1536.         If text.Length = 0 Then Return
  1537.  
  1538.         DrawTextSize = Measure(text)
  1539.         DrawTextPoint = Center(DrawTextSize)
  1540.  
  1541.         Select Case a
  1542.             Case HorizontalAlignment.Left
  1543.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  1544.             Case HorizontalAlignment.Center
  1545.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  1546.             Case HorizontalAlignment.Right
  1547.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  1548.         End Select
  1549.     End Sub
  1550.  
  1551.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  1552.         If Text.Length = 0 Then Return
  1553.         G.DrawString(Text, Font, b1, p1)
  1554.     End Sub
  1555.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  1556.         If Text.Length = 0 Then Return
  1557.         G.DrawString(Text, Font, b1, x, y)
  1558.     End Sub
  1559.  
  1560. #End Region
  1561.  
  1562. #Region " DrawImage "
  1563.  
  1564.     Private DrawImagePoint As Point
  1565.  
  1566.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1567.         DrawImage(_Image, a, x, y)
  1568.     End Sub
  1569.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1570.         If image Is Nothing Then Return
  1571.         DrawImagePoint = Center(image.Size)
  1572.  
  1573.         Select Case a
  1574.             Case HorizontalAlignment.Left
  1575.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  1576.             Case HorizontalAlignment.Center
  1577.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  1578.             Case HorizontalAlignment.Right
  1579.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  1580.         End Select
  1581.     End Sub
  1582.  
  1583.     Protected Sub DrawImage(ByVal p1 As Point)
  1584.         DrawImage(_Image, p1.X, p1.Y)
  1585.     End Sub
  1586.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  1587.         DrawImage(_Image, x, y)
  1588.     End Sub
  1589.  
  1590.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  1591.         DrawImage(image, p1.X, p1.Y)
  1592.     End Sub
  1593.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  1594.         If image Is Nothing Then Return
  1595.         G.DrawImage(image, x, y, image.Width, image.Height)
  1596.     End Sub
  1597.  
  1598. #End Region
  1599.  
  1600. #Region " DrawGradient "
  1601.  
  1602.     Private DrawGradientBrush As LinearGradientBrush
  1603.     Private DrawGradientRectangle As Rectangle
  1604.  
  1605.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1606.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1607.         DrawGradient(blend, DrawGradientRectangle)
  1608.     End Sub
  1609.     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)
  1610.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1611.         DrawGradient(blend, DrawGradientRectangle, angle)
  1612.     End Sub
  1613.  
  1614.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1615.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  1616.         DrawGradientBrush.InterpolationColors = blend
  1617.         G.FillRectangle(DrawGradientBrush, r)
  1618.     End Sub
  1619.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1620.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1621.         DrawGradientBrush.InterpolationColors = blend
  1622.         G.FillRectangle(DrawGradientBrush, r)
  1623.     End Sub
  1624.  
  1625.  
  1626.     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)
  1627.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1628.         DrawGradient(c1, c2, DrawGradientRectangle)
  1629.     End Sub
  1630.     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)
  1631.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1632.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1633.     End Sub
  1634.  
  1635.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1636.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1637.         G.FillRectangle(DrawGradientBrush, r)
  1638.     End Sub
  1639.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1640.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1641.         G.FillRectangle(DrawGradientBrush, r)
  1642.     End Sub
  1643.  
  1644. #End Region
  1645.  
  1646. #Region " DrawRadial "
  1647.  
  1648.     Private DrawRadialPath As GraphicsPath
  1649.     Private DrawRadialBrush1 As PathGradientBrush
  1650.     Private DrawRadialBrush2 As LinearGradientBrush
  1651.     Private DrawRadialRectangle As Rectangle
  1652.  
  1653.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1654.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1655.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1656.     End Sub
  1657.     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)
  1658.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1659.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1660.     End Sub
  1661.     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)
  1662.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1663.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1664.     End Sub
  1665.  
  1666.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1667.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1668.     End Sub
  1669.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1670.         DrawRadial(blend, r, center.X, center.Y)
  1671.     End Sub
  1672.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1673.         DrawRadialPath.Reset()
  1674.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1675.  
  1676.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1677.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1678.         DrawRadialBrush1.InterpolationColors = blend
  1679.  
  1680.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1681.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1682.         Else
  1683.             G.FillEllipse(DrawRadialBrush1, r)
  1684.         End If
  1685.     End Sub
  1686.  
  1687.  
  1688.     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)
  1689.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1690.         DrawRadial(c1, c2, DrawRadialRectangle)
  1691.     End Sub
  1692.     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)
  1693.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1694.         DrawRadial(c1, c2, DrawRadialRectangle, angle)
  1695.     End Sub
  1696.  
  1697.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1698.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1699.         G.FillEllipse(DrawRadialBrush2, r)
  1700.     End Sub
  1701.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1702.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1703.         G.FillEllipse(DrawRadialBrush2, r)
  1704.     End Sub
  1705.  
  1706. #End Region
  1707.  
  1708. End Class
  1709.  
  1710. Enum MouseState As Byte
  1711.     None = 0
  1712.     Over = 1
  1713.     Down = 2
  1714.     Block = 3
  1715. End Enum
  1716.  
  1717. Structure Bloom
  1718.  
  1719.     Public _Name As String
  1720.     ReadOnly Property Name() As String
  1721.         Get
  1722.             Return _Name
  1723.         End Get
  1724.     End Property
  1725.  
  1726.     Private _Value As Color
  1727.     Property Value() As Color
  1728.         Get
  1729.             Return _Value
  1730.         End Get
  1731.         Set(ByVal value As Color)
  1732.             _Value = value
  1733.         End Set
  1734.     End Property
  1735.  
  1736.     Sub New(ByVal name As String, ByVal value As Color)
  1737.         _Name = name
  1738.         _Value = value
  1739.     End Sub
  1740. End Structure
  1741.  
  1742. Class Theme
  1743.     Inherits ThemeContainer153
  1744.     Sub New()
  1745.         SetColor("tW", 204, 204, 204)
  1746.         SetColor("tLB", 0, 213, 238)
  1747.         SetColor("tDB", 0, 102, 176)
  1748.     End Sub
  1749.     Dim W, LB, DB As Color
  1750.     Protected Overrides Sub ColorHook()
  1751.         TransparencyKey = Color.Bisque
  1752.         Header = 20
  1753.         W = GetColor("tW")
  1754.         LB = GetColor("tLB")
  1755.         DB = GetColor("tDB")
  1756.     End Sub
  1757.  
  1758.     Protected Overrides Sub PaintHook()
  1759.         DrawBorders(Pens.Gray)
  1760.         DrawGradient(Color.White, W, 0, 0, Width, Height)
  1761.         G.DrawLine(Pens.Black, 11, 0, 11, Height)
  1762.         DrawGradient(LB, DB, 0, 0, 11, Height)
  1763.         G.DrawLine(Pens.Black, Width - 12, 0, Width - 12, Height)
  1764.         DrawGradient(LB, DB, 12, Height - 12, Width - 24, 12)
  1765.         G.DrawLine(Pens.Black, 11, Height - 12, Width - 12, Height - 12)
  1766.         DrawGradient(LB, DB, Width - 11, 0, 11, Height)
  1767.         DrawGradient(LB, DB, 11, 3, Width - 12, 3)
  1768.         DrawGradient(LB, DB, 0, 0, Width, 20)
  1769.         DrawBorders(Pens.DeepSkyBlue, 0, 0, Width, 21)
  1770.         DrawBorders(Pens.Black, 0, 0, Width, 22)
  1771.         DrawBorders(Pens.Black)
  1772.         DrawText(Brushes.White, HorizontalAlignment.Center, 0, 0)
  1773.     End Sub
  1774. End Class
  1775.  
  1776. Class Button
  1777.     Inherits ThemeControl153
  1778.     Sub New()
  1779.         SetColor("tLB", 0, 213, 238)
  1780.         SetColor("tDB", 0, 102, 176)
  1781.         SetColor("tLLB", 0, 223, 248)
  1782.         SetColor("tLDB", 0, 112, 186)
  1783.         SetColor("tDLB", 0, 203, 218)
  1784.         SetColor("tDDB", 0, 92, 166)
  1785.     End Sub
  1786.     Dim LB, DB, LLB, LDB, DLB, DDB As Color
  1787.     Protected Overrides Sub ColorHook()
  1788.         LB = GetColor("tLB")
  1789.         DB = GetColor("tDB")
  1790.         LLB = GetColor("tLLB")
  1791.         LDB = GetColor("tLDB")
  1792.         DLB = GetColor("tDLB")
  1793.         DDB = GetColor("tDDB")
  1794.     End Sub
  1795.  
  1796.     Protected Overrides Sub PaintHook()
  1797.         G.Clear(Color.DodgerBlue)
  1798.  
  1799.         If State = MouseState.None Then
  1800.             DrawGradient(LB, DB, 0, 0, Width, Height, 90S)
  1801.         ElseIf State = MouseState.Over Then
  1802.             DrawGradient(LLB, LDB, 0, 0, Width, Height, 90S)
  1803.         ElseIf State = MouseState.Down Then
  1804.             DrawGradient(DLB, DDB, 0, 0, Width, Height, 90S)
  1805.         End If
  1806.         DrawBorders(Pens.Black, 0)
  1807.         DrawBorders(Pens.DeepSkyBlue, 1)
  1808.         DrawText(Brushes.White, HorizontalAlignment.Center, 0, 0)
  1809.     End Sub
  1810. End Class
  1811.  
  1812. Class ProgressBar
  1813.     Inherits ThemeControl153
  1814.     Sub New()
  1815.  
  1816.         SetColor("tW", 204, 204, 204)
  1817.         SetColor("tLB", 0, 213, 238)
  1818.         SetColor("tDB", 0, 102, 176)
  1819.     End Sub
  1820.  
  1821.     Private _Maximum As Integer
  1822.     Public Property Maximum() As Integer
  1823.         Get
  1824.             Select Case _Maximum
  1825.                 Case 0
  1826.                     Return 100
  1827.                 Case Else
  1828.                     Return _Maximum
  1829.             End Select
  1830.         End Get
  1831.         Set(ByVal v As Integer)
  1832.             Select Case v
  1833.                 Case Is < _Value
  1834.                     _Value = v
  1835.             End Select
  1836.             _Maximum = v
  1837.             Invalidate()
  1838.         End Set
  1839.     End Property
  1840.     Private _Value As Integer
  1841.     Public Property Value() As Integer
  1842.         Get
  1843.             Select Case _Value
  1844.                 Case 0
  1845.                     Return 1
  1846.                 Case Else
  1847.                     Return _Value
  1848.             End Select
  1849.         End Get
  1850.         Set(ByVal v As Integer)
  1851.             Select Case v
  1852.                 Case Is > _Maximum
  1853.                     v = _Maximum
  1854.             End Select
  1855.             _Value = v
  1856.             Invalidate()
  1857.         End Set
  1858.     End Property
  1859.  
  1860.     Dim LB, DB, W As Color
  1861.     Private Progress As Integer
  1862.     Dim Blend As New ColorBlend
  1863.     Protected Overrides Sub ColorHook()
  1864.         LB = GetColor("tLB")
  1865.         DB = GetColor("tDB")
  1866.         W = GetColor("tW")
  1867.     End Sub
  1868.  
  1869.     Protected Overrides Sub PaintHook()
  1870.         DrawGradient(Color.White, W, ClientRectangle)
  1871.         DrawBorders(Pens.Black)
  1872.         Dim a As New ColorBlend
  1873.         a.Colors = {LB, DB}
  1874.         a.Positions = {0.0F, 1.0F}
  1875.         G.FillRectangle(Brushes.DimGray, 3, 3, Width - 6, Height - 6)
  1876.         DrawGradient(a, 3, 3, CInt(_Value / _Maximum * Width) - 5, Height - 6, 90S)
  1877.         DrawBorders(Pens.DeepSkyBlue, 4, 4, CInt(_Value / _Maximum * Width) - 5, Height - 8)
  1878.         DrawBorders(Pens.Black, 3)
  1879.     End Sub
  1880. End Class
  1881.  
  1882. Class TopButton
  1883.     Inherits ThemeControl153
  1884.     Sub New()
  1885.         SetColor("tLB", 0, 223, 248)
  1886.         SetColor("tDB", 0, 112, 186)
  1887.         SetColor("tLLB", 0, 233, 255)
  1888.         SetColor("tLDB", 0, 122, 196)
  1889.         SetColor("tDLB", 0, 203, 218)
  1890.         SetColor("tDDB", 0, 92, 166)
  1891.         Size = New Size(20, 14)
  1892.     End Sub
  1893.     Dim LB, DB, LLB, LDB, DLB, DDB As Color
  1894.     Protected Overrides Sub ColorHook()
  1895.         LB = GetColor("tLB")
  1896.         DB = GetColor("tDB")
  1897.         LLB = GetColor("tLLB")
  1898.         LDB = GetColor("tLDB")
  1899.         DLB = GetColor("tDLB")
  1900.         DDB = GetColor("tDDB")
  1901.     End Sub
  1902.  
  1903.     Protected Overrides Sub PaintHook()
  1904.         If State = MouseState.None Then
  1905.             DrawGradient(LB, DB, ClientRectangle)
  1906.         ElseIf State = MouseState.Down Then
  1907.             DrawGradient(DLB, DDB, ClientRectangle)
  1908.         ElseIf State = MouseState.Over Then
  1909.             DrawGradient(LLB, LDB, ClientRectangle)
  1910.         End If
  1911.         DrawBorders(Pens.Black)
  1912.         DrawBorders(Pens.DeepSkyBlue, 1)
  1913.         DrawText(Brushes.White, HorizontalAlignment.Center, -1, 0)
  1914.     End Sub
  1915. End Class
  1916.  
  1917. Class CheckBox
  1918.     Inherits ThemeControl153
  1919.     Private _CheckedState As Boolean
  1920.     Public Property CheckedState() As Boolean
  1921.         Get
  1922.             Return _CheckedState
  1923.         End Get
  1924.         Set(ByVal v As Boolean)
  1925.             _CheckedState = v
  1926.             Invalidate()
  1927.         End Set
  1928.     End Property
  1929.  
  1930.     Sub New()
  1931.         SetColor("tLB", 0, 223, 248)
  1932.         SetColor("tDB", 0, 112, 186)
  1933.         SetColor("tW", 204, 204, 204)
  1934.         Size = New Size(18, 18)
  1935.         MinimumSize = New Size(15, 15)
  1936.         MaximumSize = New Size(600, 30)
  1937.     End Sub
  1938.     Dim LB, DB, W As Color
  1939.     Protected Overrides Sub ColorHook()
  1940.         LB = GetColor("tLB")
  1941.         DB = GetColor("tDB")
  1942.         W = GetColor("tW")
  1943.     End Sub
  1944.  
  1945.     Protected Overrides Sub PaintHook()
  1946.         DrawGradient(Color.White, W, ClientRectangle)
  1947.         G.FillRectangle(Brushes.DimGray, 3, 3, Width - 6, Height - 6)
  1948.         DrawBorders(Pens.Black)
  1949.         DrawBorders(Pens.Black, 3)
  1950.         Select Case CheckedState
  1951.             Case True
  1952.                 DrawGradient(LB, DB, 4, 4, 10, 10)
  1953.             Case False
  1954.         End Select
  1955.  
  1956.     End Sub
  1957.     Sub changeCheck() Handles Me.Click
  1958.         Select Case CheckedState
  1959.             Case True
  1960.                 CheckedState = False
  1961.             Case False
  1962.                 CheckedState = True
  1963.         End Select
  1964.     End Sub
  1965. End Class
  1966.  
  1967.  
Advertisement
Add Comment
Please, Sign In to add comment