Advertisement
Finessed

Ambiance Theme

Jan 4th, 2016
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 109.43 KB | None | 0 0
  1. #Region " Imports "
  2.  
  3. Imports System.Drawing.Drawing2D
  4. Imports System.ComponentModel
  5.  
  6. #End Region
  7.  
  8. '|------DO-NOT-REMOVE------|
  9. ' Get more free themes at ThemesVB.NET
  10. ' Creator: HazelDev
  11. ' Site   : HazelDev.com
  12. ' Created: 20.Aug.2014
  13. ' Changed: 9.Sep.2014
  14. ' Version: 1.0.0
  15. '
  16. '|------DO-NOT-REMOVE------|
  17.  
  18. Namespace Ambiance
  19.  
  20. #Region " RoundRectangle "
  21.  
  22.     Module RoundRectangle
  23.         Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  24.             Dim P As GraphicsPath = New GraphicsPath()
  25.             Dim ArcRectangleWidth As Integer = Curve * 2
  26.             P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  27.             P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  28.             P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  29.             P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  30.             P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  31.             Return P
  32.         End Function
  33.         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
  34.             Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
  35.             Dim P As GraphicsPath = New GraphicsPath()
  36.             Dim ArcRectangleWidth As Integer = Curve * 2
  37.             P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  38.             P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  39.             P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  40.             P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  41.             P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  42.             Return P
  43.         End Function
  44.         Public Function RoundedTopRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  45.             Dim P As GraphicsPath = New GraphicsPath()
  46.             Dim ArcRectangleWidth As Integer = Curve * 2
  47.             P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  48.             P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  49.             P.AddLine(New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth), New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 1))
  50.             P.AddLine(New Point(Rectangle.X, Rectangle.Height - 1 + Rectangle.Y), New Point(Rectangle.X, Rectangle.Y + Curve))
  51.             Return P
  52.         End Function
  53.     End Module
  54.  
  55. #End Region
  56.  
  57. #Region " ThemeContainer "
  58. ' Get more free themes at ThemesVB.NET
  59.     Class Ambiance_ThemeContainer
  60.         Inherits ContainerControl
  61.  
  62. #Region " Enums "
  63.  
  64.         Enum MouseState As Byte
  65.             None = 0
  66.             Over = 1
  67.             Down = 2
  68.             Block = 3
  69.         End Enum
  70.  
  71. #End Region
  72. #Region " Variables "
  73.  
  74.         Private HeaderRect As Rectangle
  75.         Protected State As MouseState
  76.         Private MoveHeight As Integer
  77.         Private MouseP As Point = New Point(0, 0)
  78.         Private Cap As Boolean = False
  79.         Private HasShown As Boolean
  80.  
  81. #End Region
  82. #Region " Properties "
  83.  
  84.         Private _Sizable As Boolean = True
  85.         Property Sizable() As Boolean
  86.             Get
  87.                 Return _Sizable
  88.             End Get
  89.             Set(ByVal value As Boolean)
  90.                 _Sizable = value
  91.             End Set
  92.         End Property
  93.  
  94.         Private _SmartBounds As Boolean = True
  95.         Property SmartBounds() As Boolean
  96.             Get
  97.                 Return _SmartBounds
  98.             End Get
  99.             Set(ByVal value As Boolean)
  100.                 _SmartBounds = value
  101.             End Set
  102.         End Property
  103.  
  104.         Private _RoundCorners As Boolean = True
  105.         Property RoundCorners() As Boolean
  106.             Get
  107.                 Return _RoundCorners
  108.             End Get
  109.             Set(ByVal value As Boolean)
  110.                 _RoundCorners = value
  111.                 Invalidate()
  112.             End Set
  113.         End Property
  114.  
  115.         Private _IsParentForm As Boolean
  116.         Protected ReadOnly Property IsParentForm As Boolean
  117.             Get
  118.                 Return _IsParentForm
  119.             End Get
  120.         End Property
  121.  
  122.         Protected ReadOnly Property IsParentMdi As Boolean
  123.             Get
  124.                 If Parent Is Nothing Then Return False
  125.                 Return Parent.Parent IsNot Nothing
  126.             End Get
  127.         End Property
  128.  
  129.         Private _ControlMode As Boolean
  130.         Protected Property ControlMode() As Boolean
  131.             Get
  132.                 Return _ControlMode
  133.             End Get
  134.             Set(ByVal v As Boolean)
  135.                 _ControlMode = v
  136.                 Invalidate()
  137.             End Set
  138.         End Property
  139.  
  140.         Private _StartPosition As FormStartPosition
  141.         Property StartPosition As FormStartPosition
  142.             Get
  143.                 If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.StartPosition Else Return _StartPosition
  144.             End Get
  145.             Set(ByVal value As FormStartPosition)
  146.                 _StartPosition = value
  147.  
  148.                 If _IsParentForm AndAlso Not _ControlMode Then
  149.                     ParentForm.StartPosition = value
  150.                 End If
  151.             End Set
  152.         End Property
  153.  
  154. #End Region
  155. #Region " EventArgs "
  156.  
  157.         Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  158.             MyBase.OnParentChanged(e)
  159.  
  160.             If Parent Is Nothing Then Return
  161.             _IsParentForm = TypeOf Parent Is Form
  162.  
  163.             If Not _ControlMode Then
  164.                 InitializeMessages()
  165.  
  166.                 If _IsParentForm Then
  167.                     Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  168.                     Me.ParentForm.TransparencyKey = Color.Fuchsia
  169.  
  170.                     If Not DesignMode Then
  171.                         AddHandler ParentForm.Shown, AddressOf FormShown
  172.                     End If
  173.                 End If
  174.                 Parent.BackColor = BackColor
  175.                 Parent.MinimumSize = New Size(261, 65)
  176.             End If
  177.         End Sub
  178.  
  179.         Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  180.             MyBase.OnSizeChanged(e)
  181.             If Not _ControlMode Then HeaderRect = New Rectangle(0, 0, Width - 14, MoveHeight - 7)
  182.             Invalidate()
  183.         End Sub
  184.  
  185.         Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  186.             MyBase.OnMouseDown(e)
  187.             If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  188.             If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
  189.                 If HeaderRect.Contains(e.Location) Then
  190.                     Capture = False
  191.                     WM_LMBUTTONDOWN = True
  192.                     DefWndProc(Messages(0))
  193.                 ElseIf _Sizable AndAlso Not Previous = 0 Then
  194.                     Capture = False
  195.                     WM_LMBUTTONDOWN = True
  196.                     DefWndProc(Messages(Previous))
  197.                 End If
  198.             End If
  199.         End Sub
  200. ' Get more free themes at ThemesVB.NET
  201.         Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  202.             MyBase.OnMouseUp(e)
  203.             Cap = False
  204.         End Sub
  205.  
  206.         Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  207.             MyBase.OnMouseMove(e)
  208.             If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
  209.                 If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  210.             End If
  211.             If Cap Then
  212.                 Parent.Location = MousePosition - MouseP
  213.             End If
  214.         End Sub
  215.  
  216.         Protected Overrides Sub OnInvalidated(ByVal e As System.Windows.Forms.InvalidateEventArgs)
  217.             MyBase.OnInvalidated(e)
  218.             ParentForm.Text = Text
  219.         End Sub
  220.  
  221.         Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
  222.             MyBase.OnPaintBackground(e)
  223.         End Sub
  224.  
  225.         Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  226.             MyBase.OnTextChanged(e)
  227.             Invalidate()
  228.         End Sub
  229.  
  230.         Private Sub FormShown(ByVal sender As Object, ByVal e As EventArgs)
  231.             If _ControlMode OrElse HasShown Then Return
  232.  
  233.             If _StartPosition = FormStartPosition.CenterParent OrElse _StartPosition = FormStartPosition.CenterScreen Then
  234.                 Dim SB As Rectangle = Screen.PrimaryScreen.Bounds
  235.                 Dim CB As Rectangle = ParentForm.Bounds
  236.                 ParentForm.Location = New Point(SB.Width \ 2 - CB.Width \ 2, SB.Height \ 2 - CB.Width \ 2)
  237.             End If
  238.             HasShown = True
  239.         End Sub
  240.  
  241. #End Region
  242. #Region " Mouse & Size "
  243.  
  244.         Private Sub SetState(ByVal current As MouseState)
  245.             State = current
  246.             Invalidate()
  247.         End Sub
  248.  
  249.         Private GetIndexPoint As Point
  250.         Private B1x, B2x, B3, B4 As Boolean
  251.         Private Function GetIndex() As Integer
  252.             GetIndexPoint = PointToClient(MousePosition)
  253.             B1x = GetIndexPoint.X < 7
  254.             B2x = GetIndexPoint.X > Width - 7
  255.             B3 = GetIndexPoint.Y < 7
  256.             B4 = GetIndexPoint.Y > Height - 7
  257.  
  258.             If B1x AndAlso B3 Then Return 4
  259.             If B1x AndAlso B4 Then Return 7
  260.             If B2x AndAlso B3 Then Return 5
  261.             If B2x AndAlso B4 Then Return 8
  262.             If B1x Then Return 1
  263.             If B2x Then Return 2
  264.             If B3 Then Return 3
  265.             If B4 Then Return 6
  266.             Return 0
  267.         End Function
  268.  
  269.         Private Current, Previous As Integer
  270.         Private Sub InvalidateMouse()
  271.             Current = GetIndex()
  272.             If Current = Previous Then Return
  273.  
  274.             Previous = Current
  275.             Select Case Previous
  276.                 Case 0
  277.                     Cursor = Cursors.Default
  278.                 Case 6
  279.                     Cursor = Cursors.SizeNS
  280.                 Case 8
  281.                     Cursor = Cursors.SizeNWSE
  282.                 Case 7
  283.                     Cursor = Cursors.SizeNESW
  284.             End Select
  285.         End Sub
  286.  
  287.         Private Messages(8) As Message
  288.         Private Sub InitializeMessages()
  289.             Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  290.             For I As Integer = 1 To 8
  291.                 Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
  292.             Next
  293.         End Sub
  294.  
  295.         Private Sub CorrectBounds(ByVal bounds As Rectangle)
  296.             If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
  297.             If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
  298.  
  299.             Dim X As Integer = Parent.Location.X
  300.             Dim Y As Integer = Parent.Location.Y
  301.  
  302.             If X < bounds.X Then X = bounds.X
  303.             If Y < bounds.Y Then Y = bounds.Y
  304.  
  305.             Dim Width As Integer = bounds.X + bounds.Width
  306.             Dim Height As Integer = bounds.Y + bounds.Height
  307.  
  308.             If X + Parent.Width > Width Then X = Width - Parent.Width
  309.             If Y + Parent.Height > Height Then Y = Height - Parent.Height
  310.  
  311.             Parent.Location = New Point(X, Y)
  312.         End Sub
  313.  
  314.         Private WM_LMBUTTONDOWN As Boolean
  315.         Protected Overrides Sub WndProc(ByRef m As Message)
  316.             MyBase.WndProc(m)
  317.  
  318.             If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
  319.                 WM_LMBUTTONDOWN = False
  320.  
  321.                 SetState(MouseState.Over)
  322.                 If Not _SmartBounds Then Return
  323.  
  324.                 If IsParentMdi Then
  325.                     CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
  326.                 Else
  327.                     CorrectBounds(Screen.FromControl(Parent).WorkingArea)
  328.                 End If
  329.             End If
  330.         End Sub
  331.  
  332. #End Region
  333.  
  334.         Protected Overrides Sub CreateHandle()
  335.             MyBase.CreateHandle()
  336.         End Sub
  337.  
  338.         Sub New()
  339.             SetStyle(DirectCast(139270, ControlStyles), True)
  340.             BackColor = Color.FromArgb(244, 241, 243)
  341.             Padding = New Padding(20, 56, 20, 16)
  342.             DoubleBuffered = True
  343.             Dock = DockStyle.Fill
  344.             MoveHeight = 48
  345.             Font = New Font("Segoe UI", 9)
  346.         End Sub
  347.  
  348.         Protected Overrides Sub OnPaint(e As PaintEventArgs)
  349.             MyBase.OnPaint(e)
  350.             Dim G As Graphics = e.Graphics
  351.             G.Clear(Color.FromArgb(69, 68, 63))
  352.  
  353.             G.DrawRectangle(New Pen(Color.FromArgb(38, 38, 38)), New Rectangle(0, 0, Width - 1, Height - 1))
  354.             ' Use [Color.FromArgb(87, 86, 81), Color.FromArgb(60, 59, 55)] for a darker taste
  355.             ' And replace each (60, 59, 55) with (69, 68, 63)
  356.             G.FillRectangle(New LinearGradientBrush(New Point(0, 0), New Point(0, 36), Color.FromArgb(87, 85, 77), Color.FromArgb(69, 68, 63)), New Rectangle(1, 1, Width - 2, 36))
  357.             G.FillRectangle(New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(69, 68, 63), Color.FromArgb(69, 68, 63)), New Rectangle(1, 36, Width - 2, Height - 46))
  358.  
  359.             G.DrawRectangle(New Pen(Color.FromArgb(38, 38, 38)), New Rectangle(9, 47, Width - 19, Height - 55))
  360.             G.FillRectangle(New SolidBrush(Color.FromArgb(244, 241, 243)), New Rectangle(10, 48, Width - 20, Height - 56))
  361.  
  362.             If _RoundCorners = True Then
  363.  
  364.                 ' Draw Left upper corner
  365.                 G.FillRectangle(Brushes.Fuchsia, 0, 0, 1, 1)
  366.                 G.FillRectangle(Brushes.Fuchsia, 1, 0, 1, 1)
  367.                 G.FillRectangle(Brushes.Fuchsia, 2, 0, 1, 1)
  368.                 G.FillRectangle(Brushes.Fuchsia, 3, 0, 1, 1)
  369.                 G.FillRectangle(Brushes.Fuchsia, 0, 1, 1, 1)
  370.                 G.FillRectangle(Brushes.Fuchsia, 0, 2, 1, 1)
  371.                 G.FillRectangle(Brushes.Fuchsia, 0, 3, 1, 1)
  372.                 G.FillRectangle(Brushes.Fuchsia, 1, 1, 1, 1)
  373.  
  374.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), 1, 3, 1, 1)
  375.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), 1, 2, 1, 1)
  376.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), 2, 1, 1, 1)
  377.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), 3, 1, 1, 1)
  378.  
  379.                 ' Draw right upper corner
  380.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, 0, 1, 1)
  381.                 G.FillRectangle(Brushes.Fuchsia, Width - 2, 0, 1, 1)
  382.                 G.FillRectangle(Brushes.Fuchsia, Width - 3, 0, 1, 1)
  383.                 G.FillRectangle(Brushes.Fuchsia, Width - 4, 0, 1, 1)
  384.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, 1, 1, 1)
  385.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, 2, 1, 1)
  386.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, 3, 1, 1)
  387.                 G.FillRectangle(Brushes.Fuchsia, Width - 2, 1, 1, 1)
  388.  
  389.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), Width - 2, 3, 1, 1)
  390.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), Width - 2, 2, 1, 1)
  391.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), Width - 3, 1, 1, 1)
  392.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), Width - 4, 1, 1, 1)
  393.  
  394.                 ' Draw Left bottom corner
  395.                 G.FillRectangle(Brushes.Fuchsia, 0, Height - 1, 1, 1)
  396.                 G.FillRectangle(Brushes.Fuchsia, 0, Height - 2, 1, 1)
  397.                 G.FillRectangle(Brushes.Fuchsia, 0, Height - 3, 1, 1)
  398.                 G.FillRectangle(Brushes.Fuchsia, 0, Height - 4, 1, 1)
  399.                 G.FillRectangle(Brushes.Fuchsia, 1, Height - 1, 1, 1)
  400.                 G.FillRectangle(Brushes.Fuchsia, 2, Height - 1, 1, 1)
  401.                 G.FillRectangle(Brushes.Fuchsia, 3, Height - 1, 1, 1)
  402.                 G.FillRectangle(Brushes.Fuchsia, 1, Height - 1, 1, 1)
  403.                 G.FillRectangle(Brushes.Fuchsia, 1, Height - 2, 1, 1)
  404.  
  405.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), 1, Height - 3, 1, 1)
  406.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), 1, Height - 4, 1, 1)
  407.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), 3, Height - 2, 1, 1)
  408.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), 2, Height - 2, 1, 1)
  409.  
  410.                 ' Draw right bottom corner
  411.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, Height, 1, 1)
  412.                 G.FillRectangle(Brushes.Fuchsia, Width - 2, Height, 1, 1)
  413.                 G.FillRectangle(Brushes.Fuchsia, Width - 3, Height, 1, 1)
  414.                 G.FillRectangle(Brushes.Fuchsia, Width - 4, Height, 1, 1)
  415.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, Height - 1, 1, 1)
  416.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, Height - 2, 1, 1)
  417.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, Height - 3, 1, 1)
  418.                 G.FillRectangle(Brushes.Fuchsia, Width - 2, Height - 1, 1, 1)
  419.                 G.FillRectangle(Brushes.Fuchsia, Width - 3, Height - 1, 1, 1)
  420.                 G.FillRectangle(Brushes.Fuchsia, Width - 4, Height - 1, 1, 1)
  421.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, Height - 4, 1, 1)
  422.                 G.FillRectangle(Brushes.Fuchsia, Width - 2, Height - 2, 1, 1)
  423.  
  424.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), Width - 2, Height - 3, 1, 1)
  425.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), Width - 2, Height - 4, 1, 1)
  426.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), Width - 4, Height - 2, 1, 1)
  427.                 G.FillRectangle(New SolidBrush(Color.FromArgb(38, 38, 38)), Width - 3, Height - 2, 1, 1)
  428.             End If
  429.  
  430.             G.DrawString(Text, New Font("Tahoma", 12, FontStyle.Bold), New SolidBrush(Color.FromArgb(223, 219, 210)), New Rectangle(0, 14, Width - 1, Height), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Near})
  431.         End Sub
  432.     End Class
  433.  
  434. #End Region
  435. #Region " ControlBox "
  436.  
  437.     Public Class Ambiance_ControlBox
  438.         Inherits Control
  439.  
  440. #Region " Enums "
  441.  
  442.         Enum MouseState As Byte
  443.             None = 0
  444.             Over = 1
  445.             Down = 2
  446.         End Enum
  447.  
  448. #End Region
  449. #Region " MouseStates "
  450.         Dim State As MouseState = MouseState.None
  451.         Dim X As Integer
  452.         Dim CloseBtn As New Rectangle(3, 2, 17, 17)
  453.         Dim MinBtn As New Rectangle(23, 2, 17, 17)
  454.         Dim MaxBtn As New Rectangle(43, 2, 17, 17)
  455.  
  456.         Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  457.             MyBase.OnMouseDown(e)
  458.  
  459.             State = MouseState.Down
  460.             Invalidate()
  461.         End Sub
  462.         Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  463.             MyBase.OnMouseUp(e)
  464.             If X > 3 AndAlso X < 20 Then
  465.                 FindForm.Close()
  466.             ElseIf X > 23 AndAlso X < 40 Then
  467.                 FindForm.WindowState = FormWindowState.Minimized
  468.             ElseIf X > 43 AndAlso X < 60 Then
  469.                 If _EnableMaximize = True Then
  470.                     If FindForm.WindowState = FormWindowState.Maximized Then
  471.                         FindForm.WindowState = FormWindowState.Minimized
  472.                         FindForm.WindowState = FormWindowState.Normal
  473.                     Else
  474.                         FindForm.WindowState = FormWindowState.Minimized
  475.                         FindForm.WindowState = FormWindowState.Maximized
  476.                     End If
  477.                 End If
  478.             End If
  479.             State = MouseState.Over
  480.             Invalidate()
  481.         End Sub
  482.         Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  483.             MyBase.OnMouseEnter(e)
  484.             State = MouseState.Over
  485.             Invalidate()
  486.         End Sub
  487.         Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  488.             MyBase.OnMouseLeave(e)
  489.             State = MouseState.None
  490.             Invalidate()
  491.         End Sub
  492.         Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  493.             MyBase.OnMouseMove(e)
  494.             X = e.Location.X
  495.             Invalidate()
  496.         End Sub
  497. #End Region
  498. #Region " Properties "
  499.  
  500.         Dim _EnableMaximize As Boolean = True
  501.         Property EnableMaximize() As Boolean
  502.             Get
  503.                 Return _EnableMaximize
  504.             End Get
  505.             Set(ByVal value As Boolean)
  506.                 _EnableMaximize = value
  507.                 If _EnableMaximize = True Then
  508.                     Me.Size = New Size(64, 22)
  509.                 Else
  510.                     Me.Size = New Size(44, 22)
  511.                 End If
  512.                 Invalidate()
  513.             End Set
  514.         End Property
  515.  
  516. #End Region
  517.  
  518.         Sub New()
  519.             SetStyle(ControlStyles.UserPaint Or _
  520.               ControlStyles.SupportsTransparentBackColor Or _
  521.               ControlStyles.ResizeRedraw Or _
  522.               ControlStyles.DoubleBuffer, True)
  523.             DoubleBuffered = True
  524.             BackColor = Color.Transparent
  525.             Font = New Font("Marlett", 7)
  526.             Anchor = AnchorStyles.Top Or AnchorStyles.Left
  527.         End Sub
  528.  
  529.         Protected Overrides Sub OnResize(e As EventArgs)
  530.             MyBase.OnResize(e)
  531.             If _EnableMaximize = True Then
  532.                 Me.Size = New Size(64, 22)
  533.             Else
  534.                 Me.Size = New Size(44, 22)
  535.             End If
  536.         End Sub
  537.  
  538.         Protected Overrides Sub OnCreateControl()
  539.             MyBase.OnCreateControl()
  540.             ' Auto-decide control location on the theme container
  541.             Location = New Point(5, 13)
  542.         End Sub
  543.  
  544.         Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  545.             Dim B As New Bitmap(Width, Height)
  546.             Dim G As Graphics = Graphics.FromImage(B)
  547.  
  548.             MyBase.OnPaint(e)
  549.             G.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
  550.  
  551.             Dim LGBClose As New LinearGradientBrush(CloseBtn, Color.FromArgb(242, 132, 99), Color.FromArgb(224, 82, 33), 90S)
  552.             G.FillEllipse(LGBClose, CloseBtn)
  553.             G.DrawEllipse(New Pen(Color.FromArgb(57, 56, 53)), CloseBtn)
  554.             G.DrawString("r", New Font("Marlett", 7), New SolidBrush(Color.FromArgb(52, 50, 46)), New Rectangle(6.5, 8, 0, 0))
  555.  
  556.             Dim LGBMinimize As New LinearGradientBrush(MinBtn, Color.FromArgb(130, 129, 123), Color.FromArgb(103, 102, 96), 90S)
  557.             G.FillEllipse(LGBMinimize, MinBtn)
  558.             G.DrawEllipse(New Pen(Color.FromArgb(57, 56, 53)), MinBtn)
  559.             G.DrawString("0", New Font("Marlett", 7), New SolidBrush(Color.FromArgb(52, 50, 46)), New Rectangle(26, 4.4, 0, 0))
  560.  
  561.             If _EnableMaximize = True Then
  562.                 Dim LGBMaximize As New LinearGradientBrush(MaxBtn, Color.FromArgb(130, 129, 123), Color.FromArgb(103, 102, 96), 90S)
  563.                 G.FillEllipse(LGBMaximize, MaxBtn)
  564.                 G.DrawEllipse(New Pen(Color.FromArgb(57, 56, 53)), MaxBtn)
  565.                 G.DrawString("1", New Font("Marlett", 7), New SolidBrush(Color.FromArgb(52, 50, 46)), New Rectangle(46, 7, 0, 0))
  566.             End If
  567.  
  568.             Select Case State
  569.                 Case MouseState.None
  570.                     Dim xLGBClose As New LinearGradientBrush(CloseBtn, Color.FromArgb(242, 132, 99), Color.FromArgb(224, 82, 33), 90S)
  571.                     G.FillEllipse(xLGBClose, CloseBtn)
  572.                     G.DrawEllipse(New Pen(Color.FromArgb(57, 56, 53)), CloseBtn)
  573.                     G.DrawString("r", New Font("Marlett", 7), New SolidBrush(Color.FromArgb(52, 50, 46)), New Rectangle(6.5, 8, 0, 0))
  574.  
  575.                     Dim xLGBMinimize As New LinearGradientBrush(MinBtn, Color.FromArgb(130, 129, 123), Color.FromArgb(103, 102, 96), 90S)
  576.                     G.FillEllipse(xLGBMinimize, MinBtn)
  577.                     G.DrawEllipse(New Pen(Color.FromArgb(57, 56, 53)), MinBtn)
  578.                     G.DrawString("0", New Font("Marlett", 7), New SolidBrush(Color.FromArgb(52, 50, 46)), New Rectangle(26, 4.4, 0, 0))
  579.  
  580.                     If _EnableMaximize = True Then
  581.                         Dim xLGBMaximize As New LinearGradientBrush(MaxBtn, Color.FromArgb(130, 129, 123), Color.FromArgb(103, 102, 96), 90S)
  582.                         G.FillEllipse(xLGBMaximize, MaxBtn)
  583.                         G.DrawEllipse(New Pen(Color.FromArgb(57, 56, 53)), MaxBtn)
  584.                         G.DrawString("1", New Font("Marlett", 7), New SolidBrush(Color.FromArgb(52, 50, 46)), New Rectangle(46, 7, 0, 0))
  585.                     End If
  586.                 Case MouseState.Over
  587.                     If X > 3 AndAlso X < 20 Then
  588.                         Dim xLGBClose As New LinearGradientBrush(CloseBtn, Color.FromArgb(248, 152, 124), Color.FromArgb(231, 92, 45), 90S)
  589.                         G.FillEllipse(xLGBClose, CloseBtn)
  590.                         G.DrawEllipse(New Pen(Color.FromArgb(57, 56, 53)), CloseBtn)
  591.                         G.DrawString("r", New Font("Marlett", 7), New SolidBrush(Color.FromArgb(52, 50, 46)), New Rectangle(6.5, 8, 0, 0))
  592.                     ElseIf X > 23 AndAlso X < 40 Then
  593.                         Dim xLGBMinimize As New LinearGradientBrush(MinBtn, Color.FromArgb(196, 196, 196), Color.FromArgb(173, 173, 173), 90S)
  594.                         G.FillEllipse(xLGBMinimize, MinBtn)
  595.                         G.DrawEllipse(New Pen(Color.FromArgb(57, 56, 53)), MinBtn)
  596.                         G.DrawString("0", New Font("Marlett", 7), New SolidBrush(Color.FromArgb(52, 50, 46)), New Rectangle(26, 4.4, 0, 0))
  597.                     ElseIf X > 43 AndAlso X < 60 Then
  598.                         If _EnableMaximize = True Then
  599.                             Dim xLGBMaximize As New LinearGradientBrush(MaxBtn, Color.FromArgb(196, 196, 196), Color.FromArgb(173, 173, 173), 90S)
  600.                             G.FillEllipse(xLGBMaximize, MaxBtn)
  601.                             G.DrawEllipse(New Pen(Color.FromArgb(57, 56, 53)), MaxBtn)
  602.                             G.DrawString("1", New Font("Marlett", 7), New SolidBrush(Color.FromArgb(52, 50, 46)), New Rectangle(46, 7, 0, 0))
  603.                         End If
  604.                     End If
  605.             End Select
  606.  
  607.             e.Graphics.DrawImage(B.Clone(), 0, 0)
  608.             G.Dispose()
  609.             B.Dispose()
  610.         End Sub
  611.     End Class
  612.  
  613. #End Region
  614. #Region " Button 1 "
  615.  
  616.     Class Ambiance_Button_1
  617.         Inherits Control
  618.  
  619. #Region " Variables "
  620.  
  621.         Private MouseState As Integer
  622.         Private Shape As GraphicsPath
  623.         Private InactiveGB, PressedGB, PressedContourGB As LinearGradientBrush
  624.         Private R1 As Rectangle
  625.         Private P1, P3 As Pen
  626.         Private _Image As Image
  627.         Private _ImageSize As Size
  628.         Private _TextAlignment As StringAlignment = StringAlignment.Center
  629.         Private _TextColor As Color = Color.FromArgb(150, 150, 150)
  630.         Private _ImageAlign As ContentAlignment = ContentAlignment.MiddleLeft
  631.  
  632. #End Region
  633. #Region " Image Designer "
  634.  
  635.         Private Shared Function ImageLocation(ByVal SF As StringFormat, ByVal Area As SizeF, ByVal ImageArea As SizeF) As PointF
  636.             Dim MyPoint As PointF
  637.             Select Case SF.Alignment
  638.                 Case StringAlignment.Center
  639.                     MyPoint.X = CSng((Area.Width - ImageArea.Width) / 2)
  640.                 Case StringAlignment.Near
  641.                     MyPoint.X = 2
  642.                 Case StringAlignment.Far
  643.                     MyPoint.X = Area.Width - ImageArea.Width - 2
  644.  
  645.             End Select
  646.  
  647.             Select Case SF.LineAlignment
  648.                 Case StringAlignment.Center
  649.                     MyPoint.Y = CSng((Area.Height - ImageArea.Height) / 2)
  650.                 Case StringAlignment.Near
  651.                     MyPoint.Y = 2
  652.                 Case StringAlignment.Far
  653.                     MyPoint.Y = Area.Height - ImageArea.Height - 2
  654.             End Select
  655.             Return MyPoint
  656.         End Function
  657.  
  658.         Private Function GetStringFormat(ByVal _ContentAlignment As ContentAlignment) As StringFormat
  659.             Dim SF As StringFormat = New StringFormat()
  660.             Select Case _ContentAlignment
  661.                 Case ContentAlignment.MiddleCenter
  662.                     SF.LineAlignment = StringAlignment.Center
  663.                     SF.Alignment = StringAlignment.Center
  664.                 Case ContentAlignment.MiddleLeft
  665.                     SF.LineAlignment = StringAlignment.Center
  666.                     SF.Alignment = StringAlignment.Near
  667.                 Case ContentAlignment.MiddleRight
  668.                     SF.LineAlignment = StringAlignment.Center
  669.                     SF.Alignment = StringAlignment.Far
  670.                 Case ContentAlignment.TopCenter
  671.                     SF.LineAlignment = StringAlignment.Near
  672.                     SF.Alignment = StringAlignment.Center
  673.                 Case ContentAlignment.TopLeft
  674.                     SF.LineAlignment = StringAlignment.Near
  675.                     SF.Alignment = StringAlignment.Near
  676.                 Case ContentAlignment.TopRight
  677.                     SF.LineAlignment = StringAlignment.Near
  678.                     SF.Alignment = StringAlignment.Far
  679.                 Case ContentAlignment.BottomCenter
  680.                     SF.LineAlignment = StringAlignment.Far
  681.                     SF.Alignment = StringAlignment.Center
  682.                 Case ContentAlignment.BottomLeft
  683.                     SF.LineAlignment = StringAlignment.Far
  684.                     SF.Alignment = StringAlignment.Near
  685.                 Case ContentAlignment.BottomRight
  686.                     SF.LineAlignment = StringAlignment.Far
  687.                     SF.Alignment = StringAlignment.Far
  688.             End Select
  689.             Return SF
  690.         End Function
  691.  
  692. #End Region
  693. #Region " Properties "
  694.  
  695.         Property Image() As Image
  696.             Get
  697.                 Return _Image
  698.             End Get
  699.             Set(ByVal value As Image)
  700.                 If value Is Nothing Then
  701.                     _ImageSize = Size.Empty
  702.                 Else
  703.                     _ImageSize = value.Size
  704.                 End If
  705.  
  706.                 _Image = value
  707.                 Invalidate()
  708.             End Set
  709.         End Property
  710.  
  711.         Protected ReadOnly Property ImageSize() As Size
  712.             Get
  713.                 Return _ImageSize
  714.             End Get
  715.         End Property
  716.  
  717.         Public Property ImageAlign() As ContentAlignment
  718.             Get
  719.                 Return _ImageAlign
  720.             End Get
  721.             Set(ByVal Value As ContentAlignment)
  722.                 _ImageAlign = Value
  723.                 Invalidate()
  724.             End Set
  725.         End Property
  726.  
  727.         Public Property TextAlignment As StringAlignment
  728.             Get
  729.                 Return Me._TextAlignment
  730.             End Get
  731.             Set(ByVal value As StringAlignment)
  732.                 Me._TextAlignment = value
  733.                 Me.Invalidate()
  734.             End Set
  735.         End Property
  736.  
  737.         Public Overrides Property ForeColor As Color
  738.             Get
  739.                 Return Me._TextColor
  740.             End Get
  741.             Set(ByVal value As Color)
  742.                 Me._TextColor = value
  743.                 Me.Invalidate()
  744.             End Set
  745.         End Property
  746.  
  747. #End Region
  748. #Region " EventArgs "
  749.  
  750.         Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  751.             MouseState = 0
  752.             Invalidate()
  753.             MyBase.OnMouseUp(e)
  754.         End Sub
  755.         Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  756.             MouseState = 1
  757.             Focus()
  758.             Invalidate()
  759.             MyBase.OnMouseDown(e)
  760.         End Sub
  761.  
  762.         Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  763.             MouseState = 0
  764.             Invalidate()
  765.             MyBase.OnMouseLeave(e)
  766.         End Sub
  767.  
  768.         Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  769.             Invalidate()
  770.             MyBase.OnTextChanged(e)
  771.         End Sub
  772.  
  773. #End Region
  774.  
  775.         Sub New()
  776.             SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  777.                      ControlStyles.OptimizedDoubleBuffer Or _
  778.                      ControlStyles.ResizeRedraw Or _
  779.                      ControlStyles.SupportsTransparentBackColor Or _
  780.                      ControlStyles.UserPaint, True)
  781.  
  782.             BackColor = Color.Transparent
  783.             DoubleBuffered = True
  784.             Font = New Font("Segoe UI", 12)
  785.             ForeColor = Color.FromArgb(76, 76, 76)
  786.             Size = New Size(177, 30)
  787.             _TextAlignment = StringAlignment.Center
  788.             P1 = New Pen(Color.FromArgb(180, 180, 180)) ' P1 = Border color
  789.         End Sub
  790.  
  791.         Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  792.             If Width > 0 AndAlso Height > 0 Then
  793.  
  794.                 Shape = New GraphicsPath
  795.                 R1 = New Rectangle(0, 0, Width, Height)
  796.  
  797.                 InactiveGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(253, 252, 252), Color.FromArgb(239, 237, 236), 90.0F)
  798.                 PressedGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(226, 226, 226), Color.FromArgb(237, 237, 237), 90.0F)
  799.                 PressedContourGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(167, 167, 167), Color.FromArgb(167, 167, 167), 90.0F)
  800.  
  801.                 P3 = New Pen(PressedContourGB)
  802.             End If
  803.  
  804.             With Shape
  805.                 .AddArc(0, 0, 10, 10, 180, 90)
  806.                 .AddArc(Width - 11, 0, 10, 10, -90, 90)
  807.                 .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  808.                 .AddArc(0, Height - 11, 10, 10, 90, 90)
  809.                 .CloseAllFigures()
  810.             End With
  811.             Invalidate()
  812.             MyBase.OnResize(e)
  813.         End Sub
  814.  
  815.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  816.             With e.Graphics
  817.                 .SmoothingMode = SmoothingMode.HighQuality
  818.                 Dim ipt As PointF = ImageLocation(GetStringFormat(ImageAlign), Size, ImageSize)
  819.  
  820.                 Select Case MouseState
  821.                     Case 0 'Inactive
  822.                         .FillPath(InactiveGB, Shape) ' Fill button body with InactiveGB color gradient
  823.                         .DrawPath(P1, Shape) ' Draw button border [InactiveGB]
  824.                         If IsNothing(Image) Then
  825.                             .DrawString(Text, Font, New SolidBrush(ForeColor), R1, New StringFormat() With {.Alignment = _TextAlignment, .LineAlignment = StringAlignment.Center})
  826.                         Else
  827.                             .DrawImage(_Image, ipt.X, ipt.Y, ImageSize.Width, ImageSize.Height)
  828.                             .DrawString(Text, Font, New SolidBrush(ForeColor), R1, New StringFormat() With {.Alignment = _TextAlignment, .LineAlignment = StringAlignment.Center})
  829.                         End If
  830.                     Case 1 'Pressed
  831.                         .FillPath(PressedGB, Shape) ' Fill button body with PressedGB color gradient
  832.                         .DrawPath(P3, Shape) ' Draw button border [PressedGB]
  833.  
  834.                         If IsNothing(Image) Then
  835.                             .DrawString(Text, Font, New SolidBrush(ForeColor), R1, New StringFormat() With {.Alignment = _TextAlignment, .LineAlignment = StringAlignment.Center})
  836.                         Else
  837.                             .DrawImage(_Image, ipt.X, ipt.Y, ImageSize.Width, ImageSize.Height)
  838.                             .DrawString(Text, Font, New SolidBrush(ForeColor), R1, New StringFormat() With {.Alignment = _TextAlignment, .LineAlignment = StringAlignment.Center})
  839.                         End If
  840.                 End Select
  841.             End With
  842.             MyBase.OnPaint(e)
  843.         End Sub
  844.     End Class
  845.  
  846. #End Region
  847. #Region " Button 2 "
  848.  
  849.     Class Ambiance_Button_2
  850.         Inherits Control
  851.  
  852. #Region " Variables "
  853.  
  854.         Private MouseState As Integer
  855.         Private Shape As GraphicsPath
  856.         Private InactiveGB, PressedGB, PressedContourGB As LinearGradientBrush
  857.         Private R1 As Rectangle
  858.         Private P1, P3 As Pen
  859.         Private _Image As Image
  860.         Private _ImageSize As Size
  861.         Private _TextAlignment As StringAlignment = StringAlignment.Center
  862.         Private _TextColor As Color = Color.FromArgb(150, 150, 150)
  863.         Private _ImageAlign As ContentAlignment = ContentAlignment.MiddleLeft
  864.  
  865. #End Region
  866. #Region " Image Designer "
  867.  
  868.         Private Shared Function ImageLocation(ByVal SF As StringFormat, ByVal Area As SizeF, ByVal ImageArea As SizeF) As PointF
  869.             Dim MyPoint As PointF
  870.             Select Case SF.Alignment
  871.                 Case StringAlignment.Center
  872.                     MyPoint.X = CSng((Area.Width - ImageArea.Width) / 2)
  873.                 Case StringAlignment.Near
  874.                     MyPoint.X = 2
  875.                 Case StringAlignment.Far
  876.                     MyPoint.X = Area.Width - ImageArea.Width - 2
  877.  
  878.             End Select
  879.  
  880.             Select Case SF.LineAlignment
  881.                 Case StringAlignment.Center
  882.                     MyPoint.Y = CSng((Area.Height - ImageArea.Height) / 2)
  883.                 Case StringAlignment.Near
  884.                     MyPoint.Y = 2
  885.                 Case StringAlignment.Far
  886.                     MyPoint.Y = Area.Height - ImageArea.Height - 2
  887.             End Select
  888.             Return MyPoint
  889.         End Function
  890.  
  891.         Private Function GetStringFormat(ByVal _ContentAlignment As ContentAlignment) As StringFormat
  892.             Dim SF As StringFormat = New StringFormat()
  893.             Select Case _ContentAlignment
  894.                 Case ContentAlignment.MiddleCenter
  895.                     SF.LineAlignment = StringAlignment.Center
  896.                     SF.Alignment = StringAlignment.Center
  897.                 Case ContentAlignment.MiddleLeft
  898.                     SF.LineAlignment = StringAlignment.Center
  899.                     SF.Alignment = StringAlignment.Near
  900.                 Case ContentAlignment.MiddleRight
  901.                     SF.LineAlignment = StringAlignment.Center
  902.                     SF.Alignment = StringAlignment.Far
  903.                 Case ContentAlignment.TopCenter
  904.                     SF.LineAlignment = StringAlignment.Near
  905.                     SF.Alignment = StringAlignment.Center
  906.                 Case ContentAlignment.TopLeft
  907.                     SF.LineAlignment = StringAlignment.Near
  908.                     SF.Alignment = StringAlignment.Near
  909.                 Case ContentAlignment.TopRight
  910.                     SF.LineAlignment = StringAlignment.Near
  911.                     SF.Alignment = StringAlignment.Far
  912.                 Case ContentAlignment.BottomCenter
  913.                     SF.LineAlignment = StringAlignment.Far
  914.                     SF.Alignment = StringAlignment.Center
  915.                 Case ContentAlignment.BottomLeft
  916.                     SF.LineAlignment = StringAlignment.Far
  917.                     SF.Alignment = StringAlignment.Near
  918.                 Case ContentAlignment.BottomRight
  919.                     SF.LineAlignment = StringAlignment.Far
  920.                     SF.Alignment = StringAlignment.Far
  921.             End Select
  922.             Return SF
  923.         End Function
  924.  
  925. #End Region
  926. #Region " Properties "
  927.  
  928.         Property Image() As Image
  929.             Get
  930.                 Return _Image
  931.             End Get
  932.             Set(ByVal value As Image)
  933.                 If value Is Nothing Then
  934.                     _ImageSize = Size.Empty
  935.                 Else
  936.                     _ImageSize = value.Size
  937.                 End If
  938.  
  939.                 _Image = value
  940.                 Invalidate()
  941.             End Set
  942.         End Property
  943.  
  944.         Protected ReadOnly Property ImageSize() As Size
  945.             Get
  946.                 Return _ImageSize
  947.             End Get
  948.         End Property
  949.  
  950.         Public Property ImageAlign() As ContentAlignment
  951.             Get
  952.                 Return _ImageAlign
  953.             End Get
  954.             Set(ByVal Value As ContentAlignment)
  955.                 _ImageAlign = Value
  956.                 Invalidate()
  957.             End Set
  958.         End Property
  959.  
  960.         Public Property TextAlignment As StringAlignment
  961.             Get
  962.                 Return Me._TextAlignment
  963.             End Get
  964.             Set(ByVal value As StringAlignment)
  965.                 Me._TextAlignment = value
  966.                 Me.Invalidate()
  967.             End Set
  968.         End Property
  969.  
  970.         Public Overrides Property ForeColor As Color
  971.             Get
  972.                 Return Me._TextColor
  973.             End Get
  974.             Set(ByVal value As Color)
  975.                 Me._TextColor = value
  976.                 Me.Invalidate()
  977.             End Set
  978.         End Property
  979.  
  980. #End Region
  981. #Region " EventArgs "
  982.  
  983.         Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  984.             MouseState = 0
  985.             Invalidate()
  986.             MyBase.OnMouseUp(e)
  987.         End Sub
  988.         Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  989.             MouseState = 1
  990.             Focus()
  991.             Invalidate()
  992.             MyBase.OnMouseDown(e)
  993.         End Sub
  994.  
  995.         Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  996.             MouseState = 0
  997.             Invalidate()
  998.             MyBase.OnMouseLeave(e)
  999.         End Sub
  1000.  
  1001.         Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  1002.             Invalidate()
  1003.             MyBase.OnTextChanged(e)
  1004.         End Sub
  1005.  
  1006. #End Region
  1007.  
  1008.         Sub New()
  1009.             SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  1010.                      ControlStyles.OptimizedDoubleBuffer Or _
  1011.                      ControlStyles.ResizeRedraw Or _
  1012.                      ControlStyles.SupportsTransparentBackColor Or _
  1013.                      ControlStyles.UserPaint, True)
  1014.  
  1015.             BackColor = Color.Transparent
  1016.             DoubleBuffered = True
  1017.             Font = New Font("Segoe UI", 11.0F, FontStyle.Bold)
  1018.             ForeColor = Color.FromArgb(76, 76, 76)
  1019.             Size = New Size(177, 30)
  1020.             _TextAlignment = StringAlignment.Center
  1021.             P1 = New Pen(Color.FromArgb(162, 120, 101)) ' P1 = Border color
  1022.         End Sub
  1023.  
  1024.         Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  1025.             If Width > 0 AndAlso Height > 0 Then
  1026.  
  1027.                 Shape = New GraphicsPath
  1028.                 R1 = New Rectangle(0, 0, Width, Height)
  1029.  
  1030.                 InactiveGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(253, 175, 143), Color.FromArgb(244, 146, 106), 90.0F)
  1031.                 PressedGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(244, 146, 106), Color.FromArgb(244, 146, 106), 90.0F)
  1032.                 PressedContourGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(162, 120, 101), Color.FromArgb(162, 120, 101), 90.0F)
  1033.  
  1034.                 P3 = New Pen(PressedContourGB)
  1035.             End If
  1036.  
  1037.             With Shape
  1038.                 .AddArc(0, 0, 10, 10, 180, 90)
  1039.                 .AddArc(Width - 11, 0, 10, 10, -90, 90)
  1040.                 .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  1041.                 .AddArc(0, Height - 11, 10, 10, 90, 90)
  1042.                 .CloseAllFigures()
  1043.             End With
  1044.             Invalidate()
  1045.             MyBase.OnResize(e)
  1046.         End Sub
  1047.  
  1048.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1049.             With e.Graphics
  1050.                 .SmoothingMode = SmoothingMode.HighQuality
  1051.                 Dim ipt As PointF = ImageLocation(GetStringFormat(ImageAlign), Size, ImageSize)
  1052.  
  1053.                 Select Case MouseState
  1054.                     Case 0 'Inactive
  1055.                         .FillPath(InactiveGB, Shape) ' Fill button body with InactiveGB color gradient
  1056.                         .DrawPath(P1, Shape) ' Draw button border [InactiveGB]
  1057.                         If IsNothing(Image) Then
  1058.                             .DrawString(Text, Font, New SolidBrush(ForeColor), R1, New StringFormat() With {.Alignment = _TextAlignment, .LineAlignment = StringAlignment.Center})
  1059.                         Else
  1060.                             .DrawImage(_Image, ipt.X, ipt.Y, ImageSize.Width, ImageSize.Height)
  1061.                             .DrawString(Text, Font, New SolidBrush(ForeColor), R1, New StringFormat() With {.Alignment = _TextAlignment, .LineAlignment = StringAlignment.Center})
  1062.                         End If
  1063.                     Case 1 'Pressed
  1064.                         .FillPath(PressedGB, Shape) ' Fill button body with PressedGB color gradient
  1065.                         .DrawPath(P3, Shape) ' Draw button border [PressedGB]
  1066.  
  1067.                         If IsNothing(Image) Then
  1068.                             .DrawString(Text, Font, New SolidBrush(ForeColor), R1, New StringFormat() With {.Alignment = _TextAlignment, .LineAlignment = StringAlignment.Center})
  1069.                         Else
  1070.                             .DrawImage(_Image, ipt.X, ipt.Y, ImageSize.Width, ImageSize.Height)
  1071.                             .DrawString(Text, Font, New SolidBrush(ForeColor), R1, New StringFormat() With {.Alignment = _TextAlignment, .LineAlignment = StringAlignment.Center})
  1072.                         End If
  1073.                 End Select
  1074.             End With
  1075.             MyBase.OnPaint(e)
  1076.         End Sub
  1077.     End Class
  1078.  
  1079. #End Region
  1080. #Region " Label "
  1081.  
  1082.     Class Ambiance_Label
  1083.         Inherits Label
  1084.  
  1085.         Sub New()
  1086.             Font = New Font("Segoe UI", 11)
  1087.             ForeColor = Color.FromArgb(76, 76, 77)
  1088.             BackColor = Color.Transparent
  1089.         End Sub
  1090.     End Class
  1091.  
  1092. #End Region
  1093. #Region " Link Label "
  1094.     Class Ambiance_LinkLabel
  1095.         Inherits LinkLabel
  1096.  
  1097.         Sub New()
  1098.             Font = New Font("Segoe UI", 11, FontStyle.Regular)
  1099.             BackColor = Color.Transparent
  1100.             LinkColor = Color.FromArgb(240, 119, 70)
  1101.             ActiveLinkColor = Color.FromArgb(221, 72, 20)
  1102.             VisitedLinkColor = Color.FromArgb(240, 119, 70)
  1103.             LinkBehavior = Windows.Forms.LinkBehavior.AlwaysUnderline
  1104.         End Sub
  1105.     End Class
  1106.  
  1107. #End Region
  1108. #Region " Header Label "
  1109.  
  1110.     Class Ambiance_HeaderLabel
  1111.         Inherits Label
  1112.  
  1113.         Sub New()
  1114.             Font = New Font("Segoe UI", 11, FontStyle.Bold)
  1115.             ForeColor = Color.FromArgb(76, 76, 77)
  1116.             BackColor = Color.Transparent
  1117.         End Sub
  1118.     End Class
  1119.  
  1120. #End Region
  1121. #Region " Separator "
  1122.  
  1123.     Public Class Ambiance_Separator
  1124.         Inherits Control
  1125.  
  1126.         Sub New()
  1127.             SetStyle(ControlStyles.ResizeRedraw, True)
  1128.             Me.Size = New Point(120, 10)
  1129.         End Sub
  1130.  
  1131.         Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  1132.             MyBase.OnPaint(e)
  1133.             e.Graphics.DrawLine(New Pen(Color.FromArgb(224, 222, 220)), 0, 5, Width, 5)
  1134.             e.Graphics.DrawLine(New Pen(Color.FromArgb(250, 249, 249)), 0, 6, Width, 6)
  1135.         End Sub
  1136.     End Class
  1137.  
  1138. #End Region
  1139. #Region " ProgressBar "
  1140.  
  1141.     Public Class Ambiance_ProgressBar
  1142.         Inherits Control
  1143.  
  1144. #Region " Enums "
  1145.  
  1146.         Public Enum Alignment
  1147.             Right
  1148.             Center
  1149.         End Enum
  1150.  
  1151. #End Region
  1152. #Region " Variables "
  1153.  
  1154.         Private _Minimum As Integer
  1155.         Private _Maximum As Integer = 100
  1156.         Private _Value As Integer = 0
  1157.         Private ALN As Alignment
  1158.         Private _DrawHatch As Boolean
  1159.         Private _ShowPercentage As Boolean
  1160.  
  1161.         Private GP1, GP2, GP3 As GraphicsPath
  1162.         Private R1, R2 As Rectangle
  1163.         Private GB1, GB2 As LinearGradientBrush
  1164.         Private I1 As Integer
  1165.  
  1166. #End Region
  1167. #Region " Properties "
  1168.  
  1169.         Public Property Maximum() As Integer
  1170.             Get
  1171.                 Return _Maximum
  1172.             End Get
  1173.             Set(ByVal V As Integer)
  1174.                 If V < 1 Then V = 1
  1175.                 If V < _Value Then _Value = V
  1176.                 _Maximum = V
  1177.                 Invalidate()
  1178.             End Set
  1179.         End Property
  1180.  
  1181.         Public Property Minimum() As Integer
  1182.             Get
  1183.                 Return _Minimum
  1184.             End Get
  1185.             Set(ByVal value As Integer)
  1186.                 _Minimum = value
  1187.  
  1188.                 If value > _Maximum Then _Maximum = value
  1189.                 If value > _Value Then _Value = value
  1190.  
  1191.                 Invalidate()
  1192.             End Set
  1193.         End Property
  1194.  
  1195.         Public Property Value() As Integer
  1196.             Get
  1197.                 Return _Value
  1198.             End Get
  1199.             Set(ByVal V As Integer)
  1200.                 If V > _Maximum Then V = Maximum
  1201.                 _Value = V
  1202.                 Invalidate()
  1203.             End Set
  1204.         End Property
  1205.  
  1206.         Public Property ValueAlignment() As Alignment
  1207.             Get
  1208.                 Return ALN
  1209.             End Get
  1210.             Set(ByVal value As Alignment)
  1211.                 ALN = value
  1212.                 Invalidate()
  1213.             End Set
  1214.         End Property
  1215.  
  1216.         Property DrawHatch() As Boolean
  1217.             Get
  1218.                 Return _DrawHatch
  1219.             End Get
  1220.             Set(ByVal v As Boolean)
  1221.                 _DrawHatch = v
  1222.                 Invalidate()
  1223.             End Set
  1224.         End Property
  1225.  
  1226.         Property ShowPercentage() As Boolean
  1227.             Get
  1228.                 Return _ShowPercentage
  1229.             End Get
  1230.             Set(ByVal v As Boolean)
  1231.                 _ShowPercentage = v
  1232.                 Invalidate()
  1233.             End Set
  1234.         End Property
  1235.  
  1236. #End Region
  1237. #Region " EventArgs "
  1238.  
  1239.         Protected Overrides Sub OnResize(e As EventArgs)
  1240.             MyBase.OnResize(e)
  1241.             Me.Height = 20
  1242.             Dim minimumSize As New Size(58, 20)
  1243.             Me.MinimumSize = minimumSize
  1244.         End Sub
  1245.  
  1246. #End Region
  1247.  
  1248.         Sub New()
  1249.             _Maximum = 100
  1250.             _ShowPercentage = True
  1251.             _DrawHatch = True
  1252.             SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  1253.             SetStyle(ControlStyles.UserPaint, True)
  1254.             BackColor = Color.Transparent
  1255.             DoubleBuffered = True
  1256.         End Sub
  1257.  
  1258.         Public Sub Increment(value As Integer)
  1259.             Me._Value += value
  1260.             Invalidate()
  1261.         End Sub
  1262.  
  1263.         Public Sub Deincrement(value As Integer)
  1264.             Me._Value -= value
  1265.             Invalidate()
  1266.         End Sub
  1267.  
  1268.         Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1269.             MyBase.OnPaint(e)
  1270.             Dim B As New Bitmap(Width, Height)
  1271.             Dim G As Graphics = Graphics.FromImage(B)
  1272.  
  1273.             G.Clear(Color.Transparent)
  1274.             G.SmoothingMode = SmoothingMode.HighQuality
  1275.  
  1276.             GP1 = RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 4)
  1277.             GP2 = RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 4)
  1278.  
  1279.             R1 = New Rectangle(0, 2, Width - 1, Height - 1)
  1280.             GB1 = New LinearGradientBrush(R1, Color.FromArgb(255, 255, 255), Color.FromArgb(230, 230, 230), 90.0F)
  1281.  
  1282.             ' Draw inside background
  1283.             G.FillRectangle(New SolidBrush(Color.FromArgb(244, 241, 243)), R1)
  1284.             G.SetClip(GP1)
  1285.             G.FillPath(New SolidBrush(Color.FromArgb(244, 241, 243)), RoundRect(New Rectangle(1, 1, Width - 3, Height / 2 - 2), 4))
  1286.  
  1287.  
  1288.             I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 3))
  1289.             If I1 > 1 Then
  1290.                 GP3 = RoundRect(New Rectangle(1, 1, I1, Height - 3), 4)
  1291.  
  1292.                 R2 = New Rectangle(1, 1, I1, Height - 3)
  1293.                 GB2 = New LinearGradientBrush(R2, Color.FromArgb(214, 89, 37), Color.FromArgb(223, 118, 75), 90.0F)
  1294.  
  1295.                 ' Fill the value with its gradient
  1296.                 G.FillPath(GB2, GP3)
  1297.  
  1298.                 ' Draw diagonal lines
  1299.                 If _DrawHatch = True Then
  1300.                     For i = 0 To (Width - 1) * _Maximum / _Value Step 20
  1301.                         G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(25, Color.White)), 10.0F), New Point(i, 0), New Point(i - 10, Height))
  1302.                     Next
  1303.                 End If
  1304.  
  1305.                 G.SetClip(GP3)
  1306.                 G.SmoothingMode = SmoothingMode.None
  1307.                 G.SmoothingMode = SmoothingMode.AntiAlias
  1308.                 G.ResetClip()
  1309.             End If
  1310.  
  1311.             ' Draw value as a string
  1312.             Dim DrawString As String = CStr(CInt(Value)) & "%"
  1313.             Dim textX As Integer = Me.Width - G.MeasureString(DrawString, Font).Width - 1
  1314.             Dim textY As Integer = (Me.Height / 2) - (G.MeasureString(DrawString, Font).Height / 2 - 2)
  1315.  
  1316.             If _ShowPercentage = True Then
  1317.                 Select Case ValueAlignment
  1318.                     Case Alignment.Right
  1319.                         G.DrawString(DrawString, New Font("Segoe UI", 8), Brushes.DimGray, New Point(textX, textY))
  1320.                     Case Alignment.Center
  1321.                         G.DrawString(DrawString, New Font("Segoe UI", 8), Brushes.DimGray, _
  1322.                                      New Rectangle(0, 0, Width, Height + 2), _
  1323.                                      New StringFormat() With {.Alignment = StringAlignment.Center, _
  1324.                                                               .LineAlignment = StringAlignment.Center})
  1325.                 End Select
  1326.             End If
  1327.  
  1328.             ' Draw border
  1329.             G.DrawPath(New Pen(Color.FromArgb(180, 180, 180)), GP2)
  1330.  
  1331.             e.Graphics.DrawImage(B.Clone(), 0, 0)
  1332.             G.Dispose()
  1333.             B.Dispose()
  1334.         End Sub
  1335.     End Class
  1336.  
  1337. #End Region
  1338. #Region " Progress Indicator "
  1339.  
  1340.     Class Ambiance_ProgressIndicator
  1341.         Inherits Control
  1342.  
  1343. #Region " Variables "
  1344.  
  1345.         Private ReadOnly BaseColor As New SolidBrush(Color.FromArgb(76, 76, 76))
  1346.         Private ReadOnly AnimationColor As New SolidBrush(Color.Gray)
  1347.         Private ReadOnly AnimationSpeed As New Timer()
  1348.  
  1349.         Private FloatPoint As PointF()
  1350.         Private BuffGraphics As BufferedGraphics
  1351.         Private IndicatorIndex As Integer
  1352.         Private ReadOnly GraphicsContext As BufferedGraphicsContext = BufferedGraphicsManager.Current
  1353.  
  1354. #End Region
  1355. #Region " Properties "
  1356.  
  1357.         Public Property P_BaseColor() As Color
  1358.             Get
  1359.                 Return BaseColor.Color
  1360.             End Get
  1361.             Set(val As Color)
  1362.                 BaseColor.Color = val
  1363.             End Set
  1364.         End Property
  1365.  
  1366.         Public Property P_AnimationColor() As Color
  1367.             Get
  1368.                 Return AnimationColor.Color
  1369.             End Get
  1370.             Set(val As Color)
  1371.                 AnimationColor.Color = val
  1372.             End Set
  1373.         End Property
  1374.  
  1375.         Public Property P_AnimationSpeed() As Integer
  1376.             Get
  1377.                 Return AnimationSpeed.Interval
  1378.             End Get
  1379.             Set(val As Integer)
  1380.                 AnimationSpeed.Interval = val
  1381.             End Set
  1382.         End Property
  1383.  
  1384. #End Region
  1385. #Region " EventArgs "
  1386.  
  1387.         Protected Overrides Sub OnSizeChanged(e As EventArgs)
  1388.             MyBase.OnSizeChanged(e)
  1389.             SetStandardSize()
  1390.             UpdateGraphics()
  1391.             SetPoints()
  1392.         End Sub
  1393.  
  1394.         Protected Overrides Sub OnEnabledChanged(e As EventArgs)
  1395.             MyBase.OnEnabledChanged(e)
  1396.             AnimationSpeed.Enabled = Me.Enabled
  1397.         End Sub
  1398.  
  1399.         Protected Overrides Sub OnHandleCreated(e As EventArgs)
  1400.             MyBase.OnHandleCreated(e)
  1401.             AddHandler AnimationSpeed.Tick, AddressOf AnimationSpeed_Tick
  1402.             AnimationSpeed.Start()
  1403.         End Sub
  1404.  
  1405.         Private Sub AnimationSpeed_Tick(sender As Object, e As EventArgs)
  1406.             If IndicatorIndex.Equals(0) Then
  1407.                 IndicatorIndex = FloatPoint.Length - 1
  1408.             Else
  1409.                 IndicatorIndex -= 1
  1410.             End If
  1411.             Me.Invalidate(False)
  1412.         End Sub
  1413.  
  1414. #End Region
  1415.  
  1416.         Public Sub New()
  1417.             Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  1418.                         ControlStyles.UserPaint Or _
  1419.                         ControlStyles.ResizeRedraw Or _
  1420.                         ControlStyles.OptimizedDoubleBuffer, True)
  1421.  
  1422.             Size = New Size(80, 80)
  1423.             Text = String.Empty
  1424.             MinimumSize = New Size(80, 80)
  1425.             SetPoints()
  1426.             AnimationSpeed.Interval = 110
  1427.         End Sub
  1428.  
  1429.         Private Sub SetStandardSize()
  1430.             Dim _Size As Integer = Math.Max(Width, Height)
  1431.             Size = New Size(_Size, _Size)
  1432.         End Sub
  1433.  
  1434.         Private Sub SetPoints()
  1435.             Dim FPStack = New Stack(Of PointF)()
  1436.             Dim centerPoint As New PointF(Me.Width / 2.0F, Me.Height / 2.0F)
  1437.             Dim i As Single = 0
  1438.  
  1439.             While i < 360.0F
  1440.                 SetValue(centerPoint, Me.Width / 2 - 15, i)
  1441.                 Dim FP As PointF = EndPoint
  1442.                 FP = New PointF(FP.X - 15 / 2.0F, FP.Y - 15 / 2.0F)
  1443.                 FPStack.Push(FP)
  1444.                 i += 360.0F / 8
  1445.             End While
  1446.             FloatPoint = FPStack.ToArray()
  1447.         End Sub
  1448.  
  1449.         Private Sub UpdateGraphics()
  1450.             If Me.Width > 0 AndAlso Me.Height > 0 Then
  1451.                 GraphicsContext.MaximumBuffer = New Size(Me.Width + 1, Me.Height + 1)
  1452.                 BuffGraphics = GraphicsContext.Allocate(Me.CreateGraphics(), Me.ClientRectangle)
  1453.                 BuffGraphics.Graphics.SmoothingMode = SmoothingMode.AntiAlias
  1454.             End If
  1455.         End Sub
  1456.  
  1457.         Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1458.             MyBase.OnPaint(e)
  1459.             BuffGraphics.Graphics.Clear(Me.BackColor)
  1460.  
  1461.             For i As Integer = 0 To FloatPoint.Length - 1
  1462.                 If IndicatorIndex = i Then
  1463.                     BuffGraphics.Graphics.FillEllipse(AnimationColor, FloatPoint(i).X, FloatPoint(i).Y, 15, 15)
  1464.                 Else
  1465.                     BuffGraphics.Graphics.FillEllipse(BaseColor, FloatPoint(i).X, FloatPoint(i).Y, 15, 15)
  1466.                 End If
  1467.             Next
  1468.             BuffGraphics.Render(e.Graphics)
  1469.         End Sub
  1470.  
  1471.         Private Rise As Double, Run As Double
  1472.         Private _StartingFloatPoint As PointF
  1473.  
  1474.         Private Function AssignValues(Of X)(ByRef Run As X, Length As X) As X
  1475.             Run = Length
  1476.             Return Length
  1477.         End Function
  1478.  
  1479.         Private Sub SetValue(StartingFloatPoint As PointF, Length As Integer, Angle As Double)
  1480.             Dim CircleRadian As Double = Math.PI * Angle / 180.0
  1481.  
  1482.             _StartingFloatPoint = StartingFloatPoint
  1483.             Rise = AssignValues(Run, Length)
  1484.             Rise = Math.Sin(CircleRadian) * Rise
  1485.             Run = Math.Cos(CircleRadian) * Run
  1486.         End Sub
  1487.  
  1488.         Private ReadOnly Property EndPoint() As PointF
  1489.             Get
  1490.                 Dim LocationX As Single = CSng(_StartingFloatPoint.Y + Rise)
  1491.                 Dim LocationY As Single = CSng(_StartingFloatPoint.X + Run)
  1492.                 Return New PointF(LocationY, LocationX)
  1493.             End Get
  1494.         End Property
  1495.     End Class
  1496.  
  1497. #End Region
  1498. #Region " Toggle Button "
  1499.  
  1500.     <DefaultEvent("ToggledChanged")> Class Ambiance_Toggle
  1501.         Inherits Control
  1502.  
  1503. #Region " Enums "
  1504.  
  1505.         Enum _Type
  1506.             OnOff
  1507.             YesNo
  1508.             IO
  1509.         End Enum
  1510.  
  1511. #End Region
  1512. #Region " Variables "
  1513.  
  1514.         Event ToggledChanged()
  1515.         Private _Toggled As Boolean
  1516.         Private ToggleType As _Type
  1517.         Private Bar As Rectangle
  1518.         Private cHandle As Size = New Size(15, 20)
  1519.  
  1520. #End Region
  1521. #Region " Properties "
  1522.  
  1523.         Public Property Toggled() As Boolean
  1524.             Get
  1525.                 Return _Toggled
  1526.             End Get
  1527.             Set(ByVal value As Boolean)
  1528.                 _Toggled = value
  1529.                 Invalidate()
  1530.                 RaiseEvent ToggledChanged()
  1531.             End Set
  1532.         End Property
  1533.  
  1534.         Public Property Type As _Type
  1535.             Get
  1536.                 Return ToggleType
  1537.             End Get
  1538.             Set(value As _Type)
  1539.                 ToggleType = value
  1540.                 Invalidate()
  1541.             End Set
  1542.         End Property
  1543.  
  1544. #End Region
  1545. #Region " EventArgs "
  1546.  
  1547.         Protected Overrides Sub OnResize(e As EventArgs)
  1548.             MyBase.OnResize(e)
  1549.             Width = 79
  1550.             Height = 27
  1551.         End Sub
  1552.  
  1553.         Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  1554.             MyBase.OnMouseUp(e)
  1555.             Toggled = Not Toggled
  1556.             Focus()
  1557.         End Sub
  1558.  
  1559. #End Region
  1560.  
  1561.         Sub New()
  1562.             SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  1563.                       ControlStyles.DoubleBuffer Or _
  1564.                       ControlStyles.ResizeRedraw Or _
  1565.                       ControlStyles.UserPaint, True)
  1566.         End Sub
  1567.  
  1568.         Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  1569.             MyBase.OnPaint(e)
  1570.             Dim G As Graphics = e.Graphics
  1571.  
  1572.             G.SmoothingMode = SmoothingMode.HighQuality
  1573.             G.Clear(Parent.BackColor)
  1574.  
  1575.             Dim SwitchXLoc As Integer = 3
  1576.             Dim ControlRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
  1577.             Dim ControlPath As GraphicsPath = RoundRect(ControlRectangle, 4)
  1578.  
  1579.             Dim BackgroundLGB As LinearGradientBrush
  1580.             If _Toggled Then
  1581.                 SwitchXLoc = 37
  1582.                 BackgroundLGB = New LinearGradientBrush(ControlRectangle, Color.FromArgb(231, 108, 58), Color.FromArgb(236, 113, 63), 90.0F)
  1583.             Else
  1584.                 SwitchXLoc = 0
  1585.                 BackgroundLGB = New LinearGradientBrush(ControlRectangle, Color.FromArgb(208, 208, 208), Color.FromArgb(226, 226, 226), 90.0F)
  1586.             End If
  1587.  
  1588.             ' Fill inside background gradient
  1589.             G.FillPath(BackgroundLGB, ControlPath)
  1590.  
  1591.             ' Draw string
  1592.             Select Case ToggleType
  1593.                 Case _Type.OnOff
  1594.                     If Toggled Then
  1595.                         G.DrawString("ON", New Font("Segoe UI", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, Bar.Y + 13.5, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1596.                     Else
  1597.                         G.DrawString("OFF", New Font("Segoe UI", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 59, Bar.Y + 13.5, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1598.                     End If
  1599.                 Case _Type.YesNo
  1600.                     If Toggled Then
  1601.                         G.DrawString("YES", New Font("Segoe UI", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, Bar.Y + 13.5, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1602.                     Else
  1603.                         G.DrawString("NO", New Font("Segoe UI", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 59, Bar.Y + 13.5, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1604.                     End If
  1605.                 Case _Type.IO
  1606.                     If Toggled Then
  1607.                         G.DrawString("I", New Font("Segoe UI", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, Bar.Y + 13.5, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1608.                     Else
  1609.                         G.DrawString("O", New Font("Segoe UI", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 59, Bar.Y + 13.5, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1610.                     End If
  1611.             End Select
  1612.  
  1613.             Dim SwitchRectangle As New Rectangle(SwitchXLoc, 0, Width - 38, Height)
  1614.             Dim SwitchPath As GraphicsPath = RoundRect(SwitchRectangle, 4)
  1615.             Dim SwitchButtonLGB As New LinearGradientBrush(SwitchRectangle, Color.FromArgb(253, 253, 253), Color.FromArgb(240, 238, 237), LinearGradientMode.Vertical)
  1616.  
  1617.             ' Fill switch background gradient
  1618.             G.FillPath(SwitchButtonLGB, SwitchPath)
  1619.  
  1620.             ' Draw borders
  1621.             If _Toggled = True Then
  1622.                 G.DrawPath(New Pen(Color.FromArgb(185, 89, 55)), SwitchPath)
  1623.                 G.DrawPath(New Pen(Color.FromArgb(185, 89, 55)), ControlPath)
  1624.             Else
  1625.                 G.DrawPath(New Pen(Color.FromArgb(181, 181, 181)), SwitchPath)
  1626.                 G.DrawPath(New Pen(Color.FromArgb(181, 181, 181)), ControlPath)
  1627.             End If
  1628.         End Sub
  1629.     End Class
  1630.  
  1631. #End Region
  1632. #Region " CheckBox "
  1633.  
  1634.     <DefaultEvent("CheckedChanged")> Class Ambiance_CheckBox
  1635.         Inherits Control
  1636.  
  1637. #Region " Variables "
  1638.  
  1639.         Private Shape As GraphicsPath
  1640.         Private GB As LinearGradientBrush
  1641.         Private R1, R2 As Rectangle
  1642.         Private _Checked As Boolean
  1643.         Event CheckedChanged(ByVal sender As Object)
  1644.  
  1645. #End Region
  1646. #Region " Properties "
  1647.  
  1648.         Property Checked As Boolean
  1649.             Get
  1650.                 Return _Checked
  1651.             End Get
  1652.             Set(ByVal value As Boolean)
  1653.                 _Checked = value
  1654.                 RaiseEvent CheckedChanged(Me)
  1655.                 Invalidate()
  1656.             End Set
  1657.         End Property
  1658.  
  1659. #End Region
  1660.  
  1661.         Sub New()
  1662.             SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  1663.                      ControlStyles.OptimizedDoubleBuffer Or _
  1664.                      ControlStyles.ResizeRedraw Or _
  1665.                      ControlStyles.SupportsTransparentBackColor Or _
  1666.                      ControlStyles.UserPaint, True)
  1667.  
  1668.             BackColor = Color.Transparent
  1669.             DoubleBuffered = True ' Reduce control flicker
  1670.             Font = New Font("Segoe UI", 12)
  1671.             Size = New Size(171, 26)
  1672.         End Sub
  1673.  
  1674.         Protected Overrides Sub OnClick(ByVal e As EventArgs)
  1675.             _Checked = Not _Checked
  1676.             RaiseEvent CheckedChanged(Me)
  1677.             Focus()
  1678.             Invalidate()
  1679.             MyBase.OnClick(e)
  1680.         End Sub
  1681.  
  1682.         Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  1683.             Invalidate()
  1684.             MyBase.OnTextChanged(e)
  1685.         End Sub
  1686.  
  1687.         Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  1688.             If Width > 0 AndAlso Height > 0 Then
  1689.                 Shape = New GraphicsPath
  1690.  
  1691.                 R1 = New Rectangle(17, 0, Width, Height + 1)
  1692.                 R2 = New Rectangle(0, 0, Width, Height)
  1693.                 GB = New LinearGradientBrush(New Rectangle(0, 0, 25, 25), Color.FromArgb(213, 85, 32), Color.FromArgb(224, 123, 82), 90)
  1694.  
  1695.                 With Shape
  1696.                     .AddArc(0, 0, 7, 7, 180, 90)
  1697.                     .AddArc(7, 0, 7, 7, -90, 90)
  1698.                     .AddArc(7, 7, 7, 7, 0, 90)
  1699.                     .AddArc(0, 7, 7, 7, 90, 90)
  1700.                     .CloseAllFigures()
  1701.                 End With
  1702.                 Height = 15
  1703.             End If
  1704.  
  1705.             Invalidate()
  1706.             MyBase.OnResize(e)
  1707.         End Sub
  1708.  
  1709.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1710.             MyBase.OnPaint(e)
  1711.  
  1712.             With e.Graphics
  1713.                 .Clear(Parent.BackColor)
  1714.                 .SmoothingMode = SmoothingMode.AntiAlias
  1715.  
  1716.                 .FillPath(GB, Shape) ' Fill the body of the CheckBox
  1717.                 .DrawPath(New Pen(Color.FromArgb(182, 88, 55)), Shape) ' Draw the border
  1718.  
  1719.                 .DrawString(Text, Font, New SolidBrush(Color.FromArgb(76, 76, 95)), R1, New StringFormat() With {.LineAlignment = StringAlignment.Center})
  1720.  
  1721.                 If Checked Then
  1722.                     .DrawString("ü", New Font("Wingdings", 12), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(-2, 1, Width, Height + 2), New StringFormat() With {.LineAlignment = StringAlignment.Center})
  1723.                 End If
  1724.             End With
  1725.             e.Dispose()
  1726.         End Sub
  1727.     End Class
  1728.  
  1729. #End Region
  1730. #Region " RadioButton "
  1731.  
  1732.     <DefaultEvent("CheckedChanged")> Class Ambiance_RadioButton
  1733.         Inherits Control
  1734.  
  1735. #Region " Enums "
  1736.  
  1737.         Enum MouseState As Byte
  1738.             None = 0
  1739.             Over = 1
  1740.             Down = 2
  1741.             Block = 3
  1742.         End Enum
  1743.  
  1744. #End Region
  1745. #Region " Variables "
  1746.  
  1747.         Private _Checked As Boolean
  1748.         Event CheckedChanged(ByVal sender As Object)
  1749.  
  1750. #End Region
  1751. #Region " Properties "
  1752.  
  1753.         Property Checked() As Boolean
  1754.             Get
  1755.                 Return _Checked
  1756.             End Get
  1757.             Set(ByVal value As Boolean)
  1758.                 _Checked = value
  1759.                 InvalidateControls()
  1760.                 RaiseEvent CheckedChanged(Me)
  1761.                 Invalidate()
  1762.             End Set
  1763.         End Property
  1764.  
  1765. #End Region
  1766. #Region " EventArgs "
  1767.  
  1768.         Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  1769.             Invalidate()
  1770.             MyBase.OnTextChanged(e)
  1771.         End Sub
  1772.  
  1773.         Protected Overrides Sub OnResize(e As EventArgs)
  1774.             MyBase.OnResize(e)
  1775.             Height = 15
  1776.         End Sub
  1777.  
  1778.         Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  1779.             If Not _Checked Then Checked = True
  1780.             MyBase.OnMouseDown(e)
  1781.             Focus()
  1782.         End Sub
  1783.  
  1784. #End Region
  1785.  
  1786.         Sub New()
  1787.             SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  1788.                      ControlStyles.OptimizedDoubleBuffer Or _
  1789.                      ControlStyles.ResizeRedraw Or _
  1790.                      ControlStyles.SupportsTransparentBackColor Or _
  1791.                      ControlStyles.UserPaint, True)
  1792.             BackColor = Color.Transparent
  1793.             Font = New Font("Segoe UI", 12)
  1794.             Width = 193
  1795.         End Sub
  1796.  
  1797.         Private Sub InvalidateControls()
  1798.             If Not IsHandleCreated OrElse Not _Checked Then Return
  1799.  
  1800.             For Each _Control As Control In Parent.Controls
  1801.                 If _Control IsNot Me AndAlso TypeOf _Control Is Ambiance_RadioButton Then
  1802.                     DirectCast(_Control, Ambiance_RadioButton).Checked = False
  1803.                 End If
  1804.             Next
  1805.         End Sub
  1806.  
  1807.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1808.             MyBase.OnPaint(e)
  1809.             With e.Graphics
  1810.  
  1811.                 .Clear(Parent.BackColor)
  1812.                 .SmoothingMode = SmoothingMode.AntiAlias
  1813.  
  1814.                 ' Fill the body of the ellipse with a gradient
  1815.                 Dim LGB As New LinearGradientBrush(New Rectangle(New Point(0, 0), New Size(14, 14)), Color.FromArgb(213, 85, 32), Color.FromArgb(224, 123, 82), 90)
  1816.                 .FillEllipse(LGB, New Rectangle(New Point(0, 0), New Size(14, 14)))
  1817.  
  1818.                 Dim GP As New GraphicsPath()
  1819.                 GP.AddEllipse(New Rectangle(0, 0, 14, 14))
  1820.                 .SetClip(GP)
  1821.                 .ResetClip()
  1822.  
  1823.                 ' Draw ellipse border
  1824.                 .DrawEllipse(New Pen(Color.FromArgb(182, 88, 55)), New Rectangle(New Point(0, 0), New Size(14, 14)))
  1825.  
  1826.                 If _Checked Then ' Draw an ellipse inside the body
  1827.                     Dim EllipseColor As New SolidBrush(Color.FromArgb(255, 255, 255))
  1828.                     .FillEllipse(EllipseColor, New Rectangle(New Point(4, 4), New Size(6, 6)))
  1829.                 End If
  1830.                 .DrawString(Text, Font, New SolidBrush(Color.FromArgb(76, 76, 95)), 16, 8, New StringFormat() With {.LineAlignment = StringAlignment.Center})
  1831.             End With
  1832.             e.Dispose()
  1833.         End Sub
  1834.     End Class
  1835.  
  1836. #End Region
  1837. #Region " ComboBox "
  1838.  
  1839.     Class Ambiance_ComboBox
  1840.         Inherits ComboBox
  1841.  
  1842. #Region " Variables "
  1843.  
  1844.         Private _StartIndex As Integer = 0
  1845.         Private _HoverSelectionColor As Color = Color.FromArgb(241, 241, 241)
  1846.  
  1847. #End Region
  1848. #Region " Custom Properties "
  1849.  
  1850.         Public Property StartIndex As Integer
  1851.             Get
  1852.                 Return _StartIndex
  1853.             End Get
  1854.             Set(ByVal value As Integer)
  1855.                 _StartIndex = value
  1856.                 Try
  1857.                     MyBase.SelectedIndex = value
  1858.                 Catch
  1859.                 End Try
  1860.                 Invalidate()
  1861.             End Set
  1862.         End Property
  1863.  
  1864.         Public Property HoverSelectionColor As Color
  1865.             Get
  1866.                 Return _HoverSelectionColor
  1867.             End Get
  1868.             Set(value As Color)
  1869.                 _HoverSelectionColor = value
  1870.                 Invalidate()
  1871.             End Set
  1872.         End Property
  1873.  
  1874. #End Region
  1875. #Region " EventArgs "
  1876.  
  1877.         Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  1878.             MyBase.OnDrawItem(e)
  1879.             Dim LGB As New LinearGradientBrush(e.Bounds, Color.FromArgb(246, 132, 85), Color.FromArgb(231, 108, 57), 90.0F)
  1880.  
  1881.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  1882.                 If Not e.Index = -1 Then
  1883.                     e.Graphics.FillRectangle(LGB, e.Bounds)
  1884.                     e.Graphics.DrawString(GetItemText(Items(e.Index)), e.Font, Brushes.WhiteSmoke, e.Bounds)
  1885.                 End If
  1886.             Else
  1887.                 If Not e.Index = -1 Then
  1888.                     e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(242, 241, 240)), e.Bounds)
  1889.                     e.Graphics.DrawString(GetItemText(Items(e.Index)), e.Font, Brushes.DimGray, e.Bounds)
  1890.                 End If
  1891.             End If
  1892.             LGB.Dispose()
  1893.         End Sub
  1894.  
  1895.         Protected Overrides Sub OnLostFocus(e As EventArgs)
  1896.             MyBase.OnLostFocus(e)
  1897.             SuspendLayout()
  1898.             Update()
  1899.             ResumeLayout()
  1900.         End Sub
  1901.  
  1902.         Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
  1903.             MyBase.OnPaintBackground(e)
  1904.         End Sub
  1905.  
  1906.         Protected Overrides Sub OnResize(e As EventArgs)
  1907.             MyBase.OnResize(e)
  1908.         End Sub
  1909.  
  1910. #End Region
  1911.  
  1912.         Sub New()
  1913.             SetStyle(DirectCast(139286, ControlStyles), True)
  1914.             SetStyle(ControlStyles.Selectable, False)
  1915.  
  1916.             DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  1917.             DropDownStyle = ComboBoxStyle.DropDownList
  1918.  
  1919.             BackColor = Color.FromArgb(246, 246, 246)
  1920.             ForeColor = Color.FromArgb(142, 142, 142)
  1921.             Size = New Size(135, 26)
  1922.             ItemHeight = 20
  1923.             DropDownHeight = 100
  1924.             Font = New Font("Segoe UI", 10, FontStyle.Regular)
  1925.         End Sub
  1926.  
  1927.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1928.             MyBase.OnPaint(e)
  1929.             Dim LGB As LinearGradientBrush
  1930.             Dim GP As GraphicsPath
  1931.  
  1932.             e.Graphics.Clear(Parent.BackColor)
  1933.             e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
  1934.  
  1935.             ' Create a curvy border
  1936.             GP = RoundRectangle.RoundRect(0, 0, Width - 1, Height - 1, 5)
  1937.             ' Fills the body of the rectangle with a gradient
  1938.             LGB = New LinearGradientBrush(ClientRectangle, Color.FromArgb(253, 252, 252), Color.FromArgb(239, 237, 236), 90.0F)
  1939.  
  1940.             e.Graphics.SetClip(GP)
  1941.             e.Graphics.FillRectangle(LGB, ClientRectangle)
  1942.             e.Graphics.ResetClip()
  1943.  
  1944.             ' Draw rectangle border
  1945.             e.Graphics.DrawPath(New Pen(Color.FromArgb(180, 180, 180)), GP)
  1946.             ' Draw string
  1947.             e.Graphics.DrawString(Text, Font, New SolidBrush(Color.FromArgb(76, 76, 97)), New Rectangle(3, 0, Width - 20, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  1948.             e.Graphics.DrawString("6", New Font("Marlett", 13, FontStyle.Regular), New SolidBrush(Color.FromArgb(119, 119, 118)), New Rectangle(3, 0, Width - 4, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Far})
  1949.             e.Graphics.DrawLine(New Pen(Color.FromArgb(224, 222, 220)), Width - 24, 4, Width - 24, Me.Height - 5)
  1950.             e.Graphics.DrawLine(New Pen(Color.FromArgb(250, 249, 249)), Width - 25, 4, Width - 25, Me.Height - 5)
  1951.  
  1952.             GP.Dispose()
  1953.             LGB.Dispose()
  1954.         End Sub
  1955.     End Class
  1956.  
  1957. #End Region
  1958. #Region " NumericUpDown "
  1959.  
  1960.     Class Ambiance_NumericUpDown
  1961.         Inherits Control
  1962.  
  1963. #Region " Enums "
  1964.  
  1965.         Enum _TextAlignment
  1966.             Near
  1967.             Center
  1968.         End Enum
  1969.  
  1970. #End Region
  1971. #Region " Variables "
  1972.  
  1973.         Private Shape As GraphicsPath
  1974.         Private P1 As Pen
  1975.  
  1976.         Private _Value, _Minimum, _Maximum As Long
  1977.         Private Xval As Integer
  1978.         Private KeyboardNum As Boolean
  1979.         Private MyStringAlignment As _TextAlignment
  1980.  
  1981.         Private WithEvents LongPressTimer As New Timer
  1982.  
  1983. #End Region
  1984. #Region " Properties "
  1985.  
  1986.         Public Property Value As Long
  1987.             Get
  1988.                 Return _Value
  1989.             End Get
  1990.             Set(value As Long)
  1991.                 If value <= _Maximum And value >= _Minimum Then _Value = value
  1992.                 Invalidate()
  1993.             End Set
  1994.         End Property
  1995.  
  1996.         Public Property Minimum As Long
  1997.             Get
  1998.                 Return _Minimum
  1999.             End Get
  2000.             Set(value As Long)
  2001.                 If value < _Maximum Then _Minimum = value
  2002.                 If _Value < _Minimum Then _Value = Minimum
  2003.                 Invalidate()
  2004.             End Set
  2005.         End Property
  2006.  
  2007.         Public Property Maximum As Long
  2008.             Get
  2009.                 Return _Maximum
  2010.             End Get
  2011.             Set(value As Long)
  2012.                 If value > _Minimum Then _Maximum = value
  2013.                 If _Value > _Maximum Then _Value = _Maximum
  2014.                 Invalidate()
  2015.             End Set
  2016.         End Property
  2017.  
  2018.         Public Property TextAlignment As _TextAlignment
  2019.             Get
  2020.                 Return MyStringAlignment
  2021.             End Get
  2022.             Set(value As _TextAlignment)
  2023.                 MyStringAlignment = value
  2024.                 Invalidate()
  2025.             End Set
  2026.         End Property
  2027.  
  2028. #End Region
  2029. #Region " EventArgs "
  2030.  
  2031.         Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  2032.             MyBase.OnResize(e)
  2033.             Height = 28
  2034.             MinimumSize = New Size(93, 28)
  2035.             Shape = New GraphicsPath
  2036.             With Shape
  2037.                 .AddArc(0, 0, 10, 10, 180, 90)
  2038.                 .AddArc(Width - 11, 0, 10, 10, -90, 90)
  2039.                 .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  2040.                 .AddArc(0, Height - 11, 10, 10, 90, 90)
  2041.                 .CloseAllFigures()
  2042.             End With
  2043.         End Sub
  2044.  
  2045.         Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  2046.             MyBase.OnMouseMove(e)
  2047.             Xval = e.Location.X
  2048.             Invalidate()
  2049.  
  2050.             If e.X < Width - 50 Then
  2051.                 Cursor = Cursors.IBeam
  2052.             Else
  2053.                 Cursor = Cursors.Default
  2054.             End If
  2055.             If e.X > Me.Width - 25 AndAlso e.X < Me.Width - 10 Then
  2056.                 Cursor = Cursors.Hand
  2057.             End If
  2058.             If e.X > Me.Width - 44 AndAlso e.X < Me.Width - 33 Then
  2059.                 Cursor = Cursors.Hand
  2060.             End If
  2061.         End Sub
  2062.  
  2063.         Private Sub ClickButton()
  2064.             If Xval > Me.Width - 25 AndAlso Xval < Me.Width - 10 Then
  2065.                 If (Value + 1) <= _Maximum Then _Value += 1
  2066.             Else
  2067.                 If Xval > Me.Width - 44 AndAlso Xval < Me.Width - 33 Then
  2068.                     If (Value - 1) >= _Minimum Then _Value -= 1
  2069.                 End If
  2070.                 KeyboardNum = Not KeyboardNum
  2071.             End If
  2072.             Focus()
  2073.             Invalidate()
  2074.         End Sub
  2075.  
  2076.         Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  2077.             MyBase.OnMouseClick(e)
  2078.             ClickButton()
  2079.             LongPressTimer.Start()
  2080.         End Sub
  2081.         Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  2082.             MyBase.OnMouseUp(e)
  2083.             LongPressTimer.Stop()
  2084.         End Sub
  2085.         Private Sub LongPressTimer_Tick(sender As Object, e As EventArgs) Handles LongPressTimer.Tick
  2086.             ClickButton()
  2087.         End Sub
  2088.         Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
  2089.             MyBase.OnKeyPress(e)
  2090.             Try
  2091.                 If KeyboardNum = True Then
  2092.                     _Value = CStr(CStr(_Value) & e.KeyChar.ToString)
  2093.                 End If
  2094.                 If _Value > _Maximum Then
  2095.                     _Value = _Maximum
  2096.                 End If
  2097.             Catch ex As Exception
  2098.             End Try
  2099.         End Sub
  2100.  
  2101.         Protected Overrides Sub OnKeyUp(ByVal e As System.Windows.Forms.KeyEventArgs)
  2102.             MyBase.OnKeyUp(e)
  2103.             If e.KeyCode = Keys.Back Then
  2104.                 Dim TemporaryValue As String = _Value.ToString()
  2105.                 TemporaryValue = TemporaryValue.Remove(Convert.ToInt32(TemporaryValue.Length - 1))
  2106.                 If (TemporaryValue.Length = 0) Then TemporaryValue = "0"
  2107.                 _Value = Convert.ToInt32(TemporaryValue)
  2108.             End If
  2109.             Invalidate()
  2110.         End Sub
  2111.  
  2112.         Protected Overrides Sub OnMouseWheel(e As MouseEventArgs)
  2113.             MyBase.OnMouseWheel(e)
  2114.             If e.Delta > 0 Then
  2115.                 If (Value + 1) <= _Maximum Then _Value += 1
  2116.                 Invalidate()
  2117.             Else
  2118.                 If (Value - 1) >= _Minimum Then _Value -= 1
  2119.                 Invalidate()
  2120.             End If
  2121.         End Sub
  2122.  
  2123. #End Region
  2124.  
  2125.         Sub New()
  2126.             SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  2127.             SetStyle(ControlStyles.UserPaint, True)
  2128.  
  2129.             P1 = New Pen(Color.FromArgb(180, 180, 180))
  2130.             BackColor = Color.Transparent
  2131.             ForeColor = Color.FromArgb(76, 76, 76)
  2132.             _Minimum = 0
  2133.             _Maximum = 100
  2134.             Font = New Font("Tahoma", 11)
  2135.             Size = New Size(70, 28)
  2136.             MinimumSize = New Size(62, 28)
  2137.             DoubleBuffered = True
  2138.  
  2139.             AddHandler LongPressTimer.Tick, AddressOf LongPressTimer_Tick
  2140.             LongPressTimer.Interval = 300
  2141.         End Sub
  2142.  
  2143.         Public Sub Increment(Value As Integer)
  2144.             Me._Value += Value
  2145.             Invalidate()
  2146.         End Sub
  2147.  
  2148.         Public Sub Decrement(Value As Integer)
  2149.             Me._Value -= Value
  2150.             Invalidate()
  2151.         End Sub
  2152.  
  2153.         Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  2154.             MyBase.OnPaint(e)
  2155.             Dim B As New Bitmap(Width, Height)
  2156.             Dim G As Graphics = Graphics.FromImage(B)
  2157.             Dim BackgroundLGB As LinearGradientBrush
  2158.  
  2159.             BackgroundLGB = New LinearGradientBrush(ClientRectangle, Color.FromArgb(246, 246, 246), Color.FromArgb(254, 254, 254), 90.0F)
  2160.  
  2161.             G.SmoothingMode = SmoothingMode.AntiAlias
  2162.  
  2163.             G.Clear(Color.Transparent) ' Set control background color
  2164.             G.FillPath(BackgroundLGB, Shape) ' Draw background
  2165.             G.DrawPath(P1, Shape) ' Draw border
  2166.  
  2167.             G.DrawString("+", New Font("Tahoma", 14), New SolidBrush(Color.FromArgb(75, 75, 75)), New Rectangle(Width - 25, 1, 19, 30))
  2168.             G.DrawLine(New Pen(Color.FromArgb(229, 228, 227)), Width - 28, 1, Width - 28, Me.Height - 2)
  2169.             G.DrawString("-", New Font("Tahoma", 14), New SolidBrush(Color.FromArgb(75, 75, 75)), New Rectangle(Width - 44, 1, 19, 30))
  2170.             G.DrawLine(New Pen(Color.FromArgb(229, 228, 227)), Width - 48, 1, Width - 48, Me.Height - 2)
  2171.  
  2172.             Select Case MyStringAlignment
  2173.                 Case _TextAlignment.Near
  2174.                     G.DrawString(Value, Font, New SolidBrush(ForeColor), New Rectangle(5, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  2175.                 Case _TextAlignment.Center
  2176.                     G.DrawString(Value, Font, New SolidBrush(ForeColor), New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  2177.             End Select
  2178.             e.Graphics.DrawImage(B.Clone(), 0, 0)
  2179.             G.Dispose()
  2180.             B.Dispose()
  2181.         End Sub
  2182.     End Class
  2183.  
  2184. #End Region
  2185. #Region " TrackBar "
  2186.  
  2187.     <DefaultEvent("ValueChanged")> Class Ambiance_TrackBar
  2188.         Inherits Control
  2189.  
  2190. #Region " Enums "
  2191.  
  2192.         Enum ValueDivisor
  2193.             By1 = 1
  2194.             By10 = 10
  2195.             By100 = 100
  2196.             By1000 = 1000
  2197.         End Enum
  2198.  
  2199. #End Region
  2200. #Region " Variables "
  2201.  
  2202.         Private PipeBorder, FillValue As GraphicsPath
  2203.         Private TrackBarHandleRect As Rectangle
  2204.         Private Cap As Boolean
  2205.         Private ValueDrawer As Integer
  2206.  
  2207.         Private ThumbSize As Size = New Size(15, 15)
  2208.         Private TrackThumb As Rectangle
  2209.  
  2210.         Private _Minimum As Integer = 0
  2211.         Private _Maximum As Integer = 10
  2212.         Private _Value As Integer = 0
  2213.  
  2214.         Private _DrawValueString As Boolean = False
  2215.         Private _JumpToMouse As Boolean = False
  2216.         Private DividedValue As ValueDivisor = ValueDivisor.By1
  2217.  
  2218. #End Region
  2219. #Region " Properties "
  2220.  
  2221.         Public Property Minimum() As Integer
  2222.             Get
  2223.                 Return _Minimum
  2224.             End Get
  2225.             Set(ByVal value As Integer)
  2226.  
  2227.                 If value >= _Maximum Then value = _Maximum - 10
  2228.                 If _Value < value Then _Value = value
  2229.  
  2230.                 _Minimum = value
  2231.                 Invalidate()
  2232.             End Set
  2233.         End Property
  2234.  
  2235.         Public Property Maximum() As Integer
  2236.             Get
  2237.                 Return _Maximum
  2238.             End Get
  2239.             Set(ByVal value As Integer)
  2240.  
  2241.                 If value <= _Minimum Then value = _Minimum + 10
  2242.                 If _Value > value Then _Value = value
  2243.  
  2244.                 _Maximum = value
  2245.                 Invalidate()
  2246.             End Set
  2247.         End Property
  2248.  
  2249.         Event ValueChanged()
  2250.         Public Property Value() As Integer
  2251.             Get
  2252.                 Return _Value
  2253.             End Get
  2254.             Set(ByVal value As Integer)
  2255.                 If _Value <> value Then
  2256.                     If value < _Minimum Then
  2257.                         _Value = _Minimum
  2258.                     Else
  2259.                         If value > _Maximum Then
  2260.                             _Value = _Maximum
  2261.                         Else
  2262.                             _Value = value
  2263.                         End If
  2264.                     End If
  2265.                     Invalidate()
  2266.                     RaiseEvent ValueChanged()
  2267.                 End If
  2268.             End Set
  2269.         End Property
  2270.  
  2271.         Public Property ValueDivison() As ValueDivisor
  2272.             Get
  2273.                 Return DividedValue
  2274.             End Get
  2275.             Set(ByVal Value As ValueDivisor)
  2276.                 DividedValue = Value
  2277.                 Invalidate()
  2278.             End Set
  2279.         End Property
  2280.  
  2281.         <Browsable(False)> Public Property ValueToSet() As Single
  2282.             Get
  2283.                 Return CSng(_Value / DividedValue)
  2284.             End Get
  2285.             Set(ByVal Val As Single)
  2286.                 Value = CInt(Val * DividedValue)
  2287.             End Set
  2288.         End Property
  2289.  
  2290.         Public Property JumpToMouse() As Boolean
  2291.             Get
  2292.                 Return _JumpToMouse
  2293.             End Get
  2294.             Set(ByVal value As Boolean)
  2295.                 _JumpToMouse = value
  2296.                 Invalidate()
  2297.             End Set
  2298.         End Property
  2299.  
  2300.         Property DrawValueString() As Boolean
  2301.             Get
  2302.                 Return _DrawValueString
  2303.             End Get
  2304.             Set(ByVal value As Boolean)
  2305.                 _DrawValueString = value
  2306.                 If _DrawValueString = True Then
  2307.                     Height = 35
  2308.                 Else
  2309.                     Height = 22
  2310.                 End If
  2311.                 Invalidate()
  2312.             End Set
  2313.         End Property
  2314.  
  2315. #End Region
  2316. #Region " EventArgs "
  2317.  
  2318.         Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  2319.             MyBase.OnMouseMove(e)
  2320.             If Cap = True AndAlso e.X > -1 AndAlso e.X < (Width + 1) Then
  2321.                 Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width))
  2322.             End If
  2323.         End Sub
  2324.  
  2325.         Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  2326.             MyBase.OnMouseDown(e)
  2327.             If e.Button = Windows.Forms.MouseButtons.Left Then
  2328.                 ValueDrawer = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
  2329.                 TrackBarHandleRect = New Rectangle(ValueDrawer, 0, 25, 25)
  2330.                 Cap = TrackBarHandleRect.Contains(e.Location)
  2331.                 Focus()
  2332.                 If _JumpToMouse Then
  2333.                     Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width))
  2334.                 End If
  2335.             End If
  2336.         End Sub
  2337.  
  2338.         Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  2339.             MyBase.OnMouseUp(e)
  2340.             Cap = False
  2341.         End Sub
  2342.  
  2343. #End Region
  2344.  
  2345.         Sub New()
  2346.             SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  2347.              ControlStyles.UserPaint Or _
  2348.              ControlStyles.ResizeRedraw Or _
  2349.              ControlStyles.DoubleBuffer, True)
  2350.  
  2351.             Size = New Size(80, 22)
  2352.             MinimumSize = New Size(47, 22)
  2353.         End Sub
  2354.  
  2355.         Protected Overrides Sub OnResize(e As EventArgs)
  2356.             MyBase.OnResize(e)
  2357.             If _DrawValueString = True Then
  2358.                 Height = 35
  2359.             Else
  2360.                 Height = 22
  2361.             End If
  2362.         End Sub
  2363.  
  2364.         Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  2365.             MyBase.OnPaint(e)
  2366.             Dim G As Graphics = e.Graphics
  2367.  
  2368.             G.Clear(Parent.BackColor)
  2369.             G.SmoothingMode = SmoothingMode.AntiAlias
  2370.             TrackThumb = New Rectangle(8, 10, Width - 16, 2)
  2371.             PipeBorder = RoundRectangle.RoundRect(1, 8, Width - 3, 5, 2)
  2372.  
  2373.             Try
  2374.                 ValueDrawer = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
  2375.             Catch ex As Exception
  2376.             End Try
  2377.  
  2378.             TrackBarHandleRect = New Rectangle(ValueDrawer, 0, 10, 20)
  2379.  
  2380.             G.SetClip(PipeBorder) ' Set the clipping region of this Graphics to the specified GraphicsPath
  2381.             G.FillPath(New SolidBrush(Color.FromArgb(221, 221, 221)), PipeBorder)
  2382.             FillValue = RoundRectangle.RoundRect(1, 8, TrackBarHandleRect.X + TrackBarHandleRect.Width - 4, 5, 2)
  2383.  
  2384.             G.ResetClip() ' Reset the clip region of this Graphics to an infinite region
  2385.  
  2386.             G.SmoothingMode = SmoothingMode.HighQuality
  2387.             G.DrawPath(New Pen(Color.FromArgb(200, 200, 200)), PipeBorder) ' Draw pipe border
  2388.             G.FillPath(New SolidBrush(Color.FromArgb(217, 99, 50)), FillValue)
  2389.  
  2390.             G.FillEllipse(New SolidBrush(Color.FromArgb(244, 244, 244)), TrackThumb.X + CInt(TrackThumb.Width * (Value / Maximum)) - CInt(ThumbSize.Width / 2), TrackThumb.Y + CInt((TrackThumb.Height / 2)) - CInt(ThumbSize.Height / 2), ThumbSize.Width, ThumbSize.Height)
  2391.             G.DrawEllipse(New Pen(Color.FromArgb(180, 180, 180)), TrackThumb.X + CInt(TrackThumb.Width * (Value / Maximum)) - CInt(ThumbSize.Width / 2), TrackThumb.Y + CInt((TrackThumb.Height / 2)) - CInt(ThumbSize.Height / 2), ThumbSize.Width, ThumbSize.Height)
  2392.  
  2393.             If _DrawValueString = True Then
  2394.                 G.DrawString(ValueToSet, Font, Brushes.DimGray, 1, 20)
  2395.             End If
  2396.         End Sub
  2397.     End Class
  2398.  
  2399. #End Region
  2400. #Region " Panel "
  2401.  
  2402.     Class Ambiance_Panel
  2403.         Inherits ContainerControl
  2404.         Public Sub New()
  2405.             SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  2406.             SetStyle(ControlStyles.Opaque, False)
  2407.         End Sub
  2408.  
  2409.         Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  2410.             Dim G As Graphics = e.Graphics
  2411.  
  2412.             Me.Font = New Font("Tahoma", 9)
  2413.             Me.BackColor = Color.White
  2414.             G.SmoothingMode = SmoothingMode.AntiAlias
  2415.             G.FillRectangle(New SolidBrush(Color.White), New Rectangle(0, 0, Width, Height))
  2416.             G.FillRectangle(New SolidBrush(Color.White), New Rectangle(0, 0, Width - 1, Height - 1))
  2417.             G.DrawRectangle(New Pen(Color.FromArgb(211, 208, 205)), 0, 0, Width - 1, Height - 1)
  2418.         End Sub
  2419.     End Class
  2420.  
  2421. #End Region
  2422. #Region " TextBox "
  2423.  
  2424.     <DefaultEvent("TextChanged")> Class Ambiance_TextBox
  2425.         Inherits Control
  2426.  
  2427. #Region " Variables "
  2428.  
  2429.         Public WithEvents AmbianceTB As New TextBox
  2430.         Private Shape As GraphicsPath
  2431.         Private _maxchars As Integer = 32767
  2432.         Private _ReadOnly As Boolean
  2433.         Private _Multiline As Boolean
  2434.         Private ALNType As HorizontalAlignment
  2435.         Private isPasswordMasked As Boolean = False
  2436.         Private P1 As Pen
  2437.         Private B1 As SolidBrush
  2438.  
  2439. #End Region
  2440. #Region " Properties "
  2441.  
  2442.         Public Shadows Property TextAlignment() As HorizontalAlignment
  2443.             Get
  2444.                 Return ALNType
  2445.             End Get
  2446.             Set(ByVal Val As HorizontalAlignment)
  2447.                 ALNType = Val
  2448.                 Invalidate()
  2449.             End Set
  2450.         End Property
  2451.         Public Shadows Property MaxLength() As Integer
  2452.             Get
  2453.                 Return _maxchars
  2454.             End Get
  2455.             Set(ByVal Val As Integer)
  2456.                 _maxchars = Val
  2457.                 AmbianceTB.MaxLength = MaxLength
  2458.                 Invalidate()
  2459.             End Set
  2460.         End Property
  2461.  
  2462.         Public Shadows Property UseSystemPasswordChar() As Boolean
  2463.             Get
  2464.                 Return isPasswordMasked
  2465.             End Get
  2466.             Set(ByVal Val As Boolean)
  2467.                 AmbianceTB.UseSystemPasswordChar = UseSystemPasswordChar
  2468.                 isPasswordMasked = Val
  2469.                 Invalidate()
  2470.             End Set
  2471.         End Property
  2472.         Property [ReadOnly]() As Boolean
  2473.             Get
  2474.                 Return _ReadOnly
  2475.             End Get
  2476.             Set(ByVal value As Boolean)
  2477.                 _ReadOnly = value
  2478.                 If AmbianceTB IsNot Nothing Then
  2479.                     AmbianceTB.ReadOnly = value
  2480.                 End If
  2481.             End Set
  2482.         End Property
  2483.         Property Multiline() As Boolean
  2484.             Get
  2485.                 Return _Multiline
  2486.             End Get
  2487.             Set(ByVal value As Boolean)
  2488.                 _Multiline = value
  2489.                 If AmbianceTB IsNot Nothing Then
  2490.                     AmbianceTB.Multiline = value
  2491.  
  2492.                     If value Then
  2493.                         AmbianceTB.Height = Height - 10
  2494.                     Else
  2495.                         Height = AmbianceTB.Height + 10
  2496.                     End If
  2497.                 End If
  2498.             End Set
  2499.         End Property
  2500.  
  2501. #End Region
  2502. #Region " EventArgs "
  2503.  
  2504.         Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  2505.             MyBase.OnTextChanged(e)
  2506.             Invalidate()
  2507.         End Sub
  2508.  
  2509.         Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  2510.             MyBase.OnForeColorChanged(e)
  2511.             AmbianceTB.ForeColor = ForeColor
  2512.             Invalidate()
  2513.         End Sub
  2514.  
  2515.         Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  2516.             MyBase.OnFontChanged(e)
  2517.             AmbianceTB.Font = Font
  2518.         End Sub
  2519.         Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
  2520.             MyBase.OnPaintBackground(e)
  2521.         End Sub
  2522.  
  2523.         Private Sub _OnKeyDown(ByVal Obj As Object, ByVal e As KeyEventArgs)
  2524.             If e.Control AndAlso e.KeyCode = Keys.A Then
  2525.                 AmbianceTB.SelectAll()
  2526.                 e.SuppressKeyPress = True
  2527.             End If
  2528.             If e.Control AndAlso e.KeyCode = Keys.C Then
  2529.                 AmbianceTB.Copy()
  2530.                 e.SuppressKeyPress = True
  2531.             End If
  2532.         End Sub
  2533.  
  2534.         Private Sub _Enter(ByVal Obj As Object, ByVal e As EventArgs)
  2535.             P1 = New Pen(Color.FromArgb(205, 87, 40))
  2536.             Refresh()
  2537.         End Sub
  2538.  
  2539.         Private Sub _Leave(ByVal Obj As Object, ByVal e As EventArgs)
  2540.             P1 = New Pen(Color.FromArgb(180, 180, 180))
  2541.             Refresh()
  2542.         End Sub
  2543.  
  2544.         Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  2545.             MyBase.OnResize(e)
  2546.             If _Multiline Then
  2547.                 AmbianceTB.Height = Height - 10
  2548.             Else
  2549.                 Height = AmbianceTB.Height + 10
  2550.             End If
  2551.  
  2552.             Shape = New GraphicsPath
  2553.             With Shape
  2554.                 .AddArc(0, 0, 10, 10, 180, 90)
  2555.                 .AddArc(Width - 11, 0, 10, 10, -90, 90)
  2556.                 .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  2557.                 .AddArc(0, Height - 11, 10, 10, 90, 90)
  2558.                 .CloseAllFigures()
  2559.             End With
  2560.         End Sub
  2561.  
  2562.         Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  2563.             MyBase.OnGotFocus(e)
  2564.             AmbianceTB.Focus()
  2565.         End Sub
  2566.  
  2567.         Sub _TextChanged() Handles AmbianceTB.TextChanged
  2568.             Text = AmbianceTB.Text
  2569.         End Sub
  2570.  
  2571.         Sub _BaseTextChanged() Handles MyBase.TextChanged
  2572.             AmbianceTB.Text = Text
  2573.         End Sub
  2574.  
  2575. #End Region
  2576.  
  2577.         Sub AddTextBox()
  2578.             ' Initialize the TextBox
  2579.             With AmbianceTB
  2580.  
  2581.                 .Size = New Size(Width - 10, 33)
  2582.                 .Location = New Point(7, 4)
  2583.                 .Text = String.Empty
  2584.                 .BorderStyle = BorderStyle.None
  2585.                 .BackColor = Color.White
  2586.                 .TextAlign = HorizontalAlignment.Left
  2587.                 .Font = New Font("Tahoma", 9)
  2588.                 .UseSystemPasswordChar = UseSystemPasswordChar
  2589.                 .Multiline = False
  2590.             End With
  2591.             AddHandler AmbianceTB.KeyDown, AddressOf _OnKeyDown
  2592.             AddHandler AmbianceTB.Enter, AddressOf _Enter
  2593.             AddHandler AmbianceTB.Leave, AddressOf _Leave
  2594.         End Sub
  2595.  
  2596.         Sub New()
  2597.             SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  2598.             SetStyle(ControlStyles.UserPaint, True)
  2599.  
  2600.             AddTextBox()
  2601.             Controls.Add(AmbianceTB)
  2602.  
  2603.             P1 = New Pen(Color.FromArgb(180, 180, 180))
  2604.             B1 = New SolidBrush(Color.White)
  2605.             BackColor = Color.Transparent
  2606.             ForeColor = Color.FromArgb(76, 76, 76)
  2607.  
  2608.             Text = Nothing
  2609.             Font = New Font("Tahoma", 11)
  2610.             Size = New Size(135, 33)
  2611.             DoubleBuffered = True
  2612.         End Sub
  2613.  
  2614.         Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  2615.             MyBase.OnPaint(e)
  2616.             Dim B As New Bitmap(Width, Height)
  2617.             Dim G As Graphics = Graphics.FromImage(B)
  2618.  
  2619.             G.SmoothingMode = SmoothingMode.AntiAlias
  2620.  
  2621.             With AmbianceTB
  2622.                 .Width = Width - 10
  2623.                 .TextAlign = TextAlignment
  2624.                 .UseSystemPasswordChar = UseSystemPasswordChar
  2625.             End With
  2626.  
  2627.             G.Clear(Color.Transparent)
  2628.             G.FillPath(B1, Shape) ' Draw background
  2629.             G.DrawPath(P1, Shape) ' Draw border
  2630.  
  2631.             e.Graphics.DrawImage(B.Clone(), 0, 0)
  2632.             G.Dispose() : B.Dispose()
  2633.         End Sub
  2634.     End Class
  2635.  
  2636. #End Region
  2637. #Region " RichTextBox "
  2638.  
  2639.     <DefaultEvent("TextChanged")> Class Ambiance_RichTextBox
  2640.         Inherits Control
  2641.  
  2642. #Region " Variables "
  2643.  
  2644.         Public WithEvents AmbianceRTB As New RichTextBox
  2645.         Private _ReadOnly As Boolean
  2646.         Private _WordWrap As Boolean
  2647.         Private _AutoWordSelection As Boolean
  2648.         Private Shape As GraphicsPath
  2649.         Private P1 As Pen
  2650.  
  2651. #End Region
  2652. #Region " Properties "
  2653.  
  2654.         Overrides Property Text As String
  2655.             Get
  2656.                 Return AmbianceRTB.Text
  2657.             End Get
  2658.             Set(value As String)
  2659.                 AmbianceRTB.Text = value
  2660.                 Invalidate()
  2661.             End Set
  2662.         End Property
  2663.         Property [ReadOnly]() As Boolean
  2664.             Get
  2665.                 Return _ReadOnly
  2666.             End Get
  2667.             Set(ByVal value As Boolean)
  2668.                 _ReadOnly = value
  2669.                 If AmbianceRTB IsNot Nothing Then
  2670.                     AmbianceRTB.ReadOnly = value
  2671.                 End If
  2672.             End Set
  2673.         End Property
  2674.         Property [WordWrap]() As Boolean
  2675.             Get
  2676.                 Return _WordWrap
  2677.             End Get
  2678.             Set(ByVal value As Boolean)
  2679.                 _WordWrap = value
  2680.                 If AmbianceRTB IsNot Nothing Then
  2681.                     AmbianceRTB.WordWrap = value
  2682.                 End If
  2683.             End Set
  2684.         End Property
  2685.         Property [AutoWordSelection]() As Boolean
  2686.             Get
  2687.                 Return _AutoWordSelection
  2688.             End Get
  2689.             Set(ByVal value As Boolean)
  2690.                 _AutoWordSelection = value
  2691.                 If AmbianceRTB IsNot Nothing Then
  2692.                     AmbianceRTB.AutoWordSelection = value
  2693.                 End If
  2694.             End Set
  2695.         End Property
  2696. #End Region
  2697. #Region " EventArgs "
  2698.  
  2699.         Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  2700.             MyBase.OnForeColorChanged(e)
  2701.             AmbianceRTB.ForeColor = ForeColor
  2702.             Invalidate()
  2703.         End Sub
  2704.  
  2705.         Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  2706.             MyBase.OnFontChanged(e)
  2707.             AmbianceRTB.Font = Font
  2708.         End Sub
  2709.         Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
  2710.             MyBase.OnPaintBackground(e)
  2711.         End Sub
  2712.  
  2713.         Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
  2714.             MyBase.OnSizeChanged(e)
  2715.             AmbianceRTB.Size = New Size(Width - 13, Height - 11)
  2716.         End Sub
  2717.  
  2718.         Private Sub _Enter(ByVal Obj As Object, ByVal e As EventArgs)
  2719.             P1 = New Pen(Color.FromArgb(205, 87, 40))
  2720.             Refresh()
  2721.         End Sub
  2722.  
  2723.         Private Sub _Leave(ByVal Obj As Object, ByVal e As EventArgs)
  2724.             P1 = New Pen(Color.FromArgb(180, 180, 180))
  2725.             Refresh()
  2726.         End Sub
  2727.  
  2728.         Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  2729.             MyBase.OnResize(e)
  2730.  
  2731.             Shape = New GraphicsPath
  2732.             With Shape
  2733.                 .AddArc(0, 0, 10, 10, 180, 90)
  2734.                 .AddArc(Width - 11, 0, 10, 10, -90, 90)
  2735.                 .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  2736.                 .AddArc(0, Height - 11, 10, 10, 90, 90)
  2737.                 .CloseAllFigures()
  2738.             End With
  2739.         End Sub
  2740.  
  2741.         Sub _TextChanged() Handles MyBase.TextChanged
  2742.             AmbianceRTB.Text = Text
  2743.         End Sub
  2744.  
  2745. #End Region
  2746.  
  2747.         Sub AddRichTextBox()
  2748.             With AmbianceRTB
  2749.                 .BackColor = Color.White
  2750.                 .Size = New Size(Width - 10, 100)
  2751.                 .Location = New Point(7, 5)
  2752.                 .Text = String.Empty
  2753.                 .BorderStyle = BorderStyle.None
  2754.                 .Font = New Font("Tahoma", 10)
  2755.                 .Multiline = True
  2756.             End With
  2757.         End Sub
  2758.  
  2759.         Sub New()
  2760.             MyBase.New()
  2761.             SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  2762.             SetStyle(ControlStyles.UserPaint, True)
  2763.  
  2764.             AddRichTextBox()
  2765.             Controls.Add(AmbianceRTB)
  2766.             BackColor = Color.Transparent
  2767.             ForeColor = Color.FromArgb(76, 76, 76)
  2768.  
  2769.             P1 = New Pen(Color.FromArgb(180, 180, 180))
  2770.             Text = Nothing
  2771.             Font = New Font("Tahoma", 10)
  2772.             Size = New Size(150, 100)
  2773.             WordWrap = True
  2774.             AutoWordSelection = False
  2775.             DoubleBuffered = True
  2776.  
  2777.             AddHandler AmbianceRTB.Enter, AddressOf _Enter
  2778.             AddHandler AmbianceRTB.Leave, AddressOf _Leave
  2779.         End Sub
  2780.  
  2781.         Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  2782.             MyBase.OnPaint(e)
  2783.             Dim B As New Bitmap(Width, Height)
  2784.             Dim G = Graphics.FromImage(B)
  2785.  
  2786.             G.SmoothingMode = SmoothingMode.AntiAlias
  2787.  
  2788.             G.Clear(Color.Transparent) ' Set control background to transparent
  2789.             G.FillPath(Brushes.White, Shape) ' Draw RTB background
  2790.             G.DrawPath(P1, Shape) ' Draw border
  2791.  
  2792.             G.Dispose()
  2793.             e.Graphics.DrawImage(B.Clone(), 0, 0)
  2794.             B.Dispose()
  2795.         End Sub
  2796.     End Class
  2797.  
  2798. #End Region
  2799. #Region " ListBox "
  2800. ' Get more free themes at ThemesVB.NET
  2801.     Class Ambiance_ListBox
  2802.         Inherits ListBox
  2803.  
  2804.         Public Sub New()
  2805.             Me.SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
  2806.             Me.DrawMode = DrawMode.OwnerDrawFixed
  2807.             IntegralHeight = False
  2808.             ItemHeight = 18
  2809.             Font = New Font("Seoge UI", 11, FontStyle.Regular)
  2810.         End Sub
  2811.  
  2812.         Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  2813.             MyBase.OnDrawItem(e)
  2814.             e.DrawBackground()
  2815.             Dim LGB As New LinearGradientBrush(e.Bounds, Color.FromArgb(246, 132, 85), Color.FromArgb(231, 108, 57), 90.0F)
  2816.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  2817.                 e.Graphics.FillRectangle(LGB, e.Bounds)
  2818.             End If
  2819.             Using b As New SolidBrush(e.ForeColor)
  2820.                 If MyBase.Items.Count = Nothing Then
  2821.                     Exit Sub
  2822.                 Else
  2823.                     e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), e.Font, b, e.Bounds)
  2824.                 End If
  2825.             End Using
  2826.             LGB.Dispose()
  2827.         End Sub
  2828.         Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2829.             MyBase.OnPaint(e)
  2830.             Dim MyRegion As New Region(e.ClipRectangle)
  2831.             e.Graphics.FillRegion(New SolidBrush(Me.BackColor), MyRegion)
  2832.  
  2833.             If Me.Items.Count > 0 Then
  2834.                 For i As Integer = 0 To Me.Items.Count - 1
  2835.                     Dim RegionRect As System.Drawing.Rectangle = Me.GetItemRectangle(i)
  2836.                     If e.ClipRectangle.IntersectsWith(RegionRect) Then
  2837.                         If (Me.SelectionMode = SelectionMode.One AndAlso Me.SelectedIndex = i) OrElse (Me.SelectionMode = SelectionMode.MultiSimple AndAlso Me.SelectedIndices.Contains(i)) OrElse (Me.SelectionMode = SelectionMode.MultiExtended AndAlso Me.SelectedIndices.Contains(i)) Then
  2838.                             OnDrawItem(New DrawItemEventArgs(e.Graphics, Me.Font, RegionRect, i, DrawItemState.Selected, Me.ForeColor, _
  2839.                                 Me.BackColor))
  2840.                         Else
  2841.                             OnDrawItem(New DrawItemEventArgs(e.Graphics, Me.Font, RegionRect, i, DrawItemState.[Default], Color.FromArgb(60, 60, 60), _
  2842.                                 Me.BackColor))
  2843.                         End If
  2844.                         MyRegion.Complement(RegionRect)
  2845.                     End If
  2846.                 Next
  2847.             End If
  2848.         End Sub
  2849.     End Class
  2850.  
  2851. #End Region
  2852. #Region " TabControl "
  2853.  
  2854.     Class Ambiance_TabControl
  2855.         Inherits TabControl
  2856.  
  2857.         Sub New()
  2858.             SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  2859.                      ControlStyles.OptimizedDoubleBuffer Or _
  2860.                      ControlStyles.ResizeRedraw Or _
  2861.                      ControlStyles.UserPaint, True)
  2862.         End Sub
  2863. ' Get more free themes at ThemesVB.NET
  2864.         Protected Overrides Sub CreateHandle()
  2865.             MyBase.CreateHandle()
  2866.  
  2867.             ItemSize = New Size(80, 24)
  2868.             Alignment = TabAlignment.Top
  2869.         End Sub
  2870.  
  2871.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  2872.             Dim G As Graphics = e.Graphics
  2873.             Dim ItemBoundsRect As Rectangle
  2874.             G.Clear(Parent.BackColor)
  2875.             For TabIndex As Integer = 0 To TabCount - 1
  2876.                 ItemBoundsRect = GetTabRect(TabIndex)
  2877.                 If Not TabIndex = SelectedIndex Then
  2878.                     G.DrawString(TabPages(TabIndex).Text, New Font(Font.Name, Font.Size - 2, FontStyle.Bold), New SolidBrush(Color.FromArgb(80, 76, 76)), New Rectangle(GetTabRect(TabIndex).Location, GetTabRect(TabIndex).Size), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  2879.                 End If
  2880.             Next
  2881.  
  2882.             ' Draw container rectangle
  2883.             G.FillPath(New SolidBrush(Color.FromArgb(247, 246, 246)), RoundRect(0, 23, Width - 1, Height - 24, 2))
  2884.             G.DrawPath(New Pen(Color.FromArgb(201, 198, 195)), RoundRect(0, 23, Width - 1, Height - 24, 2))
  2885.  
  2886.             For ItemIndex As Integer = 0 To TabCount - 1
  2887.                 ItemBoundsRect = GetTabRect(ItemIndex)
  2888.                 If ItemIndex = SelectedIndex Then
  2889.  
  2890.                     ' Draw header tabs
  2891.                     G.DrawPath(New Pen(Color.FromArgb(201, 198, 195)), RoundedTopRect(New Rectangle(New Point(ItemBoundsRect.X - 2, ItemBoundsRect.Y - 2), New Size(ItemBoundsRect.Width + 3, ItemBoundsRect.Height)), 7))
  2892.                     G.FillPath(New SolidBrush(Color.FromArgb(247, 246, 246)), RoundedTopRect(New Rectangle(New Point(ItemBoundsRect.X - 1, ItemBoundsRect.Y - 1), New Size(ItemBoundsRect.Width + 2, ItemBoundsRect.Height)), 7))
  2893.  
  2894.                     Try
  2895.                         G.DrawString(TabPages(ItemIndex).Text, New Font(Font.Name, Font.Size - 1, FontStyle.Bold), New SolidBrush(Color.FromArgb(80, 76, 76)), New Rectangle(GetTabRect(ItemIndex).Location, GetTabRect(ItemIndex).Size), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  2896.                         TabPages(ItemIndex).BackColor = Color.FromArgb(247, 246, 246)
  2897.                     Catch : End Try
  2898.                 End If
  2899.             Next
  2900.         End Sub
  2901.     End Class
  2902.  
  2903. #End Region
  2904.  
  2905. End Namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement