SqLasticSoftware

Aether Theme

Jul 28th, 2017
616
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 33.52 KB | None | 0 0
  1. Module Helpers
  2.  
  3.     Public Enum MouseState As Byte
  4.         None = 0
  5.         Over = 1
  6.         Down = 2
  7.     End Enum
  8.  
  9.     Public Function FullRectangle(S As Size, Subtract As Boolean) As Rectangle
  10.         If Subtract Then
  11.             Return New Rectangle(0, 0, S.Width - 1, S.Height - 1)
  12.         Else
  13.             Return New Rectangle(0, 0, S.Width, S.Height)
  14.         End If
  15.     End Function
  16.  
  17.     Public Function GreyColor(G As UInteger) As Color
  18.         Return Color.FromArgb(G, G, G)
  19.     End Function
  20.  
  21.     Public Sub CenterString(G As Graphics, T As String, F As Font, C As Color, R As Rectangle)
  22.         Dim TS As SizeF = G.MeasureString(T, F)
  23.  
  24.         Using B As New SolidBrush(C)
  25.             G.DrawString(T, F, B, New Point(R.Width / 2 - (TS.Width / 2), R.Height / 2 - (TS.Height / 2)))
  26.         End Using
  27.  
  28.     End Sub
  29.  
  30.     Public Sub FillRoundRect(G As Graphics, R As Rectangle, Curve As Integer, B As Brush)
  31.         G.FillPie(B, R.X, R.Y, Curve, Curve, 180, 90)
  32.         G.FillPie(B, R.X + R.Width - Curve, R.Y, Curve, Curve, 270, 90)
  33.         G.FillPie(B, R.X, R.Y + R.Height - Curve, Curve, Curve, 90, 90)
  34.         G.FillPie(B, R.X + R.Width - Curve, R.Y + R.Height - Curve, Curve, Curve, 0, 90)
  35.         G.FillRectangle(B, CInt(R.X + Curve / 2), R.Y, R.Width - Curve, CInt(Curve / 2))
  36.         G.FillRectangle(B, R.X, CInt(R.Y + Curve / 2), R.Width, R.Height - Curve)
  37.         G.FillRectangle(B, CInt(R.X + Curve / 2), CInt(R.Y + R.Height - Curve / 2), R.Width - Curve, CInt(Curve / 2))
  38.     End Sub
  39.  
  40.     Public Sub DrawRoundRect(G As Graphics, R As Rectangle, Curve As Integer, PP As Pen)
  41.         G.DrawArc(PP, R.X, R.Y, Curve, Curve, 180, 90)
  42.         G.DrawLine(PP, CInt(R.X + Curve / 2), R.Y, CInt(R.X + R.Width - Curve / 2), R.Y)
  43.         G.DrawArc(PP, R.X + R.Width - Curve, R.Y, Curve, Curve, 270, 90)
  44.         G.DrawLine(PP, R.X, CInt(R.Y + Curve / 2), R.X, CInt(R.Y + R.Height - Curve / 2))
  45.         G.DrawLine(PP, CInt(R.X + R.Width), CInt(R.Y + Curve / 2), CInt(R.X + R.Width), CInt(R.Y + R.Height - Curve / 2))
  46.         G.DrawLine(PP, CInt(R.X + Curve / 2), CInt(R.Y + R.Height), CInt(R.X + R.Width - Curve / 2), CInt(R.Y + R.Height))
  47.         G.DrawArc(PP, R.X, R.Y + R.Height - Curve, Curve, Curve, 90, 90)
  48.         G.DrawArc(PP, R.X + R.Width - Curve, R.Y + R.Height - Curve, Curve, Curve, 0, 90)
  49.     End Sub
  50.  
  51.     Public Enum Direction As Byte
  52.         Up = 0
  53.         Down = 1
  54.         Left = 2
  55.         Right = 3
  56.     End Enum
  57.  
  58.     Public Sub DrawTriangle(G As Graphics, Rect As Rectangle, D As Direction, C As Color)
  59.         Dim halfWidth As Integer = Rect.Width / 2
  60.         Dim halfHeight As Integer = Rect.Height / 2
  61.         Dim p0 As Point = Point.Empty
  62.         Dim p1 As Point = Point.Empty
  63.         Dim p2 As Point = Point.Empty
  64.  
  65.         Select Case D
  66.             Case Direction.Up
  67.                 p0 = New Point(Rect.Left + halfWidth, Rect.Top)
  68.                 p1 = New Point(Rect.Left, Rect.Bottom)
  69.                 p2 = New Point(Rect.Right, Rect.Bottom)
  70.  
  71.             Case Direction.Down
  72.                 p0 = New Point(Rect.Left + halfWidth, Rect.Bottom)
  73.                 p1 = New Point(Rect.Left, Rect.Top)
  74.                 p2 = New Point(Rect.Right, Rect.Top)
  75.  
  76.             Case Direction.Left
  77.                 p0 = New Point(Rect.Left, Rect.Top + halfHeight)
  78.                 p1 = New Point(Rect.Right, Rect.Top)
  79.                 p2 = New Point(Rect.Right, Rect.Bottom)
  80.  
  81.             Case Direction.Right
  82.                 p0 = New Point(Rect.Right, Rect.Top + halfHeight)
  83.                 p1 = New Point(Rect.Left, Rect.Bottom)
  84.                 p2 = New Point(Rect.Left, Rect.Top)
  85.  
  86.         End Select
  87.  
  88.         Using B As New SolidBrush(C)
  89.             G.FillPolygon(B, New Point() {p0, p1, p2})
  90.         End Using
  91.  
  92.     End Sub
  93.  
  94.     Public Function ColorFromHex(Hex As String) As Color
  95.         Dim R, G, B As String
  96.         Hex = Replace(Hex, "#", "")
  97.         R = Val("&H" & Mid(Hex, 1, 2))
  98.         G = Val("&H" & Mid(Hex, 3, 2))
  99.         B = Val("&H" & Mid(Hex, 5, 2))
  100.         Return Color.FromArgb(R, G, B)
  101.     End Function
  102.  
  103. End Module
  104.  
  105. Public Class AetherTabControl
  106.     Inherits TabControl
  107.  
  108.     Private G As Graphics
  109.     Private Rect As Rectangle
  110.     Private MS1 As SizeF
  111.     Private MS2 As SizeF
  112.  
  113.     Public Property UpperText As Boolean = True
  114.  
  115.     Sub New()
  116.         DoubleBuffered = True
  117.         Alignment = TabAlignment.Left
  118.         SizeMode = TabSizeMode.Fixed
  119.         ItemSize = New Size(40, 190)
  120.         Dock = DockStyle.Fill
  121.     End Sub
  122.  
  123.     Protected Overrides Sub OnCreateControl()
  124.         MyBase.OnCreateControl()
  125.         SetStyle(ControlStyles.UserPaint, True)
  126.     End Sub
  127.  
  128.     Protected Overrides Sub OnControlAdded(e As ControlEventArgs)
  129.         MyBase.OnControlAdded(e)
  130.         e.Control.BackColor = Color.White
  131.         e.Control.ForeColor = ColorFromHex("#343843")
  132.  
  133.         Using F1 As New Font("Segoe UI", 9)
  134.             e.Control.Font = F1
  135.         End Using
  136.  
  137.     End Sub
  138.  
  139.     Protected Overrides ReadOnly Property CreateParams() As CreateParams
  140.         Get
  141.             Dim cp As CreateParams = MyBase.CreateParams
  142.             cp.ExStyle = cp.ExStyle Or &H2000000
  143.             Return cp
  144.         End Get
  145.     End Property
  146.  
  147.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  148.  
  149.         G = e.Graphics
  150.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  151.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  152.  
  153.         MyBase.OnPaint(e)
  154.  
  155.         G.Clear(ColorFromHex("#343843"))
  156.  
  157.         For I As Integer = 0 To TabPages.Count - 1
  158.  
  159.             Rect = GetTabRect(I)
  160.  
  161.             If SelectedIndex = I Then
  162.  
  163.                 Using B1 As New SolidBrush(ColorFromHex("#3A3E49"))
  164.                     G.FillRectangle(B1, New Rectangle(Rect.X - 4, Rect.Y + 1, Rect.Width + 6, Rect.Height))
  165.                 End Using
  166.  
  167.             End If
  168.  
  169.             Using B1 As New SolidBrush(ColorFromHex("#737A8A"))
  170.  
  171.                 If UpperText Then
  172.  
  173.                     Using F1 As New Font("Segoe UI", 7.75, FontStyle.Bold)
  174.                         G.DrawString(TabPages(I).Text.ToUpper, F1, B1, New Point(Rect.X + 50, Rect.Y + 13))
  175.                     End Using
  176.  
  177.                 Else
  178.  
  179.                     Using F1 As New Font("Segoe UI semibold", 9)
  180.                         G.DrawString(TabPages(I).Text, F1, B1, New Point(Rect.X + 50, Rect.Y + 11))
  181.                     End Using
  182.  
  183.                 End If
  184.  
  185.             End Using
  186.  
  187.             If Not String.IsNullOrEmpty(TabPages(I).Tag) Then
  188.  
  189.                 If UpperText Then
  190.  
  191.                     Using F1 As New Font("Segoe UI", 7.75, FontStyle.Bold)
  192.                         MS1 = G.MeasureString(TabPages(I).Text, F1)
  193.                     End Using
  194.  
  195.                 Else
  196.  
  197.                     Using F1 As New Font("Segoe UI semibold", 9)
  198.                         MS1 = G.MeasureString(TabPages(I).Text, F1)
  199.                     End Using
  200.  
  201.                 End If
  202.  
  203.                 Using F1 As New Font("Segoe UI", 9)
  204.                     MS2 = G.MeasureString(TabPages(I).Tag, F1)
  205.                 End Using
  206.  
  207.                 Using B1 As New SolidBrush(ColorFromHex("#424452")), P1 As New Pen(ColorFromHex("#323541")), B2 As New SolidBrush(ColorFromHex("#737A8A"))
  208.                     G.FillRectangle(B1, New Rectangle(Rect.X + MS1.Width + 72, Rect.Y + 13, MS2.Width + 5, 15))
  209.                     DrawRoundRect(G, New Rectangle(Rect.X + MS1.Width + 72, Rect.Y + 13, MS2.Width + 5, 15), 3, P1)
  210.  
  211.                     If IsNumeric(TabPages(I).Tag) Then
  212.  
  213.                         Using F1 As New Font("Segoe UI", 8, FontStyle.Bold)
  214.                             G.DrawString(TabPages(I).Tag, F1, B2, New Point(Rect.X + MS1.Width + 75, Rect.Y + 14))
  215.                         End Using
  216.  
  217.                     Else
  218.  
  219.                         Using F1 As New Font("Segoe UI", 7, FontStyle.Bold)
  220.                             G.DrawString(TabPages(I).Tag.ToString.ToUpper, F1, B2, New Point(Rect.X + MS1.Width + 75, Rect.Y + 14))
  221.                         End Using
  222.  
  223.                     End If
  224.  
  225.                 End Using
  226.  
  227.             End If
  228.  
  229.             If Not I = 0 Then
  230.  
  231.                 Using P1 As New Pen(ColorFromHex("#3B3D49")), P2 As New Pen(ColorFromHex("#2F323C"))
  232.                     G.DrawLine(P1, New Point(Rect.X - 4, Rect.Y + 1), New Point(Rect.Width + 4, Rect.Y + 1))
  233.                     G.DrawLine(P2, New Point(Rect.X - 4, Rect.Y + 2), New Point(Rect.Width + 4, Rect.Y + 2))
  234.                 End Using
  235.  
  236.             End If
  237.  
  238.             If Not IsNothing(ImageList) Then
  239.                 If Not TabPages(I).ImageIndex < 0 Then
  240.                     G.DrawImage(ImageList.Images(TabPages(I).ImageIndex), New Rectangle(Rect.X + 18, Rect.Y + ((Rect.Height / 2) - 8), 16, 16))
  241.                 End If
  242.             End If
  243.  
  244.         Next
  245.  
  246.     End Sub
  247.  
  248. End Class
  249.  
  250. Public Class AetherCircular
  251.     Inherits Control
  252.  
  253.     Private G As Graphics
  254.     Private ProgressAngle As Single
  255.     Private RemainderAngle As Single
  256.     Private ExceedingLimits As Boolean
  257.     Private ExceedingSign As String
  258.  
  259.     Private _Progress As Single
  260.     Private _Max As Single = 100
  261.     Private _Min As Single = 0
  262.  
  263.     Public Property Percent As Boolean = True
  264.  
  265.  
  266.     Public Property Progress As Single
  267.         Get
  268.             Return _Progress
  269.         End Get
  270.         Set(value As Single)
  271.             Select Case value
  272.                 Case Is > Max
  273.                     value = Max
  274.                     ExceedingSign = "+"
  275.                     ExceedingLimits = True
  276.                     Invalidate()
  277.  
  278.                 Case Is < Min
  279.                     value = Min
  280.                     ExceedingSign = "-"
  281.                     ExceedingLimits = True
  282.                     Invalidate()
  283.             End Select
  284.             _Progress = value
  285.             Invalidate()
  286.         End Set
  287.     End Property
  288.  
  289.     Public Property Max As Single
  290.         Get
  291.             Return _Max
  292.         End Get
  293.         Set(value As Single)
  294.             Select Case value
  295.                 Case Is < _Progress
  296.                     _Progress = value
  297.             End Select
  298.             _Max = value
  299.             Invalidate()
  300.         End Set
  301.     End Property
  302.  
  303.     Public Property Min As Single
  304.         Get
  305.             Return _Min
  306.         End Get
  307.         Set(value As Single)
  308.             Select Case value
  309.                 Case Is > _Progress
  310.                     _Progress = value
  311.             End Select
  312.             _Min = value
  313.             Invalidate()
  314.         End Set
  315.     End Property
  316.  
  317.     Public Property Border As Color = Color.LightGray
  318.     Public Property HatchPrimary As Color = Color.Green
  319.     Public Property HatchSecondary As Color = Color.Red
  320.  
  321.     Sub New()
  322.         DoubleBuffered = True
  323.     End Sub
  324.  
  325.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  326.  
  327.         G = e.Graphics
  328.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  329.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  330.  
  331.         MyBase.OnPaint(e)
  332.  
  333.         ProgressAngle = 360 / Max * Progress
  334.         RemainderAngle = 360 - ProgressAngle
  335.  
  336.         Using P1 As New Pen(New Drawing2D.HatchBrush(Drawing2D.HatchStyle.LightUpwardDiagonal, HatchPrimary, HatchSecondary), 4), P2 As New Pen(Border, 4)
  337.             G.DrawArc(P1, New Rectangle(2, 2, Width - 5, Height - 5), -90, ProgressAngle)
  338.             G.DrawArc(P2, New Rectangle(2, 2, Width - 5, Height - 5), ProgressAngle - 90, RemainderAngle)
  339.         End Using
  340.  
  341.         If Percent Then
  342.  
  343.             Using F1 As New Font("Segoe UI", 9, FontStyle.Bold)
  344.  
  345.                 If ExceedingLimits Then
  346.                     CenterString(G, Progress & "%" & ExceedingSign, F1, Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  347.                 Else
  348.                     CenterString(G, Progress & "%", F1, Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  349.                 End If
  350.  
  351.             End Using
  352.  
  353.         Else
  354.  
  355.             If ExceedingLimits Then
  356.                 CenterString(G, Progress & ExceedingSign, New Font("Segoe UI", 9, FontStyle.Bold), Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  357.             Else
  358.                 CenterString(G, Progress, New Font("Segoe UI", 9, FontStyle.Bold), Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  359.             End If
  360.  
  361.         End If
  362.  
  363.         ExceedingLimits = False
  364.  
  365.         CenterString(G, Text.ToUpper, New Font("Segoe UI", 6, FontStyle.Bold), Color.FromArgb(170, 170, 170), New Rectangle(2, 2, Width, Height + 27))
  366.  
  367.     End Sub
  368.  
  369. End Class
  370.  
  371. <ComponentModel.DefaultEvent("CheckedChanged")>
  372. Public Class AetherCheckBox
  373.     Inherits Control
  374.  
  375.     Public Event CheckedChanged(sender As Object, e As EventArgs)
  376.  
  377.     Private _Checked As Boolean
  378.     Private _EnabledCalc As Boolean
  379.     Private G As Graphics
  380.  
  381.     Private State As MouseState
  382.  
  383.     Public Property Checked As Boolean
  384.         Get
  385.             Return _Checked
  386.         End Get
  387.         Set(value As Boolean)
  388.             _Checked = value
  389.             Invalidate()
  390.         End Set
  391.     End Property
  392.  
  393.     Public Shadows Property Enabled As Boolean
  394.         Get
  395.             Return EnabledCalc
  396.         End Get
  397.         Set(value As Boolean)
  398.             _EnabledCalc = value
  399.  
  400.             If Enabled Then
  401.                 Cursor = Cursors.Hand
  402.             Else
  403.                 Cursor = Cursors.Default
  404.             End If
  405.  
  406.             Invalidate()
  407.         End Set
  408.     End Property
  409.  
  410.     <ComponentModel.DisplayName("Enabled")>
  411.     Public Property EnabledCalc As Boolean
  412.         Get
  413.             Return _EnabledCalc
  414.         End Get
  415.         Set(value As Boolean)
  416.             Enabled = value
  417.             Invalidate()
  418.         End Set
  419.     End Property
  420.  
  421.     Sub New()
  422.         DoubleBuffered = True
  423.         Enabled = True
  424.         Cursor = Cursors.Hand
  425.     End Sub
  426.  
  427.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  428.         G = e.Graphics
  429.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  430.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  431.  
  432.         MyBase.OnPaint(e)
  433.  
  434.         If Enabled Then
  435.  
  436.             Using P1 As New Pen(ColorFromHex("#D2D2D2")), B1 As New SolidBrush(ColorFromHex("#343843")), F1 As New Font("Segoe UI", 9)
  437.                 DrawRoundRect(G, New Rectangle(0, 0, 18, 18), 6, P1)
  438.                 G.DrawString(Text, F1, B1, New Point(25, 1))
  439.             End Using
  440.  
  441.             If State = MouseState.Over Or State = MouseState.Down Then
  442.  
  443.                 Using P1 As New Pen(ColorFromHex("#8C92A1"))
  444.                     DrawRoundRect(G, New Rectangle(0, 0, 18, 18), 6, P1)
  445.                 End Using
  446.  
  447.             End If
  448.  
  449.         Else
  450.  
  451.             Using P1 As New Pen(ColorFromHex("#DCDCDC")), B1 As New SolidBrush(ColorFromHex("#989CA7")), F1 As New Font("Segoe UI", 9)
  452.                 DrawRoundRect(G, New Rectangle(0, 0, 18, 18), 6, P1)
  453.                 G.DrawString(Text, F1, B1, New Point(25, 1))
  454.             End Using
  455.  
  456.         End If
  457.  
  458.         If Checked Then
  459.  
  460.             If Enabled Then
  461.  
  462.                 Using B1 As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.WideUpwardDiagonal, ColorFromHex("#5B606F"), ColorFromHex("#525766")), P1 As New Pen(ColorFromHex("#474C5A"))
  463.                     G.FillRectangle(B1, New Rectangle(4, 4, 10, 10))
  464.                     DrawRoundRect(G, New Rectangle(4, 4, 10, 10), 3, P1)
  465.                 End Using
  466.  
  467.             Else
  468.  
  469.                 Using B1 As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.WideUpwardDiagonal, ColorFromHex("#8C92A1"), ColorFromHex("#7A7F8E")), P1 As New Pen(ColorFromHex("#797E8C"))
  470.                     G.FillRectangle(B1, New Rectangle(4, 4, 10, 10))
  471.                     DrawRoundRect(G, New Rectangle(4, 4, 10, 10), 3, P1)
  472.                 End Using
  473.  
  474.             End If
  475.  
  476.  
  477.         End If
  478.  
  479.     End Sub
  480.  
  481.     Protected Overrides Sub OnResize(e As EventArgs)
  482.         MyBase.OnResize(e)
  483.         Size = New Size(Width, 19)
  484.     End Sub
  485.  
  486.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  487.         MyBase.OnMouseUp(e)
  488.  
  489.         If Enabled Then
  490.             State = MouseState.Over
  491.             Checked = Not Checked
  492.             RaiseEvent CheckedChanged(Me, e)
  493.             Invalidate()
  494.         End If
  495.  
  496.     End Sub
  497.  
  498.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  499.         MyBase.OnMouseDown(e)
  500.         If Enabled Then
  501.             State = MouseState.Down : Invalidate()
  502.         End If
  503.     End Sub
  504.  
  505.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  506.         MyBase.OnMouseEnter(e)
  507.         If Enabled Then
  508.             State = MouseState.Over : Invalidate()
  509.         End If
  510.     End Sub
  511.  
  512.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  513.         MyBase.OnMouseLeave(e)
  514.         If Enabled Then
  515.             State = MouseState.None : Invalidate()
  516.         End If
  517.     End Sub
  518.  
  519. End Class
  520.  
  521. <ComponentModel.DefaultEvent("CheckedChanged")>
  522. Public Class AetherRadioButton
  523.     Inherits Control
  524.  
  525.     Public Event CheckedChanged(sender As Object, e As EventArgs)
  526.  
  527.     Private G As Graphics
  528.     Private State As MouseState
  529.  
  530.     Private _Checked As Boolean
  531.     Private _EnabledCalc As Boolean
  532.  
  533.     Sub New()
  534.         DoubleBuffered = True
  535.         Enabled = True
  536.         Cursor = Cursors.Hand
  537.     End Sub
  538.  
  539.     Public Property Checked As Boolean
  540.         Get
  541.             Return _Checked
  542.         End Get
  543.         Set(value As Boolean)
  544.             _Checked = value
  545.             Invalidate()
  546.         End Set
  547.     End Property
  548.  
  549.     Public Shadows Property Enabled As Boolean
  550.         Get
  551.             Return EnabledCalc
  552.         End Get
  553.         Set(value As Boolean)
  554.             _EnabledCalc = value
  555.  
  556.             If Enabled Then
  557.                 Cursor = Cursors.Hand
  558.             Else
  559.                 Cursor = Cursors.Default
  560.             End If
  561.  
  562.             Invalidate()
  563.         End Set
  564.     End Property
  565.  
  566.     <ComponentModel.DisplayName("Enabled")>
  567.     Public Property EnabledCalc As Boolean
  568.         Get
  569.             Return _EnabledCalc
  570.         End Get
  571.         Set(value As Boolean)
  572.             Enabled = value
  573.             Invalidate()
  574.         End Set
  575.     End Property
  576.  
  577.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  578.  
  579.         G = e.Graphics
  580.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  581.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  582.  
  583.         MyBase.OnPaint(e)
  584.  
  585.         If Enabled Then
  586.  
  587.             Using P As New Pen(ColorFromHex("#C8C8C8"))
  588.                 G.DrawEllipse(P, New Rectangle(0, 0, 18, 18))
  589.             End Using
  590.  
  591.             Using B As New SolidBrush(ColorFromHex("#343843"))
  592.                 G.DrawString(Text, New Font("Segoe UI", 9), B, New Point(25, 1))
  593.             End Using
  594.  
  595.             If State = MouseState.Over Or State = MouseState.Down Then
  596.  
  597.                 Using P1 As New Pen(ColorFromHex("#8C92A1"))
  598.                     G.DrawEllipse(P1, New Rectangle(0, 0, 18, 18))
  599.                 End Using
  600.  
  601.             End If
  602.  
  603.         Else
  604.  
  605.             Using P As New Pen(ColorFromHex("#DCDCDC"))
  606.                 G.DrawEllipse(P, New Rectangle(0, 0, 18, 18))
  607.             End Using
  608.  
  609.             Using B As New SolidBrush(ColorFromHex("#989CA7"))
  610.                 G.DrawString(Text, New Font("Segoe UI", 9), B, New Point(25, 1))
  611.             End Using
  612.  
  613.         End If
  614.  
  615.         If Checked Then
  616.  
  617.             If Enabled Then
  618.  
  619.                 Using B1 As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.WideUpwardDiagonal, ColorFromHex("#5B606F"), ColorFromHex("#525766")), P1 As New Pen(ColorFromHex("#474C5A"))
  620.                     G.FillEllipse(B1, New Rectangle(4, 4, 10, 10))
  621.                     G.DrawEllipse(P1, New Rectangle(4, 4, 10, 10))
  622.                 End Using
  623.  
  624.             Else
  625.  
  626.                 Using B1 As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.WideUpwardDiagonal, ColorFromHex("#8C92A1"), ColorFromHex("#7A7F8E")), P1 As New Pen(ColorFromHex("#797E8C"))
  627.                     G.FillEllipse(B1, New Rectangle(4, 4, 10, 10))
  628.                     G.DrawEllipse(P1, New Rectangle(4, 4, 10, 10))
  629.                 End Using
  630.  
  631.             End If
  632.  
  633.         End If
  634.  
  635.     End Sub
  636.  
  637.     Protected Overrides Sub OnResize(e As EventArgs)
  638.         MyBase.OnResize(e)
  639.         Size = New Size(Width, 19)
  640.     End Sub
  641.  
  642.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  643.         MyBase.OnMouseUp(e)
  644.  
  645.         If Enabled Then
  646.  
  647.             For Each C As Control In Parent.Controls
  648.                 If TypeOf C Is AetherRadioButton Then
  649.                     DirectCast(C, AetherRadioButton).Checked = False
  650.                 End If
  651.             Next
  652.  
  653.             Checked = Not Checked
  654.             RaiseEvent CheckedChanged(Me, e)
  655.             State = MouseState.Over : Invalidate()
  656.  
  657.         End If
  658.  
  659.     End Sub
  660.  
  661.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  662.         MyBase.OnMouseDown(e)
  663.         If Enabled Then
  664.             State = MouseState.Down : Invalidate()
  665.         End If
  666.     End Sub
  667.  
  668.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  669.         MyBase.OnMouseEnter(e)
  670.         If Enabled Then
  671.             State = MouseState.Over : Invalidate()
  672.         End If
  673.     End Sub
  674.  
  675.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  676.         MyBase.OnMouseLeave(e)
  677.         If Enabled Then
  678.             State = MouseState.None : Invalidate()
  679.         End If
  680.     End Sub
  681.  
  682. End Class
  683.  
  684. Public Class AetherGroupBox
  685.     Inherits ContainerControl
  686.  
  687.     Private G As Graphics
  688.  
  689.     Public Property Footer As Boolean
  690.     Public Property FooterText As String
  691.  
  692.     Sub New()
  693.         DoubleBuffered = True
  694.     End Sub
  695.  
  696.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  697.  
  698.         G = e.Graphics
  699.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  700.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  701.  
  702.         MyBase.OnPaint(e)
  703.  
  704.         G.Clear(Color.White)
  705.  
  706.         Using P1 As New Pen(ColorFromHex("#F1F5FC")), B1 As New SolidBrush(ColorFromHex("#343843")), F1 As New Font("Segoe UI", 9)
  707.             DrawRoundRect(G, FullRectangle(Size, True), 6, P1)
  708.             G.DrawString(Text, F1, B1, New Point(12, 10))
  709.             G.DrawLine(P1, New Point(0, 36), New Point(Width, 36))
  710.         End Using
  711.  
  712.         If Footer Then
  713.  
  714.             Using P1 As New Pen(ColorFromHex("#F5F5F5")), B1 As New SolidBrush(ColorFromHex("#7A7E89")), F1 As New Font("Segoe UI", 9)
  715.                 G.DrawLine(P1, New Point(0, Height - 35), New Point(Width, Height - 35))
  716.                 G.DrawString(FooterText, F1, B1, New Point(12, Height - 27))
  717.             End Using
  718.  
  719.         End If
  720.  
  721.     End Sub
  722.  
  723. End Class
  724.  
  725. Public Class AetherButton
  726.     Inherits Control
  727.  
  728.     Private G As Graphics
  729.     Private State As MouseState
  730.  
  731.     Private _EnabledCalc As Boolean
  732.  
  733.     Public Shadows Event Click(sender As Object, e As EventArgs)
  734.  
  735.     Sub New()
  736.         DoubleBuffered = True
  737.         Enabled = True
  738.     End Sub
  739.  
  740.     Public Shadows Property Enabled As Boolean
  741.         Get
  742.             Return EnabledCalc
  743.         End Get
  744.         Set(value As Boolean)
  745.             _EnabledCalc = value
  746.             Invalidate()
  747.         End Set
  748.     End Property
  749.  
  750.     <ComponentModel.DisplayName("Enabled")>
  751.     Public Property EnabledCalc As Boolean
  752.         Get
  753.             Return _EnabledCalc
  754.         End Get
  755.         Set(value As Boolean)
  756.             Enabled = value
  757.             Invalidate()
  758.         End Set
  759.     End Property
  760.  
  761.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  762.  
  763.         G = e.Graphics
  764.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  765.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  766.  
  767.         MyBase.OnPaint(e)
  768.  
  769.         If Enabled Then
  770.  
  771.             Select Case State
  772.  
  773.                 Case MouseState.Over
  774.  
  775.                     Using B1 As New SolidBrush(ColorFromHex("#FDFDFD"))
  776.                         FillRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 3, B1)
  777.                     End Using
  778.  
  779.                 Case MouseState.Down
  780.  
  781.                     Using B1 As New SolidBrush(ColorFromHex("#F0F0F0"))
  782.                         FillRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 3, B1)
  783.                     End Using
  784.  
  785.                 Case Else
  786.  
  787.                     Using B1 As New SolidBrush(ColorFromHex("#F6F6F6"))
  788.                         FillRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 3, B1)
  789.                     End Using
  790.  
  791.             End Select
  792.  
  793.             Using F1 As New Font("Segoe UI", 9), P1 As New Pen(ColorFromHex("#C3C3C3"))
  794.                 DrawRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 3, P1)
  795.                 CenterString(G, Text, F1, ColorFromHex("#343843"), FullRectangle(Size, False))
  796.             End Using
  797.  
  798.  
  799.         Else
  800.  
  801.             Using B1 As New SolidBrush(ColorFromHex("#F2F2F2")), P1 As New Pen(ColorFromHex("#DCDCDC")), F1 As New Font("Segoe UI", 9)
  802.                 FillRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 6, B1)
  803.                 DrawRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 6, P1)
  804.                 CenterString(G, Text, F1, ColorFromHex("#989CA7"), FullRectangle(Size, False))
  805.             End Using
  806.  
  807.         End If
  808.  
  809.     End Sub
  810.  
  811.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  812.         MyBase.OnMouseEnter(e)
  813.         State = MouseState.Over : Invalidate()
  814.     End Sub
  815.  
  816.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  817.         MyBase.OnMouseLeave(e)
  818.         State = MouseState.None : Invalidate()
  819.     End Sub
  820.  
  821.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  822.         MyBase.OnMouseUp(e)
  823.  
  824.         If Enabled Then
  825.             RaiseEvent Click(Me, e)
  826.         End If
  827.  
  828.         State = MouseState.Over : Invalidate()
  829.     End Sub
  830.  
  831.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  832.         MyBase.OnMouseDown(e)
  833.         State = MouseState.Down : Invalidate()
  834.     End Sub
  835.  
  836. End Class
  837.  
  838. Public Class AetherTag
  839.     Inherits Control
  840.  
  841.     Private G As Graphics
  842.  
  843.     Public Property Background As Color = ColorFromHex("#424452")
  844.     Public Property Border As Color = ColorFromHex("#323541")
  845.     Public Property TextColor As Color = ColorFromHex("#7C8290")
  846.  
  847.     Sub New()
  848.         DoubleBuffered = True
  849.         Text = "Tag"
  850.     End Sub
  851.  
  852.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  853.         G = e.Graphics
  854.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  855.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  856.  
  857.         MyBase.OnPaint(e)
  858.  
  859.         Using B1 As New SolidBrush(Background), P1 As New Pen(Border), B2 As New SolidBrush(TextColor)
  860.             G.FillRectangle(B1, FullRectangle(Size, True))
  861.             DrawRoundRect(G, FullRectangle(Size, True), 3, P1)
  862.  
  863.             If IsNumeric(Text) Then
  864.  
  865.                 Using F1 As New Font("Segoe UI", 8, FontStyle.Bold)
  866.                     G.DrawString(Text, F1, B2, New Point(2, 0))
  867.                 End Using
  868.  
  869.             Else
  870.  
  871.                 Using F1 As New Font("Segoe UI", 7, FontStyle.Bold)
  872.                     G.DrawString(Text.ToUpper, F1, B2, New Point(2, 1))
  873.                 End Using
  874.  
  875.             End If
  876.  
  877.         End Using
  878.  
  879.     End Sub
  880.  
  881.     Protected Overrides Sub OnResize(e As EventArgs)
  882.         MyBase.OnResize(e)
  883.         Size = New Size(Width, 15)
  884.     End Sub
  885.  
  886. End Class
  887.  
  888. <ComponentModel.DefaultEvent("TextChanged")>
  889. Public Class AetherTextbox
  890.     Inherits Control
  891.  
  892.     Private WithEvents TB As New TextBox
  893.     Private G As Graphics
  894.     Private State As MouseState
  895.     Private IsDown As Boolean
  896.  
  897.     Private _EnabledCalc As Boolean
  898.     Private _allowpassword As Boolean = False
  899.     Private _maxChars As Integer = 32767
  900.     Private _textAlignment As HorizontalAlignment
  901.     Private _multiLine As Boolean = False
  902.     Private _readOnly As Boolean = False
  903.  
  904.     Public Shadows Property Enabled As Boolean
  905.         Get
  906.             Return EnabledCalc
  907.         End Get
  908.         Set(value As Boolean)
  909.             TB.Enabled = value
  910.             _EnabledCalc = value
  911.             Invalidate()
  912.         End Set
  913.     End Property
  914.  
  915.     <ComponentModel.DisplayName("Enabled")>
  916.     Public Property EnabledCalc As Boolean
  917.         Get
  918.             Return _EnabledCalc
  919.         End Get
  920.         Set(value As Boolean)
  921.             Enabled = value
  922.             Invalidate()
  923.         End Set
  924.     End Property
  925.  
  926.     Public Shadows Property UseSystemPasswordChar() As Boolean
  927.         Get
  928.             Return _allowpassword
  929.         End Get
  930.         Set(ByVal value As Boolean)
  931.             TB.UseSystemPasswordChar = UseSystemPasswordChar
  932.             _allowpassword = value
  933.             Invalidate()
  934.         End Set
  935.     End Property
  936.  
  937.     Public Shadows Property MaxLength() As Integer
  938.         Get
  939.             Return _maxChars
  940.         End Get
  941.         Set(ByVal value As Integer)
  942.             _maxChars = value
  943.             TB.MaxLength = MaxLength
  944.             Invalidate()
  945.         End Set
  946.     End Property
  947.  
  948.     Public Shadows Property TextAlign() As HorizontalAlignment
  949.         Get
  950.             Return _textAlignment
  951.         End Get
  952.         Set(ByVal value As HorizontalAlignment)
  953.             _textAlignment = value
  954.             Invalidate()
  955.         End Set
  956.     End Property
  957.  
  958.     Public Shadows Property MultiLine() As Boolean
  959.         Get
  960.             Return _multiLine
  961.         End Get
  962.         Set(ByVal value As Boolean)
  963.             _multiLine = value
  964.             TB.Multiline = value
  965.             OnResize(EventArgs.Empty)
  966.             Invalidate()
  967.         End Set
  968.     End Property
  969.  
  970.     Public Shadows Property [ReadOnly]() As Boolean
  971.         Get
  972.             Return _readOnly
  973.         End Get
  974.         Set(ByVal value As Boolean)
  975.             _readOnly = value
  976.             If TB IsNot Nothing Then
  977.                 TB.ReadOnly = value
  978.             End If
  979.         End Set
  980.     End Property
  981.  
  982.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  983.         MyBase.OnTextChanged(e)
  984.         Invalidate()
  985.     End Sub
  986.  
  987.     Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
  988.         MyBase.OnBackColorChanged(e)
  989.         Invalidate()
  990.     End Sub
  991.  
  992.     Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
  993.         MyBase.OnForeColorChanged(e)
  994.         TB.ForeColor = ForeColor
  995.         Invalidate()
  996.     End Sub
  997.  
  998.     Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
  999.         MyBase.OnFontChanged(e)
  1000.         TB.Font = Font
  1001.     End Sub
  1002.  
  1003.     Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
  1004.         MyBase.OnGotFocus(e)
  1005.         TB.Focus()
  1006.     End Sub
  1007.  
  1008.     Private Sub TextChangeTb() Handles TB.TextChanged
  1009.         Text = TB.Text
  1010.     End Sub
  1011.  
  1012.     Private Sub TextChng() Handles MyBase.TextChanged
  1013.         TB.Text = Text
  1014.     End Sub
  1015.  
  1016.     Public Sub NewTextBox()
  1017.         With TB
  1018.             .Text = String.Empty
  1019.             .BackColor = Color.White
  1020.             .ForeColor = ColorFromHex("#343843")
  1021.             .TextAlign = HorizontalAlignment.Left
  1022.             .BorderStyle = BorderStyle.None
  1023.             .Location = New Point(3, 3)
  1024.             .Font = New Font("Segoe UI", 9)
  1025.             .Size = New Size(Width - 3, Height - 3)
  1026.             .UseSystemPasswordChar = UseSystemPasswordChar
  1027.         End With
  1028.     End Sub
  1029.  
  1030.     Sub New()
  1031.         MyBase.New()
  1032.         NewTextBox()
  1033.         Controls.Add(TB)
  1034.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  1035.         DoubleBuffered = True
  1036.         TextAlign = HorizontalAlignment.Left
  1037.         ForeColor = ColorFromHex("#343843")
  1038.         Font = New Font("Segoe UI", 9)
  1039.         Size = New Size(130, 29)
  1040.         Enabled = True
  1041.     End Sub
  1042.  
  1043.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1044.  
  1045.         G = e.Graphics
  1046.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  1047.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  1048.  
  1049.         MyBase.OnPaint(e)
  1050.  
  1051.         G.Clear(Color.White)
  1052.  
  1053.         If Enabled Then
  1054.  
  1055.             TB.ForeColor = ColorFromHex("#343843")
  1056.  
  1057.             If State = MouseState.Down Then
  1058.  
  1059.                 Using P As New Pen(ColorFromHex("#5B606F"))
  1060.                     DrawRoundRect(G, FullRectangle(Size, True), 3, P)
  1061.                 End Using
  1062.  
  1063.             Else
  1064.  
  1065.                 Using P As New Pen(ColorFromHex("#C8C8C8"))
  1066.                     DrawRoundRect(G, FullRectangle(Size, True), 3, P)
  1067.                 End Using
  1068.  
  1069.             End If
  1070.  
  1071.         Else
  1072.  
  1073.             TB.ForeColor = ColorFromHex("#DCDCDC")
  1074.  
  1075.             Using P As New Pen(ColorFromHex("#E6E6E6"))
  1076.                 DrawRoundRect(G, FullRectangle(Size, True), 3, P)
  1077.             End Using
  1078.  
  1079.         End If
  1080.  
  1081.         TB.TextAlign = TextAlign
  1082.         TB.UseSystemPasswordChar = UseSystemPasswordChar
  1083.  
  1084.     End Sub
  1085.  
  1086.     Protected Overrides Sub OnResize(e As EventArgs)
  1087.         MyBase.OnResize(e)
  1088.         If Not MultiLine Then
  1089.             Dim tbheight As Integer = TB.Height
  1090.             TB.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 0), Integer))
  1091.             TB.Size = New Size(Width - 20, tbheight)
  1092.         Else
  1093.             TB.Location = New Point(10, 10)
  1094.             TB.Size = New Size(Width - 20, Height - 20)
  1095.         End If
  1096.     End Sub
  1097.  
  1098.     Protected Overrides Sub OnEnter(e As EventArgs)
  1099.         MyBase.OnEnter(e)
  1100.         State = MouseState.Down : Invalidate()
  1101.     End Sub
  1102.  
  1103.     Protected Overrides Sub OnLeave(e As EventArgs)
  1104.         MyBase.OnLeave(e)
  1105.         State = MouseState.None : Invalidate()
  1106.     End Sub
  1107.  
  1108. End Class
Advertisement
Add Comment
Please, Sign In to add comment