Advertisement
VmX5

Velocity Theme - Vb.net

May 6th, 2017
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 25.33 KB | None | 0 0
  1. Public Module Helpers
  2.  
  3.     Public Enum MouseState
  4.         Hover = 1
  5.         Down = 2
  6.         None = 3
  7.     End Enum
  8.     Public Enum TxtAlign
  9.         Left = 1
  10.         Center = 2
  11.         Right = 3
  12.     End Enum
  13.  
  14.     Public Function b64Image(ByVal b64 As String) As Image
  15.         Return Image.FromStream(New System.IO.MemoryStream(Convert.FromBase64String(b64)))
  16.     End Function
  17.  
  18.     Public Function FromHex(hex As String) As Color
  19.         Return ColorTranslator.FromHtml(hex)
  20.     End Function
  21. End Module
  22.  
  23. Public Class VelocityButton
  24.     Inherits Control
  25.  
  26.     Private state As MouseState = MouseState.None
  27.     Private _enabled As Boolean = True
  28.  
  29.     Private _txtAlign As TxtAlign = TxtAlign.Center
  30.     Public Property TextAlign As TxtAlign
  31.         Get
  32.             Return _txtAlign
  33.         End Get
  34.         Set(value As TxtAlign)
  35.             _txtAlign = value
  36.             Invalidate()
  37.         End Set
  38.     End Property
  39.  
  40.     Sub New()
  41.         DoubleBuffered = True
  42.         Font = New Font("Segoe UI Semilight", 9)
  43.         ForeColor = Color.White
  44.         Size = New Size(94, 40)
  45.     End Sub
  46.  
  47.     Public Overloads Property Enabled As Boolean
  48.         Get
  49.             Return _enabled
  50.         End Get
  51.         Set(value As Boolean)
  52.             _enabled = value
  53.             Invalidate()
  54.         End Set
  55.     End Property
  56.  
  57.     Sub PerformClick()
  58.         MyBase.OnClick(EventArgs.Empty)
  59.     End Sub
  60.  
  61.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  62.         MyBase.OnPaint(e)
  63.         Dim g As Graphics = e.Graphics
  64.         Select Case _enabled
  65.             Case True
  66.                 Select Case state
  67.                     Case MouseState.None
  68.                         g.Clear(FromHex("#435363"))
  69.                     Case MouseState.Hover
  70.                         g.Clear(FromHex("#38495A"))
  71.                     Case MouseState.Down
  72.                         g.Clear(BackColor)
  73.                         g.FillRectangle(New SolidBrush(FromHex("#2c3e50")), 1, 1, Width - 2, Height - 2)
  74.                 End Select
  75.             Case False
  76.                 g.Clear(FromHex("#38495A"))
  77.         End Select
  78.  
  79.         Select Case _txtAlign
  80.             Case TxtAlign.Left
  81.                 g.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(8, 0, Width, Height), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  82.             Case TxtAlign.Center
  83.                 g.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(0, 0, Width, Height), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  84.             Case TxtAlign.Right
  85.                 g.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(0, 0, Width - 8, Height), New StringFormat With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  86.         End Select
  87.     End Sub
  88.  
  89.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  90.         MyBase.OnMouseEnter(e)
  91.         state = MouseState.Hover : Invalidate()
  92.     End Sub
  93.  
  94.     Protected Overrides Sub OnMouseHover(e As EventArgs)
  95.         MyBase.OnMouseHover(e)
  96.         state = MouseState.Hover : Invalidate()
  97.     End Sub
  98.  
  99.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  100.         MyBase.OnMouseLeave(e)
  101.         state = MouseState.None : Invalidate()
  102.     End Sub
  103.  
  104.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  105.         MyBase.OnMouseDown(e)
  106.         state = MouseState.Down : Invalidate()
  107.     End Sub
  108.  
  109.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  110.         MyBase.OnMouseUp(e)
  111.         state = MouseState.Hover : Invalidate()
  112.     End Sub
  113.  
  114.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  115.         MyBase.OnTextChanged(e)
  116.         Invalidate()
  117.     End Sub
  118. End Class
  119.  
  120. <DefaultEvent("CheckChanged")> _
  121. Public Class VelocityCheckBox
  122.     Inherits Control
  123.  
  124.     Dim _state As MouseState = MouseState.None
  125.     Public Event CheckChanged(sender As Object, e As EventArgs)
  126.  
  127.     Private _autoSize As Boolean = True
  128.     Public Overrides Property AutoSize As Boolean
  129.         Get
  130.             Return _autoSize
  131.         End Get
  132.         Set(value As Boolean)
  133.             _autoSize = value
  134.             Invalidate()
  135.         End Set
  136.     End Property
  137.  
  138.     Private _checked As Boolean = False
  139.     Public Property Checked As Boolean
  140.         Get
  141.             Return _checked
  142.         End Get
  143.         Set(value As Boolean)
  144.             _checked = value
  145.             Invalidate()
  146.         End Set
  147.     End Property
  148.  
  149.     Sub New()
  150.         DoubleBuffered = True
  151.     End Sub
  152.  
  153.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  154.         MyBase.OnPaint(e)
  155.         Select Case AutoSize
  156.             Case True
  157.                 Size = New Size(TextRenderer.MeasureText(Text, Font).Width + 28, Height)
  158.         End Select
  159.         Dim g As Graphics = e.Graphics
  160.         Select Case _state
  161.             Case MouseState.Hover
  162.                 g.FillRectangle(New SolidBrush(FromHex("#DBDBDB")), 4, 4, 14, 14)
  163.             Case Else
  164.                 g.FillRectangle(Brushes.White, 4, 4, 14, 14)
  165.         End Select
  166.         If _checked Then
  167.             g.FillRectangle(New SolidBrush(FromHex("#435363")), 7, 7, 9, 9)
  168.         End If
  169.         g.DrawRectangle(New Pen(FromHex("#435363")), New Rectangle(4, 4, 14, 14))
  170.         g.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(22, 0, Width, Height), New StringFormat With {.LineAlignment = StringAlignment.Center})
  171.     End Sub
  172.  
  173.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  174.         MyBase.OnTextChanged(e)
  175.         Invalidate()
  176.     End Sub
  177.  
  178.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  179.         MyBase.OnMouseUp(e)
  180.         Select Case Checked
  181.             Case True
  182.                 Checked = False
  183.             Case False
  184.                 Checked = True
  185.         End Select
  186.         _state = MouseState.Hover : Invalidate()
  187.     End Sub
  188.  
  189.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  190.         MyBase.OnMouseEnter(e)
  191.         _state = MouseState.Hover : Invalidate()
  192.     End Sub
  193.  
  194.     Protected Overrides Sub OnMouseHover(e As EventArgs)
  195.         MyBase.OnMouseHover(e)
  196.         _state = MouseState.Hover : Invalidate()
  197.     End Sub
  198.  
  199.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  200.         MyBase.OnMouseLeave(e)
  201.         _state = MouseState.None : Invalidate()
  202.     End Sub
  203.  
  204.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  205.         MyBase.OnMouseDown(e)
  206.         _state = MouseState.Down : Invalidate()
  207.     End Sub
  208.  
  209.     Protected Overrides Sub OnResize(e As EventArgs)
  210.         MyBase.OnResize(e)
  211.         Invalidate()
  212.     End Sub
  213. End Class
  214.  
  215. <DefaultEvent("CheckChanged")> _
  216. Public Class VelocityRadioButton
  217.     Inherits Control
  218.  
  219.     Dim _state As MouseState
  220.     Public Event CheckChanged(sender As Object, e As EventArgs)
  221.  
  222.     Private _autoSize As Boolean = True
  223.     Public Overrides Property AutoSize As Boolean
  224.         Get
  225.             Return _autoSize
  226.         End Get
  227.         Set(value As Boolean)
  228.             _autoSize = value
  229.             Invalidate()
  230.         End Set
  231.     End Property
  232.  
  233.     Private _checked As Boolean = False
  234.     Public Property Checked As Boolean
  235.         Get
  236.             Return _checked
  237.         End Get
  238.         Set(value As Boolean)
  239.             _checked = value
  240.             Invalidate()
  241.         End Set
  242.     End Property
  243.  
  244.     Sub New()
  245.         DoubleBuffered = True
  246.         InvalidateControls()
  247.     End Sub
  248.  
  249.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  250.         MyBase.OnPaint(e)
  251.         Select Case AutoSize
  252.             Case True
  253.                 Size = New Size(TextRenderer.MeasureText(Text, Font).Width + 24, Height)
  254.         End Select
  255.         Dim g As Graphics = e.Graphics
  256.         g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  257.         Select Case _state
  258.             Case MouseState.Hover
  259.                 g.FillEllipse(New SolidBrush(FromHex("#DBDBDB")), 4, 4, 14, 14)
  260.             Case Else
  261.                 g.FillEllipse(Brushes.White, 4, 4, 14, 14)
  262.         End Select
  263.         g.DrawEllipse(New Pen(FromHex("#435363")), New Rectangle(4, 4, 14, 14))
  264.         g.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(22, 0, Width, Height), New StringFormat With {.LineAlignment = StringAlignment.Center})
  265.         If _checked = True Then
  266.             g.FillEllipse(New SolidBrush(FromHex("#435363")), 7, 7, 8, 8)
  267.         End If
  268.     End Sub
  269.  
  270.     Private Sub InvalidateControls()
  271.         If Not IsHandleCreated OrElse Not _checked Then Return
  272.         For Each C As Control In Parent.Controls
  273.             If C IsNot Me AndAlso TypeOf C Is VelocityRadioButton Then
  274.                 DirectCast(C, VelocityRadioButton).Checked = False
  275.                 Invalidate()
  276.             End If
  277.         Next
  278.     End Sub
  279.  
  280.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  281.         MyBase.OnTextChanged(e)
  282.         Invalidate()
  283.     End Sub
  284.  
  285.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  286.         MyBase.OnMouseUp(e)
  287.         _state = MouseState.Hover
  288.         Select Case Checked
  289.             Case True
  290.                 Checked = False
  291.             Case False
  292.                 Checked = True
  293.         End Select
  294.         _state = MouseState.Hover
  295.         InvalidateControls()
  296.     End Sub
  297.  
  298.     Protected Overrides Sub OnMouseHover(e As EventArgs)
  299.         MyBase.OnMouseHover(e)
  300.         _state = MouseState.Hover : Invalidate()
  301.     End Sub
  302.  
  303.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  304.         MyBase.OnMouseLeave(e)
  305.         _state = MouseState.None : Invalidate()
  306.     End Sub
  307.  
  308.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  309.         MyBase.OnMouseDown(e)
  310.         _state = MouseState.None : Invalidate()
  311.     End Sub
  312.  
  313.     Protected Overrides Sub OnResize(e As EventArgs)
  314.         MyBase.OnResize(e)
  315.         Invalidate()
  316.     End Sub
  317. End Class
  318.  
  319. Public Class VelocityTitle
  320.     Inherits Control
  321.  
  322.     Private _txtAlign As TxtAlign = TxtAlign.Left
  323.     Public Property TextAlign As TxtAlign
  324.         Get
  325.             Return _txtAlign
  326.         End Get
  327.         Set(value As TxtAlign)
  328.             _txtAlign = value
  329.             Invalidate()
  330.         End Set
  331.     End Property
  332.  
  333.     Sub New()
  334.         DoubleBuffered = True
  335.         Size = New Size(180, 23)
  336.     End Sub
  337.  
  338.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  339.         MyBase.OnPaint(e)
  340.         Dim g As Graphics = e.Graphics
  341.         g.DrawLine(New Pen(FromHex("#435363")), New Point(0, Height / 2), New Point(Width, Height / 2))
  342.             Dim txtRect As New Size(g.MeasureString(Text, Font).ToSize)
  343.             Select Case _txtAlign
  344.                 Case TxtAlign.Left
  345.                     g.FillRectangle(New SolidBrush(BackColor), New Rectangle(18, Height / 2 - txtRect.Height - 2, txtRect.Width + 6, Height / 2 + txtRect.Height / 2 + 6))
  346.                     g.DrawString(Text, Font, New SolidBrush(ForeColor), 20, Height / 2 - txtRect.Height / 2)
  347.                 Case TxtAlign.Center
  348.                     g.FillRectangle(New SolidBrush(BackColor), New Rectangle(Width / 2 - txtRect.Width / 2 - 2, Height / 2 - txtRect.Height / 2 - 2, txtRect.Width + 2, txtRect.Height + 2))
  349.                     g.DrawString(Text, Font, New SolidBrush(ForeColor), Width / 2 - txtRect.Width / 2, Height / 2 - txtRect.Height / 2)
  350.                 Case TxtAlign.Right
  351.                     g.FillRectangle(New SolidBrush(BackColor), New Rectangle(Width - (txtRect.Width + 18), Height / 2 - txtRect.Height - 2, txtRect.Width + 4, Height + 6))
  352.                     g.DrawString(Text, Font, New SolidBrush(ForeColor), Width - (txtRect.Width + 16), Height / 2 - txtRect.Height / 2)
  353.             End Select
  354.     End Sub
  355.  
  356.     Protected Overrides Sub OnFontChanged(e As EventArgs)
  357.         MyBase.OnFontChanged(e)
  358.         Invalidate()
  359.     End Sub
  360.  
  361.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  362.         MyBase.OnTextChanged(e)
  363.         Invalidate()
  364.     End Sub
  365. End Class
  366.  
  367. Public Class VelocitySplitter
  368.     Inherits Control
  369.  
  370.     Private _offset As Integer = 8
  371.     Public Property Offset As Integer
  372.         Get
  373.             Return _offset
  374.         End Get
  375.         Set(value As Integer)
  376.             _offset = value
  377.             Invalidate()
  378.         End Set
  379.     End Property
  380.     Sub New()
  381.         DoubleBuffered = True
  382.     End Sub
  383.  
  384.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  385.         MyBase.OnPaint(e)
  386.         Dim g As Graphics = e.Graphics
  387.         g.DrawLine(New Pen(ForeColor), New Point(_offset, Height / 2 - 2), New Point(Width - _offset, Height / 2 - 1))
  388.     End Sub
  389. End Class
  390.  
  391. <DefaultEvent("XClicked")> _
  392. Public Class VelocityAlert
  393.     Inherits Control
  394.  
  395.     Public Event XClicked(sender As Object, e As EventArgs)
  396.     Dim _xHover As Boolean = False
  397.  
  398. #Region "Filler Image Base64"
  399.     Dim FillerImage As String = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTM0A1t6AAADZUlEQVRoQ+2W2ytsYRjG9x85Cikpp1KORSkihITkyinkdCERm0wi3IiS5ELKIQkXkiQkh9m/tZ7PNHuwWi707dl9v4vpfd/1zut51ncYvyIpzv9iIJaCSLkzYA8pdwbsIeXOgD2k3Bmwh5Q7A/aQcmfAHlLuDNhDyp0Be0i5M2APKXcG7CHlzoA9pPx7Bh4fH4+Pj/f29m5vb03pHSpnZ2cmCeTt7Y1OhlxdXZnSO8/PzyGHgJR/w8Dc3Fx6err6s7OzTdXn9fW1sLCQ+urqqil9AQ15eXkaAkdHR+aBT21tLcWJiQmTB6IJYQ1sbW3RtrKyovTy8lKBGBsb05zl5WVT+ozT01N6pqenlSatwNLSkoaMjIyYUiBqDmugoaGhr6/PJH/DojNhf3+fz2g0SoXPqampu7s7Nfz2Iejt7W1sbFQxiaenJ1YG/wwZHBw01UA83eENsHnW1tZ4Z4eHh/f396bq09bW1tLSQpE5MgBFRUWdnZ0EJycn1Dc2NojLysrYHhhjSNIpGh4ezs/PJ6C5v79fxWA83SENXF9f01NVVaVmGBgY0KPNzU1SgiQDKCZlx1dUVHR0dKiYlZVVWlrqfd+nvb1ddS4G0ouLC2ICFkr1YPwZ4Qycn5/TMzQ0pHRmZoYU6cTl5eXaHkkGoLm52Rsdidzc3JBy+RC3trZqASV6dnaWmAXs6enxvvNDBlh0era3t00eixUUFKCb45iZmcnqj4+P6xwjJf5eFxYWqLACSiEnJ4erzCSxWF1dHedKa8W+ZwIbjJillrFg6ISwZyA3N3d+fl4xvwZpaWmsAAa6u7u7uro4Bk1NTcwpLi4uKSmhhy3OsRkdHaUY/2JNTU187wHNTMAAQwDnGsJhYKZp+hpPd3gD/IHq6moOw8vLC++JG4O73zzzeXh4YA4HXSn99fX1BLzajIwM7aLJyUl+Lg4ODogXFxfpZ3N63QmwpD9yjfJGWXE18+Z2d3fNg3cSDezs7BDHf1MrKytJFbNW3ohIhO20vr6uYiIsNXvJJIFoTlgDgs3DhW2SD3z8/+JTmJB0EScScghI+fcM/FNIuTNgDyl3Buwh5c6APaTcGbCHlDsD9pByZ8AeUu4M2EPKnQF7SLkzYA8pdwbsIeXOgD2k3Bmwh5QbA6lLihuIRP4AXubLj7lh8ksAAAAASUVORK5CYII="
  400. #End Region
  401.  
  402.     Private _xChangeCursor As Boolean = True
  403.     Public Property XChangeCursor As Boolean
  404.         Get
  405.             Return _xChangeCursor
  406.         End Get
  407.         Set(value As Boolean)
  408.             _xChangeCursor = value
  409.             Invalidate()
  410.         End Set
  411.     End Property
  412.  
  413.     Private _title As String = Name
  414.     Public Property Title As String
  415.         Get
  416.             Return _title
  417.         End Get
  418.         Set(value As String)
  419.             _title = value
  420.             Invalidate()
  421.         End Set
  422.     End Property
  423.  
  424.     Private _exitButton As Boolean = False
  425.     Public Property ShowExit As Boolean
  426.         Get
  427.             Return _exitButton
  428.         End Get
  429.         Set(value As Boolean)
  430.             _exitButton = value
  431.             Invalidate()
  432.         End Set
  433.     End Property
  434.  
  435.     Private _showImage As Boolean = True
  436.     Public Property ShowImage As Boolean
  437.         Get
  438.             Return _showImage
  439.         End Get
  440.         Set(value As Boolean)
  441.             _showImage = value
  442.             Invalidate()
  443.         End Set
  444.     End Property
  445.  
  446.     Private _image As Image
  447.     Public Property Image As Image
  448.         Get
  449.             Return _image
  450.         End Get
  451.         Set(value As Image)
  452.             _image = value
  453.             Invalidate()
  454.         End Set
  455.     End Property
  456.  
  457.     Private _border As Color = FromHex("#435363")
  458.     Public Property Border As Color
  459.         Get
  460.             Return _border
  461.         End Get
  462.         Set(value As Color)
  463.             _border = value
  464.             Invalidate()
  465.         End Set
  466.     End Property
  467.  
  468.     Sub New()
  469.         Size = New Size(370, 80)
  470.         DoubleBuffered = True
  471.     End Sub
  472.  
  473.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  474.         MyBase.OnPaint(e)
  475.         Dim g As Graphics = e.Graphics
  476.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  477.  
  478.  
  479.         Select Case ShowImage
  480.             Case True
  481.                 If _image Is Nothing Then
  482.                     g.DrawImage(b64Image(FillerImage), 13, 8)
  483.                 Else
  484.                     g.DrawImage(_image, 12, 8, 64, 64)
  485.                 End If
  486.                 g.DrawString(_title, New Font("Segoe UI Semilight", 14), New SolidBrush(ForeColor), 84, 6)
  487.                 g.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(86, 33, Width - 88, Height - 10))
  488.             Case False
  489.                 g.DrawString(_title, New Font("Segoe UI Semilight", 14), New SolidBrush(ForeColor), 18, 6)
  490.                 g.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(20, 33, Width - 28, Height - 10))
  491.         End Select
  492.  
  493.         If ShowExit Then
  494.             If _xHover Then
  495.                 g.DrawString("r", New Font("Marlett", 9), New SolidBrush(FromHex("#596372")), Width - 18, 4)
  496.             Else
  497.                 g.DrawString("r", New Font("Marlett", 9), New SolidBrush(FromHex("#435363")), Width - 18, 4)
  498.             End If
  499.         End If
  500.  
  501.         g.DrawRectangle(New Pen(_border), 0, 0, Width - 1, Height - 1)
  502.         g.FillRectangle(New SolidBrush(_border), 0, 0, 6, Height)
  503.     End Sub
  504.  
  505.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  506.         MyBase.OnMouseMove(e)
  507.         If _exitButton Then
  508.             If New Rectangle(Width - 16, 4, 12, 13).Contains(e.X, e.Y) Then
  509.                 _xHover = True
  510.                 If _xChangeCursor Then
  511.                     Cursor = Cursors.Hand
  512.                 End If
  513.             Else
  514.                 _xHover = False
  515.                 Cursor = Cursors.Default
  516.             End If
  517.         End If
  518.         Invalidate()
  519.     End Sub
  520.  
  521.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  522.         MyBase.OnMouseUp(e)
  523.         If _exitButton Then
  524.             If _xHover Then
  525.                 RaiseEvent XClicked(Me, EventArgs.Empty)
  526.             End If
  527.         End If
  528.     End Sub
  529.  
  530.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  531.         MyBase.OnTextChanged(e)
  532.         Invalidate()
  533.     End Sub
  534. End Class
  535.  
  536. Public Class VelocityTabControl
  537.     Inherits TabControl
  538.  
  539.     Private _overtab As Integer = 0
  540.  
  541.     Private _txtAlign As TxtAlign = TxtAlign.Center
  542.     Public Property TextAlign As TxtAlign
  543.         Get
  544.             Return _txtAlign
  545.         End Get
  546.         Set(value As TxtAlign)
  547.             _txtAlign = value
  548.             Invalidate()
  549.         End Set
  550.     End Property
  551.  
  552.     Sub New()
  553.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
  554.         DoubleBuffered = True
  555.         SizeMode = TabSizeMode.Fixed
  556.         ItemSize = New Size(40, 130)
  557.         Alignment = TabAlignment.Left
  558.         Font = New Font("Segoe UI Semilight", 9)
  559.     End Sub
  560.      
  561.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  562.         MyBase.OnPaint(e)
  563.         Dim b As New Bitmap(Width, Height)
  564.         Dim g As Graphics = Graphics.FromImage(b)
  565.         g.Clear(FromHex("#435363"))
  566.         For i = 0 To TabCount - 1
  567.             Dim tabRect As Rectangle = GetTabRect(i)
  568.             If i = SelectedIndex Then
  569.                 g.FillRectangle(New SolidBrush(FromHex("#2c3e50")), tabRect)
  570.             ElseIf i = _overtab Then
  571.                 g.FillRectangle(New SolidBrush(FromHex("#435363")), tabRect)
  572.             Else
  573.                 g.FillRectangle(New SolidBrush(FromHex("#38495A")), tabRect)
  574.             End If
  575.             Select Case _txtAlign
  576.                 Case TxtAlign.Left
  577.                     g.DrawString(TabPages(i).Text, Font, Brushes.White, New Rectangle(tabRect.X + 8, tabRect.Y, tabRect.Width, tabRect.Height), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  578.                 Case TxtAlign.Center
  579.                     g.DrawString(TabPages(i).Text, Font, Brushes.White, tabRect, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  580.                 Case TxtAlign.Right
  581.                     g.DrawString(TabPages(i).Text, Font, Brushes.White, New Rectangle(tabRect.X - 8, tabRect.Y, tabRect.Width, tabRect.Height), New StringFormat With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  582.             End Select
  583.         Next
  584.  
  585.         e.Graphics.DrawImage(b.Clone, 0, 0)
  586.         g.Dispose() : b.Dispose()
  587.     End Sub
  588.  
  589.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  590.         MyBase.OnMouseMove(e)
  591.         For i = 0 To TabPages.Count - 1
  592.             If GetTabRect(i).Contains(e.Location) Then
  593.                 _overtab = i
  594.             End If
  595.             Invalidate()
  596.         Next
  597.     End Sub
  598. End Class
  599.  
  600. Public Class VelocityTag
  601.     Inherits Control
  602.  
  603.     Private _border As Color = FromHex("#2c3e50")
  604.     Public Property Border As Color
  605.         Get
  606.             Return _border
  607.         End Get
  608.         Set(value As Color)
  609.             _border = value
  610.             Invalidate()
  611.         End Set
  612.     End Property
  613.  
  614.     Sub New()
  615.         DoubleBuffered = True
  616.         BackColor = FromHex("#34495e")
  617.         ForeColor = Color.White
  618.     End Sub
  619.  
  620.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  621.         MyBase.OnPaint(e)
  622.         Dim g As Graphics = e.Graphics
  623.         g.Clear(BackColor)
  624.         g.DrawRectangle(New Pen(_border), 0, 0, Width - 1, Height - 1)
  625.         g.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(0, 0, Width, Height), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  626.     End Sub
  627.  
  628.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  629.         MyBase.OnTextChanged(e)
  630.         Invalidate()
  631.     End Sub
  632. End Class
  633.  
  634. Public Class VelocityProgressBar
  635.     Inherits Control
  636.  
  637.     Private _border As Color = FromHex("#485e75")
  638.     Public Property Border As Color
  639.         Get
  640.             Return _border
  641.         End Get
  642.         Set(value As Color)
  643.             _border = value
  644.             Invalidate()
  645.         End Set
  646.     End Property
  647.  
  648.     Private _progressColor As Color = FromHex("#2c3e50")
  649.     Public Property ProgressColor As Color
  650.         Get
  651.             Return _progressColor
  652.         End Get
  653.         Set(value As Color)
  654.             _progressColor = value
  655.             Invalidate()
  656.         End Set
  657.     End Property
  658.  
  659.     Private _val As Integer = 0
  660.     Public Property Value As Integer
  661.         Get
  662.             Return _val
  663.         End Get
  664.         Set(value As Integer)
  665.             _val = value
  666.             ValChanged()
  667.             Invalidate()
  668.         End Set
  669.     End Property
  670.  
  671.     Private _min As Integer = 0
  672.     Public Property Min As Integer
  673.         Get
  674.             Return _min
  675.         End Get
  676.         Set(value As Integer)
  677.             _min = value
  678.             Invalidate()
  679.         End Set
  680.     End Property
  681.  
  682.     Private _max As Integer = 100
  683.     Public Property Max As Integer
  684.         Get
  685.             Return _max
  686.         End Get
  687.         Set(value As Integer)
  688.             _max = value
  689.             Invalidate()
  690.         End Set
  691.     End Property
  692.  
  693.     Private _showPercent As Boolean = False
  694.     Public Property ShowPercent As Boolean
  695.         Get
  696.             Return _showPercent
  697.         End Get
  698.         Set(value As Boolean)
  699.             _showPercent = value
  700.             Invalidate()
  701.         End Set
  702.     End Property
  703.  
  704.     Private Sub ValChanged()
  705.         If _val > _max Then
  706.             _val = _max
  707.         End If
  708.     End Sub
  709.  
  710.     Sub New()
  711.         DoubleBuffered = True
  712.     End Sub
  713.  
  714.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  715.         MyBase.OnPaint(e)
  716.         Dim g As Graphics = e.Graphics
  717.  
  718.         If _showPercent Then
  719.             g.FillRectangle(New SolidBrush(FromHex("#506070")), 0, 0, Width - 35, Height - 1)
  720.             g.FillRectangle(New SolidBrush(_progressColor), New Rectangle(0, 0, _val * (Width - 35) / (_max - _min), Height))
  721.             g.DrawRectangle(New Pen(Color.Black), 0, 0, Width - 35, Height - 1)
  722.             g.DrawString(_val & "%", Font, New SolidBrush(ForeColor), Width - 30, Height / 2 - g.MeasureString(_val & "%", Font).Height / 2 - 1)
  723.         Else
  724.             g.Clear(FromHex("#506070"))
  725.             g.FillRectangle(New SolidBrush(_progressColor), New Rectangle(0, 0, (_val - 0) * (Width - 0) / (_max - _min) + 0, Height))
  726.             g.DrawRectangle(New Pen(Color.Black), 0, 0, Width - 1, Height - 1)
  727.         End If
  728.     End Sub
  729. End Class
  730.  
  731. Public Class VelocityToggle
  732.     Inherits Control
  733.  
  734.     Private _checked As Boolean = False
  735.     Public Property Checked As Boolean
  736.         Get
  737.             Return _checked
  738.         End Get
  739.         Set(value As Boolean)
  740.             _checked = value
  741.             Invalidate()
  742.         End Set
  743.     End Property
  744.  
  745.     Sub New()
  746.         Size = New Size(50, 23)
  747.         DoubleBuffered = True
  748.     End Sub
  749.  
  750.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  751.         MyBase.OnPaint(e)
  752.         Dim g As Graphics = e.Graphics
  753.         g.Clear(FromHex("#435363"))
  754.  
  755.         Select Case _checked
  756.             Case True
  757.                 g.FillRectangle(Brushes.White, Width - 19, Height - 19, 15, 15)
  758.             Case False
  759.                 g.FillRectangle(New SolidBrush(FromHex("#2c3e50")), 4, 4, 15, 15)
  760.         End Select
  761.     End Sub
  762.  
  763.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  764.         MyBase.OnMouseDown(e)
  765.         _checked = Not (_checked)
  766.         Invalidate()
  767.     End Sub
  768. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement