Advertisement
Guest User

VB.NET SUGAR THEME RELEASE

a guest
Jul 29th, 2012
3,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 92.54 KB | None | 0 0
  1.  
  2. ' ####### Sugar Theme #######
  3.  
  4. 'Theme name: Sugar Theme
  5. 'Creator   : greenviruz
  6. 'SKYPE     : greenviruz
  7. 'Site:     : www.aeonsofts.com
  8. 'Created   : 26/07/2012
  9. 'Version   : 1.0
  10. 'Thanks to : aeonhack ,Mavamaarten
  11. 'If you want a custom theme to be designed contact me at my skype..
  12. 'IF YOU ARE USING THIS THEME GIVE CREDITS TO ME
  13. 'THIS THEME IS A FREE THEME
  14.  
  15. '####### Sugar Theme #######
  16.  
  17.  
  18. #Region "Themebase"
  19. Imports System, System.IO, System.Collections.Generic
  20. Imports System.Drawing, System.Drawing.Drawing2D
  21. Imports System.ComponentModel, System.Windows.Forms
  22. Imports System.Runtime.InteropServices
  23. Imports System.Drawing.Imaging
  24.  
  25. '------------------
  26. 'Creator: aeonhack
  27. 'Site: elitevs.net
  28. 'Created: 08/02/2011
  29. 'Changed: 12/06/2011
  30. 'Version: 1.5.4
  31. '------------------
  32.  
  33. MustInherit Class ThemeContainer154
  34.     Inherits ContainerControl
  35.  
  36. #Region " Initialization "
  37.  
  38.     Protected G As Graphics, B As Bitmap
  39.  
  40.     Sub New()
  41.         SetStyle(DirectCast(139270, ControlStyles), True)
  42.  
  43.         _ImageSize = Size.Empty
  44.         Font = New Font("Verdana", 8S)
  45.  
  46.         MeasureBitmap = New Bitmap(1, 1)
  47.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  48.  
  49.         DrawRadialPath = New GraphicsPath
  50.  
  51.         InvalidateCustimization()
  52.     End Sub
  53.  
  54.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  55.         If DoneCreation Then InitializeMessages()
  56.  
  57.         InvalidateCustimization()
  58.         ColorHook()
  59.  
  60.         If Not _LockWidth = 0 Then Width = _LockWidth
  61.         If Not _LockHeight = 0 Then Height = _LockHeight
  62.         If Not _ControlMode Then MyBase.Dock = DockStyle.Fill
  63.  
  64.         Transparent = _Transparent
  65.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  66.  
  67.         MyBase.OnHandleCreated(e)
  68.     End Sub
  69.  
  70.     Private DoneCreation As Boolean
  71.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  72.         MyBase.OnParentChanged(e)
  73.  
  74.         If Parent Is Nothing Then Return
  75.         _IsParentForm = TypeOf Parent Is Form
  76.  
  77.         If Not _ControlMode Then
  78.             InitializeMessages()
  79.  
  80.             If _IsParentForm Then
  81.                 ParentForm.FormBorderStyle = _BorderStyle
  82.                 ParentForm.TransparencyKey = _TransparencyKey
  83.  
  84.                 If Not DesignMode Then
  85.                     AddHandler ParentForm.Shown, AddressOf FormShown
  86.                 End If
  87.             End If
  88.  
  89.             Parent.BackColor = BackColor
  90.         End If
  91.  
  92.         OnCreation()
  93.         DoneCreation = True
  94.         InvalidateTimer()
  95.     End Sub
  96.  
  97. #End Region
  98.  
  99.     Private Sub DoAnimation(ByVal i As Boolean)
  100.         OnAnimation()
  101.         If i Then Invalidate()
  102.     End Sub
  103.  
  104.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  105.         If Width = 0 OrElse Height = 0 Then Return
  106.  
  107.         If _Transparent AndAlso _ControlMode Then
  108.             PaintHook()
  109.             e.Graphics.DrawImage(B, 0, 0)
  110.         Else
  111.             G = e.Graphics
  112.             PaintHook()
  113.         End If
  114.     End Sub
  115.  
  116.     Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  117.         RemoveAnimationCallback(AddressOf DoAnimation)
  118.         MyBase.OnHandleDestroyed(e)
  119.     End Sub
  120.  
  121.     Private HasShown As Boolean
  122.     Private Sub FormShown(ByVal sender As Object, ByVal e As EventArgs)
  123.         If _ControlMode OrElse HasShown Then Return
  124.  
  125.         If _StartPosition = FormStartPosition.CenterParent OrElse _StartPosition = FormStartPosition.CenterScreen Then
  126.             Dim SB As Rectangle = Screen.PrimaryScreen.Bounds
  127.             Dim CB As Rectangle = ParentForm.Bounds
  128.             ParentForm.Location = New Point(SB.Width \ 2 - CB.Width \ 2, SB.Height \ 2 - CB.Width \ 2)
  129.         End If
  130.  
  131.         HasShown = True
  132.     End Sub
  133.  
  134.  
  135. #Region " Size Handling "
  136.  
  137.     Private Frame As Rectangle
  138.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  139.         If _Movable AndAlso Not _ControlMode Then
  140.             Frame = New Rectangle(7, 7, Width - 14, _Header - 7)
  141.         End If
  142.  
  143.         InvalidateBitmap()
  144.         Invalidate()
  145.  
  146.         MyBase.OnSizeChanged(e)
  147.     End Sub
  148.  
  149.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  150.         If Not _LockWidth = 0 Then width = _LockWidth
  151.         If Not _LockHeight = 0 Then height = _LockHeight
  152.         MyBase.SetBoundsCore(x, y, width, height, specified)
  153.     End Sub
  154.  
  155. #End Region
  156.  
  157. #Region " State Handling "
  158.  
  159.     Protected State As MouseState
  160.     Private Sub SetState(ByVal current As MouseState)
  161.         State = current
  162.         Invalidate()
  163.     End Sub
  164.  
  165.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  166.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
  167.             If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  168.         End If
  169.  
  170.         MyBase.OnMouseMove(e)
  171.     End Sub
  172.  
  173.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  174.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  175.         MyBase.OnEnabledChanged(e)
  176.     End Sub
  177.  
  178.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  179.         SetState(MouseState.Over)
  180.         MyBase.OnMouseEnter(e)
  181.     End Sub
  182.  
  183.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  184.         SetState(MouseState.Over)
  185.         MyBase.OnMouseUp(e)
  186.     End Sub
  187.  
  188.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  189.         SetState(MouseState.None)
  190.  
  191.         If GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
  192.             If _Sizable AndAlso Not _ControlMode Then
  193.                 Cursor = Cursors.Default
  194.                 Previous = 0
  195.             End If
  196.         End If
  197.  
  198.         MyBase.OnMouseLeave(e)
  199.     End Sub
  200.  
  201.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  202.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  203.  
  204.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
  205.             If _Movable AndAlso Frame.Contains(e.Location) Then
  206.                 Capture = False
  207.                 WM_LMBUTTONDOWN = True
  208.                 DefWndProc(Messages(0))
  209.             ElseIf _Sizable AndAlso Not Previous = 0 Then
  210.                 Capture = False
  211.                 WM_LMBUTTONDOWN = True
  212.                 DefWndProc(Messages(Previous))
  213.             End If
  214.         End If
  215.  
  216.         MyBase.OnMouseDown(e)
  217.     End Sub
  218.  
  219.     Private WM_LMBUTTONDOWN As Boolean
  220.     Protected Overrides Sub WndProc(ByRef m As Message)
  221.         MyBase.WndProc(m)
  222.  
  223.         If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
  224.             WM_LMBUTTONDOWN = False
  225.  
  226.             SetState(MouseState.Over)
  227.             If Not _SmartBounds Then Return
  228.  
  229.             If IsParentMdi Then
  230.                 CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
  231.             Else
  232.                 CorrectBounds(Screen.FromControl(Parent).WorkingArea)
  233.             End If
  234.         End If
  235.     End Sub
  236.  
  237.     Private GetIndexPoint As Point
  238.     Private B1, B2, B3, B4 As Boolean
  239.     Private Function GetIndex() As Integer
  240.         GetIndexPoint = PointToClient(MousePosition)
  241.         B1 = GetIndexPoint.X < 7
  242.         B2 = GetIndexPoint.X > Width - 7
  243.         B3 = GetIndexPoint.Y < 7
  244.         B4 = GetIndexPoint.Y > Height - 7
  245.  
  246.         If B1 AndAlso B3 Then Return 4
  247.         If B1 AndAlso B4 Then Return 7
  248.         If B2 AndAlso B3 Then Return 5
  249.         If B2 AndAlso B4 Then Return 8
  250.         If B1 Then Return 1
  251.         If B2 Then Return 2
  252.         If B3 Then Return 3
  253.         If B4 Then Return 6
  254.         Return 0
  255.     End Function
  256.  
  257.     Private Current, Previous As Integer
  258.     Private Sub InvalidateMouse()
  259.         Current = GetIndex()
  260.         If Current = Previous Then Return
  261.  
  262.         Previous = Current
  263.         Select Case Previous
  264.             Case 0
  265.                 Cursor = Cursors.Default
  266.             Case 1, 2
  267.                 Cursor = Cursors.SizeWE
  268.             Case 3, 6
  269.                 Cursor = Cursors.SizeNS
  270.             Case 4, 8
  271.                 Cursor = Cursors.SizeNWSE
  272.             Case 5, 7
  273.                 Cursor = Cursors.SizeNESW
  274.         End Select
  275.     End Sub
  276.  
  277.     Private Messages(8) As Message
  278.     Private Sub InitializeMessages()
  279.         Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  280.         For I As Integer = 1 To 8
  281.             Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
  282.         Next
  283.     End Sub
  284.  
  285.     Private Sub CorrectBounds(ByVal bounds As Rectangle)
  286.         If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
  287.         If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
  288.  
  289.         Dim X As Integer = Parent.Location.X
  290.         Dim Y As Integer = Parent.Location.Y
  291.  
  292.         If X < bounds.X Then X = bounds.X
  293.         If Y < bounds.Y Then Y = bounds.Y
  294.  
  295.         Dim Width As Integer = bounds.X + bounds.Width
  296.         Dim Height As Integer = bounds.Y + bounds.Height
  297.  
  298.         If X + Parent.Width > Width Then X = Width - Parent.Width
  299.         If Y + Parent.Height > Height Then Y = Height - Parent.Height
  300.  
  301.         Parent.Location = New Point(X, Y)
  302.     End Sub
  303.  
  304. #End Region
  305.  
  306.  
  307. #Region " Base Properties "
  308.  
  309.     Overrides Property Dock As DockStyle
  310.         Get
  311.             Return MyBase.Dock
  312.         End Get
  313.         Set(ByVal value As DockStyle)
  314.             If Not _ControlMode Then Return
  315.             MyBase.Dock = value
  316.         End Set
  317.     End Property
  318.  
  319.     Private _BackColor As Boolean
  320.     <Category("Misc")> _
  321.     Overrides Property BackColor() As Color
  322.         Get
  323.             Return MyBase.BackColor
  324.         End Get
  325.         Set(ByVal value As Color)
  326.             If value = MyBase.BackColor Then Return
  327.  
  328.             If Not IsHandleCreated AndAlso _ControlMode AndAlso value = Color.Transparent Then
  329.                 _BackColor = True
  330.                 Return
  331.             End If
  332.  
  333.             MyBase.BackColor = value
  334.             If Parent IsNot Nothing Then
  335.                 If Not _ControlMode Then Parent.BackColor = value
  336.                 ColorHook()
  337.             End If
  338.         End Set
  339.     End Property
  340.  
  341.     Overrides Property MinimumSize As Size
  342.         Get
  343.             Return MyBase.MinimumSize
  344.         End Get
  345.         Set(ByVal value As Size)
  346.             MyBase.MinimumSize = value
  347.             If Parent IsNot Nothing Then Parent.MinimumSize = value
  348.         End Set
  349.     End Property
  350.  
  351.     Overrides Property MaximumSize As Size
  352.         Get
  353.             Return MyBase.MaximumSize
  354.         End Get
  355.         Set(ByVal value As Size)
  356.             MyBase.MaximumSize = value
  357.             If Parent IsNot Nothing Then Parent.MaximumSize = value
  358.         End Set
  359.     End Property
  360.  
  361.     Overrides Property Text() As String
  362.         Get
  363.             Return MyBase.Text
  364.         End Get
  365.         Set(ByVal value As String)
  366.             MyBase.Text = value
  367.             Invalidate()
  368.         End Set
  369.     End Property
  370.  
  371.     Overrides Property Font() As Font
  372.         Get
  373.             Return MyBase.Font
  374.         End Get
  375.         Set(ByVal value As Font)
  376.             MyBase.Font = value
  377.             Invalidate()
  378.         End Set
  379.     End Property
  380.  
  381.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  382.     Overrides Property ForeColor() As Color
  383.         Get
  384.             Return Color.Empty
  385.         End Get
  386.         Set(ByVal value As Color)
  387.         End Set
  388.     End Property
  389.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  390.     Overrides Property BackgroundImage() As Image
  391.         Get
  392.             Return Nothing
  393.         End Get
  394.         Set(ByVal value As Image)
  395.         End Set
  396.     End Property
  397.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  398.     Overrides Property BackgroundImageLayout() As ImageLayout
  399.         Get
  400.             Return ImageLayout.None
  401.         End Get
  402.         Set(ByVal value As ImageLayout)
  403.         End Set
  404.     End Property
  405.  
  406. #End Region
  407.  
  408. #Region " Public Properties "
  409.  
  410.     Private _SmartBounds As Boolean = True
  411.     Property SmartBounds() As Boolean
  412.         Get
  413.             Return _SmartBounds
  414.         End Get
  415.         Set(ByVal value As Boolean)
  416.             _SmartBounds = value
  417.         End Set
  418.     End Property
  419.  
  420.     Private _Movable As Boolean = True
  421.     Property Movable() As Boolean
  422.         Get
  423.             Return _Movable
  424.         End Get
  425.         Set(ByVal value As Boolean)
  426.             _Movable = value
  427.         End Set
  428.     End Property
  429.  
  430.     Private _Sizable As Boolean = True
  431.     Property Sizable() As Boolean
  432.         Get
  433.             Return _Sizable
  434.         End Get
  435.         Set(ByVal value As Boolean)
  436.             _Sizable = value
  437.         End Set
  438.     End Property
  439.  
  440.     Private _TransparencyKey As Color
  441.     Property TransparencyKey() As Color
  442.         Get
  443.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
  444.         End Get
  445.         Set(ByVal value As Color)
  446.             If value = _TransparencyKey Then Return
  447.             _TransparencyKey = value
  448.  
  449.             If _IsParentForm AndAlso Not _ControlMode Then
  450.                 ParentForm.TransparencyKey = value
  451.                 ColorHook()
  452.             End If
  453.         End Set
  454.     End Property
  455.  
  456.     Private _BorderStyle As FormBorderStyle
  457.     Property BorderStyle() As FormBorderStyle
  458.         Get
  459.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
  460.         End Get
  461.         Set(ByVal value As FormBorderStyle)
  462.             _BorderStyle = value
  463.  
  464.             If _IsParentForm AndAlso Not _ControlMode Then
  465.                 ParentForm.FormBorderStyle = value
  466.  
  467.                 If Not value = FormBorderStyle.None Then
  468.                     Movable = False
  469.                     Sizable = False
  470.                 End If
  471.             End If
  472.         End Set
  473.     End Property
  474.  
  475.     Private _StartPosition As FormStartPosition
  476.     Property StartPosition As FormStartPosition
  477.         Get
  478.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.StartPosition Else Return _StartPosition
  479.         End Get
  480.         Set(ByVal value As FormStartPosition)
  481.             _StartPosition = value
  482.  
  483.             If _IsParentForm AndAlso Not _ControlMode Then
  484.                 ParentForm.StartPosition = value
  485.             End If
  486.         End Set
  487.     End Property
  488.  
  489.     Private _NoRounding As Boolean
  490.     Property NoRounding() As Boolean
  491.         Get
  492.             Return _NoRounding
  493.         End Get
  494.         Set(ByVal v As Boolean)
  495.             _NoRounding = v
  496.             Invalidate()
  497.         End Set
  498.     End Property
  499.  
  500.     Private _Image As Image
  501.     Property Image() As Image
  502.         Get
  503.             Return _Image
  504.         End Get
  505.         Set(ByVal value As Image)
  506.             If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size
  507.  
  508.             _Image = value
  509.             Invalidate()
  510.         End Set
  511.     End Property
  512.  
  513.     Private Items As New Dictionary(Of String, Color)
  514.     Property Colors() As Bloom()
  515.         Get
  516.             Dim T As New List(Of Bloom)
  517.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  518.  
  519.             While E.MoveNext
  520.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  521.             End While
  522.  
  523.             Return T.ToArray
  524.         End Get
  525.         Set(ByVal value As Bloom())
  526.             For Each B As Bloom In value
  527.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  528.             Next
  529.  
  530.             InvalidateCustimization()
  531.             ColorHook()
  532.             Invalidate()
  533.         End Set
  534.     End Property
  535.  
  536.     Private _Customization As String
  537.     Property Customization() As String
  538.         Get
  539.             Return _Customization
  540.         End Get
  541.         Set(ByVal value As String)
  542.             If value = _Customization Then Return
  543.  
  544.             Dim Data As Byte()
  545.             Dim Items As Bloom() = Colors
  546.  
  547.             Try
  548.                 Data = Convert.FromBase64String(value)
  549.                 For I As Integer = 0 To Items.Length - 1
  550.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  551.                 Next
  552.             Catch
  553.                 Return
  554.             End Try
  555.  
  556.             _Customization = value
  557.  
  558.             Colors = Items
  559.             ColorHook()
  560.             Invalidate()
  561.         End Set
  562.     End Property
  563.  
  564.     Private _Transparent As Boolean
  565.     Property Transparent() As Boolean
  566.         Get
  567.             Return _Transparent
  568.         End Get
  569.         Set(ByVal value As Boolean)
  570.             _Transparent = value
  571.             If Not (IsHandleCreated OrElse _ControlMode) Then Return
  572.  
  573.             If Not value AndAlso Not BackColor.A = 255 Then
  574.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  575.             End If
  576.  
  577.             SetStyle(ControlStyles.Opaque, Not value)
  578.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  579.  
  580.             InvalidateBitmap()
  581.             Invalidate()
  582.         End Set
  583.     End Property
  584.  
  585. #End Region
  586.  
  587. #Region " Private Properties "
  588.  
  589.     Private _ImageSize As Size
  590.     Protected ReadOnly Property ImageSize() As Size
  591.         Get
  592.             Return _ImageSize
  593.         End Get
  594.     End Property
  595.  
  596.     Private _IsParentForm As Boolean
  597.     Protected ReadOnly Property IsParentForm As Boolean
  598.         Get
  599.             Return _IsParentForm
  600.         End Get
  601.     End Property
  602.  
  603.     Protected ReadOnly Property IsParentMdi As Boolean
  604.         Get
  605.             If Parent Is Nothing Then Return False
  606.             Return Parent.Parent IsNot Nothing
  607.         End Get
  608.     End Property
  609.  
  610.     Private _LockWidth As Integer
  611.     Protected Property LockWidth() As Integer
  612.         Get
  613.             Return _LockWidth
  614.         End Get
  615.         Set(ByVal value As Integer)
  616.             _LockWidth = value
  617.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  618.         End Set
  619.     End Property
  620.  
  621.     Private _LockHeight As Integer
  622.     Protected Property LockHeight() As Integer
  623.         Get
  624.             Return _LockHeight
  625.         End Get
  626.         Set(ByVal value As Integer)
  627.             _LockHeight = value
  628.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  629.         End Set
  630.     End Property
  631.  
  632.     Private _Header As Integer = 24
  633.     Protected Property Header() As Integer
  634.         Get
  635.             Return _Header
  636.         End Get
  637.         Set(ByVal v As Integer)
  638.             _Header = v
  639.  
  640.             If Not _ControlMode Then
  641.                 Frame = New Rectangle(7, 7, Width - 14, v - 7)
  642.                 Invalidate()
  643.             End If
  644.         End Set
  645.     End Property
  646.  
  647.     Private _ControlMode As Boolean
  648.     Protected Property ControlMode() As Boolean
  649.         Get
  650.             Return _ControlMode
  651.         End Get
  652.         Set(ByVal v As Boolean)
  653.             _ControlMode = v
  654.  
  655.             Transparent = _Transparent
  656.             If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  657.  
  658.             InvalidateBitmap()
  659.             Invalidate()
  660.         End Set
  661.     End Property
  662.  
  663.     Private _IsAnimated As Boolean
  664.     Protected Property IsAnimated() As Boolean
  665.         Get
  666.             Return _IsAnimated
  667.         End Get
  668.         Set(ByVal value As Boolean)
  669.             _IsAnimated = value
  670.             InvalidateTimer()
  671.         End Set
  672.     End Property
  673.  
  674. #End Region
  675.  
  676.  
  677. #Region " Property Helpers "
  678.  
  679.     Protected Function GetPen(ByVal name As String) As Pen
  680.         Return New Pen(Items(name))
  681.     End Function
  682.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  683.         Return New Pen(Items(name), width)
  684.     End Function
  685.  
  686.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  687.         Return New SolidBrush(Items(name))
  688.     End Function
  689.  
  690.     Protected Function GetColor(ByVal name As String) As Color
  691.         Return Items(name)
  692.     End Function
  693.  
  694.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  695.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  696.     End Sub
  697.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  698.         SetColor(name, Color.FromArgb(r, g, b))
  699.     End Sub
  700.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  701.         SetColor(name, Color.FromArgb(a, r, g, b))
  702.     End Sub
  703.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  704.         SetColor(name, Color.FromArgb(a, value))
  705.     End Sub
  706.  
  707.     Private Sub InvalidateBitmap()
  708.         If _Transparent AndAlso _ControlMode Then
  709.             If Width = 0 OrElse Height = 0 Then Return
  710.             B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  711.             G = Graphics.FromImage(B)
  712.         Else
  713.             G = Nothing
  714.             B = Nothing
  715.         End If
  716.     End Sub
  717.  
  718.     Private Sub InvalidateCustimization()
  719.         Dim M As New MemoryStream(Items.Count * 4)
  720.  
  721.         For Each B As Bloom In Colors
  722.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  723.         Next
  724.  
  725.         M.Close()
  726.         _Customization = Convert.ToBase64String(M.ToArray)
  727.     End Sub
  728.  
  729.     Private Sub InvalidateTimer()
  730.         If DesignMode OrElse Not DoneCreation Then Return
  731.  
  732.         If _IsAnimated Then
  733.             AddAnimationCallback(AddressOf DoAnimation)
  734.         Else
  735.             RemoveAnimationCallback(AddressOf DoAnimation)
  736.         End If
  737.     End Sub
  738.  
  739. #End Region
  740.  
  741.  
  742. #Region " User Hooks "
  743.  
  744.     Protected MustOverride Sub ColorHook()
  745.     Protected MustOverride Sub PaintHook()
  746.  
  747.     Protected Overridable Sub OnCreation()
  748.     End Sub
  749.  
  750.     Protected Overridable Sub OnAnimation()
  751.     End Sub
  752.  
  753. #End Region
  754.  
  755.  
  756. #Region " Offset "
  757.  
  758.     Private OffsetReturnRectangle As Rectangle
  759.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  760.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  761.         Return OffsetReturnRectangle
  762.     End Function
  763.  
  764.     Private OffsetReturnSize As Size
  765.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  766.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  767.         Return OffsetReturnSize
  768.     End Function
  769.  
  770.     Private OffsetReturnPoint As Point
  771.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  772.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  773.         Return OffsetReturnPoint
  774.     End Function
  775.  
  776. #End Region
  777.  
  778. #Region " Center "
  779.  
  780.     Private CenterReturn As Point
  781.  
  782.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  783.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  784.         Return CenterReturn
  785.     End Function
  786.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  787.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  788.         Return CenterReturn
  789.     End Function
  790.  
  791.     Protected Function Center(ByVal child As Rectangle) As Point
  792.         Return Center(Width, Height, child.Width, child.Height)
  793.     End Function
  794.     Protected Function Center(ByVal child As Size) As Point
  795.         Return Center(Width, Height, child.Width, child.Height)
  796.     End Function
  797.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  798.         Return Center(Width, Height, childWidth, childHeight)
  799.     End Function
  800.  
  801.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  802.         Return Center(p.Width, p.Height, c.Width, c.Height)
  803.     End Function
  804.  
  805.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  806.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  807.         Return CenterReturn
  808.     End Function
  809.  
  810. #End Region
  811.  
  812. #Region " Measure "
  813.  
  814.     Private MeasureBitmap As Bitmap
  815.     Private MeasureGraphics As Graphics
  816.  
  817.     Protected Function Measure() As Size
  818.         SyncLock MeasureGraphics
  819.             Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  820.         End SyncLock
  821.     End Function
  822.     Protected Function Measure(ByVal text As String) As Size
  823.         SyncLock MeasureGraphics
  824.             Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  825.         End SyncLock
  826.     End Function
  827.  
  828. #End Region
  829.  
  830.  
  831. #Region " DrawPixel "
  832.  
  833.     Private DrawPixelBrush As SolidBrush
  834.  
  835.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  836.         If _Transparent Then
  837.             B.SetPixel(x, y, c1)
  838.         Else
  839.             DrawPixelBrush = New SolidBrush(c1)
  840.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  841.         End If
  842.     End Sub
  843.  
  844. #End Region
  845.  
  846. #Region " DrawCorners "
  847.  
  848.     Private DrawCornersBrush As SolidBrush
  849.  
  850.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  851.         DrawCorners(c1, 0, 0, Width, Height, offset)
  852.     End Sub
  853.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  854.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  855.     End Sub
  856.     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)
  857.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  858.     End Sub
  859.  
  860.     Protected Sub DrawCorners(ByVal c1 As Color)
  861.         DrawCorners(c1, 0, 0, Width, Height)
  862.     End Sub
  863.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  864.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  865.     End Sub
  866.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  867.         If _NoRounding Then Return
  868.  
  869.         If _Transparent Then
  870.             B.SetPixel(x, y, c1)
  871.             B.SetPixel(x + (width - 1), y, c1)
  872.             B.SetPixel(x, y + (height - 1), c1)
  873.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  874.         Else
  875.             DrawCornersBrush = New SolidBrush(c1)
  876.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  877.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  878.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  879.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  880.         End If
  881.     End Sub
  882.  
  883. #End Region
  884.  
  885. #Region " DrawBorders "
  886.  
  887.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  888.         DrawBorders(p1, 0, 0, Width, Height, offset)
  889.     End Sub
  890.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  891.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  892.     End Sub
  893.     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)
  894.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  895.     End Sub
  896.  
  897.     Protected Sub DrawBorders(ByVal p1 As Pen)
  898.         DrawBorders(p1, 0, 0, Width, Height)
  899.     End Sub
  900.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  901.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  902.     End Sub
  903.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  904.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  905.     End Sub
  906.  
  907. #End Region
  908.  
  909. #Region " DrawText "
  910.  
  911.     Private DrawTextPoint As Point
  912.     Private DrawTextSize As Size
  913.  
  914.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  915.         DrawText(b1, Text, a, x, y)
  916.     End Sub
  917.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  918.         If text.Length = 0 Then Return
  919.  
  920.         DrawTextSize = Measure(text)
  921.         DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, Header \ 2 - DrawTextSize.Height \ 2)
  922.  
  923.         Select Case a
  924.             Case HorizontalAlignment.Left
  925.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  926.             Case HorizontalAlignment.Center
  927.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  928.             Case HorizontalAlignment.Right
  929.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  930.         End Select
  931.     End Sub
  932.  
  933.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  934.         If Text.Length = 0 Then Return
  935.         G.DrawString(Text, Font, b1, p1)
  936.     End Sub
  937.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  938.         If Text.Length = 0 Then Return
  939.         G.DrawString(Text, Font, b1, x, y)
  940.     End Sub
  941.  
  942. #End Region
  943.  
  944. #Region " DrawImage "
  945.  
  946.     Private DrawImagePoint As Point
  947.  
  948.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  949.         DrawImage(_Image, a, x, y)
  950.     End Sub
  951.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  952.         If image Is Nothing Then Return
  953.         DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, Header \ 2 - image.Height \ 2)
  954.  
  955.         Select Case a
  956.             Case HorizontalAlignment.Left
  957.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  958.             Case HorizontalAlignment.Center
  959.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  960.             Case HorizontalAlignment.Right
  961.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  962.         End Select
  963.     End Sub
  964.  
  965.     Protected Sub DrawImage(ByVal p1 As Point)
  966.         DrawImage(_Image, p1.X, p1.Y)
  967.     End Sub
  968.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  969.         DrawImage(_Image, x, y)
  970.     End Sub
  971.  
  972.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  973.         DrawImage(image, p1.X, p1.Y)
  974.     End Sub
  975.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  976.         If image Is Nothing Then Return
  977.         G.DrawImage(image, x, y, image.Width, image.Height)
  978.     End Sub
  979.  
  980. #End Region
  981.  
  982. #Region " DrawGradient "
  983.  
  984.     Private DrawGradientBrush As LinearGradientBrush
  985.     Private DrawGradientRectangle As Rectangle
  986.  
  987.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  988.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  989.         DrawGradient(blend, DrawGradientRectangle)
  990.     End Sub
  991.     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)
  992.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  993.         DrawGradient(blend, DrawGradientRectangle, angle)
  994.     End Sub
  995.  
  996.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  997.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  998.         DrawGradientBrush.InterpolationColors = blend
  999.         G.FillRectangle(DrawGradientBrush, r)
  1000.     End Sub
  1001.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1002.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1003.         DrawGradientBrush.InterpolationColors = blend
  1004.         G.FillRectangle(DrawGradientBrush, r)
  1005.     End Sub
  1006.  
  1007.  
  1008.     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)
  1009.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1010.         DrawGradient(c1, c2, DrawGradientRectangle)
  1011.     End Sub
  1012.     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)
  1013.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1014.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1015.     End Sub
  1016.  
  1017.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1018.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1019.         G.FillRectangle(DrawGradientBrush, r)
  1020.     End Sub
  1021.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1022.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1023.         G.FillRectangle(DrawGradientBrush, r)
  1024.     End Sub
  1025.  
  1026. #End Region
  1027.  
  1028. #Region " DrawRadial "
  1029.  
  1030.     Private DrawRadialPath As GraphicsPath
  1031.     Private DrawRadialBrush1 As PathGradientBrush
  1032.     Private DrawRadialBrush2 As LinearGradientBrush
  1033.     Private DrawRadialRectangle As Rectangle
  1034.  
  1035.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1036.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1037.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1038.     End Sub
  1039.     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)
  1040.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1041.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1042.     End Sub
  1043.     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)
  1044.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1045.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1046.     End Sub
  1047.  
  1048.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1049.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1050.     End Sub
  1051.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1052.         DrawRadial(blend, r, center.X, center.Y)
  1053.     End Sub
  1054.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1055.         DrawRadialPath.Reset()
  1056.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1057.  
  1058.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1059.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1060.         DrawRadialBrush1.InterpolationColors = blend
  1061.  
  1062.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1063.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1064.         Else
  1065.             G.FillEllipse(DrawRadialBrush1, r)
  1066.         End If
  1067.     End Sub
  1068.  
  1069.  
  1070.     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)
  1071.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1072.         DrawRadial(c1, c2, DrawGradientRectangle)
  1073.     End Sub
  1074.     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)
  1075.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1076.         DrawRadial(c1, c2, DrawGradientRectangle, angle)
  1077.     End Sub
  1078.  
  1079.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1080.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1081.         G.FillRectangle(DrawGradientBrush, r)
  1082.     End Sub
  1083.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1084.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1085.         G.FillEllipse(DrawGradientBrush, r)
  1086.     End Sub
  1087.  
  1088. #End Region
  1089.  
  1090. #Region " CreateRound "
  1091.  
  1092.     Private CreateRoundPath As GraphicsPath
  1093.     Private CreateRoundRectangle As Rectangle
  1094.  
  1095.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  1096.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  1097.         Return CreateRound(CreateRoundRectangle, slope)
  1098.     End Function
  1099.  
  1100.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  1101.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  1102.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  1103.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  1104.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  1105.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  1106.         CreateRoundPath.CloseFigure()
  1107.         Return CreateRoundPath
  1108.     End Function
  1109.  
  1110. #End Region
  1111.  
  1112. End Class
  1113.  
  1114. MustInherit Class ThemeControl154
  1115.     Inherits Control
  1116.  
  1117.  
  1118. #Region " Initialization "
  1119.  
  1120.     Protected G As Graphics, B As Bitmap
  1121.  
  1122.     Sub New()
  1123.         SetStyle(DirectCast(139270, ControlStyles), True)
  1124.  
  1125.         _ImageSize = Size.Empty
  1126.         Font = New Font("Verdana", 8S)
  1127.  
  1128.         MeasureBitmap = New Bitmap(1, 1)
  1129.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  1130.  
  1131.         DrawRadialPath = New GraphicsPath
  1132.  
  1133.         InvalidateCustimization() 'Remove?
  1134.     End Sub
  1135.  
  1136.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  1137.         InvalidateCustimization()
  1138.         ColorHook()
  1139.  
  1140.         If Not _LockWidth = 0 Then Width = _LockWidth
  1141.         If Not _LockHeight = 0 Then Height = _LockHeight
  1142.  
  1143.         Transparent = _Transparent
  1144.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  1145.  
  1146.         MyBase.OnHandleCreated(e)
  1147.     End Sub
  1148.  
  1149.     Private DoneCreation As Boolean
  1150.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  1151.         If Parent IsNot Nothing Then
  1152.             OnCreation()
  1153.             DoneCreation = True
  1154.             InvalidateTimer()
  1155.         End If
  1156.  
  1157.         MyBase.OnParentChanged(e)
  1158.     End Sub
  1159.  
  1160. #End Region
  1161.  
  1162.     Private Sub DoAnimation(ByVal i As Boolean)
  1163.         OnAnimation()
  1164.         If i Then Invalidate()
  1165.     End Sub
  1166.  
  1167.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1168.         If Width = 0 OrElse Height = 0 Then Return
  1169.  
  1170.         If _Transparent Then
  1171.             PaintHook()
  1172.             e.Graphics.DrawImage(B, 0, 0)
  1173.         Else
  1174.             G = e.Graphics
  1175.             PaintHook()
  1176.         End If
  1177.     End Sub
  1178.  
  1179.     Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  1180.         RemoveAnimationCallback(AddressOf DoAnimation)
  1181.         MyBase.OnHandleDestroyed(e)
  1182.     End Sub
  1183.  
  1184. #Region " Size Handling "
  1185.  
  1186.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  1187.         If _Transparent Then
  1188.             InvalidateBitmap()
  1189.         End If
  1190.  
  1191.         Invalidate()
  1192.         MyBase.OnSizeChanged(e)
  1193.     End Sub
  1194.  
  1195.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  1196.         If Not _LockWidth = 0 Then width = _LockWidth
  1197.         If Not _LockHeight = 0 Then height = _LockHeight
  1198.         MyBase.SetBoundsCore(x, y, width, height, specified)
  1199.     End Sub
  1200.  
  1201. #End Region
  1202.  
  1203. #Region " State Handling "
  1204.  
  1205.     Private InPosition As Boolean
  1206.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  1207.         InPosition = True
  1208.         SetState(MouseState.Over)
  1209.         MyBase.OnMouseEnter(e)
  1210.     End Sub
  1211.  
  1212.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  1213.         If InPosition Then SetState(MouseState.Over)
  1214.         MyBase.OnMouseUp(e)
  1215.     End Sub
  1216.  
  1217.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  1218.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  1219.         MyBase.OnMouseDown(e)
  1220.     End Sub
  1221.  
  1222.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  1223.         InPosition = False
  1224.         SetState(MouseState.None)
  1225.         MyBase.OnMouseLeave(e)
  1226.     End Sub
  1227.  
  1228.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  1229.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  1230.         MyBase.OnEnabledChanged(e)
  1231.     End Sub
  1232.  
  1233.     Protected State As MouseState
  1234.     Private Sub SetState(ByVal current As MouseState)
  1235.         State = current
  1236.         Invalidate()
  1237.     End Sub
  1238.  
  1239. #End Region
  1240.  
  1241.  
  1242. #Region " Base Properties "
  1243.  
  1244.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1245.     Overrides Property ForeColor() As Color
  1246.         Get
  1247.             Return Color.Empty
  1248.         End Get
  1249.         Set(ByVal value As Color)
  1250.         End Set
  1251.     End Property
  1252.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1253.     Overrides Property BackgroundImage() As Image
  1254.         Get
  1255.             Return Nothing
  1256.         End Get
  1257.         Set(ByVal value As Image)
  1258.         End Set
  1259.     End Property
  1260.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1261.     Overrides Property BackgroundImageLayout() As ImageLayout
  1262.         Get
  1263.             Return ImageLayout.None
  1264.         End Get
  1265.         Set(ByVal value As ImageLayout)
  1266.         End Set
  1267.     End Property
  1268.  
  1269.     Overrides Property Text() As String
  1270.         Get
  1271.             Return MyBase.Text
  1272.         End Get
  1273.         Set(ByVal value As String)
  1274.             MyBase.Text = value
  1275.             Invalidate()
  1276.         End Set
  1277.     End Property
  1278.     Overrides Property Font() As Font
  1279.         Get
  1280.             Return MyBase.Font
  1281.         End Get
  1282.         Set(ByVal value As Font)
  1283.             MyBase.Font = value
  1284.             Invalidate()
  1285.         End Set
  1286.     End Property
  1287.  
  1288.     Private _BackColor As Boolean
  1289.     <Category("Misc")> _
  1290.     Overrides Property BackColor() As Color
  1291.         Get
  1292.             Return MyBase.BackColor
  1293.         End Get
  1294.         Set(ByVal value As Color)
  1295.             If Not IsHandleCreated AndAlso value = Color.Transparent Then
  1296.                 _BackColor = True
  1297.                 Return
  1298.             End If
  1299.  
  1300.             MyBase.BackColor = value
  1301.             If Parent IsNot Nothing Then ColorHook()
  1302.         End Set
  1303.     End Property
  1304.  
  1305. #End Region
  1306.  
  1307. #Region " Public Properties "
  1308.  
  1309.     Private _NoRounding As Boolean
  1310.     Property NoRounding() As Boolean
  1311.         Get
  1312.             Return _NoRounding
  1313.         End Get
  1314.         Set(ByVal v As Boolean)
  1315.             _NoRounding = v
  1316.             Invalidate()
  1317.         End Set
  1318.     End Property
  1319.  
  1320.     Private _Image As Image
  1321.     Property Image() As Image
  1322.         Get
  1323.             Return _Image
  1324.         End Get
  1325.         Set(ByVal value As Image)
  1326.             If value Is Nothing Then
  1327.                 _ImageSize = Size.Empty
  1328.             Else
  1329.                 _ImageSize = value.Size
  1330.             End If
  1331.  
  1332.             _Image = value
  1333.             Invalidate()
  1334.         End Set
  1335.     End Property
  1336.  
  1337.     Private _Transparent As Boolean
  1338.     Property Transparent() As Boolean
  1339.         Get
  1340.             Return _Transparent
  1341.         End Get
  1342.         Set(ByVal value As Boolean)
  1343.             _Transparent = value
  1344.             If Not IsHandleCreated Then Return
  1345.  
  1346.             If Not value AndAlso Not BackColor.A = 255 Then
  1347.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  1348.             End If
  1349.  
  1350.             SetStyle(ControlStyles.Opaque, Not value)
  1351.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  1352.  
  1353.             If value Then InvalidateBitmap() Else B = Nothing
  1354.             Invalidate()
  1355.         End Set
  1356.     End Property
  1357.  
  1358.     Private Items As New Dictionary(Of String, Color)
  1359.     Property Colors() As Bloom()
  1360.         Get
  1361.             Dim T As New List(Of Bloom)
  1362.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  1363.  
  1364.             While E.MoveNext
  1365.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  1366.             End While
  1367.  
  1368.             Return T.ToArray
  1369.         End Get
  1370.         Set(ByVal value As Bloom())
  1371.             For Each B As Bloom In value
  1372.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  1373.             Next
  1374.  
  1375.             InvalidateCustimization()
  1376.             ColorHook()
  1377.             Invalidate()
  1378.         End Set
  1379.     End Property
  1380.  
  1381.     Private _Customization As String
  1382.     Property Customization() As String
  1383.         Get
  1384.             Return _Customization
  1385.         End Get
  1386.         Set(ByVal value As String)
  1387.             If value = _Customization Then Return
  1388.  
  1389.             Dim Data As Byte()
  1390.             Dim Items As Bloom() = Colors
  1391.  
  1392.             Try
  1393.                 Data = Convert.FromBase64String(value)
  1394.                 For I As Integer = 0 To Items.Length - 1
  1395.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  1396.                 Next
  1397.             Catch
  1398.                 Return
  1399.             End Try
  1400.  
  1401.             _Customization = value
  1402.  
  1403.             Colors = Items
  1404.             ColorHook()
  1405.             Invalidate()
  1406.         End Set
  1407.     End Property
  1408.  
  1409. #End Region
  1410.  
  1411. #Region " Private Properties "
  1412.  
  1413.     Private _ImageSize As Size
  1414.     Protected ReadOnly Property ImageSize() As Size
  1415.         Get
  1416.             Return _ImageSize
  1417.         End Get
  1418.     End Property
  1419.  
  1420.     Private _LockWidth As Integer
  1421.     Protected Property LockWidth() As Integer
  1422.         Get
  1423.             Return _LockWidth
  1424.         End Get
  1425.         Set(ByVal value As Integer)
  1426.             _LockWidth = value
  1427.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  1428.         End Set
  1429.     End Property
  1430.  
  1431.     Private _LockHeight As Integer
  1432.     Protected Property LockHeight() As Integer
  1433.         Get
  1434.             Return _LockHeight
  1435.         End Get
  1436.         Set(ByVal value As Integer)
  1437.             _LockHeight = value
  1438.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  1439.         End Set
  1440.     End Property
  1441.  
  1442.     Private _IsAnimated As Boolean
  1443.     Protected Property IsAnimated() As Boolean
  1444.         Get
  1445.             Return _IsAnimated
  1446.         End Get
  1447.         Set(ByVal value As Boolean)
  1448.             _IsAnimated = value
  1449.             InvalidateTimer()
  1450.         End Set
  1451.     End Property
  1452.  
  1453. #End Region
  1454.  
  1455.  
  1456. #Region " Property Helpers "
  1457.  
  1458.     Protected Function GetPen(ByVal name As String) As Pen
  1459.         Return New Pen(Items(name))
  1460.     End Function
  1461.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  1462.         Return New Pen(Items(name), width)
  1463.     End Function
  1464.  
  1465.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  1466.         Return New SolidBrush(Items(name))
  1467.     End Function
  1468.  
  1469.     Protected Function GetColor(ByVal name As String) As Color
  1470.         Return Items(name)
  1471.     End Function
  1472.  
  1473.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  1474.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  1475.     End Sub
  1476.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1477.         SetColor(name, Color.FromArgb(r, g, b))
  1478.     End Sub
  1479.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1480.         SetColor(name, Color.FromArgb(a, r, g, b))
  1481.     End Sub
  1482.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  1483.         SetColor(name, Color.FromArgb(a, value))
  1484.     End Sub
  1485.  
  1486.     Private Sub InvalidateBitmap()
  1487.         If Width = 0 OrElse Height = 0 Then Return
  1488.         B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  1489.         G = Graphics.FromImage(B)
  1490.     End Sub
  1491.  
  1492.     Private Sub InvalidateCustimization()
  1493.         Dim M As New MemoryStream(Items.Count * 4)
  1494.  
  1495.         For Each B As Bloom In Colors
  1496.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1497.         Next
  1498.  
  1499.         M.Close()
  1500.         _Customization = Convert.ToBase64String(M.ToArray)
  1501.     End Sub
  1502.  
  1503.     Private Sub InvalidateTimer()
  1504.         If DesignMode OrElse Not DoneCreation Then Return
  1505.  
  1506.         If _IsAnimated Then
  1507.             AddAnimationCallback(AddressOf DoAnimation)
  1508.         Else
  1509.             RemoveAnimationCallback(AddressOf DoAnimation)
  1510.         End If
  1511.     End Sub
  1512. #End Region
  1513.  
  1514.  
  1515. #Region " User Hooks "
  1516.  
  1517.     Protected MustOverride Sub ColorHook()
  1518.     Protected MustOverride Sub PaintHook()
  1519.  
  1520.     Protected Overridable Sub OnCreation()
  1521.     End Sub
  1522.  
  1523.     Protected Overridable Sub OnAnimation()
  1524.     End Sub
  1525.  
  1526. #End Region
  1527.  
  1528.  
  1529. #Region " Offset "
  1530.  
  1531.     Private OffsetReturnRectangle As Rectangle
  1532.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  1533.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  1534.         Return OffsetReturnRectangle
  1535.     End Function
  1536.  
  1537.     Private OffsetReturnSize As Size
  1538.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  1539.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  1540.         Return OffsetReturnSize
  1541.     End Function
  1542.  
  1543.     Private OffsetReturnPoint As Point
  1544.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  1545.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  1546.         Return OffsetReturnPoint
  1547.     End Function
  1548.  
  1549. #End Region
  1550.  
  1551. #Region " Center "
  1552.  
  1553.     Private CenterReturn As Point
  1554.  
  1555.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  1556.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  1557.         Return CenterReturn
  1558.     End Function
  1559.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  1560.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  1561.         Return CenterReturn
  1562.     End Function
  1563.  
  1564.     Protected Function Center(ByVal child As Rectangle) As Point
  1565.         Return Center(Width, Height, child.Width, child.Height)
  1566.     End Function
  1567.     Protected Function Center(ByVal child As Size) As Point
  1568.         Return Center(Width, Height, child.Width, child.Height)
  1569.     End Function
  1570.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  1571.         Return Center(Width, Height, childWidth, childHeight)
  1572.     End Function
  1573.  
  1574.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  1575.         Return Center(p.Width, p.Height, c.Width, c.Height)
  1576.     End Function
  1577.  
  1578.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  1579.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  1580.         Return CenterReturn
  1581.     End Function
  1582.  
  1583. #End Region
  1584.  
  1585. #Region " Measure "
  1586.  
  1587.     Private MeasureBitmap As Bitmap
  1588.     Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
  1589.  
  1590.     Protected Function Measure() As Size
  1591.         Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  1592.     End Function
  1593.     Protected Function Measure(ByVal text As String) As Size
  1594.         Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  1595.     End Function
  1596.  
  1597. #End Region
  1598.  
  1599.  
  1600. #Region " DrawPixel "
  1601.  
  1602.     Private DrawPixelBrush As SolidBrush
  1603.  
  1604.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  1605.         If _Transparent Then
  1606.             B.SetPixel(x, y, c1)
  1607.         Else
  1608.             DrawPixelBrush = New SolidBrush(c1)
  1609.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  1610.         End If
  1611.     End Sub
  1612.  
  1613. #End Region
  1614.  
  1615. #Region " DrawCorners "
  1616.  
  1617.     Private DrawCornersBrush As SolidBrush
  1618.  
  1619.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  1620.         DrawCorners(c1, 0, 0, Width, Height, offset)
  1621.     End Sub
  1622.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  1623.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  1624.     End Sub
  1625.     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)
  1626.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1627.     End Sub
  1628.  
  1629.     Protected Sub DrawCorners(ByVal c1 As Color)
  1630.         DrawCorners(c1, 0, 0, Width, Height)
  1631.     End Sub
  1632.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  1633.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  1634.     End Sub
  1635.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1636.         If _NoRounding Then Return
  1637.  
  1638.         If _Transparent Then
  1639.             B.SetPixel(x, y, c1)
  1640.             B.SetPixel(x + (width - 1), y, c1)
  1641.             B.SetPixel(x, y + (height - 1), c1)
  1642.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  1643.         Else
  1644.             DrawCornersBrush = New SolidBrush(c1)
  1645.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  1646.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  1647.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  1648.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  1649.         End If
  1650.     End Sub
  1651.  
  1652. #End Region
  1653.  
  1654. #Region " DrawBorders "
  1655.  
  1656.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  1657.         DrawBorders(p1, 0, 0, Width, Height, offset)
  1658.     End Sub
  1659.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  1660.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  1661.     End Sub
  1662.     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)
  1663.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1664.     End Sub
  1665.  
  1666.     Protected Sub DrawBorders(ByVal p1 As Pen)
  1667.         DrawBorders(p1, 0, 0, Width, Height)
  1668.     End Sub
  1669.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  1670.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  1671.     End Sub
  1672.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1673.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  1674.     End Sub
  1675.  
  1676. #End Region
  1677.  
  1678. #Region " DrawText "
  1679.  
  1680.     Private DrawTextPoint As Point
  1681.     Private DrawTextSize As Size
  1682.  
  1683.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1684.         DrawText(b1, Text, a, x, y)
  1685.     End Sub
  1686.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1687.         If text.Length = 0 Then Return
  1688.  
  1689.         DrawTextSize = Measure(text)
  1690.         DrawTextPoint = Center(DrawTextSize)
  1691.  
  1692.         Select Case a
  1693.             Case HorizontalAlignment.Left
  1694.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  1695.             Case HorizontalAlignment.Center
  1696.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  1697.             Case HorizontalAlignment.Right
  1698.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  1699.         End Select
  1700.     End Sub
  1701.  
  1702.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  1703.         If Text.Length = 0 Then Return
  1704.         G.DrawString(Text, Font, b1, p1)
  1705.     End Sub
  1706.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  1707.         If Text.Length = 0 Then Return
  1708.         G.DrawString(Text, Font, b1, x, y)
  1709.     End Sub
  1710.  
  1711. #End Region
  1712.  
  1713. #Region " DrawImage "
  1714.  
  1715.     Private DrawImagePoint As Point
  1716.  
  1717.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1718.         DrawImage(_Image, a, x, y)
  1719.     End Sub
  1720.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1721.         If image Is Nothing Then Return
  1722.         DrawImagePoint = Center(image.Size)
  1723.  
  1724.         Select Case a
  1725.             Case HorizontalAlignment.Left
  1726.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  1727.             Case HorizontalAlignment.Center
  1728.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  1729.             Case HorizontalAlignment.Right
  1730.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  1731.         End Select
  1732.     End Sub
  1733.  
  1734.     Protected Sub DrawImage(ByVal p1 As Point)
  1735.         DrawImage(_Image, p1.X, p1.Y)
  1736.     End Sub
  1737.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  1738.         DrawImage(_Image, x, y)
  1739.     End Sub
  1740.  
  1741.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  1742.         DrawImage(image, p1.X, p1.Y)
  1743.     End Sub
  1744.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  1745.         If image Is Nothing Then Return
  1746.         G.DrawImage(image, x, y, image.Width, image.Height)
  1747.     End Sub
  1748.  
  1749. #End Region
  1750.  
  1751. #Region " DrawGradient "
  1752.  
  1753.     Private DrawGradientBrush As LinearGradientBrush
  1754.     Private DrawGradientRectangle As Rectangle
  1755.  
  1756.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1757.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1758.         DrawGradient(blend, DrawGradientRectangle)
  1759.     End Sub
  1760.     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)
  1761.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1762.         DrawGradient(blend, DrawGradientRectangle, angle)
  1763.     End Sub
  1764.  
  1765.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1766.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  1767.         DrawGradientBrush.InterpolationColors = blend
  1768.         G.FillRectangle(DrawGradientBrush, r)
  1769.     End Sub
  1770.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1771.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1772.         DrawGradientBrush.InterpolationColors = blend
  1773.         G.FillRectangle(DrawGradientBrush, r)
  1774.     End Sub
  1775.  
  1776.  
  1777.     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)
  1778.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1779.         DrawGradient(c1, c2, DrawGradientRectangle)
  1780.     End Sub
  1781.     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)
  1782.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1783.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1784.     End Sub
  1785.  
  1786.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1787.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1788.         G.FillRectangle(DrawGradientBrush, r)
  1789.     End Sub
  1790.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1791.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1792.         G.FillRectangle(DrawGradientBrush, r)
  1793.     End Sub
  1794.  
  1795. #End Region
  1796.  
  1797. #Region " DrawRadial "
  1798.  
  1799.     Private DrawRadialPath As GraphicsPath
  1800.     Private DrawRadialBrush1 As PathGradientBrush
  1801.     Private DrawRadialBrush2 As LinearGradientBrush
  1802.     Private DrawRadialRectangle As Rectangle
  1803.  
  1804.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1805.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1806.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1807.     End Sub
  1808.     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)
  1809.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1810.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1811.     End Sub
  1812.     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)
  1813.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1814.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1815.     End Sub
  1816.  
  1817.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1818.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1819.     End Sub
  1820.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1821.         DrawRadial(blend, r, center.X, center.Y)
  1822.     End Sub
  1823.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1824.         DrawRadialPath.Reset()
  1825.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1826.  
  1827.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1828.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1829.         DrawRadialBrush1.InterpolationColors = blend
  1830.  
  1831.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1832.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1833.         Else
  1834.             G.FillEllipse(DrawRadialBrush1, r)
  1835.         End If
  1836.     End Sub
  1837.  
  1838.  
  1839.     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)
  1840.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1841.         DrawRadial(c1, c2, DrawRadialRectangle)
  1842.     End Sub
  1843.     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)
  1844.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1845.         DrawRadial(c1, c2, DrawRadialRectangle, angle)
  1846.     End Sub
  1847.  
  1848.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1849.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1850.         G.FillEllipse(DrawRadialBrush2, r)
  1851.     End Sub
  1852.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1853.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1854.         G.FillEllipse(DrawRadialBrush2, r)
  1855.     End Sub
  1856.  
  1857. #End Region
  1858.  
  1859. #Region " CreateRound "
  1860.  
  1861.     Private CreateRoundPath As GraphicsPath
  1862.     Private CreateRoundRectangle As Rectangle
  1863.  
  1864.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  1865.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  1866.         Return CreateRound(CreateRoundRectangle, slope)
  1867.     End Function
  1868.  
  1869.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  1870.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  1871.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  1872.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  1873.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  1874.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  1875.         CreateRoundPath.CloseFigure()
  1876.         Return CreateRoundPath
  1877.     End Function
  1878.  
  1879. #End Region
  1880.  
  1881. End Class
  1882.  
  1883. Module ThemeShare
  1884.  
  1885. #Region " Animation "
  1886.  
  1887.     Private Frames As Integer
  1888.     Private Invalidate As Boolean
  1889.     Public ThemeTimer As New PrecisionTimer
  1890.  
  1891.     Private Const FPS As Integer = 50 '1000 / 50 = 20 FPS
  1892.     Private Const Rate As Integer = 10
  1893.  
  1894.     Public Delegate Sub AnimationDelegate(ByVal invalidate As Boolean)
  1895.  
  1896.     Private Callbacks As New List(Of AnimationDelegate)
  1897.  
  1898.     Private Sub HandleCallbacks(ByVal state As IntPtr, ByVal reserve As Boolean)
  1899.         Invalidate = (Frames >= FPS)
  1900.         If Invalidate Then Frames = 0
  1901.  
  1902.         SyncLock Callbacks
  1903.             For I As Integer = 0 To Callbacks.Count - 1
  1904.                 Callbacks(I).Invoke(Invalidate)
  1905.             Next
  1906.         End SyncLock
  1907.  
  1908.         Frames += Rate
  1909.     End Sub
  1910.  
  1911.     Private Sub InvalidateThemeTimer()
  1912.         If Callbacks.Count = 0 Then
  1913.             ThemeTimer.Delete()
  1914.         Else
  1915.             ThemeTimer.Create(0, Rate, AddressOf HandleCallbacks)
  1916.         End If
  1917.     End Sub
  1918.  
  1919.     Sub AddAnimationCallback(ByVal callback As AnimationDelegate)
  1920.         SyncLock Callbacks
  1921.             If Callbacks.Contains(callback) Then Return
  1922.  
  1923.             Callbacks.Add(callback)
  1924.             InvalidateThemeTimer()
  1925.         End SyncLock
  1926.     End Sub
  1927.  
  1928.     Sub RemoveAnimationCallback(ByVal callback As AnimationDelegate)
  1929.         SyncLock Callbacks
  1930.             If Not Callbacks.Contains(callback) Then Return
  1931.  
  1932.             Callbacks.Remove(callback)
  1933.             InvalidateThemeTimer()
  1934.         End SyncLock
  1935.     End Sub
  1936.  
  1937. #End Region
  1938.  
  1939. End Module
  1940.  
  1941. Enum MouseState As Byte
  1942.     None = 0
  1943.     Over = 1
  1944.     Down = 2
  1945.     Block = 3
  1946. End Enum
  1947.  
  1948. Structure Bloom
  1949.  
  1950.     Public _Name As String
  1951.     ReadOnly Property Name() As String
  1952.         Get
  1953.             Return _Name
  1954.         End Get
  1955.     End Property
  1956.  
  1957.     Private _Value As Color
  1958.     Property Value() As Color
  1959.         Get
  1960.             Return _Value
  1961.         End Get
  1962.         Set(ByVal value As Color)
  1963.             _Value = value
  1964.         End Set
  1965.     End Property
  1966.  
  1967.     Property ValueHex() As String
  1968.         Get
  1969.             Return String.Concat("#", _
  1970.             _Value.R.ToString("X2", Nothing), _
  1971.             _Value.G.ToString("X2", Nothing), _
  1972.             _Value.B.ToString("X2", Nothing))
  1973.         End Get
  1974.         Set(ByVal value As String)
  1975.             Try
  1976.                 _Value = ColorTranslator.FromHtml(value)
  1977.             Catch
  1978.                 Return
  1979.             End Try
  1980.         End Set
  1981.     End Property
  1982.  
  1983.  
  1984.     Sub New(ByVal name As String, ByVal value As Color)
  1985.         _Name = name
  1986.         _Value = value
  1987.     End Sub
  1988. End Structure
  1989.  
  1990. '------------------
  1991. 'Creator: aeonhack
  1992. 'Site: elitevs.net
  1993. 'Created: 11/30/2011
  1994. 'Changed: 11/30/2011
  1995. 'Version: 1.0.0
  1996. '------------------
  1997. Class PrecisionTimer
  1998.     Implements IDisposable
  1999.  
  2000.     Private _Enabled As Boolean
  2001.     ReadOnly Property Enabled() As Boolean
  2002.         Get
  2003.             Return _Enabled
  2004.         End Get
  2005.     End Property
  2006.  
  2007.     Private Handle As IntPtr
  2008.     Private TimerCallback As TimerDelegate
  2009.  
  2010.     <DllImport("kernel32.dll", EntryPoint:="CreateTimerQueueTimer")> _
  2011.     Private Shared Function CreateTimerQueueTimer( _
  2012.     ByRef handle As IntPtr, _
  2013.     ByVal queue As IntPtr, _
  2014.     ByVal callback As TimerDelegate, _
  2015.     ByVal state As IntPtr, _
  2016.     ByVal dueTime As UInteger, _
  2017.     ByVal period As UInteger, _
  2018.     ByVal flags As UInteger) As Boolean
  2019.     End Function
  2020.  
  2021.     <DllImport("kernel32.dll", EntryPoint:="DeleteTimerQueueTimer")> _
  2022.     Private Shared Function DeleteTimerQueueTimer( _
  2023.     ByVal queue As IntPtr, _
  2024.     ByVal handle As IntPtr, _
  2025.     ByVal callback As IntPtr) As Boolean
  2026.     End Function
  2027.  
  2028.     Delegate Sub TimerDelegate(ByVal r1 As IntPtr, ByVal r2 As Boolean)
  2029.  
  2030.     Sub Create(ByVal dueTime As UInteger, ByVal period As UInteger, ByVal callback As TimerDelegate)
  2031.         If _Enabled Then Return
  2032.  
  2033.         TimerCallback = callback
  2034.         Dim Success As Boolean = CreateTimerQueueTimer(Handle, IntPtr.Zero, TimerCallback, IntPtr.Zero, dueTime, period, 0)
  2035.  
  2036.         If Not Success Then ThrowNewException("CreateTimerQueueTimer")
  2037.         _Enabled = Success
  2038.     End Sub
  2039.  
  2040.     Sub Delete()
  2041.         If Not _Enabled Then Return
  2042.         Dim Success As Boolean = DeleteTimerQueueTimer(IntPtr.Zero, Handle, IntPtr.Zero)
  2043.  
  2044.         If Not Success AndAlso Not Marshal.GetLastWin32Error = 997 Then
  2045.             ThrowNewException("DeleteTimerQueueTimer")
  2046.         End If
  2047.  
  2048.         _Enabled = Not Success
  2049.     End Sub
  2050.  
  2051.     Private Sub ThrowNewException(ByVal name As String)
  2052.         Throw New Exception(String.Format("{0} failed. Win32Error: {1}", name, Marshal.GetLastWin32Error))
  2053.     End Sub
  2054.  
  2055.     Public Sub Dispose() Implements IDisposable.Dispose
  2056.         Delete()
  2057.     End Sub
  2058. End Class
  2059.  
  2060. #End Region
  2061.  
  2062. Class SugarTheme
  2063.     Inherits ThemeContainer154
  2064.  
  2065.  
  2066.     Sub New()
  2067.         TransparencyKey = Color.Fuchsia
  2068.         BackColor = Color.FromArgb(247, 249, 254)
  2069.         Font = New Font("Century Gothic", 11)
  2070.         SetColor("Border", Color.FromArgb(190, 210, 217))
  2071.         SetColor("text", Color.FromArgb(49, 51, 48))
  2072.  
  2073.     End Sub
  2074.     Dim Border As Color
  2075.     Dim TextBrush As Brush
  2076.  
  2077.  
  2078.  
  2079.     Protected Overrides Sub ColorHook()
  2080.         Border = GetColor("Border")
  2081.         TextBrush = GetBrush("text")
  2082.  
  2083.     End Sub
  2084.  
  2085.     Protected Overrides Sub PaintHook()
  2086.         G.Clear(Border)
  2087.         Dim HB As New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(30, Color.White), Color.Transparent)
  2088.  
  2089.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(6, 36, Width - 13, Height - 43))
  2090.         G.FillRectangle(HB, New Rectangle(0, 0, Width - 1, Height - 1))
  2091.         G.DrawString(FindForm.Text, Font, TextBrush, New Point(35, 10))
  2092.         G.DrawIcon(FindForm.Icon, New Rectangle(10, 10, 16, 16))
  2093.         DrawCorners(Color.Fuchsia)
  2094.     End Sub
  2095. End Class
  2096.  
  2097. Class SugarButton
  2098.     Inherits ThemeControl154
  2099.     Dim Buttoncolor As Color
  2100.     Dim Textcolor As Brush
  2101.     Dim Border As Pen
  2102.  
  2103.     Sub New()
  2104.         SetColor("Button", Color.FromArgb(220, 232, 235))
  2105.         SetColor("Text", Color.FromArgb(49, 51, 48))
  2106.         SetColor("Border", Color.White)
  2107.  
  2108.     End Sub
  2109.  
  2110.     Protected Overrides Sub ColorHook()
  2111.         Buttoncolor = GetColor("Button")
  2112.         Textcolor = GetBrush("Text")
  2113.         Border = GetPen("Border")
  2114.  
  2115.     End Sub
  2116.  
  2117.     Protected Overrides Sub PaintHook()
  2118.         G.Clear(Buttoncolor)
  2119.  
  2120.  
  2121.         DrawCorners(BackColor)
  2122.         Select Case State
  2123.             Case MouseState.None
  2124.  
  2125.                 Dim HB As New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(30, Color.White), Color.Transparent)
  2126.                 G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  2127.                 G.FillRectangle(HB, New Rectangle(0, 0, Width - 1, Height - 1))
  2128.                 DrawText(Textcolor, HorizontalAlignment.Center, 0, 0)
  2129.  
  2130.             Case MouseState.Over
  2131.  
  2132.                 Dim HB As New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(30, Color.White), Color.Transparent)
  2133.                 G.FillRectangle(New SolidBrush(Color.FromArgb(236, 241, 242)), New Rectangle(0, 0, Width - 1, Height - 1))
  2134.                 G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  2135.                 G.FillRectangle(HB, New Rectangle(0, 0, Width - 1, Height - 1))
  2136.                 DrawText(Textcolor, HorizontalAlignment.Center, 0, 0)
  2137.             Case MouseState.Down
  2138.  
  2139.                 Dim HB As New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(30, Color.White), Color.Transparent)
  2140.                 G.FillRectangle(New SolidBrush(Color.FromArgb(50, Color.Black)), New Rectangle(0, 0, Width - 1, Height - 1))
  2141.                 G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  2142.                 G.FillRectangle(HB, New Rectangle(0, 0, Width - 1, Height - 1))
  2143.                 DrawText(Textcolor, HorizontalAlignment.Center, 0, 0)
  2144.         End Select
  2145.     End Sub
  2146. End Class
  2147.  
  2148. Class SugarProgressbar
  2149.     Inherits ThemeControl154
  2150.     Private _Maximum As Integer = 100
  2151.     Private _Value As Integer
  2152.     Private HOffset As Integer = 0
  2153.     Private Progress As Integer
  2154.     Protected Overrides Sub ColorHook()
  2155.  
  2156.     End Sub
  2157.  
  2158.     Public Property Maximum As Integer
  2159.         Get
  2160.             Return _Maximum
  2161.         End Get
  2162.         Set(ByVal V As Integer)
  2163.             If V < 1 Then V = 1
  2164.             If V < _Value Then _Value = V
  2165.             _Maximum = V
  2166.             Invalidate()
  2167.         End Set
  2168.     End Property
  2169.     Public Property Value As Integer
  2170.         Get
  2171.             Return _Value
  2172.         End Get
  2173.         Set(ByVal V As Integer)
  2174.             If V > _Maximum Then V = Maximum
  2175.             _Value = V
  2176.             Invalidate()
  2177.         End Set
  2178.     End Property
  2179.     Public Property Animated As Boolean
  2180.         Get
  2181.             Return IsAnimated
  2182.         End Get
  2183.         Set(ByVal V As Boolean)
  2184.             IsAnimated = V
  2185.             Invalidate()
  2186.         End Set
  2187.     End Property
  2188.  
  2189.     Protected Overrides Sub OnAnimation()
  2190.         HOffset -= 1
  2191.         If HOffset = 7 Then HOffset = 0
  2192.     End Sub
  2193.  
  2194.     Protected Overrides Sub PaintHook()
  2195.         Dim hatch As New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(60, Color.Green))
  2196.         G.Clear(Color.FromArgb(0, 236, 241, 242))
  2197.         Dim cblend As New ColorBlend(2)
  2198.         cblend.Colors(0) = Color.FromArgb(236, 241, 242)
  2199.         cblend.Colors(1) = Color.FromArgb(236, 241, 242)
  2200.         cblend.Positions(0) = 0
  2201.         cblend.Positions(1) = 1
  2202.         DrawGradient(cblend, New Rectangle(0, 0, CInt(((Width / _Maximum) * _Value) - 2), Height - 2))
  2203.         cblend.Colors(1) = Color.FromArgb(236, 241, 242)
  2204.         DrawGradient(cblend, New Rectangle(0, 0, CInt(((Width / _Maximum) * _Value) - 2), Height / 5 * 2))
  2205.         G.RenderingOrigin = New Point(HOffset, 0)
  2206.         hatch = New HatchBrush(HatchStyle.ForwardDiagonal, Color.FromArgb(40, Color.Green), Color.FromArgb(0, Color.Green))
  2207.         G.FillRectangle(hatch, 0, 0, CInt(((Width / _Maximum) * _Value) - 2), Height - 2)
  2208.         DrawBorders(Pens.Black)
  2209.         DrawBorders(New Pen(Color.FromArgb(236, 241, 242)), 1)
  2210.         DrawCorners(Color.Black)
  2211.         G.DrawLine(New Pen(Color.FromArgb(200, 236, 241, 242)), CInt(((Width / _Maximum) * _Value) - 2), 1, CInt(((Width / _Maximum) * _Value) - 2), Height - 2)
  2212.         G.DrawLine(Pens.Green, CInt(((Width / _Maximum) * _Value) - 2) + 1, 2, CInt(((Width / _Maximum) * _Value) - 2) + 1, Height - 3)
  2213.         Progress = CInt(((Width / _Maximum) * _Value))
  2214.         Dim cblend2 As New ColorBlend(3)
  2215.         cblend2.Colors(0) = Color.FromArgb(0, Color.Gray)
  2216.         cblend2.Colors(1) = Color.FromArgb(80, Color.DimGray)
  2217.         cblend2.Colors(2) = Color.FromArgb(0, Color.Gray)
  2218.         cblend2.Positions = {0, 0.5, 1}
  2219.         Dim HB As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(30, Color.White), Color.Transparent)
  2220.         G.FillRectangle(New SolidBrush(Color.FromArgb(190, 210, 217)), CInt(((Width / _Maximum) * _Value)) - 1, 2, Width - CInt(((Width / _Maximum) * _Value)) - 1, Height - 4)
  2221.         G.FillRectangle(HB, New Rectangle(0, 0, Width - 1, Height - 1))
  2222.         If Value > 0 Then G.FillRectangle(New SolidBrush(Color.FromArgb(190, 210, 217)), CInt(((Width / _Maximum) * _Value)) - 1, 2, Width - CInt(((Width / _Maximum) * _Value)) - 1, Height - 4)
  2223.     End Sub
  2224.  
  2225.     Public Sub New()
  2226.         _Maximum = 100
  2227.         IsAnimated = True
  2228.     End Sub
  2229. End Class
  2230.  
  2231. <DefaultEvent("CheckedChanged")> _
  2232. Class SugarRadiobutton
  2233.     Inherits ThemeControl154
  2234.     Private X As Integer
  2235.     Private _Checked As Boolean
  2236.  
  2237.     Property Checked() As Boolean
  2238.         Get
  2239.             Return _Checked
  2240.         End Get
  2241.         Set(ByVal value As Boolean)
  2242.             _Checked = value
  2243.             InvalidateControls()
  2244.             RaiseEvent CheckedChanged(Me)
  2245.             Invalidate()
  2246.         End Set
  2247.     End Property
  2248.  
  2249.     Event CheckedChanged(ByVal sender As Object)
  2250.  
  2251.     Protected Overrides Sub OnCreation()
  2252.         InvalidateControls()
  2253.     End Sub
  2254.  
  2255.     Private Sub InvalidateControls()
  2256.         If Not IsHandleCreated OrElse Not _Checked Then Return
  2257.  
  2258.         For Each C As Control In Parent.Controls
  2259.             If C IsNot Me AndAlso TypeOf C Is SugarRadiobutton Then
  2260.                 DirectCast(C, SugarRadiobutton).Checked = False
  2261.             End If
  2262.         Next
  2263.     End Sub
  2264.  
  2265.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  2266.         If Not _Checked Then Checked = True
  2267.         MyBase.OnMouseDown(e)
  2268.     End Sub
  2269.  
  2270.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  2271.         MyBase.OnMouseMove(e)
  2272.         X = e.X
  2273.         Invalidate()
  2274.     End Sub
  2275.  
  2276.     Protected Overrides Sub ColorHook()
  2277.  
  2278.     End Sub
  2279.  
  2280.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  2281.         MyBase.OnTextChanged(e)
  2282.         Dim textSize As Integer
  2283.         textSize = Me.CreateGraphics.MeasureString(Text, Font).Width
  2284.         Me.Width = 20 + textSize
  2285.     End Sub
  2286.  
  2287.     Protected Overrides Sub PaintHook()
  2288.         G.Clear(Color.FromArgb(247, 249, 254))
  2289.         Dim asdf As HatchBrush
  2290.         asdf = New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(35, Color.Black), Color.FromArgb(0, Color.Gray))
  2291.         G.FillRectangle(New SolidBrush(Color.FromArgb(247, 249, 254)), New Rectangle(0, 0, Width, Height))
  2292.         asdf = New HatchBrush(HatchStyle.LightDownwardDiagonal, Color.DimGray)
  2293.         G.FillRectangle(asdf, 0, 0, Width, Height)
  2294.         G.FillRectangle(New SolidBrush(Color.FromArgb(247, 249, 254)), 0, 0, Width, Height)
  2295.  
  2296.         G.SmoothingMode = SmoothingMode.AntiAlias
  2297.         G.FillEllipse(New SolidBrush(Color.FromArgb(220, 232, 235)), 2, 2, 11, 11)
  2298.         G.DrawEllipse(Pens.Black, 0, 0, 13, 13)
  2299.         G.DrawEllipse(New Pen(Color.FromArgb(220, 232, 235)), 1, 1, 11, 11)
  2300.  
  2301.         If _Checked = False Then
  2302.             Dim hatch As HatchBrush
  2303.             hatch = New HatchBrush(HatchStyle.LightDownwardDiagonal, Color.FromArgb(20, Color.White), Color.FromArgb(0, Color.Gray))
  2304.             G.FillEllipse(hatch, 2, 2, 10, 10)
  2305.         Else
  2306.             G.FillEllipse(New SolidBrush(Color.FromArgb(80, 80, 80)), 3, 3, 7, 7)
  2307.             Dim hatch As HatchBrush
  2308.             hatch = New HatchBrush(HatchStyle.LightDownwardDiagonal, Color.FromArgb(60, Color.Black), Color.FromArgb(0, Color.Gray))
  2309.             G.FillRectangle(hatch, 3, 3, 7, 7)
  2310.         End If
  2311.  
  2312.         If State = MouseState.Over And X < 13 Then
  2313.             G.FillEllipse(New SolidBrush(Color.FromArgb(20, Color.White)), 2, 2, 11, 11)
  2314.         End If
  2315.  
  2316.         G.DrawString(Text, Font, Brushes.Black, 16, 0)
  2317.     End Sub
  2318.  
  2319.     Public Sub New()
  2320.         Me.Size = New Point(50, 14)
  2321.     End Sub
  2322. End Class
  2323.  
  2324. <DefaultEvent("CheckedChanged")> _
  2325. Class SugarCheckbox
  2326.     Inherits ThemeControl154
  2327.     Private _Checked As Boolean
  2328.     Private X As Integer
  2329.  
  2330.     Event CheckedChanged(ByVal sender As Object)
  2331.  
  2332.     Public Property Checked As Boolean
  2333.         Get
  2334.             Return _Checked
  2335.         End Get
  2336.         Set(ByVal V As Boolean)
  2337.             _Checked = V
  2338.             Invalidate()
  2339.             RaiseEvent CheckedChanged(Me)
  2340.         End Set
  2341.     End Property
  2342.  
  2343.     Protected Overrides Sub ColorHook()
  2344.  
  2345.     End Sub
  2346.  
  2347.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  2348.         MyBase.OnTextChanged(e)
  2349.         Dim textSize As Integer
  2350.         textSize = Me.CreateGraphics.MeasureString(Text, Font).Width
  2351.         Me.Width = 20 + textSize
  2352.     End Sub
  2353.  
  2354.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  2355.         MyBase.OnMouseMove(e)
  2356.         X = e.X
  2357.         Invalidate()
  2358.     End Sub
  2359.  
  2360.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  2361.         MyBase.OnMouseDown(e)
  2362.         If _Checked = True Then _Checked = False Else _Checked = True
  2363.     End Sub
  2364.  
  2365.     Protected Overrides Sub PaintHook()
  2366.         G.Clear(Color.FromArgb(239, 254, 213))
  2367.         Dim asdf As HatchBrush
  2368.         asdf = New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(35, Color.Black), Color.FromArgb(0, Color.Gray))
  2369.         G.FillRectangle(New SolidBrush(Color.FromArgb(247, 249, 254)), New Rectangle(0, 0, Width, Height))
  2370.         asdf = New HatchBrush(HatchStyle.LightDownwardDiagonal, Color.DimGray)
  2371.         G.FillRectangle(asdf, 0, 0, Width, Height)
  2372.         G.FillRectangle(New SolidBrush(Color.FromArgb(247, 249, 254)), 0, 0, Width, Height)
  2373.  
  2374.         G.FillRectangle(New SolidBrush(Color.FromArgb(247, 249, 254)), 3, 3, 10, 10)
  2375.         If _Checked Then
  2376.             Dim cblend As New ColorBlend(2)
  2377.             cblend.Colors(0) = Color.FromArgb(190, 210, 217)
  2378.             cblend.Colors(1) = Color.FromArgb(190, 210, 217)
  2379.             cblend.Positions(0) = 0
  2380.             cblend.Positions(1) = 1
  2381.             DrawGradient(cblend, New Rectangle(3, 3, 10, 10))
  2382.             cblend.Colors(0) = Color.FromArgb(190, 210, 217)
  2383.             cblend.Colors(1) = Color.FromArgb(190, 210, 217)
  2384.             DrawGradient(cblend, New Rectangle(3, 3, 10, 4))
  2385.             Dim hatch As HatchBrush
  2386.             hatch = New HatchBrush(HatchStyle.LightDownwardDiagonal, Color.FromArgb(60, Color.Black), Color.FromArgb(0, Color.Gray))
  2387.             G.FillRectangle(hatch, 3, 3, 10, 10)
  2388.         Else
  2389.             Dim hatch As HatchBrush
  2390.             hatch = New HatchBrush(HatchStyle.LightDownwardDiagonal, Color.FromArgb(20, Color.White), Color.FromArgb(0, Color.Gray))
  2391.             G.FillRectangle(hatch, 3, 3, 10, 10)
  2392.         End If
  2393.  
  2394.         If State = MouseState.Over And X < 15 Then
  2395.             G.FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Gray)), New Rectangle(3, 3, 10, 10))
  2396.         ElseIf State = MouseState.Down Then
  2397.             G.FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), New Rectangle(3, 3, 10, 10))
  2398.         End If
  2399.  
  2400.         G.DrawRectangle(Pens.Black, 0, 0, 15, 15)
  2401.         G.DrawRectangle(New Pen(Color.FromArgb(90, 90, 90)), 1, 1, 13, 13)
  2402.         G.DrawString(Text, Font, Brushes.Black, 17, 1)
  2403.     End Sub
  2404.  
  2405.     Public Sub New()
  2406.         Me.Size = New Point(16, 50)
  2407.     End Sub
  2408. End Class
  2409.  
  2410. Class SugarTabControl
  2411.     Inherits TabControl
  2412.     Private Xstart(9999) As Integer 'Stupid VB.Net bug. Please don't use more than 9999 tabs :3
  2413.     Private Xstop(9999) As Integer  'Stupid VB.Net bug. Please don't use more than 9999 tabs :3
  2414.  
  2415.     Sub New()
  2416.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  2417.         DoubleBuffered = True
  2418.         For Each p As TabPage In TabPages
  2419.             p.BackColor = Color.FromArgb(247, 249, 254)
  2420.             Application.DoEvents()
  2421.             p.BackColor = Color.FromArgb(247, 249, 254)
  2422.         Next
  2423.     End Sub
  2424.     Protected Overrides Sub CreateHandle()
  2425.         MyBase.CreateHandle()
  2426.         Alignment = TabAlignment.Top
  2427.     End Sub
  2428.  
  2429.     Protected Overrides Sub OnMouseClick(ByVal e As System.Windows.Forms.MouseEventArgs)
  2430.         MyBase.OnMouseClick(e)
  2431.         Dim index As Integer = 0
  2432.         Dim height As Integer = Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 8
  2433.         For Each a As Integer In Xstart
  2434.             If e.X > a And e.X < Xstop(index) And e.Y < height And e.Button = Windows.Forms.MouseButtons.Left Then
  2435.                 SelectedIndex = index
  2436.                 Invalidate()
  2437.             Else
  2438.             End If
  2439.             index += 1
  2440.         Next
  2441.     End Sub
  2442.  
  2443.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  2444.         Dim B As New Bitmap(Width, Height)
  2445.         Dim G As Graphics = Graphics.FromImage(B)
  2446.         G.Clear(Color.Red)
  2447.         Dim asdf As HatchBrush
  2448.         asdf = New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(35, Color.Red), Color.Pink)
  2449.         G.FillRectangle(New SolidBrush(Color.Red), New Rectangle(0, 0, Width, Height))
  2450.         asdf = New HatchBrush(HatchStyle.LightDownwardDiagonal, Color.DimGray)
  2451.         G.FillRectangle(asdf, 0, 0, Width, Height)
  2452.         G.FillRectangle(New SolidBrush(Color.FromArgb(190, 210, 217)), 0, 0, Width, Height)
  2453.  
  2454.         G.FillRectangle(Brushes.PowderBlue, 0, 0, Width, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 8)
  2455.         G.FillRectangle(New SolidBrush(Color.FromArgb(190, 210, 217)), 2, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 7, Width - 2, Height - 2)
  2456.  
  2457.         Dim totallength As Integer = 0
  2458.         Dim index As Integer = 0
  2459.         For Each tab As TabPage In TabPages
  2460.             If SelectedIndex = index Then
  2461.                 G.FillRectangle(New SolidBrush(Color.Red), totallength, 1, Me.CreateGraphics.MeasureString(tab.Text, Font).Width + 15, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 10)
  2462.                 asdf = New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(35, Color.Red), Color.FromArgb(0, Color.Blue))
  2463.                 G.FillRectangle(New SolidBrush(Color.FromArgb(199, 211, 229)), totallength, 1, Me.CreateGraphics.MeasureString(tab.Text, Font).Width + 15, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 10)
  2464.                 asdf = New HatchBrush(HatchStyle.LightDownwardDiagonal, Color.Blue)
  2465.                 G.FillRectangle(asdf, totallength, 1, Me.CreateGraphics.MeasureString(tab.Text, Font).Width + 15, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 10)
  2466.                 G.FillRectangle(New SolidBrush(Color.FromArgb(190, 210, 217)), totallength, 1, Me.CreateGraphics.MeasureString(tab.Text, Font).Width + 15, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 10)
  2467.  
  2468.                 Dim gradient As New LinearGradientBrush(New Point(totallength, 1), New Point(totallength, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 8), Color.FromArgb(15, Color.Black), Color.Transparent)
  2469.                 G.FillRectangle(gradient, totallength, 1, Me.CreateGraphics.MeasureString(tab.Text, Font).Width + 15, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 5)
  2470.  
  2471.                 G.DrawLine(New Pen(Color.FromArgb(190, 210, 217)), totallength, 2, totallength, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 8)
  2472.  
  2473.                 G.DrawLine(New Pen(Color.FromArgb(190, 210, 217)), totallength + Me.CreateGraphics.MeasureString(tab.Text, Font).Width + 15, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 8, Width - 1, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 8)
  2474.                 G.DrawLine(New Pen(Color.FromArgb(190, 210, 217)), 1, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 8, totallength, Me.CreateGraphics.MeasureString("Sasi is awesome", Font).Height + 8)
  2475.  
  2476.             End If
  2477.             Xstart(index) = totallength
  2478.             Xstop(index) = totallength + Me.CreateGraphics.MeasureString(tab.Text, Font).Width + 15
  2479.             G.DrawString(tab.Text, Font, Brushes.Black, totallength + 8, 5)
  2480.             totallength += Me.CreateGraphics.MeasureString(tab.Text, Font).Width + 15
  2481.             index += 1
  2482.         Next
  2483.  
  2484.         G.DrawLine(New Pen(Color.FromArgb(190, 210, 217)), 1, 1, Width - 2, 1) 'boven
  2485.         G.DrawLine(New Pen(Color.FromArgb(190, 210, 217)), 1, Height - 2, Width - 2, Height - 2) 'onder
  2486.         G.DrawLine(New Pen(Color.FromArgb(190, 210, 217)), 1, 1, 1, Height - 2) 'links
  2487.         G.DrawLine(New Pen(Color.FromArgb(190, 210, 217)), Width - 2, 1, Width - 2, Height - 2) 'rechts
  2488.  
  2489.         G.DrawLine(Pens.Transparent, 0, 0, Width - 1, 0) 'boven
  2490.         G.DrawLine(Pens.Transparent, 0, Height - 1, Width, Height - 1) 'onder
  2491.         G.DrawLine(Pens.Transparent, 0, 0, 0, Height - 1) 'links
  2492.         G.DrawLine(Pens.Transparent, Width - 1, 0, Width - 1, Height - 1) 'rechts
  2493.  
  2494.         e.Graphics.DrawImage(B.Clone, 0, 0)
  2495.         G.Dispose() : B.Dispose()
  2496.     End Sub
  2497.  
  2498.     Protected Overrides Sub OnSelectedIndexChanged(ByVal e As System.EventArgs)
  2499.         MyBase.OnSelectedIndexChanged(e)
  2500.         Invalidate()
  2501.     End Sub
  2502. End Class
  2503.  
  2504. <DefaultEvent("TextChanged")> _
  2505. Class SugarTextBox
  2506.     Inherits ThemeControl154
  2507.  
  2508.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  2509.     Property TextAlign() As HorizontalAlignment
  2510.         Get
  2511.             Return _TextAlign
  2512.         End Get
  2513.         Set(ByVal value As HorizontalAlignment)
  2514.             _TextAlign = value
  2515.             If Base IsNot Nothing Then
  2516.                 Base.TextAlign = value
  2517.             End If
  2518.         End Set
  2519.     End Property
  2520.     Private _MaxLength As Integer = 32767
  2521.     Property MaxLength() As Integer
  2522.         Get
  2523.             Return _MaxLength
  2524.         End Get
  2525.         Set(ByVal value As Integer)
  2526.             _MaxLength = value
  2527.             If Base IsNot Nothing Then
  2528.                 Base.MaxLength = value
  2529.             End If
  2530.         End Set
  2531.     End Property
  2532.     Private _ReadOnly As Boolean
  2533.     Property [ReadOnly]() As Boolean
  2534.         Get
  2535.             Return _ReadOnly
  2536.         End Get
  2537.         Set(ByVal value As Boolean)
  2538.             _ReadOnly = value
  2539.             If Base IsNot Nothing Then
  2540.                 Base.ReadOnly = value
  2541.             End If
  2542.         End Set
  2543.     End Property
  2544.     Private _UseSystemPasswordChar As Boolean
  2545.     Property UseSystemPasswordChar() As Boolean
  2546.         Get
  2547.             Return _UseSystemPasswordChar
  2548.         End Get
  2549.         Set(ByVal value As Boolean)
  2550.             _UseSystemPasswordChar = value
  2551.             If Base IsNot Nothing Then
  2552.                 Base.UseSystemPasswordChar = value
  2553.             End If
  2554.         End Set
  2555.     End Property
  2556.     Private _Multiline As Boolean
  2557.     Property Multiline() As Boolean
  2558.         Get
  2559.             Return _Multiline
  2560.         End Get
  2561.         Set(ByVal value As Boolean)
  2562.             _Multiline = value
  2563.             If Base IsNot Nothing Then
  2564.                 Base.Multiline = value
  2565.  
  2566.                 If value Then
  2567.                     LockHeight = 0
  2568.                     Base.Height = Height - 11
  2569.                 Else
  2570.                     LockHeight = Base.Height + 11
  2571.                 End If
  2572.             End If
  2573.         End Set
  2574.     End Property
  2575.     Overrides Property Text As String
  2576.         Get
  2577.             Return MyBase.Text
  2578.         End Get
  2579.         Set(ByVal value As String)
  2580.             MyBase.Text = value
  2581.             If Base IsNot Nothing Then
  2582.                 Base.Text = value
  2583.             End If
  2584.         End Set
  2585.     End Property
  2586.     Overrides Property Font As Font
  2587.         Get
  2588.             Return MyBase.Font
  2589.         End Get
  2590.         Set(ByVal value As Font)
  2591.             MyBase.Font = value
  2592.             If Base IsNot Nothing Then
  2593.                 Base.Font = value
  2594.                 Base.Location = New Point(3, 5)
  2595.                 Base.Width = Width - 6
  2596.  
  2597.                 If Not _Multiline Then
  2598.                     LockHeight = Base.Height + 11
  2599.                 End If
  2600.             End If
  2601.         End Set
  2602.     End Property
  2603.  
  2604.     Protected Overrides Sub OnCreation()
  2605.         If Not Controls.Contains(Base) Then
  2606.             Controls.Add(Base)
  2607.         End If
  2608.     End Sub
  2609.  
  2610.     Private Base As TextBox
  2611.     Sub New()
  2612.         Base = New TextBox
  2613.  
  2614.         Base.Font = Font
  2615.         Base.Text = Text
  2616.         Base.MaxLength = _MaxLength
  2617.         Base.Multiline = _Multiline
  2618.         Base.ReadOnly = _ReadOnly
  2619.         Base.UseSystemPasswordChar = _UseSystemPasswordChar
  2620.  
  2621.         Base.BorderStyle = BorderStyle.None
  2622.  
  2623.         Base.Location = New Point(5, 5)
  2624.         Base.Width = Width - 10
  2625.  
  2626.         If _Multiline Then
  2627.             Base.Height = Height - 11
  2628.         Else
  2629.             LockHeight = Base.Height + 11
  2630.         End If
  2631.  
  2632.         AddHandler Base.TextChanged, AddressOf OnBaseTextChanged
  2633.         AddHandler Base.KeyDown, AddressOf OnBaseKeyDown
  2634.  
  2635.  
  2636.         SetColor("Text", Color.Black)
  2637.         SetColor("Back", Color.FromArgb(220, 232, 235))
  2638.         SetColor("Border1", Color.White)
  2639.         SetColor("Border2", Color.White)
  2640.     End Sub
  2641.  
  2642.     Private C1 As Color
  2643.     Private P1, P2 As Pen
  2644.  
  2645.     Protected Overrides Sub ColorHook()
  2646.         C1 = GetColor("Back")
  2647.  
  2648.         P1 = GetPen("Border1")
  2649.         P2 = GetPen("Border2")
  2650.  
  2651.         Base.ForeColor = GetColor("Text")
  2652.         Base.BackColor = C1
  2653.     End Sub
  2654.  
  2655.     Protected Overrides Sub PaintHook()
  2656.         G.Clear(C1)
  2657.  
  2658.         DrawBorders(P1, 1)
  2659.         DrawBorders(P2)
  2660.     End Sub
  2661.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  2662.         Text = Base.Text
  2663.     End Sub
  2664.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  2665.         If e.Control AndAlso e.KeyCode = Keys.A Then
  2666.             Base.SelectAll()
  2667.             e.SuppressKeyPress = True
  2668.         End If
  2669.     End Sub
  2670.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  2671.         Base.Location = New Point(5, 5)
  2672.         Base.Width = Width - 10
  2673.  
  2674.         If _Multiline Then
  2675.             Base.Height = Height - 11
  2676.         End If
  2677.  
  2678.  
  2679.         MyBase.OnResize(e)
  2680.     End Sub
  2681.  
  2682. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement