Advertisement
Guest User

Untitled

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