Advertisement
Guest User

Aresio VB.NET Theme

a guest
Dec 20th, 2013
2,380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 27.21 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(236, 237, 239)
  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. Class AresioProgressBar
  468.     Inherits Control
  469.  
  470. #Region " Properties "
  471.  
  472.     Private _minimum As Integer
  473.     Public Property Minimum() As Integer
  474.         Get
  475.             Return _minimum
  476.         End Get
  477.         Set(ByVal value As Integer)
  478.             _minimum = value
  479.  
  480.             If value > _maximum Then _maximum = value
  481.             If value > _value Then _value = value
  482.  
  483.             Invalidate()
  484.         End Set
  485.     End Property
  486.  
  487.     Private _maximum As Integer
  488.     Public Property Maximum() As Integer
  489.         Get
  490.             Return _maximum
  491.         End Get
  492.         Set(ByVal value As Integer)
  493.             _maximum = value
  494.  
  495.             If value < _minimum Then _minimum = value
  496.             If value < _value Then _value = value
  497.  
  498.             Invalidate()
  499.         End Set
  500.     End Property
  501.  
  502.     Event ValueChanged()
  503.     Private _value As Integer
  504.     Public Property Value() As Integer
  505.         Get
  506.             Return _value
  507.         End Get
  508.         Set(ByVal value As Integer)
  509.             If value < _minimum Then
  510.                 _value = _minimum
  511.             ElseIf value > _maximum Then
  512.                 _value = _maximum
  513.             Else
  514.                 _value = value
  515.             End If
  516.  
  517.             Invalidate()
  518.             RaiseEvent ValueChanged()
  519.         End Set
  520.     End Property
  521.  
  522. #End Region
  523.  
  524.     Sub New()
  525.         SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  526.                 ControlStyles.ResizeRedraw Or _
  527.                 ControlStyles.UserPaint Or _
  528.                 ControlStyles.DoubleBuffer, True)
  529.         _maximum = 100
  530.         _minimum = 0
  531.         _value = 0
  532.     End Sub
  533.  
  534.  
  535.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  536.         MyBase.OnPaint(e)
  537.         Dim G As Graphics = e.Graphics
  538.         G.Clear(Parent.FindForm.BackColor)
  539.         G.SmoothingMode = SmoothingMode.AntiAlias
  540.  
  541.         'Background
  542.         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)
  543.         G.FillPath(BackLinear, RoundRect(0, CInt((Height / 2) - 4), Width - 1, 8, 3))
  544.         G.DrawPath(ToPen(50, Color.Black), RoundRect(0, CInt((Height / 2) - 4), Width - 1, 8, 3))
  545.         BackLinear.Dispose()
  546.  
  547.         'Fill
  548.         If _value > 0 Then
  549.             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))
  550.             G.DrawPath(ToPen(100, Color.White), RoundRect(2, CInt((Height / 2) - 2), CInt((Width - 4) * (Value / Maximum)), 4, 3))
  551.         End If
  552.     End Sub
  553. End Class
  554.  
  555. Class AresioRadioButton
  556.     Inherits Control
  557.  
  558.     Event CheckedChanged()
  559.     Private _checked As Boolean
  560.     Public Property Checked() As Boolean
  561.         Get
  562.             Return _checked
  563.         End Get
  564.         Set(ByVal value As Boolean)
  565.             _checked = value
  566.  
  567.             Invalidate()
  568.             RaiseEvent CheckedChanged()
  569.         End Set
  570.     End Property
  571.  
  572.     Sub New()
  573.         SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  574.                 ControlStyles.ResizeRedraw Or _
  575.                 ControlStyles.UserPaint Or _
  576.                 ControlStyles.DoubleBuffer, True)
  577.     End Sub
  578.  
  579.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  580.         MyBase.OnPaint(e)
  581.         Dim G As Graphics = e.Graphics
  582.  
  583.         G.SmoothingMode = SmoothingMode.AntiAlias
  584.  
  585.         Dim MLG As LinearGradientBrush = New LinearGradientBrush(New Point(Height / 2, 0), New Point(Height / 2, Height), Color.FromArgb(50, Color.Black), Color.Transparent)
  586.  
  587.         G.FillEllipse(MLG, New Rectangle(0, 0, Height - 1, Height - 1))
  588.         G.DrawEllipse(ToPen(50, Color.Black), New Rectangle(0, 0, Height - 1, Height - 1))
  589.  
  590.         G.DrawString(Text, Font, Brushes.Black, New Rectangle(Height + 5, 0, Width - Height + 4, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  591.  
  592.         If _checked Then
  593.             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))
  594.             G.FillEllipse(MLG2, New Rectangle(3, 3, Height - 7, Height - 7))
  595.             G.DrawEllipse(ToPen(50, Color.Black), New Rectangle(3, 3, Height - 7, Height - 7))
  596.         End If
  597.     End Sub
  598.  
  599.     Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  600.         MyBase.OnClick(e)
  601.  
  602.         If Not Checked Then Checked = True
  603.  
  604.         For Each ctl As Control In Parent.Controls
  605.             If TypeOf ctl Is AresioRadioButton Then
  606.                 If ctl.Handle = Me.Handle Then Continue For
  607.                 If ctl.Enabled Then DirectCast(ctl, AresioRadioButton).Checked = False
  608.             End If
  609.         Next
  610.     End Sub
  611. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement