Advertisement
Guest User

Blue Theme

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