RidanCoded

VB.NET XPTheme V1.0 (New, Simple and small)

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