Advertisement
Guest User

Xylos Theme [9 Controls]

a guest
Oct 11th, 2015
4,982
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 36.26 KB | None | 0 0
  1. ' Xylos Theme.
  2. ' Made by AeroRev9.
  3. ' 9 Controls.
  4.  
  5. Friend Module Helpers
  6.  
  7.     Enum RoundingStyle As Byte
  8.         All = 0
  9.         Top = 1
  10.         Bottom = 2
  11.         Left = 3
  12.         Right = 4
  13.         TopRight = 5
  14.         BottomRight = 6
  15.     End Enum
  16.  
  17.     Public Sub CenterString(G As Graphics, T As String, F As Font, C As Color, R As Rectangle)
  18.         Dim TS As SizeF = G.MeasureString(T, F)
  19.  
  20.         Using B As New SolidBrush(C)
  21.             G.DrawString(T, F, B, New Point(R.Width / 2 - (TS.Width / 2), R.Height / 2 - (TS.Height / 2)))
  22.         End Using
  23.     End Sub
  24.  
  25.     Public Function ColorFromHex(Hex As String) As Color
  26.         Return Color.FromArgb(Long.Parse(String.Format("FFFFFFFFFF{0}", Hex.Substring(1)), Globalization.NumberStyles.HexNumber))
  27.     End Function
  28.  
  29.     Public Function FullRectangle(S As Size, Subtract As Boolean) As Rectangle
  30.  
  31.         If Subtract Then
  32.             Return New Rectangle(0, 0, S.Width - 1, S.Height - 1)
  33.         Else
  34.             Return New Rectangle(0, 0, S.Width, S.Height)
  35.         End If
  36.  
  37.     End Function
  38.  
  39.     Public Function RoundRect(ByVal Rect As Rectangle, ByVal Rounding As Integer, Optional ByVal Style As RoundingStyle = RoundingStyle.All) As Drawing2D.GraphicsPath
  40.  
  41.         Dim GP As New Drawing2D.GraphicsPath()
  42.         Dim AW As Integer = Rounding * 2
  43.  
  44.         GP.StartFigure()
  45.  
  46.         If Rounding = 0 Then
  47.             GP.AddRectangle(Rect)
  48.             GP.CloseAllFigures()
  49.             Return GP
  50.         End If
  51.  
  52.         Select Case Style
  53.             Case RoundingStyle.All
  54.                 GP.AddArc(New Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90)
  55.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90)
  56.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90)
  57.                 GP.AddArc(New Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90)
  58.             Case RoundingStyle.Top
  59.                 GP.AddArc(New Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90)
  60.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90)
  61.                 GP.AddLine(New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y + Rect.Height))
  62.             Case RoundingStyle.Bottom
  63.                 GP.AddLine(New Point(Rect.X, Rect.Y), New Point(Rect.X + Rect.Width, Rect.Y))
  64.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90)
  65.                 GP.AddArc(New Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90)
  66.             Case RoundingStyle.Left
  67.                 GP.AddArc(New Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90)
  68.                 GP.AddLine(New Point(Rect.X + Rect.Width, Rect.Y), New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height))
  69.                 GP.AddArc(New Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90)
  70.             Case RoundingStyle.Right
  71.                 GP.AddLine(New Point(Rect.X, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y))
  72.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90)
  73.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90)
  74.             Case RoundingStyle.TopRight
  75.                 GP.AddLine(New Point(Rect.X, Rect.Y + 1), New Point(Rect.X, Rect.Y))
  76.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90)
  77.                 GP.AddLine(New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height - 1), New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height))
  78.                 GP.AddLine(New Point(Rect.X + 1, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y + Rect.Height))
  79.             Case RoundingStyle.BottomRight
  80.                 GP.AddLine(New Point(Rect.X, Rect.Y + 1), New Point(Rect.X, Rect.Y))
  81.                 GP.AddLine(New Point(Rect.X + Rect.Width - 1, Rect.Y), New Point(Rect.X + Rect.Width, Rect.Y))
  82.                 GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90)
  83.                 GP.AddLine(New Point(Rect.X + 1, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y + Rect.Height))
  84.         End Select
  85.  
  86.         GP.CloseAllFigures()
  87.  
  88.         Return GP
  89.  
  90.     End Function
  91.  
  92. End Module
  93.  
  94. Public Class XylosTabControl
  95.     Inherits TabControl
  96.  
  97.     Private G As Graphics
  98.     Private Rect As Rectangle
  99.     Private _OverIndex As Integer = -1
  100.  
  101.     Public Property FirstHeaderBorder As Boolean
  102.  
  103.     Private Property OverIndex As Integer
  104.         Get
  105.             Return _OverIndex
  106.         End Get
  107.         Set(value As Integer)
  108.             _OverIndex = value
  109.             Invalidate()
  110.         End Set
  111.     End Property
  112.  
  113.     Sub New()
  114.         DoubleBuffered = True
  115.         Alignment = TabAlignment.Left
  116.         SizeMode = TabSizeMode.Fixed
  117.         ItemSize = New Size(40, 180)
  118.     End Sub
  119.  
  120.     Protected Overrides Sub OnCreateControl()
  121.         MyBase.OnCreateControl()
  122.         SetStyle(ControlStyles.UserPaint, True)
  123.     End Sub
  124.  
  125.     Protected Overrides Sub OnControlAdded(e As ControlEventArgs)
  126.         MyBase.OnControlAdded(e)
  127.         e.Control.BackColor = Color.White
  128.         e.Control.ForeColor = ColorFromHex("#7C858E")
  129.         e.Control.Font = New Font("Segoe UI", 9)
  130.     End Sub
  131.  
  132.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  133.         G = e.Graphics
  134.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  135.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  136.  
  137.         MyBase.OnPaint(e)
  138.  
  139.         G.Clear(ColorFromHex("#33373B"))
  140.  
  141.         For I As Integer = 0 To TabPages.Count - 1
  142.  
  143.             Rect = GetTabRect(I)
  144.  
  145.             If String.IsNullOrEmpty(TabPages(I).Tag) Then
  146.  
  147.                 If SelectedIndex = I Then
  148.  
  149.                     Using Background As New SolidBrush(ColorFromHex("#2B2F33")), TextColor As New SolidBrush(ColorFromHex("#BECCD9")), TextFont As New Font("Segoe UI semibold", 9)
  150.                         G.FillRectangle(Background, New Rectangle(Rect.X - 5, Rect.Y + 1, Rect.Width + 7, Rect.Height))
  151.                         G.DrawString(TabPages(I).Text, TextFont, TextColor, New Point(Rect.X + 50 + (ItemSize.Height - 180), Rect.Y + 12))
  152.                     End Using
  153.  
  154.                 Else
  155.  
  156.                     Using TextColor As New SolidBrush(ColorFromHex("#919BA6")), TextFont As New Font("Segoe UI semibold", 9)
  157.                         G.DrawString(TabPages(I).Text, TextFont, TextColor, New Point(Rect.X + 50 + (ItemSize.Height - 180), Rect.Y + 12))
  158.                     End Using
  159.  
  160.                 End If
  161.  
  162.                 If Not OverIndex = -1 And Not SelectedIndex = OverIndex Then
  163.  
  164.                     Using Background As New SolidBrush(ColorFromHex("#2F3338")), TextColor As New SolidBrush(ColorFromHex("#919BA6")), TextFont As New Font("Segoe UI semibold", 9)
  165.                         G.FillRectangle(Background, New Rectangle(GetTabRect(OverIndex).X - 5, GetTabRect(OverIndex).Y + 1, GetTabRect(OverIndex).Width + 7, GetTabRect(OverIndex).Height))
  166.                         G.DrawString(TabPages(OverIndex).Text, TextFont, TextColor, New Point(GetTabRect(OverIndex).X + 50 + (ItemSize.Height - 180), GetTabRect(OverIndex).Y + 12))
  167.                     End Using
  168.  
  169.                     If Not IsNothing(ImageList) Then
  170.                         If Not TabPages(OverIndex).ImageIndex < 0 Then
  171.                             G.DrawImage(ImageList.Images(TabPages(OverIndex).ImageIndex), New Rectangle(GetTabRect(OverIndex).X + 25 + (ItemSize.Height - 180), GetTabRect(OverIndex).Y + ((GetTabRect(OverIndex).Height / 2) - 9), 16, 16))
  172.                         End If
  173.                     End If
  174.  
  175.                 End If
  176.  
  177.  
  178.                 If Not IsNothing(ImageList) Then
  179.                     If Not TabPages(I).ImageIndex < 0 Then
  180.                         G.DrawImage(ImageList.Images(TabPages(I).ImageIndex), New Rectangle(Rect.X + 25 + (ItemSize.Height - 180), Rect.Y + ((Rect.Height / 2) - 9), 16, 16))
  181.                     End If
  182.                 End If
  183.  
  184.             Else
  185.  
  186.                 Using TextColor As New SolidBrush(ColorFromHex("#6A7279")), TextFont As New Font("Segoe UI", 7, FontStyle.Bold), Border As New Pen(ColorFromHex("#2B2F33"))
  187.  
  188.                     If FirstHeaderBorder Then
  189.                         G.DrawLine(Border, New Point(Rect.X - 5, Rect.Y + 1), New Point(Rect.Width + 7, Rect.Y + 1))
  190.                     Else
  191.                         If Not I = 0 Then
  192.                             G.DrawLine(Border, New Point(Rect.X - 5, Rect.Y + 1), New Point(Rect.Width + 7, Rect.Y + 1))
  193.                         End If
  194.                     End If
  195.  
  196.                     G.DrawString(TabPages(I).Text.ToUpper, TextFont, TextColor, New Point(Rect.X + 25 + (ItemSize.Height - 180), Rect.Y + 16))
  197.  
  198.                 End Using
  199.  
  200.             End If
  201.  
  202.         Next
  203.  
  204.     End Sub
  205.  
  206.     Protected Overrides Sub OnSelecting(e As TabControlCancelEventArgs)
  207.         MyBase.OnSelecting(e)
  208.  
  209.         If Not IsNothing(e.TabPage) Then
  210.             If Not String.IsNullOrEmpty(e.TabPage.Tag) Then
  211.                 e.Cancel = True
  212.             Else
  213.                 OverIndex = -1
  214.             End If
  215.         End If
  216.  
  217.     End Sub
  218.  
  219.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  220.         MyBase.OnMouseMove(e)
  221.  
  222.         For I As Integer = 0 To TabPages.Count - 1
  223.             If GetTabRect(I).Contains(e.Location) And Not SelectedIndex = I And String.IsNullOrEmpty(TabPages(I).Tag) Then
  224.                 OverIndex = I
  225.                 Exit For
  226.             Else
  227.                 OverIndex = -1
  228.             End If
  229.         Next
  230.  
  231.     End Sub
  232.  
  233.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  234.         MyBase.OnMouseLeave(e)
  235.         OverIndex = -1
  236.     End Sub
  237.  
  238. End Class
  239.  
  240. <ComponentModel.DefaultEvent("CheckedChanged")>
  241. Public Class XylosCheckBox
  242.     Inherits Control
  243.  
  244.     Public Event CheckedChanged(sender As Object, e As EventArgs)
  245.  
  246.     Private _Checked As Boolean
  247.     Private _EnabledCalc As Boolean
  248.     Private G As Graphics
  249.  
  250.     Private B64Enabled As String = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA00lEQVQ4T6WTwQ2CMBSG30/07Ci6gY7gxZoIiYADuAIrsIDpQQ/cHMERZBOuXHimDSWALYL01EO/L//724JmLszk6S+BCOIExFsmL50sEH4kAZxVciYuJgnacD16Plpgg8tFtYMILntQdSXiZ3aXqa1UF/yUsoDw4wKglQaZZPa4RW3JEKzO4RjEbyJaN1BL8gvWgsMp3ADeq0lRJ2FimLZNYWpmFbudUJdolXTLyG2wTmDODUiccEfgSDIIfwmMxAMStS+XHPZn7l/z6Ifk+nSzBR8zi2d9JmVXSgAAAABJRU5ErkJggg=="
  251.     Private B64Disabled As String = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA1UlEQVQ4T6WTzQ2CQBCF56EnLpaiXvUAJBRgB2oFtkALdEAJnoVEMIGzdEIFjNkFN4DLn+xpD/N9efMWQAsPFvL0lyBMUg8MiwzyZwuiJAuI6CyTMxezBC24EuSTBTp4xaaN6JWdqKQbge6udfB1pfbBjrMvEMZZAdCm3ilw7eO1KRmCxRyiOH0TsFUQs5KMwVLweKY7ALFKUZUTECD6qdquCxM7i9jNhLJEraQ5xZzrYJngO9crGYBbAm2SEfhHoCQGeeK+Ls1Ld+fuM0/+kPp+usWCD10idEOGa4QuAAAAAElFTkSuQmCC"
  252.  
  253.     Public Property Checked As Boolean
  254.         Get
  255.             Return _Checked
  256.         End Get
  257.         Set(value As Boolean)
  258.             _Checked = value
  259.             Invalidate()
  260.         End Set
  261.     End Property
  262.  
  263.     Public Shadows Property Enabled As Boolean
  264.         Get
  265.             Return EnabledCalc
  266.         End Get
  267.         Set(value As Boolean)
  268.             _EnabledCalc = value
  269.  
  270.             If Enabled Then
  271.                 Cursor = Cursors.Hand
  272.             Else
  273.                 Cursor = Cursors.Default
  274.             End If
  275.  
  276.             Invalidate()
  277.         End Set
  278.     End Property
  279.  
  280.     <ComponentModel.DisplayName("Enabled")>
  281.     Public Property EnabledCalc As Boolean
  282.         Get
  283.             Return _EnabledCalc
  284.         End Get
  285.         Set(value As Boolean)
  286.             Enabled = value
  287.             Invalidate()
  288.         End Set
  289.     End Property
  290.  
  291.     Sub New()
  292.         DoubleBuffered = True
  293.         Enabled = True
  294.     End Sub
  295.  
  296.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  297.         G = e.Graphics
  298.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  299.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  300.  
  301.         MyBase.OnPaint(e)
  302.  
  303.         G.Clear(Color.White)
  304.  
  305.         If Enabled Then
  306.  
  307.             Using Background As New SolidBrush(ColorFromHex("#F3F4F7")), Border As New Pen(ColorFromHex("#D0D5D9")), TextColor As New SolidBrush(ColorFromHex("#7C858E")), TextFont As New Font("Segoe UI", 9)
  308.                 G.FillPath(Background, RoundRect(New Rectangle(0, 0, 16, 16), 3))
  309.                 G.DrawPath(Border, RoundRect(New Rectangle(0, 0, 16, 16), 3))
  310.                 G.DrawString(Text, TextFont, TextColor, New Point(25, 0))
  311.             End Using
  312.  
  313.             If Checked Then
  314.  
  315.                 Using I As Image = Image.FromStream(New IO.MemoryStream(Convert.FromBase64String(B64Enabled)))
  316.                     G.DrawImage(I, New Rectangle(3, 3, 11, 11))
  317.                 End Using
  318.  
  319.             End If
  320.  
  321.         Else
  322.  
  323.             Using Background As New SolidBrush(ColorFromHex("#F5F5F8")), Border As New Pen(ColorFromHex("#E1E1E2")), TextColor As New SolidBrush(ColorFromHex("#D0D3D7")), TextFont As New Font("Segoe UI", 9)
  324.                 G.FillPath(Background, RoundRect(New Rectangle(0, 0, 16, 16), 3))
  325.                 G.DrawPath(Border, RoundRect(New Rectangle(0, 0, 16, 16), 3))
  326.                 G.DrawString(Text, TextFont, TextColor, New Point(25, 0))
  327.             End Using
  328.  
  329.             If Checked Then
  330.  
  331.                 Using I As Image = Image.FromStream(New IO.MemoryStream(Convert.FromBase64String(B64Disabled)))
  332.                     G.DrawImage(I, New Rectangle(3, 3, 11, 11))
  333.                 End Using
  334.  
  335.             End If
  336.  
  337.         End If
  338.  
  339.     End Sub
  340.  
  341.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  342.         MyBase.OnMouseUp(e)
  343.  
  344.         If Enabled Then
  345.             Checked = Not Checked
  346.             RaiseEvent CheckedChanged(Me, e)
  347.         End If
  348.  
  349.     End Sub
  350.  
  351.     Protected Overrides Sub OnResize(e As EventArgs)
  352.         MyBase.OnResize(e)
  353.         Size = New Size(Width, 18)
  354.     End Sub
  355.  
  356. End Class
  357.  
  358. <ComponentModel.DefaultEvent("CheckedChanged")>
  359. Public Class XylosRadioButton
  360.     Inherits Control
  361.  
  362.     Public Event CheckedChanged(sender As Object, e As EventArgs)
  363.  
  364.     Private _Checked As Boolean
  365.     Private _EnabledCalc As Boolean
  366.     Private G As Graphics
  367.  
  368.     Public Property Checked As Boolean
  369.         Get
  370.             Return _Checked
  371.         End Get
  372.         Set(value As Boolean)
  373.             _Checked = value
  374.             Invalidate()
  375.         End Set
  376.     End Property
  377.  
  378.     Public Shadows Property Enabled As Boolean
  379.         Get
  380.             Return EnabledCalc
  381.         End Get
  382.         Set(value As Boolean)
  383.             _EnabledCalc = value
  384.  
  385.             If Enabled Then
  386.                 Cursor = Cursors.Hand
  387.             Else
  388.                 Cursor = Cursors.Default
  389.             End If
  390.  
  391.             Invalidate()
  392.         End Set
  393.     End Property
  394.  
  395.     <ComponentModel.DisplayName("Enabled")>
  396.     Public Property EnabledCalc As Boolean
  397.         Get
  398.             Return _EnabledCalc
  399.         End Get
  400.         Set(value As Boolean)
  401.             Enabled = value
  402.             Invalidate()
  403.         End Set
  404.     End Property
  405.  
  406.     Sub New()
  407.         DoubleBuffered = True
  408.         Enabled = True
  409.     End Sub
  410.  
  411.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  412.         G = e.Graphics
  413.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  414.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  415.  
  416.         MyBase.OnPaint(e)
  417.  
  418.         G.Clear(Color.White)
  419.  
  420.         If Enabled Then
  421.  
  422.             Using Background As New SolidBrush(ColorFromHex("#F3F4F7")), Border As New Pen(ColorFromHex("#D0D5D9")), TextColor As New SolidBrush(ColorFromHex("#7C858E")), TextFont As New Font("Segoe UI", 9)
  423.                 G.FillEllipse(Background, New Rectangle(0, 0, 16, 16))
  424.                 G.DrawEllipse(Border, New Rectangle(0, 0, 16, 16))
  425.                 G.DrawString(Text, TextFont, TextColor, New Point(25, 0))
  426.             End Using
  427.  
  428.             If Checked Then
  429.  
  430.                 Using Background As New SolidBrush(ColorFromHex("#575C62"))
  431.                     G.FillEllipse(Background, New Rectangle(4, 4, 8, 8))
  432.                 End Using
  433.  
  434.             End If
  435.  
  436.         Else
  437.  
  438.             Using Background As New SolidBrush(ColorFromHex("#F5F5F8")), Border As New Pen(ColorFromHex("#E1E1E2")), TextColor As New SolidBrush(ColorFromHex("#D0D3D7")), TextFont As New Font("Segoe UI", 9)
  439.                 G.FillEllipse(Background, New Rectangle(0, 0, 16, 16))
  440.                 G.DrawEllipse(Border, New Rectangle(0, 0, 16, 16))
  441.                 G.DrawString(Text, TextFont, TextColor, New Point(25, 0))
  442.             End Using
  443.  
  444.             If Checked Then
  445.  
  446.                 Using Background As New SolidBrush(ColorFromHex("#BCC1C6"))
  447.                     G.FillEllipse(Background, New Rectangle(4, 4, 8, 8))
  448.                 End Using
  449.  
  450.             End If
  451.  
  452.         End If
  453.  
  454.     End Sub
  455.  
  456.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  457.         MyBase.OnMouseUp(e)
  458.  
  459.         If Enabled Then
  460.  
  461.             For Each C As Control In Parent.Controls
  462.                 If TypeOf C Is XylosRadioButton Then
  463.                     DirectCast(C, XylosRadioButton).Checked = False
  464.                 End If
  465.             Next
  466.  
  467.             Checked = Not Checked
  468.             RaiseEvent CheckedChanged(Me, e)
  469.         End If
  470.  
  471.     End Sub
  472.  
  473.     Protected Overrides Sub OnResize(e As EventArgs)
  474.         MyBase.OnResize(e)
  475.         Size = New Size(Width, 18)
  476.     End Sub
  477.  
  478. End Class
  479.  
  480. Public Class XylosNotice
  481.     Inherits TextBox
  482.  
  483.     Private G As Graphics
  484.     Private B64 As String = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABL0lEQVQ4T5VT0VGDQBB9e2cBdGBSgTIDEr9MCw7pI0kFtgB9yFiC+KWMmREqMOnAAuDWOfAiudzhyA/svtvH7Xu7BOv5eH2atVKtwbwk0LWGGVyDqLzoRB7e3u/HJTQOdm+PGYjWNuk4ZkIW36RbkzsS7KqiBnB1Usw49DHh8oQEXMfJKhwgAM4/Mw7RIp0NeLG3ScCcR4vVhnTPnVCf9rUZeImTdKnz71VREnBnn5FKzMnX95jA2V6vLufkBQFESTq0WBXsEla7owmcoC6QJMKW2oCUePY5M0lAjK0iBAQ8TBGc2/d7+uvnM/AQNF4Rp4bpiGkRfTb2Gigx12+XzQb3D9JfBGaQzHWm7HS000RJ2i/av5fJjPDZMplErwl1GxDpMTbL1YC5lCwze52/AQFekh7wKBpGAAAAAElFTkSuQmCC"
  485.  
  486.     Sub New()
  487.         DoubleBuffered = True
  488.         Enabled = False
  489.         [ReadOnly] = True
  490.         BorderStyle = BorderStyle.None
  491.         Multiline = True
  492.         Cursor = Cursors.Default
  493.     End Sub
  494.  
  495.     Protected Overrides Sub OnCreateControl()
  496.         MyBase.OnCreateControl()
  497.         SetStyle(ControlStyles.UserPaint, True)
  498.     End Sub
  499.  
  500.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  501.         G = e.Graphics
  502.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  503.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  504.  
  505.         MyBase.OnPaint(e)
  506.  
  507.         G.Clear(Color.White)
  508.  
  509.         Using Background As New SolidBrush(ColorFromHex("#FFFDE8")), MainBorder As New Pen(ColorFromHex("#F2F3F7")), TextColor As New SolidBrush(ColorFromHex("#B9B595")), TextFont As New Font("Segoe UI", 9)
  510.             G.FillPath(Background, RoundRect(FullRectangle(Size, True), 3))
  511.             G.DrawPath(MainBorder, RoundRect(FullRectangle(Size, True), 3))
  512.             G.DrawString(Text, TextFont, TextColor, New Point(30, 6))
  513.         End Using
  514.  
  515.         Using I As Image = Image.FromStream(New IO.MemoryStream(Convert.FromBase64String(B64)))
  516.             G.DrawImage(I, New Rectangle(8, Height / 2 - 8, 16, 16))
  517.         End Using
  518.  
  519.     End Sub
  520.  
  521.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  522.         MyBase.OnMouseUp(e)
  523.  
  524.     End Sub
  525.  
  526. End Class
  527.  
  528. <ComponentModel.DefaultEvent("TextChanged")>
  529. Public Class XylosTextBox
  530.     Inherits Control
  531.  
  532.     Enum MouseState As Byte
  533.         None = 0
  534.         Over = 1
  535.         Down = 2
  536.     End Enum
  537.  
  538.     Private WithEvents TB As New TextBox
  539.     Private G As Graphics
  540.     Private State As MouseState
  541.     Private IsDown As Boolean
  542.  
  543.     Private _EnabledCalc As Boolean
  544.     Private _allowpassword As Boolean = False
  545.     Private _maxChars As Integer = 32767
  546.     Private _textAlignment As HorizontalAlignment
  547.     Private _multiLine As Boolean = False
  548.     Private _readOnly As Boolean = False
  549.  
  550.     Public Shadows Property Enabled As Boolean
  551.         Get
  552.             Return EnabledCalc
  553.         End Get
  554.         Set(value As Boolean)
  555.             TB.Enabled = value
  556.             _EnabledCalc = value
  557.             Invalidate()
  558.         End Set
  559.     End Property
  560.  
  561.     <ComponentModel.DisplayName("Enabled")>
  562.     Public Property EnabledCalc As Boolean
  563.         Get
  564.             Return _EnabledCalc
  565.         End Get
  566.         Set(value As Boolean)
  567.             Enabled = value
  568.             Invalidate()
  569.         End Set
  570.     End Property
  571.  
  572.     Public Shadows Property UseSystemPasswordChar() As Boolean
  573.         Get
  574.             Return _allowpassword
  575.         End Get
  576.         Set(ByVal value As Boolean)
  577.             TB.UseSystemPasswordChar = UseSystemPasswordChar
  578.             _allowpassword = value
  579.             Invalidate()
  580.         End Set
  581.     End Property
  582.  
  583.     Public Shadows Property MaxLength() As Integer
  584.         Get
  585.             Return _maxChars
  586.         End Get
  587.         Set(ByVal value As Integer)
  588.             _maxChars = value
  589.             TB.MaxLength = MaxLength
  590.             Invalidate()
  591.         End Set
  592.     End Property
  593.  
  594.     Public Shadows Property TextAlign() As HorizontalAlignment
  595.         Get
  596.             Return _textAlignment
  597.         End Get
  598.         Set(ByVal value As HorizontalAlignment)
  599.             _textAlignment = value
  600.             Invalidate()
  601.         End Set
  602.     End Property
  603.  
  604.     Public Shadows Property MultiLine() As Boolean
  605.         Get
  606.             Return _multiLine
  607.         End Get
  608.         Set(ByVal value As Boolean)
  609.             _multiLine = value
  610.             TB.Multiline = value
  611.             OnResize(EventArgs.Empty)
  612.             Invalidate()
  613.         End Set
  614.     End Property
  615.  
  616.     Public Shadows Property [ReadOnly]() As Boolean
  617.         Get
  618.             Return _readOnly
  619.         End Get
  620.         Set(ByVal value As Boolean)
  621.             _readOnly = value
  622.             If TB IsNot Nothing Then
  623.                 TB.ReadOnly = value
  624.             End If
  625.         End Set
  626.     End Property
  627.  
  628.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  629.         MyBase.OnTextChanged(e)
  630.         Invalidate()
  631.     End Sub
  632.  
  633.     Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
  634.         MyBase.OnBackColorChanged(e)
  635.         Invalidate()
  636.     End Sub
  637.  
  638.     Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
  639.         MyBase.OnForeColorChanged(e)
  640.         TB.ForeColor = ForeColor
  641.         Invalidate()
  642.     End Sub
  643.  
  644.     Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
  645.         MyBase.OnFontChanged(e)
  646.         TB.Font = Font
  647.     End Sub
  648.  
  649.     Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
  650.         MyBase.OnGotFocus(e)
  651.         TB.Focus()
  652.     End Sub
  653.  
  654.     Private Sub TextChangeTb() Handles TB.TextChanged
  655.         Text = TB.Text
  656.     End Sub
  657.  
  658.     Private Sub TextChng() Handles MyBase.TextChanged
  659.         TB.Text = Text
  660.     End Sub
  661.  
  662.     Public Sub NewTextBox()
  663.         With TB
  664.             .Text = String.Empty
  665.             .BackColor = Color.White
  666.             .ForeColor = ColorFromHex("#7C858E")
  667.             .TextAlign = HorizontalAlignment.Left
  668.             .BorderStyle = BorderStyle.None
  669.             .Location = New Point(3, 3)
  670.             .Font = New Font("Segoe UI", 9)
  671.             .Size = New Size(Width - 3, Height - 3)
  672.             .UseSystemPasswordChar = UseSystemPasswordChar
  673.         End With
  674.     End Sub
  675.  
  676.     Sub New()
  677.         MyBase.New()
  678.         NewTextBox()
  679.         Controls.Add(TB)
  680.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  681.         DoubleBuffered = True
  682.         TextAlign = HorizontalAlignment.Left
  683.         ForeColor = ColorFromHex("#7C858E")
  684.         Font = New Font("Segoe UI", 9)
  685.         Size = New Size(130, 29)
  686.         Enabled = True
  687.     End Sub
  688.  
  689.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  690.  
  691.         G = e.Graphics
  692.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  693.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  694.  
  695.         MyBase.OnPaint(e)
  696.  
  697.         G.Clear(Color.White)
  698.  
  699.         If Enabled Then
  700.  
  701.             TB.ForeColor = ColorFromHex("#7C858E")
  702.  
  703.             If State = MouseState.Down Then
  704.  
  705.                 Using Border As New Pen(ColorFromHex("#78B7E6"))
  706.                     G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 12))
  707.                 End Using
  708.  
  709.             Else
  710.  
  711.                 Using Border As New Pen(ColorFromHex("#D0D5D9"))
  712.                     G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 12))
  713.                 End Using
  714.  
  715.             End If
  716.  
  717.         Else
  718.  
  719.             TB.ForeColor = ColorFromHex("#7C858E")
  720.  
  721.             Using Border As New Pen(ColorFromHex("#E1E1E2"))
  722.                 G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 12))
  723.             End Using
  724.  
  725.         End If
  726.  
  727.         TB.TextAlign = TextAlign
  728.         TB.UseSystemPasswordChar = UseSystemPasswordChar
  729.  
  730.     End Sub
  731.  
  732.     Protected Overrides Sub OnResize(e As EventArgs)
  733.         MyBase.OnResize(e)
  734.         If Not MultiLine Then
  735.             Dim tbheight As Integer = TB.Height
  736.             TB.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 0), Integer))
  737.             TB.Size = New Size(Width - 20, tbheight)
  738.         Else
  739.             TB.Location = New Point(10, 10)
  740.             TB.Size = New Size(Width - 20, Height - 20)
  741.         End If
  742.     End Sub
  743.  
  744.     Protected Overrides Sub OnEnter(e As EventArgs)
  745.         MyBase.OnEnter(e)
  746.         State = MouseState.Down : Invalidate()
  747.     End Sub
  748.  
  749.     Protected Overrides Sub OnLeave(e As EventArgs)
  750.         MyBase.OnLeave(e)
  751.         State = MouseState.None : Invalidate()
  752.     End Sub
  753.  
  754. End Class
  755.  
  756. Public Class XylosProgressBar
  757.     Inherits Control
  758.  
  759. #Region " Drawing "
  760.  
  761.     Private _Val As Integer = 0
  762.     Private _Min As Integer = 0
  763.     Private _Max As Integer = 100
  764.  
  765.     Public Property Stripes As Color = Color.DarkGreen
  766.     Public Property BackgroundColor As Color = Color.Green
  767.  
  768.  
  769.     Public Property Value As Integer
  770.         Get
  771.             Return _Val
  772.         End Get
  773.         Set(value As Integer)
  774.             _Val = value
  775.             Invalidate()
  776.         End Set
  777.     End Property
  778.  
  779.     Public Property Minimum As Integer
  780.         Get
  781.             Return _Min
  782.         End Get
  783.         Set(value As Integer)
  784.             _Min = value
  785.             Invalidate()
  786.         End Set
  787.     End Property
  788.  
  789.     Public Property Maximum As Integer
  790.         Get
  791.             Return _Max
  792.         End Get
  793.         Set(value As Integer)
  794.             _Max = value
  795.             Invalidate()
  796.         End Set
  797.     End Property
  798.  
  799.     Sub New()
  800.         DoubleBuffered = True
  801.         Maximum = 100
  802.         Minimum = 0
  803.         Value = 0
  804.     End Sub
  805.  
  806.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  807.  
  808.         Dim G As Graphics = e.Graphics
  809.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  810.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  811.  
  812.         MyBase.OnPaint(e)
  813.  
  814.         G.Clear(Color.White)
  815.  
  816.         Using Border As New Pen(ColorFromHex("#D0D5D9"))
  817.             G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 6))
  818.         End Using
  819.  
  820.         If Not Value = 0 Then
  821.  
  822.             Using Background As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.LightUpwardDiagonal, Stripes, BackgroundColor)
  823.                 G.FillPath(Background, RoundRect(New Rectangle(0, 0, Value / Maximum * Width - 1, Height - 1), 6))
  824.             End Using
  825.  
  826.         End If
  827.  
  828.  
  829.     End Sub
  830.  
  831. #End Region
  832.  
  833. End Class
  834.  
  835. Public Class XylosCombobox
  836.     Inherits ComboBox
  837.  
  838.     Private G As Graphics
  839.     Private Rect As Rectangle
  840.     Private _EnabledCalc As Boolean
  841.  
  842.     Public Shadows Property Enabled As Boolean
  843.         Get
  844.             Return EnabledCalc
  845.         End Get
  846.         Set(value As Boolean)
  847.             _EnabledCalc = value
  848.             Invalidate()
  849.         End Set
  850.     End Property
  851.  
  852.     <ComponentModel.DisplayName("Enabled")>
  853.     Public Property EnabledCalc As Boolean
  854.         Get
  855.             Return _EnabledCalc
  856.         End Get
  857.         Set(value As Boolean)
  858.             MyBase.Enabled = value
  859.             Enabled = value
  860.             Invalidate()
  861.         End Set
  862.     End Property
  863.  
  864.     Sub New()
  865.         DoubleBuffered = True
  866.         DropDownStyle = ComboBoxStyle.DropDownList
  867.         Cursor = Cursors.Hand
  868.         Enabled = True
  869.         DrawMode = DrawMode.OwnerDrawFixed
  870.         ItemHeight = 20
  871.     End Sub
  872.  
  873.     Protected Overrides Sub OnCreateControl()
  874.         MyBase.OnCreateControl()
  875.         SetStyle(ControlStyles.UserPaint, True)
  876.     End Sub
  877.  
  878.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  879.         G = e.Graphics
  880.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  881.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  882.  
  883.         MyBase.OnPaint(e)
  884.  
  885.         G.Clear(Color.White)
  886.  
  887.         If Enabled Then
  888.  
  889.             Using Border As New Pen(ColorFromHex("#D0D5D9")), TriangleColor As New SolidBrush(ColorFromHex("#7C858E")), TriangleFont As New Font("Marlett", 13)
  890.                 G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 6))
  891.                 G.DrawString("6", TriangleFont, TriangleColor, New Point(Width - 22, 3))
  892.             End Using
  893.  
  894.         Else
  895.  
  896.             Using Border As New Pen(ColorFromHex("#E1E1E2")), TriangleColor As New SolidBrush(ColorFromHex("#D0D3D7")), TriangleFont As New Font("Marlett", 13)
  897.                 G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 6))
  898.                 G.DrawString("6", TriangleFont, TriangleColor, New Point(Width - 22, 3))
  899.             End Using
  900.  
  901.         End If
  902.  
  903.         If Not IsNothing(Items) Then
  904.  
  905.             Using ItemsFont As New Font("Segoe UI", 9), ItemsColor As New SolidBrush(ColorFromHex("#7C858E"))
  906.  
  907.                 If Enabled Then
  908.  
  909.                     If Not SelectedIndex = -1 Then
  910.                         G.DrawString(GetItemText(Items(SelectedIndex)), ItemsFont, ItemsColor, New Point(7, 4))
  911.                     Else
  912.                         Try
  913.                             G.DrawString(GetItemText(Items(0)), ItemsFont, ItemsColor, New Point(7, 4))
  914.                         Catch
  915.                         End Try
  916.                     End If
  917.  
  918.                 Else
  919.  
  920.                     Using DisabledItemsColor As New SolidBrush(ColorFromHex("#D0D3D7"))
  921.  
  922.                         If Not SelectedIndex = -1 Then
  923.                             G.DrawString(GetItemText(Items(SelectedIndex)), ItemsFont, DisabledItemsColor, New Point(7, 4))
  924.                         Else
  925.                             G.DrawString(GetItemText(Items(0)), ItemsFont, DisabledItemsColor, New Point(7, 4))
  926.                         End If
  927.  
  928.                     End Using
  929.  
  930.                 End If
  931.  
  932.             End Using
  933.  
  934.         End If
  935.  
  936.     End Sub
  937.  
  938.     Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  939.         MyBase.OnDrawItem(e)
  940.         G = e.Graphics
  941.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  942.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  943.  
  944.         If Enabled Then
  945.             e.DrawBackground()
  946.             Rect = e.Bounds
  947.  
  948.             Try
  949.  
  950.                 Using ItemsFont As New Font("Segoe UI", 9), Border As New Pen(ColorFromHex("#D0D5D9"))
  951.  
  952.                     If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  953.  
  954.                         Using ItemsColor As New SolidBrush(Color.White), Itembackground As New SolidBrush(ColorFromHex("#78B7E6"))
  955.                             G.FillRectangle(Itembackground, Rect)
  956.                             G.DrawString(GetItemText(Items(e.Index)), New Font("Segoe UI", 9), Brushes.White, New Point(Rect.X + 5, Rect.Y + 1))
  957.                         End Using
  958.  
  959.                     Else
  960.                         Using ItemsColor As New SolidBrush(ColorFromHex("#7C858E"))
  961.                             G.FillRectangle(Brushes.White, Rect)
  962.                             G.DrawString(GetItemText(Items(e.Index)), New Font("Segoe UI", 9), ItemsColor, New Point(Rect.X + 5, Rect.Y + 1))
  963.                         End Using
  964.  
  965.                     End If
  966.  
  967.                 End Using
  968.  
  969.             Catch
  970.             End Try
  971.  
  972.         End If
  973.  
  974.     End Sub
  975.  
  976.     Protected Overrides Sub OnSelectedItemChanged(ByVal e As EventArgs)
  977.         MyBase.OnSelectedItemChanged(e)
  978.         Invalidate()
  979.     End Sub
  980.  
  981. End Class
  982.  
  983. Public Class XylosSeparator
  984.     Inherits Control
  985.  
  986.     Private G As Graphics
  987.  
  988.     Sub New()
  989.         DoubleBuffered = True
  990.     End Sub
  991.  
  992.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  993.         G = e.Graphics
  994.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  995.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  996.  
  997.         MyBase.OnPaint(e)
  998.  
  999.         Using C As New Pen(ColorFromHex("#EBEBEC"))
  1000.             G.DrawLine(C, New Point(0, 0), New Point(Width, 0))
  1001.         End Using
  1002.  
  1003.     End Sub
  1004.  
  1005.     Protected Overrides Sub OnResize(e As EventArgs)
  1006.         MyBase.OnResize(e)
  1007.         Size = New Size(Width, 2)
  1008.     End Sub
  1009.  
  1010. End Class
  1011.  
  1012. Public Class XylosButton
  1013.     Inherits Control
  1014.  
  1015.     Enum MouseState As Byte
  1016.         None = 0
  1017.         Over = 1
  1018.         Down = 2
  1019.     End Enum
  1020.  
  1021.     Private G As Graphics
  1022.     Private State As MouseState
  1023.  
  1024.     Private _EnabledCalc As Boolean
  1025.  
  1026.     Public Shadows Event Click(sender As Object, e As EventArgs)
  1027.  
  1028.     Sub New()
  1029.         DoubleBuffered = True
  1030.         Enabled = True
  1031.     End Sub
  1032.  
  1033.     Public Shadows Property Enabled As Boolean
  1034.         Get
  1035.             Return EnabledCalc
  1036.         End Get
  1037.         Set(value As Boolean)
  1038.             _EnabledCalc = value
  1039.             Invalidate()
  1040.         End Set
  1041.     End Property
  1042.  
  1043.     <ComponentModel.DisplayName("Enabled")>
  1044.     Public Property EnabledCalc As Boolean
  1045.         Get
  1046.             Return _EnabledCalc
  1047.         End Get
  1048.         Set(value As Boolean)
  1049.             Enabled = value
  1050.             Invalidate()
  1051.         End Set
  1052.     End Property
  1053.  
  1054.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1055.  
  1056.         G = e.Graphics
  1057.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  1058.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  1059.  
  1060.         MyBase.OnPaint(e)
  1061.  
  1062.         If Enabled Then
  1063.  
  1064.             Select Case State
  1065.  
  1066.                 Case MouseState.Over
  1067.  
  1068.                     Using Background As New SolidBrush(ColorFromHex("#FDFDFD"))
  1069.                         G.FillPath(Background, RoundRect(FullRectangle(Size, True), 3))
  1070.                     End Using
  1071.  
  1072.                 Case MouseState.Down
  1073.  
  1074.                     Using Background As New SolidBrush(ColorFromHex("#F0F0F0"))
  1075.                         G.FillPath(Background, RoundRect(FullRectangle(Size, True), 3))
  1076.                     End Using
  1077.  
  1078.                 Case Else
  1079.  
  1080.                     Using Background As New SolidBrush(ColorFromHex("#F6F6F6"))
  1081.                         G.FillPath(Background, RoundRect(FullRectangle(Size, True), 3))
  1082.                     End Using
  1083.  
  1084.             End Select
  1085.  
  1086.             Using ButtonFont As New Font("Segoe UI", 9), Border As New Pen(ColorFromHex("#C3C3C3"))
  1087.                 G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 3))
  1088.                 CenterString(G, Text, ButtonFont, ColorFromHex("#7C858E"), FullRectangle(Size, False))
  1089.             End Using
  1090.  
  1091.         Else
  1092.  
  1093.             Using Background As New SolidBrush(ColorFromHex("#F3F4F7")), Border As New Pen(ColorFromHex("#DCDCDC")), ButtonFont As New Font("Segoe UI", 9)
  1094.                 G.FillPath(Background, RoundRect(FullRectangle(Size, True), 3))
  1095.                 G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 3))
  1096.                 CenterString(G, Text, ButtonFont, ColorFromHex("#D0D3D7"), FullRectangle(Size, False))
  1097.             End Using
  1098.  
  1099.         End If
  1100.  
  1101.     End Sub
  1102.  
  1103.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1104.         MyBase.OnMouseEnter(e)
  1105.         State = MouseState.Over : Invalidate()
  1106.     End Sub
  1107.  
  1108.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1109.         MyBase.OnMouseLeave(e)
  1110.         State = MouseState.None : Invalidate()
  1111.     End Sub
  1112.  
  1113.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1114.         MyBase.OnMouseUp(e)
  1115.  
  1116.         If Enabled Then
  1117.             RaiseEvent Click(Me, e)
  1118.         End If
  1119.  
  1120.         State = MouseState.Over : Invalidate()
  1121.     End Sub
  1122.  
  1123.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1124.         MyBase.OnMouseDown(e)
  1125.         State = MouseState.Down : Invalidate()
  1126.     End Sub
  1127.  
  1128. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement