trewq343

Theme Base 1.5.3 VB.NET

Nov 6th, 2011
1,439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 58.85 KB | None | 0 0
  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. 'Creator: aeonhack
  9. 'Created: 08/02/2011
  10. 'Changed: 10/9/2011
  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.             MyBase.BackColor = value
  1172.             If Parent IsNot Nothing Then ColorHook()
  1173.         End Set
  1174.     End Property
  1175.  
  1176. #End Region
  1177.  
  1178. #Region " Public Properties "
  1179.  
  1180.     Private _NoRounding As Boolean
  1181.     Property NoRounding() As Boolean
  1182.         Get
  1183.             Return _NoRounding
  1184.         End Get
  1185.         Set(ByVal v As Boolean)
  1186.             _NoRounding = v
  1187.             Invalidate()
  1188.         End Set
  1189.     End Property
  1190.  
  1191.     Private _Image As Image
  1192.     Property Image() As Image
  1193.         Get
  1194.             Return _Image
  1195.         End Get
  1196.         Set(ByVal value As Image)
  1197.             If value Is Nothing Then
  1198.                 _ImageSize = Size.Empty
  1199.             Else
  1200.                 _ImageSize = value.Size
  1201.             End If
  1202.  
  1203.             _Image = value
  1204.             Invalidate()
  1205.         End Set
  1206.     End Property
  1207.  
  1208.     Private _Transparent As Boolean
  1209.     Property Transparent() As Boolean
  1210.         Get
  1211.             Return _Transparent
  1212.         End Get
  1213.         Set(ByVal value As Boolean)
  1214.             _Transparent = value
  1215.             If Not IsHandleCreated Then Return
  1216.  
  1217.             If Not value AndAlso Not BackColor.A = 255 Then
  1218.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  1219.             End If
  1220.  
  1221.             SetStyle(ControlStyles.Opaque, Not value)
  1222.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  1223.  
  1224.             If value Then InvalidateBitmap() Else B = Nothing
  1225.             Invalidate()
  1226.         End Set
  1227.     End Property
  1228.  
  1229.     Private Items As New Dictionary(Of String, Color)
  1230.     Property Colors() As Bloom()
  1231.         Get
  1232.             Dim T As New List(Of Bloom)
  1233.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  1234.  
  1235.             While E.MoveNext
  1236.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  1237.             End While
  1238.  
  1239.             Return T.ToArray
  1240.         End Get
  1241.         Set(ByVal value As Bloom())
  1242.             For Each B As Bloom In value
  1243.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  1244.             Next
  1245.  
  1246.             InvalidateCustimization()
  1247.             ColorHook()
  1248.             Invalidate()
  1249.         End Set
  1250.     End Property
  1251.  
  1252.     Private _Customization As String
  1253.     Property Customization() As String
  1254.         Get
  1255.             Return _Customization
  1256.         End Get
  1257.         Set(ByVal value As String)
  1258.             If value = _Customization Then Return
  1259.  
  1260.             Dim Data As Byte()
  1261.             Dim Items As Bloom() = Colors
  1262.  
  1263.             Try
  1264.                 Data = Convert.FromBase64String(value)
  1265.                 For I As Integer = 0 To Items.Length - 1
  1266.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  1267.                 Next
  1268.             Catch
  1269.                 Return
  1270.             End Try
  1271.  
  1272.             _Customization = value
  1273.  
  1274.             Colors = Items
  1275.             ColorHook()
  1276.             Invalidate()
  1277.         End Set
  1278.     End Property
  1279.  
  1280. #End Region
  1281.  
  1282. #Region " Private Properties "
  1283.  
  1284.     Private _ImageSize As Size
  1285.     Protected ReadOnly Property ImageSize() As Size
  1286.         Get
  1287.             Return _ImageSize
  1288.         End Get
  1289.     End Property
  1290.  
  1291.     Private _LockWidth As Integer
  1292.     Protected Property LockWidth() As Integer
  1293.         Get
  1294.             Return _LockWidth
  1295.         End Get
  1296.         Set(ByVal value As Integer)
  1297.             _LockWidth = value
  1298.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  1299.         End Set
  1300.     End Property
  1301.  
  1302.     Private _LockHeight As Integer
  1303.     Protected Property LockHeight() As Integer
  1304.         Get
  1305.             Return _LockHeight
  1306.         End Get
  1307.         Set(ByVal value As Integer)
  1308.             _LockHeight = value
  1309.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  1310.         End Set
  1311.     End Property
  1312.  
  1313. #End Region
  1314.  
  1315.  
  1316. #Region " Property Helpers "
  1317.  
  1318.     Protected Function GetPen(ByVal name As String) As Pen
  1319.         Return New Pen(Items(name))
  1320.     End Function
  1321.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  1322.         Return New Pen(Items(name), width)
  1323.     End Function
  1324.  
  1325.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  1326.         Return New SolidBrush(Items(name))
  1327.     End Function
  1328.  
  1329.     Protected Function GetColor(ByVal name As String) As Color
  1330.         Return Items(name)
  1331.     End Function
  1332.  
  1333.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  1334.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  1335.     End Sub
  1336.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1337.         SetColor(name, Color.FromArgb(r, g, b))
  1338.     End Sub
  1339.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1340.         SetColor(name, Color.FromArgb(a, r, g, b))
  1341.     End Sub
  1342.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  1343.         SetColor(name, Color.FromArgb(a, value))
  1344.     End Sub
  1345.  
  1346.     Private Sub InvalidateBitmap()
  1347.         If Width = 0 OrElse Height = 0 Then Return
  1348.         B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  1349.         G = Graphics.FromImage(B)
  1350.     End Sub
  1351.  
  1352.     Private Sub InvalidateCustimization()
  1353.         Dim M As New MemoryStream(Items.Count * 4)
  1354.  
  1355.         For Each B As Bloom In Colors
  1356.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1357.         Next
  1358.  
  1359.         M.Close()
  1360.         _Customization = Convert.ToBase64String(M.ToArray)
  1361.     End Sub
  1362.  
  1363. #End Region
  1364.  
  1365.  
  1366. #Region " User Hooks "
  1367.  
  1368.     Protected MustOverride Sub ColorHook()
  1369.     Protected MustOverride Sub PaintHook()
  1370.  
  1371.     Protected Overridable Sub OnCreation()
  1372.     End Sub
  1373.  
  1374. #End Region
  1375.  
  1376.  
  1377. #Region " Offset "
  1378.  
  1379.     Private OffsetReturnRectangle As Rectangle
  1380.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  1381.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  1382.         Return OffsetReturnRectangle
  1383.     End Function
  1384.  
  1385.     Private OffsetReturnSize As Size
  1386.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  1387.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  1388.         Return OffsetReturnSize
  1389.     End Function
  1390.  
  1391.     Private OffsetReturnPoint As Point
  1392.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  1393.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  1394.         Return OffsetReturnPoint
  1395.     End Function
  1396.  
  1397. #End Region
  1398.  
  1399. #Region " Center "
  1400.  
  1401.     Private CenterReturn As Point
  1402.  
  1403.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  1404.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  1405.         Return CenterReturn
  1406.     End Function
  1407.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  1408.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  1409.         Return CenterReturn
  1410.     End Function
  1411.  
  1412.     Protected Function Center(ByVal child As Rectangle) As Point
  1413.         Return Center(Width, Height, child.Width, child.Height)
  1414.     End Function
  1415.     Protected Function Center(ByVal child As Size) As Point
  1416.         Return Center(Width, Height, child.Width, child.Height)
  1417.     End Function
  1418.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  1419.         Return Center(Width, Height, childWidth, childHeight)
  1420.     End Function
  1421.  
  1422.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  1423.         Return Center(p.Width, p.Height, c.Width, c.Height)
  1424.     End Function
  1425.  
  1426.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  1427.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  1428.         Return CenterReturn
  1429.     End Function
  1430.  
  1431. #End Region
  1432.  
  1433. #Region " Measure "
  1434.  
  1435.     Private MeasureBitmap As Bitmap
  1436.     Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
  1437.  
  1438.     Protected Function Measure() As Size
  1439.         Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  1440.     End Function
  1441.     Protected Function Measure(ByVal text As String) As Size
  1442.         Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  1443.     End Function
  1444.  
  1445. #End Region
  1446.  
  1447.  
  1448. #Region " DrawPixel "
  1449.  
  1450.     Private DrawPixelBrush As SolidBrush
  1451.  
  1452.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  1453.         If _Transparent Then
  1454.             B.SetPixel(x, y, c1)
  1455.         Else
  1456.             DrawPixelBrush = New SolidBrush(c1)
  1457.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  1458.         End If
  1459.     End Sub
  1460.  
  1461. #End Region
  1462.  
  1463. #Region " DrawCorners "
  1464.  
  1465.     Private DrawCornersBrush As SolidBrush
  1466.  
  1467.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  1468.         DrawCorners(c1, 0, 0, Width, Height, offset)
  1469.     End Sub
  1470.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  1471.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  1472.     End Sub
  1473.     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)
  1474.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1475.     End Sub
  1476.  
  1477.     Protected Sub DrawCorners(ByVal c1 As Color)
  1478.         DrawCorners(c1, 0, 0, Width, Height)
  1479.     End Sub
  1480.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  1481.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  1482.     End Sub
  1483.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1484.         If _NoRounding Then Return
  1485.  
  1486.         If _Transparent Then
  1487.             B.SetPixel(x, y, c1)
  1488.             B.SetPixel(x + (width - 1), y, c1)
  1489.             B.SetPixel(x, y + (height - 1), c1)
  1490.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  1491.         Else
  1492.             DrawCornersBrush = New SolidBrush(c1)
  1493.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  1494.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  1495.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  1496.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  1497.         End If
  1498.     End Sub
  1499.  
  1500. #End Region
  1501.  
  1502. #Region " DrawBorders "
  1503.  
  1504.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  1505.         DrawBorders(p1, 0, 0, Width, Height, offset)
  1506.     End Sub
  1507.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  1508.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  1509.     End Sub
  1510.     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)
  1511.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1512.     End Sub
  1513.  
  1514.     Protected Sub DrawBorders(ByVal p1 As Pen)
  1515.         DrawBorders(p1, 0, 0, Width, Height)
  1516.     End Sub
  1517.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  1518.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  1519.     End Sub
  1520.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1521.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  1522.     End Sub
  1523.  
  1524. #End Region
  1525.  
  1526. #Region " DrawText "
  1527.  
  1528.     Private DrawTextPoint As Point
  1529.     Private DrawTextSize As Size
  1530.  
  1531.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1532.         DrawText(b1, Text, a, x, y)
  1533.     End Sub
  1534.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1535.         If text.Length = 0 Then Return
  1536.  
  1537.         DrawTextSize = Measure(text)
  1538.         DrawTextPoint = Center(DrawTextSize)
  1539.  
  1540.         Select Case a
  1541.             Case HorizontalAlignment.Left
  1542.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  1543.             Case HorizontalAlignment.Center
  1544.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  1545.             Case HorizontalAlignment.Right
  1546.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  1547.         End Select
  1548.     End Sub
  1549.  
  1550.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  1551.         If Text.Length = 0 Then Return
  1552.         G.DrawString(Text, Font, b1, p1)
  1553.     End Sub
  1554.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  1555.         If Text.Length = 0 Then Return
  1556.         G.DrawString(Text, Font, b1, x, y)
  1557.     End Sub
  1558.  
  1559. #End Region
  1560.  
  1561. #Region " DrawImage "
  1562.  
  1563.     Private DrawImagePoint As Point
  1564.  
  1565.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1566.         DrawImage(_Image, a, x, y)
  1567.     End Sub
  1568.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1569.         If image Is Nothing Then Return
  1570.         DrawImagePoint = Center(image.Size)
  1571.  
  1572.         Select Case a
  1573.             Case HorizontalAlignment.Left
  1574.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  1575.             Case HorizontalAlignment.Center
  1576.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  1577.             Case HorizontalAlignment.Right
  1578.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  1579.         End Select
  1580.     End Sub
  1581.  
  1582.     Protected Sub DrawImage(ByVal p1 As Point)
  1583.         DrawImage(_Image, p1.X, p1.Y)
  1584.     End Sub
  1585.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  1586.         DrawImage(_Image, x, y)
  1587.     End Sub
  1588.  
  1589.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  1590.         DrawImage(image, p1.X, p1.Y)
  1591.     End Sub
  1592.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  1593.         If image Is Nothing Then Return
  1594.         G.DrawImage(image, x, y, image.Width, image.Height)
  1595.     End Sub
  1596.  
  1597. #End Region
  1598.  
  1599. #Region " DrawGradient "
  1600.  
  1601.     Private DrawGradientBrush As LinearGradientBrush
  1602.     Private DrawGradientRectangle As Rectangle
  1603.  
  1604.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1605.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1606.         DrawGradient(blend, DrawGradientRectangle)
  1607.     End Sub
  1608.     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)
  1609.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1610.         DrawGradient(blend, DrawGradientRectangle, angle)
  1611.     End Sub
  1612.  
  1613.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1614.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  1615.         DrawGradientBrush.InterpolationColors = blend
  1616.         G.FillRectangle(DrawGradientBrush, r)
  1617.     End Sub
  1618.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1619.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1620.         DrawGradientBrush.InterpolationColors = blend
  1621.         G.FillRectangle(DrawGradientBrush, r)
  1622.     End Sub
  1623.  
  1624.  
  1625.     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)
  1626.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1627.         DrawGradient(c1, c2, DrawGradientRectangle)
  1628.     End Sub
  1629.     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)
  1630.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1631.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1632.     End Sub
  1633.  
  1634.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1635.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1636.         G.FillRectangle(DrawGradientBrush, r)
  1637.     End Sub
  1638.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1639.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1640.         G.FillRectangle(DrawGradientBrush, r)
  1641.     End Sub
  1642.  
  1643. #End Region
  1644.  
  1645. #Region " DrawRadial "
  1646.  
  1647.     Private DrawRadialPath As GraphicsPath
  1648.     Private DrawRadialBrush1 As PathGradientBrush
  1649.     Private DrawRadialBrush2 As LinearGradientBrush
  1650.     Private DrawRadialRectangle As Rectangle
  1651.  
  1652.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1653.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1654.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1655.     End Sub
  1656.     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)
  1657.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1658.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1659.     End Sub
  1660.     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)
  1661.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1662.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1663.     End Sub
  1664.  
  1665.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1666.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1667.     End Sub
  1668.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1669.         DrawRadial(blend, r, center.X, center.Y)
  1670.     End Sub
  1671.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1672.         DrawRadialPath.Reset()
  1673.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1674.  
  1675.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1676.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1677.         DrawRadialBrush1.InterpolationColors = blend
  1678.  
  1679.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1680.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1681.         Else
  1682.             G.FillEllipse(DrawRadialBrush1, r)
  1683.         End If
  1684.     End Sub
  1685.  
  1686.  
  1687.     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)
  1688.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1689.         DrawRadial(c1, c2, DrawRadialRectangle)
  1690.     End Sub
  1691.     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)
  1692.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1693.         DrawRadial(c1, c2, DrawRadialRectangle, angle)
  1694.     End Sub
  1695.  
  1696.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1697.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1698.         G.FillEllipse(DrawRadialBrush2, r)
  1699.     End Sub
  1700.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1701.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1702.         G.FillEllipse(DrawRadialBrush2, r)
  1703.     End Sub
  1704.  
  1705. #End Region
  1706.  
  1707. End Class
  1708.  
  1709. Enum MouseState As Byte
  1710.     None = 0
  1711.     Over = 1
  1712.     Down = 2
  1713.     Block = 3
  1714. End Enum
  1715.  
  1716. Structure Bloom
  1717.  
  1718.     Public _Name As String
  1719.     ReadOnly Property Name() As String
  1720.         Get
  1721.             Return _Name
  1722.         End Get
  1723.     End Property
  1724.  
  1725.     Private _Value As Color
  1726.     Property Value() As Color
  1727.         Get
  1728.             Return _Value
  1729.         End Get
  1730.         Set(ByVal value As Color)
  1731.             _Value = value
  1732.         End Set
  1733.     End Property
  1734.  
  1735.     Sub New(ByVal name As String, ByVal value As Color)
  1736.         _Name = name
  1737.         _Value = value
  1738.     End Sub
  1739. End Structure
  1740.  
Advertisement
Add Comment
Please, Sign In to add comment