Guest User

Security

a guest
Feb 21st, 2015
1,770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 48.04 KB | None | 0 0
  1. #Region " Imports "
  2.  
  3. Imports System.Drawing.Drawing2D
  4. Imports System.ComponentModel
  5.  
  6. #End Region
  7. #Region " RoundRectangle "
  8.  
  9. Module RoundRectangle
  10.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  11.         Dim P As GraphicsPath = New GraphicsPath()
  12.         Dim ArcRectangleWidth As Integer = Curve * 2
  13.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  14.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  15.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  16.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  17.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  18.         Return P
  19.     End Function
  20. End Module
  21.  
  22. #End Region
  23.  
  24.  
  25.  
  26. #Region " ThemeContainer "
  27.  
  28. Class Chili_ThemeContainer
  29.     Inherits ContainerControl
  30.  
  31. #Region " Enums "
  32.  
  33.     Enum MouseState As Byte
  34.         None = 0
  35.         Over = 1
  36.         Down = 2
  37.         Block = 3
  38.     End Enum
  39.  
  40. #End Region
  41. #Region " Variables "
  42.  
  43.     Private HeaderRect As Rectangle
  44.     Protected State As MouseState
  45.     Private MoveHeight As Integer
  46.     Private MouseP As Point = New Point(0, 0)
  47.     Private Cap As Boolean = False
  48.     Private HasShown As Boolean
  49.  
  50. #End Region
  51. #Region " Properties "
  52.  
  53.     Private _Sizable As Boolean = True
  54.     Property Sizable() As Boolean
  55.         Get
  56.             Return _Sizable
  57.         End Get
  58.         Set(ByVal value As Boolean)
  59.             _Sizable = value
  60.         End Set
  61.     End Property
  62.  
  63.     Private _SmartBounds As Boolean = True
  64.     Property SmartBounds() As Boolean
  65.         Get
  66.             Return _SmartBounds
  67.         End Get
  68.         Set(ByVal value As Boolean)
  69.             _SmartBounds = value
  70.         End Set
  71.     End Property
  72.  
  73.     Private _RoundCorners As Boolean = True
  74.     Property RoundCorners() As Boolean
  75.         Get
  76.             Return _RoundCorners
  77.         End Get
  78.         Set(ByVal value As Boolean)
  79.             _RoundCorners = value
  80.             Invalidate()
  81.         End Set
  82.     End Property
  83.  
  84.     Private _IsParentForm As Boolean
  85.     Protected ReadOnly Property IsParentForm As Boolean
  86.         Get
  87.             Return _IsParentForm
  88.         End Get
  89.     End Property
  90.  
  91.     Protected ReadOnly Property IsParentMdi As Boolean
  92.         Get
  93.             If Parent Is Nothing Then Return False
  94.             Return Parent.Parent IsNot Nothing
  95.         End Get
  96.     End Property
  97.  
  98.     Private _ControlMode As Boolean
  99.     Protected Property ControlMode() As Boolean
  100.         Get
  101.             Return _ControlMode
  102.         End Get
  103.         Set(ByVal v As Boolean)
  104.             _ControlMode = v
  105.             Invalidate()
  106.         End Set
  107.     End Property
  108.  
  109.     Private _StartPosition As FormStartPosition
  110.     Property StartPosition As FormStartPosition
  111.         Get
  112.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.StartPosition Else Return _StartPosition
  113.         End Get
  114.         Set(ByVal value As FormStartPosition)
  115.             _StartPosition = value
  116.  
  117.             If _IsParentForm AndAlso Not _ControlMode Then
  118.                 ParentForm.StartPosition = value
  119.             End If
  120.         End Set
  121.     End Property
  122.  
  123. #End Region
  124. #Region " EventArgs "
  125.  
  126.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  127.         MyBase.OnParentChanged(e)
  128.  
  129.         If Parent Is Nothing Then Return
  130.         _IsParentForm = TypeOf Parent Is Form
  131.  
  132.         If Not _ControlMode Then
  133.             InitializeMessages()
  134.  
  135.             If _IsParentForm Then
  136.                 Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  137.                 Me.ParentForm.TransparencyKey = Color.Fuchsia
  138.  
  139.                 If Not DesignMode Then
  140.                     AddHandler ParentForm.Shown, AddressOf FormShown
  141.                 End If
  142.             End If
  143.             Parent.BackColor = BackColor
  144.             '   Parent.MinimumSize = New Size(261, 65)
  145.         End If
  146.     End Sub
  147.  
  148.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  149.         MyBase.OnSizeChanged(e)
  150.         If Not _ControlMode Then HeaderRect = New Rectangle(0, 0, Width - 14, MoveHeight - 7)
  151.         Invalidate()
  152.     End Sub
  153.  
  154.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  155.         MyBase.OnMouseDown(e)
  156.         Focus()
  157.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  158.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
  159.             If HeaderRect.Contains(e.Location) Then
  160.                 Capture = False
  161.                 WM_LMBUTTONDOWN = True
  162.                 DefWndProc(Messages(0))
  163.             ElseIf _Sizable AndAlso Not Previous = 0 Then
  164.                 Capture = False
  165.                 WM_LMBUTTONDOWN = True
  166.                 DefWndProc(Messages(Previous))
  167.             End If
  168.         End If
  169.     End Sub
  170.  
  171.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  172.         MyBase.OnMouseUp(e)
  173.         Cap = False
  174.     End Sub
  175.  
  176.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  177.         MyBase.OnMouseMove(e)
  178.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
  179.             If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  180.         End If
  181.         If Cap Then
  182.             Parent.Location = MousePosition - MouseP
  183.         End If
  184.     End Sub
  185.  
  186.     Protected Overrides Sub OnInvalidated(ByVal e As System.Windows.Forms.InvalidateEventArgs)
  187.         MyBase.OnInvalidated(e)
  188.         ParentForm.Text = Text
  189.     End Sub
  190.  
  191.     Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
  192.         MyBase.OnPaintBackground(e)
  193.     End Sub
  194.  
  195.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  196.         MyBase.OnTextChanged(e)
  197.         Invalidate()
  198.     End Sub
  199.  
  200.     Private Sub FormShown(ByVal sender As Object, ByVal e As EventArgs)
  201.         If _ControlMode OrElse HasShown Then Return
  202.  
  203.         If _StartPosition = FormStartPosition.CenterParent OrElse _StartPosition = FormStartPosition.CenterScreen Then
  204.             Dim SB As Rectangle = Screen.PrimaryScreen.Bounds
  205.             Dim CB As Rectangle = ParentForm.Bounds
  206.             ParentForm.Location = New Point(SB.Width \ 2 - CB.Width \ 2, SB.Height \ 2 - CB.Width \ 2)
  207.         End If
  208.         HasShown = True
  209.     End Sub
  210.  
  211. #End Region
  212.  
  213.     Protected Overrides Sub CreateHandle()
  214.         MyBase.CreateHandle()
  215.     End Sub
  216.  
  217.     Sub New()
  218.         SetStyle(DirectCast(139270, ControlStyles), True)
  219.         BackColor = Color.FromArgb(33, 36, 38)
  220.         'Padding = New Padding(10, 70, 10, 9)
  221.         DoubleBuffered = True
  222.         Dock = DockStyle.Fill
  223.         MoveHeight = 166
  224.         Font = New Font("Segoe UI", 9)
  225.     End Sub
  226.  
  227.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  228.         MyBase.OnPaint(e)
  229.         Dim G As Graphics = e.Graphics
  230.  
  231.         G.Clear(Color.FromArgb(33, 36, 38))
  232.         G.FillRectangle(New SolidBrush(Color.FromArgb(33, 36, 38)), New Rectangle(0, 0, Width, 60))
  233.  
  234.         If _RoundCorners = True Then
  235.  
  236.             G.FillRectangle(New SolidBrush(Color.FromArgb(33, 36, 38)), Width - 2, Height - 3, 1, 1)
  237.             G.FillRectangle(New SolidBrush(Color.FromArgb(33, 36, 38)), Width - 2, Height - 4, 1, 1)
  238.             G.FillRectangle(New SolidBrush(Color.FromArgb(33, 36, 38)), Width - 4, Height - 2, 1, 1)
  239.             G.FillRectangle(New SolidBrush(Color.FromArgb(33, 36, 38)), Width - 3, Height - 2, 1, 1)
  240.         End If
  241.     End Sub
  242. End Class
  243.  
  244. #End Region
  245. #Region " ControlBox "
  246. '
  247. Class Chili_ControlBox
  248.     Inherits Control
  249.  
  250. #Region " Enums "
  251.  
  252.     Enum ButtonHoverState
  253.         Minimize
  254.         Close
  255.         None
  256.     End Enum
  257.  
  258. #End Region
  259. #Region " Variables "
  260.  
  261.     Private ButtonHState As ButtonHoverState = ButtonHoverState.None
  262.  
  263. #End Region
  264. #Region " Properties "
  265.  
  266.     Private _EnableMaximize As Boolean = True
  267.     Property EnableMaximizeButton() As Boolean
  268.         Get
  269.             Return _EnableMaximize
  270.         End Get
  271.         Set(ByVal value As Boolean)
  272.             _EnableMaximize = value
  273.             Invalidate()
  274.         End Set
  275.     End Property
  276.  
  277.     Private _EnableMinimize As Boolean = True
  278.     Property EnableMinimizeButton() As Boolean
  279.         Get
  280.             Return _EnableMinimize
  281.         End Get
  282.         Set(ByVal value As Boolean)
  283.             _EnableMinimize = value
  284.             Invalidate()
  285.         End Set
  286.     End Property
  287.  
  288.     Private _EnableHoverHighlight As Boolean = False
  289.     Property EnableHoverHighlight() As Boolean
  290.         Get
  291.             Return _EnableHoverHighlight
  292.         End Get
  293.         Set(ByVal value As Boolean)
  294.             _EnableHoverHighlight = value
  295.             Invalidate()
  296.         End Set
  297.     End Property
  298.  
  299. #End Region
  300. #Region " EventArgs "
  301.  
  302.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  303.         MyBase.OnResize(e)
  304.         Size = New Size(100, 25)
  305.     End Sub
  306.  
  307.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  308.         MyBase.OnMouseMove(e)
  309.         Dim X As Integer = e.Location.X
  310.         Dim Y As Integer = e.Location.Y
  311.         If Y > 0 AndAlso Y < (Height - 2) Then
  312.             If X > 0 AndAlso X < 40 Then
  313.                 ButtonHState = ButtonHoverState.Minimize
  314.             ElseIf X > 64 AndAlso X < Width Then
  315.                 ButtonHState = ButtonHoverState.Close
  316.             Else
  317.                 ButtonHState = ButtonHoverState.None
  318.             End If
  319.         Else
  320.             ButtonHState = ButtonHoverState.None
  321.         End If
  322.         Invalidate()
  323.     End Sub
  324.  
  325.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  326.         MyBase.OnMouseDown(e)
  327.         Select Case ButtonHState
  328.             Case ButtonHoverState.Close
  329.                 Parent.FindForm().Close()
  330.             Case ButtonHoverState.Minimize
  331.                 If _EnableMinimize = True Then
  332.                     Parent.FindForm().WindowState = FormWindowState.Minimized
  333.                 End If
  334.         End Select
  335.     End Sub
  336.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  337.         MyBase.OnMouseLeave(e)
  338.         ButtonHState = ButtonHoverState.None : Invalidate()
  339.     End Sub
  340.  
  341.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  342.         MyBase.OnMouseDown(e)
  343.         Focus()
  344.     End Sub
  345.  
  346. #End Region
  347.  
  348.     Sub New()
  349.         MyBase.New()
  350.         DoubleBuffered = True
  351.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  352.     End Sub
  353.  
  354.     Protected Overrides Sub OnCreateControl()
  355.         MyBase.OnCreateControl()
  356.  
  357.     End Sub
  358.  
  359.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  360.         MyBase.OnPaint(e)
  361.         Dim G As Graphics = e.Graphics
  362.         G.Clear(Color.FromArgb(33, 36, 38))
  363.  
  364.         If _EnableHoverHighlight = True Then
  365.             Select Case ButtonHState
  366.                 Case ButtonHoverState.None
  367.                     G.Clear(Color.FromArgb(33, 36, 38))
  368.                 Case ButtonHoverState.Minimize
  369.                     If _EnableMinimize = True Then
  370.                         G.FillRectangle(New SolidBrush(Color.FromArgb(33, 36, 38)), New Rectangle(3, 0, 35, Height))
  371.                     End If
  372.                 Case ButtonHoverState.Close
  373.                     G.FillRectangle(New SolidBrush(Color.FromArgb(33, 36, 38)), New Rectangle(66, 0, 35, Height))
  374.             End Select
  375.         End If
  376.  
  377.         G.DrawString("r", New Font("Marlett", 11), New SolidBrush(Color.FromArgb(119, 131, 141)), New Point(Width - 16, 8), New StringFormat With {.Alignment = StringAlignment.Center})
  378.  
  379.         If _EnableMinimize = True Then
  380.             G.DrawString("0", New Font("Marlett", 11), New SolidBrush(Color.FromArgb(119, 131, 141)), New Point(40, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  381.         Else
  382.             G.DrawString("0", New Font("Marlett", 11), New SolidBrush(Color.FromArgb(119, 131, 141)), New Point(40, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  383.         End If
  384.     End Sub
  385. End Class
  386. '
  387. #End Region
  388. #Region " Button "
  389.  
  390.  
  391.  
  392.  
  393. Class ChiliButton : Inherits Control
  394.  
  395.  
  396.     Dim _state As MouseState
  397. #Region "Declaration and shits"
  398.     Public Function RoundRect(ByVal rectangle As Rectangle, ByVal curve As Integer) As GraphicsPath
  399.         Dim p As GraphicsPath = New GraphicsPath()
  400.         Dim arcRectangleWidth As Integer = curve * 1
  401.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  402.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  403.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  404.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  405.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  406.         Return p
  407.     End Function
  408.     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
  409.         Dim rectangle As Rectangle = New Rectangle(x, y, width, height)
  410.         Dim p As GraphicsPath = New GraphicsPath()
  411.         Dim arcRectangleWidth As Integer = curve * 1
  412.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  413.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  414.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  415.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  416.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  417.         Return p
  418.     End Function
  419.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  420.         MyBase.OnMouseDown(e)
  421.         _state = MouseState.Down
  422.         Invalidate()
  423.     End Sub
  424.  
  425.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  426.         MyBase.OnMouseUp(e)
  427.         _state = MouseState.Over
  428.         Invalidate()
  429.     End Sub
  430.  
  431.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  432.         MyBase.OnMouseEnter(e)
  433.         _state = MouseState.Over
  434.         Invalidate()
  435.     End Sub
  436.  
  437.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  438.         MyBase.OnMouseLeave(e)
  439.         _state = MouseState.None
  440.         Invalidate()
  441.     End Sub
  442.  
  443. #End Region
  444.  
  445.  
  446.     Sub New()
  447.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  448.         BackColor = Color.Transparent
  449.         DoubleBuffered = True
  450.         Size = New Size(150, 28)
  451.         _state = MouseState.None
  452.     End Sub
  453.  
  454.  
  455.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  456.         Dim b As Bitmap = New Bitmap(Width, Height)
  457.         Dim g As Graphics = Graphics.FromImage(b)
  458.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  459.         Dim btnfont As New Font("Verdana", 8, FontStyle.Regular)
  460.         MyBase.OnPaint(e)
  461.         g.SmoothingMode = SmoothingMode.HighQuality
  462.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  463.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  464.         g.Clear(BackColor)
  465.         Dim buttonrect As New LinearGradientBrush(rect, Color.FromArgb(0, 161, 255), Color.FromArgb(0, 161, 255), LinearGradientMode.Vertical)
  466.         g.FillPath(buttonrect, RoundRect(rect, 1))
  467.         g.DrawPath(New Pen(Color.FromArgb(0, 161, 255)), RoundRect(rect, 1))
  468.         Select Case _state
  469.             Case MouseState.None
  470.                 Dim buttonrectnone As New LinearGradientBrush(rect, Color.FromArgb(0, 161, 255), Color.FromArgb(0, 161, 255), LinearGradientMode.Vertical)
  471.                 g.FillPath(buttonrectnone, RoundRect(rect, 1))
  472.                 g.DrawPath(New Pen(Color.FromArgb(0, 161, 255)), RoundRect(rect, 3))
  473.                 g.DrawString(Text, btnfont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  474.             Case MouseState.Over
  475.                 Dim buttonrectnone As New LinearGradientBrush(rect, Color.FromArgb(0, 161, 255), Color.FromArgb(0, 161, 255), LinearGradientMode.Vertical)
  476.                 g.FillPath(buttonrectnone, RoundRect(rect, 1))
  477.                 g.DrawPath(New Pen(Color.FromArgb(0, 161, 255)), RoundRect(rect, 3))
  478.                 g.DrawString(Text, btnfont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  479.             Case MouseState.Down
  480.                 Dim buttonrectnone As New LinearGradientBrush(rect, Color.FromArgb(0, 153, 243), Color.FromArgb(0, 153, 243), LinearGradientMode.Vertical)
  481.                 g.FillPath(buttonrectnone, RoundRect(rect, 1))
  482.                 g.DrawPath(New Pen(Color.FromArgb(0, 153, 243)), RoundRect(rect, 3))
  483.                 g.DrawString(Text, btnfont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  484.         End Select
  485.         e.Graphics.DrawImage(b, New Point(0, 0))
  486.         g.Dispose() : b.Dispose()
  487.     End Sub
  488. End Class
  489.  
  490.  
  491.  
  492. #End Region
  493. #Region " Toggle Button "
  494.  
  495. <DefaultEvent("ToggledChanged")> Class Chili_Toggle
  496.     Inherits Control
  497.  
  498. #Region " Enums "
  499.  
  500.     Enum _Type
  501.         OnOff
  502.     End Enum
  503.  
  504. #End Region
  505. #Region " Variables "
  506.  
  507.     Event ToggledChanged()
  508.     Private _Toggled As Boolean
  509.     Private ToggleType As _Type
  510.     Private Bar As Rectangle
  511.     Private _Width, _Height As Integer
  512.  
  513. #End Region
  514. #Region " Properties "
  515.  
  516.     Public Property Toggled() As Boolean
  517.         Get
  518.             Return _Toggled
  519.         End Get
  520.         Set(ByVal value As Boolean)
  521.             _Toggled = value
  522.             Invalidate()
  523.             RaiseEvent ToggledChanged()
  524.         End Set
  525.     End Property
  526.  
  527.     Public Property Type As _Type
  528.         Get
  529.             Return ToggleType
  530.         End Get
  531.         Set(value As _Type)
  532.             ToggleType = value
  533.             Invalidate()
  534.         End Set
  535.     End Property
  536.  
  537. #End Region
  538. #Region " EventArgs "
  539.  
  540.     Protected Overrides Sub OnResize(e As EventArgs)
  541.         MyBase.OnResize(e)
  542.         Me.Size = New Size(70, 30)
  543.     End Sub
  544.  
  545.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  546.         MyBase.OnMouseUp(e)
  547.         Toggled = Not Toggled
  548.         Focus()
  549.     End Sub
  550.  
  551. #End Region
  552.  
  553.     Sub New()
  554.         SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  555.                   ControlStyles.DoubleBuffer Or _
  556.                   ControlStyles.ResizeRedraw Or _
  557.                   ControlStyles.UserPaint, True)
  558.     End Sub
  559.  
  560.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  561.         MyBase.OnPaint(e)
  562.         Dim G As Graphics = e.Graphics
  563.  
  564.         G.SmoothingMode = SmoothingMode.HighQuality
  565.         G.Clear(Parent.BackColor)
  566.         _Width = Width - 2 : _Height = Height - 2
  567.  
  568.         Dim GP, GP2 As New GraphicsPath
  569.         Dim BaseRect As New Rectangle(0, 0, _Width, _Height)
  570.         Dim ThumbRect As New Rectangle(CInt(_Width \ 2), 0, 38, _Height)
  571.  
  572.         With G
  573.             .SmoothingMode = 2
  574.             .PixelOffsetMode = 2
  575.             .TextRenderingHint = 5
  576.             .Clear(BackColor)
  577.  
  578.             GP = RoundRect(BaseRect, 1)
  579.             ThumbRect = New Rectangle(CInt(_Width \ 2) - 2, 1, 35, _Height - 2)
  580.             GP2 = RoundRect(ThumbRect, 1)
  581.             .FillPath(New SolidBrush(Color.FromArgb(63, 70, 73)), GP)
  582.             .FillPath(New SolidBrush(Color.FromArgb(32, 35, 37)), GP2) '32, 35, 37
  583.  
  584.             If _Toggled Then
  585.                 GP = RoundRect(BaseRect, 1)
  586.                 ThumbRect = New Rectangle(0, 0, 35, _Height - 0)
  587.                 GP2 = RoundRect(ThumbRect, 1)
  588.                 .FillPath(New SolidBrush(Color.FromArgb(63, 70, 73)), GP)
  589.                 .FillPath(New SolidBrush(Color.FromArgb(0, 161, 255)), GP2)
  590.             End If
  591.  
  592.             ' Draw string
  593.             Select Case ToggleType
  594.                 Case _Type.OnOff
  595.                     If Toggled Then
  596.                         G.DrawString("t", New Font("Marlett", 11, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 17, Bar.Y + 16, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  597.                     Else
  598.                         G.DrawString("r", New Font("Marlett", 11, FontStyle.Regular), Brushes.DimGray, Bar.X + 50, Bar.Y + 16, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  599.                     End If
  600.             End Select
  601.         End With
  602.     End Sub
  603. End Class
  604.  
  605. #End Region
  606. #Region " Social Button "
  607.  
  608. Class Chili_SocialButton
  609.     Inherits Control
  610.  
  611. #Region " Variables "
  612.  
  613.     Private EllipseColor As Color = Color.FromArgb(127, 187, 25)
  614.     Private EllipseColor2 As Color = Color.FromArgb(33, 36, 38)
  615.  
  616. #End Region
  617. #Region " Properties "
  618.  
  619.     Private O As _Options
  620.     <Flags()> _
  621.     Enum _Options
  622.         Normal
  623.         Warning
  624.     End Enum
  625.  
  626.     <Category("Options")> _
  627.     Public Property Style As _Options
  628.         Get
  629.             Return O
  630.         End Get
  631.         Set(value As _Options)
  632.             O = value
  633.         End Set
  634.     End Property
  635.  
  636. #End Region
  637. #Region " EventArgs "
  638.  
  639.     Protected Overrides Sub OnResize(e As EventArgs)
  640.         MyBase.OnResize(e)
  641.         Me.Size = New Size(100, 100)
  642.     End Sub
  643.  
  644.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  645.         MyBase.OnMouseEnter(e)
  646.         EllipseColor = EllipseColor
  647.         Refresh()
  648.     End Sub
  649.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  650.         MyBase.OnMouseLeave(e)
  651.         EllipseColor = EllipseColor
  652.         Refresh()
  653.     End Sub
  654.  
  655.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  656.         MyBase.OnMouseDown(e)
  657.         EllipseColor = EllipseColor
  658.         Focus()
  659.         Refresh()
  660.     End Sub
  661.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  662.         MyBase.OnMouseUp(e)
  663.         EllipseColor = EllipseColor
  664.         Refresh()
  665.     End Sub
  666.  
  667. #End Region
  668.  
  669.  
  670.  
  671.  
  672.     Sub New()
  673.         DoubleBuffered = True
  674.         Font = New Font("Verdana", 20, FontStyle.Regular)
  675.     End Sub
  676.  
  677.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  678.         Select Case O
  679.             Case _Options.Normal
  680.                 EllipseColor = Color.FromArgb(127, 187, 25)
  681.                 Dim G As Graphics = e.Graphics
  682.                 G.Clear(Parent.BackColor)
  683.                 G.SmoothingMode = SmoothingMode.HighQuality
  684.                 G.DrawEllipse(New Pen(EllipseColor), New Rectangle(10, 10, 85, 85))
  685.                 G.FillEllipse(New SolidBrush(EllipseColor2), New Rectangle(0, 0, 23, 23))
  686.                 G.DrawString("✓", New Font("Verdana", 20, FontStyle.Bold), New SolidBrush(EllipseColor), New Rectangle(0, 0, Width + 8, Height + 8), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  687.             Case _Options.Warning
  688.                 EllipseColor = Color.FromArgb(255, 31, 31)
  689.                 Dim G As Graphics = e.Graphics
  690.                 G.Clear(Parent.BackColor)
  691.                 G.SmoothingMode = SmoothingMode.HighQuality
  692.                 G.DrawEllipse(New Pen(EllipseColor), New Rectangle(10, 10, 85, 85))
  693.                 G.FillEllipse(New SolidBrush(EllipseColor2), New Rectangle(0, 0, 23, 23))
  694.                 G.DrawString("✕", New Font("Verdana", 20, FontStyle.Bold), New SolidBrush(EllipseColor), New Rectangle(0, 0, Width + 8, Height + 8), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  695.         End Select
  696.  
  697.  
  698.  
  699.  
  700.     End Sub
  701. End Class
  702.  
  703. #End Region
  704. #Region " Label "
  705.  
  706. Class Chili_Label
  707.     Inherits Label
  708.  
  709.     Sub New()
  710.         Font = New Font("Arial", 7)
  711.         ForeColor = Color.FromArgb(116, 125, 132)
  712.         BackColor = Color.Transparent
  713.     End Sub
  714. End Class
  715.  
  716. #End Region
  717. #Region " Panel "
  718.  
  719. Class Chili_Panel
  720.     Inherits ContainerControl
  721.  
  722.     Private Shape As GraphicsPath
  723.     Private Basecolor As Color
  724.     Private Basecolor2 As Color
  725.  
  726.     Private O As _Options
  727.     <Flags()> _
  728.     Enum _Options
  729.         Big
  730.         Small
  731.     End Enum
  732.  
  733.     <Category("Options")> _
  734.     Public Property Style As _Options
  735.         Get
  736.             Return O
  737.         End Get
  738.         Set(value As _Options)
  739.             O = value
  740.         End Set
  741.     End Property
  742.  
  743.     Sub New()
  744.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  745.         SetStyle(ControlStyles.UserPaint, True)
  746.         Select Case O
  747.             Case _Options.Big
  748.                 BackColor = Color.FromArgb(85, 94, 102)
  749.                 Basecolor = Color.FromArgb(85, 94, 102)
  750.             Case _Options.Small
  751.                 BackColor = Color.FromArgb(64, 71, 77)
  752.                 Basecolor2 = Color.FromArgb(64, 71, 77)
  753.         End Select
  754.         Me.Size = New Size(187, 117)
  755.         Padding = New Padding(5, 5, 5, 5)
  756.         DoubleBuffered = True
  757.     End Sub
  758.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  759.         MyBase.OnMouseEnter(e)
  760.         Select Case O
  761.             Case _Options.Big
  762.                 Basecolor = Color.FromArgb(0, 161, 255)
  763.             Case _Options.Small
  764.                 Basecolor2 = Color.FromArgb(0, 161, 255)
  765.         End Select
  766.         Refresh()
  767.     End Sub
  768.  
  769.  
  770.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  771.         MyBase.OnMouseDown(e)
  772.         Select Case O
  773.             Case _Options.Big
  774.                 Basecolor = Color.FromArgb(0, 161, 255)
  775.             Case _Options.Small
  776.                 Basecolor2 = Color.FromArgb(0, 161, 255)
  777.         End Select
  778.         Focus()
  779.         Refresh()
  780.     End Sub
  781.  
  782.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  783.         MyBase.OnMouseUp(e)
  784.         Select Case O
  785.             Case _Options.Big
  786.                 Basecolor = Color.FromArgb(0, 161, 255)
  787.             Case _Options.Small
  788.                 Basecolor2 = Color.FromArgb(0, 161, 255)
  789.         End Select
  790.         Refresh()
  791.     End Sub
  792.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  793.         MyBase.OnMouseLeave(e)
  794.         Select Case O
  795.             Case _Options.Big
  796.                 Basecolor = Color.FromArgb(85, 94, 102)
  797.             Case _Options.Small
  798.                 Basecolor2 = Color.FromArgb(64, 71, 77)
  799.         End Select
  800.  
  801.         Refresh()
  802.     End Sub
  803.     Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  804.         MyBase.OnResize(e)
  805.  
  806.         Shape = New GraphicsPath
  807.         With Shape
  808.             .AddArc(0, 0, 10, 10, 180, 90)
  809.             .AddArc(Width - 11, 0, 10, 10, -90, 90)
  810.             .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  811.             .AddArc(0, Height - 11, 10, 10, 90, 90)
  812.             .CloseAllFigures()
  813.         End With
  814.     End Sub
  815.  
  816.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  817.         Select Case O
  818.             Case _Options.Big
  819.                 Size = New Size(150, 150)
  820.                 MyBase.OnPaint(e)
  821.                 Dim B As New Bitmap(Width, Height)
  822.                 Dim G = Graphics.FromImage(B)
  823.  
  824.                 G.SmoothingMode = SmoothingMode.HighQuality
  825.  
  826.                 G.Clear(Basecolor)
  827.                 G.FillPath(New SolidBrush(Basecolor), Shape)
  828.                 G.DrawPath(New Pen(Basecolor), Shape)
  829.  
  830.                 G.Dispose()
  831.                 e.Graphics.DrawImage(B.Clone(), 0, 0)
  832.                 B.Dispose()
  833.             Case _Options.Small
  834.                 Size = New Size(73, 73)
  835.                 MyBase.OnPaint(e)
  836.                 Dim B As New Bitmap(Width, Height)
  837.                 Dim G = Graphics.FromImage(B)
  838.  
  839.                 G.SmoothingMode = SmoothingMode.HighQuality
  840.  
  841.                 G.Clear(Basecolor2)
  842.                 G.FillPath(New SolidBrush(Basecolor2), Shape)
  843.                 G.DrawPath(New Pen(Basecolor2), Shape)
  844.  
  845.                 G.Dispose()
  846.                 e.Graphics.DrawImage(B.Clone(), 0, 0)
  847.                 B.Dispose()
  848.         End Select
  849.  
  850.  
  851.     End Sub
  852. End Class
  853.  
  854. #End Region
  855. #Region " Radio Button "
  856.  
  857. <DefaultEvent("CheckedChanged")> Class Chili_RadioButton
  858.     Inherits Control
  859. #Region " Variables "
  860.  
  861.     Private X As Integer
  862.     Private _Checked As Boolean
  863.  
  864. #End Region
  865. #Region " Properties "
  866.  
  867.     Property Checked() As Boolean
  868.         Get
  869.             Return _Checked
  870.         End Get
  871.         Set(ByVal value As Boolean)
  872.             _Checked = value
  873.             InvalidateControls()
  874.             RaiseEvent CheckedChanged(Me)
  875.             Invalidate()
  876.         End Set
  877.     End Property
  878.  
  879. #End Region
  880. #Region " EventArgs "
  881.  
  882.     Event CheckedChanged(ByVal sender As Object)
  883.  
  884.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  885.         If Not _Checked Then Checked = True
  886.         Focus()
  887.         MyBase.OnMouseDown(e)
  888.     End Sub
  889.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  890.         MyBase.OnMouseMove(e)
  891.         X = e.X
  892.         Invalidate()
  893.     End Sub
  894.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  895.         MyBase.OnTextChanged(e)
  896.         Dim textSize As Integer
  897.         textSize = Me.CreateGraphics.MeasureString(Text, Font).Width
  898.         Me.Width = 28 + textSize
  899.     End Sub
  900.  
  901.     Protected Overrides Sub OnResize(e As EventArgs)
  902.         MyBase.OnResize(e)
  903.         Me.Height = 17
  904.     End Sub
  905.  
  906. #End Region
  907.  
  908.     Public Sub New()
  909.         Width = 159
  910.         Height = 17
  911.         DoubleBuffered = True
  912.     End Sub
  913.  
  914.  
  915.  
  916.     Private Sub InvalidateControls()
  917.         If Not IsHandleCreated OrElse Not _Checked Then Return
  918.  
  919.         For Each _Control As Control In Parent.Controls
  920.             If _Control IsNot Me AndAlso TypeOf _Control Is Chili_RadioButton Then
  921.                 DirectCast(_Control, Chili_RadioButton).Checked = False
  922.             End If
  923.         Next
  924.     End Sub
  925.  
  926.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  927.         MyBase.OnPaint(e)
  928.         Dim G As Graphics = e.Graphics
  929.         G.Clear(Parent.BackColor)
  930.         G.SmoothingMode = SmoothingMode.HighQuality
  931.  
  932.         G.FillEllipse(New SolidBrush(Color.FromArgb(254, 254, 254)), New Rectangle(0, 0, 16, 16))
  933.  
  934.         If _Checked Then
  935.             G.Clear(Parent.BackColor)
  936.             G.FillEllipse(New SolidBrush(Color.FromArgb(0, 160, 254)), New Rectangle(0, 0, 16, 16))
  937.             G.FillEllipse(New SolidBrush(Color.FromArgb(254, 254, 254)), New Rectangle(5, 5, 6, 6))
  938.         End If
  939.  
  940.         G.DrawString(Text, Font, New SolidBrush(Color.FromArgb(116, 125, 132)), New Point(20, 0))
  941.     End Sub
  942. End Class
  943.  
  944. #End Region
  945. #Region " CheckBox "
  946.  
  947. <DefaultEvent("CheckedChanged")> Class Chili_CheckBox
  948.     Inherits Control
  949.  
  950. #Region " Variables "
  951.  
  952.     Private X As Integer
  953.     Private _Checked As Boolean = False
  954.     Private Shape As GraphicsPath
  955.  
  956. #End Region
  957. #Region " Properties "
  958.  
  959.     Property Checked() As Boolean
  960.         Get
  961.             Return _Checked
  962.         End Get
  963.         Set(ByVal value As Boolean)
  964.             _Checked = value
  965.             Invalidate()
  966.         End Set
  967.     End Property
  968.  
  969. #End Region
  970. #Region " EventArgs "
  971.  
  972.     Event CheckedChanged(ByVal sender As Object)
  973.  
  974.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  975.         MyBase.OnMouseMove(e)
  976.         X = e.Location.X
  977.         Invalidate()
  978.     End Sub
  979.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  980.         _Checked = Not _Checked
  981.         Focus()
  982.         RaiseEvent CheckedChanged(Me)
  983.         MyBase.OnMouseDown(e)
  984.     End Sub
  985.  
  986.     Protected Overrides Sub OnResize(e As EventArgs)
  987.         MyBase.OnResize(e)
  988.  
  989.         Me.Height = 16
  990.  
  991.         Shape = New GraphicsPath
  992.         With Shape
  993.             .AddArc(0, 0, 10, 10, 180, 90)
  994.             .AddArc(Width - 11, 0, 10, 10, -90, 90)
  995.             .AddArc(Width - 11, Height - 11, 10, 10, 0, 90)
  996.             .AddArc(0, Height - 11, 10, 10, 90, 90)
  997.             .CloseAllFigures()
  998.         End With
  999.         Invalidate()
  1000.     End Sub
  1001.  
  1002. #End Region
  1003.  
  1004.     Sub New()
  1005.         Width = 148
  1006.         Height = 16
  1007.         Font = New Font("Microsoft Sans Serif", 9)
  1008.         DoubleBuffered = True
  1009.     End Sub
  1010.  
  1011.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1012.         MyBase.OnPaint(e)
  1013.         Dim G As Graphics = e.Graphics
  1014.         G.Clear(Parent.BackColor)
  1015.  
  1016.         If _Checked Then
  1017.             G.FillRectangle(New SolidBrush(Color.FromArgb(0, 161, 255)), New Rectangle(0, 0, 16, 16))
  1018.             G.FillRectangle(New SolidBrush(Color.FromArgb(0, 161, 255)), New Rectangle(1, 1, 16 - 2, 16 - 2))
  1019.         Else
  1020.             G.FillRectangle(New SolidBrush(Color.FromArgb(254, 254, 254)), New Rectangle(0, 0, 16, 16))
  1021.             G.FillRectangle(New SolidBrush(Color.FromArgb(254, 254, 254)), New Rectangle(1, 1, 16 - 2, 16 - 2))
  1022.         End If
  1023.  
  1024.         If Enabled = True Then
  1025.             If _Checked Then G.DrawString("a", New Font("Marlett", 12), New SolidBrush(Color.FromArgb(254, 254, 254)), New Point(-2, -1))
  1026.         Else
  1027.             If _Checked Then G.DrawString("a", New Font("Marlett", 12), New SolidBrush(Color.Gray), New Point(-5, -3))
  1028.         End If
  1029.  
  1030.         G.DrawString(Text, Font, New SolidBrush(Color.FromArgb(116, 125, 132)), New Point(20, 0))
  1031.     End Sub
  1032. End Class
  1033. #End Region
  1034. #Region " TextBox "
  1035.  
  1036. <DefaultEvent("TextChanged")> Class Chili_TextBox
  1037.     Inherits Control
  1038.  
  1039. #Region " Variables "
  1040.  
  1041.     Public WithEvents ChiliTB As New TextBox
  1042.     Private _maxchars As Integer = 32767
  1043.     Private _ReadOnly As Boolean
  1044.     Private _Multiline As Boolean
  1045.     Private _Image As Image
  1046.     Private _ImageSize As Size
  1047.     Private ALNType As HorizontalAlignment
  1048.     Private isPasswordMasked As Boolean = False
  1049.     Private P1 As Pen
  1050.     Private B1 As SolidBrush
  1051.     Private Shape As GraphicsPath
  1052.  
  1053. #End Region
  1054. #Region " Properties "
  1055.  
  1056.     Public Shadows Property TextAlignment() As HorizontalAlignment
  1057.         Get
  1058.             Return ALNType
  1059.         End Get
  1060.         Set(ByVal Val As HorizontalAlignment)
  1061.             ALNType = Val
  1062.             Invalidate()
  1063.         End Set
  1064.     End Property
  1065.     Public Shadows Property MaxLength() As Integer
  1066.         Get
  1067.             Return _maxchars
  1068.         End Get
  1069.         Set(ByVal Val As Integer)
  1070.             _maxchars = Val
  1071.             ChiliTB.MaxLength = MaxLength
  1072.             Invalidate()
  1073.         End Set
  1074.     End Property
  1075.  
  1076.     Public Shadows Property UseSystemPasswordChar() As Boolean
  1077.         Get
  1078.             Return isPasswordMasked
  1079.         End Get
  1080.         Set(ByVal Val As Boolean)
  1081.             ChiliTB.UseSystemPasswordChar = UseSystemPasswordChar
  1082.             isPasswordMasked = Val
  1083.             Invalidate()
  1084.         End Set
  1085.     End Property
  1086.  
  1087.  
  1088.  
  1089.  
  1090. #End Region
  1091. #Region " EventArgs "
  1092.  
  1093.  
  1094.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  1095.         MyBase.OnTextChanged(e)
  1096.         Invalidate()
  1097.     End Sub
  1098.  
  1099.     Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  1100.         MyBase.OnForeColorChanged(e)
  1101.         ChiliTB.ForeColor = ForeColor
  1102.         Invalidate()
  1103.     End Sub
  1104.  
  1105.     Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  1106.         MyBase.OnFontChanged(e)
  1107.         ChiliTB.Font = Font
  1108.     End Sub
  1109.  
  1110.     Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
  1111.         MyBase.OnPaintBackground(e)
  1112.     End Sub
  1113.  
  1114.  
  1115.  
  1116.     Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  1117.         MyBase.OnResize(e)
  1118.  
  1119.     End Sub
  1120.  
  1121.     Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  1122.         MyBase.OnGotFocus(e)
  1123.         ChiliTB.Focus()
  1124.     End Sub
  1125.  
  1126.     Sub _TextChanged() Handles ChiliTB.TextChanged
  1127.         Text = ChiliTB.Text
  1128.     End Sub
  1129.  
  1130.     Sub _BaseTextChanged() Handles MyBase.TextChanged
  1131.         ChiliTB.Text = Text
  1132.     End Sub
  1133.  
  1134. #End Region
  1135.  
  1136.     Sub AddTextBox()
  1137.         With ChiliTB
  1138.             .Location = New Point(8, 10)
  1139.             .Text = String.Empty
  1140.             .BorderStyle = BorderStyle.None
  1141.             .TextAlign = HorizontalAlignment.Left
  1142.             .Font = New Font("Tahoma", 8)
  1143.             .ForeColor = Color.White
  1144.             .UseSystemPasswordChar = UseSystemPasswordChar
  1145.             .Multiline = False
  1146.             .BackColor = Color.FromArgb(66, 76, 85)
  1147.             .ScrollBars = ScrollBars.None
  1148.         End With
  1149.         'AddHandler ChiliTB.KeyDown, AddressOf _OnKeyDown
  1150.         'AddHandler ChiliTB.Enter, AddressOf _Enter
  1151.         'AddHandler ChiliTB.Leave, AddressOf _Leave
  1152.     End Sub
  1153.  
  1154.     Sub New()
  1155.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  1156.         SetStyle(ControlStyles.UserPaint, True)
  1157.  
  1158.         AddTextBox()
  1159.         Controls.Add(ChiliTB)
  1160.  
  1161.         'P1 = New Pen(Color.FromArgb(66, 76, 85))
  1162.         B1 = New SolidBrush(Color.FromArgb(66, 76, 85))
  1163.         BackColor = Color.Transparent
  1164.         ForeColor = Color.White
  1165.  
  1166.         Text = Nothing
  1167.         Font = New Font("Tahoma", 11)
  1168.         Size = New Size(118, 28)
  1169.         DoubleBuffered = True
  1170.     End Sub
  1171.  
  1172.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  1173.         Dim B = New Bitmap(Width, Height) : Dim G = Graphics.FromImage(B)
  1174.         Dim W = Width + 20 : Dim H = Height + 1
  1175.  
  1176.         Dim Base As New Rectangle(-1, 50, W + 7, H + 20)
  1177.  
  1178.         With G
  1179.             .SmoothingMode = 2
  1180.             .PixelOffsetMode = 2
  1181.             .TextRenderingHint = 5
  1182.             .Clear(BackColor)
  1183.  
  1184.             '-- Colors
  1185.             BackColor = Color.FromArgb(66, 76, 85)
  1186.  
  1187.             '-- Base
  1188.             .FillRectangle(New SolidBrush(Color.FromArgb(66, 76, 85)), Base)
  1189.             .DrawString(Text, New Font("Tahoma", 11), New SolidBrush(Color.White), W - 1, H + 50)
  1190.         End With
  1191.  
  1192.         MyBase.OnPaint(e)
  1193.         G.Dispose()
  1194.         e.Graphics.InterpolationMode = 7
  1195.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  1196.         B.Dispose()
  1197.     End Sub
  1198. End Class
  1199.  
  1200. #End Region
  1201. Class ChiliTextbox : Inherits Control
  1202.     Dim WithEvents _tb As New TextBox
  1203.  
  1204.  
  1205.     Private O As _Options
  1206.     <Flags()> _
  1207.     Enum _Options
  1208.         Enabled
  1209.         Disabled
  1210.     End Enum
  1211.  
  1212.     <Category("Options")> _
  1213.     Public Property TextboxStyle As _Options
  1214.         Get
  1215.             Return O
  1216.         End Get
  1217.         Set(value As _Options)
  1218.             O = value
  1219.         End Set
  1220.     End Property
  1221.  
  1222.  
  1223.     <Category("Colors")> _
  1224.     Public Property BaseColor() As Color
  1225.         Get
  1226.             Return _BaseColor
  1227.         End Get
  1228.         Set(value As Color)
  1229.             _BaseColor = value
  1230.         End Set
  1231.     End Property
  1232.  
  1233.     <Category("Colors")> _
  1234.     Public Property BackgroundText() As Color
  1235.         Get
  1236.             Return _BackgroundText
  1237.         End Get
  1238.         Set(value As Color)
  1239.             _BackgroundText = value
  1240.         End Set
  1241.     End Property
  1242.  
  1243.     Private _BaseColor As Color = Color.FromArgb(63, 70, 76)
  1244.     Private _BackgroundText As Color = Color.FromArgb(63, 70, 76)
  1245.  
  1246.  
  1247. #Region "Declaration and shits"
  1248.     Public Function RoundRect(ByVal rectangle As Rectangle, ByVal curve As Integer) As GraphicsPath
  1249.         Dim p As GraphicsPath = New GraphicsPath()
  1250.         Dim arcRectangleWidth As Integer = curve * 2
  1251.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  1252.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  1253.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  1254.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  1255.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  1256.         Return p
  1257.     End Function
  1258.     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
  1259.         Dim rectangle As Rectangle = New Rectangle(x, y, width, height)
  1260.         Dim p As GraphicsPath = New GraphicsPath()
  1261.         Dim arcRectangleWidth As Integer = curve * 2
  1262.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  1263.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  1264.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  1265.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  1266.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  1267.         Return p
  1268.     End Function
  1269.  
  1270.     Private _allowpassword As Boolean = False
  1271.     Public Shadows Property UseSystemPasswordChar() As Boolean
  1272.         Get
  1273.             Return _allowpassword
  1274.         End Get
  1275.         Set(ByVal value As Boolean)
  1276.             _tb.UseSystemPasswordChar = UseSystemPasswordChar
  1277.             _allowpassword = value
  1278.             Invalidate()
  1279.         End Set
  1280.     End Property
  1281.  
  1282.     Private _maxChars As Integer = 32767
  1283.     Public Shadows Property MaxLength() As Integer
  1284.         Get
  1285.             Return _maxChars
  1286.         End Get
  1287.         Set(ByVal value As Integer)
  1288.             _maxChars = value
  1289.             _tb.MaxLength = MaxLength
  1290.             Invalidate()
  1291.         End Set
  1292.     End Property
  1293.  
  1294.     Private _textAlignment As HorizontalAlignment
  1295.     Public Shadows Property TextAlign() As HorizontalAlignment
  1296.         Get
  1297.             Return _textAlignment
  1298.         End Get
  1299.         Set(ByVal value As HorizontalAlignment)
  1300.             _textAlignment = value
  1301.             Invalidate()
  1302.         End Set
  1303.     End Property
  1304.  
  1305.     Private _multiLine As Boolean = False
  1306.     Public Shadows Property MultiLine() As Boolean
  1307.         Get
  1308.             Return _multiLine
  1309.         End Get
  1310.         Set(ByVal value As Boolean)
  1311.             _multiLine = value
  1312.             _tb.Multiline = value
  1313.             OnResize(EventArgs.Empty)
  1314.             Invalidate()
  1315.         End Set
  1316.     End Property
  1317.  
  1318.     Private _readOnly As Boolean = False
  1319.     Public Shadows Property [ReadOnly]() As Boolean
  1320.         Get
  1321.             Return _readOnly
  1322.         End Get
  1323.         Set(ByVal value As Boolean)
  1324.             _readOnly = value
  1325.             If _tb IsNot Nothing Then
  1326.                 _tb.ReadOnly = value
  1327.             End If
  1328.         End Set
  1329.     End Property
  1330.  
  1331.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  1332.         MyBase.OnTextChanged(e)
  1333.         Invalidate()
  1334.     End Sub
  1335.  
  1336.     Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
  1337.         MyBase.OnBackColorChanged(e)
  1338.         Invalidate()
  1339.     End Sub
  1340.  
  1341.     Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
  1342.         MyBase.OnForeColorChanged(e)
  1343.         _tb.ForeColor = ForeColor
  1344.         Invalidate()
  1345.     End Sub
  1346.  
  1347.     Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
  1348.         MyBase.OnFontChanged(e)
  1349.         _tb.Font = Font
  1350.     End Sub
  1351.  
  1352.     Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
  1353.         MyBase.OnGotFocus(e)
  1354.         _tb.Focus()
  1355.     End Sub
  1356.  
  1357.     Private Sub TextChangeTb() Handles _tb.TextChanged
  1358.         Text = _tb.Text
  1359.     End Sub
  1360.  
  1361.     Private Sub TextChng() Handles MyBase.TextChanged
  1362.         _tb.Text = Text
  1363.     End Sub
  1364.  
  1365. #End Region
  1366.  
  1367.     Public Sub NewTextBox()
  1368.         With _tb
  1369.             .Text = String.Empty
  1370.             .BackColor = _BackgroundText
  1371.             .ForeColor = ForeColor
  1372.             .TextAlign = HorizontalAlignment.Left
  1373.             .BorderStyle = BorderStyle.None
  1374.             .Location = New Point(3, 3)
  1375.             .Font = New Font("Verdana", 10, FontStyle.Regular)
  1376.             .Size = New Size(Width - 3, Height - 3)
  1377.             .UseSystemPasswordChar = UseSystemPasswordChar
  1378.         End With
  1379.     End Sub
  1380.  
  1381.     Sub New()
  1382.         MyBase.New()
  1383.         NewTextBox()
  1384.         Controls.Add(_tb)
  1385.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  1386.         DoubleBuffered = True
  1387.         TextAlign = HorizontalAlignment.Left
  1388.         BackColor = _BaseColor
  1389.         ForeColor = Color.White
  1390.         Font = New Font("Verdana", 10, FontStyle.Regular)
  1391.         Size = New Size(132, 29)
  1392.     End Sub
  1393.  
  1394.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  1395.         Select Case O
  1396.             Case _Options.Enabled
  1397.                 Dim b As Bitmap = New Bitmap(Width, Height)
  1398.                 Dim g As Graphics = Graphics.FromImage(b)
  1399.                 Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  1400.                 MyBase.OnPaint(e)
  1401.                 g.SmoothingMode = SmoothingMode.HighQuality
  1402.                 g.InterpolationMode = InterpolationMode.HighQualityBicubic
  1403.                 g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  1404.                 With _tb
  1405.                     .TextAlign = TextAlign
  1406.                     .UseSystemPasswordChar = UseSystemPasswordChar
  1407.                 End With
  1408.                 g.FillPath(New SolidBrush(_BackgroundText), RoundRect(rect, 3))
  1409.                 e.Graphics.DrawImage(b, New Point(0, 0))
  1410.                 ForeColor = Color.White
  1411.                 g.Dispose() : b.Dispose()
  1412.  
  1413.             Case _Options.Disabled
  1414.  
  1415.                 Dim b As Bitmap = New Bitmap(Width, Height)
  1416.                 Dim g As Graphics = Graphics.FromImage(b)
  1417.                 Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  1418.                 MyBase.OnPaint(e)
  1419.                 g.SmoothingMode = SmoothingMode.HighQuality
  1420.                 g.InterpolationMode = InterpolationMode.HighQualityBicubic
  1421.                 g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  1422.                 With _tb
  1423.                     .TextAlign = TextAlign
  1424.                     .UseSystemPasswordChar = UseSystemPasswordChar
  1425.                 End With
  1426.                 g.FillPath(New SolidBrush(Color.FromArgb(63, 70, 76)), RoundRect(rect, 3))
  1427.                 g.DrawPath(New Pen(Color.FromArgb(63, 70, 76)), RoundRect(rect, 3))
  1428.                 e.Graphics.DrawImage(b, New Point(0, 0))
  1429.                 ForeColor = Color.FromArgb(63, 70, 76)
  1430.                 Enabled = False
  1431.                 g.Dispose() : b.Dispose()
  1432.         End Select
  1433.  
  1434.     End Sub
  1435.  
  1436.     Protected Overrides Sub OnResize(e As EventArgs)
  1437.         MyBase.OnResize(e)
  1438.         If Not MultiLine Then
  1439.             Dim tbheight As Integer = _tb.Height
  1440.             _tb.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 0), Integer))
  1441.             _tb.Size = New Size(Width - 20, tbheight)
  1442.         Else
  1443.             _tb.Location = New Point(10, 10)
  1444.             _tb.Size = New Size(Width - 20, Height - 20)
  1445.         End If
  1446.     End Sub
  1447. End Class
  1448. #Region " Separator "
  1449.  
  1450. Class Chili_Separator
  1451.     Inherits Control
  1452.  
  1453.     Sub New()
  1454.         SetStyle(ControlStyles.ResizeRedraw, True)
  1455.         Me.Size = New Point(120, 10)
  1456.     End Sub
  1457.  
  1458.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  1459.         MyBase.OnPaint(e)
  1460.         e.Graphics.DrawLine(New Pen(Color.FromArgb(58, 64, 70)), 1, 5, Width, 5)
  1461.     End Sub
  1462. End Class
  1463.  
  1464. #End Region
Advertisement
Add Comment
Please, Sign In to add comment