Advertisement
Guest User

Steam Theme Boudoire

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