FuckFace32

The Blue and White GUI Theme

Apr 26th, 2014
2,116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 45.35 KB | None | 0 0
  1. Imports System.ComponentModel, System.Drawing.Drawing2D, System.Windows.Forms
  2.  
  3. '----------------------------
  4. 'The Blue and White GUI Theme
  5. 'Creator: FuckFace
  6. 'Version: 1.0
  7. 'Created: 14/04/2014
  8. 'Changed: 26/04/2014
  9. '----------------------------
  10. Class BaWGUIButton : Inherits Control
  11. #Region " Declarations "
  12.     Private State As Integer
  13.     Private Shape As GraphicsPath
  14.     Private InactiveGB, ActiveGB, ActiveContourGB, PressedGB, PressedContourGB As LinearGradientBrush
  15.     Private R1, R2 As Rectangle
  16.     Private P1, P2, P3, P4 As Pen
  17.     Private B1, B2, B3 As SolidBrush
  18.     Private CSF As StringFormat = New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
  19. #End Region
  20.  
  21.     Sub New()
  22.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  23.                 ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  24.  
  25.         BackColor = Color.Transparent
  26.         DoubleBuffered = True
  27.         Font = New Font("Arial", 12)
  28.         Size = New Size(130, 45)
  29.  
  30.         P1 = New Pen(Color.FromArgb(185, 185, 185))
  31.         ' P2 is in the OnResize event.
  32.         ' P3 is in the OnResize event.
  33.         P4 = New Pen(Color.FromArgb(135, 182, 233))
  34.         B1 = New SolidBrush(Color.FromArgb(114, 114, 114))
  35.         B2 = New SolidBrush(Color.FromArgb(246, 247, 250))
  36.         B3 = New SolidBrush(Color.FromArgb(25, 55, 82))
  37.     End Sub
  38.  
  39.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  40.         State = 2
  41.         Invalidate()
  42.  
  43.         MyBase.OnMouseDown(e)
  44.     End Sub
  45.  
  46.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  47.         State = 1
  48.         Invalidate()
  49.  
  50.         MyBase.OnMouseEnter(e)
  51.     End Sub
  52.  
  53.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  54.         State = 0
  55.         Invalidate()
  56.  
  57.         MyBase.OnMouseLeave(e)
  58.     End Sub
  59.  
  60.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  61.         State = 1
  62.         Invalidate()
  63.  
  64.         MyBase.OnMouseUp(e)
  65.     End Sub
  66.  
  67.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  68.         Invalidate() : MyBase.OnTextChanged(e)
  69.     End Sub
  70.  
  71.     Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  72.         If Width > 0 AndAlso Height > 0 Then
  73.             Shape = New GraphicsPath
  74.  
  75.             R1 = New Rectangle(0, 0, Width, Height)
  76.             R2 = New Rectangle(0, 1, Width, Height)
  77.  
  78.             InactiveGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(249, 249, 249) _
  79.                                                  , Color.FromArgb(222, 222, 222), 90)
  80.             ActiveGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(171, 210, 244) _
  81.                                                , Color.FromArgb(84, 153, 228), 90)
  82.             ActiveContourGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(121, 180, 235) _
  83.                                                       , Color.FromArgb(70, 137, 201), 90)
  84.             PressedGB = New LinearGradientBrush(New Rectangle(0, 1, Width, Height), Color.FromArgb(97, 162, 228) _
  85.                                                 , Color.FromArgb(114, 173, 233), 90)
  86.             PressedContourGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(74, 141, 208) _
  87.                                                        , Color.FromArgb(114, 173, 230), 90)
  88.  
  89.             P2 = New Pen(ActiveContourGB)
  90.             P3 = New Pen(PressedContourGB)
  91.  
  92.             With Shape
  93.                 .AddArc(0, 0, 10, 10, 180, 90)
  94.                 .AddArc(Width - 11, 0, 10, 10, -90, 90)
  95.                 .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  96.                 .AddArc(0, Height - 11, 10, 10, 90, 90)
  97.                 .CloseAllFigures()
  98.             End With
  99.         End If
  100.  
  101.         Invalidate()
  102.         MyBase.OnResize(e)
  103.     End Sub
  104.  
  105.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  106.         With e.Graphics
  107.             .SmoothingMode = SmoothingMode.HighQuality
  108.  
  109.             Select Case State
  110.                 Case 0 'Inactive
  111.                     .FillPath(InactiveGB, Shape)
  112.                     .DrawPath(P1, Shape)
  113.                     .DrawString(Text, Font, B1, R1, CSF)
  114.                 Case 1 'Active
  115.                     .FillPath(ActiveGB, Shape)
  116.                     .DrawPath(P2, Shape)
  117.                     .DrawString(Text, Font, Brushes.DarkSlateGray, R2, CSF)
  118.                     .DrawString(Text, Font, B2, R1, CSF)
  119.                 Case 2 'Pressed
  120.                     .FillPath(PressedGB, Shape)
  121.                     .DrawPath(P3, Shape)
  122.                     .DrawLine(P4, 1, 1, Width - 2, 1)
  123.                     .DrawString(Text, Font, Brushes.White, R2, CSF)
  124.                     .DrawString(Text, Font, B3, R1, CSF)
  125.             End Select
  126.         End With
  127.  
  128.         MyBase.OnPaint(e)
  129.     End Sub
  130. End Class
  131.  
  132. <DefaultEvent("CheckedChanged")> Public Class BaWGUICheckBox : Inherits Control
  133. #Region " Declarations "
  134.     Private MFont As New Font("Marlett", 16)
  135.     Private Shape As GraphicsPath
  136.     Private GB As LinearGradientBrush
  137.     Private P1 As Pen
  138.     Private R1, R2 As Rectangle
  139.     Private B1, B2 As SolidBrush
  140.     Private CSF As StringFormat = New StringFormat() With {.LineAlignment = StringAlignment.Center}
  141.  
  142.     Event CheckedChanged(ByVal sender As Object)
  143.  
  144.     Private _Checked As Boolean
  145. #End Region
  146.  
  147. #Region " Properties "
  148.     <Category("Appearance")> _
  149.     Property Checked As Boolean
  150.         Get
  151.             Return _Checked
  152.         End Get
  153.         Set(ByVal value As Boolean)
  154.             _Checked = value
  155.             RaiseEvent CheckedChanged(Me)
  156.             Invalidate()
  157.         End Set
  158.     End Property
  159. #End Region
  160.  
  161.     Sub New()
  162.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  163.         ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  164.  
  165.         BackColor = Color.Transparent
  166.         DoubleBuffered = True
  167.         Font = New Font("Arial", 12)
  168.         Size = New Size(185, 26)
  169.  
  170.         P1 = New Pen(Color.FromArgb(160, 160, 160))
  171.         B1 = New SolidBrush(Color.FromArgb(114, 114, 114))
  172.         B2 = New SolidBrush(Color.FromArgb(110, 175, 235))
  173.     End Sub
  174.  
  175.     Protected Overrides Sub OnClick(ByVal e As EventArgs)
  176.         _Checked = Not _Checked
  177.         RaiseEvent CheckedChanged(Me)
  178.         Invalidate()
  179.  
  180.         MyBase.OnClick(e)
  181.     End Sub
  182.  
  183.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  184.         Invalidate() : MyBase.OnTextChanged(e)
  185.     End Sub
  186.  
  187.     Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  188.         If Width > 0 AndAlso Height > 0 Then
  189.             Shape = New GraphicsPath
  190.  
  191.             R1 = New Rectangle(30, 0, Width, Height)
  192.             R2 = New Rectangle(0, 0, Width, Height)
  193.  
  194.             GB = New LinearGradientBrush(New Rectangle(0, 0, 25, 25), Color.FromArgb(244, 245, 244) _
  195.                                          , Color.FromArgb(227, 227, 227), 90)
  196.  
  197.  
  198.             With Shape
  199.                 .AddArc(0, 0, 10, 10, 180, 90)
  200.                 .AddArc(14, 0, 10, 10, -90, 90)
  201.                 .AddArc(14, 14, 10, 10, 0, 90)
  202.                 .AddArc(0, 14, 10, 10, 90, 90)
  203.                 .CloseAllFigures()
  204.             End With
  205.  
  206.             Height = 26
  207.         End If
  208.  
  209.         Invalidate()
  210.         MyBase.OnResize(e)
  211.     End Sub
  212.  
  213.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  214.         With e.Graphics
  215.             .SmoothingMode = SmoothingMode.HighQuality
  216.  
  217.             .FillPath(GB, Shape)
  218.             .DrawPath(P1, Shape)
  219.  
  220.             .DrawString(Text, Font, B1, R1, CSF)
  221.  
  222.             If Checked Then
  223.                 .DrawString("a", MFont, B2, R2, CSF)
  224.             End If
  225.         End With
  226.  
  227.         MyBase.OnPaint(e)
  228.     End Sub
  229. End Class
  230.  
  231. Public Class BaWGUIComboBox : Inherits ComboBox
  232. #Region " Declarations "
  233.     Private Side, Button, Arrow1, Arrow2 As GraphicsPath
  234.     Private SideGB, ButtonOGB, ButtonGB As LinearGradientBrush
  235.     Private R1 As Rectangle
  236.     Private P1, P2, P3, P4 As Pen
  237.     Private B1, B2, B3 As SolidBrush
  238.     Private CSF As StringFormat = New StringFormat() With {.LineAlignment = StringAlignment.Center}
  239.  
  240.     Private _StartIndex As Integer = 0
  241. #End Region
  242.  
  243. #Region " Properties "
  244.     Private Property StartIndex As Integer
  245.         Get
  246.             Return _StartIndex
  247.         End Get
  248.         Set(ByVal value As Integer)
  249.             _StartIndex = value
  250.             Try
  251.                 MyBase.SelectedIndex = value
  252.             Catch
  253.             End Try
  254.             Invalidate()
  255.         End Set
  256.     End Property
  257. #End Region
  258.  
  259.     Sub New()
  260.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  261.         ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  262.  
  263.         BackColor = Color.Transparent
  264.         DoubleBuffered = True
  265.         DrawMode = DrawMode.OwnerDrawFixed
  266.         DropDownStyle = ComboBoxStyle.DropDownList
  267.         Font = New Font("Arial", 12)
  268.         ForeColor = Color.Black
  269.         ItemHeight = 39
  270.         StartIndex = 0
  271.  
  272.         P1 = New Pen(Color.FromArgb(180, 180, 180))
  273.         P3 = New Pen(Color.FromArgb(110, 170, 230))
  274.         P4 = New Pen(Color.FromArgb(50, 130, 215))
  275.         B1 = New SolidBrush(Color.FromArgb(100, 130, 160))
  276.         B2 = New SolidBrush(Color.FromArgb(114, 114, 114))
  277.         B3 = New SolidBrush(Color.FromArgb(246, 247, 250))
  278.     End Sub
  279.  
  280.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  281.         If Width > 0 AndAlso Height > 0 Then
  282.             Side = New GraphicsPath
  283.             Button = New GraphicsPath
  284.             Arrow1 = New GraphicsPath
  285.             Arrow2 = New GraphicsPath
  286.  
  287.             ButtonOGB = New LinearGradientBrush(New Rectangle(Width - 51, 0, Width, Height), Color.FromArgb(125, 180, 235) _
  288.                                                , Color.FromArgb(45, 125, 200), 90)
  289.             ButtonGB = New LinearGradientBrush(New Rectangle(Width - 50, 0, Width, Height), Color.FromArgb(175, 215, 240) _
  290.                                                , Color.FromArgb(70, 145, 215), 90)
  291.             SideGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 50, Height), Color.FromArgb(253, 253, 253) _
  292.                                              , Color.FromArgb(223, 223, 223), 90)
  293.  
  294.             R1 = New Rectangle(12, 0, Width, Height)
  295.  
  296.             P2 = New Pen(ButtonOGB)
  297.  
  298.  
  299.             With Side
  300.                 .AddArc(0, 0, 10, 10, 180, 90)
  301.                 .AddLine(Width - 50, 0, Width - 50, Height - 1)
  302.                 .AddArc(0, Height - 11, 10, 10, 90, 90)
  303.                 .CloseFigure()
  304.             End With
  305.             With Button
  306.                 .AddLine(Width - 51, Height - 1, Width - 51, 0)
  307.                 .AddArc(Width - 11, 0, 10, 10, -90, 90)
  308.                 .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  309.                 .CloseFigure()
  310.             End With
  311.             With Arrow1
  312.                 .AddLine(Width - 35, 21, Width - 19, 21)
  313.                 .AddLine(Width - 19, 21, Width - 27, 11)
  314.                 .CloseFigure()
  315.             End With
  316.             With Arrow2
  317.                 .AddLine(Width - 35, 26, Width - 19, 26)
  318.                 .AddLine(Width - 19, 26, Width - 27, 36)
  319.                 .CloseFigure()
  320.             End With
  321.         End If
  322.  
  323.         Invalidate()
  324.         MyBase.OnResize(e)
  325.     End Sub
  326.  
  327.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  328.         With e.Graphics
  329.             .SmoothingMode = SmoothingMode.HighQuality
  330.  
  331.             .FillPath(SideGB, Side)
  332.             .DrawPath(P1, Side)
  333.  
  334.             .FillPath(ButtonGB, Button)
  335.             .DrawPath(P2, Button)
  336.  
  337.             .FillPath(B1, Arrow1)
  338.             .FillPath(B1, Arrow2)
  339.  
  340.             .DrawString(Text, Font, B2, R1, CSF)
  341.         End With
  342.  
  343.         MyBase.OnPaint(e)
  344.     End Sub
  345.  
  346.     Private Sub DrawItm(ByVal sender As Object, ByVal e As DrawItemEventArgs) Handles Me.DrawItem
  347.         If e.Index < 0 Then Exit Sub
  348.  
  349.         e.DrawBackground()
  350.  
  351.         Dim NormalGB As LinearGradientBrush = New LinearGradientBrush(e.Bounds, Color.FromArgb(251, 251, 251) _
  352.                                                                       , Color.FromArgb(237, 237, 237), 90)
  353.         Dim OverGB As LinearGradientBrush = New LinearGradientBrush(e.Bounds, Color.FromArgb(155, 200, 240) _
  354.                                                                       , Color.FromArgb(75, 144, 225), 90)
  355.  
  356.  
  357.         With e.Graphics
  358.             .SmoothingMode = SmoothingMode.HighQuality
  359.  
  360.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  361.                 .FillRectangle(OverGB, e.Bounds)
  362.                 .DrawLine(P3, e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Y)
  363.                 .DrawLine(P4, e.Bounds.X, e.Bounds.Y + 38, e.Bounds.Width - 1, e.Bounds.Y + 38)
  364.  
  365.                 .DrawString(Text, Font, Brushes.DarkSlateGray _
  366.                             , New Rectangle(e.Bounds.X + 12, e.Bounds.Y + 1, e.Bounds.Width, e.Bounds.Height), CSF)
  367.                 .DrawString(Text, Font, B3, New Rectangle(e.Bounds.X + 12, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), CSF)
  368.             Else
  369.                 .FillRectangle(NormalGB, e.Bounds)
  370.                 .DrawLine(P1, e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Y)
  371.  
  372.                 .DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), Font, B2 _
  373.                             , New Rectangle(e.Bounds.X + 12, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), CSF)
  374.             End If
  375.         End With
  376.     End Sub
  377. End Class
  378.  
  379. Public Class BaWGUIProgressBar : Inherits Control
  380. #Region " Declarations "
  381.     Private OPath, IPath, Indicator As GraphicsPath
  382.     Private FillValue As Integer
  383.     Private OGB, IGB, IOGB, IndicatorGB As LinearGradientBrush
  384.     Private P1, P2, P3 As Pen
  385.     Private B1 As SolidBrush
  386.     Private TB As New TextureBrush(Image.FromStream(New System.IO.MemoryStream(Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAACUElEQVQYGa3BwY1dVRBF0X2q6mExtWDgAQEQIDmRDzn0wBISYtL9771Vx/81CBNAr6Xffv9jbEAC8WRukrh5jBBgbiED5mYbSZjAFrf6/PlnelrDPyRhm5swIQMmUoREBk/GNjdJgBiER9QvX35in8E2Bsx30lDRRIiqoFJkBhFgG9uAwMEguqG+/vkX3WZsbgYskEQGXAlVyVVBVZApxCDANm2YgbPNOkN9/fuBARMYc5NERHBl8qmSa4pyED1IwzsZD3QPezVrN2dD8MFqzYVsJJ4aMaChqvgUw4/xRqoIJ27hEIOw4fSwz7B2s07TberNCTPIjQJSSWXRmXQFO0wTyMkgGDEjdg/7HHbD2uYcmDF1zmA30ASgK1AlUQWZWMHhyWIQbnHarDZ7iXXE2qJHYFGeg+YA5gpxKbhkYoaQcAxjwMKIGbHW4W1t9m5OmxnAxojgg1WvB4GpK0iJSpGCwPQsZgYIPGIs9mleXw9vj81pA8IGI5CoZbgqqUx0JY6iBWNjGww2jM3eh7Wa18dm78YWtgAB5laugAy4iongYGyBjQfaQfewT/NYzVrN3mYc2DwFQtwkU0FTAakBNzR0G9kMwZ7g7Obx2KxHs1bTBpRgnpqbAiJE8MHqh7hIBTHAiOHJ4BmOmz2wVvN4O+zddPMkYLB5FyEyxBWi3laxG0oCjLiJGTg9PPZh78M+5rTBAoTNO8nIphS0Tb28vBASGAKDzM0ztGEkZoYZY/Mv8Z25RYgMqF+/FE8WAyOk4D8ShLANBO8k/s9usAEDwzcn97xOZ2JTrwAAAABJRU5ErkJggg=="))), WrapMode.Tile)
  387.  
  388.     Private _Value As Integer = 0
  389.     Private _Maximum As Integer = 100
  390. #End Region
  391.  
  392. #Region " Properties "
  393.     <Category("Control")>
  394.     Public Property Maximum As Integer
  395.         Get
  396.             Return _Maximum
  397.         End Get
  398.         Set(ByVal value As Integer)
  399.             If value < _Value Then _Value = value
  400.             _Maximum = value
  401.             FillValue = CInt((_Value / _Maximum) * (Width - 50))
  402.             ChangePaths()
  403.             Invalidate()
  404.         End Set
  405.     End Property
  406.  
  407.     <Category("Control")>
  408.     Public Property Value As Integer
  409.         Get
  410.             Select Case _Value
  411.                 Case 0
  412.                     Return 0
  413.                     FillValue = CInt((_Value / _Maximum) * (Width - 50))
  414.                     ChangePaths()
  415.                     Invalidate()
  416.                 Case Else
  417.                     Return _Value
  418.                     FillValue = CInt((_Value / _Maximum) * (Width - 50))
  419.                     ChangePaths()
  420.                     Invalidate()
  421.             End Select
  422.         End Get
  423.         Set(ByVal value As Integer)
  424.             If value > _Maximum Then value = _Maximum
  425.             _Value = value
  426.             FillValue = CInt((_Value / _Maximum) * (Width - 50))
  427.             ChangePaths()
  428.             Invalidate()
  429.         End Set
  430.     End Property
  431. #End Region
  432.  
  433.     Sub New()
  434.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  435.         ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  436.  
  437.         BackColor = Color.Transparent
  438.         DoubleBuffered = True
  439.         Font = New Font("Arial", 16)
  440.         MinimumSize = New Size(60, 80)
  441.  
  442.         TB.TranslateTransform(0, -5, MatrixOrder.Prepend)
  443.  
  444.         P3 = New Pen(Color.FromArgb(190, 190, 190))
  445.         B1 = New SolidBrush(Color.FromArgb(84, 83, 81))
  446.     End Sub
  447.  
  448.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  449.         FillValue = CInt((_Value / _Maximum) * (Width - 50))
  450.  
  451.         OPath = New GraphicsPath
  452.  
  453.         With OPath
  454.             .AddArc(14, Height - 31, 20, 20, 180, 90)
  455.             .AddArc(Width - 44, Height - 31, 20, 20, -90, 90)
  456.             .AddArc(Width - 44, Height - 21, 20, 20, 0, 90)
  457.             .AddArc(14, Height - 21, 20, 20, 90, 90)
  458.             .CloseAllFigures()
  459.         End With
  460.         ChangePaths()
  461.  
  462.         Height = 80
  463.  
  464.         Invalidate()
  465.         MyBase.OnResize(e)
  466.     End Sub
  467.  
  468.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  469.         With e.Graphics
  470.             .SmoothingMode = SmoothingMode.HighQuality
  471.  
  472.             Select Case _Value
  473.                 Case 0
  474.                     .FillPath(IGB, OPath)
  475.                     .DrawPath(P1, OPath)
  476.                 Case Else
  477.                     .FillPath(IGB, OPath)
  478.                     .DrawPath(P1, OPath)
  479.                     .FillPath(TB, IPath)
  480.                     .DrawPath(P2, IPath)
  481.  
  482.                     .FillPath(IndicatorGB, Indicator)
  483.                     .DrawPath(P3, Indicator)
  484.  
  485.                     Select Case _Value
  486.                         Case Is < 10
  487.                             .DrawString(_Value & "%", Font, B1, FillValue + 6, 7)
  488.                         Case Is < 100
  489.                             .DrawString(_Value & "%", Font, B1, FillValue - 5, 7)
  490.                         Case Else
  491.                             .DrawString(_Value & "%", Font, B1, FillValue - 11, 7)
  492.                     End Select
  493.             End Select
  494.         End With
  495.  
  496.         MyBase.OnPaint(e)
  497.     End Sub
  498.  
  499.     Private Sub ChangePaths()
  500.         If Width > 0 AndAlso Height > 0 Then
  501.             IPath = New GraphicsPath
  502.             Indicator = New GraphicsPath
  503.  
  504.             OGB = New LinearGradientBrush(New Rectangle(Width - 44, Height - 31, 31, 31), Color.FromArgb(173, 173, 173) _
  505.                                               , Color.FromArgb(195, 195, 195), 90)
  506.             IGB = New LinearGradientBrush(New Rectangle(Width - 43, Height - 30, 30, 30), Color.FromArgb(201, 201, 201) _
  507.                                               , Color.FromArgb(225, 225, 225), 90)
  508.             IOGB = New LinearGradientBrush(New Rectangle(19, Height - 26, Width - 6, Height - 26) _
  509.                                                , Color.FromArgb(125, 175, 225), Color.FromArgb(55, 130, 205), -90)
  510.             IndicatorGB = New LinearGradientBrush(New Rectangle(FillValue - 11, 0, FillValue + 19, 45) _
  511.                                                   , Color.FromArgb(232, 232, 232), Color.FromArgb(202, 202, 202), 90)
  512.  
  513.             P1 = New Pen(OGB)
  514.             P2 = New Pen(IOGB)
  515.  
  516.  
  517.             If FillValue >= 13 Then
  518.                 With IPath
  519.                     .AddArc(19, Height - 26, 20, 20, 180, 90)
  520.                     .AddArc(FillValue, Height - 26, 20, 20, -90, 90)
  521.                     .AddArc(FillValue, Height - 26, 20, 20, 0, 90)
  522.                     .AddArc(19, Height - 26, 20, 20, 90, 90)
  523.                 End With
  524.             End If
  525.             With Indicator
  526.                 .AddArc(FillValue - 11, 0, 8, 8, 180, 90)
  527.                 .AddArc(FillValue + 40, 0, 8, 8, -90, 90)
  528.                 .AddArc(FillValue + 40, 27, 8, 8, 0, 90)
  529.                 .AddLine(FillValue + 24, 35, FillValue + 19, 45)
  530.                 .AddLine(FillValue + 14, 35, FillValue - 3, 35)
  531.                 .AddArc(FillValue - 11, 27, 8, 8, 90, 90)
  532.                 .CloseFigure()
  533.             End With
  534.         End If
  535.     End Sub
  536.  
  537.     Public Sub Increment(ByVal Amount As Integer)
  538.         Value += Amount
  539.     End Sub
  540. End Class
  541.  
  542. <DefaultEvent("CheckedChanged")> Public Class BaWGUIRadioButton : Inherits Control
  543. #Region " Declarations "
  544.     Private GB As LinearGradientBrush
  545.     Private R1 As Rectangle
  546.     Private P1 As Pen
  547.     Private B1, B2 As SolidBrush
  548.     Private CSF As StringFormat = New StringFormat() With {.LineAlignment = StringAlignment.Center}
  549.  
  550.     Event CheckedChanged(ByVal sender As Object)
  551.  
  552.     Private _Checked As Boolean
  553.     Private _Group As Integer = 1
  554. #End Region
  555.  
  556. #Region " Properties "
  557.     <Category("Appearance")> _
  558.     Property Checked As Boolean
  559.         Get
  560.             Return _Checked
  561.         End Get
  562.         Set(ByVal value As Boolean)
  563.             _Checked = value
  564.             InvalidateControls()
  565.             RaiseEvent CheckedChanged(Me)
  566.             Invalidate()
  567.         End Set
  568.     End Property
  569.  
  570.     <Category("Custom")> _
  571.     Property Group As Integer
  572.         Get
  573.             Return _Group
  574.         End Get
  575.         Set(ByVal value As Integer)
  576.             _Group = value
  577.         End Set
  578.     End Property
  579. #End Region
  580.     Sub New()
  581.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  582.         ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  583.  
  584.         BackColor = Color.Transparent
  585.         DoubleBuffered = True
  586.         Font = New Font("Arial", 12)
  587.         Size = New Size(200, 26)
  588.  
  589.         P1 = New Pen(Color.FromArgb(160, 160, 160))
  590.         B1 = New SolidBrush(Color.FromArgb(114, 114, 114))
  591.         B2 = New SolidBrush(Color.FromArgb(95, 165, 230))
  592.     End Sub
  593.  
  594.   Private Sub InvalidateControls()
  595.         If Not IsHandleCreated OrElse Not _Checked Then Return
  596.  
  597.         For Each C As Control In Parent.Controls
  598.             If C IsNot Me AndAlso TypeOf C Is BaWGUIRadioButton AndAlso DirectCast(C, BaWGUIRadioButton).Group = _Group Then
  599.                 DirectCast(C, BaWGUIRadioButton).Checked = False
  600.             End If
  601.         Next
  602.     End Sub
  603.  
  604.     Protected Overrides Sub OnClick(ByVal e As EventArgs)
  605.         If Not _Checked Then Checked = True
  606.         MyBase.OnClick(e)
  607.     End Sub
  608.  
  609.     Protected Overrides Sub OnCreateControl()
  610.         InvalidateControls()
  611.         MyBase.OnCreateControl()
  612.     End Sub
  613.  
  614.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  615.         Invalidate() : MyBase.OnTextChanged(e)
  616.     End Sub
  617.  
  618.     Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  619.         Height = 26
  620.  
  621.         R1 = New Rectangle(30, 0, Width, Height)
  622.  
  623.         GB = New LinearGradientBrush(New Rectangle(0, 0, 25, 25), Color.FromArgb(244, 245, 244) _
  624.                                      , Color.FromArgb(227, 227, 227), 90)
  625.  
  626.         Invalidate()
  627.         MyBase.OnResize(e)
  628.     End Sub
  629.  
  630.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  631.         With e.Graphics
  632.             .SmoothingMode = SmoothingMode.HighQuality
  633.  
  634.             .FillEllipse(GB, 0, 0, 25, 25)
  635.             .DrawEllipse(P1, 0, 0, 24, 24)
  636.  
  637.             .DrawString(Text, Font, B1, R1, CSF)
  638.  
  639.             If Checked Then
  640.                 .FillEllipse(B2, 8, 8, 8, 8)
  641.             End If
  642.         End With
  643.  
  644.         MyBase.OnPaint(e)
  645.     End Sub
  646. End Class
  647.  
  648. <DefaultEvent("TextChanged")> Public Class BaWGUITextBox : Inherits Control
  649. #Region " Declarations "
  650.     Private Side, Button As GraphicsPath
  651.     Private ButtonOGB, ButtonGB As LinearGradientBrush
  652.     Private P1, P2 As Pen
  653.     Private B1 As SolidBrush
  654.  
  655.     Private WithEvents TBox As TextBox
  656.  
  657.     Private _MaxLength As Integer = 32767
  658.     Private _ReadOnly As Boolean
  659.     Private _UseSystemPasswordChar As Boolean
  660.     Private _Multiline As Boolean
  661.     Private _Image As Image
  662. #End Region
  663.  
  664. #Region " Properties "
  665.     <Category("Options")> _
  666.     Overrides Property Font As Font
  667.         Get
  668.             Return MyBase.Font
  669.         End Get
  670.         Set(ByVal value As Font)
  671.             MyBase.Font = value
  672.             If TBox IsNot Nothing Then
  673.                 TBox.Font = value
  674.                 TBox.Location = New Point(3, 5)
  675.                 TBox.Width = Width - 6
  676.  
  677.                 If Not _Multiline Then
  678.                     Height = TBox.Height + 11
  679.                 End If
  680.             End If
  681.         End Set
  682.     End Property
  683.  
  684.     <Category("Appearance")> _
  685.     Property Image As Image
  686.         Get
  687.             Return _Image
  688.         End Get
  689.         Set(ByVal value As Image)
  690.             _Image = value
  691.         End Set
  692.     End Property
  693.  
  694.     <Category("Options")> _
  695.     Property MaxLength As Integer
  696.         Get
  697.             Return _MaxLength
  698.         End Get
  699.         Set(ByVal value As Integer)
  700.             _MaxLength = value
  701.             If TBox IsNot Nothing Then
  702.                 TBox.MaxLength = value
  703.             End If
  704.         End Set
  705.     End Property
  706.  
  707.     <Category("Options")> _
  708.     Property Multiline As Boolean
  709.         Get
  710.             Return _Multiline
  711.         End Get
  712.         Set(ByVal value As Boolean)
  713.             _Multiline = value
  714.             If TBox IsNot Nothing Then
  715.                 TBox.Multiline = value
  716.  
  717.                 If value Then
  718.                     TBox.Height = Height - 11
  719.                 Else
  720.                     Height = TBox.Height + 11
  721.                 End If
  722.  
  723.             End If
  724.         End Set
  725.     End Property
  726.  
  727.     <Category("Options")> _
  728.     Property [ReadOnly] As Boolean
  729.         Get
  730.             Return _ReadOnly
  731.         End Get
  732.         Set(ByVal value As Boolean)
  733.             _ReadOnly = value
  734.             If TBox IsNot Nothing Then
  735.                 TBox.ReadOnly = value
  736.             End If
  737.         End Set
  738.     End Property
  739.  
  740.     <Category("Options")> _
  741.     Overrides Property Text As String
  742.         Get
  743.             Return MyBase.Text
  744.         End Get
  745.         Set(ByVal value As String)
  746.             MyBase.Text = value
  747.             If TBox IsNot Nothing Then
  748.                 TBox.Text = value
  749.             End If
  750.         End Set
  751.     End Property
  752.  
  753.     <Category("Options")> _
  754.     Property UseSystemPasswordChar As Boolean
  755.         Get
  756.             Return _UseSystemPasswordChar
  757.         End Get
  758.         Set(ByVal value As Boolean)
  759.             _UseSystemPasswordChar = value
  760.             If TBox IsNot Nothing Then
  761.                 TBox.UseSystemPasswordChar = value
  762.             End If
  763.         End Set
  764.     End Property
  765. #End Region
  766.  
  767.     Sub New()
  768.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  769.         ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  770.  
  771.         BackColor = Color.Transparent
  772.         DoubleBuffered = True
  773.         Font = New Font("Arial", 16)
  774.         Size = New Size(125, 53)
  775.  
  776.         TBox = New TextBox
  777.         With TBox
  778.             .BackColor = Color.FromArgb(245, 245, 245)
  779.             .BorderStyle = BorderStyle.None
  780.             .Cursor = Cursors.IBeam
  781.             .Font = Font
  782.             .ForeColor = Color.FromArgb(185, 185, 185)
  783.             .Height = Height - 11
  784.             .Location = New Point(5, 5)
  785.             .MaxLength = _MaxLength
  786.             .Multiline = _Multiline
  787.             .ReadOnly = _ReadOnly
  788.             .Text = Text
  789.             .UseSystemPasswordChar = _UseSystemPasswordChar
  790.             .Width = Width - 10
  791.         End With
  792.  
  793.         P1 = New Pen(Color.FromArgb(180, 180, 180))
  794.         B1 = New SolidBrush(Color.FromArgb(245, 245, 245))
  795.     End Sub
  796.  
  797.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs) Handles TBox.KeyDown
  798.         If e.Control AndAlso e.KeyCode = Keys.A Then
  799.             TBox.SelectAll()
  800.             e.SuppressKeyPress = True
  801.         End If
  802.         If e.Control AndAlso e.KeyCode = Keys.C Then
  803.             TBox.Copy()
  804.             e.SuppressKeyPress = True
  805.         End If
  806.     End Sub
  807.  
  808.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs) Handles TBox.TextChanged
  809.         Text = TBox.Text
  810.     End Sub
  811.  
  812.     Protected Overrides Sub OnCreateControl()
  813.         MyBase.OnCreateControl()
  814.         If Not Controls.Contains(TBox) Then
  815.             Controls.Add(TBox)
  816.         End If
  817.     End Sub
  818.  
  819.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  820.         If Width > 0 AndAlso Height > 0 Then
  821.             If Controls.Contains(TBox) AndAlso Not _Multiline AndAlso _Image IsNot Nothing Then
  822.                 TBox.Location = New Point(20, 14)
  823.                 TBox.Width = Width - 81
  824.                 Height = 53
  825.             ElseIf Controls.Contains(TBox) AndAlso _Multiline Then
  826.                 TBox.Location = New Point(5, 5)
  827.                 TBox.Width = Width - 10
  828.                 TBox.Height = Height - 11
  829.             ElseIf Controls.Contains(TBox) AndAlso Not _Multiline Then
  830.                 TBox.Location = New Point(5, 5)
  831.                 TBox.Width = Width - 10
  832.                 TBox.Height = Height - 11
  833.                 Height = 53
  834.             End If
  835.  
  836.  
  837.             Side = New GraphicsPath
  838.             Button = New GraphicsPath
  839.  
  840.             ButtonOGB = New LinearGradientBrush(New Rectangle(Width - 51, 0, Width, Height), Color.FromArgb(125, 180, 235) _
  841.                                                , Color.FromArgb(45, 125, 200), 90)
  842.             ButtonGB = New LinearGradientBrush(New Rectangle(Width - 50, 0, Width, Height), Color.FromArgb(175, 215, 240) _
  843.                                                , Color.FromArgb(70, 145, 215), 90)
  844.  
  845.             P2 = New Pen(ButtonOGB)
  846.  
  847.             With Side
  848.                 .AddArc(0, 0, 10, 10, 180, 90)
  849.                 .AddArc(Width - 11, 0, 10, 10, -90, 90)
  850.                 .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  851.                 .AddArc(0, Height - 11, 10, 10, 90, 90)
  852.                 .CloseFigure()
  853.             End With
  854.             With Button
  855.                 .AddLine(Width - 51, Height - 1, Width - 51, 0)
  856.                 .AddArc(Width - 11, 0, 10, 10, -90, 90)
  857.                 .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  858.                 .CloseFigure()
  859.             End With
  860.         End If
  861.  
  862.         Invalidate()
  863.         MyBase.OnResize(e)
  864.     End Sub
  865.  
  866.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  867.         With e.Graphics
  868.             .SmoothingMode = SmoothingMode.HighQuality
  869.  
  870.             .FillPath(B1, Side)
  871.             .DrawPath(P1, Side)
  872.  
  873.             If Not _Multiline AndAlso _Image IsNot Nothing Then
  874.                 .FillPath(ButtonGB, Button)
  875.                 .DrawPath(P2, Button)
  876.  
  877.                 .DrawImage(_Image, Width - 42, 11, 32, 32)
  878.             End If
  879.         End With
  880.  
  881.         MyBase.OnPaint(e)
  882.     End Sub
  883. End Class
  884.  
  885. Class BaWGUIThemeContainer : Inherits ContainerControl
  886. #Region " Declarations "
  887.     Private OverCls, OverMax, OverMin As Boolean
  888.     Private XF, PF, MF As Font
  889.     Private Base, Header As GraphicsPath
  890.     Private BaseGB, HeaderGB, HeaderOutlineGB, ButtonOuterGB, ButtonInnerGB, ButtonOInnerGB As LinearGradientBrush
  891.     Private R1, R2 As Rectangle
  892.     Private P1, P2, P3 As Pen
  893.     Private B1, B2, B3 As SolidBrush
  894.     Private CSF As StringFormat = New StringFormat() With {.Alignment = StringAlignment.Center}
  895.  
  896.     Private _DrawButtonStrings As Boolean = True
  897. #End Region
  898.  
  899. #Region " Properties "
  900.     <Category("Drawing")> _
  901.     Property DrawButtonStrings As Boolean
  902.         Get
  903.             Return _DrawButtonStrings
  904.         End Get
  905.         Set(ByVal value As Boolean)
  906.             _DrawButtonStrings = value
  907.         End Set
  908.     End Property
  909. #End Region
  910.  
  911.     Sub New()
  912.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  913.         ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
  914.  
  915.         BackColor = Color.White
  916.         Dock = DockStyle.Fill
  917.         DoubleBuffered = True
  918.         Font = New Font("Arial", 12, FontStyle.Bold)
  919.         XF = New Font("Tahoma", 12)
  920.         PF = New Font("Arial", 16)
  921.         MF = New Font("Arial", 20)
  922.  
  923.         P1 = New Pen(Color.FromArgb(128, 128, 128))
  924.         ' P2 is in the OnSizeChanged event.
  925.         P3 = New Pen(Color.FromArgb(180, 217, 246))
  926.         B1 = New SolidBrush(Color.FromArgb(58, 118, 181))
  927.         B2 = New SolidBrush(Color.FromArgb(71, 132, 191))
  928.         B3 = New SolidBrush(Color.FromArgb(128, 0, 0, 0))
  929.     End Sub
  930.  
  931.     Protected Overrides Sub CreateHandle()
  932.         FindForm.FormBorderStyle = FormBorderStyle.None
  933.         If FindForm.TransparencyKey = Nothing Then FindForm.TransparencyKey = Color.Fuchsia
  934.  
  935.         MyBase.CreateHandle()
  936.     End Sub
  937.  
  938.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  939.         If e.Button = MouseButtons.Left Then
  940.             If OverMin Then
  941.                 FindForm.WindowState = FormWindowState.Minimized
  942.             ElseIf OverMax Then
  943.                 If FindForm.WindowState = FormWindowState.Maximized Then FindForm.WindowState = FormWindowState.Normal _
  944.                     Else FindForm.WindowState = FormWindowState.Maximized
  945.             ElseIf OverCls Then
  946.                 FindForm.Close()
  947.             Else
  948.                 If New Rectangle(FindForm.Location.X, FindForm.Location.Y, Width, 50).IntersectsWith(New Rectangle(MousePosition.X, MousePosition.Y, 1, 1)) AndAlso _
  949.                                           Not FindForm.WindowState = FormWindowState.Maximized Then
  950.                     Capture = False
  951.                     Dim M As Message = Message.Create(FindForm.Handle, 161, New IntPtr(2), IntPtr.Zero)
  952.                     DefWndProc(M)
  953.                 End If
  954.             End If
  955.         End If
  956.  
  957.         MyBase.OnMouseDown(e)
  958.     End Sub
  959.  
  960.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  961.         If e.Location.X >= 33 AndAlso e.Location.Y >= 19 AndAlso e.Location.X <= 120 AndAlso e.Location.Y <= 37 Then
  962.             If e.Location.X >= 33 AndAlso e.Location.X <= 51 Then
  963.                 OverCls = True : Invalidate()
  964.             Else
  965.                 OverCls = False : Invalidate()
  966.             End If
  967.  
  968.             If e.Location.X >= 104 Then
  969.                 OverMax = True : Invalidate()
  970.             Else
  971.                 OverMax = False : Invalidate()
  972.             End If
  973.  
  974.             If e.Location.X >= 68 AndAlso e.Location.X <= 86 Then
  975.                 OverMin = True : Invalidate()
  976.             Else
  977.                 OverMin = False : Invalidate()
  978.             End If
  979.         Else
  980.             OverMin = False : OverMax = False : OverCls = False
  981.             Invalidate()
  982.         End If
  983.  
  984.         MyBase.OnMouseMove(e)
  985.     End Sub
  986.  
  987.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  988.         Invalidate() : MyBase.OnTextChanged(e)
  989.     End Sub
  990.  
  991.     Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
  992.         If Width > 0 AndAlso Height > 0 Then
  993.             Base = New GraphicsPath
  994.             Header = New GraphicsPath
  995.  
  996.             R1 = New Rectangle(-1, CInt((50 - Font.Size) / 2 - 1), Width, Height)
  997.             R2 = New Rectangle(0, CInt((50 - Font.Size) / 2 - 2), Width, Height)
  998.  
  999.             BaseGB = New LinearGradientBrush(New Rectangle(0, 50, Width, Height) _
  1000.                                              , Color.FromArgb(236, 236, 236), Color.FromArgb(232, 232, 232), 90)
  1001.             HeaderGB = New LinearGradientBrush(New Rectangle(0, 0, Width, 50) _
  1002.                                              , Color.FromArgb(161, 207, 243), Color.FromArgb(80, 152, 222), 90)
  1003.             HeaderOutlineGB = New LinearGradientBrush(New Rectangle(0, 0, Width, 50) _
  1004.                                              , Color.FromArgb(102, 167, 227), Color.FromArgb(52, 130, 202), -90)
  1005.             ButtonOuterGB = New LinearGradientBrush(New Rectangle(0, 15, 25, 25) _
  1006.                                              , Color.FromArgb(89, 158, 228), Color.FromArgb(150, 202, 241), 90)
  1007.             ButtonInnerGB = New LinearGradientBrush(New Rectangle(0, 20, 16, 16) _
  1008.                                              , Color.FromArgb(185, 211, 239), Color.FromArgb(145, 191, 238), 90)
  1009.             ButtonOInnerGB = New LinearGradientBrush(New Rectangle(0, 22, 16, 16) _
  1010.                                              , Color.FromArgb(94, 163, 215), Color.FromArgb(13, 67, 141), 90)
  1011.  
  1012.             P2 = New Pen(HeaderOutlineGB)
  1013.  
  1014.  
  1015.             With Base
  1016.                 .AddLine(Width - 1, 50, Width - 1, Height - 11)
  1017.                 .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  1018.                 .AddArc(0, Height - 11, 10, 10, 90, 90)
  1019.                 .AddLine(0, Height - 11, 0, 50)
  1020.             End With
  1021.  
  1022.             With Header
  1023.                 .AddArc(0, 0, 10, 10, 180, 90)
  1024.                 .AddArc(Width - 11, 0, 10, 10, -90, 90)
  1025.                 .AddLine(Width - 1, 50, 0, 50)
  1026.                 .AddLine(0, 50, 0, 5)
  1027.             End With
  1028.             Invalidate()
  1029.         End If
  1030.  
  1031.         Invalidate()
  1032.         MyBase.OnSizeChanged(e)
  1033.     End Sub
  1034.  
  1035.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1036.         With e.Graphics
  1037.             .SmoothingMode = SmoothingMode.HighQuality
  1038.             .Clear(FindForm.TransparencyKey)
  1039.  
  1040.             ' Base & Header
  1041.             .FillPath(BaseGB, Base)
  1042.             .DrawPath(P1, Base)
  1043.  
  1044.             .FillPath(HeaderGB, Header)
  1045.             .DrawPath(P2, Header)
  1046.             .DrawLine(P3, 4, 1, Width - 5, 1) ' Little header shine
  1047.  
  1048.  
  1049.             ' Buttons
  1050.             If OverCls Then
  1051.                 .FillEllipse(ButtonOuterGB, 30, 15, 25, 25)
  1052.                 .FillEllipse(B1, 33, 19, 18, 18)
  1053.                 .FillEllipse(ButtonOInnerGB, 34, 21, 16, 16)
  1054.                 If _DrawButtonStrings Then .DrawString("x", XF, B3, 36, 17)
  1055.             Else
  1056.                 .FillEllipse(ButtonOuterGB, 30, 15, 25, 25)
  1057.                 .FillEllipse(B2, 33, 19, 18, 18)
  1058.                 .FillEllipse(ButtonInnerGB, 34, 19, 16, 16)
  1059.             End If
  1060.  
  1061.             If OverMax Then
  1062.                 .FillEllipse(ButtonOuterGB, 100, 15, 25, 25)
  1063.                 .FillEllipse(B1, 103, 19, 18, 18)
  1064.                 .FillEllipse(ButtonOInnerGB, 104, 21, 16, 16)
  1065.                 If _DrawButtonStrings Then .DrawString("+", PF, B3, 102, 17)
  1066.             Else
  1067.                 .FillEllipse(ButtonOuterGB, 100, 15, 25, 25)
  1068.                 .FillEllipse(B2, 103, 19, 18, 18)
  1069.                 .FillEllipse(ButtonInnerGB, 104, 19, 16, 16)
  1070.             End If
  1071.  
  1072.             If OverMin Then
  1073.                 .FillEllipse(ButtonOuterGB, 65, 15, 25, 25)
  1074.                 .FillEllipse(B1, 68, 19, 18, 18)
  1075.                 .FillEllipse(ButtonOInnerGB, 69, 21, 16, 16)
  1076.                 If _DrawButtonStrings Then .DrawString("-", MF, B3, 69, 10)
  1077.             Else
  1078.                 .FillEllipse(ButtonOuterGB, 65, 15, 25, 25)
  1079.                 .FillEllipse(B2, 68, 19, 18, 18)
  1080.                 .FillEllipse(ButtonInnerGB, 69, 19, 16, 16)
  1081.             End If
  1082.  
  1083.  
  1084.             .DrawString(Text, Font, Brushes.DarkSlateGray, R1, CSF)
  1085.             .DrawString(Text, Font, Brushes.WhiteSmoke, R2, CSF)
  1086.         End With
  1087.  
  1088.         MyBase.OnPaint(e)
  1089.     End Sub
  1090. End Class
  1091.  
  1092. <DefaultEvent("Scroll")> Public Class BaWGUITrackBar : Inherits Control
  1093. #Region " Declarations "
  1094.     Private Moveable As Boolean
  1095.     Private Slider, Track As GraphicsPath
  1096.     Private DrawValue As Integer
  1097.     Private SliderGB, SliderOGB As LinearGradientBrush
  1098.     Private P1, P2, P3 As Pen
  1099.     Private B1, B2 As SolidBrush
  1100.  
  1101.     Event Scroll(ByVal sender As Object)
  1102.  
  1103.     Private _Maximum As Integer = 10
  1104.     Private _Minimum As Integer
  1105.     Private _Value As Integer
  1106. #End Region
  1107.  
  1108. #Region " Properties "
  1109.     <Category("Behavior")> _
  1110.     Property Maximum As Integer
  1111.         Get
  1112.             Return _Maximum
  1113.         End Get
  1114.         Set(ByVal value As Integer)
  1115.             _Maximum = value
  1116.             If value < _Value Then _Value = value
  1117.             If value < _Minimum Then _Minimum = value
  1118.  
  1119.             DrawValue = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 24))
  1120.             ChangePaths()
  1121.             Invalidate()
  1122.         End Set
  1123.     End Property
  1124.  
  1125.     <Category("Behavior")> _
  1126.     Property Minimum As Integer
  1127.         Get
  1128.             Return _Minimum
  1129.         End Get
  1130.         Set(ByVal value As Integer)
  1131.             If value < 0 Then
  1132.             End If
  1133.  
  1134.             _Minimum = value
  1135.  
  1136.             If value > _Value Then _Value = value
  1137.             If value > _Maximum Then _Maximum = value
  1138.  
  1139.             DrawValue = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 24))
  1140.             ChangePaths()
  1141.             Invalidate()
  1142.         End Set
  1143.     End Property
  1144.  
  1145.     <Category("Behavior")> _
  1146.     Property Value As Integer
  1147.         Get
  1148.             Return _Value
  1149.         End Get
  1150.         Set(ByVal value As Integer)
  1151.             If value = _Value Then Return
  1152.  
  1153.             If value > _Maximum Then value = _Maximum
  1154.             If value < _Minimum Then value = _Minimum
  1155.  
  1156.             _Value = value
  1157.  
  1158.             DrawValue = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 24))
  1159.             ChangePaths()
  1160.             Invalidate()
  1161.             RaiseEvent Scroll(Me)
  1162.         End Set
  1163.     End Property
  1164. #End Region
  1165.  
  1166.     Sub New()
  1167.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  1168.         ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  1169.  
  1170.         BackColor = Color.Transparent
  1171.         DoubleBuffered = True
  1172.  
  1173.         P1 = New Pen(Color.FromArgb(156, 156, 156))
  1174.         P2 = New Pen(Color.FromArgb(205, 205, 205))
  1175.         B1 = New SolidBrush(Color.FromArgb(194, 194, 194))
  1176.         B2 = New SolidBrush(Color.FromArgb(75, 145, 215))
  1177.     End Sub
  1178.  
  1179.     Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs)
  1180.         If e.KeyCode = Keys.Subtract OrElse e.KeyCode = Keys.Down OrElse e.KeyCode = Keys.Left Then
  1181.             If Value = 0 Then Exit Sub
  1182.             Value -= 1
  1183.         ElseIf e.KeyCode = Keys.Add OrElse e.KeyCode = Keys.Up OrElse e.KeyCode = Keys.Right Then
  1184.             If Value = _Maximum Then Exit Sub
  1185.             Value += 1
  1186.         End If
  1187.  
  1188.         MyBase.OnKeyDown(e)
  1189.     End Sub
  1190.  
  1191.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  1192.         If e.Button = MouseButtons.Left AndAlso Height > 0 Then
  1193.             DrawValue = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 24))
  1194.             ChangePaths()
  1195.  
  1196.             Moveable = New Rectangle(DrawValue, 0, 24, Height).Contains(e.Location)
  1197.         End If
  1198.  
  1199.         MyBase.OnMouseDown(e)
  1200.     End Sub
  1201.  
  1202.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  1203.         If Moveable AndAlso e.X > -1 AndAlso e.X < Width + 1 Then Value = _Minimum + _
  1204.             CInt((_Maximum - _Minimum) * (e.X / Width))
  1205.  
  1206.         MyBase.OnMouseMove(e)
  1207.     End Sub
  1208.  
  1209.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  1210.         Moveable = False : MyBase.OnMouseUp(e)
  1211.     End Sub
  1212.  
  1213.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  1214.         If Width > 0 AndAlso Height > 0 Then
  1215.             DrawValue = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 24))
  1216.  
  1217.             Track = New GraphicsPath
  1218.  
  1219.             SliderOGB = New LinearGradientBrush(New Rectangle(DrawValue, 0, 24, Height), Color.FromArgb(100, 170, 230) _
  1220.                                                 , Color.FromArgb(70, 140, 210), 90)
  1221.  
  1222.             P3 = New Pen(SliderOGB)
  1223.  
  1224.  
  1225.             With Track
  1226.                 .AddArc(0, 27, 10, 10, 90, 180)
  1227.                 .AddArc(Width - 11, 27, 10, 10, -90, 180)
  1228.                 .CloseFigure()
  1229.             End With
  1230.             ChangePaths()
  1231.  
  1232.             Height = 37
  1233.         End If
  1234.  
  1235.         Invalidate()
  1236.         MyBase.OnResize(e)
  1237.     End Sub
  1238.  
  1239.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1240.         With e.Graphics
  1241.             .SmoothingMode = SmoothingMode.HighQuality
  1242.  
  1243.             .FillPath(B1, Track)
  1244.             .DrawLine(P1, 5, 27, Width - 6, 27)
  1245.  
  1246.             For i As Integer = 0 To _Maximum - _Minimum + 1
  1247.                 .DrawLine(P2, CInt(i / (_Maximum - _Minimum) * (Width - 24) + 10), 25 _
  1248.                           , CInt(i / (_Maximum - _Minimum) * (Width - 24) + 10), 18)
  1249.             Next
  1250.  
  1251.             .FillPath(SliderGB, Slider)
  1252.             .DrawPath(P3, Slider)
  1253.  
  1254.             .FillEllipse(B2, DrawValue + 5, 10, 2, 2)
  1255.             .FillEllipse(B2, DrawValue + 9, 10, 2, 2)
  1256.             .FillEllipse(B2, DrawValue + 13, 10, 2, 2)
  1257.             .FillEllipse(B2, DrawValue + 5, 14, 2, 2)
  1258.             .FillEllipse(B2, DrawValue + 9, 14, 2, 2)
  1259.             .FillEllipse(B2, DrawValue + 13, 14, 2, 2)
  1260.         End With
  1261.     End Sub
  1262.  
  1263.     Private Sub ChangePaths()
  1264.         If Width > 0 AndAlso Height > 0 Then
  1265.             Slider = New GraphicsPath
  1266.  
  1267.             SliderGB = New LinearGradientBrush(New Rectangle(DrawValue, 0, 24, Height), Color.FromArgb(170, 210, 245) _
  1268.                                                , Color.FromArgb(80, 150, 225), 90)
  1269.  
  1270.  
  1271.             With Slider
  1272.                 .AddArc(DrawValue, 0, 4, 4, 180, 90)
  1273.                 .AddArc(DrawValue + 17, 0, 4, 4, -90, 90)
  1274.                 .AddLine(DrawValue + 21, 4, DrawValue + 21, 25)
  1275.                 .AddLine(DrawValue + 21, 25, DrawValue + 10, Height - 1)
  1276.                 .AddLine(DrawValue, 25, DrawValue, 2)
  1277.             End With
  1278.         End If
  1279.     End Sub
  1280. End Class
Add Comment
Please, Sign In to add comment