Advertisement
Guest User

Huratheme

a guest
May 8th, 2014
6,252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 31.83 KB | None | 0 0
  1. ' All credits to Aeonhack
  2. ' All credits to HawkHF
  3. ' All credits to Leumonic
  4.  
  5. ' Edited by Huracan
  6.  
  7. Imports System.Drawing.Drawing2D
  8. Imports System.ComponentModel
  9.  
  10.  
  11.  
  12. Module HuraModule
  13.  
  14. #Region " G"
  15.     Friend G As Graphics, B As Bitmap
  16. #End Region
  17.  
  18.  
  19.     Sub New()
  20.         TextBitmap = New Bitmap(1, 1)
  21.         TextGraphics = Graphics.FromImage(TextBitmap)
  22.     End Sub
  23.  
  24.     Private TextBitmap As Bitmap
  25.     Private TextGraphics As Graphics
  26.  
  27.     Friend Function MeasureString(text As String, font As Font) As SizeF
  28.         Return TextGraphics.MeasureString(text, font)
  29.     End Function
  30.  
  31.     Friend Function MeasureString(text As String, font As Font, width As Integer) As SizeF
  32.         Return TextGraphics.MeasureString(text, font, width, StringFormat.GenericTypographic)
  33.     End Function
  34.  
  35.     Private CreateRoundPath As GraphicsPath
  36.     Private CreateRoundRectangle As Rectangle
  37.  
  38.     Friend Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  39.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  40.         Return CreateRound(CreateRoundRectangle, slope)
  41.     End Function
  42.  
  43.     Friend Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  44.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  45.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  46.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  47.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  48.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  49.         CreateRoundPath.CloseFigure()
  50.         Return CreateRoundPath
  51.     End Function
  52.  
  53. End Module
  54.  
  55.  
  56.  
  57. Public Class HuraForm : Inherits ContainerControl
  58.     Enum ColorSchemes
  59.         Dark
  60.     End Enum
  61.     Event ColorSchemeChanged()
  62.     Private _ColorScheme As ColorSchemes
  63.     Public Property ColorScheme() As ColorSchemes
  64.         Get
  65.             Return _ColorScheme
  66.         End Get
  67.         Set(ByVal value As ColorSchemes)
  68.             _ColorScheme = value
  69.             RaiseEvent ColorSchemeChanged()
  70.         End Set
  71.     End Property
  72.     Protected Sub OnColorSchemeChanged() Handles Me.ColorSchemeChanged
  73.         Invalidate()
  74.         Select Case ColorScheme
  75.             Case ColorSchemes.Dark
  76.                 BackColor = Color.FromArgb(40, 40, 40)
  77.                 Font = New Font("Segoe UI", 9.5)
  78.                 AccentColor = Color.FromArgb(90, 90, 90)
  79.                 ForeColor = Color.White
  80.         End Select
  81.     End Sub
  82. #Region " Properties "
  83.     Private _AccentColor As Color
  84.     Public Property AccentColor() As Color
  85.         Get
  86.             Return _AccentColor
  87.         End Get
  88.         Set(ByVal value As Color)
  89.             _AccentColor = value
  90.             OnAccentColorChanged()
  91.         End Set
  92.     End Property
  93. #End Region
  94. #Region " Constructor "
  95.     Sub New()
  96.         MyBase.New()
  97.         DoubleBuffered = True
  98.         Font = New Font("Segoe UI Semilight", 9.75F)
  99.         'AccentColor = Color.FromArgb(150, 0, 150)
  100.         AccentColor = Color.DodgerBlue
  101.         ColorScheme = ColorSchemes.Dark
  102.         ForeColor = Color.White
  103.         BackColor = Color.FromArgb(180, 180, 180)
  104.         MoveHeight = 32
  105.     End Sub
  106. #End Region
  107. #Region " Events "
  108.     Event AccentColorChanged()
  109. #End Region
  110. #Region " Overrides "
  111.     Private MouseP As Point = New Point(0, 0)
  112.     Private Cap As Boolean = False
  113.     Private MoveHeight As Integer
  114.     Private pos As Integer = 0
  115.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  116.         MyBase.OnMouseDown(e)
  117.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  118.             Cap = True : MouseP = e.Location
  119.         End If
  120.     End Sub
  121.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  122.         MyBase.OnMouseMove(e)
  123.         If Cap Then
  124.             Parent.Location = MousePosition - MouseP
  125.         End If
  126.     End Sub
  127.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  128.         MyBase.OnMouseUp(e) : Cap = False
  129.     End Sub
  130.     Protected Overrides Sub OnCreateControl()
  131.         MyBase.OnCreateControl()
  132.         Dock = DockStyle.Fill
  133.         Parent.FindForm().FormBorderStyle = FormBorderStyle.None
  134.     End Sub
  135.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  136.         Dim B As Bitmap = New Bitmap(Width, Height)
  137.         Dim G As Graphics = Graphics.FromImage(B)
  138.         MyBase.OnPaint(e)
  139.  
  140.         G.Clear(BackColor)
  141.         G.DrawLine(New Pen(_AccentColor, 1), New Point(0, 30), New Point(Width, 30))
  142.         G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(8, 6, Width - 1, Height - 1), StringFormat.GenericDefault)
  143.         G.DrawRectangle(New Pen(Color.FromArgb(100, 100, 100)), New Rectangle(0, 0, Width - 1, Height - 1))
  144.         e.Graphics.DrawImage(B, New Point(0, 0))
  145.         G.Dispose() : B.Dispose()
  146.     End Sub
  147.     Protected Sub OnAccentColorChanged() Handles Me.AccentColorChanged
  148.         Invalidate()
  149.     End Sub
  150.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  151.         MyBase.OnTextChanged(e)
  152.         Invalidate()
  153.     End Sub
  154.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  155.         MyBase.OnResize(e)
  156.         Invalidate()
  157.     End Sub
  158. #End Region
  159.  
  160. End Class
  161.  
  162. <DefaultEvent("CheckedChanged")> _
  163. Class HuraRadioButton
  164.     Inherits Control
  165.  
  166.     Event CheckedChanged(sender As Object)
  167.  
  168.     Sub New()
  169.         SetStyle(DirectCast(139286, ControlStyles), True)
  170.         SetStyle(ControlStyles.Selectable, False)
  171.  
  172.         P1 = New Pen(Color.FromArgb(50, 50, 50))
  173.         P2 = New Pen(Color.FromArgb(95, 95, 95))
  174.     End Sub
  175.  
  176.     Private _Checked As Boolean
  177.     Public Property Checked() As Boolean
  178.         Get
  179.             Return _Checked
  180.         End Get
  181.         Set(ByVal value As Boolean)
  182.             _Checked = value
  183.  
  184.             If _Checked Then
  185.                 InvalidateParent()
  186.             End If
  187.  
  188.             RaiseEvent CheckedChanged(Me)
  189.             Invalidate()
  190.         End Set
  191.     End Property
  192.  
  193.     Private Sub InvalidateParent()
  194.         If Parent Is Nothing Then Return
  195.  
  196.         For Each C As Control In Parent.Controls
  197.             If Not (C Is Me) AndAlso (TypeOf C Is HuraRadioButton) Then
  198.                 DirectCast(C, HuraRadioButton).Checked = False
  199.             End If
  200.         Next
  201.     End Sub
  202.  
  203.     Private GP1 As GraphicsPath
  204.  
  205.     Private SZ1 As SizeF
  206.     Private PT1 As PointF
  207.  
  208.     Private P1, P2 As Pen
  209.  
  210.  
  211.  
  212.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  213.         G = e.Graphics
  214.  
  215.  
  216.         G.Clear(BackColor)
  217.         G.SmoothingMode = SmoothingMode.AntiAlias
  218.  
  219.         GP1 = New GraphicsPath
  220.         GP1.AddEllipse(0, 1, Height - 5, Height - 5)
  221.  
  222.         G.DrawEllipse(P1, 0, 2, Height - 5, Height - 5)
  223.         G.DrawEllipse(P2, 1, 3, Height - 7, Height - 7)
  224.  
  225.         If _Checked Then
  226.             G.FillEllipse(Brushes.Black, 6, 8, Height - 15, Height - 15)
  227.             G.FillEllipse(Brushes.White, 5, 7, Height - 15, Height - 15)
  228.         End If
  229.  
  230.         SZ1 = G.MeasureString(Text, Font)
  231.         PT1 = New PointF(Height - 3, Height \ 2 - SZ1.Height / 2)
  232.  
  233.         G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  234.         G.DrawString(Text, Font, Brushes.White, PT1)
  235.     End Sub
  236.  
  237.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  238.         Checked = True
  239.         MyBase.OnMouseDown(e)
  240.     End Sub
  241.  
  242. End Class
  243.  
  244. Public Class HuraControlBox : Inherits Control
  245.     Enum ColorSchemes
  246.         Dark
  247.     End Enum
  248.     Event ColorSchemeChanged()
  249.     Private _ColorScheme As ColorSchemes
  250.     Public Property ColorScheme() As ColorSchemes
  251.         Get
  252.             Return _ColorScheme
  253.         End Get
  254.         Set(ByVal value As ColorSchemes)
  255.             _ColorScheme = value
  256.             RaiseEvent ColorSchemeChanged()
  257.         End Set
  258.     End Property
  259.     Protected Sub OnColorSchemeChanged() Handles Me.ColorSchemeChanged
  260.         Invalidate()
  261.         Select Case ColorScheme
  262.             Case ColorSchemes.Dark
  263.                 BackColor = Color.FromArgb(40, 40, 40)
  264.                 ForeColor = Color.White
  265.                 AccentColor = Color.FromArgb(60, 60, 60)
  266.         End Select
  267.     End Sub
  268.     Private _AccentColor As Color
  269.     Public Property AccentColor() As Color
  270.         Get
  271.             Return _AccentColor
  272.         End Get
  273.         Set(ByVal value As Color)
  274.             _AccentColor = value
  275.             Invalidate()
  276.         End Set
  277.     End Property
  278.  
  279.     Sub New()
  280.         MyBase.New()
  281.         DoubleBuffered = True
  282.         SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  283.         SetStyle(ControlStyles.UserPaint, True)
  284.         SetStyle(ControlStyles.ResizeRedraw, True)
  285.         SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  286.         ForeColor = Color.FromArgb(50, 50, 50)
  287.         BackColor = Color.FromArgb(50, 50, 50)
  288.         AccentColor = Color.DodgerBlue
  289.         ColorScheme = ColorSchemes.Dark
  290.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  291.     End Sub
  292.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  293.         MyBase.OnResize(e)
  294.         Size = New Size(100, 25)
  295.     End Sub
  296.     Enum ButtonHover
  297.         Minimize
  298.         Maximize
  299.         Close
  300.         None
  301.     End Enum
  302.     Dim ButtonState As ButtonHover = ButtonHover.None
  303.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  304.         MyBase.OnMouseMove(e)
  305.         Dim X As Integer = e.Location.X
  306.         Dim Y As Integer = e.Location.Y
  307.         If Y > 0 AndAlso Y < (Height - 2) Then
  308.             If X > 0 AndAlso X < 34 Then
  309.                 ButtonState = ButtonHover.Minimize
  310.             ElseIf X > 33 AndAlso X < 65 Then
  311.                 ButtonState = ButtonHover.Maximize
  312.             ElseIf X > 64 AndAlso X < Width Then
  313.                 ButtonState = ButtonHover.Close
  314.             Else
  315.                 ButtonState = ButtonHover.None
  316.             End If
  317.         Else
  318.             ButtonState = ButtonHover.None
  319.         End If
  320.         Invalidate()
  321.     End Sub
  322.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  323.         Dim B As New Bitmap(Width, Height)
  324.         Dim G As Graphics = Graphics.FromImage(B)
  325.         MyBase.OnPaint(e)
  326.  
  327.         G.Clear(BackColor)
  328.         Select Case ButtonState
  329.             Case ButtonHover.None
  330.                 G.Clear(BackColor)
  331.             Case ButtonHover.Minimize
  332.                 G.FillRectangle(New SolidBrush(_AccentColor), New Rectangle(3, 0, 30, Height))
  333.             Case ButtonHover.Maximize
  334.                 G.FillRectangle(New SolidBrush(_AccentColor), New Rectangle(34, 0, 30, Height))
  335.             Case ButtonHover.Close
  336.                 G.FillRectangle(New SolidBrush(_AccentColor), New Rectangle(65, 0, 35, Height))
  337.         End Select
  338.  
  339.         Dim ButtonFont As New Font("Marlett", 9.75F)
  340.         'Close
  341.         G.DrawString("r", ButtonFont, New SolidBrush(Color.FromArgb(210, 210, 210)), New Point(Width - 16, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  342.         'Maximize
  343.         Select Case Parent.FindForm().WindowState
  344.             Case FormWindowState.Maximized
  345.                 G.DrawString("2", ButtonFont, New SolidBrush(Color.FromArgb(210, 210, 210)), New Point(51, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  346.             Case FormWindowState.Normal
  347.                 G.DrawString("1", ButtonFont, New SolidBrush(Color.FromArgb(210, 210, 210)), New Point(51, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  348.         End Select
  349.         'Minimize
  350.         G.DrawString("0", ButtonFont, New SolidBrush(Color.FromArgb(210, 210, 210)), New Point(20, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  351.  
  352.  
  353.         e.Graphics.DrawImage(B, New Point(0, 0))
  354.         G.Dispose() : B.Dispose()
  355.     End Sub
  356.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  357.         MyBase.OnMouseDown(e)
  358.         Select Case ButtonState
  359.             Case ButtonHover.Close
  360.                 Parent.FindForm().Close()
  361.             Case ButtonHover.Minimize
  362.                 Parent.FindForm().WindowState = FormWindowState.Minimized
  363.             Case ButtonHover.Maximize
  364.                 If Parent.FindForm().WindowState = FormWindowState.Normal Then
  365.                     Parent.FindForm().WindowState = FormWindowState.Maximized
  366.                 Else
  367.                     Parent.FindForm().WindowState = FormWindowState.Normal
  368.                 End If
  369.  
  370.         End Select
  371.     End Sub
  372.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  373.         MyBase.OnMouseLeave(e)
  374.         ButtonState = ButtonHover.None : Invalidate()
  375.     End Sub
  376. End Class
  377. Public Class HuraButton : Inherits Button
  378.     Enum MouseState
  379.         None
  380.         Over
  381.         Down
  382.     End Enum
  383.     Enum ColorSchemes
  384.         Dark
  385.     End Enum
  386.     Private _ColorScheme As ColorSchemes
  387.     Public Property ColorScheme() As ColorSchemes
  388.         Get
  389.             Return _ColorScheme
  390.         End Get
  391.         Set(ByVal value As ColorSchemes)
  392.             _ColorScheme = value
  393.             Invalidate()
  394.         End Set
  395.     End Property
  396.  
  397.     Dim State As MouseState = MouseState.None
  398.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  399.         MyBase.OnMouseEnter(e)
  400.         State = MouseState.Over : Invalidate()
  401.     End Sub
  402.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  403.         MyBase.OnMouseLeave(e)
  404.         State = MouseState.None : Invalidate()
  405.     End Sub
  406.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  407.         MyBase.OnMouseDown(e)
  408.         State = MouseState.Down : Invalidate()
  409.     End Sub
  410.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  411.         MyBase.OnMouseUp(e)
  412.         State = MouseState.Over : Invalidate()
  413.     End Sub
  414.  
  415.     Private _AccentColor As Color
  416.     Public Property AccentColor() As Color
  417.         Get
  418.             Return _AccentColor
  419.         End Get
  420.         Set(ByVal value As Color)
  421.             _AccentColor = value
  422.             OnAccentColorChanged()
  423.         End Set
  424.     End Property
  425.  
  426.     Event AccentColorChanged()
  427.  
  428.     Sub New()
  429.         MyBase.New()
  430.         Font = New Font("Segoe UI", 9.5)
  431.         ForeColor = Color.White
  432.         BackColor = Color.FromArgb(50, 50, 50)
  433.         AccentColor = Color.FromArgb(70, 70, 70)
  434.         ColorScheme = ColorSchemes.Dark
  435.     End Sub
  436.  
  437.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  438.         Dim B As New Bitmap(Width, Height)
  439.         Dim G As Graphics = Graphics.FromImage(B)
  440.         MyBase.OnPaint(e)
  441.         Dim BGColor As Color
  442.         Select Case ColorScheme
  443.             Case ColorSchemes.Dark
  444.                 BGColor = Color.FromArgb(50, 50, 50)
  445.         End Select
  446.  
  447.         Select Case State
  448.             Case MouseState.None
  449.                 G.Clear(BGColor)
  450.             Case MouseState.Over
  451.                 G.Clear(AccentColor)
  452.             Case MouseState.Down
  453.                 G.Clear(AccentColor)
  454.                 G.FillRectangle(New SolidBrush(Color.FromArgb(50, Color.Black)), New Rectangle(0, 0, Width - 1, Height - 1))
  455.         End Select
  456.  
  457.  
  458.         G.DrawRectangle(New Pen(Color.FromArgb(100, 100, 100)), New Rectangle(0, 0, Width - 1, Height - 1))
  459.  
  460.         Dim ButtonString As New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
  461.         Select Case ColorScheme
  462.             Case ColorSchemes.Dark
  463.                 G.DrawString(Text, Font, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), ButtonString)
  464.         End Select
  465.  
  466.         e.Graphics.DrawImage(B, New Point(0, 0))
  467.         G.Dispose() : B.Dispose()
  468.     End Sub
  469.     Protected Sub OnAccentColorChanged() Handles Me.AccentColorChanged
  470.         Invalidate()
  471.     End Sub
  472. End Class
  473.  
  474. Class HuraGroupBox
  475.     Inherits ContainerControl
  476.  
  477.     Sub New()
  478.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  479.                  ControlStyles.UserPaint Or ControlStyles.ResizeRedraw, True)
  480.         BackColor = Color.FromArgb(50, 50, 50)
  481.     End Sub
  482.  
  483.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  484.         MyBase.OnPaint(e)
  485.  
  486.         Dim G As Graphics = e.Graphics
  487.  
  488.         G.SmoothingMode = SmoothingMode.HighQuality
  489.         G.Clear(Parent.BackColor)
  490.  
  491.         Dim mainRect As New Rectangle(0, 0, Width - 1, Height - 1)
  492.         G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), mainRect)
  493.         G.DrawRectangle(New Pen(Color.FromArgb(87, 87, 87)), mainRect)
  494.  
  495.     End Sub
  496.  
  497. End Class
  498.  
  499. <DefaultEvent("CheckedChanged")> _
  500. Class HuraCheckBox
  501.     Inherits Control
  502.  
  503.     Event CheckedChanged(sender As Object)
  504.  
  505.     Sub New()
  506.         SetStyle(DirectCast(139286, ControlStyles), True)
  507.         SetStyle(ControlStyles.Selectable, False)
  508.  
  509.         P11 = New Pen(Color.FromArgb(50, 50, 50))
  510.         P22 = New Pen(Color.FromArgb(87, 87, 87))
  511.         P3 = New Pen(Color.Black, 2.0F)
  512.         P4 = New Pen(Color.White, 2.0F)
  513.     End Sub
  514.  
  515.     Private _Checked As Boolean
  516.     Public Property Checked() As Boolean
  517.         Get
  518.             Return _Checked
  519.         End Get
  520.         Set(ByVal value As Boolean)
  521.             _Checked = value
  522.             RaiseEvent CheckedChanged(Me)
  523.  
  524.             Invalidate()
  525.         End Set
  526.     End Property
  527.  
  528.     Private GP1, GP2 As GraphicsPath
  529.  
  530.     Private SZ1 As SizeF
  531.     Private PT1 As PointF
  532.  
  533.     Private P11, P22, P3, P4 As Pen
  534.  
  535.     Private PB1 As PathGradientBrush
  536.  
  537.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  538.         G = e.Graphics
  539.  
  540.  
  541.         G.Clear(BackColor)
  542.         G.SmoothingMode = SmoothingMode.AntiAlias
  543.  
  544.         GP1 = CreateRound(0, 2, Height - 5, Height - 5, 5)
  545.         GP2 = CreateRound(1, 3, Height - 7, Height - 7, 5)
  546.  
  547.         PB1 = New PathGradientBrush(GP1)
  548.         PB1.CenterColor = Color.FromArgb(50, 50, 50)
  549.         PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  550.         PB1.FocusScales = New PointF(0.3F, 0.3F)
  551.  
  552.         G.FillPath(PB1, GP1)
  553.         G.DrawPath(P11, GP1)
  554.         G.DrawPath(P22, GP2)
  555.  
  556.         If _Checked Then
  557.             G.DrawLine(P3, 5, Height - 9, 8, Height - 7)
  558.             G.DrawLine(P3, 7, Height - 7, Height - 8, 7)
  559.  
  560.             G.DrawLine(P4, 4, Height - 10, 7, Height - 8)
  561.             G.DrawLine(P4, 6, Height - 8, Height - 9, 6)
  562.         End If
  563.  
  564.         SZ1 = G.MeasureString(Text, Font)
  565.         PT1 = New PointF(Height - 3, Height \ 2 - SZ1.Height / 2)
  566.  
  567.         G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  568.         G.DrawString(Text, Font, Brushes.White, PT1)
  569.     End Sub
  570.  
  571.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  572.         Checked = Not Checked
  573.     End Sub
  574.  
  575. End Class
  576.  
  577. Public Class HuraTextBox : Inherits TextBox
  578.     Enum ColorSchemes
  579.         Light
  580.         Dark
  581.     End Enum
  582.     Event ColorSchemeChanged()
  583.     Private _ColorScheme As ColorSchemes
  584.     Public Property ColorScheme() As ColorSchemes
  585.         Get
  586.             Return _ColorScheme
  587.         End Get
  588.         Set(ByVal value As ColorSchemes)
  589.             _ColorScheme = value
  590.             RaiseEvent ColorSchemeChanged()
  591.         End Set
  592.     End Property
  593.  
  594.     Sub New()
  595.         BorderStyle = Windows.Forms.BorderStyle.FixedSingle
  596.         Font = New Font("Segoe UI", 9.5)
  597.         BackColor = Color.FromArgb(50, 50, 50)
  598.         ForeColor = Color.White
  599.         ColorScheme = ColorSchemes.Dark
  600.     End Sub
  601.  
  602.     Protected Sub OnColorSchemeChanged() Handles Me.ColorSchemeChanged
  603.         Invalidate()
  604.         Select Case ColorScheme
  605.             Case ColorSchemes.Dark
  606.                 BackColor = Color.FromArgb(50, 50, 50)
  607.                 ForeColor = Color.White
  608.         End Select
  609.     End Sub
  610. End Class
  611.  
  612.  
  613. Public Class HuraComboBox : Inherits ComboBox
  614. #Region " Control Help - Properties & Flicker Control "
  615.     Enum ColorSchemes
  616.         Light
  617.         Dark
  618.     End Enum
  619.     Private _ColorScheme As ColorSchemes
  620.     Public Property ColorScheme() As ColorSchemes
  621.         Get
  622.             Return _ColorScheme
  623.         End Get
  624.         Set(ByVal value As ColorSchemes)
  625.             _ColorScheme = value
  626.             Invalidate()
  627.         End Set
  628.     End Property
  629.  
  630.     Private _AccentColor As Color
  631.     Public Property AccentColor() As Color
  632.         Get
  633.             Return _AccentColor
  634.         End Get
  635.         Set(ByVal value As Color)
  636.             _AccentColor = value
  637.             Invalidate()
  638.         End Set
  639.     End Property
  640.  
  641.     Private _StartIndex As Integer = 0
  642.     Private Property StartIndex As Integer
  643.         Get
  644.             Return _StartIndex
  645.         End Get
  646.         Set(ByVal value As Integer)
  647.             _StartIndex = value
  648.             Try
  649.                 MyBase.SelectedIndex = value
  650.             Catch
  651.             End Try
  652.             Invalidate()
  653.         End Set
  654.     End Property
  655.     Sub ReplaceItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  656.         e.DrawBackground()
  657.         Try
  658.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  659.                 e.Graphics.FillRectangle(New SolidBrush(_AccentColor), e.Bounds)
  660.             Else
  661.                 Select Case ColorScheme
  662.                     Case ColorSchemes.Dark
  663.                         e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(35, 35, 35)), e.Bounds)
  664.                     Case ColorSchemes.Light
  665.                         e.Graphics.FillRectangle(New SolidBrush(Color.White), e.Bounds)
  666.                 End Select
  667.             End If
  668.             Select Case ColorScheme
  669.                 Case ColorSchemes.Dark
  670.                     e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), e.Font, Brushes.White, e.Bounds)
  671.                 Case ColorSchemes.Light
  672.                     e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), e.Font, Brushes.Black, e.Bounds)
  673.             End Select
  674.         Catch
  675.         End Try
  676.     End Sub
  677.     Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, ByVal SecondPoint As Point, ByVal ThirdPoint As Point, ByVal G As Graphics)
  678.         Dim points As New List(Of Point)()
  679.         points.Add(FirstPoint)
  680.         points.Add(SecondPoint)
  681.         points.Add(ThirdPoint)
  682.         G.FillPolygon(New SolidBrush(Clr), points.ToArray())
  683.     End Sub
  684.  
  685. #End Region
  686.  
  687.     Sub New()
  688.         MyBase.New()
  689.         SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  690.         SetStyle(ControlStyles.ResizeRedraw, True)
  691.         SetStyle(ControlStyles.UserPaint, True)
  692.         SetStyle(ControlStyles.DoubleBuffer, True)
  693.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  694.         DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  695.         BackColor = Color.FromArgb(50, 50, 50)
  696.         Size = New Size(189, 24)
  697.         ForeColor = Color.White
  698.         AccentColor = Color.FromArgb(70, 70, 70)
  699.         ColorScheme = ColorSchemes.Dark
  700.         DropDownStyle = ComboBoxStyle.DropDownList
  701.         Font = New Font("Segoe UI", 9.5)
  702.         StartIndex = 0
  703.         DoubleBuffered = True
  704.     End Sub
  705.  
  706.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  707.         Dim B As New Bitmap(Width, Height)
  708.         Dim G As Graphics = Graphics.FromImage(B)
  709.         Dim Curve As Integer = 2
  710.  
  711.  
  712.         G.SmoothingMode = SmoothingMode.HighQuality
  713.  
  714.  
  715.         Select Case ColorScheme
  716.             Case ColorSchemes.Dark
  717.                 G.Clear(Color.FromArgb(50, 50, 50))
  718.                 G.DrawLine(New Pen(Color.White, 2), New Point(Width - 18, 10), New Point(Width - 14, 14))
  719.                 G.DrawLine(New Pen(Color.White, 2), New Point(Width - 14, 14), New Point(Width - 10, 10))
  720.                 G.DrawLine(New Pen(Color.White), New Point(Width - 14, 15), New Point(Width - 14, 14))
  721.             Case ColorSchemes.Light
  722.                 G.Clear(Color.White)
  723.                 G.DrawLine(New Pen(Color.FromArgb(100, 100, 100), 2), New Point(Width - 18, 10), New Point(Width - 14, 14))
  724.                 G.DrawLine(New Pen(Color.FromArgb(100, 100, 100), 2), New Point(Width - 14, 14), New Point(Width - 10, 10))
  725.                 G.DrawLine(New Pen(Color.FromArgb(100, 100, 100)), New Point(Width - 14, 15), New Point(Width - 14, 14))
  726.         End Select
  727.         G.DrawRectangle(New Pen(Color.FromArgb(100, 100, 100)), New Rectangle(0, 0, Width - 1, Height - 1))
  728.  
  729.  
  730.         Try
  731.             Select Case ColorScheme
  732.                 Case ColorSchemes.Dark
  733.                     G.DrawString(Text, Font, Brushes.White, New Rectangle(7, 0, Width - 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  734.                 Case ColorSchemes.Light
  735.                     G.DrawString(Text, Font, Brushes.Black, New Rectangle(7, 0, Width - 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  736.             End Select
  737.         Catch
  738.         End Try
  739.  
  740.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  741.         G.Dispose() : B.Dispose()
  742.     End Sub
  743. End Class
  744.  
  745. Class HuraProgressBar
  746.     Inherits Control
  747.  
  748.     Private _Minimum As Integer
  749.     Property Minimum() As Integer
  750.         Get
  751.             Return _Minimum
  752.         End Get
  753.         Set(ByVal value As Integer)
  754.             If value < 0 Then
  755.                 Throw New Exception("Property value is not valid.")
  756.             End If
  757.  
  758.             _Minimum = value
  759.             If value > _Value Then _Value = value
  760.             If value > _Maximum Then _Maximum = value
  761.             Invalidate()
  762.         End Set
  763.     End Property
  764.  
  765.     Private _Maximum As Integer = 100
  766.     Property Maximum() As Integer
  767.         Get
  768.             Return _Maximum
  769.         End Get
  770.         Set(ByVal value As Integer)
  771.             If value < 0 Then
  772.                 Throw New Exception("Property value is not valid.")
  773.             End If
  774.  
  775.             _Maximum = value
  776.             If value < _Value Then _Value = value
  777.             If value < _Minimum Then _Minimum = value
  778.             Invalidate()
  779.         End Set
  780.     End Property
  781.  
  782.     Private _Value As Integer
  783.     Property Value() As Integer
  784.         Get
  785.             Return _Value
  786.         End Get
  787.         Set(ByVal value As Integer)
  788.  
  789.             _Value = value
  790.             Invalidate()
  791.         End Set
  792.     End Property
  793.  
  794.     Private Sub Increment(ByVal amount As Integer)
  795.         Value += amount
  796.     End Sub
  797.  
  798.     Sub New()
  799.         SetStyle(DirectCast(139286, ControlStyles), True)
  800.         SetStyle(ControlStyles.Selectable, False)
  801.  
  802.         P1 = New Pen(Color.FromArgb(90, 90, 90))
  803.         P2 = New Pen(Color.FromArgb(55, 55, 55))
  804.         B1 = New SolidBrush(Color.FromArgb(70, 70, 70))
  805.     End Sub
  806.  
  807.     Private GP1, GP2, GP3 As GraphicsPath
  808.  
  809.     Private R1, R2 As Rectangle
  810.  
  811.     Private P1, P2 As Pen
  812.     Private B1 As SolidBrush
  813.     Private GB1, GB2 As LinearGradientBrush
  814.  
  815.     Private I1 As Integer
  816.  
  817.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  818.         G = e.Graphics
  819.  
  820.         G.Clear(BackColor)
  821.         G.SmoothingMode = SmoothingMode.AntiAlias
  822.  
  823.         GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  824.         GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  825.  
  826.         R1 = New Rectangle(0, 2, Width - 1, Height - 1)
  827.         GB1 = New LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90.0F)
  828.  
  829.         G.SetClip(GP1)
  830.         G.FillRectangle(GB1, R1)
  831.  
  832.         I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 3))
  833.  
  834.         If I1 > 1 Then
  835.             GP3 = CreateRound(1, 1, I1, Height - 3, 7)
  836.  
  837.             R2 = New Rectangle(1, 1, I1, Height - 3)
  838.             GB2 = New LinearGradientBrush(R2, Color.FromArgb(70, 70, 70), Color.FromArgb(70, 70, 70), 90.0F)
  839.  
  840.             G.FillPath(GB2, GP3)
  841.             G.DrawPath(P1, GP3)
  842.  
  843.             G.SetClip(GP3)
  844.             G.SmoothingMode = SmoothingMode.None
  845.  
  846.             G.FillRectangle(B1, R2.X, R2.Y + 1, R2.Width, R2.Height \ 2)
  847.  
  848.             G.SmoothingMode = SmoothingMode.AntiAlias
  849.             G.ResetClip()
  850.         End If
  851.  
  852.         G.DrawPath(P2, GP1)
  853.         G.DrawPath(P1, GP2)
  854.     End Sub
  855. End Class
  856.  
  857. Class HuraAlertBox
  858.     Inherits Control
  859.  
  860.     Private exitLocation As Point
  861.     Private overExit As Boolean
  862.  
  863.     Enum Style
  864.         Simple
  865.         Success
  866.         Notice
  867.         Warning
  868.         Informations
  869.     End Enum
  870.  
  871.     Private _alertStyle As Style
  872.     Public Property AlertStyle As Style
  873.         Get
  874.             Return _alertStyle
  875.         End Get
  876.         Set(ByVal value As Style)
  877.             _alertStyle = value
  878.             Invalidate()
  879.         End Set
  880.     End Property
  881.  
  882.     Sub New()
  883.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  884.                  ControlStyles.UserPaint Or ControlStyles.ResizeRedraw, True)
  885.         Font = New Font("Verdana", 8)
  886.         Size = New Size(200, 40)
  887.     End Sub
  888.  
  889.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  890.         MyBase.OnPaint(e)
  891.  
  892.         Dim G As Graphics = e.Graphics
  893.  
  894.         G.SmoothingMode = SmoothingMode.HighQuality
  895.         G.Clear(Parent.BackColor)
  896.  
  897.         Dim borderColor, innerColor, textColor As Color
  898.         Select Case _alertStyle
  899.             Case Style.Simple
  900.                 borderColor = Color.FromArgb(90, 90, 90)
  901.                 innerColor = Color.FromArgb(50, 50, 50)
  902.                 textColor = Color.FromArgb(150, 150, 150)
  903.             Case Style.Success
  904.                 borderColor = Color.FromArgb(60, 98, 79)
  905.                 innerColor = Color.FromArgb(60, 85, 79)
  906.                 textColor = Color.FromArgb(35, 169, 110)
  907.             Case Style.Notice
  908.                 borderColor = Color.FromArgb(70, 91, 107)
  909.                 innerColor = Color.FromArgb(70, 91, 94)
  910.                 textColor = Color.FromArgb(97, 185, 186)
  911.             Case Style.Warning
  912.                 borderColor = Color.FromArgb(100, 71, 71)
  913.                 innerColor = Color.FromArgb(87, 71, 71)
  914.                 textColor = Color.FromArgb(254, 142, 122)
  915.             Case Style.Informations
  916.                 borderColor = Color.FromArgb(133, 133, 71)
  917.                 innerColor = Color.FromArgb(120, 120, 71)
  918.                 textColor = Color.FromArgb(254, 224, 122)
  919.         End Select
  920.  
  921.         Dim mainRect As New Rectangle(0, 0, Width - 1, Height - 1)
  922.         G.FillRectangle(New SolidBrush(innerColor), mainRect)
  923.         G.DrawRectangle(New Pen(borderColor), mainRect)
  924.  
  925.         Dim styleText As String = Nothing
  926.  
  927.         Select Case _alertStyle
  928.  
  929.         End Select
  930.  
  931.         Dim styleFont As New Font(Font.FontFamily, Font.Size, FontStyle.Bold)
  932.         Dim textY As Integer = ((Me.Height - 1) / 2) - (G.MeasureString(Text, Font).Height / 2)
  933.         G.DrawString(styleText, styleFont, New SolidBrush(textColor), New Point(10, textY))
  934.         G.DrawString(Text, Font, New SolidBrush(textColor), New Point(10 + G.MeasureString(styleText, styleFont).Width + 4, textY))
  935.  
  936.         Dim exitFont As New Font("Marlett", 6)
  937.         Dim exitY As Integer = ((Me.Height - 1) / 2) - (G.MeasureString("r", exitFont).Height / 2) + 1
  938.         exitLocation = New Point(Width - 26, exitY - 3)
  939.         G.DrawString("r", exitFont, New SolidBrush(textColor), New Point(Width - 23, exitY))
  940.  
  941.     End Sub
  942.  
  943.  
  944.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  945.         MyBase.OnMouseMove(e)
  946.  
  947.         If e.X >= Width - 26 AndAlso e.X <= Width - 12 AndAlso e.Y > exitLocation.Y AndAlso e.Y < exitLocation.Y + 12 Then
  948.             If Cursor <> Cursors.Hand Then Cursor = Cursors.Hand
  949.             overExit = True
  950.         Else
  951.             If Cursor <> Cursors.Arrow Then Cursor = Cursors.Arrow
  952.             overExit = False
  953.         End If
  954.  
  955.         Invalidate()
  956.  
  957.     End Sub
  958.  
  959.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  960.         MyBase.OnMouseDown(e)
  961.  
  962.         If overExit Then Me.Visible = False
  963.  
  964.     End Sub
  965.  
  966. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement