Advertisement
Finessed

Bionic Theme

Jan 4th, 2016
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 21.74 KB | None | 0 0
  1. Imports System.Drawing
  2. Imports System.Drawing.Drawing2D
  3. Imports System.ComponentModel
  4. Imports System.Drawing.Text
  5.  
  6. ' Get more free themes at ThemesVB.NET
  7.  
  8. Enum MouseState
  9.     None = 0
  10.     Hover = 1
  11.     Down = 2
  12. End Enum
  13.  
  14. Class BionicTheme
  15.     Inherits ContainerControl
  16.  
  17. #Region " Declarations "
  18.     Private _Down As Boolean = False
  19.     Private _Header As Integer = 34
  20.     Private _MousePoint As Point
  21. #End Region
  22.  
  23. #Region " MouseStates "
  24.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  25.         MyBase.OnMouseUp(e)
  26.         _Down = False
  27.     End Sub
  28. ' Get more free themes at ThemesVB.NET
  29.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  30.         MyBase.OnMouseDown(e)
  31.         If e.Location.Y < _Header AndAlso e.Button = Windows.Forms.MouseButtons.Left Then
  32.             _Down = True
  33.             _MousePoint = e.Location
  34.         End If
  35.     End Sub
  36.  
  37.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  38.         MyBase.OnMouseMove(e)
  39.         If _Down = True Then
  40.             ParentForm.Location = MousePosition - _MousePoint
  41.         End If
  42.     End Sub
  43. #End Region
  44.  
  45.     Protected Overrides Sub OnCreateControl()
  46.         MyBase.OnCreateControl()
  47.         ParentForm.TransparencyKey = Color.Fuchsia
  48.         ParentForm.FormBorderStyle = FormBorderStyle.None
  49.         Dock = DockStyle.Fill
  50.         BackColor = Color.FromArgb(48, 48, 48)
  51.         Invalidate()
  52.     End Sub
  53.  
  54.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  55.         MyBase.OnPaint(e)
  56.         Dim G = e.Graphics
  57.         G.Clear(Color.FromArgb(29, 29, 29))
  58.         G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), New Rectangle(2, 2, Width - 4, 15))
  59.         G.FillRectangle(New SolidBrush(Color.FromArgb(48, 48, 48)), New Rectangle(2, 32, Width - 4, Height - 34))
  60.         Dim _StringF As New StringFormat
  61.         _StringF.Alignment = StringAlignment.Center
  62.         _StringF.LineAlignment = StringAlignment.Center
  63.         G.DrawString(FindForm.Text, New Font("Arial", 11), Brushes.White, New RectangleF(2, 2, Width - 4, 30), _StringF)
  64.     End Sub
  65.  
  66. End Class
  67.  
  68. Class BionicGroupBox
  69.     Inherits ContainerControl
  70.  
  71.     Sub New()
  72.         BackColor = Color.FromArgb(38, 38, 38)
  73.         Size = New Size(200, 100)
  74.     End Sub
  75.  
  76.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  77.         MyBase.OnPaint(e)
  78.         Dim G = e.Graphics
  79.         G.Clear(Color.FromArgb(38, 38, 38))
  80.         G.DrawString(Text, New Font("Arial", 9), Brushes.White, New Point(5, 5))
  81.     End Sub
  82.  
  83. End Class
  84.  
  85. Class BionicButton
  86.     Inherits Control
  87.  
  88. #Region " Declarations "
  89.     Private _State As MouseState = MouseState.None
  90. #End Region
  91. ' Get more free themes at ThemesVB.NET
  92. #Region " MouseStates "
  93.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  94.         MyBase.OnMouseEnter(e)
  95.         _State = MouseState.Hover
  96.         Invalidate()
  97.     End Sub
  98.  
  99.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  100.         MyBase.OnMouseLeave(e)
  101.         _State = MouseState.None
  102.         Invalidate()
  103.     End Sub
  104.  
  105.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  106.         MyBase.OnMouseDown(e)
  107.         _State = MouseState.Down
  108.         Invalidate()
  109.     End Sub
  110.  
  111.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  112.         MyBase.OnMouseUp(e)
  113.         _State = MouseState.Hover
  114.         Invalidate()
  115.     End Sub
  116. #End Region
  117.  
  118.     Sub New()
  119.         Size = New Size(90, 30)
  120.     End Sub
  121.  
  122.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  123.         MyBase.OnPaint(e)
  124.         Dim G = e.Graphics
  125.         G.Clear(Color.FromArgb(206, 145, 60))
  126.         G.FillRectangle(New LinearGradientBrush(New Point(1, 1), New Point(1, Height - 2), Color.FromArgb(252, 132, 19), Color.FromArgb(212, 75, 31)), New Rectangle(1, 1, Width - 2, Height - 2))
  127.  
  128.         Select Case _State
  129.             Case MouseState.Hover
  130.                 G.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), New Rectangle(1, 1, Width - 2, Height - 2))
  131.             Case MouseState.Down
  132.                 G.FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), New Rectangle(1, 1, Width - 2, Height - 2))
  133.         End Select
  134.  
  135.         Dim _StringF As New StringFormat
  136.         _StringF.Alignment = StringAlignment.Center
  137.         _StringF.LineAlignment = StringAlignment.Center
  138.         G.DrawString(Text, New Font("Arial", 9), Brushes.White, New RectangleF(0, 0, Width, Height), _StringF)
  139.     End Sub
  140.  
  141. End Class
  142.  
  143. <DefaultEvent("CheckedChanged")>
  144. Class BionicRadioButton
  145.     Inherits Control
  146.  
  147. #Region " Declarations "
  148.     Private _State As MouseState = MouseState.None
  149.     Private _Checked As Boolean
  150. #End Region
  151.  
  152. #Region " Properties "
  153.     Property Checked() As Boolean
  154.         Get
  155.             Return _Checked
  156.         End Get
  157.         Set(value As Boolean)
  158.             _Checked = value
  159.             InvalidateControls()
  160.             RaiseEvent CheckedChanged(Me)
  161.             Invalidate()
  162.         End Set
  163.     End Property
  164.     Event CheckedChanged(ByVal sender As Object)
  165.     Protected Overrides Sub OnClick(e As EventArgs)
  166.         If Not _Checked Then Checked = True
  167.         MyBase.OnClick(e)
  168.     End Sub
  169.     Private Sub InvalidateControls()
  170.         If Not IsHandleCreated OrElse Not _Checked Then Return
  171.         For Each C As Control In Parent.Controls
  172.             If C IsNot Me AndAlso TypeOf C Is BionicRadioButton Then
  173.                 DirectCast(C, BionicRadioButton).Checked = False
  174.                 Invalidate()
  175.             End If
  176.         Next
  177.     End Sub
  178.     Protected Overrides Sub OnCreateControl()
  179.         MyBase.OnCreateControl()
  180.         InvalidateControls()
  181.     End Sub
  182.  
  183.  
  184.     Protected Overrides Sub OnResize(e As EventArgs)
  185.         MyBase.OnResize(e)
  186.         Height = 16
  187.     End Sub
  188.  
  189. #Region " Mouse States"
  190.  
  191.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  192.         MyBase.OnMouseDown(e)
  193.         _State = MouseState.Down : Invalidate()
  194.     End Sub
  195.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  196.         MyBase.OnMouseUp(e)
  197.         _State = MouseState.Hover : Invalidate()
  198.     End Sub
  199.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  200.         MyBase.OnMouseEnter(e)
  201.         _State = MouseState.Hover : Invalidate()
  202.     End Sub
  203.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  204.         MyBase.OnMouseLeave(e)
  205.         _State = MouseState.None : Invalidate()
  206.     End Sub
  207.  
  208. #End Region
  209. #End Region
  210.  
  211.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  212.         MyBase.OnPaint(e)
  213.         Dim G = e.Graphics
  214.         G.SmoothingMode = 2
  215.         G.TextRenderingHint = 5
  216.         G.Clear(Parent.BackColor)
  217.  
  218.         G.FillEllipse(New SolidBrush(Color.FromArgb(29, 29, 29)), New Rectangle(0, 0, 15, 15))
  219.         Select Case _State
  220.             Case MouseState.Hover
  221.                 G.FillEllipse(New SolidBrush(Color.FromArgb(5, Color.White)), New Rectangle(0, 0, 15, 15))
  222.         End Select
  223.         If Checked Then
  224.             G.FillEllipse(New LinearGradientBrush(New Point(4, 4), New Point(4, 11), Color.FromArgb(252, 132, 19), Color.FromArgb(212, 75, 31)), New Rectangle(4, 4, 7, 7))
  225.         End If
  226.         G.DrawString(Text, New Font("Arial", 9), Brushes.White, New Point(18, 0))
  227.     End Sub
  228.  
  229. End Class
  230. ' Get more free themes at ThemesVB.NET
  231. <DefaultEvent("CheckedChanged")>
  232. Class BionicCheckBox
  233.     Inherits Control
  234.  
  235. #Region " Declarations "
  236.     Event CheckedChanged(ByVal sender As Object)
  237.     Private _State As MouseState = MouseState.None
  238.     Private _Checked As Boolean
  239. #End Region
  240.  
  241. #Region " Properties "
  242.     Public Property Checked() As Boolean
  243.         Get
  244.             Return _Checked
  245.         End Get
  246.         Set(ByVal value As Boolean)
  247.             _Checked = value
  248.             RaiseEvent CheckedChanged(Me)
  249.             Invalidate()
  250.         End Set
  251.     End Property
  252.     Protected Overrides Sub OnClick(e As EventArgs)
  253.         MyBase.OnClick(e)
  254.         If Not _Checked Then Checked = True
  255.     End Sub
  256.  
  257.     Protected Overrides Sub OnResize(e As EventArgs)
  258.         MyBase.OnResize(e)
  259.         Height = 16
  260.     End Sub
  261.  
  262. #End Region
  263.  
  264.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  265.         MyBase.OnPaint(e)
  266.         Dim G = e.Graphics
  267.         G.SmoothingMode = 2
  268.         G.TextRenderingHint = 5
  269.         G.Clear(Parent.BackColor)
  270.  
  271.         G.FillRectangle(New SolidBrush(Color.FromArgb(29, 29, 29)), New Rectangle(0, 0, 15, 15))
  272.         Select Case _State
  273.             Case MouseState.Hover
  274.                 G.FillRectangle(New SolidBrush(Color.FromArgb(5, Color.White)), New Rectangle(0, 0, 15, 15))
  275.         End Select
  276.         If Checked Then
  277.             G.FillRectangle(New LinearGradientBrush(New Point(4, 4), New Point(4, 11), Color.FromArgb(252, 132, 19), Color.FromArgb(212, 75, 31)), New Rectangle(4, 4, 7, 7))
  278.         End If
  279.         G.DrawString(Text, New Font("Arial", 9), Brushes.White, New Point(18, 0))
  280.     End Sub
  281.  
  282. End Class
  283.  
  284. Class BionicProgressBar
  285.     Inherits Control
  286.  
  287. #Region " Variables "
  288.  
  289.     Private _Value As Integer = 0
  290.     Private _Maximum As Integer = 100
  291.  
  292. #End Region
  293.  
  294. #Region " Control "
  295.     <Category("Control")>
  296.     Public Property Maximum() As Integer
  297.         Get
  298.             Return _Maximum
  299.         End Get
  300.         Set(V As Integer)
  301.             Select Case V
  302.                 Case Is < _Value
  303.                     _Value = V
  304.             End Select
  305.             _Maximum = V
  306.             Invalidate()
  307.         End Set
  308.     End Property
  309.  
  310.     <Category("Control")>
  311.     Public Property Value() As Integer
  312.         Get
  313.             Select Case _Value
  314.                 Case 0
  315.                     Return 0
  316.                     Invalidate()
  317.                 Case Else
  318.                     Return _Value
  319.                     Invalidate()
  320.             End Select
  321.         End Get
  322.         Set(V As Integer)
  323.             Select Case V
  324.                 Case Is > _Maximum
  325.                     V = _Maximum
  326.                     Invalidate()
  327.             End Select
  328.             _Value = V
  329.             Invalidate()
  330.         End Set
  331.     End Property
  332. #End Region
  333.  
  334. #Region " Events "
  335.     Public Sub Increment(ByVal Amount As Integer)
  336.         Value += Amount
  337.     End Sub
  338. #End Region
  339.  
  340.     Sub New()
  341.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  342.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  343.         DoubleBuffered = True
  344.     End Sub
  345.  
  346.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  347.         MyBase.OnPaint(e)
  348.         Dim G = e.Graphics
  349.  
  350.         G.Clear(Color.FromArgb(206, 145, 60))
  351.         Dim ProgVal As Integer = CInt(_Value / _Maximum * Width)
  352.         G.FillRectangle(New SolidBrush(Color.FromArgb(29, 29, 29)), New Rectangle(1, 1, Width - 2, Height - 2))
  353.         G.FillRectangle(New LinearGradientBrush(New Point(1, 1), New Point(1, Height - 1), Color.FromArgb(252, 132, 19), Color.FromArgb(212, 75, 31)), New Rectangle(1, 1, ProgVal - 2, Height - 2))
  354.         G.InterpolationMode = CType(7, InterpolationMode)
  355.  
  356.     End Sub
  357. End Class
  358.  
  359. <DefaultEvent("TextChanged")>
  360. Class BionicTextBox
  361.     Inherits Control
  362.  
  363. #Region " Variables"
  364.  
  365.     Private _State As MouseState = MouseState.None
  366.     Private WithEvents TB As Windows.Forms.TextBox
  367.  
  368. #End Region
  369.  
  370. #Region " Properties"
  371.  
  372.  
  373.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  374.     <Category("Options")> _
  375.     Property TextAlign() As HorizontalAlignment
  376.         Get
  377.             Return _TextAlign
  378.         End Get
  379.         Set(ByVal value As HorizontalAlignment)
  380.             _TextAlign = value
  381.             If TB IsNot Nothing Then
  382.                 TB.TextAlign = value
  383.             End If
  384.         End Set
  385.     End Property
  386.     Private _MaxLength As Integer = 32767
  387.     <Category("Options")> _
  388.     Property MaxLength() As Integer
  389.         Get
  390.             Return _MaxLength
  391.         End Get
  392.         Set(ByVal value As Integer)
  393.             _MaxLength = value
  394.             If TB IsNot Nothing Then
  395.                 TB.MaxLength = value
  396.             End If
  397.         End Set
  398.     End Property
  399.     Private _ReadOnly As Boolean
  400.     <Category("Options")> _
  401.     Property [ReadOnly]() As Boolean
  402.         Get
  403.             Return _ReadOnly
  404.         End Get
  405.         Set(ByVal value As Boolean)
  406.             _ReadOnly = value
  407.             If TB IsNot Nothing Then
  408.                 TB.ReadOnly = value
  409.             End If
  410.         End Set
  411.     End Property
  412.     Private _UseSystemPasswordChar As Boolean
  413.     <Category("Options")> _
  414.     Property UseSystemPasswordChar() As Boolean
  415.         Get
  416.             Return _UseSystemPasswordChar
  417.         End Get
  418.         Set(ByVal value As Boolean)
  419.             _UseSystemPasswordChar = value
  420.             If TB IsNot Nothing Then
  421.                 TB.UseSystemPasswordChar = value
  422.             End If
  423.         End Set
  424.     End Property
  425.     Private _Multiline As Boolean
  426.     <Category("Options")> _
  427.     Property Multiline() As Boolean
  428.         Get
  429.             Return _Multiline
  430.         End Get
  431.         Set(ByVal value As Boolean)
  432.             _Multiline = value
  433.             If TB IsNot Nothing Then
  434.                 TB.Multiline = value
  435.  
  436.                 If value Then
  437.                     TB.Height = Height - 11
  438.                 Else
  439.                     Height = TB.Height + 11
  440.                 End If
  441.  
  442.             End If
  443.         End Set
  444.     End Property
  445.     <Category("Options")> _
  446.     Overrides Property Text As String
  447.         Get
  448.             Return MyBase.Text
  449.         End Get
  450.         Set(ByVal value As String)
  451.             MyBase.Text = value
  452.             If TB IsNot Nothing Then
  453.                 TB.Text = value
  454.             End If
  455.         End Set
  456.     End Property
  457.     <Category("Options")> _
  458.     Overrides Property Font As Font
  459.         Get
  460.             Return MyBase.Font
  461.         End Get
  462.         Set(ByVal value As Font)
  463.             MyBase.Font = value
  464.             If TB IsNot Nothing Then
  465.                 TB.Font = value
  466.                 TB.Location = New Point(3, 5)
  467.                 TB.Width = Width - 6
  468.  
  469.                 If Not _Multiline Then
  470.                     Height = TB.Height + 11
  471.                 End If
  472.             End If
  473.         End Set
  474.     End Property
  475.  
  476.     Protected Overrides Sub OnCreateControl()
  477.         MyBase.OnCreateControl()
  478.         If Not Controls.Contains(TB) Then
  479.             Controls.Add(TB)
  480.         End If
  481.     End Sub
  482.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  483.         Text = TB.Text
  484.     End Sub
  485.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  486.         If e.Control AndAlso e.KeyCode = Keys.A Then
  487.             TB.SelectAll()
  488.             e.SuppressKeyPress = True
  489.         End If
  490.         If e.Control AndAlso e.KeyCode = Keys.C Then
  491.             TB.Copy()
  492.             e.SuppressKeyPress = True
  493.         End If
  494.     End Sub
  495.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  496.         TB.Location = New Point(5, 5)
  497.         TB.Width = Width - 10
  498.  
  499.         If _Multiline Then
  500.             TB.Height = Height - 11
  501.         Else
  502.             Height = TB.Height + 11
  503.         End If
  504.  
  505.         MyBase.OnResize(e)
  506.     End Sub
  507.  
  508. #End Region
  509.  
  510. #Region " Mouse States"
  511.  
  512.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  513.         MyBase.OnMouseDown(e)
  514.         _State = MouseState.Down : Invalidate()
  515.     End Sub
  516.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  517.         MyBase.OnMouseUp(e)
  518.         _State = MouseState.Hover : TB.Focus() : Invalidate()
  519.     End Sub
  520.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  521.         MyBase.OnMouseEnter(e)
  522.         _State = MouseState.Hover : TB.Focus() : Invalidate()
  523.     End Sub
  524.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  525.         MyBase.OnMouseLeave(e)
  526.         _State = MouseState.None : Invalidate()
  527.     End Sub
  528.  
  529. #End Region
  530.  
  531.  
  532.     Sub New()
  533.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  534.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  535.                  ControlStyles.SupportsTransparentBackColor, True)
  536.         DoubleBuffered = True
  537.  
  538.         BackColor = Color.Transparent
  539.  
  540.         TB = New Windows.Forms.TextBox
  541.         TB.Font = New Font("Arial", 9)
  542.         TB.Text = Text
  543.         TB.BackColor = Color.FromArgb(29, 29, 29)
  544.         TB.ForeColor = Color.White
  545.         TB.MaxLength = _MaxLength
  546.         TB.Multiline = _Multiline
  547.         TB.ReadOnly = _ReadOnly
  548.         TB.UseSystemPasswordChar = _UseSystemPasswordChar
  549.         TB.BorderStyle = BorderStyle.None
  550.         TB.Location = New Point(5, 5)
  551.         TB.Width = Width - 10
  552.  
  553.         TB.Cursor = Cursors.IBeam
  554.  
  555.         If _Multiline Then
  556.             TB.Height = Height - 11
  557.         Else
  558.             Height = TB.Height + 11
  559.         End If
  560.  
  561.         AddHandler TB.TextChanged, AddressOf OnBaseTextChanged
  562.         AddHandler TB.KeyDown, AddressOf OnBaseKeyDown
  563.     End Sub
  564.  
  565.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  566.         MyBase.OnPaint(e)
  567.         Dim G = e.Graphics
  568.         G.Clear(Color.FromArgb(29, 29, 29))
  569.         G.DrawRectangle(New Pen(Color.FromArgb(206, 145, 60)), New Rectangle(0, 0, Width - 1, Height - 1))
  570.     End Sub
  571.  
  572. End Class
  573.  
  574. Class BionicClose
  575.     Inherits Control
  576.  
  577. #Region " Declarations "
  578.     Private _State As MouseState
  579. #End Region
  580.  
  581. #Region " MouseStates "
  582.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  583.         MyBase.OnMouseEnter(e)
  584.         _State = MouseState.Hover
  585.         Invalidate()
  586.     End Sub
  587.  
  588.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  589.         MyBase.OnMouseLeave(e)
  590.         _State = MouseState.None
  591.         Invalidate()
  592.     End Sub
  593.  
  594.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  595.         MyBase.OnMouseDown(e)
  596.         _State = MouseState.Down
  597.         Invalidate()
  598.     End Sub
  599.  
  600.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  601.         MyBase.OnMouseUp(e)
  602.         _State = MouseState.Hover
  603.         Invalidate()
  604.     End Sub
  605.  
  606.     Protected Overrides Sub OnClick(e As EventArgs)
  607.         MyBase.OnClick(e)
  608.         Environment.Exit(0)
  609.     End Sub
  610. #End Region
  611. ' Get more free themes at ThemesVB.NET
  612.     Protected Overrides Sub OnResize(e As EventArgs)
  613.         MyBase.OnResize(e)
  614.         Size = New Size(12, 12)
  615.     End Sub
  616.  
  617.     Sub New()
  618.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  619.                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  620.         DoubleBuffered = True
  621.  
  622.         Size = New Size(12, 12)
  623.     End Sub
  624.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  625.         MyBase.OnPaint(e)
  626.         Dim G = e.Graphics
  627.  
  628.         G.Clear(Color.FromArgb(38, 38, 38))
  629.         G.FillRectangle(New SolidBrush(Color.FromArgb(29, 29, 29)), New Rectangle(0, Height / 2, Width, Height / 2))
  630.  
  631.  
  632.         Dim _StringF As New StringFormat
  633.         _StringF.Alignment = StringAlignment.Center
  634.         _StringF.LineAlignment = StringAlignment.Center
  635.  
  636.         G.DrawString("r", New Font("Marlett", 11), Brushes.White, New RectangleF(0, 0, Width, Height), _StringF)
  637.  
  638.         Select Case _State
  639.             Case MouseState.Hover
  640.                 G.DrawString("r", New Font("Marlett", 11), New SolidBrush(Color.FromArgb(25, Color.White)), New RectangleF(0, 0, Width, Height), _StringF)
  641.  
  642.             Case MouseState.Down
  643.                 G.DrawString("r", New Font("Marlett", 11), New SolidBrush(Color.FromArgb(40, Color.Black)), New RectangleF(0, 0, Width, Height), _StringF)
  644.  
  645.         End Select
  646.  
  647.     End Sub
  648.  
  649. End Class
  650.  
  651. Class BionicMini
  652.     Inherits Control
  653.  
  654. #Region " Declarations "
  655.     Private _State As MouseState
  656. #End Region
  657.  
  658. #Region " MouseStates "
  659.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  660.         MyBase.OnMouseEnter(e)
  661.         _State = MouseState.Hover
  662.         Invalidate()
  663.     End Sub
  664.  
  665.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  666.         MyBase.OnMouseLeave(e)
  667.         _State = MouseState.None
  668.         Invalidate()
  669.     End Sub
  670.  
  671.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  672.         MyBase.OnMouseDown(e)
  673.         _State = MouseState.Down
  674.         Invalidate()
  675.     End Sub
  676.  
  677.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  678.         MyBase.OnMouseUp(e)
  679.         _State = MouseState.Hover
  680.         Invalidate()
  681.     End Sub
  682.  
  683.     Protected Overrides Sub OnClick(e As EventArgs)
  684.         MyBase.OnClick(e)
  685.         FindForm.WindowState = FormWindowState.Minimized
  686.     End Sub
  687. #End Region
  688.  
  689.     Protected Overrides Sub OnResize(e As EventArgs)
  690.         MyBase.OnResize(e)
  691.         Size = New Size(12, 12)
  692.     End Sub
  693. ' Get more free themes at ThemesVB.NET
  694.     Sub New()
  695.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  696.                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
  697.         DoubleBuffered = True
  698.         Size = New Size(12, 12)
  699.     End Sub
  700.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  701.         MyBase.OnPaint(e)
  702.         Dim G = e.Graphics
  703.         G.Clear(Color.FromArgb(38, 38, 38))
  704.  
  705.         G.FillRectangle(New SolidBrush(Color.FromArgb(29, 29, 29)), New Rectangle(0, Height / 2, Width, Height / 2))
  706.  
  707.         Dim _StringF As New StringFormat
  708.         _StringF.Alignment = StringAlignment.Center
  709.         _StringF.LineAlignment = StringAlignment.Center
  710.  
  711.         G.DrawString("0", New Font("Marlett", 11), Brushes.White, New RectangleF(0, 0, Width, Height), _StringF)
  712.  
  713.         Select Case _State
  714.             Case MouseState.Hover
  715.                 G.DrawString("0", New Font("Marlett", 11), New SolidBrush(Color.FromArgb(25, Color.White)), New RectangleF(0, 0, Width, Height), _StringF)
  716.  
  717.             Case MouseState.Down
  718.                 G.DrawString("0", New Font("Marlett", 11), New SolidBrush(Color.FromArgb(40, Color.Black)), New RectangleF(0, 0, Width, Height), _StringF)
  719.  
  720.         End Select
  721.  
  722.      
  723.     End Sub
  724.  
  725. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement