Mystic Tema vb.net



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

Nenhum comentário

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();