Advertisement
ZeekoSec

Huresio Theme

Feb 1st, 2015
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 33.51 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D
  2.  
  3. Module DesignFunctions
  4.     Function ToBrush(ByVal A As Integer, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Brush
  5.         Return ToBrush(Color.FromArgb(A, R, G, B))
  6.     End Function
  7.     Function ToBrush(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Brush
  8.         Return ToBrush(Color.FromArgb(R, G, B))
  9.     End Function
  10.     Function ToBrush(ByVal A As Integer, ByVal C As Color) As Brush
  11.         Return ToBrush(Color.FromArgb(A, C))
  12.     End Function
  13.     Function ToBrush(ByVal Pen As Pen) As Brush
  14.         Return ToBrush(Pen.Color)
  15.     End Function
  16.     Function ToBrush(ByVal Color As Color) As Brush
  17.         Return New SolidBrush(Color)
  18.     End Function
  19.     Function ToPen(ByVal A As Integer, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Pen
  20.         Return ToPen(Color.FromArgb(A, R, G, B))
  21.     End Function
  22.     Function ToPen(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Pen
  23.         Return ToPen(Color.FromArgb(R, G, B))
  24.     End Function
  25.     Function ToPen(ByVal A As Integer, ByVal C As Color) As Pen
  26.         Return ToPen(Color.FromArgb(A, C))
  27.     End Function
  28.     Function ToPen(ByVal Color As Color) As Pen
  29.         Return ToPen(New SolidBrush(Color))
  30.     End Function
  31.     Function ToPen(ByVal Brush As SolidBrush) As Pen
  32.         Return New Pen(Brush)
  33.     End Function
  34.  
  35.     Class CornerStyle
  36.         Public TopLeft As Boolean
  37.         Public TopRight As Boolean
  38.         Public BottomLeft As Boolean
  39.         Public BottomRight As Boolean
  40.     End Class
  41.  
  42.     Public Function AdvRect(ByVal Rectangle As Rectangle, ByVal CornerStyle As CornerStyle, ByVal Curve As Integer) As GraphicsPath
  43.         AdvRect = New GraphicsPath()
  44.         Dim ArcRectangleWidth As Integer = Curve * 2
  45.  
  46.         If CornerStyle.TopLeft Then
  47.             AdvRect.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  48.         Else
  49.             AdvRect.AddLine(Rectangle.X, Rectangle.Y, Rectangle.X + ArcRectangleWidth, Rectangle.Y)
  50.         End If
  51.  
  52.         If CornerStyle.TopRight Then
  53.             AdvRect.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  54.         Else
  55.             AdvRect.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y, Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth)
  56.         End If
  57.  
  58.         If CornerStyle.BottomRight Then
  59.             AdvRect.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  60.         Else
  61.             AdvRect.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height, Rectangle.X + Rectangle.Width - ArcRectangleWidth, Rectangle.Y + Rectangle.Height)
  62.         End If
  63.  
  64.         If CornerStyle.BottomLeft Then
  65.             AdvRect.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  66.         Else
  67.             AdvRect.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height, Rectangle.X, Rectangle.Y + Rectangle.Height - ArcRectangleWidth)
  68.         End If
  69.  
  70.         AdvRect.CloseAllFigures()
  71.  
  72.         Return AdvRect
  73.     End Function
  74.  
  75.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  76.         RoundRect = New GraphicsPath()
  77.         Dim ArcRectangleWidth As Integer = Curve * 2
  78.         RoundRect.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  79.         RoundRect.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  80.         RoundRect.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  81.         RoundRect.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  82.         RoundRect.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, ArcRectangleWidth + Rectangle.Y))
  83.         RoundRect.CloseAllFigures()
  84.         Return RoundRect
  85.     End Function
  86.  
  87.     Public Function RoundRect(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal Curve As Integer) As GraphicsPath
  88.         Return RoundRect(New Rectangle(X, Y, Width, Height), Curve)
  89.     End Function
  90.  
  91.     Class PillStyle
  92.         Public Left As Boolean
  93.         Public Right As Boolean
  94.     End Class
  95.  
  96.     Public Function Pill(ByVal Rectangle As Rectangle, ByVal PillStyle As PillStyle) As GraphicsPath
  97.         Pill = New GraphicsPath()
  98.  
  99.         If PillStyle.Left Then
  100.             Pill.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, Rectangle.Height, Rectangle.Height), -270, 180)
  101.         Else
  102.             Pill.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height, Rectangle.X, Rectangle.Y)
  103.         End If
  104.  
  105.         If PillStyle.Right Then
  106.             Pill.AddArc(New Rectangle(Rectangle.X + Rectangle.Width - Rectangle.Height, Rectangle.Y, Rectangle.Height, Rectangle.Height), -90, 180)
  107.         Else
  108.             Pill.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height)
  109.         End If
  110.  
  111.         Pill.CloseAllFigures()
  112.  
  113.         Return Pill
  114.     End Function
  115.  
  116.     Public Function Pill(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal PillStyle As PillStyle)
  117.         Return Pill(New Rectangle(X, Y, Width, Height), PillStyle)
  118.     End Function
  119.  
  120. End Module
  121.  
  122. Class AresioButton
  123.     Inherits Control
  124.  
  125.     Enum MouseState
  126.         None
  127.         Over
  128.         Down
  129.     End Enum
  130.  
  131.     Sub New()
  132.         SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  133.         ControlStyles.ResizeRedraw Or _
  134.         ControlStyles.UserPaint Or _
  135.         ControlStyles.DoubleBuffer, True)
  136.     End Sub
  137.  
  138.     Private State As MouseState = 0
  139.  
  140.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  141.         MyBase.OnPaint(e)
  142.         Dim G As Graphics = e.Graphics
  143.  
  144.         G.SmoothingMode = SmoothingMode.HighQuality
  145.  
  146.         'Background
  147.         G.FillPath(New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(250, 200, 70), Color.FromArgb(250, 160, 40)), _
  148.                    RoundRect(0, 0, Width - 1, Height - 1, 4))
  149.  
  150.         G.DrawPath(ToPen(50, Color.White), RoundRect(0, 1, Width - 1, Height - 2, 4))
  151.         G.DrawPath(ToPen(150, 100, 70), RoundRect(0, 0, Width - 1, Height - 1, 4))
  152.         Select Case Enabled
  153.             Case True
  154.                 Select Case State
  155.                     Case MouseState.Over
  156.                         G.FillPath(New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(50, Color.White), Color.Transparent), _
  157.            RoundRect(0, 0, Width - 1, Height - 1, 4))
  158.                     Case MouseState.Down
  159.                         G.FillPath(New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(50, Color.Black), Color.Transparent), _
  160.                    RoundRect(0, 0, Width - 1, Height - 1, 4))
  161.                 End Select
  162.  
  163.                 G.DrawString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular), ToBrush(100, Color.White), New Point(CInt((Width / 2) - (G.MeasureString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Width / 2)), CInt((Height / 2) - (G.MeasureString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Height / 2)) + 1))
  164.                 G.DrawString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular), ToBrush(200, Color.Black), New Point(CInt((Width / 2) - (G.MeasureString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Width / 2)), CInt((Height / 2) - (G.MeasureString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Height / 2))))
  165.             Case False
  166.                 G.DrawString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular), Brushes.White, New Point(CInt((Width / 2) - (G.MeasureString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Width / 2)) + 1, CInt((Height / 2) - (G.MeasureString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Height / 2)) + 1))
  167.                 G.DrawString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular), Brushes.Gray, New Point(CInt((Width / 2) - (G.MeasureString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Width / 2)), CInt((Height / 2) - (G.MeasureString(Text, New Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Height / 2))))
  168.         End Select
  169.     End Sub
  170.  
  171.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  172.         MyBase.OnMouseEnter(e) : State = MouseState.Over : Invalidate()
  173.     End Sub
  174.  
  175.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  176.         MyBase.OnMouseLeave(e) : State = MouseState.None : Invalidate()
  177.     End Sub
  178.  
  179.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  180.         MyBase.OnMouseDown(e) : State = MouseState.Down : Invalidate()
  181.     End Sub
  182.  
  183.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  184.         MyBase.OnMouseUp(e) : State = MouseState.Over : Invalidate()
  185.     End Sub
  186. End Class
  187.  
  188.  
  189. Class AresioTrackBar
  190.     Inherits Control
  191.  
  192. #Region "Properties"
  193.     Dim _Maximum As Integer = 10
  194.     Public Property Maximum() As Integer
  195.         Get
  196.             Return _Maximum
  197.         End Get
  198.         Set(ByVal value As Integer)
  199.             If value > 0 Then _Maximum = value
  200.             If value < _Value Then _Value = value
  201.             Invalidate()
  202.         End Set
  203.     End Property
  204.  
  205.     Event ValueChanged()
  206.     Dim _Value As Integer = 0
  207.     Public Property Value() As Integer
  208.         Get
  209.             Return _Value
  210.         End Get
  211.         Set(ByVal value As Integer)
  212.  
  213.             Select Case value
  214.                 Case Is = _Value
  215.                     Exit Property
  216.                 Case Is < 0
  217.                     _Value = 0
  218.                 Case Is > _Maximum
  219.                     _Value = _Maximum
  220.                 Case Else
  221.                     _Value = value
  222.             End Select
  223.  
  224.             Invalidate()
  225.             RaiseEvent ValueChanged()
  226.         End Set
  227.     End Property
  228. #End Region
  229.  
  230.     Sub New()
  231.         Me.SetStyle(ControlStyles.DoubleBuffer Or _
  232.                     ControlStyles.AllPaintingInWmPaint Or _
  233.                     ControlStyles.ResizeRedraw Or _
  234.                     ControlStyles.UserPaint Or _
  235.                     ControlStyles.Selectable Or _
  236.                     ControlStyles.SupportsTransparentBackColor, True)
  237.     End Sub
  238.  
  239.     Dim CaptureM As Boolean = False
  240.     Dim Bar As Rectangle = New Rectangle(0, 10, Width - 1, Height - 21)
  241.     Dim Track As Size = New Size(20, 20)
  242.  
  243.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  244.         MyBase.OnPaint(e)
  245.         Dim G As Graphics = e.Graphics
  246.         Bar = New Rectangle(10, 10, Width - 21, Height - 21)
  247.         G.Clear(Parent.FindForm.BackColor)
  248.         G.SmoothingMode = SmoothingMode.AntiAlias
  249.  
  250.         'Background
  251.         Dim BackLinear As LinearGradientBrush = New LinearGradientBrush(New Point(0, CInt((Height / 2) - 4)), New Point(0, CInt((Height / 2) + 4)), Color.FromArgb(50, Color.Black), Color.Transparent)
  252.         G.FillPath(BackLinear, RoundRect(0, CInt((Height / 2) - 4), Width - 1, 8, 3))
  253.         G.DrawPath(ToPen(50, Color.Black), RoundRect(0, CInt((Height / 2) - 4), Width - 1, 8, 3))
  254.         BackLinear.Dispose()
  255.  
  256.  
  257.         'Fill
  258.         G.FillPath(New LinearGradientBrush(New Point(1, CInt((Height / 2) - 4)), New Point(1, CInt((Height / 2) + 4)), Color.FromArgb(250, 200, 70), Color.FromArgb(250, 160, 40)), RoundRect(1, CInt((Height / 2) - 4), CInt(Bar.Width * (Value / Maximum)) + CInt(Track.Width / 2), 8, 3))
  259.         G.DrawPath(ToPen(100, Color.White), RoundRect(2, CInt((Height / 2) - 2), CInt(Bar.Width * (Value / Maximum)) + CInt(Track.Width / 2), 4, 3))
  260.         G.SetClip(RoundRect(1, CInt((Height / 2) - 4), CInt(Bar.Width * (Value / Maximum)) + CInt(Track.Width / 2), 8, 3))
  261.         For i = 0 To CInt(Bar.Width * (Value / Maximum)) + CInt(Track.Width / 2) Step 10
  262.             G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(20, Color.Black)), 4), New Point(i, CInt((Height / 2) - 10)), New Point(i - 10, CInt((Height / 2) + 10)))
  263.         Next
  264.         G.SetClip(New Rectangle(0, 0, Width, Height))
  265.  
  266.         'Button
  267.         G.FillEllipse(Brushes.White, Bar.X + CInt(Bar.Width * (Value / Maximum)) - CInt(Track.Width / 2), Bar.Y + CInt((Bar.Height / 2)) - CInt(Track.Height / 2), Track.Width, Track.Height)
  268.         G.DrawEllipse(ToPen(50, Color.Black), Bar.X + CInt(Bar.Width * (Value / Maximum)) - CInt(Track.Width / 2), Bar.Y + CInt((Bar.Height / 2)) - CInt(Track.Height / 2), Track.Width, Track.Height)
  269.         G.FillEllipse(New LinearGradientBrush(New Point(0, Bar.Y + CInt((Bar.Height / 2)) - CInt(Track.Height / 2)), New Point(0, Bar.Y + CInt((Bar.Height / 2)) - CInt(Track.Height / 2) + Track.Height), Color.FromArgb(200, Color.Black), Color.FromArgb(100, Color.Black)), New Rectangle(Bar.X + CInt(Bar.Width * (Value / Maximum)) - CInt(Track.Width / 2) + 6, Bar.Y + CInt((Bar.Height / 2)) - CInt(Track.Height / 2) + 6, Track.Width - 12, Track.Height - 12))
  270.  
  271.     End Sub
  272.  
  273.     Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
  274.         Me.BackColor = Color.Transparent
  275.  
  276.         MyBase.OnHandleCreated(e)
  277.     End Sub
  278.  
  279.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  280.         MyBase.OnMouseDown(e)
  281.         Dim mp = New Rectangle(New Point(e.Location.X, e.Location.Y), New Size(1, 1))
  282.         Dim Bar As Rectangle = New Rectangle(10, 10, Width - 21, Height - 21)
  283.         If New Rectangle(New Point(Bar.X + CInt(Bar.Width * (Value / Maximum)) - CInt(Track.Width / 2), 0), New Size(Track.Width, Height)).IntersectsWith(mp) Then
  284.             CaptureM = True
  285.         End If
  286.     End Sub
  287.  
  288.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  289.         MyBase.OnMouseUp(e)
  290.         CaptureM = False
  291.     End Sub
  292.  
  293.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  294.         MyBase.OnMouseMove(e)
  295.         If CaptureM Then
  296.             Dim mp As Point = New Point(e.X, e.Y)
  297.             Dim Bar As Rectangle = New Rectangle(10, 10, Width - 21, Height - 21)
  298.             Value = CInt(Maximum * ((mp.X - Bar.X) / Bar.Width))
  299.         End If
  300.     End Sub
  301.  
  302.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  303.         MyBase.OnMouseLeave(e) : CaptureM = False
  304.     End Sub
  305.  
  306. End Class
  307.  
  308. Class AresioSwitch
  309.     Inherits Control
  310.  
  311.     Private ToggleLocation As Integer = 0
  312.     Private WithEvents ToggleAnimation As Timer = New Timer With {.Interval = 1}
  313.  
  314.     Event ToggledChanged()
  315.     Private _toggled As Boolean
  316.     Public Property Toggled() As Boolean
  317.         Get
  318.             Return _toggled
  319.         End Get
  320.         Set(ByVal value As Boolean)
  321.             _toggled = value
  322.             Invalidate()
  323.  
  324.             RaiseEvent ToggledChanged()
  325.         End Set
  326.     End Property
  327.  
  328.     Sub New()
  329.         SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  330.                 ControlStyles.ResizeRedraw Or _
  331.                 ControlStyles.UserPaint Or _
  332.                 ControlStyles.DoubleBuffer, True)
  333.     End Sub
  334.  
  335.     Protected Overrides Sub CreateHandle()
  336.         MyBase.CreateHandle()
  337.         ToggleAnimation.Start()
  338.     End Sub
  339.  
  340.     Private Sub Animation() Handles ToggleAnimation.Tick
  341.         If _toggled Then
  342.             If ToggleLocation < 100 Then
  343.                 ToggleLocation += 10
  344.             End If
  345.         Else
  346.             If ToggleLocation > 0 Then
  347.                 ToggleLocation -= 10
  348.             End If
  349.         End If
  350.  
  351.         Invalidate()
  352.     End Sub
  353.  
  354.     Dim Bar As Rectangle = New Rectangle(0, 10, Width - 1, Height - 21)
  355.     Dim Track As Size = New Size(20, 20)
  356.  
  357.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  358.         MyBase.OnPaint(e)
  359.         Dim G As Graphics = e.Graphics
  360.         Bar = New Rectangle(10, 10, Width - 21, Height - 21)
  361.         G.Clear(Parent.FindForm.BackColor)
  362.         G.SmoothingMode = SmoothingMode.AntiAlias
  363.  
  364.         'Background
  365.         Dim BackLinear As LinearGradientBrush = New LinearGradientBrush(New Point(0, CInt((Height / 2) - (Track.Height / 2))), New Point(0, CInt((Height / 2) + (Track.Height / 2))), Color.FromArgb(50, Color.Black), Color.Transparent)
  366.         'G.FillPath(BackLinear, RoundRect(0, CInt((Height / 2) - 4), Width - 1, 8, 3))
  367.         G.FillPath(BackLinear, Pill(0, CInt(Height / 2 - Track.Height / 2), Width - 1, Track.Height - 2, New PillStyle With {.Left = True, .Right = True}))
  368.         G.DrawPath(ToPen(50, Color.Black), Pill(0, CInt(Height / 2 - Track.Height / 2), Width - 1, Track.Height - 2, New PillStyle With {.Left = True, .Right = True}))
  369.  
  370.         BackLinear.Dispose()
  371.  
  372.         'Fill
  373.         If ToggleLocation > 0 Then
  374.             G.FillPath(New LinearGradientBrush(New Point(0, CInt((Height / 2) - Track.Height / 2)), New Point(1, CInt((Height / 2) + Track.Height / 2)), Color.FromArgb(250, 200, 70), Color.FromArgb(250, 160, 40)), Pill(1, CInt((Height / 2) - Track.Height / 2), CInt(Bar.Width * (ToggleLocation / 100)) + CInt(Track.Width / 2), Track.Height - 3, New PillStyle With {.Left = True, .Right = True}))
  375.             G.DrawPath(ToPen(100, Color.White), Pill(1, CInt((Height / 2) - Track.Height / 2 + 1), CInt(Bar.Width * (ToggleLocation / 100)) + CInt(Track.Width / 2), Track.Height - 5, New PillStyle With {.Left = True, .Right = True}))
  376.         End If
  377.  
  378.         If Toggled Then
  379.             G.DrawString("ON", New Font("Arial", 6, FontStyle.Bold), ToBrush(150, Color.Black), New Rectangle(0, -1, Width - Track.Width + Track.Width / 3, Height), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  380.         Else
  381.             G.DrawString("OFF", New Font("Arial", 6, FontStyle.Bold), ToBrush(150, Color.Black), New Rectangle(Track.Width - Track.Width / 3, -1, Width - Track.Width + Track.Width / 3, Height), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  382.         End If
  383.  
  384.         'Button
  385.         G.FillEllipse(Brushes.White, Bar.X + CInt(Bar.Width * (ToggleLocation / 100)) - CInt(Track.Width / 2), Bar.Y + CInt((Bar.Height / 2)) - CInt(Track.Height / 2), Track.Width, Track.Height)
  386.         G.DrawEllipse(ToPen(50, Color.Black), Bar.X + CInt(Bar.Width * (ToggleLocation / 100) - CInt(Track.Width / 2)), Bar.Y + CInt((Bar.Height / 2)) - CInt(Track.Height / 2), Track.Width, Track.Height)
  387.     End Sub
  388.  
  389.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  390.         MyBase.OnMouseUp(e)
  391.         Toggled = Not Toggled
  392.     End Sub
  393. End Class
  394.  
  395.  
  396. Class AresioTabControl
  397.     Inherits TabControl
  398.  
  399.     Sub New()
  400.         SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  401.         ControlStyles.ResizeRedraw Or _
  402.         ControlStyles.UserPaint Or _
  403.         ControlStyles.DoubleBuffer, True)
  404.     End Sub
  405.     Protected Overrides Sub CreateHandle()
  406.         MyBase.CreateHandle()
  407.         SizeMode = TabSizeMode.Normal
  408.         ItemSize = New Size(77, 31)
  409.     End Sub
  410.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  411.         Dim G As Graphics = e.Graphics
  412.         Dim ItemBounds As Rectangle
  413.         Dim TextBrush As New SolidBrush(Color.Empty)
  414.         Dim SOFF As Integer = 0
  415.         G.Clear(Color.FromArgb(236, 237, 239))
  416.  
  417.         For TabItemIndex As Integer = 0 To Me.TabCount - 1
  418.             ItemBounds = Me.GetTabRect(TabItemIndex)
  419.  
  420.             If Not TabItemIndex = SelectedIndex Then
  421.                 SOFF = 2
  422.  
  423.                 G.FillPath(ToBrush(10, Color.Black), RoundRect(New Rectangle(New Point(ItemBounds.X, ItemBounds.Y + SOFF), New Size(ItemBounds.Width, ItemBounds.Height)), 2))
  424.                 G.DrawPath(ToPen(90, Color.Black), RoundRect(New Rectangle(New Point(ItemBounds.X, ItemBounds.Y + SOFF), New Size(ItemBounds.Width, ItemBounds.Height)), 2))
  425.  
  426.                 Dim sf As New StringFormat
  427.                 sf.LineAlignment = StringAlignment.Center
  428.                 sf.Alignment = StringAlignment.Center
  429.                 TextBrush.Color = Color.FromArgb(80, 80, 80)
  430.                 Try
  431.                     G.DrawString(TabPages(TabItemIndex).Text, New Font(Font.Name, Font.Size - 1), TextBrush, New Rectangle(GetTabRect(TabItemIndex).Location, GetTabRect(TabItemIndex).Size), sf)
  432.                     TabPages(TabItemIndex).BackColor = Color.FromArgb(243, 243, 243)
  433.                 Catch : End Try
  434.  
  435.             End If
  436.         Next
  437.  
  438.         G.FillPath(ToBrush(236, 237, 239), RoundRect(0, ItemSize.Height - 1, Width - 1, Height - ItemSize.Height - 1, 2))
  439.         G.DrawPath(ToPen(150, 151, 153), RoundRect(0, ItemSize.Height - 1, Width - 1, Height - ItemSize.Height - 1, 2))
  440.  
  441.         For TabItemIndex As Integer = 0 To Me.TabCount - 1
  442.             ItemBounds = Me.GetTabRect(TabItemIndex)
  443.  
  444.             If TabItemIndex = SelectedIndex Then
  445.  
  446.                 G.FillPath(ToBrush(236, 237, 239), RoundRect(New Rectangle(New Point(ItemBounds.X - 2, ItemBounds.Y), New Size(ItemBounds.Width + 3, ItemBounds.Height - 2)), 2))
  447.                 G.DrawPath(ToPen(150, 151, 153), RoundRect(New Rectangle(New Point(ItemBounds.X - 2, ItemBounds.Y), New Size(ItemBounds.Width + 2, ItemBounds.Height - 2)), 2))
  448.  
  449.                 G.FillRectangle(ToBrush(236, 237, 239), New Rectangle(New Point(ItemBounds.X - 1, ItemBounds.Y + 1), New Size(ItemBounds.Width + 1, ItemBounds.Height)))
  450.                 SOFF = 0
  451.  
  452.                 Dim sf As New StringFormat
  453.                 sf.LineAlignment = StringAlignment.Center
  454.                 sf.Alignment = StringAlignment.Center
  455.                 TextBrush.Color = Color.FromArgb(80, 80, 80)
  456.                 Try
  457.                     G.DrawString(TabPages(TabItemIndex).Text, Font, TextBrush, New Rectangle(GetTabRect(TabItemIndex).Location + New Point(0, SOFF), GetTabRect(TabItemIndex).Size), sf)
  458.                     TabPages(TabItemIndex).BackColor = Color.FromArgb(236, 237, 239)
  459.                 Catch : End Try
  460.  
  461.             End If
  462.         Next
  463.     End Sub
  464.  
  465. End Class
  466.  
  467. Enum MouseState As Byte
  468.     None = 0
  469.     Over = 1
  470.     Down = 2
  471.     Block = 3
  472. End Enum
  473.  
  474. Module HuraModule
  475.  
  476. #Region " G"
  477.     Friend G As Graphics, B As Bitmap
  478. #End Region
  479.  
  480.  
  481.     Sub New()
  482.         TextBitmap = New Bitmap(1, 1)
  483.         TextGraphics = Graphics.FromImage(TextBitmap)
  484.     End Sub
  485.  
  486.     Private TextBitmap As Bitmap
  487.     Private TextGraphics As Graphics
  488.  
  489.     Friend Function MeasureString(text As String, font As Font) As SizeF
  490.         Return TextGraphics.MeasureString(text, font)
  491.     End Function
  492.  
  493.     Friend Function MeasureString(text As String, font As Font, width As Integer) As SizeF
  494.         Return TextGraphics.MeasureString(text, font, width, StringFormat.GenericTypographic)
  495.     End Function
  496.  
  497.     Private CreateRoundPath As GraphicsPath
  498.     Private CreateRoundRectangle As Rectangle
  499.  
  500.     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
  501.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  502.         Return CreateRound(CreateRoundRectangle, slope)
  503.     End Function
  504.  
  505.     Friend Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  506.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  507.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  508.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  509.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  510.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  511.         CreateRoundPath.CloseFigure()
  512.         Return CreateRoundPath
  513.     End Function
  514.  
  515.     Public Function RoundRectangle(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  516.         Dim P As GraphicsPath = New GraphicsPath()
  517.         Dim ArcRectangleWidth As Integer = Curve * 2
  518.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  519.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  520.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  521.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  522.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  523.         Return P
  524.     End Function
  525.  
  526. End Module
  527.  
  528.  
  529.  
  530. Public Class HuraForm : Inherits ContainerControl
  531.     Enum ColorSchemes
  532.         Dark
  533.     End Enum
  534.     Event ColorSchemeChanged()
  535.     Private _ColorScheme As ColorSchemes
  536.     Public Property ColorScheme() As ColorSchemes
  537.         Get
  538.             Return _ColorScheme
  539.         End Get
  540.         Set(ByVal value As ColorSchemes)
  541.             _ColorScheme = value
  542.             RaiseEvent ColorSchemeChanged()
  543.         End Set
  544.     End Property
  545.     Protected Sub OnColorSchemeChanged() Handles Me.ColorSchemeChanged
  546.         Invalidate()
  547.         Select Case ColorScheme
  548.             Case ColorSchemes.Dark
  549.                 BackColor = Color.FromArgb(243, 243, 243)
  550.                 Font = New Font("Segoe UI", 9.5)
  551.                 AccentColor = Color.FromArgb(255, 255, 255)
  552.                 ForeColor = Color.Gray
  553.         End Select
  554.     End Sub
  555. #Region " Properties "
  556.     Private _AccentColor As Color
  557.     Public Property AccentColor() As Color
  558.         Get
  559.             Return _AccentColor
  560.         End Get
  561.         Set(ByVal value As Color)
  562.             _AccentColor = value
  563.             OnAccentColorChanged()
  564.         End Set
  565.     End Property
  566. #End Region
  567. #Region " Constructor "
  568.     Sub New()
  569.         MyBase.New()
  570.         DoubleBuffered = True
  571.         Font = New Font("Segoe UI Semilight", 9.75F)
  572.         'AccentColor = Color.FromArgb(150, 0, 150)
  573.         AccentColor = Color.White
  574.         ColorScheme = ColorSchemes.Dark
  575.         ForeColor = Color.Gray
  576.         BackColor = Color.FromArgb(255, 255, 255)
  577.         MoveHeight = 32
  578.     End Sub
  579. #End Region
  580. #Region " Events "
  581.     Event AccentColorChanged()
  582. #End Region
  583.     Private MouseP As Point = New Point(0, 0)
  584.     Private Cap As Boolean = False
  585.     Private MoveHeight As Integer
  586.     Private pos As Integer = 0
  587.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  588.         MyBase.OnMouseDown(e)
  589.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  590.             Cap = True : MouseP = e.Location
  591.         End If
  592.     End Sub
  593.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  594.         MyBase.OnMouseMove(e)
  595.         If Cap Then
  596.             Parent.Location = MousePosition - MouseP
  597.         End If
  598.     End Sub
  599.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  600.         MyBase.OnMouseUp(e) : Cap = False
  601.     End Sub
  602.     Protected Overrides Sub OnCreateControl()
  603.         MyBase.OnCreateControl()
  604.         Dock = DockStyle.Fill
  605.         Parent.FindForm().FormBorderStyle = FormBorderStyle.None
  606.     End Sub
  607.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  608.         Dim B As Bitmap = New Bitmap(Width, Height)
  609.         Dim G As Graphics = Graphics.FromImage(B)
  610.         MyBase.OnPaint(e)
  611.  
  612.         Dim MainRect As New Rectangle(0, 0, Width - 1, Height - 1)
  613.  
  614.         G.Clear(BackColor)
  615.         G.DrawLine(New Pen(Color.FromArgb(250, 171, 48), 3), New Point(0, 0), New Point(Width, 0))
  616.         G.DrawRectangle(New Pen(Color.FromArgb(250, 171, 48)), MainRect)
  617.         G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(8, 6, Width - 1, Height - 1), StringFormat.GenericDefault)
  618.  
  619.         e.Graphics.DrawImage(B, New Point(0, 0))
  620.         G.Dispose() : B.Dispose()
  621.     End Sub
  622.     Protected Sub OnAccentColorChanged() Handles Me.AccentColorChanged
  623.         Invalidate()
  624.     End Sub
  625.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  626.         MyBase.OnTextChanged(e)
  627.         Invalidate()
  628.     End Sub
  629.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  630.         MyBase.OnResize(e)
  631.         Invalidate()
  632.     End Sub
  633. End Class
  634.  
  635.  
  636. Class AresioProgressBar
  637.     Inherits Control
  638.  
  639. #Region " Properties "
  640.  
  641.     Private _minimum As Integer
  642.     Public Property Minimum() As Integer
  643.         Get
  644.             Return _minimum
  645.         End Get
  646.         Set(ByVal value As Integer)
  647.             _minimum = value
  648.  
  649.             If value > _maximum Then _maximum = value
  650.             If value > _value Then _value = value
  651.  
  652.             Invalidate()
  653.         End Set
  654.     End Property
  655.  
  656.     Private _maximum As Integer
  657.     Public Property Maximum() As Integer
  658.         Get
  659.             Return _maximum
  660.         End Get
  661.         Set(ByVal value As Integer)
  662.             _maximum = value
  663.  
  664.             If value < _minimum Then _minimum = value
  665.             If value < _value Then _value = value
  666.  
  667.             Invalidate()
  668.         End Set
  669.     End Property
  670.  
  671.     Event ValueChanged()
  672.     Private _value As Integer
  673.     Public Property Value() As Integer
  674.         Get
  675.             Return _value
  676.         End Get
  677.         Set(ByVal value As Integer)
  678.             If value < _minimum Then
  679.                 _value = _minimum
  680.             ElseIf value > _maximum Then
  681.                 _value = _maximum
  682.             Else
  683.                 _value = value
  684.             End If
  685.  
  686.             Invalidate()
  687.             RaiseEvent ValueChanged()
  688.         End Set
  689.     End Property
  690.  
  691. #End Region
  692.  
  693.     Sub New()
  694.         SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  695.                 ControlStyles.ResizeRedraw Or _
  696.                 ControlStyles.UserPaint Or _
  697.                 ControlStyles.DoubleBuffer, True)
  698.         _maximum = 100
  699.         _minimum = 0
  700.         _value = 0
  701.     End Sub
  702.  
  703.  
  704.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  705.         MyBase.OnPaint(e)
  706.         Dim G As Graphics = e.Graphics
  707.         G.Clear(Parent.FindForm.BackColor)
  708.         G.SmoothingMode = SmoothingMode.AntiAlias
  709.  
  710.         'Background
  711.         Dim BackLinear As LinearGradientBrush = New LinearGradientBrush(New Point(0, CInt((Height / 2) - 4)), New Point(0, CInt((Height / 2) + 4)), Color.FromArgb(50, Color.Black), Color.Transparent)
  712.         G.FillPath(BackLinear, RoundRect(0, CInt((Height / 2) - 4), Width - 1, 8, 3))
  713.         G.DrawPath(ToPen(50, Color.Black), RoundRect(0, CInt((Height / 2) - 4), Width - 1, 8, 3))
  714.         BackLinear.Dispose()
  715.  
  716.         'Fill
  717.         If _value > 0 Then
  718.             G.FillPath(New LinearGradientBrush(New Point(1, CInt((Height / 2) - 4)), New Point(1, CInt((Height / 2) + 4)), Color.FromArgb(250, 200, 70), Color.FromArgb(250, 160, 40)), RoundRect(1, CInt((Height / 2) - 4), CInt((Width - 2) * (Value / Maximum)), 8, 3))
  719.             G.DrawPath(ToPen(100, Color.White), RoundRect(2, CInt((Height / 2) - 2), CInt((Width - 4) * (Value / Maximum)), 4, 3))
  720.         End If
  721.     End Sub
  722. End Class
  723.  
  724. Class AresioRadioButton
  725.     Inherits Control
  726.  
  727.     Event CheckedChanged()
  728.     Private _checked As Boolean
  729.     Public Property Checked() As Boolean
  730.         Get
  731.             Return _checked
  732.         End Get
  733.         Set(ByVal value As Boolean)
  734.             _checked = value
  735.  
  736.             Invalidate()
  737.             RaiseEvent CheckedChanged()
  738.         End Set
  739.     End Property
  740.  
  741.     Sub New()
  742.         SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  743.                 ControlStyles.ResizeRedraw Or _
  744.                 ControlStyles.UserPaint Or _
  745.                 ControlStyles.DoubleBuffer, True)
  746.     End Sub
  747.  
  748.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  749.         MyBase.OnPaint(e)
  750.         Dim G As Graphics = e.Graphics
  751.  
  752.         G.SmoothingMode = SmoothingMode.AntiAlias
  753.  
  754.         Dim MLG As LinearGradientBrush = New LinearGradientBrush(New Point(Height / 2, 0), New Point(Height / 2, Height), Color.FromArgb(50, Color.Black), Color.Transparent)
  755.  
  756.         G.FillEllipse(MLG, New Rectangle(0, 0, Height - 1, Height - 1))
  757.         G.DrawEllipse(ToPen(50, Color.Black), New Rectangle(0, 0, Height - 1, Height - 1))
  758.  
  759.         G.DrawString(Text, Font, Brushes.Black, New Rectangle(Height + 5, 0, Width - Height + 4, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  760.  
  761.         If _checked Then
  762.             Dim MLG2 As LinearGradientBrush = New LinearGradientBrush(New Point(Height / 2, 3), New Point(Height / 2, Height - 6), Color.FromArgb(200, Color.White), Color.FromArgb(10, Color.White))
  763.             G.FillEllipse(MLG2, New Rectangle(3, 3, Height - 7, Height - 7))
  764.             G.DrawEllipse(ToPen(50, Color.Black), New Rectangle(3, 3, Height - 7, Height - 7))
  765.         End If
  766.     End Sub
  767.  
  768.     Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  769.         MyBase.OnClick(e)
  770.  
  771.         If Not Checked Then Checked = True
  772.  
  773.         For Each ctl As Control In Parent.Controls
  774.             If TypeOf ctl Is AresioRadioButton Then
  775.                 If ctl.Handle = Me.Handle Then Continue For
  776.                 If ctl.Enabled Then DirectCast(ctl, AresioRadioButton).Checked = False
  777.             End If
  778.         Next
  779.     End Sub
  780. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement