ImaFoSho

[VB] Synchron Theme

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