Advertisement
Finessed

Hex Theme

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