Advertisement
Guest User

Booster Theme [02/08]

a guest
Feb 8th, 2016
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 32.82 KB | None | 0 0
  1. ' // Booster Theme GDI+
  2. ' // 9 Controls
  3. ' // Made by AeroRev9 / Naywyn
  4. ' // 02/08.
  5.  
  6. Option Strict On
  7.  
  8. Imports System.ComponentModel
  9. Imports System.Drawing.Drawing2D
  10. Imports System.Drawing.Text
  11.  
  12. Friend Module Helpers
  13.  
  14.     Public G As Graphics
  15.     Private TargetStringMeasure As SizeF
  16.  
  17.     Enum MouseState As Byte
  18.         None = 0
  19.         Over = 1
  20.         Down = 2
  21.     End Enum
  22.  
  23.     Enum RoundingStyle As Byte
  24.         All = 0
  25.         Top = 1
  26.         Bottom = 2
  27.         Left = 3
  28.         Right = 4
  29.         TopRight = 5
  30.         BottomRight = 6
  31.     End Enum
  32.  
  33.     Public Function ColorFromHex(Hex As String) As Color
  34.         Return Color.FromArgb(CInt(Long.Parse(String.Format("FFFFFFFFFF{0}", Hex.Substring(1)), Globalization.NumberStyles.HexNumber)))
  35.     End Function
  36.  
  37.     Public Function MiddlePoint(TargetText As String, TargetFont As Font, Rect As Rectangle) As Point
  38.         TargetStringMeasure = G.MeasureString(TargetText, TargetFont)
  39.         Return New Point(CInt(Rect.Width / 2 - TargetStringMeasure.Width / 2), CInt(Rect.Height / 2 - TargetStringMeasure.Height / 2))
  40.     End Function
  41.  
  42.     Public Function RoundRect(Rect As Rectangle, Rounding As Integer, Optional Style As RoundingStyle = RoundingStyle.All) As GraphicsPath
  43.  
  44.         Dim GP As New GraphicsPath()
  45.         Dim AW As Integer = Rounding * 2
  46.  
  47.         GP.StartFigure()
  48.  
  49.         If Rounding = 0 Then
  50.             GP.AddRectangle(Rect)
  51.             GP.CloseAllFigures()
  52.             Return GP
  53.         End If
  54.  
  55.         Select Case Style
  56.             Case RoundingStyle.All
  57.                 GP.AddArc(New Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90)
  58.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90)
  59.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90)
  60.                 GP.AddArc(New Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90)
  61.             Case RoundingStyle.Top
  62.                 GP.AddArc(New Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90)
  63.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90)
  64.                 GP.AddLine(New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y + Rect.Height))
  65.             Case RoundingStyle.Bottom
  66.                 GP.AddLine(New Point(Rect.X, Rect.Y), New Point(Rect.X + Rect.Width, Rect.Y))
  67.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90)
  68.                 GP.AddArc(New Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90)
  69.             Case RoundingStyle.Left
  70.                 GP.AddArc(New Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90)
  71.                 GP.AddLine(New Point(Rect.X + Rect.Width, Rect.Y), New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height))
  72.                 GP.AddArc(New Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90)
  73.             Case RoundingStyle.Right
  74.                 GP.AddLine(New Point(Rect.X, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y))
  75.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90)
  76.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90)
  77.             Case RoundingStyle.TopRight
  78.                 GP.AddLine(New Point(Rect.X, Rect.Y + 1), New Point(Rect.X, Rect.Y))
  79.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90)
  80.                 GP.AddLine(New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height - 1), New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height))
  81.                 GP.AddLine(New Point(Rect.X + 1, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y + Rect.Height))
  82.             Case RoundingStyle.BottomRight
  83.                 GP.AddLine(New Point(Rect.X, Rect.Y + 1), New Point(Rect.X, Rect.Y))
  84.                 GP.AddLine(New Point(Rect.X + Rect.Width - 1, Rect.Y), New Point(Rect.X + Rect.Width, Rect.Y))
  85.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90)
  86.                 GP.AddLine(New Point(Rect.X + 1, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y + Rect.Height))
  87.         End Select
  88.  
  89.         GP.CloseAllFigures()
  90.  
  91.         Return GP
  92.  
  93.     End Function
  94.  
  95. End Module
  96.  
  97. Public Class BoosterHeader
  98.     Inherits Control
  99.  
  100.     Private TextMeasure As SizeF
  101.  
  102.     Sub New()
  103.         DoubleBuffered = True
  104.         Font = New Font("Segoe UI", 10)
  105.         ForeColor = ColorFromHex("#C0C0C0")
  106.     End Sub
  107.  
  108.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  109.  
  110.         G = e.Graphics
  111.         G.SmoothingMode = SmoothingMode.HighQuality
  112.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  113.  
  114.         G.Clear(Parent.BackColor)
  115.  
  116.         Using Line As New Pen(ColorFromHex("#5C5C5C"))
  117.             G.DrawLine(Line, 0, 6, Width - 1, 6)
  118.         End Using
  119.  
  120.         Using TextBrush As New SolidBrush(ColorFromHex("#D4D4D4")), TextFont As New Font("Segoe UI", 10), ParentFill As New SolidBrush(Parent.BackColor)
  121.             TextMeasure = G.MeasureString(Text, TextFont)
  122.             G.FillRectangle(ParentFill, New Rectangle(14, -4, CInt(TextMeasure.Width + 8), CInt(TextMeasure.Height + 4)))
  123.             G.DrawString(Text, TextFont, TextBrush, New Point(20, -4))
  124.         End Using
  125.  
  126.         MyBase.OnPaint(e)
  127.     End Sub
  128.  
  129.     Protected Overrides Sub OnResize(e As EventArgs)
  130.         Size = New Size(Width, 14)
  131.         MyBase.OnResize(e)
  132.     End Sub
  133.  
  134. End Class
  135.  
  136. Public Class BoosterButton
  137.     Inherits Button
  138.  
  139.     Private State As MouseState
  140.     Private Gradient As LinearGradientBrush
  141.  
  142.     Sub New()
  143.         DoubleBuffered = True
  144.         Font = New Font("Segoe UI", 9)
  145.         ForeColor = ColorFromHex("#B6B6B6")
  146.         SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque Or ControlStyles.OptimizedDoubleBuffer, True)
  147.     End Sub
  148.  
  149.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  150.  
  151.         G = e.Graphics
  152.         G.SmoothingMode = SmoothingMode.HighQuality
  153.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  154.  
  155.         MyBase.OnPaint(e)
  156.  
  157.         G.Clear(Parent.BackColor)
  158.  
  159.         If Enabled Then
  160.  
  161.             Select Case State
  162.                 Case MouseState.None
  163.                     Gradient = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), ColorFromHex("#606060"), ColorFromHex("#4E4E4E"), LinearGradientMode.Vertical)
  164.  
  165.                 Case MouseState.Over
  166.                     Gradient = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), ColorFromHex("#6A6A6A"), ColorFromHex("#585858"), LinearGradientMode.Vertical)
  167.  
  168.                 Case MouseState.Down
  169.                     Gradient = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), ColorFromHex("#565656"), ColorFromHex("#444444"), LinearGradientMode.Vertical)
  170.  
  171.             End Select
  172.  
  173.             G.FillPath(Gradient, RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  174.  
  175.             Using Border As New Pen(ColorFromHex("#323232"))
  176.                 G.DrawPath(Border, RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  177.             End Using
  178.  
  179.             '// Top Line
  180.             Select Case State
  181.  
  182.                 Case MouseState.None
  183.  
  184.                     Using TopLine As New Pen(ColorFromHex("#737373"))
  185.                         G.DrawLine(TopLine, 4, 1, Width - 4, 1)
  186.                     End Using
  187.  
  188.                 Case MouseState.Over
  189.  
  190.                     Using TopLine As New Pen(ColorFromHex("#7D7D7D"))
  191.                         G.DrawLine(TopLine, 4, 1, Width - 4, 1)
  192.                     End Using
  193.  
  194.                 Case MouseState.Down
  195.  
  196.                     Using TopLine As New Pen(ColorFromHex("#696969"))
  197.                         G.DrawLine(TopLine, 4, 1, Width - 4, 1)
  198.                     End Using
  199.  
  200.             End Select
  201.  
  202.             Using TextBrush As New SolidBrush(ColorFromHex("#F5F5F5")), TextFont As New Font("Segoe UI", 9)
  203.                 G.DrawString(Text, TextFont, TextBrush, MiddlePoint(Text, TextFont, New Rectangle(0, 0, Width + 2, Height)))
  204.             End Using
  205.  
  206.         Else
  207.  
  208.             Gradient = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), ColorFromHex("#4C4C4C"), ColorFromHex("#3A3A3A"), LinearGradientMode.Vertical)
  209.  
  210.             G.FillPath(Gradient, RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  211.  
  212.             Using Border As New Pen(ColorFromHex("#323232"))
  213.                 G.DrawPath(Border, RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  214.             End Using
  215.  
  216.             Using TopLine As New Pen(ColorFromHex("#5F5F5F"))
  217.                 G.DrawLine(TopLine, 4, 1, Width - 4, 1)
  218.             End Using
  219.  
  220.             Using TextBrush As New SolidBrush(ColorFromHex("#818181")), TextFont As New Font("Segoe UI", 9)
  221.                 G.DrawString(Text, TextFont, TextBrush, MiddlePoint(Text, TextFont, New Rectangle(0, 0, Width + 2, Height)))
  222.             End Using
  223.  
  224.         End If
  225.  
  226.     End Sub
  227.  
  228.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  229.         State = MouseState.Over : Invalidate()
  230.         MyBase.OnMouseEnter(e)
  231.     End Sub
  232.  
  233.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  234.         State = MouseState.None : Invalidate()
  235.         MyBase.OnMouseLeave(e)
  236.     End Sub
  237.  
  238.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  239.         State = MouseState.Down : Invalidate()
  240.         MyBase.OnMouseDown(e)
  241.     End Sub
  242.  
  243.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  244.         State = MouseState.Over : Invalidate()
  245.         MyBase.OnMouseUp(e)
  246.     End Sub
  247.  
  248. End Class
  249.  
  250. Public Class BoosterToolTip
  251.     Inherits ToolTip
  252.  
  253.     Public Sub New()
  254.         OwnerDraw = True
  255.         BackColor = ColorFromHex("#242424")
  256.         AddHandler Draw, AddressOf OnDraw
  257.     End Sub
  258.  
  259.     Private Sub OnDraw(sender As Object, e As DrawToolTipEventArgs)
  260.  
  261.         G = e.Graphics
  262.         G.SmoothingMode = SmoothingMode.HighQuality
  263.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  264.  
  265.         G.Clear(ColorFromHex("#242424"))
  266.  
  267.         Using Border As New Pen(ColorFromHex("#343434"))
  268.             G.DrawRectangle(Border, New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1))
  269.         End Using
  270.  
  271.         Using TextFont As New Font("Segoe UI", 9), TextBrush As New SolidBrush(ColorFromHex("#B6B6B6"))
  272.             G.DrawString(e.ToolTipText, TextFont, TextBrush, New PointF(e.Bounds.X + 4, e.Bounds.Y + 1))
  273.         End Using
  274.  
  275.     End Sub
  276.  
  277. End Class
  278.  
  279. <DefaultEvent("TextChanged")>
  280. Public Class BoosterTextBox
  281.     Inherits Control
  282.  
  283.     Private WithEvents T As TextBox
  284.     Private State As MouseState
  285.  
  286.     Public Shadows Property Text As String
  287.         Get
  288.             Return T.Text
  289.         End Get
  290.         Set(value As String)
  291.             MyBase.Text = value
  292.             T.Text = value
  293.             Invalidate()
  294.         End Set
  295.     End Property
  296.  
  297.     Public Shadows Property Enabled As Boolean
  298.         Get
  299.             Return T.Enabled
  300.         End Get
  301.         Set(value As Boolean)
  302.             T.Enabled = value
  303.             Invalidate()
  304.         End Set
  305.     End Property
  306.  
  307.     Public Property UseSystemPasswordChar As Boolean
  308.         Get
  309.             Return T.UseSystemPasswordChar
  310.         End Get
  311.         Set(value As Boolean)
  312.             T.UseSystemPasswordChar = value
  313.             Invalidate()
  314.         End Set
  315.     End Property
  316.  
  317.     Public Property MultiLine() As Boolean
  318.         Get
  319.             Return T.Multiline
  320.         End Get
  321.         Set(ByVal value As Boolean)
  322.             T.Multiline = value
  323.             Size = New Size(T.Width + 2, T.Height + 2)
  324.             Invalidate()
  325.         End Set
  326.     End Property
  327.  
  328.     Public Shadows Property [ReadOnly]() As Boolean
  329.         Get
  330.             Return T.ReadOnly
  331.         End Get
  332.         Set(ByVal value As Boolean)
  333.             T.ReadOnly = value
  334.             Invalidate()
  335.         End Set
  336.     End Property
  337.  
  338.     Sub New()
  339.         DoubleBuffered = True
  340.  
  341.         T = New TextBox With {
  342.             .BorderStyle = BorderStyle.None,
  343.             .BackColor = ColorFromHex("#242424"),
  344.             .ForeColor = ColorFromHex("#B6B6B6"),
  345.             .Location = New Point(1, 1),
  346.             .Multiline = True}
  347.  
  348.         Controls.Add(T)
  349.     End Sub
  350.  
  351.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  352.  
  353.         G = e.Graphics
  354.         G.SmoothingMode = SmoothingMode.HighQuality
  355.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  356.  
  357.         If Enabled Then
  358.  
  359.             T.BackColor = ColorFromHex("#242424")
  360.  
  361.             Select Case State
  362.  
  363.                 Case MouseState.Down
  364.  
  365.                     Using Border As New Pen(ColorFromHex("#C8C8C8"))
  366.                         G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  367.                     End Using
  368.  
  369.                 Case Else
  370.  
  371.                     Using Border As New Pen(ColorFromHex("#5C5C5C"))
  372.                         G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  373.                     End Using
  374.  
  375.             End Select
  376.  
  377.         Else
  378.  
  379.             T.BackColor = ColorFromHex("#282828")
  380.  
  381.             Using Border As New Pen(ColorFromHex("#484848"))
  382.                 G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  383.             End Using
  384.  
  385.         End If
  386.  
  387.         MyBase.OnPaint(e)
  388.  
  389.     End Sub
  390.  
  391.     Protected Overrides Sub OnEnter(e As EventArgs)
  392.         State = MouseState.Down : Invalidate()
  393.         MyBase.OnEnter(e)
  394.     End Sub
  395.  
  396.     Protected Overrides Sub OnLeave(e As EventArgs)
  397.         State = MouseState.None : Invalidate()
  398.         MyBase.OnLeave(e)
  399.     End Sub
  400.  
  401.     Protected Overrides Sub OnResize(e As EventArgs)
  402.         If MultiLine Then
  403.             T.Size = New Size(Width - 2, Height - 2) : Invalidate()
  404.         Else
  405.             T.Size = New Size(Width - 2, T.Height)
  406.             Size = New Size(Width, T.Height + 2)
  407.         End If
  408.         MyBase.OnResize(e)
  409.     End Sub
  410.  
  411.     Private Sub TTextChanged() Handles T.TextChanged
  412.         MyBase.OnTextChanged(EventArgs.Empty)
  413.     End Sub
  414.  
  415. End Class
  416.  
  417. Public Class BoosterCheckBox
  418.     Inherits CheckBox
  419.  
  420.     Private State As MouseState
  421.  
  422.     Sub New()
  423.         DoubleBuffered = True
  424.         Font = New Font("Segoe UI", 9)
  425.         ForeColor = ColorFromHex("#B6B6B6")
  426.         SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque Or ControlStyles.OptimizedDoubleBuffer, True)
  427.     End Sub
  428.  
  429.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  430.  
  431.         G = e.Graphics
  432.         G.SmoothingMode = SmoothingMode.HighQuality
  433.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  434.  
  435.         MyBase.OnPaint(e)
  436.  
  437.         G.Clear(Parent.BackColor)
  438.  
  439.         If Enabled Then
  440.  
  441.             Using Fill As New SolidBrush(ColorFromHex("#242424")), Border As New Pen(ColorFromHex("#5C5C5C"))
  442.                 G.FillRectangle(Fill, New Rectangle(0, 0, 16, 16))
  443.                 G.DrawRectangle(Border, New Rectangle(0, 0, 16, 16))
  444.             End Using
  445.  
  446.             Select Case State
  447.  
  448.                 Case MouseState.None
  449.  
  450.                     Using TextBrush As New SolidBrush(ColorFromHex("#B6B6B6")), TextFont As New Font("Segoe UI", 9)
  451.                         G.DrawString(Text, TextFont, TextBrush, New Point(25, -1))
  452.                     End Using
  453.  
  454.                 Case MouseState.Over
  455.  
  456.                     Using TextBrush As New SolidBrush(ColorFromHex("#F5F5F5")), TextFont As New Font("Segoe UI", 9)
  457.                         G.DrawString(Text, TextFont, TextBrush, New Point(25, -1))
  458.                     End Using
  459.  
  460.             End Select
  461.  
  462.             If Checked Then
  463.  
  464.                 Using CheckFont As New Font("Marlett", 12), CheckBrush As New SolidBrush(ColorFromHex("#909090"))
  465.                     G.DrawString("b", CheckFont, CheckBrush, New Point(-2, 1))
  466.                 End Using
  467.  
  468.             End If
  469.  
  470.         Else
  471.  
  472.             Using Fill As New SolidBrush(ColorFromHex("#282828")), Border As New Pen(ColorFromHex("#484848"))
  473.                 G.FillRectangle(Fill, New Rectangle(0, 0, 16, 16))
  474.                 G.DrawRectangle(Border, New Rectangle(0, 0, 16, 16))
  475.             End Using
  476.  
  477.             Using TextBrush As New SolidBrush(ColorFromHex("#818181")), TextFont As New Font("Segoe UI", 9)
  478.                 G.DrawString(Text, TextFont, TextBrush, New Point(25, -1))
  479.             End Using
  480.  
  481.             If Checked Then
  482.  
  483.                 Using CheckFont As New Font("Marlett", 12), CheckBrush As New SolidBrush(ColorFromHex("#707070"))
  484.                     G.DrawString("b", CheckFont, CheckBrush, New Point(-2, 1))
  485.                 End Using
  486.             End If
  487.  
  488.         End If
  489.  
  490.     End Sub
  491.  
  492.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  493.         State = MouseState.Over : Invalidate()
  494.         MyBase.OnMouseEnter(e)
  495.     End Sub
  496.  
  497.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  498.         State = MouseState.None : Invalidate()
  499.         MyBase.OnMouseLeave(e)
  500.     End Sub
  501.  
  502. End Class
  503.  
  504. Public Class BoosterComboBox
  505.     Inherits ComboBox
  506.  
  507.     Private State As MouseState
  508.     Private Rect As Rectangle
  509.  
  510.     Private ItemString As String = String.Empty
  511.     Private FirstItem As String = String.Empty
  512.  
  513.     Sub New()
  514.         ItemHeight = 20
  515.         DoubleBuffered = True
  516.         FlatStyle = FlatStyle.Flat
  517.         DropDownStyle = ComboBoxStyle.DropDownList
  518.         DrawMode = DrawMode.OwnerDrawFixed
  519.         SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque Or ControlStyles.OptimizedDoubleBuffer, True)
  520.     End Sub
  521.  
  522.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  523.  
  524.         G = e.Graphics
  525.         G.SmoothingMode = SmoothingMode.HighQuality
  526.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  527.  
  528.         MyBase.OnPaint(e)
  529.  
  530.         G.Clear(Parent.BackColor)
  531.  
  532.         If Enabled Then
  533.  
  534.             Using Fill As New SolidBrush(ColorFromHex("#242424"))
  535.                 G.FillRectangle(Fill, New Rectangle(0, 0, Width - 1, Height - 1))
  536.             End Using
  537.  
  538.             Select Case State
  539.  
  540.                 Case MouseState.None
  541.  
  542.                     Using Border As New Pen(ColorFromHex("#5C5C5C"))
  543.                         G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  544.                     End Using
  545.  
  546.                 Case MouseState.Over
  547.  
  548.                     Using Border As New Pen(ColorFromHex("#C8C8C8"))
  549.                         G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  550.                     End Using
  551.  
  552.             End Select
  553.  
  554.             Using ArrowFont As New Font("Marlett", 12), ArrowBrush As New SolidBrush(ColorFromHex("#909090"))
  555.                 G.DrawString("6", ArrowFont, ArrowBrush, New Point(Width - 20, 5))
  556.             End Using
  557.  
  558.             If Not IsNothing(Items) Then
  559.  
  560.                 Try : FirstItem = GetItemText(Items(0)) : Catch : End Try
  561.  
  562.                 If Not SelectedIndex = -1 Then
  563.  
  564.                     Using TextBrush As New SolidBrush(ColorFromHex("#B6B6B6")), TextFont As New Font("Segoe UI", 9)
  565.                         G.DrawString(ItemString, TextFont, TextBrush, New Point(4, 4))
  566.                     End Using
  567.  
  568.                 Else
  569.  
  570.                     Using TextBrush As New SolidBrush(ColorFromHex("#B6B6B6")), TextFont As New Font("Segoe UI", 9)
  571.                         G.DrawString(FirstItem, TextFont, TextBrush, New Point(4, 4))
  572.                     End Using
  573.  
  574.                 End If
  575.  
  576.  
  577.             End If
  578.  
  579.         Else
  580.  
  581.             Using Fill As New SolidBrush(ColorFromHex("#282828")), Border As New Pen(ColorFromHex("#484848"))
  582.                 G.FillRectangle(Fill, New Rectangle(0, 0, Width - 1, Height - 1))
  583.                 G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  584.             End Using
  585.  
  586.             Using ArrowFont As New Font("Marlett", 12), ArrowBrush As New SolidBrush(ColorFromHex("#707070"))
  587.                 G.DrawString("6", ArrowFont, ArrowBrush, New Point(Width - 20, 5))
  588.             End Using
  589.  
  590.             If Not IsNothing(Items) Then
  591.  
  592.                 Try : FirstItem = GetItemText(Items(0)) : Catch : End Try
  593.  
  594.                 Using TextBrush As New SolidBrush(ColorFromHex("#818181")), TextFont As New Font("Segoe UI", 9)
  595.                     G.DrawString(FirstItem, TextFont, TextBrush, New Point(4, 4))
  596.                 End Using
  597.  
  598.             End If
  599.  
  600.         End If
  601.  
  602.     End Sub
  603.  
  604.     Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  605.  
  606.         G = e.Graphics
  607.         G.SmoothingMode = SmoothingMode.HighQuality
  608.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  609.  
  610.         Rect = e.Bounds
  611.  
  612.         Using Back As New SolidBrush(ColorFromHex("#242424"))
  613.             G.FillRectangle(Back, New Rectangle(e.Bounds.X - 4, e.Bounds.Y - 1, e.Bounds.Width + 4, e.Bounds.Height - 1))
  614.         End Using
  615.  
  616.         If Not e.Index = -1 Then
  617.             ItemString = GetItemText(Items(e.Index))
  618.         End If
  619.  
  620.         Using ItemsFont As New Font("Segoe UI", 9), Border As New Pen(ColorFromHex("#D0D5D9"))
  621.  
  622.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  623.  
  624.                 Using HoverItemBrush As New SolidBrush(ColorFromHex("#F5F5F5"))
  625.                     G.DrawString(ItemString, New Font("Segoe UI", 9), HoverItemBrush, New Point(Rect.X + 5, Rect.Y + 1))
  626.                 End Using
  627.  
  628.             Else
  629.  
  630.                 Using DefaultItemBrush As New SolidBrush(ColorFromHex("#C0C0C0"))
  631.                     G.DrawString(ItemString, New Font("Segoe UI", 9), DefaultItemBrush, New Point(Rect.X + 5, Rect.Y + 1))
  632.                 End Using
  633.  
  634.             End If
  635.  
  636.         End Using
  637.  
  638.         e.DrawFocusRectangle()
  639.  
  640.         MyBase.OnDrawItem(e)
  641.  
  642.     End Sub
  643.  
  644.     Protected Overrides Sub OnSelectedItemChanged(ByVal e As EventArgs)
  645.         Invalidate()
  646.         MyBase.OnSelectedItemChanged(e)
  647.     End Sub
  648.  
  649.     Protected Overrides Sub OnSelectedIndexChanged(e As EventArgs)
  650.         State = MouseState.None : Invalidate()
  651.         MyBase.OnSelectedIndexChanged(e)
  652.     End Sub
  653.  
  654.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  655.         State = MouseState.Over : Invalidate()
  656.         MyBase.OnMouseEnter(e)
  657.     End Sub
  658.  
  659.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  660.         State = MouseState.None : Invalidate()
  661.         MyBase.OnMouseLeave(e)
  662.     End Sub
  663.  
  664. End Class
  665.  
  666. Public Class BoosterTabControl
  667.     Inherits TabControl
  668.  
  669.     Private MainRect As Rectangle
  670.     Private OverRect As Rectangle
  671.  
  672.     Private SubOverIndex As Integer = -1
  673.  
  674.     Private ReadOnly Property Hovering As Boolean
  675.         Get
  676.             Return Not OverIndex = -1
  677.         End Get
  678.     End Property
  679.  
  680.     Private Property OverIndex As Integer
  681.         Get
  682.             Return SubOverIndex
  683.         End Get
  684.         Set(value As Integer)
  685.             SubOverIndex = value
  686.             If Not SubOverIndex = -1 Then
  687.                 OverRect = GetTabRect(OverIndex)
  688.             End If
  689.             Invalidate()
  690.         End Set
  691.     End Property
  692.  
  693.     Sub New()
  694.         DoubleBuffered = True
  695.         Font = New Font("Segoe UI", 10)
  696.         ForeColor = ColorFromHex("#78797B")
  697.         ItemSize = New Size(40, 170)
  698.         SizeMode = TabSizeMode.Fixed
  699.         Alignment = TabAlignment.Left
  700.         SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque Or ControlStyles.OptimizedDoubleBuffer, True)
  701.     End Sub
  702.  
  703.     Protected Overrides Sub CreateHandle()
  704.         For Each Tab As TabPage In TabPages
  705.             Tab.BackColor = ColorFromHex("#424242")
  706.             Tab.ForeColor = ColorFromHex("#B6B6B6")
  707.             Tab.Font = New Font("Segoe UI", 9)
  708.         Next
  709.         MyBase.CreateHandle()
  710.     End Sub
  711.  
  712.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  713.  
  714.         G = e.Graphics
  715.         G.SmoothingMode = SmoothingMode.HighQuality
  716.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  717.  
  718.         G.Clear(ColorFromHex("#333333"))
  719.  
  720.         Using Border As New Pen(ColorFromHex("#292929"))
  721.             G.SmoothingMode = SmoothingMode.None
  722.             G.DrawLine(Border, ItemSize.Height + 3, 4, ItemSize.Height + 3, Height - 5)
  723.         End Using
  724.  
  725.         For I As Integer = 0 To TabPages.Count - 1
  726.  
  727.             MainRect = GetTabRect(I)
  728.  
  729.             If SelectedIndex = I Then
  730.  
  731.                 Using Selection As New SolidBrush(ColorFromHex("#424242"))
  732.                     G.FillRectangle(Selection, New Rectangle(MainRect.X - 6, MainRect.Y + 2, MainRect.Width + 8, MainRect.Height - 1))
  733.                 End Using
  734.  
  735.                 Using SelectionLeft As New SolidBrush(ColorFromHex("#F63333"))
  736.                     G.FillRectangle(SelectionLeft, New Rectangle(MainRect.X - 2, MainRect.Y + 2, 3, MainRect.Height - 1))
  737.                 End Using
  738.  
  739.                 Using TextBrush As New SolidBrush(ColorFromHex("#F5F5F5")), TextFont As New Font("Segoe UI", 10)
  740.                     G.DrawString(TabPages(I).Text, TextFont, TextBrush, New Point(MainRect.X + 25, MainRect.Y + 11))
  741.                 End Using
  742.  
  743.             Else
  744.  
  745.                 Using TextBrush As New SolidBrush(ColorFromHex("#C0C0C0")), TextFont As New Font("Segoe UI", 10)
  746.                     G.DrawString(TabPages(I).Text, TextFont, TextBrush, New Point(MainRect.X + 25, MainRect.Y + 11))
  747.                 End Using
  748.  
  749.             End If
  750.  
  751.             If Hovering Then
  752.  
  753.                 Using Selection As New SolidBrush(ColorFromHex("#383838"))
  754.                     G.FillRectangle(Selection, New Rectangle(OverRect.X - 6, OverRect.Y + 2, OverRect.Width + 8, OverRect.Height - 1))
  755.                 End Using
  756.  
  757.                 Using TextBrush As New SolidBrush(ColorFromHex("#C0C0C0")), TextFont As New Font("Segoe UI", 10)
  758.                     G.DrawString(TabPages(OverIndex).Text, TextFont, TextBrush, New Point(OverRect.X + 25, OverRect.Y + 11))
  759.                 End Using
  760.  
  761.             End If
  762.  
  763.         Next
  764.  
  765.         MyBase.OnPaint(e)
  766.  
  767.     End Sub
  768.  
  769.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  770.         For I As Integer = 0 To TabPages.Count - 1
  771.             If GetTabRect(I).Contains(e.Location) And Not SelectedIndex = I Then
  772.                 OverIndex = I
  773.                 Exit For
  774.             Else
  775.                 OverIndex = -1
  776.             End If
  777.         Next
  778.         MyBase.OnMouseMove(e)
  779.     End Sub
  780.  
  781.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  782.         OverIndex = -1
  783.         MyBase.OnMouseLeave(e)
  784.     End Sub
  785.  
  786. End Class
  787.  
  788. Public Class BoosterRadioButton
  789.     Inherits RadioButton
  790.  
  791.     Private State As MouseState
  792.  
  793.     Sub New()
  794.         DoubleBuffered = True
  795.         Font = New Font("Segoe UI", 9)
  796.         ForeColor = ColorFromHex("#B6B6B6")
  797.         SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque Or ControlStyles.OptimizedDoubleBuffer, True)
  798.     End Sub
  799.  
  800.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  801.  
  802.         G = e.Graphics
  803.         G.SmoothingMode = SmoothingMode.HighQuality
  804.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  805.  
  806.         MyBase.OnPaint(e)
  807.  
  808.         G.Clear(Parent.BackColor)
  809.  
  810.         If Enabled Then
  811.  
  812.             Using Fill As New SolidBrush(ColorFromHex("#242424")), Border As New Pen(ColorFromHex("#5C5C5C"))
  813.                 G.FillEllipse(Fill, New Rectangle(0, 0, 16, 16))
  814.                 G.DrawEllipse(Border, New Rectangle(0, 0, 16, 16))
  815.             End Using
  816.  
  817.             Select Case State
  818.  
  819.                 Case MouseState.None
  820.  
  821.                     Using TextBrush As New SolidBrush(ColorFromHex("#B6B6B6")), TextFont As New Font("Segoe UI", 9)
  822.                         G.DrawString(Text, TextFont, TextBrush, New Point(25, -1))
  823.                     End Using
  824.  
  825.                 Case MouseState.Over
  826.  
  827.                     Using TextBrush As New SolidBrush(ColorFromHex("#F5F5F5")), TextFont As New Font("Segoe UI", 9)
  828.                         G.DrawString(Text, TextFont, TextBrush, New Point(25, -1))
  829.                     End Using
  830.  
  831.             End Select
  832.  
  833.             If Checked Then
  834.  
  835.                 Using CheckBrush As New SolidBrush(ColorFromHex("#909090"))
  836.                     G.FillEllipse(CheckBrush, New Rectangle(5, 5, 6, 6))
  837.                 End Using
  838.  
  839.             End If
  840.  
  841.         Else
  842.  
  843.             Using Fill As New SolidBrush(ColorFromHex("#282828")), Border As New Pen(ColorFromHex("#484848"))
  844.                 G.FillEllipse(Fill, New Rectangle(0, 0, 16, 16))
  845.                 G.DrawEllipse(Border, New Rectangle(0, 0, 16, 16))
  846.             End Using
  847.  
  848.             Using TextBrush As New SolidBrush(ColorFromHex("#818181")), TextFont As New Font("Segoe UI", 9)
  849.                 G.DrawString(Text, TextFont, TextBrush, New Point(25, -1))
  850.             End Using
  851.  
  852.             If Checked Then
  853.  
  854.                 Using CheckBrush As New SolidBrush(ColorFromHex("#707070"))
  855.                     G.FillEllipse(CheckBrush, New Rectangle(5, 5, 6, 6))
  856.                 End Using
  857.  
  858.             End If
  859.  
  860.         End If
  861.  
  862.     End Sub
  863.  
  864.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  865.         State = MouseState.Over : Invalidate()
  866.         MyBase.OnMouseEnter(e)
  867.     End Sub
  868.  
  869.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  870.         State = MouseState.None : Invalidate()
  871.         MyBase.OnMouseLeave(e)
  872.     End Sub
  873.  
  874. End Class
  875.  
  876. Public Class BoosterNumericUpDown
  877.     Inherits NumericUpDown
  878.  
  879.     Private State As MouseState
  880.  
  881.     Public Property AfterValue As String
  882.  
  883.     Sub New()
  884.         DoubleBuffered = True
  885.         Font = New Font("Segoe UI", 10)
  886.         Controls(0).Hide()
  887.         Controls(1).Hide()
  888.         ForeColor = ColorFromHex("#B6B6B6")
  889.         SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque Or ControlStyles.OptimizedDoubleBuffer, True)
  890.     End Sub
  891.  
  892.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  893.  
  894.         G = e.Graphics
  895.         G.SmoothingMode = SmoothingMode.HighQuality
  896.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  897.  
  898.         G.Clear(Parent.BackColor)
  899.  
  900.         MyBase.OnPaint(e)
  901.  
  902.         If Enabled Then
  903.  
  904.             Using Fill As New SolidBrush(ColorFromHex("#242424"))
  905.                 G.FillRectangle(Fill, New Rectangle(0, 0, Width - 1, Height - 1))
  906.             End Using
  907.  
  908.             Select Case State
  909.  
  910.                 Case MouseState.None
  911.  
  912.                     Using Border As New Pen(ColorFromHex("#5C5C5C"))
  913.                         G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  914.                     End Using
  915.  
  916.                 Case MouseState.Over
  917.  
  918.                     Using Border As New Pen(ColorFromHex("#C8C8C8"))
  919.                         G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  920.                     End Using
  921.  
  922.             End Select
  923.  
  924.             Using TextBrush As New SolidBrush(ColorFromHex("#B6B6B6")), TextFont As New Font("Segoe UI", 10)
  925.                 G.DrawString(Value & AfterValue, TextFont, TextBrush, New Point(2, 2))
  926.             End Using
  927.  
  928.             Using ArrowFont As New Font("Marlett", 10), ArrowBrush As New SolidBrush(ColorFromHex("#909090"))
  929.                 G.DrawString("5", ArrowFont, ArrowBrush, New Point(Width - 18, 2))
  930.                 G.DrawString("6", ArrowFont, ArrowBrush, New Point(Width - 18, 10))
  931.             End Using
  932.  
  933.         Else
  934.  
  935.             Using Fill As New SolidBrush(ColorFromHex("#282828")), Border As New Pen(ColorFromHex("#484848"))
  936.                 G.FillRectangle(Fill, New Rectangle(0, 0, Width - 1, Height - 1))
  937.                 G.DrawRectangle(Border, New Rectangle(0, 0, Width - 1, Height - 1))
  938.             End Using
  939.  
  940.             Using TextBrush As New SolidBrush(ColorFromHex("#818181")), TextFont As New Font("Segoe UI", 10)
  941.                 G.DrawString(Value & AfterValue, TextFont, TextBrush, New Point(2, 2))
  942.             End Using
  943.  
  944.             Using ArrowFont As New Font("Marlett", 10), ArrowBrush As New SolidBrush(ColorFromHex("#707070"))
  945.                 G.DrawString("5", ArrowFont, ArrowBrush, New Point(Width - 18, 2))
  946.                 G.DrawString("6", ArrowFont, ArrowBrush, New Point(Width - 18, 10))
  947.             End Using
  948.  
  949.         End If
  950.  
  951.     End Sub
  952.  
  953.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  954.  
  955.         If e.X > Width - 16 AndAlso e.Y < 11 Then
  956.  
  957.             If Not Value + Increment > Maximum Then
  958.                 Value += Increment
  959.             Else
  960.                 Value = Maximum
  961.             End If
  962.  
  963.         ElseIf e.X > Width - 16 AndAlso e.Y > 13
  964.             If Not Value - Increment < Minimum Then
  965.                 Value -= Increment
  966.             Else
  967.                 Value = Minimum
  968.             End If
  969.         End If
  970.  
  971.         Invalidate()
  972.  
  973.         MyBase.OnMouseUp(e)
  974.     End Sub
  975.  
  976.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  977.         State = MouseState.Over : Invalidate()
  978.         MyBase.OnMouseEnter(e)
  979.     End Sub
  980.  
  981.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  982.         State = MouseState.None : Invalidate()
  983.         MyBase.OnMouseLeave(e)
  984.     End Sub
  985.  
  986. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement