THE_LORD

DarkUI Theme

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