Advertisement
Guest User

Untitled

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