Advertisement
Finessed

Angel Theme

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