Advertisement
THE_LORD

DarkUI Theme

Aug 12th, 2017
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 63.94 KB | None | 0 0
  1. '' <summary>
  2. '' DarkUI Theme
  3. '' Author : THE LORD
  4. '' Release Date : Saturday, August 12, 2017
  5. '' Update : Saturday, August 14, 2017
  6. '' HF Account : https://hackforums.net/member.php?action=profile&uid=3304362
  7. '' PM Me for any bug.
  8. '' </summary>
  9.  
  10. #Region " Namespaces "
  11.  
  12. Imports System.Drawing.Drawing2D
  13. Imports System.ComponentModel
  14. Imports System.Drawing.Text
  15. Imports System.Windows.Forms
  16. Imports System.Drawing
  17.  
  18. #End Region
  19.  
  20. #Region " Helper "
  21.  
  22. Public Module HelperMethods
  23.  
  24. #Region " MouseStates "
  25.  
  26.     ''' <summary>
  27.     ''' The helper enumerator to get mouse states.
  28.     ''' </summary>
  29.     Public Enum MouseMode As Byte
  30.         Normal
  31.         Hovered
  32.         Pushed
  33.         Disabled
  34.     End Enum
  35.  
  36. #End Region
  37.  
  38. #Region " Draw Methods "
  39.  
  40.     ''' <summary>
  41.     ''' The Method to draw the image from encoded base64 string.
  42.     ''' </summary>
  43.     ''' <param name="G">The Graphics to draw the image.</param>
  44.     ''' <param name="Base64Image">The Encoded base64 image.</param>
  45.     ''' <param name="Rect">The Rectangle area for the image.</param>
  46.     Public Sub DrawImageFromBase64(ByVal G As Graphics, ByVal Base64Image As String, ByVal Rect As Rectangle)
  47.         Dim IM As Image = Nothing
  48.         With G
  49.             Using ms As New System.IO.MemoryStream(Convert.FromBase64String(Base64Image))
  50.                 IM = Image.FromStream(ms) : ms.Close()
  51.             End Using
  52.             .DrawImage(IM, Rect)
  53.         End With
  54.     End Sub
  55.  
  56.     ''' <summary>
  57.     ''' The Method to fill rounded rectangle.
  58.     ''' </summary>
  59.     ''' <param name="G">The Graphics to draw the image.</param>
  60.     ''' <param name="C">The Color to the rectangle area.</param>
  61.     ''' <param name="Rect">The Rectangle area to be filled.</param>
  62.     ''' <param name="Curve">The Rounding border radius.</param>
  63.     ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
  64.     ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
  65.     ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
  66.     ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
  67.     Public Sub FillRoundedPath(ByVal G As Graphics, ByVal C As Color, ByVal Rect As Rectangle, ByVal Curve As Integer, _
  68.                                  Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
  69.                                  Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True)
  70.         With G
  71.             .FillPath(New SolidBrush(C), RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
  72.         End With
  73.     End Sub
  74.  
  75.     ''' <summary>
  76.     ''' The Method to fill the rounded rectangle.
  77.     ''' </summary>
  78.     ''' <param name="G">The Graphics to fill the rectangle.</param>
  79.     ''' <param name="B">The brush to the rectangle area.</param>
  80.     ''' <param name="Rect">The Rectangle area to be filled.</param>
  81.     ''' <param name="Curve">The Rounding border radius.</param>
  82.     ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
  83.     ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
  84.     ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
  85.     ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
  86.     Public Sub FillRoundedPath(ByVal G As Graphics, ByVal B As Brush, ByVal Rect As Rectangle, ByVal Curve As Integer, _
  87.                                  Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
  88.                                  Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True)
  89.         With G
  90.             .FillPath(B, RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
  91.         End With
  92.     End Sub
  93.    
  94.     ''' <summary>
  95.     ''' The Method to fill the rectangle the base color and surrounding with another color(Rectangle with shadow).
  96.     ''' </summary>
  97.     ''' <param name="G">The Graphics to fill the rectangle.</param>
  98.     ''' <param name="CenterColor">The Center color of the rectangle area.</param>
  99.     ''' <param name="SurroundColor">The Inner Surround color of the rectangle area.</param>
  100.     ''' <param name="P">The Point of the surrounding color.</param>
  101.     ''' <param name="Rect">The Rectangle area to be filled.</param>
  102.     ''' <param name="Curve">The Rounding border radius.</param>
  103.     ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
  104.     ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
  105.     ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
  106.     ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
  107.     Public Sub FillWithInnerRectangle(ByVal G As Graphics, ByVal CenterColor As Color, ByVal SurroundColor As Color, ByVal P As Point, ByVal Rect As Rectangle, ByVal Curve As Integer, _
  108.                          Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
  109.                          Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True)
  110.         Using PGB As New PathGradientBrush(RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
  111.             With PGB
  112.                 .CenterColor = CenterColor
  113.                 .SurroundColors = New Color() {SurroundColor}
  114.                 .FocusScales = P
  115.                 With G
  116.                     Dim GP As New GraphicsPath With {.FillMode = FillMode.Winding}
  117.                     GP.AddRectangle(Rect)
  118.                     .FillPath(PGB, GP)
  119.                     GP.Dispose()
  120.                 End With
  121.             End With
  122.         End Using
  123.     End Sub
  124.  
  125.     ''' <summary>
  126.     ''' The Method to fill the circle the base color and surrounding with another color(Rectangle with shadow).
  127.     ''' </summary>
  128.     ''' <param name="G">The Graphics to fill the circle.</param>
  129.     ''' <param name="CenterColor">The Center color of the rectangle area.</param>
  130.     ''' <param name="SurroundColor">The Inner Surround color of the rectangle area.</param>
  131.     ''' <param name="P">The Point of the surrounding color.</param>
  132.     ''' <param name="Rect">The circle area to be filled.</param>
  133.     Public Sub FillWithInnerEllipse(ByVal G As Graphics, ByVal CenterColor As Color, ByVal SurroundColor As Color, ByVal P As Point, ByVal Rect As Rectangle)
  134.         Dim GP As New GraphicsPath With {.FillMode = FillMode.Winding}
  135.         GP.AddEllipse(Rect)
  136.         Using PGB As New PathGradientBrush(GP)
  137.             With PGB
  138.                 .CenterColor = CenterColor
  139.                 .SurroundColors = New Color() {SurroundColor}
  140.                 .FocusScales = P
  141.                 With G
  142.                     .FillPath(PGB, GP)
  143.                     GP.Dispose()
  144.                 End With
  145.             End With
  146.         End Using
  147.     End Sub
  148.  
  149.     ''' <summary>
  150.     ''' The Method to fill the rounded rectangle the base color and surrounding with another color(Rectangle with shadow).
  151.     ''' </summary>
  152.     ''' <param name="G">The Graphics to fill rounded the rectangle.</param>
  153.     ''' <param name="CenterColor">The Center color of the rectangle area.</param>
  154.     ''' <param name="SurroundColor">The Inner Surround color of the rectangle area.</param>
  155.     ''' <param name="P">The Point of the surrounding color.</param>
  156.     ''' <param name="Rect">The Rectangle area to be filled.</param>
  157.     ''' <param name="Curve">The Rounding border radius.</param>
  158.     ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
  159.     ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
  160.     ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
  161.     ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
  162.     Public Sub FillWithInnerRoundedPath(ByVal G As Graphics, ByVal CenterColor As Color, ByVal SurroundColor As Color, ByVal P As Point, ByVal Rect As Rectangle, ByVal Curve As Integer, _
  163.                      Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
  164.                      Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True)
  165.         Using PGB As New PathGradientBrush(RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
  166.             With PGB
  167.                 .CenterColor = CenterColor
  168.                 .SurroundColors = New Color() {SurroundColor}
  169.                 .FocusScales = P
  170.                 With G
  171.                     .FillPath(PGB, RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
  172.                 End With
  173.             End With
  174.         End Using
  175.     End Sub
  176.  
  177.     ''' <summary>
  178.     ''' The Method to draw the rounded rectangle area.
  179.     ''' </summary>
  180.     ''' <param name="G">The Graphics to draw rounded the rectangle.</param>
  181.     ''' <param name="C">Border Color</param>
  182.     ''' <param name="Size">Border thickness</param>
  183.     ''' <param name="Rect">The Rectangle area to be drawn.</param>
  184.     ''' <param name="Curve">The Rounding border radius.</param>
  185.     ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
  186.     ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
  187.     ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
  188.     ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
  189.     Public Sub DrawRoundedPath(ByVal G As Graphics, ByVal C As Color, ByVal Size As Single, ByVal Rect As Rectangle, ByVal Curve As Integer, _
  190.                                  Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
  191.                                  Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True)
  192.         With G
  193.             .DrawPath(New Pen(C, Size), RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
  194.         End With
  195.     End Sub
  196.  
  197.     ''' <summary>
  198.     ''' The method to draw the triangle.
  199.     ''' </summary>
  200.     ''' <param name="G">The Graphics to draw triangle.</param>
  201.     ''' <param name="C">The Triangle Color.</param>
  202.     ''' <param name="Size">The Triangle thickness</param>
  203.     ''' <param name="P1">Point 1</param>
  204.     ''' <param name="P2">Point 2</param>
  205.     ''' <param name="P3">Point 3</param>
  206.     ''' <param name="P4">Point 4</param>
  207.     ''' <param name="P5">Point 5</param>
  208.     ''' <param name="P6">Point 6</param>
  209.     Public Sub DrawTriangle(ByVal G As Graphics, ByVal C As Color, ByVal Size As Integer, ByVal P1 As Point, ByVal P2 As Point, ByVal P3 As Point, ByVal P4 As Point, ByVal P5 As Point, ByVal P6 As Point)
  210.         With G
  211.             .DrawLine(New Pen(C, Size), P1, P2)
  212.             .DrawLine(New Pen(C, Size), P3, P4)
  213.             .DrawLine(New Pen(C, Size), P5, P6)
  214.         End With
  215.     End Sub
  216.  
  217.     ''' <summary>
  218.     ''' The Method to fill the rectangle with border.
  219.     ''' </summary>
  220.     ''' <param name="G">The Graphics to fill the the rectangle.</param>
  221.     ''' <param name="Rect">The Rectangle to fill.</param>
  222.     ''' <param name="RectColor">The Rectangle color.</param>
  223.     ''' <param name="StrokeColor">The Stroke(Border) color.</param>
  224.     ''' <param name="StrokeSize">The Stroke thickness.</param>
  225.     Public Sub FillStrokedRectangle(ByVal G As Graphics, ByVal Rect As Rectangle, ByVal RectColor As Color, ByVal StrokeColor As Color, Optional ByVal StrokeSize As Integer = 1)
  226.         Using B As New SolidBrush(RectColor), S As New Pen(StrokeColor, StrokeSize)
  227.             G.FillRectangle(B, Rect)
  228.             G.DrawRectangle(S, Rect)
  229.         End Using
  230.     End Sub
  231.  
  232.     ''' <summary>
  233.     ''' The Method to fill rounded rectangle with border.
  234.     ''' </summary>
  235.     ''' <param name="G">The Graphics to fill rounded the rectangle.</param>
  236.     ''' <param name="Rect">The Rectangle to fill.</param>
  237.     ''' <param name="RectColor">The Rectangle color.</param>
  238.     ''' <param name="StrokeColor">The Stroke(Border) color.</param>
  239.     ''' <param name="StrokeSize">The Stroke thickness.</param>
  240.     ''' <param name="Curve">The Rounding border radius.</param>
  241.     ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
  242.     ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
  243.     ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
  244.     ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
  245.     Public Sub FillRoundedStrokedRectangle(ByVal G As Graphics, ByVal Rect As Rectangle, ByVal RectColor As Color, ByVal StrokeColor As Color, Optional ByVal StrokeSize As Integer = 1, Optional ByVal curve As Integer = 1, _
  246.                                  Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
  247.                                  Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True)
  248.         Using B As New SolidBrush(RectColor)
  249.             FillRoundedPath(G, B, Rect, curve, TopLeft, TopRight, BottomLeft, BottomRight)
  250.             DrawRoundedPath(G, StrokeColor, StrokeSize, Rect, curve, TopLeft, TopRight, BottomLeft, BottomRight)
  251.         End Using
  252.     End Sub
  253.    
  254.     ''' <summary>
  255.     ''' The Method to draw the image with custom color.
  256.     ''' </summary>
  257.     ''' <param name="G"> The Graphic to draw the image.</param>
  258.     ''' <param name="R"> The Rectangle area of image.</param>
  259.     ''' <param name="_Image"> The image that the custom color applies on it.</param>
  260.     ''' <param name="C">The Color that be applied to the image.</param>
  261.     ''' <remarks></remarks>
  262.  
  263.     Public Sub DrawImageWithColor(ByVal G As Graphics, ByVal R As Rectangle, ByVal _Image As Image, C As Color)
  264.         Dim ptsArray As Single()() = {
  265.             New Single() {Convert.ToSingle(C.R / 255), 0, 0, 0, 0}, _
  266.             New Single() {0, Convert.ToSingle(C.G / 255), 0, 0, 0}, _
  267.             New Single() {0, 0, Convert.ToSingle(C.B / 255), 0, 0}, _
  268.             New Single() {0, 0, 0, Convert.ToSingle(C.A / 255), 0}, _
  269.             New Single() {Convert.ToSingle(C.R / 255), Convert.ToSingle(C.G / 255), Convert.ToSingle(C.B / 255), 0.0F, Convert.ToSingle(C.A / 255)}}
  270.         Dim imgAttribs As New Imaging.ImageAttributes
  271.         imgAttribs.SetColorMatrix(New Imaging.ColorMatrix(ptsArray), Imaging.ColorMatrixFlag.Default, Imaging.ColorAdjustType.Default)
  272.         G.DrawImage(_Image, R, 0, 0, _Image.Width, _Image.Height, GraphicsUnit.Pixel, imgAttribs)
  273.     End Sub
  274.  
  275.     ''' <summary>
  276.     ''' The Method to draw the image with custom color.
  277.     ''' </summary>
  278.     ''' <param name="G"> The Graphic to draw the image.</param>
  279.     ''' <param name="R"> The Rectangle area of image.</param>
  280.     ''' <param name="_Image"> The Encoded base64 image that the custom color applies on it.</param>
  281.     ''' <param name="C">The Color that be applied to the image.</param>
  282.     ''' <remarks></remarks>
  283.     Public Sub DrawImageWithColor(ByVal G As Graphics, ByVal R As Rectangle, ByVal _Image As String, C As Color)
  284.         Dim IM As Image = ImageFromBase64(_Image)
  285.         Dim ptsArray As Single()() = {
  286.             New Single() {Convert.ToSingle(C.R / 255), 0, 0, 0, 0}, _
  287.             New Single() {0, Convert.ToSingle(C.G / 255), 0, 0, 0}, _
  288.             New Single() {0, 0, Convert.ToSingle(C.B / 255), 0, 0}, _
  289.             New Single() {0, 0, 0, Convert.ToSingle(C.A / 255), 0}, _
  290.             New Single() {Convert.ToSingle(C.R / 255), Convert.ToSingle(C.G / 255), Convert.ToSingle(C.B / 255), 0.0F, Convert.ToSingle(C.A / 255)}}
  291.         Dim imgAttribs As New Imaging.ImageAttributes
  292.         imgAttribs.SetColorMatrix(New Imaging.ColorMatrix(ptsArray), Imaging.ColorMatrixFlag.Default, Imaging.ColorAdjustType.Default)
  293.         G.DrawImage(IM, R, 0, 0, IM.Width, IM.Height, GraphicsUnit.Pixel, imgAttribs)
  294.     End Sub
  295.  
  296. #End Region
  297.  
  298. #Region " Shapes "
  299.  
  300.     ''' <summary>
  301.     ''' The Triangle that joins 3 points to the triangle shape.
  302.     ''' </summary>
  303.     ''' <param name="P1">Point 1.</param>
  304.     ''' <param name="P2">Point 2.</param>
  305.     ''' <param name="P3">Point 3.</param>
  306.     ''' <returns>The Trangle shape based on given points.</returns>
  307.     Public Function Triangle(ByVal P1 As Point, ByVal P2 As Point, ByVal P3 As Point) As Point()
  308.         Return New Point() {P1, P2, P3}
  309.     End Function
  310.  
  311. #End Region
  312.  
  313. #Region " Brushes "
  314.  
  315.     ''' <summary>
  316.     ''' The Brush with two colors one center another surounding the center based on the given rectangle area.
  317.     ''' </summary>
  318.     ''' <param name="CenterColor">The Center color of the rectangle.</param>
  319.     ''' <param name="SurroundColor">The Surrounding color of the rectangle.</param>
  320.     ''' <param name="P">The Point of surrounding.</param>
  321.     ''' <param name="Rect">The Rectangle of the brush.</param>
  322.     ''' <returns>The Brush with two colors one center another surounding the center.</returns>
  323.     Public Function GlowBrush(ByVal CenterColor As Color, ByVal SurroundColor As Color, ByVal P As Point, ByVal Rect As Rectangle) As PathGradientBrush
  324.         Dim GP As New GraphicsPath With {.FillMode = FillMode.Winding}
  325.         GP.AddRectangle(Rect)
  326.         Return New PathGradientBrush(GP) With {.CenterColor = CenterColor, .SurroundColors = New Color() {SurroundColor}, .FocusScales = P}
  327.         GP.Dispose()
  328.     End Function
  329.  
  330.     ''' <summary>
  331.     ''' The Brush from RGBA color.
  332.     ''' </summary>
  333.     ''' <param name="R">Red.</param>
  334.     ''' <param name="G">Green.</param>
  335.     ''' <param name="B">Blue.</param>
  336.     ''' <param name="A">Alpha.</param>
  337.     ''' <returns>The Brush from given RGBA color.</returns>
  338.     Public Function SolidBrushRGBColor(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer, Optional ByVal A As Integer = 0) As SolidBrush
  339.         Return New SolidBrush(Color.FromArgb(A, R, G, B))
  340.     End Function
  341.  
  342.     ''' <summary>
  343.     ''' The Brush from HEX color.
  344.     ''' </summary>
  345.     ''' <param name="C_WithoutHash">HEX Color without hash.</param>
  346.     ''' <returns>The Brush from given HEX color.</returns>
  347.     Public Function SolidBrushHTMlColor(ByVal C_WithoutHash As String) As SolidBrush
  348.         Return New SolidBrush(GetHTMLColor(C_WithoutHash))
  349.     End Function
  350.  
  351. #End Region
  352.  
  353. #Region " Pens "
  354.  
  355.     ''' <summary>
  356.     ''' The Pen from RGBA color.
  357.     ''' </summary>
  358.     ''' <param name="R">Red.</param>
  359.     ''' <param name="G">Green.</param>
  360.     ''' <param name="B">Blue.</param>
  361.     ''' <param name="A">Alpha.</param>
  362.     ''' <returns>The Pen from given RGBA color.</returns>
  363.     Public Function PenRGBColor(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer, ByVal A As Integer, ByVal Size As Single) As Pen
  364.         Return New Pen(Color.FromArgb(A, R, G, B), Size)
  365.     End Function
  366.  
  367.     ''' <summary>
  368.     ''' The Pen from HEX color.
  369.     ''' </summary>
  370.     ''' <param name="C_WithoutHash">HEX Color without hash.</param>
  371.     ''' <param name="Size">The Size of the pen.</param>
  372.     ''' <returns></returns>
  373.     Public Function PenHTMlColor(ByVal C_WithoutHash As String, Optional ByVal Size As Single = 1) As Pen
  374.         Return New Pen(GetHTMLColor(C_WithoutHash), Size)
  375.     End Function
  376.  
  377. #End Region
  378.  
  379. #Region " Colors "
  380.  
  381.     ''' <summary>
  382.     '''
  383.     ''' </summary>
  384.     ''' <param name="C_WithoutHash"></param>
  385.     ''' <returns></returns>
  386.     Public Function GetHTMLColor(ByVal C_WithoutHash As String) As Color
  387.         Return ColorTranslator.FromHtml("#" & C_WithoutHash)
  388.     End Function
  389.    
  390.     ''' <summary>
  391.     ''' The Color from HEX by alpha property.
  392.     ''' </summary>
  393.     ''' <param name="alpha">Alpha.</param>
  394.     ''' <param name="C_WithoutHash">HEX Color without hash.</param>
  395.     ''' <returns>The Color from HEX with given ammount of transparency</returns>
  396.     Public Function GetAlphaHTMLColor(ByVal alpha As integer ,ByVal C_WithoutHash As String) As Color
  397.         Return Color.FromArgb(alpha,ColorTranslator.FromHtml("#" & C_WithoutHash))
  398.     End Function
  399.  
  400. #End Region
  401.  
  402. #Region " Methods "
  403.  
  404.     ''' <summary>
  405.     ''' The String format to provide the alignment.
  406.     ''' </summary>
  407.     ''' <param name="Horizontal">Horizontal alignment.</param>
  408.     ''' <param name="Vertical">Horizontal alignment. alignment.</param>
  409.     ''' <returns>The String format.</returns>
  410.     Public Function SetPosition(Optional ByVal Horizontal As StringAlignment = StringAlignment.Center, Optional ByVal Vertical As StringAlignment = StringAlignment.Center) As StringFormat
  411.         Return New StringFormat() With {.Alignment = Horizontal, .LineAlignment = Vertical}
  412.     End Function
  413.  
  414.     ''' <summary>
  415.     ''' The Matrix array of single from color.
  416.     ''' </summary>
  417.     ''' <param name="C">The Color.</param>
  418.     ''' <returns>The Matrix array of single from the given color</returns>
  419.     Function ColorToMatrix(ByVal C As Color) As Single()()
  420.         Return New Single()() {
  421.             New Single() {Convert.ToSingle(C.R / 255), 0, 0, 0, 0}, _
  422.             New Single() {0, Convert.ToSingle(C.G / 255), 0, 0, 0}, _
  423.             New Single() {0, 0, Convert.ToSingle(C.B / 255), 0, 0}, _
  424.             New Single() {0, 0, 0, Convert.ToSingle(C.A / 255), 0}, _
  425.             New Single() {Convert.ToSingle(C.R / 255), Convert.ToSingle(C.G / 255), Convert.ToSingle(C.B / 255), 0.0F, Convert.ToSingle(C.A / 255)}}
  426.     End Function
  427.  
  428.     ''' <summary>
  429.     ''' The Image from encoded base64 image.
  430.     ''' </summary>
  431.     ''' <param name="Base64Image">The Encoded base64 image</param>
  432.     ''' <returns>The Image from encoded base64.</returns>
  433.     Public Function ImageFromBase64(ByVal Base64Image As String) As Image
  434.         Using ms As New System.IO.MemoryStream(Convert.FromBase64String(Base64Image))
  435.             Return Image.FromStream(ms)
  436.         End Using
  437.     End Function
  438.  
  439.  
  440. #End Region
  441.  
  442. #Region " Round Border "
  443.  
  444.     ''' <summary>
  445.     ''' Credits : AeonHack
  446.     ''' </summary>
  447.  
  448.     Public Function RoundRec(ByVal r As Rectangle, ByVal Curve As Integer, _
  449.                                  Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
  450.                                  Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True) As GraphicsPath
  451.         Dim CreateRoundPath As New GraphicsPath(FillMode.Winding)
  452.         If TopLeft Then
  453.             CreateRoundPath.AddArc(r.X, r.Y, Curve, Curve, 180.0F, 90.0F)
  454.         Else
  455.             CreateRoundPath.AddLine(r.X, r.Y, r.X, r.Y)
  456.         End If
  457.         If TopRight Then
  458.             CreateRoundPath.AddArc(r.Right - Curve, r.Y, Curve, Curve, 270.0F, 90.0F)
  459.         Else
  460.             CreateRoundPath.AddLine(r.Right - r.Width, r.Y, r.Width, r.Y)
  461.         End If
  462.         If BottomRight Then
  463.             CreateRoundPath.AddArc(r.Right - Curve, r.Bottom - Curve, Curve, Curve, 0.0F, 90.0F)
  464.         Else
  465.             CreateRoundPath.AddLine(r.Right, r.Bottom, r.Right, r.Bottom)
  466.  
  467.         End If
  468.         If BottomLeft Then
  469.             CreateRoundPath.AddArc(r.X, r.Bottom - Curve, Curve, Curve, 90.0F, 90.0F)
  470.         Else
  471.             CreateRoundPath.AddLine(r.X, r.Bottom, r.X, r.Bottom)
  472.         End If
  473.         CreateRoundPath.CloseFigure()
  474.         Return CreateRoundPath
  475.     End Function
  476.  
  477. #End Region
  478.  
  479.  
  480. End Module
  481.  
  482. #End Region
  483.  
  484. #Region "Form"
  485.  
  486. Public Class DarkUIForm
  487.     Inherits ContainerControl
  488.  
  489.     #Region "Declarations"
  490.  
  491.     Private Movable As Boolean = False
  492.     Private MousePoint As New Point(-1, -1)
  493.     Private MoveHeight As Integer = 40
  494.  
  495.     #End Region
  496.  
  497.     #Region "Constructors"
  498.  
  499.     Public Sub New()
  500.         SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
  501.         UpdateStyles()
  502.         DoubleBuffered = True
  503.         Font = New Font("Helvetica Neue", 9)
  504.     End Sub
  505.  
  506.     #End Region
  507.  
  508.     #Region "Enumerators"
  509.  
  510.     Public Enum TitlePostion
  511.         Left
  512.         Center
  513.         Right
  514.     End Enum
  515.  
  516.     #End Region
  517.  
  518.     #Region "Draw Control"
  519.  
  520.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  521.         Dim G As Graphics = e.Graphics
  522.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  523.         G.InterpolationMode = InterpolationMode.HighQualityBicubic
  524.         G.CompositingQuality = CompositingQuality.HighQuality
  525.         Dim r As New Rectangle(0, 0, Width - 1, Height - 1)
  526.         Dim rH As New Rectangle(0, 0, Width - 1, 40)
  527.         Using B As New SolidBrush(Color.FromArgb(39, 39, 39)), BH As New LinearGradientBrush(rH, Color.FromArgb(64, 64, 64), Color.FromArgb(48, 48, 48), 90), p As New Pen(Color.FromArgb(22, 22, 22)), p2 As New Pen(Color.FromArgb(15, 255, 255, 255))
  528.             G.FillRectangle(B, r)
  529.             G.FillRectangle(BH, rH)
  530.             G.DrawLine(p, 0, 40, Width - 2, 40)
  531.             G.DrawLine(p2, 0, 41, Width - 2, 41)
  532.             G.DrawRectangle(p, r)
  533.         End Using
  534.  
  535.         If FindForm().ShowIcon Then
  536.             If FindForm().Icon IsNot Nothing Then
  537.                 G.DrawIcon(FindForm().Icon, New Rectangle(5, 10, 20, 20))
  538.             End If
  539.         End If
  540.  
  541.         G.DrawString(Text, Font, Brushes.White, rH, SetPosition())
  542.     End Sub
  543.    
  544.     #End Region
  545.  
  546.     #Region "Events"
  547.  
  548.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  549.         MyBase.OnMouseDown(e)
  550.         If e.Button = System.Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  551.             Movable = True
  552.             MousePoint = e.Location
  553.         End If
  554.     End Sub
  555.  
  556.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  557.         MyBase.OnMouseUp(e)
  558.         Movable = False
  559.     End Sub
  560.  
  561.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  562.         MyBase.OnMouseMove(e)
  563.         Dim x As Integer = MousePosition.X
  564.         Dim y As Integer = MousePosition.Y
  565.         Dim x1 As Integer = MousePoint.X
  566.         Dim y1 As Integer = MousePoint.Y
  567.  
  568.         If Movable Then
  569.             Parent.Location = New Point(x - x1, y - y1)
  570.         End If
  571.         Focus()
  572.     End Sub
  573.  
  574.     Protected Overrides Sub OnCreateControl()
  575.         MyBase.OnCreateControl()
  576.         ParentForm.FormBorderStyle = FormBorderStyle.None
  577.         ParentForm.Dock = DockStyle.None
  578.         Dock = DockStyle.Fill
  579.         Invalidate()
  580.     End Sub
  581.  
  582.  
  583.     #End Region
  584.  
  585. End Class
  586.  
  587. #End Region
  588.  
  589. #Region "CheckBox"
  590.  
  591. <DefaultEvent("CheckedChanged"), DefaultProperty("Checked")> _
  592. Public Class DarkUICheckBox
  593.     Inherits Control
  594.  
  595.     #Region "Variables"
  596.  
  597.     Private _Checked As Boolean
  598.  
  599.  
  600.     #End Region
  601.  
  602.     #Region "Properties"
  603.  
  604.     <Category("Custom"), Description("Gets or sets a value indicating whether the control is checked.")> _
  605.     Public Property Checked() As Boolean
  606.         Get
  607.             Return _Checked
  608.         End Get
  609.         Set
  610.             _Checked = value
  611.             If CheckedChangedEvent IsNot Nothing Then
  612.                 RaiseEvent CheckedChanged(Me)
  613.             End If
  614.             Invalidate()
  615.         End Set
  616.     End Property
  617.  
  618.     #End Region
  619.  
  620.     #Region "Constructors"
  621.  
  622.     Public Sub New()
  623.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  624.         DoubleBuffered = True
  625.         Cursor = Cursors.Hand
  626.         BackColor = Color.Transparent
  627.         ForeColor = Color.FromArgb(209, 209, 209)
  628.         Font = New Font("Helvetica Neue", 9)
  629.         UpdateStyles()
  630.     End Sub
  631.  
  632.     #End Region
  633.  
  634.     #Region "Draw Control"
  635.  
  636.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  637.         Dim G As Graphics = e.Graphics
  638.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  639.  
  640.         Dim rect As New Rectangle(1, 0, 18, 17)
  641.         Try
  642.             Using BackBrush As New LinearGradientBrush(rect, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270), P As New Pen(Color.FromArgb(22, 22, 22)), CheckMarkPen As New Pen(Color.FromArgb(189, 189, 189), 2), P2 As New Pen(Color.FromArgb(30, Color.White)), TB As New SolidBrush(Color.FromArgb(209, 209, 209))
  643.                 FillRoundedPath(G, BackBrush, rect, 2)
  644.                 DrawRoundedPath(G, P.Color, 1, New Rectangle(0, 0, 18, 17), 2)
  645.                 G.DrawLine(P2, 3, 1, 15, 1)
  646.                 G.DrawString(Text, Font, TB, New Rectangle(19, 3, Width, Height - 4), SetPosition(StringAlignment.Near))
  647.                 If Checked Then
  648.                     G.DrawLines(CheckMarkPen, New Point() {New Point(4, 8), New Point(7, 11), New Point(14, 4)})
  649.                 End If
  650.             End Using
  651.         Catch
  652.         End Try
  653.     End Sub
  654.  
  655.     #End Region
  656.  
  657.     #Region "Events"
  658.  
  659.     Public Event CheckedChanged As CheckedChangedEventHandler
  660.     Public Delegate Sub CheckedChangedEventHandler(sender As Object)
  661.  
  662.     Protected Overrides Sub OnClick(e As EventArgs)
  663.         _Checked = Not Checked
  664.         If CheckedChangedEvent IsNot Nothing Then
  665.             RaiseEvent CheckedChanged(Me)
  666.         End If
  667.         MyBase.OnClick(e)
  668.         Invalidate()
  669.     End Sub
  670.  
  671.     Protected Overrides Sub OnTextChanged(e As System.EventArgs)
  672.         Invalidate()
  673.         MyBase.OnTextChanged(e)
  674.     End Sub
  675.  
  676.     Protected Overrides Sub OnResize(e As System.EventArgs)
  677.         MyBase.OnResize(e)
  678.         Height = 18
  679.         Invalidate()
  680.     End Sub
  681.  
  682.     #End Region
  683.  
  684. End Class
  685.  
  686. #End Region
  687.  
  688. #Region "RadioButton"
  689.  
  690. <DefaultEvent("CheckedChanged"), DefaultProperty("Checked")>
  691. Public Class DarkUIRadioButton : Inherits Control
  692.  
  693.     #Region "Variables"
  694.  
  695.     Private _Checked As Boolean
  696.     Protected _Group As Integer = 1
  697.    
  698.     #End Region
  699.  
  700.     #Region "Properties"
  701.  
  702.     <Category("Custom"), Description("Gets or sets a value indicating whether the control is checked.")> _
  703.     Public Property Checked() As Boolean
  704.         Get
  705.             Return _Checked
  706.         End Get
  707.         Set
  708.             _Checked = value
  709.             If CheckedChangedEvent IsNot Nothing Then
  710.                 RaiseEvent CheckedChanged(Me)
  711.             End If
  712.             Invalidate()
  713.         End Set
  714.     End Property
  715.  
  716.     <Category("Custom")> _
  717.     Public Property Group() As Integer
  718.         Get
  719.             Return _Group
  720.         End Get
  721.         Set
  722.             _Group = value
  723.             Invalidate()
  724.         End Set
  725.     End Property
  726.  
  727.     #End Region
  728.  
  729.     #Region "Constructors"
  730.  
  731.     Public Sub New()
  732.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  733.         DoubleBuffered = True
  734.         UpdateStyles()
  735.         Cursor = Cursors.Hand
  736.         BackColor = Color.Transparent
  737.         ForeColor = Color.FromArgb(209, 209, 209)
  738.         Font = New Font("Helvetica Neue", 9)
  739.     End Sub
  740.  
  741.     #End Region
  742.  
  743.     #Region "Draw Control"
  744.  
  745.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  746.         Dim G As Graphics = e.Graphics
  747.         Dim R As New Rectangle(0, 0, 18, 18)
  748.         G.SmoothingMode = SmoothingMode.HighQuality
  749.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  750.  
  751.         Using BackBrush As New LinearGradientBrush(R, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270), CheckMarkBrush As New SolidBrush(Color.FromArgb(189, 189, 189)), Border As New Pen(Color.FromArgb(22, 22, 22)), TB As New SolidBrush(ForeColor), P2 As New Pen(Color.FromArgb(20, Color.White))
  752.             G.FillEllipse(BackBrush, R)
  753.             G.DrawEllipse(P2, New Rectangle(1, 1, 16, 16))
  754.             G.DrawEllipse(Border, R)
  755.             G.DrawString(Text, Font, TB, New Rectangle(21, 1, Width, Height - 2), SetPosition(StringAlignment.Near))
  756.             If Checked Then
  757.                 G.FillEllipse(CheckMarkBrush, New Rectangle(5, 5, 8, 8))
  758.             End If
  759.         End Using
  760.  
  761.     End Sub
  762.  
  763.     #End Region
  764.  
  765.     #Region "Events"
  766.  
  767.     Public Event CheckedChanged As CheckedChangedEventHandler
  768.     Public Delegate Sub CheckedChangedEventHandler(sender As Object)
  769.  
  770.     Private Sub UpdateState()
  771.         If Not IsHandleCreated OrElse Not Checked Then
  772.             Return
  773.         End If
  774.         For Each C As Control In Parent.Controls
  775.             If Not Object.ReferenceEquals(C, Me) AndAlso TypeOf C Is DarkUIRadioButton AndAlso DirectCast(C, DarkUIRadioButton).Group = _Group Then
  776.                 DirectCast(C, DarkUIRadioButton).Checked = False
  777.             End If
  778.         Next
  779.     End Sub
  780.  
  781.     Protected Overrides Sub OnClick(e As EventArgs)
  782.         _Checked = Not Checked
  783.         UpdateState()
  784.         MyBase.OnClick(e)
  785.         Invalidate()
  786.     End Sub
  787.  
  788.     Protected Overrides Sub OnCreateControl()
  789.         UpdateState()
  790.         MyBase.OnCreateControl()
  791.     End Sub
  792.  
  793.     Protected Overrides Sub OnTextChanged(e As System.EventArgs)
  794.         Invalidate()
  795.         MyBase.OnTextChanged(e)
  796.     End Sub
  797.  
  798.     Protected Overrides Sub OnResize(e As System.EventArgs)
  799.         MyBase.OnResize(e)
  800.         Height = 21
  801.         Invalidate()
  802.     End Sub
  803.  
  804.     #End Region
  805.  
  806. End Class
  807.  
  808. #End Region
  809.  
  810. #Region "ComboBox"
  811.  
  812. <DefaultEvent("SelectedIndexChanged")> _
  813. Public Class DarkUIComboBox : Inherits ComboBox
  814.  
  815.     #Region "Declarations"
  816.    
  817.     Private _StartIndex As Integer = 0
  818.     Public Shadows Event SelectedIndexChanged As SelectedIndexChangedEventHandler
  819.     Public Delegate Sub SelectedIndexChangedEventHandler(sender As Object)
  820.  
  821.     #End Region
  822.  
  823.     #Region "Constructors"
  824.  
  825.     Public Sub New()
  826.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
  827.         BackColor = Color.Transparent
  828.         Font = New Font("Helvetica Neue", 10)
  829.         DrawMode = DrawMode.OwnerDrawFixed
  830.         DoubleBuffered = True
  831.         StartIndex = 0
  832.         DropDownStyle = ComboBoxStyle.DropDownList
  833.         UpdateStyles()
  834.     End Sub
  835.  
  836.     #End Region
  837.  
  838.     #Region "Properties"
  839.  
  840.     <Category("Custom"), Description("Gets or sets the index specifying the currently selected item.")> _
  841.     Private Property StartIndex() As Integer
  842.         Get
  843.             Return _StartIndex
  844.         End Get
  845.         Set
  846.             _StartIndex = value
  847.             Try
  848.                 MyBase.SelectedIndex = value
  849.                 If SelectedIndexChangedEvent IsNot Nothing Then
  850.                     RaiseEvent SelectedIndexChanged(Me)
  851.                 End If
  852.             Catch
  853.             End Try
  854.             Invalidate()
  855.         End Set
  856.     End Property
  857.  
  858.     #End Region
  859.  
  860.     #Region "Draw Control"
  861.  
  862.     Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  863.         Dim G As Graphics = e.Graphics
  864.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  865.  
  866.         Try
  867.             Using BG As New LinearGradientBrush(e.Graphics.ClipBounds, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270),
  868.                 TC As New SolidBrush(If((e.State And DrawItemState.Selected) <> 0, Color.White, Color.FromArgb(189, 189, 189))),
  869.                 F As New Font(Font.Name, Font.Size - 2)
  870.                 G.FillRectangle(BG, e.Bounds)
  871.                 G.DrawString(GetItemText(Items(e.Index)), F, TC, e.Bounds, SetPosition(StringAlignment.Near))
  872.             End Using
  873.         Catch
  874.         End Try
  875.  
  876.     End Sub
  877.  
  878.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  879.         Dim G As Graphics = e.Graphics
  880.  
  881.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  882.         Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
  883.  
  884.         Using P2 As New Pen(Color.FromArgb(20, Color.White)), B As New SolidBrush(Color.FromArgb(31, 31, 31)),
  885.             B2 As New LinearGradientBrush(New Rectangle(Width - 29, 0, 30, Height - 1), Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270)
  886.             FillRoundedPath(G, B, Rect, 1)
  887.             FillRoundedPath(G, B2, New Rectangle(Width - 29, 0, 30, Height - 1), 1, False, True, False)
  888.             G.DrawLine(P2, Width - 28, 1, Width - 28 + Width, 1)
  889.             DrawRoundedPath(G, Color.FromArgb(22, 22, 22), 1, Rect, 2)
  890.         End Using
  891.  
  892.         G.SmoothingMode = SmoothingMode.AntiAlias
  893.  
  894.         DrawTriangle(G, Color.FromArgb(192, 192, 192), 2, New Point(Width - 20, 10), New Point(Width - 16, 14), New Point(Width - 16, 14), _
  895.             New Point(Width - 12, 10), New Point(Width - 16, 15), New Point(Width - 16, 14))
  896.         G.SmoothingMode = SmoothingMode.None
  897.         Using TC As New SolidBrush(Color.FromArgb(168, 168, 168)), F As New Font(Font.Name, Font.Size - 2)
  898.             G.DrawString(Text, F, TC, New Rectangle(7, 1, Width - 1, Height - 1), SetPosition(StringAlignment.Near))
  899.         End Using
  900.     End Sub
  901.  
  902.     #End Region
  903.  
  904. End Class
  905.  
  906. #End Region
  907.  
  908. #Region "TextBox"
  909.  
  910. <DefaultEvent("TextChanged")> _
  911. Public Class DarkUITextBox : Inherits Control
  912.  
  913.     #Region "Declarations"
  914.  
  915.     Private _T As New TextBox()
  916.     Private Property T() As TextBox
  917.         Get
  918.             Return _T
  919.         End Get
  920.         Set
  921.             If _T IsNot Nothing Then
  922.                 RemoveHandler _T.TextChanged, AddressOf T_TextChanged
  923.                 RemoveHandler _T.KeyDown, AddressOf T_KeyDown
  924.             End If
  925.             _T = value
  926.             If _T IsNot Nothing Then
  927.                 AddHandler _T.TextChanged, AddressOf T_TextChanged
  928.                 AddHandler _T.KeyDown, AddressOf T_KeyDown
  929.             End If
  930.         End Set
  931.     End Property
  932.  
  933.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  934.     Private _MaxLength As Integer = 32767
  935.     Private _ReadOnly As Boolean = False
  936.     Private _UseSystemPasswordChar As Boolean = False
  937.     Private _WatermarkText As String = String.Empty
  938.     Private _Image As Image
  939.     Private _AutoCompleteSource As AutoCompleteSource = AutoCompleteSource.None
  940.     Private _AutoCompleteMode As AutoCompleteMode = AutoCompleteMode.None
  941.     Private _AutoCompleteCustomSource As AutoCompleteStringCollection
  942.     Private _Multiline As Boolean = False
  943.     Private _Lines As String() = Nothing
  944.  
  945. #End Region
  946.  
  947.     #Region "Native Methods"
  948.  
  949.     Private Declare Auto Function SendMessage Lib "user32.dll" (hWnd As IntPtr, msg As Integer, wParam As Integer, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)> lParam As String) As Int32
  950.    
  951.     #End Region
  952.  
  953.     #Region "Properties"
  954.  
  955.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  956.     Public ReadOnly Property BorderStyle() As BorderStyle
  957.         Get
  958.             Return BorderStyle.None
  959.         End Get
  960.     End Property
  961.  
  962.     <Category("Custom"), Description("Gets or sets how text is aligned in TextBox control.")> _
  963.     Public Property TextAlign() As HorizontalAlignment
  964.         Get
  965.             Return _TextAlign
  966.         End Get
  967.         Set
  968.             _TextAlign = value
  969.             If T IsNot Nothing Then
  970.                 T.TextAlign = value
  971.             End If
  972.             Invalidate()
  973.         End Set
  974.     End Property
  975.  
  976.     <Category("Custom"), Description("Gets or sets how text is aligned in TextBox control.")> _
  977.     Public Property MaxLength() As Integer
  978.         Get
  979.             Return _MaxLength
  980.         End Get
  981.         Set
  982.             _MaxLength = value
  983.             If T IsNot Nothing Then
  984.                 T.MaxLength = value
  985.             End If
  986.             Invalidate()
  987.         End Set
  988.     End Property
  989.    
  990.     <Category("Custom"), Description("Gets or sets a value indicating whether text in the text box is read-only.")> _
  991.     Public Property [ReadOnly]() As Boolean
  992.         Get
  993.             Return _ReadOnly
  994.         End Get
  995.         Set
  996.             _ReadOnly = value
  997.             If T IsNot Nothing Then
  998.                 T.[ReadOnly] = value
  999.             End If
  1000.         End Set
  1001.     End Property
  1002.  
  1003.     <Category("Custom"), Description("Gets or sets a value indicating whether the text in  TextBox control should appear as the default password character.")> _
  1004.     Public Property UseSystemPasswordChar() As Boolean
  1005.         Get
  1006.             Return _UseSystemPasswordChar
  1007.         End Get
  1008.         Set
  1009.             _UseSystemPasswordChar = value
  1010.             If T IsNot Nothing Then
  1011.                 T.UseSystemPasswordChar = value
  1012.             End If
  1013.         End Set
  1014.     End Property
  1015.  
  1016.     <Category("Custom"), Description("Gets or sets a value indicating whether this is a multiline System.Windows.Forms.TextBox control.")> _
  1017.     Public Property Multiline() As Boolean
  1018.         Get
  1019.             Return _Multiline
  1020.         End Get
  1021.         Set
  1022.             _Multiline = value
  1023.             If T Is Nothing Then
  1024.                 Return
  1025.             End If
  1026.             T.Multiline = value
  1027.             If value Then
  1028.                 T.Height = Height - 10
  1029.             Else
  1030.                 Height = T.Height + 10
  1031.             End If
  1032.         End Set
  1033.     End Property
  1034.  
  1035.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1036.     Public Shadows ReadOnly Property BackgroundImage() As Image
  1037.         Get
  1038.             Return Nothing
  1039.         End Get
  1040.     End Property
  1041.  
  1042.     <Category("Custom"), Description("Gets or sets the current text in  TextBox.")> _
  1043.     Public Overrides Property Text() As String
  1044.         Get
  1045.             Return MyBase.Text
  1046.         End Get
  1047.         Set
  1048.             MyBase.Text = value
  1049.             If T IsNot Nothing Then
  1050.                 T.Text = value
  1051.             End If
  1052.         End Set
  1053.     End Property
  1054.  
  1055.     <Category("Custom"), Description("Gets or sets the text in the System.Windows.Forms.TextBox while being empty.")> _
  1056.     Public Property WatermarkText() As String
  1057.         Get
  1058.             Return _WatermarkText
  1059.         End Get
  1060.         Set
  1061.             _WatermarkText = value
  1062.             SendMessage(T.Handle, 5377, 0, value)
  1063.             Invalidate()
  1064.         End Set
  1065.     End Property
  1066.  
  1067.     <Category("Custom"), Description("Gets or sets the image of the control.")> _
  1068.     Public Property Image() As Image
  1069.         Get
  1070.             Return _Image
  1071.         End Get
  1072.         Set
  1073.             _Image = value
  1074.             Invalidate()
  1075.         End Set
  1076.     End Property
  1077.  
  1078.     <Category("Custom"), Description("Gets or sets a value specifying the source of complete strings used for automatic completion.")> _
  1079.     Public Property AutoCompleteSource() As AutoCompleteSource
  1080.         Get
  1081.             Return _AutoCompleteSource
  1082.         End Get
  1083.         Set
  1084.             _AutoCompleteSource = value
  1085.             If T IsNot Nothing Then
  1086.                 T.AutoCompleteSource = value
  1087.             End If
  1088.             Invalidate()
  1089.         End Set
  1090.     End Property
  1091.  
  1092.     <Category("Custom"), Description("Gets or sets a value specifying the source of complete strings used for automatic completion.")> _
  1093.     Public Property AutoCompleteCustomSource() As AutoCompleteStringCollection
  1094.         Get
  1095.             Return _AutoCompleteCustomSource
  1096.         End Get
  1097.         Set
  1098.             _AutoCompleteCustomSource = value
  1099.             If T IsNot Nothing Then
  1100.                 T.AutoCompleteCustomSource = value
  1101.             End If
  1102.             Invalidate()
  1103.         End Set
  1104.     End Property
  1105.  
  1106.     <Category("Custom"), Description("Gets or sets an option that controls how automatic completion works for the TextBox.")> _
  1107.     Public Property AutoCompleteMode() As AutoCompleteMode
  1108.         Get
  1109.             Return _AutoCompleteMode
  1110.         End Get
  1111.         Set
  1112.             _AutoCompleteMode = value
  1113.             If T IsNot Nothing Then
  1114.                 T.AutoCompleteMode = value
  1115.             End If
  1116.             Invalidate()
  1117.         End Set
  1118.     End Property
  1119.  
  1120.     <Category("Custom"), Description("Gets or sets the font of the text displayed by the control.")> _
  1121.     Public Shadows Property Font() As Font
  1122.         Get
  1123.             Return MyBase.Font
  1124.         End Get
  1125.         Set
  1126.             MyBase.Font = value
  1127.             If T Is Nothing Then
  1128.                 Return
  1129.             End If
  1130.             T.Font = value
  1131.             T.Location = New Point(5, 5)
  1132.             T.Width = Width - 8
  1133.             If Not Multiline Then
  1134.                 Height = T.Height + 11
  1135.             End If
  1136.         End Set
  1137.     End Property
  1138.  
  1139.     <Category("Custom"), Description("Gets or sets the lines of text in the control.")> _
  1140.     Public Property Lines() As String()
  1141.         Get
  1142.             Return _Lines
  1143.         End Get
  1144.         Set
  1145.             _Lines = value
  1146.             If T Is Nothing Then
  1147.                 Return
  1148.             End If
  1149.             T.Lines = value
  1150.             Invalidate()
  1151.         End Set
  1152.     End Property
  1153.  
  1154.     <Category("Custom"), Description("Gets or sets the ContextMenuStrip associated with this control.")> _
  1155.     Public Overrides Property ContextMenuStrip() As ContextMenuStrip
  1156.         Get
  1157.             Return MyBase.ContextMenuStrip
  1158.         End Get
  1159.         Set
  1160.             MyBase.ContextMenuStrip = value
  1161.             If T Is Nothing Then
  1162.                 Return
  1163.             End If
  1164.             T.ContextMenuStrip = value
  1165.             Invalidate()
  1166.         End Set
  1167.     End Property
  1168.  
  1169.     #End Region
  1170.  
  1171.     #Region "Constructors"
  1172.  
  1173.     Public Sub New()
  1174.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
  1175.         DoubleBuffered = True
  1176.         UpdateStyles()
  1177.         BackColor = Color.Transparent
  1178.         ForeColor = Color.FromArgb(189, 189, 189)
  1179.         Font = New Font("Helvetica World", 10)
  1180.         T.Multiline = False
  1181.         T.Cursor = Cursors.IBeam
  1182.         T.BackColor = Color.FromArgb(31, 31, 31)
  1183.         T.ForeColor = ForeColor
  1184.         T.BorderStyle = BorderStyle.None
  1185.         T.Location = New Point(7, 4)
  1186.         T.Font = Font
  1187.         T.UseSystemPasswordChar = UseSystemPasswordChar
  1188.         Size = New Size(135, 30)
  1189.         If Multiline Then
  1190.             T.Height = Height - 11
  1191.         Else
  1192.             Height = T.Height + 11
  1193.         End If
  1194.     End Sub
  1195.  
  1196.     #End Region
  1197.  
  1198.     #Region "Events"
  1199.  
  1200.     Public Shadows Event TextChanged As TextChangedEventHandler
  1201.     Public Delegate Sub TextChangedEventHandler(sender As Object)
  1202.  
  1203.     Protected Overrides Sub OnCreateControl()
  1204.         MyBase.OnCreateControl()
  1205.         If Not Controls.Contains(T) Then
  1206.             Controls.Add(T)
  1207.         End If
  1208.     End Sub
  1209.  
  1210.     Protected Overrides Sub OnResize(e As EventArgs)
  1211.         MyBase.OnResize(e)
  1212.         T.Size = New Size(Width - 10, Height - 10)
  1213.     End Sub
  1214.  
  1215.     #Region "TextBox MouseEvents"
  1216.  
  1217.     Private Sub T_TextChanged(sender As Object, e As EventArgs)
  1218.         Text = T.Text
  1219.         If TextChangedEvent IsNot Nothing Then
  1220.             RaiseEvent TextChanged(Me)
  1221.         End If
  1222.         Invalidate()
  1223.     End Sub
  1224.  
  1225.     Private Sub T_KeyDown(sender As Object, e As KeyEventArgs)
  1226.         If e.Control AndAlso e.KeyCode = Keys.A Then
  1227.             e.SuppressKeyPress = True
  1228.         End If
  1229.         If e.Control AndAlso e.KeyCode = Keys.C Then
  1230.             T.Copy()
  1231.             e.SuppressKeyPress = True
  1232.         End If
  1233.         Invalidate()
  1234.     End Sub
  1235.  
  1236.     #End Region
  1237.  
  1238.     #End Region
  1239.  
  1240.     #Region "Draw Control"
  1241.  
  1242.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1243.         Dim G As Graphics = e.Graphics
  1244.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  1245.  
  1246.         Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
  1247.  
  1248.         Using B As New SolidBrush(Color.FromArgb(31, 31, 31))
  1249.             FillRoundedPath(G, B, Rect, 2)
  1250.             DrawRoundedPath(G, Color.FromArgb(22, 22, 22), 1, Rect, 2)
  1251.         End Using
  1252.  
  1253.         If Image IsNot Nothing Then
  1254.             T.Location = New Point(31, 4)
  1255.             T.Width = Width - 60
  1256.             G.InterpolationMode = InterpolationMode.HighQualityBicubic
  1257.             G.DrawImage(Image, New Rectangle(8, 6, 16, 16))
  1258.         Else
  1259.             T.Location = New Point(7, 4)
  1260.  
  1261.             T.Width = Width - 10
  1262.         End If
  1263.        
  1264.     End Sub
  1265.  
  1266.     #End Region
  1267.  
  1268. End Class
  1269.  
  1270. #End Region
  1271.  
  1272. #Region "Button"
  1273.  
  1274. Public Class DarkUIButton : Inherits Control
  1275.  
  1276.     #Region "Declarations"
  1277.    
  1278.     Private State As MouseMode
  1279.     Private _RoundRadius As Integer = 0
  1280.  
  1281.     #End Region
  1282.  
  1283.     #Region "Constructors"
  1284.  
  1285.     Public Sub New()
  1286.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
  1287.         DoubleBuffered = True
  1288.         BackColor = Color.Transparent
  1289.         Font = New Font("Helvetica Neue", 10)
  1290.         UpdateStyles()
  1291.     End Sub
  1292.  
  1293.     #End Region
  1294.  
  1295.     #Region "Properties"
  1296.  
  1297.     <Category("Custom"), Description("Gets or sets a value indicating whether the control can Rounded in corners.")> _
  1298.     Public Property RoundRadius() As Integer
  1299.         Get
  1300.             Return _RoundRadius
  1301.         End Get
  1302.         Set
  1303.             _RoundRadius = value
  1304.             Invalidate()
  1305.         End Set
  1306.     End Property
  1307.  
  1308.     #End Region
  1309.  
  1310.     #Region "Draw Control"
  1311.  
  1312.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1313.         Dim G As Graphics = e.Graphics
  1314.         Dim GP As New GraphicsPath(), GP2 As New GraphicsPath()
  1315.         Dim Rect As New Rectangle(0, 0, Width - 1, Height - 2), Rect2 As New Rectangle(0, 1, Width - 1, Height - 2)
  1316.  
  1317.         If RoundRadius > 0 Then
  1318.             G.SmoothingMode = SmoothingMode.AntiAlias
  1319.             GP = RoundRec(Rect, RoundRadius)
  1320.             GP2 = RoundRec(Rect2, RoundRadius)
  1321.         Else
  1322.             GP.AddRectangle(Rect)
  1323.             GP2.AddRectangle(Rect2)
  1324.         End If
  1325.  
  1326.         GP.CloseFigure()
  1327.  
  1328.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  1329.  
  1330.         Select Case State
  1331.  
  1332.             Case MouseMode.Normal
  1333.                 Using BG As New LinearGradientBrush(Rect, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270), P As New Pen(Color.FromArgb(22, 22, 22)), _
  1334.                         P2 As New Pen(Color.FromArgb(30, Color.White)), TB As New SolidBrush(Color.FromArgb(212, 212, 212))
  1335.                     G.FillPath(BG, GP)
  1336.                     G.DrawPath(P2, GP2)
  1337.                     G.DrawPath(P, GP)
  1338.                     G.DrawString(Text, Font, TB, New Rectangle(0, 0, Width, Height), SetPosition())
  1339.                 End Using
  1340.                 Exit Select
  1341.             Case MouseMode.Hovered
  1342.                 Cursor = Cursors.Hand
  1343.                 Using BG As New LinearGradientBrush(Rect, Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 270), P As New Pen(Color.FromArgb(22, 22, 22)), _
  1344.                         P2 As New Pen(Color.FromArgb(30, Color.White)), TB As New SolidBrush(Color.FromArgb(212, 212, 212))
  1345.                     G.FillPath(BG, GP)
  1346.                     G.DrawPath(P2, GP2)
  1347.                     G.DrawPath(P, GP)
  1348.                     G.DrawString(Text, Font, TB, New Rectangle(0, 0, Width, Height), SetPosition())
  1349.                 End Using
  1350.                 Exit Select
  1351.             Case MouseMode.Pushed
  1352.                 Using BG As New LinearGradientBrush(Rect, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270), P As New Pen(Color.FromArgb(22, 22, 22)), _
  1353.                     P2 As New Pen(Color.FromArgb(30, Color.White)), TB As New SolidBrush(Color.FromArgb(212, 212, 212))
  1354.                     G.FillPath(BG, GP)
  1355.                     G.DrawPath(P2, GP2)
  1356.                     G.DrawPath(P, GP)
  1357.                     G.DrawString(Text, Font, TB, New Rectangle(0, 0, Width, Height), SetPosition())
  1358.                 End Using
  1359.                 Exit Select
  1360.         End Select
  1361.  
  1362.         GP.Dispose()
  1363.     End Sub
  1364.  
  1365.     #End Region
  1366.  
  1367.     #Region "Events"
  1368.  
  1369.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1370.         MyBase.OnMouseUp(e)
  1371.         State = MouseMode.Hovered
  1372.         Invalidate()
  1373.     End Sub
  1374.  
  1375.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1376.         MyBase.OnMouseUp(e)
  1377.         State = MouseMode.Pushed
  1378.         Invalidate()
  1379.     End Sub
  1380.  
  1381.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1382.         MyBase.OnMouseEnter(e)
  1383.         State = MouseMode.Hovered
  1384.         Invalidate()
  1385.     End Sub
  1386.  
  1387.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1388.         MyBase.OnMouseEnter(e)
  1389.         State = MouseMode.Normal
  1390.         Invalidate()
  1391.     End Sub
  1392.  
  1393.     #End Region
  1394.  
  1395. End Class
  1396.  
  1397. #End Region
  1398.  
  1399. #Region "Numerical UPDown"
  1400.  
  1401. Public Class DarkUINumericUpDown : Inherits Control
  1402.  
  1403.     #Region "Variables"
  1404.    
  1405.     Private X As Integer = 0
  1406.     Private Y As Integer = 0
  1407.     Private _Value As Integer = 0
  1408.     Private _Maximum As Integer = 100
  1409.     Private _Minimum As Integer = 0
  1410.  
  1411.     #End Region
  1412.  
  1413.     #Region "Properties"
  1414.  
  1415.     <Category("Custom"), Description("Gets or sets the current number of the NumericUpDown.")> _
  1416.     Public Property Value() As Integer
  1417.         Get
  1418.             Return _Value
  1419.         End Get
  1420.         Set
  1421.             If value <= Maximum And value >= Minimum Then
  1422.                 _Value = value
  1423.             End If
  1424.             If value > Maximum Then
  1425.                 _Value = Maximum
  1426.             End If
  1427.             Invalidate()
  1428.         End Set
  1429.     End Property
  1430.  
  1431.     <Category("Custom"), Description("Gets or sets the maximum number of the NumericUpDown.")> _
  1432.     Public Property Maximum() As Integer
  1433.         Get
  1434.             Return _Maximum
  1435.         End Get
  1436.         Set
  1437.             If value > Minimum Then
  1438.                 _Maximum = value
  1439.             End If
  1440.             If value > _Maximum Then
  1441.                 value = _Maximum
  1442.             End If
  1443.             Invalidate()
  1444.         End Set
  1445.     End Property
  1446.  
  1447.     <Category("Custom"), Description("Gets or sets the minimum number of the NumericUpDown.")> _
  1448.     Public Property Minimum() As Integer
  1449.         Get
  1450.             Return _Minimum
  1451.         End Get
  1452.         Set
  1453.             If value < Maximum Then
  1454.                 _Minimum = value
  1455.             End If
  1456.             If value < _Minimum Then
  1457.                 value = _Minimum
  1458.             End If
  1459.             Invalidate()
  1460.         End Set
  1461.     End Property
  1462.  
  1463.     #End Region
  1464.  
  1465.     #Region "Constructors"
  1466.  
  1467.     Public Sub New()
  1468.         SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
  1469.         DoubleBuffered = True
  1470.         UpdateStyles()
  1471.         BackColor = Color.Transparent
  1472.         Font = New Font("Helvetica Neue", 10)
  1473.     End Sub
  1474.  
  1475.     #End Region
  1476.  
  1477.     #Region "Draw Control"
  1478.  
  1479.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1480.         Dim G As Graphics = e.Graphics
  1481.  
  1482.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  1483.  
  1484.         Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
  1485.  
  1486.         Using B As New SolidBrush(Color.FromArgb(31, 31, 31))
  1487.             Using CR As New LinearGradientBrush(Rect, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270), P As New Pen(Color.FromArgb(22, 22, 22)), _
  1488.                 P2 As New Pen(Color.FromArgb(20, Color.White))
  1489.                 G.FillRectangle(B, Rect)
  1490.                 G.FillPath(CR, RoundRec(New Rectangle(Width - 25, 0, 24, Height - 1), 2))
  1491.                 G.DrawLine(P, New Point(Width - 25, 1), New Point(Width - 25, Height - 2))
  1492.                 G.DrawLine(P, New Point(Width - 25, 13), New Point(Width - 1, 13))
  1493.                 G.DrawLine(P2, Width - 24, 1, Width - 24 + Width, 1)
  1494.             End Using
  1495.         End Using
  1496.         G.SmoothingMode = SmoothingMode.AntiAlias
  1497.         Using AboveWardTriangle As New GraphicsPath()
  1498.             Using B As New SolidBrush(If(Value <> Maximum, Color.FromArgb(192, 192, 192), Color.FromArgb(22, 22, 22)))
  1499.                 AboveWardTriangle.AddLine(Width - 17, 9, Width - 2, 9)
  1500.                 AboveWardTriangle.AddLine(Width - 9, 9, Width - 13, 4)
  1501.                 AboveWardTriangle.CloseFigure()
  1502.                 G.FillPath(B, AboveWardTriangle)
  1503.             End Using
  1504.         End Using
  1505.         Using DownWardTriangle As New GraphicsPath()
  1506.             Using B As New SolidBrush(If(Value > Minimum, Color.FromArgb(192, 192, 192), Color.FromArgb(22, 22, 22)))
  1507.                 DownWardTriangle.AddLine(Width - 17, 17, Width - 2, 17)
  1508.                 DownWardTriangle.AddLine(Width - 9, 17, Width - 13, 22)
  1509.                 DownWardTriangle.CloseFigure()
  1510.                 G.FillPath(B, DownWardTriangle)
  1511.             End Using
  1512.         End Using
  1513.         G.SmoothingMode = SmoothingMode.[Default]
  1514.         Using B As New SolidBrush(Color.FromArgb(207, 207, 207))
  1515.             G.DrawString(Value.ToString(), Font, B, New Rectangle(0, 0, Width - 18, Height), SetPosition())
  1516.         End Using
  1517.  
  1518.         Using P As New Pen(Color.FromArgb(22, 22, 22))
  1519.             G.DrawRectangle(P, Rect)
  1520.         End Using
  1521.  
  1522.     End Sub
  1523.  
  1524.     #End Region
  1525.  
  1526.     #Region "Events"
  1527.  
  1528.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  1529.         MyBase.OnMouseMove(e)
  1530.         X = e.Location.X
  1531.         Y = e.Location.Y
  1532.         Invalidate()
  1533.         If e.X < Width - 25 Then
  1534.             Cursor = Cursors.IBeam
  1535.         Else
  1536.             Cursor = Cursors.Hand
  1537.         End If
  1538.     End Sub
  1539.  
  1540.     Protected Overrides Sub OnResize(e As EventArgs)
  1541.         MyBase.OnResize(e)
  1542.         Height = 26
  1543.     End Sub
  1544.  
  1545.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1546.         OnMouseClick(e)
  1547.         If X > Width - 17 AndAlso X < Width - 3 Then
  1548.             If Y < 13 Then
  1549.                 If (Value + 1) <= Maximum Then
  1550.                     Value += 1
  1551.                 End If
  1552.             Else
  1553.                 If (Value - 1) >= Minimum Then
  1554.                     Value -= 1
  1555.                 End If
  1556.             End If
  1557.         End If
  1558.         Invalidate()
  1559.     End Sub
  1560.  
  1561.     Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean
  1562.         If keyData = Keys.Down Or keyData = Keys.[Next] Then
  1563.             If (Value - 1) >= Minimum Then
  1564.                 Value -= 1
  1565.             End If
  1566.             Invalidate()
  1567.             Return True
  1568.         ElseIf keyData = Keys.Up Or keyData = Keys.Back Then
  1569.             If (Value + 1) <= Maximum Then
  1570.                 Value += 1
  1571.             End If
  1572.             Invalidate()
  1573.             Return True
  1574.         Else
  1575.             Return MyBase.ProcessCmdKey(msg, keyData)
  1576.         End If
  1577.     End Function
  1578.  
  1579.     #End Region
  1580.  
  1581. End Class
  1582.  
  1583.  
  1584. #End Region
  1585.  
  1586. #Region "ProgressBar"
  1587.  
  1588. <DefaultEvent("ValueChanged"), DefaultProperty("Value")>
  1589. Public Class DarkUIProgressBar : Inherits Control
  1590.  
  1591.     #Region "Declarations"
  1592.  
  1593.     Private _Maximum As Integer = 100
  1594.     Private _Value As Integer = 0
  1595.     Private _ShowProgressLines As Boolean = True
  1596.     Public Event ValueChanged As ValueChangedEventHandler
  1597.     Public Delegate Sub ValueChangedEventHandler(sender As Object)
  1598.     Private _ShowProgressValue As Boolean = True
  1599.  
  1600.     #End Region
  1601.  
  1602.     #Region "Constructors"
  1603.  
  1604.  
  1605.     Public Sub New()
  1606.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
  1607.         DoubleBuffered = True
  1608.         BackColor = Color.Transparent
  1609.         UpdateStyles()
  1610.         Font = New Font("Helvetica Neue", 9)
  1611.     End Sub
  1612.  
  1613.     #End Region
  1614.  
  1615.     #Region "Properties"
  1616.  
  1617.     <Category("Custom"), Description("Gets or sets the current position of the progressbar.")> _
  1618.     Public Property Value() As Integer
  1619.         Get
  1620.             If _Value < 0 Then
  1621.                 Return 0
  1622.             Else
  1623.                 Return _Value
  1624.             End If
  1625.         End Get
  1626.         Set
  1627.             If value > Maximum Then
  1628.                 value = Maximum
  1629.             End If
  1630.             _Value = value
  1631.             If ValueChangedEvent IsNot Nothing Then
  1632.                 RaiseEvent ValueChanged(Me)
  1633.             End If
  1634.             Invalidate()
  1635.         End Set
  1636.     End Property
  1637.  
  1638.     <Category("Custom"), Description("Gets or sets the maximum value of the progressbar.")> _
  1639.     Public Property Maximum() As Integer
  1640.         Get
  1641.             Return _Maximum
  1642.         End Get
  1643.         Set
  1644.             If value < _Value Then
  1645.                 _Value = Value
  1646.             End If
  1647.             _Maximum = value
  1648.             Invalidate()
  1649.         End Set
  1650.     End Property
  1651.  
  1652.     <Category("Custom"), Description("Gets or sets the whether the progressbar line be shown or not.")> _
  1653.     Public Property ShowProgressLines() As Boolean
  1654.         Get
  1655.             Return _ShowProgressLines
  1656.         End Get
  1657.         Set
  1658.             _ShowProgressLines = value
  1659.             Invalidate()
  1660.         End Set
  1661.     End Property
  1662.  
  1663.     <Category("Custom"), Description("Gets or sets the whether the progressbar value be shown or not.")> _
  1664.     Public Property ShowProgressValue() As Boolean
  1665.         Get
  1666.             Return _ShowProgressValue
  1667.         End Get
  1668.         Set
  1669.             _ShowProgressValue = value
  1670.             Invalidate()
  1671.         End Set
  1672.     End Property
  1673.  
  1674.     #End Region
  1675.  
  1676.     #Region "Draw Control"
  1677.  
  1678.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1679.         Dim G As Graphics = e.Graphics
  1680.         G.TextRenderingHint = TextRenderingHint.AntiAlias
  1681.  
  1682.         Dim GP As New GraphicsPath()
  1683.  
  1684.         Dim CurrentValue As Integer = Convert.ToInt32(Value / CDbl(Maximum) * Width)
  1685.         Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
  1686.  
  1687.         Using BG As New LinearGradientBrush(Rect, Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 90)
  1688.             G.FillPath(BG, RoundRec(Rect, 2))
  1689.         End Using
  1690.  
  1691.         If CurrentValue <> 0 Then
  1692.             Using PS As New LinearGradientBrush(New Rectangle(Rect.X, Rect.Y, CurrentValue - 1, Rect.Height), Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270)
  1693.                 Using P2 As New Pen(Color.FromArgb(20, Color.White))
  1694.                     G.FillPath(PS, RoundRec(New Rectangle(Rect.X, Rect.Y, CurrentValue - 1, Rect.Height), 2))
  1695.                     Using PSL As New Pen(Color.FromArgb(50, 50, 50), 20)
  1696.                         If ShowProgressLines Then
  1697.                             G.SmoothingMode = SmoothingMode.AntiAlias
  1698.                             For i As Integer = 9 To Convert.ToInt32((Width - 20) * (CDbl(Value) / Maximum)) Step 45
  1699.                                 G.DrawLine(PSL, New Point(i, Convert.ToInt32((Height \ 2) - Height)), New Point(i - Height, Convert.ToInt32((Height \ 2) + Height)))
  1700.                             Next
  1701.                         End If
  1702.                     End Using
  1703.                     G.DrawLine(P2, Rect.X, 1, CurrentValue - 2, 1)
  1704.                 End Using
  1705.             End Using
  1706.         End If
  1707.         Using B As New SolidBrush(Color.FromArgb(207, 207, 207))
  1708.             If ShowProgressValue Then
  1709.                 G.DrawString(Value & "%", Font, B, New Rectangle(0, 1, Width, Height), SetPosition())
  1710.             End If
  1711.         End Using
  1712.  
  1713.         Using PSL As New Pen(Color.FromArgb(22, 22, 22))
  1714.             G.DrawPath(PSL, RoundRec(Rect, 2))
  1715.         End Using
  1716.         GP.Dispose()
  1717.     End Sub
  1718.  
  1719.     #End Region
  1720.  
  1721. End Class
  1722.  
  1723. #End Region
  1724.  
  1725. #Region "TabControl"
  1726.  
  1727. Public Class DarkUITabControl : Inherits TabControl
  1728.  
  1729.     #Region "Constructors"
  1730.  
  1731.     Public Sub New()
  1732.         SetStyle(ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.SupportsTransparentBackColor, True)
  1733.         DoubleBuffered = True
  1734.         SizeMode = TabSizeMode.Fixed
  1735.         Dock = DockStyle.None
  1736.         ItemSize = New Size(80, 32)
  1737.         Font = New Font("Helvetica Neue", 8)
  1738.         Alignment = TabAlignment.Top
  1739.         UpdateStyles()
  1740.     End Sub
  1741.  
  1742.     #End Region
  1743.  
  1744.     #Region "Draw Control"
  1745.  
  1746.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1747.         Dim G As Graphics = e.Graphics
  1748.         G.SmoothingMode = SmoothingMode.AntiAlias
  1749.         G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit
  1750.         G.Clear(Color.FromArgb(39, 39, 39))
  1751.  
  1752.         Cursor = Cursors.Hand
  1753.  
  1754.         Dim Rects As Integer = 0
  1755.  
  1756.         For i As Integer = 0 To TabCount - 1
  1757.             Dim R As Rectangle = GetTabRect(i)
  1758.  
  1759.             If i = TabCount - 1 Then
  1760.                 Using B As New LinearGradientBrush(R, Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 270)
  1761.                     FillRoundedPath(G, B, R, 2, False, True, False)
  1762.                 End Using
  1763.             ElseIf i = 0 Then
  1764.                 Using B As New LinearGradientBrush(R, Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 270)
  1765.                     FillRoundedPath(G, B, New Rectangle(R.X, R.Y, R.Width, R.Height), 2, True, False, True, False)
  1766.                 End Using
  1767.             Else
  1768.                 Using B As New LinearGradientBrush(R, Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 270)
  1769.                     G.FillRectangle(B, R)
  1770.                 End Using
  1771.             End If
  1772.         Next
  1773.  
  1774.         For i As Integer = 0 To TabCount - 1
  1775.             Dim R As Rectangle = GetTabRect(i)
  1776.             Rects += R.Width
  1777.             If SelectedIndex = i Then
  1778.                 Using PS As New LinearGradientBrush(R, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270)
  1779.                     If i = TabCount - 1 Then
  1780.                         G.FillPath(PS, RoundRec(New Rectangle(R.X + 1, R.Y, R.Width - 1, R.Height - 1), 2, False, True, False))
  1781.                     ElseIf i = 0 Then
  1782.                         G.FillPath(PS, RoundRec(New Rectangle(R.X, R.Y, R.Width, R.Height), 2, True, False, True, False))
  1783.                     Else
  1784.                         G.FillRectangle(PS, New Rectangle(R.X + 1, R.Y, R.Width - 1, R.Height))
  1785.                     End If
  1786.                 End Using
  1787.  
  1788.                 Using B As New SolidBrush(Color.White)
  1789.                     G.DrawString(TabPages(i).Text, Font, B, R, SetPosition())
  1790.                 End Using
  1791.             Else
  1792.                 Using B As New SolidBrush(Color.FromArgb(168, 168, 168))
  1793.                     G.DrawString(TabPages(i).Text, Font, B, R, SetPosition())
  1794.  
  1795.                 End Using
  1796.             End If
  1797.             Try
  1798.                 Using P As New Pen(Color.FromArgb(22, 22, 22))
  1799.                     G.DrawPath(P, RoundRec(New Rectangle(GetTabRect(0).X, GetTabRect(0).Y, Rects, GetTabRect(TabCount - 1).Height), 1))
  1800.                 End Using
  1801.             Catch
  1802.             End Try
  1803.         Next
  1804.     End Sub
  1805.  
  1806.     #End Region
  1807.  
  1808.     #Region "Events"
  1809.  
  1810.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  1811.         MyBase.OnMouseMove(e)
  1812.         For i As Integer = 0 To TabCount - 1
  1813.             Dim R As Rectangle = GetTabRect(i)
  1814.             If R.Contains(e.Location) Then
  1815.                 Cursor = Cursors.Hand
  1816.                 Invalidate()
  1817.             Else
  1818.                 Cursor = Cursors.Arrow
  1819.                 Invalidate()
  1820.             End If
  1821.         Next
  1822.     End Sub
  1823.  
  1824.     Protected Overrides Sub OnCreateControl()
  1825.         MyBase.OnCreateControl()
  1826.         For Each Tab As TabPage In MyBase.TabPages
  1827.             Tab.BackColor = Color.FromArgb(39, 39, 39)
  1828.         Next
  1829.     End Sub
  1830.  
  1831.     #End Region
  1832.  
  1833. End Class
  1834.  
  1835. #End Region
  1836.  
  1837. #Region "ControlButton"
  1838.  
  1839. Public Class DarkUIControlButton : Inherits Control
  1840.    
  1841.     #Region "Variables"
  1842.  
  1843.     Private State As MouseMode
  1844.     Private _ControlStyle As Style = Style.Close
  1845.  
  1846.     #End Region
  1847.  
  1848.     #Region "Enumenators"
  1849.  
  1850.     Public Enum Style
  1851.         Close
  1852.         Minimize
  1853.         Maximize
  1854.     End Enum
  1855.  
  1856.     #End Region
  1857.  
  1858.     #Region "Constructors"
  1859.  
  1860.     Public Sub New()
  1861.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
  1862.         DoubleBuffered = True
  1863.         BackColor = Color.Transparent
  1864.         UpdateStyles()
  1865.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  1866.         Size = New Size(18, 18)
  1867.     End Sub
  1868.  
  1869.     #End Region
  1870.  
  1871.     #Region "Draw Control"
  1872.  
  1873.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1874.         Dim G As Graphics = e.Graphics
  1875.         If True Then
  1876.  
  1877.             G.SmoothingMode = SmoothingMode.AntiAlias
  1878.  
  1879.             Select Case State
  1880.                 Case MouseMode.Normal
  1881.                     Using PS As New LinearGradientBrush(New Rectangle(1, 1, 15, 15), Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270)
  1882.                         Using PSL As New Pen(Color.FromArgb(22, 22, 22))
  1883.                             G.FillEllipse(PS, New Rectangle(1, 1, 15, 15))
  1884.                             G.DrawEllipse(PSL, New Rectangle(1, 1, 15, 15))
  1885.                         End Using
  1886.                     End Using
  1887.                     Exit Select
  1888.                 Case MouseMode.Hovered
  1889.                     Cursor = Cursors.Hand
  1890.                     Using BG As New LinearGradientBrush(New Rectangle(1, 1, 15, 15), Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 90)
  1891.                         Using PSL As New Pen(Color.FromArgb(22, 22, 22))
  1892.                             G.FillEllipse(BG, New Rectangle(1, 1, 15, 15))
  1893.                             G.DrawEllipse(PSL, New Rectangle(1, 1, 15, 15))
  1894.                         End Using
  1895.                     End Using
  1896.                     Exit Select
  1897.                 Case MouseMode.Pushed
  1898.                     Using PS As New LinearGradientBrush(New Rectangle(1, 1, 15, 15), Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270)
  1899.                         Using PSL As New Pen(Color.FromArgb(22, 22, 22))
  1900.                             G.FillEllipse(PS, New Rectangle(1, 1, 15, 15))
  1901.                             G.DrawEllipse(PSL, New Rectangle(1, 1, 15, 15))
  1902.                         End Using
  1903.                     End Using
  1904.                     Exit Select
  1905.             End Select
  1906.         End If
  1907.     End Sub
  1908.  
  1909.     #End Region
  1910.  
  1911.     #Region "Properties"
  1912.  
  1913.     <Category("Custom"), Description("Gets or sets the type of control button.")>
  1914.     Public Property ControlStyle() As Style
  1915.         Get
  1916.             Return _ControlStyle
  1917.         End Get
  1918.         Set
  1919.             _ControlStyle = value
  1920.             Invalidate()
  1921.         End Set
  1922.     End Property
  1923.  
  1924.     #End Region
  1925.  
  1926.     #Region "Events"
  1927.  
  1928.     Protected Overrides Sub OnClick(e As EventArgs)
  1929.         MyBase.OnClick(e)
  1930.         If ControlStyle = Style.Close Then
  1931.             Environment.[Exit](0)
  1932.             Application.[Exit]()
  1933.         ElseIf ControlStyle = Style.Minimize Then
  1934.             If FindForm().WindowState = FormWindowState.Normal Then
  1935.                 FindForm().WindowState = FormWindowState.Minimized
  1936.             End If
  1937.         ElseIf ControlStyle = Style.Maximize Then
  1938.             If FindForm().WindowState = FormWindowState.Normal Then
  1939.                 FindForm().WindowState = FormWindowState.Maximized
  1940.             ElseIf FindForm().WindowState = FormWindowState.Maximized Then
  1941.                 FindForm().WindowState = FormWindowState.Normal
  1942.             End If
  1943.         End If
  1944.     End Sub
  1945.  
  1946.  
  1947.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1948.  
  1949.         MyBase.OnMouseEnter(e)
  1950.         State = MouseMode.Hovered
  1951.         Invalidate()
  1952.     End Sub
  1953.  
  1954.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1955.  
  1956.         MyBase.OnMouseUp(e)
  1957.         State = MouseMode.Hovered
  1958.         Invalidate()
  1959.     End Sub
  1960.  
  1961.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1962.  
  1963.         MyBase.OnMouseDown(e)
  1964.         State = MouseMode.Pushed
  1965.         Invalidate()
  1966.     End Sub
  1967.  
  1968.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1969.  
  1970.         MyBase.OnMouseLeave(e)
  1971.         State = MouseMode.Normal
  1972.         Invalidate()
  1973.     End Sub
  1974.  
  1975.  
  1976. #End Region
  1977.  
  1978. End Class
  1979.  
  1980. #End Region
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement