Scourge

[VB] Complex Theme

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