Advertisement
Finessed

Element Theme

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