Finessed

FLAT UI

Feb 7th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 129.47 KB | None | 0 0
  1. using System;
  2. using System.ComponentModel;
  3. using System.Drawing;
  4. using System.Drawing.Drawing2D;
  5. using System.Drawing.Text;
  6. using System.Windows.Forms;
  7.  
  8. namespace FlatUI
  9. {
  10.     public class FlatAlertBox : Control
  11.     {
  12.         /// <summary>
  13.         /// How to use: FlatAlertBox.ShowControl(Kind, String, Interval)
  14.         /// </summary>
  15.         /// <remarks></remarks>
  16.  
  17.         private int W;
  18.         private int H;
  19.         private _Kind K;
  20.         private string _Text;
  21.         private MouseState State = MouseState.None;
  22.         private int X;
  23.         private Timer withEventsField_T;
  24.         private Timer T
  25.         {
  26.             get { return withEventsField_T; }
  27.             set
  28.             {
  29.                 if (withEventsField_T != null)
  30.                 {
  31.                     withEventsField_T.Tick -= T_Tick;
  32.                 }
  33.                 withEventsField_T = value;
  34.                 if (withEventsField_T != null)
  35.                 {
  36.                     withEventsField_T.Tick += T_Tick;
  37.                 }
  38.             }
  39.  
  40.         }
  41.  
  42.         [Flags()]
  43.         public enum _Kind
  44.         {
  45.             Success,
  46.             Error,
  47.             Info
  48.         }
  49.  
  50.         [Category("Options")]
  51.         public _Kind kind
  52.         {
  53.             get { return K; }
  54.             set { K = value; }
  55.         }
  56.  
  57.         [Category("Options")]
  58.         public override string Text
  59.         {
  60.             get { return base.Text; }
  61.             set
  62.             {
  63.                 base.Text = value;
  64.                 if (_Text != null)
  65.                 {
  66.                     _Text = value;
  67.                 }
  68.             }
  69.         }
  70.  
  71.         [Category("Options")]
  72.         public new bool Visible
  73.         {
  74.             get { return base.Visible == false; }
  75.             set { base.Visible = value; }
  76.         }
  77.  
  78.         protected override void OnTextChanged(EventArgs e)
  79.         {
  80.             base.OnTextChanged(e);
  81.             Invalidate();
  82.         }
  83.  
  84.         protected override void OnResize(EventArgs e)
  85.         {
  86.             base.OnResize(e);
  87.             Height = 42;
  88.         }
  89.  
  90.         public void ShowControl(_Kind Kind, string Str, int Interval)
  91.         {
  92.             K = Kind;
  93.             Text = Str;
  94.             this.Visible = true;
  95.             T = new Timer();
  96.             T.Interval = Interval;
  97.             T.Enabled = true;
  98.         }
  99.  
  100.         private void T_Tick(object sender, EventArgs e)
  101.         {
  102.             this.Visible = false;
  103.             T.Enabled = false;
  104.             T.Dispose();
  105.         }
  106.  
  107.         protected override void OnMouseDown(MouseEventArgs e)
  108.         {
  109.             base.OnMouseDown(e);
  110.             State = MouseState.Down;
  111.             Invalidate();
  112.         }
  113.  
  114.         protected override void OnMouseUp(MouseEventArgs e)
  115.         {
  116.             base.OnMouseUp(e);
  117.             State = MouseState.Over;
  118.             Invalidate();
  119.         }
  120.  
  121.         protected override void OnMouseEnter(EventArgs e)
  122.         {
  123.             base.OnMouseEnter(e);
  124.             State = MouseState.Over;
  125.             Invalidate();
  126.         }
  127.  
  128.         protected override void OnMouseLeave(EventArgs e)
  129.         {
  130.             base.OnMouseLeave(e);
  131.             State = MouseState.None;
  132.             Invalidate();
  133.         }
  134.  
  135.         protected override void OnMouseMove(MouseEventArgs e)
  136.         {
  137.             base.OnMouseMove(e);
  138.             X = e.X;
  139.             Invalidate();
  140.         }
  141.  
  142.         protected override void OnClick(EventArgs e)
  143.         {
  144.             base.OnClick(e);
  145.             this.Visible = false;
  146.         }
  147.  
  148.         private Color SuccessColor = Color.FromArgb(60, 85, 79);
  149.         private Color SuccessText = Color.FromArgb(35, 169, 110);
  150.         private Color ErrorColor = Color.FromArgb(87, 71, 71);
  151.         private Color ErrorText = Color.FromArgb(254, 142, 122);
  152.         private Color InfoColor = Color.FromArgb(70, 91, 94);
  153.         private Color InfoText = Color.FromArgb(97, 185, 186);
  154.  
  155.         public FlatAlertBox()
  156.         {
  157.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  158.             DoubleBuffered = true;
  159.             BackColor = Color.FromArgb(60, 70, 73);
  160.             Size = new Size(576, 42);
  161.             Location = new Point(10, 61);
  162.             Font = new Font("Segoe UI", 10);
  163.             Cursor = Cursors.Hand;
  164.         }
  165.  
  166.         protected override void OnPaint(PaintEventArgs e)
  167.         {
  168.             Bitmap B = new Bitmap(Width, Height);
  169.             Graphics G = Graphics.FromImage(B);
  170.             W = Width - 1;
  171.             H = Height - 1;
  172.  
  173.             Rectangle Base = new Rectangle(0, 0, W, H);
  174.  
  175.             var _with14 = G;
  176.             _with14.SmoothingMode = SmoothingMode.HighQuality;
  177.             _with14.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  178.             _with14.Clear(BackColor);
  179.  
  180.             switch (K)
  181.             {
  182.                 case _Kind.Success:
  183.                     //-- Base
  184.                     _with14.FillRectangle(new SolidBrush(SuccessColor), Base);
  185.  
  186.                     //-- Ellipse
  187.                     _with14.FillEllipse(new SolidBrush(SuccessText), new Rectangle(8, 9, 24, 24));
  188.                     _with14.FillEllipse(new SolidBrush(SuccessColor), new Rectangle(10, 11, 20, 20));
  189.  
  190.                     //-- Checked Sign
  191.                     _with14.DrawString("ΓΌ", new Font("Wingdings", 22), new SolidBrush(SuccessText), new Rectangle(7, 7, W, H), Helpers.NearSF);
  192.                     _with14.DrawString(Text, Font, new SolidBrush(SuccessText), new Rectangle(48, 12, W, H), Helpers.NearSF);
  193.  
  194.                     //-- X button
  195.                     _with14.FillEllipse(new SolidBrush(Color.FromArgb(35, Color.Black)), new Rectangle(W - 30, H - 29, 17, 17));
  196.                     _with14.DrawString("r", new Font("Marlett", 8), new SolidBrush(SuccessColor), new Rectangle(W - 28, 16, W, H), Helpers.NearSF);
  197.  
  198.                     switch (State)
  199.                     {
  200.                         // -- Mouse Over
  201.                         case MouseState.Over:
  202.                             _with14.DrawString("r", new Font("Marlett", 8), new SolidBrush(Color.FromArgb(25, Color.White)), new Rectangle(W - 28, 16, W, H), Helpers.NearSF);
  203.                             break;
  204.                     }
  205.  
  206.                     break;
  207.                 case _Kind.Error:
  208.                     //-- Base
  209.                     _with14.FillRectangle(new SolidBrush(ErrorColor), Base);
  210.  
  211.                     //-- Ellipse
  212.                     _with14.FillEllipse(new SolidBrush(ErrorText), new Rectangle(8, 9, 24, 24));
  213.                     _with14.FillEllipse(new SolidBrush(ErrorColor), new Rectangle(10, 11, 20, 20));
  214.  
  215.                     //-- X Sign
  216.                     _with14.DrawString("r", new Font("Marlett", 16), new SolidBrush(ErrorText), new Rectangle(6, 11, W, H), Helpers.NearSF);
  217.                     _with14.DrawString(Text, Font, new SolidBrush(ErrorText), new Rectangle(48, 12, W, H), Helpers.NearSF);
  218.  
  219.                     //-- X button
  220.                     _with14.FillEllipse(new SolidBrush(Color.FromArgb(35, Color.Black)), new Rectangle(W - 32, H - 29, 17, 17));
  221.                     _with14.DrawString("r", new Font("Marlett", 8), new SolidBrush(ErrorColor), new Rectangle(W - 30, 17, W, H), Helpers.NearSF);
  222.  
  223.                     switch (State)
  224.                     {
  225.                         case MouseState.Over:
  226.                             // -- Mouse Over
  227.                             _with14.DrawString("r", new Font("Marlett", 8), new SolidBrush(Color.FromArgb(25, Color.White)), new Rectangle(W - 30, 15, W, H), Helpers.NearSF);
  228.                             break;
  229.                     }
  230.  
  231.                     break;
  232.                 case _Kind.Info:
  233.                     //-- Base
  234.                     _with14.FillRectangle(new SolidBrush(InfoColor), Base);
  235.  
  236.                     //-- Ellipse
  237.                     _with14.FillEllipse(new SolidBrush(InfoText), new Rectangle(8, 9, 24, 24));
  238.                     _with14.FillEllipse(new SolidBrush(InfoColor), new Rectangle(10, 11, 20, 20));
  239.  
  240.                     //-- Info Sign
  241.                     _with14.DrawString("Β‘", new Font("Segoe UI", 20, FontStyle.Bold), new SolidBrush(InfoText), new Rectangle(12, -4, W, H), Helpers.NearSF);
  242.                     _with14.DrawString(Text, Font, new SolidBrush(InfoText), new Rectangle(48, 12, W, H), Helpers.NearSF);
  243.  
  244.                     //-- X button
  245.                     _with14.FillEllipse(new SolidBrush(Color.FromArgb(35, Color.Black)), new Rectangle(W - 32, H - 29, 17, 17));
  246.                     _with14.DrawString("r", new Font("Marlett", 8), new SolidBrush(InfoColor), new Rectangle(W - 30, 17, W, H), Helpers.NearSF);
  247.  
  248.                     switch (State)
  249.                     {
  250.                         case MouseState.Over:
  251.                             // -- Mouse Over
  252.                             _with14.DrawString("r", new Font("Marlett", 8), new SolidBrush(Color.FromArgb(25, Color.White)), new Rectangle(W - 30, 17, W, H), Helpers.NearSF);
  253.                             break;
  254.                     }
  255.                     break;
  256.             }
  257.  
  258.             base.OnPaint(e);
  259.             G.Dispose();
  260.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  261.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  262.             B.Dispose();
  263.         }
  264.     }
  265. }
  266. namespace FlatUI
  267. {
  268.     public class FlatButton : Control
  269.     {
  270.         private int W;
  271.         private int H;
  272.         private bool _Rounded = false;
  273.         private MouseState State = MouseState.None;
  274.  
  275.         [Category("Colors")]
  276.         public Color BaseColor
  277.         {
  278.             get { return _BaseColor; }
  279.             set { _BaseColor = value; }
  280.         }
  281.  
  282.         [Category("Colors")]
  283.         public Color TextColor
  284.         {
  285.             get { return _TextColor; }
  286.             set { _TextColor = value; }
  287.         }
  288.  
  289.         [Category("Options")]
  290.         public bool Rounded
  291.         {
  292.             get { return _Rounded; }
  293.             set { _Rounded = value; }
  294.         }
  295.  
  296.         protected override void OnMouseDown(MouseEventArgs e)
  297.         {
  298.             base.OnMouseDown(e);
  299.             State = MouseState.Down;
  300.             Invalidate();
  301.         }
  302.  
  303.         protected override void OnMouseUp(MouseEventArgs e)
  304.         {
  305.             base.OnMouseUp(e);
  306.             State = MouseState.Over;
  307.             Invalidate();
  308.         }
  309.  
  310.         protected override void OnMouseEnter(EventArgs e)
  311.         {
  312.             base.OnMouseEnter(e);
  313.             State = MouseState.Over;
  314.             Invalidate();
  315.         }
  316.  
  317.         protected override void OnMouseLeave(EventArgs e)
  318.         {
  319.             base.OnMouseLeave(e);
  320.             State = MouseState.None;
  321.             Invalidate();
  322.         }
  323.  
  324.         private Color _BaseColor = Helpers.FlatColor;
  325.         private Color _TextColor = Color.FromArgb(243, 243, 243);
  326.  
  327.         public FlatButton()
  328.         {
  329.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  330.             DoubleBuffered = true;
  331.             Size = new Size(106, 32);
  332.             BackColor = Color.Transparent;
  333.             Font = new Font("Segoe UI", 12);
  334.             Cursor = Cursors.Hand;
  335.         }
  336.  
  337.         protected override void OnPaint(PaintEventArgs e)
  338.         {
  339.             this.UpdateColors();
  340.  
  341.             Bitmap B = new Bitmap(Width, Height);
  342.             Graphics G = Graphics.FromImage(B);
  343.             W = Width - 1;
  344.             H = Height - 1;
  345.  
  346.             GraphicsPath GP = new GraphicsPath();
  347.             Rectangle Base = new Rectangle(0, 0, W, H);
  348.  
  349.             var _with8 = G;
  350.             _with8.SmoothingMode = SmoothingMode.HighQuality;
  351.             _with8.PixelOffsetMode = PixelOffsetMode.HighQuality;
  352.             _with8.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  353.             _with8.Clear(BackColor);
  354.  
  355.             switch (State)
  356.             {
  357.                 case MouseState.None:
  358.                     if (Rounded)
  359.                     {
  360.                         //-- Base
  361.                         GP = Helpers.RoundRec(Base, 6);
  362.                         _with8.FillPath(new SolidBrush(_BaseColor), GP);
  363.  
  364.                         //-- Text
  365.                         _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  366.                     }
  367.                     else
  368.                     {
  369.                         //-- Base
  370.                         _with8.FillRectangle(new SolidBrush(_BaseColor), Base);
  371.  
  372.                         //-- Text
  373.                         _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  374.                     }
  375.                     break;
  376.                 case MouseState.Over:
  377.                     if (Rounded)
  378.                     {
  379.                         //-- Base
  380.                         GP = Helpers.RoundRec(Base, 6);
  381.                         _with8.FillPath(new SolidBrush(_BaseColor), GP);
  382.                         _with8.FillPath(new SolidBrush(Color.FromArgb(20, Color.White)), GP);
  383.  
  384.                         //-- Text
  385.                         _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  386.                     }
  387.                     else
  388.                     {
  389.                         //-- Base
  390.                         _with8.FillRectangle(new SolidBrush(_BaseColor), Base);
  391.                         _with8.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.White)), Base);
  392.  
  393.                         //-- Text
  394.                         _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  395.                     }
  396.                     break;
  397.                 case MouseState.Down:
  398.                     if (Rounded)
  399.                     {
  400.                         //-- Base
  401.                         GP = Helpers.RoundRec(Base, 6);
  402.                         _with8.FillPath(new SolidBrush(_BaseColor), GP);
  403.                         _with8.FillPath(new SolidBrush(Color.FromArgb(20, Color.Black)), GP);
  404.  
  405.                         //-- Text
  406.                         _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  407.                     }
  408.                     else
  409.                     {
  410.                         //-- Base
  411.                         _with8.FillRectangle(new SolidBrush(_BaseColor), Base);
  412.                         _with8.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.Black)), Base);
  413.  
  414.                         //-- Text
  415.                         _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  416.                     }
  417.                     break;
  418.             }
  419.  
  420.             base.OnPaint(e);
  421.             G.Dispose();
  422.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  423.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  424.             B.Dispose();
  425.         }
  426.  
  427.         private void UpdateColors()
  428.         {
  429.             FlatColors colors = Helpers.GetColors(this);
  430.  
  431.             _BaseColor = colors.Flat;
  432.         }
  433.     }
  434. }
  435. namespace FlatUI
  436. {
  437.     [DefaultEvent("CheckedChanged")]
  438.     public class FlatCheckBox : Control
  439.     {
  440.         private int W;
  441.         private int H;
  442.         private MouseState State = MouseState.None;
  443.         private _Options O;
  444.         private bool _Checked;
  445.  
  446.         protected override void OnTextChanged(System.EventArgs e)
  447.         {
  448.             base.OnTextChanged(e);
  449.             Invalidate();
  450.         }
  451.  
  452.         public bool Checked
  453.         {
  454.             get { return _Checked; }
  455.             set
  456.             {
  457.                 _Checked = value;
  458.                 Invalidate();
  459.             }
  460.         }
  461.  
  462.         public event CheckedChangedEventHandler CheckedChanged;
  463.         public delegate void CheckedChangedEventHandler(object sender);
  464.         protected override void OnClick(System.EventArgs e)
  465.         {
  466.             _Checked = !_Checked;
  467.             if (CheckedChanged != null)
  468.             {
  469.                 CheckedChanged(this);
  470.             }
  471.             base.OnClick(e);
  472.         }
  473.  
  474.         [Flags()]
  475.         public enum _Options
  476.         {
  477.             Style1,
  478.             Style2
  479.         }
  480.  
  481.         [Category("Options")]
  482.         public _Options Options
  483.         {
  484.             get { return O; }
  485.             set { O = value; }
  486.         }
  487.  
  488.         protected override void OnResize(EventArgs e)
  489.         {
  490.             base.OnResize(e);
  491.             Height = 22;
  492.         }
  493.  
  494.         [Category("Colors")]
  495.         public Color BaseColor
  496.         {
  497.             get { return _BaseColor; }
  498.             set { _BaseColor = value; }
  499.         }
  500.  
  501.         [Category("Colors")]
  502.         public Color BorderColor
  503.         {
  504.             get { return _BorderColor; }
  505.             set { _BorderColor = value; }
  506.         }
  507.  
  508.         protected override void OnMouseDown(MouseEventArgs e)
  509.         {
  510.             base.OnMouseDown(e);
  511.             State = MouseState.Down;
  512.             Invalidate();
  513.         }
  514.  
  515.         protected override void OnMouseUp(MouseEventArgs e)
  516.         {
  517.             base.OnMouseUp(e);
  518.             State = MouseState.Over;
  519.             Invalidate();
  520.         }
  521.  
  522.         protected override void OnMouseEnter(EventArgs e)
  523.         {
  524.             base.OnMouseEnter(e);
  525.             State = MouseState.Over;
  526.             Invalidate();
  527.         }
  528.  
  529.         protected override void OnMouseLeave(EventArgs e)
  530.         {
  531.             base.OnMouseLeave(e);
  532.             State = MouseState.None;
  533.             Invalidate();
  534.         }
  535.  
  536.         private Color _BaseColor = Color.FromArgb(45, 47, 49);
  537.         private Color _TextColor = Color.FromArgb(243, 243, 243);
  538.         private Color _BorderColor = Helpers.FlatColor;
  539.  
  540.         public FlatCheckBox()
  541.         {
  542.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  543.             DoubleBuffered = true;
  544.             BackColor = Color.FromArgb(60, 70, 73);
  545.             Cursor = Cursors.Hand;
  546.             Font = new Font("Segoe UI", 10);
  547.             Size = new Size(112, 22);
  548.         }
  549.  
  550.         protected override void OnPaint(PaintEventArgs e)
  551.         {
  552.             this.UpdateColors();
  553.  
  554.             Bitmap B = new Bitmap(Width, Height);
  555.             Graphics G = Graphics.FromImage(B);
  556.             W = Width - 1;
  557.             H = Height - 1;
  558.  
  559.             Rectangle Base = new Rectangle(0, 2, Height - 5, Height - 5);
  560.  
  561.             var _with11 = G;
  562.             _with11.SmoothingMode = SmoothingMode.HighQuality;
  563.             _with11.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  564.             _with11.Clear(BackColor);
  565.             switch (O)
  566.             {
  567.                 case _Options.Style1:
  568.                     //-- Style 1
  569.                     //-- Base
  570.                     _with11.FillRectangle(new SolidBrush(_BaseColor), Base);
  571.  
  572.                     switch (State)
  573.                     {
  574.                         case MouseState.Over:
  575.                             //-- Base
  576.                             _with11.DrawRectangle(new Pen(_BorderColor), Base);
  577.                             break;
  578.                         case MouseState.Down:
  579.                             //-- Base
  580.                             _with11.DrawRectangle(new Pen(_BorderColor), Base);
  581.                             break;
  582.                     }
  583.  
  584.                     //-- If Checked
  585.                     if (Checked)
  586.                     {
  587.                         _with11.DrawString("ΓΌ", new Font("Wingdings", 18), new SolidBrush(_BorderColor), new Rectangle(5, 7, H - 9, H - 9), Helpers.CenterSF);
  588.                     }
  589.  
  590.                     //-- If Enabled
  591.                     if (this.Enabled == false)
  592.                     {
  593.                         _with11.FillRectangle(new SolidBrush(Color.FromArgb(54, 58, 61)), Base);
  594.                         _with11.DrawString(Text, Font, new SolidBrush(Color.FromArgb(140, 142, 143)), new Rectangle(20, 2, W, H), Helpers.NearSF);
  595.                     }
  596.  
  597.                     //-- Text
  598.                     _with11.DrawString(Text, Font, new SolidBrush(_TextColor), new Rectangle(20, 2, W, H), Helpers.NearSF);
  599.                     break;
  600.                 case _Options.Style2:
  601.                     //-- Style 2
  602.                     //-- Base
  603.                     _with11.FillRectangle(new SolidBrush(_BaseColor), Base);
  604.  
  605.                     switch (State)
  606.                     {
  607.                         case MouseState.Over:
  608.                             //-- Base
  609.                             _with11.DrawRectangle(new Pen(_BorderColor), Base);
  610.                             _with11.FillRectangle(new SolidBrush(Color.FromArgb(118, 213, 170)), Base);
  611.                             break;
  612.                         case MouseState.Down:
  613.                             //-- Base
  614.                             _with11.DrawRectangle(new Pen(_BorderColor), Base);
  615.                             _with11.FillRectangle(new SolidBrush(Color.FromArgb(118, 213, 170)), Base);
  616.                             break;
  617.                     }
  618.  
  619.                     //-- If Checked
  620.                     if (Checked)
  621.                     {
  622.                         _with11.DrawString("ΓΌ", new Font("Wingdings", 18), new SolidBrush(_BorderColor), new Rectangle(5, 7, H - 9, H - 9), Helpers.CenterSF);
  623.                     }
  624.  
  625.                     //-- If Enabled
  626.                     if (this.Enabled == false)
  627.                     {
  628.                         _with11.FillRectangle(new SolidBrush(Color.FromArgb(54, 58, 61)), Base);
  629.                         _with11.DrawString(Text, Font, new SolidBrush(Color.FromArgb(48, 119, 91)), new Rectangle(20, 2, W, H), Helpers.NearSF);
  630.                     }
  631.  
  632.                     //-- Text
  633.                     _with11.DrawString(Text, Font, new SolidBrush(_TextColor), new Rectangle(20, 2, W, H), Helpers.NearSF);
  634.                     break;
  635.             }
  636.  
  637.             base.OnPaint(e);
  638.             G.Dispose();
  639.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  640.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  641.             B.Dispose();
  642.         }
  643.  
  644.         private void UpdateColors()
  645.         {
  646.             FlatColors colors = Helpers.GetColors(this);
  647.  
  648.             _BorderColor = colors.Flat;
  649.         }
  650.     }
  651. }
  652. namespace FlatUI
  653. {
  654.     public class FlatClose : Control
  655.     {
  656.         private MouseState State = MouseState.None;
  657.         private int x;
  658.  
  659.         protected override void OnMouseEnter(EventArgs e)
  660.         {
  661.             base.OnMouseEnter(e);
  662.             State = MouseState.Over;
  663.             Invalidate();
  664.         }
  665.  
  666.         protected override void OnMouseDown(MouseEventArgs e)
  667.         {
  668.             base.OnMouseDown(e);
  669.             State = MouseState.Down;
  670.             Invalidate();
  671.         }
  672.  
  673.         protected override void OnMouseLeave(EventArgs e)
  674.         {
  675.             base.OnMouseLeave(e);
  676.             State = MouseState.None;
  677.             Invalidate();
  678.         }
  679.  
  680.         protected override void OnMouseUp(MouseEventArgs e)
  681.         {
  682.             base.OnMouseUp(e);
  683.             State = MouseState.Over;
  684.             Invalidate();
  685.         }
  686.  
  687.         protected override void OnMouseMove(MouseEventArgs e)
  688.         {
  689.             base.OnMouseMove(e);
  690.             x = e.X;
  691.             Invalidate();
  692.         }
  693.  
  694.         protected override void OnClick(EventArgs e)
  695.         {
  696.             base.OnClick(e);
  697.             Environment.Exit(0);
  698.         }
  699.  
  700.         protected override void OnResize(EventArgs e)
  701.         {
  702.             base.OnResize(e);
  703.             Size = new Size(18, 18);
  704.         }
  705.  
  706.         [Category("Colors")]
  707.         public Color BaseColor
  708.         {
  709.             get { return _BaseColor; }
  710.             set { _BaseColor = value; }
  711.         }
  712.  
  713.         [Category("Colors")]
  714.         public Color TextColor
  715.         {
  716.             get { return _TextColor; }
  717.             set { _TextColor = value; }
  718.         }
  719.  
  720.         private Color _BaseColor = Color.FromArgb(168, 35, 35);
  721.         private Color _TextColor = Color.FromArgb(243, 243, 243);
  722.  
  723.         public FlatClose()
  724.         {
  725.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  726.             DoubleBuffered = true;
  727.             BackColor = Color.White;
  728.             Size = new Size(18, 18);
  729.             Anchor = AnchorStyles.Top | AnchorStyles.Right;
  730.             Font = new Font("Marlett", 10);
  731.         }
  732.  
  733.         protected override void OnPaint(PaintEventArgs e)
  734.         {
  735.             Bitmap B = new Bitmap(Width, Height);
  736.             Graphics G = Graphics.FromImage(B);
  737.  
  738.             Rectangle Base = new Rectangle(0, 0, Width, Height);
  739.  
  740.             var _with3 = G;
  741.             _with3.SmoothingMode = SmoothingMode.HighQuality;
  742.             _with3.PixelOffsetMode = PixelOffsetMode.HighQuality;
  743.             _with3.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  744.             _with3.Clear(BackColor);
  745.  
  746.             //-- Base
  747.             _with3.FillRectangle(new SolidBrush(_BaseColor), Base);
  748.  
  749.             //-- X
  750.             _with3.DrawString("r", Font, new SolidBrush(TextColor), new Rectangle(0, 0, Width, Height), Helpers.CenterSF);
  751.  
  752.             //-- Hover/down
  753.             switch (State)
  754.             {
  755.                 case MouseState.Over:
  756.                     _with3.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.White)), Base);
  757.                     break;
  758.                 case MouseState.Down:
  759.                     _with3.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.Black)), Base);
  760.                     break;
  761.             }
  762.  
  763.             base.OnPaint(e);
  764.             G.Dispose();
  765.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  766.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  767.             B.Dispose();
  768.         }
  769.     }
  770. }
  771. namespace FlatUI
  772. {
  773.     public class FlatColorPalette : Control
  774.     {
  775.         private int W;
  776.         private int H;
  777.  
  778.         protected override void OnResize(EventArgs e)
  779.         {
  780.             base.OnResize(e);
  781.             Width = 180;
  782.             Height = 80;
  783.         }
  784.  
  785.         [Category("Colors")]
  786.         public Color Red
  787.         {
  788.             get { return _Red; }
  789.             set { _Red = value; }
  790.         }
  791.  
  792.         [Category("Colors")]
  793.         public Color Cyan
  794.         {
  795.             get { return _Cyan; }
  796.             set { _Cyan = value; }
  797.         }
  798.  
  799.         [Category("Colors")]
  800.         public Color Blue
  801.         {
  802.             get { return _Blue; }
  803.             set { _Blue = value; }
  804.         }
  805.  
  806.         [Category("Colors")]
  807.         public Color LimeGreen
  808.         {
  809.             get { return _LimeGreen; }
  810.             set { _LimeGreen = value; }
  811.         }
  812.  
  813.         [Category("Colors")]
  814.         public Color Orange
  815.         {
  816.             get { return _Orange; }
  817.             set { _Orange = value; }
  818.         }
  819.  
  820.         [Category("Colors")]
  821.         public Color Purple
  822.         {
  823.             get { return _Purple; }
  824.             set { _Purple = value; }
  825.         }
  826.  
  827.         [Category("Colors")]
  828.         public Color Black
  829.         {
  830.             get { return _Black; }
  831.             set { _Black = value; }
  832.         }
  833.  
  834.         [Category("Colors")]
  835.         public Color Gray
  836.         {
  837.             get { return _Gray; }
  838.             set { _Gray = value; }
  839.         }
  840.  
  841.         [Category("Colors")]
  842.         public Color White
  843.         {
  844.             get { return _White; }
  845.             set { _White = value; }
  846.         }
  847.  
  848.         private Color _Red = Color.FromArgb(220, 85, 96);
  849.         private Color _Cyan = Color.FromArgb(10, 154, 157);
  850.         private Color _Blue = Color.FromArgb(0, 128, 255);
  851.         private Color _LimeGreen = Color.FromArgb(35, 168, 109);
  852.         private Color _Orange = Color.FromArgb(253, 181, 63);
  853.         private Color _Purple = Color.FromArgb(155, 88, 181);
  854.         private Color _Black = Color.FromArgb(45, 47, 49);
  855.         private Color _Gray = Color.FromArgb(63, 70, 73);
  856.         private Color _White = Color.FromArgb(243, 243, 243);
  857.  
  858.         public FlatColorPalette()
  859.         {
  860.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  861.             DoubleBuffered = true;
  862.             BackColor = Color.FromArgb(60, 70, 73);
  863.             Size = new Size(160, 80);
  864.             Font = new Font("Segoe UI", 12);
  865.         }
  866.  
  867.         protected override void OnPaint(PaintEventArgs e)
  868.         {
  869.             Bitmap B = new Bitmap(Width, Height);
  870.             Graphics G = Graphics.FromImage(B);
  871.             W = Width - 1;
  872.             H = Height - 1;
  873.  
  874.             var _with6 = G;
  875.             _with6.SmoothingMode = SmoothingMode.HighQuality;
  876.             _with6.PixelOffsetMode = PixelOffsetMode.HighQuality;
  877.             _with6.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  878.             _with6.Clear(BackColor);
  879.  
  880.             //-- Colors
  881.             _with6.FillRectangle(new SolidBrush(_Red), new Rectangle(0, 0, 20, 40));
  882.             _with6.FillRectangle(new SolidBrush(_Cyan), new Rectangle(20, 0, 20, 40));
  883.             _with6.FillRectangle(new SolidBrush(_Blue), new Rectangle(40, 0, 20, 40));
  884.             _with6.FillRectangle(new SolidBrush(_LimeGreen), new Rectangle(60, 0, 20, 40));
  885.             _with6.FillRectangle(new SolidBrush(_Orange), new Rectangle(80, 0, 20, 40));
  886.             _with6.FillRectangle(new SolidBrush(_Purple), new Rectangle(100, 0, 20, 40));
  887.             _with6.FillRectangle(new SolidBrush(_Black), new Rectangle(120, 0, 20, 40));
  888.             _with6.FillRectangle(new SolidBrush(_Gray), new Rectangle(140, 0, 20, 40));
  889.             _with6.FillRectangle(new SolidBrush(_White), new Rectangle(160, 0, 20, 40));
  890.  
  891.             //-- Text
  892.             _with6.DrawString("Color Palette", Font, new SolidBrush(_White), new Rectangle(0, 22, W, H), Helpers.CenterSF);
  893.  
  894.             base.OnPaint(e);
  895.             G.Dispose();
  896.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  897.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  898.             B.Dispose();
  899.         }
  900.     }
  901. }
  902. namespace FlatUI
  903. {
  904.     public class FlatColors
  905.     {
  906.         public Color Flat = Helpers.FlatColor;
  907.     }
  908. }
  909. namespace FlatUI
  910. {
  911.     public class FlatComboBox : ComboBox
  912.     {
  913.         private int W;
  914.         private int H;
  915.         private int _StartIndex = 0;
  916.         private int x;
  917.         private int y;
  918.  
  919.         private MouseState State = MouseState.None;
  920.         protected override void OnMouseDown(MouseEventArgs e)
  921.         {
  922.             base.OnMouseDown(e);
  923.             State = MouseState.Down;
  924.             Invalidate();
  925.         }
  926.  
  927.         protected override void OnMouseUp(MouseEventArgs e)
  928.         {
  929.             base.OnMouseUp(e);
  930.             State = MouseState.Over;
  931.             Invalidate();
  932.         }
  933.  
  934.         protected override void OnMouseEnter(EventArgs e)
  935.         {
  936.             base.OnMouseEnter(e);
  937.             State = MouseState.Over;
  938.             Invalidate();
  939.         }
  940.  
  941.         protected override void OnMouseLeave(EventArgs e)
  942.         {
  943.             base.OnMouseLeave(e);
  944.             State = MouseState.None;
  945.             Invalidate();
  946.         }
  947.  
  948.         protected override void OnMouseMove(MouseEventArgs e)
  949.         {
  950.             base.OnMouseMove(e);
  951.             x = e.Location.X;
  952.             y = e.Location.Y;
  953.             Invalidate();
  954.             if (e.X < Width - 41)
  955.                 Cursor = Cursors.IBeam;
  956.             else
  957.                 Cursor = Cursors.Hand;
  958.         }
  959.  
  960.         protected override void OnDrawItem(DrawItemEventArgs e)
  961.         {
  962.             base.OnDrawItem(e);
  963.             Invalidate();
  964.             if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  965.             {
  966.                 Invalidate();
  967.             }
  968.         }
  969.  
  970.         protected override void OnClick(EventArgs e)
  971.         {
  972.             base.OnClick(e);
  973.             Invalidate();
  974.         }
  975.  
  976.         [Category("Colors")]
  977.         public Color HoverColor
  978.         {
  979.             get { return _HoverColor; }
  980.             set { _HoverColor = value; }
  981.         }
  982.  
  983.         private int StartIndex
  984.         {
  985.             get { return _StartIndex; }
  986.             set
  987.             {
  988.                 _StartIndex = value;
  989.                 try
  990.                 {
  991.                     base.SelectedIndex = value;
  992.                 }
  993.                 catch
  994.                 {
  995.                 }
  996.                 Invalidate();
  997.             }
  998.         }
  999.  
  1000.         public void DrawItem_(System.Object sender, System.Windows.Forms.DrawItemEventArgs e)
  1001.         {
  1002.             if (e.Index < 0)
  1003.                 return;
  1004.             e.DrawBackground();
  1005.             e.DrawFocusRectangle();
  1006.  
  1007.             e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
  1008.             e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
  1009.             e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1010.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  1011.  
  1012.             if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  1013.             {
  1014.                 //-- Selected item
  1015.                 e.Graphics.FillRectangle(new SolidBrush(_HoverColor), e.Bounds);
  1016.             }
  1017.             else
  1018.             {
  1019.                 //-- Not Selected
  1020.                 e.Graphics.FillRectangle(new SolidBrush(_BaseColor), e.Bounds);
  1021.             }
  1022.  
  1023.             //-- Text
  1024.             e.Graphics.DrawString(base.GetItemText(base.Items[e.Index]), new Font("Segoe UI", 8), Brushes.White, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height));
  1025.  
  1026.  
  1027.             e.Graphics.Dispose();
  1028.         }
  1029.  
  1030.         protected override void OnResize(EventArgs e)
  1031.         {
  1032.             base.OnResize(e);
  1033.             Height = 18;
  1034.         }
  1035.  
  1036.         private Color _BaseColor = Color.FromArgb(25, 27, 29);
  1037.         private Color _BGColor = Color.FromArgb(45, 47, 49);
  1038.         private Color _HoverColor = Color.FromArgb(35, 168, 109);
  1039.  
  1040.         public FlatComboBox()
  1041.         {
  1042.             DrawItem += DrawItem_;
  1043.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  1044.             DoubleBuffered = true;
  1045.  
  1046.             DrawMode = DrawMode.OwnerDrawFixed;
  1047.             BackColor = Color.FromArgb(45, 45, 48);
  1048.             ForeColor = Color.White;
  1049.             DropDownStyle = ComboBoxStyle.DropDownList;
  1050.             Cursor = Cursors.Hand;
  1051.             StartIndex = 0;
  1052.             ItemHeight = 18;
  1053.             Font = new Font("Segoe UI", 8, FontStyle.Regular);
  1054.         }
  1055.  
  1056.         protected override void OnPaint(PaintEventArgs e)
  1057.         {
  1058.             Bitmap B = new Bitmap(Width, Height);
  1059.             Graphics G = Graphics.FromImage(B);
  1060.             W = Width;
  1061.             H = Height;
  1062.  
  1063.             Rectangle Base = new Rectangle(0, 0, W, H);
  1064.             Rectangle Button = new Rectangle(Convert.ToInt32(W - 40), 0, W, H);
  1065.             GraphicsPath GP = new GraphicsPath();
  1066.             GraphicsPath GP2 = new GraphicsPath();
  1067.  
  1068.             var _with16 = G;
  1069.             _with16.Clear(Color.FromArgb(45, 45, 48));
  1070.             _with16.SmoothingMode = SmoothingMode.HighQuality;
  1071.             _with16.PixelOffsetMode = PixelOffsetMode.HighQuality;
  1072.             _with16.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1073.  
  1074.             //-- Base
  1075.             _with16.FillRectangle(new SolidBrush(_BGColor), Base);
  1076.  
  1077.             //-- Button
  1078.             GP.Reset();
  1079.             GP.AddRectangle(Button);
  1080.             _with16.SetClip(GP);
  1081.             _with16.FillRectangle(new SolidBrush(_BaseColor), Button);
  1082.             _with16.ResetClip();
  1083.  
  1084.             //-- Lines
  1085.             _with16.DrawLine(Pens.White, W - 10, 6, W - 30, 6);
  1086.             _with16.DrawLine(Pens.White, W - 10, 12, W - 30, 12);
  1087.             _with16.DrawLine(Pens.White, W - 10, 18, W - 30, 18);
  1088.  
  1089.             //-- Text
  1090.             _with16.DrawString(Text, Font, Brushes.White, new Point(4, 6), Helpers.NearSF);
  1091.  
  1092.             G.Dispose();
  1093.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  1094.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  1095.             B.Dispose();
  1096.         }
  1097.     }
  1098. }
  1099. namespace FlatUI
  1100. {
  1101.     public class FlatContextMenuStrip : ContextMenuStrip
  1102.     {
  1103.         protected override void OnTextChanged(EventArgs e)
  1104.         {
  1105.             base.OnTextChanged(e);
  1106.             Invalidate();
  1107.         }
  1108.  
  1109.         public FlatContextMenuStrip()
  1110.             : base()
  1111.         {
  1112.             Renderer = new ToolStripProfessionalRenderer(new TColorTable());
  1113.             ShowImageMargin = false;
  1114.             ForeColor = Color.White;
  1115.             Font = new Font("Segoe UI", 8);
  1116.         }
  1117.  
  1118.         protected override void OnPaint(PaintEventArgs e)
  1119.         {
  1120.             base.OnPaint(e);
  1121.             e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1122.         }
  1123.  
  1124.         public class TColorTable : ProfessionalColorTable
  1125.         {
  1126.             [Category("Colors")]
  1127.             public Color _BackColor
  1128.             {
  1129.                 get { return BackColor; }
  1130.                 set { BackColor = value; }
  1131.             }
  1132.  
  1133.             [Category("Colors")]
  1134.             public Color _CheckedColor
  1135.             {
  1136.                 get { return CheckedColor; }
  1137.                 set { CheckedColor = value; }
  1138.             }
  1139.  
  1140.             [Category("Colors")]
  1141.             public Color _BorderColor
  1142.             {
  1143.                 get { return BorderColor; }
  1144.                 set { BorderColor = value; }
  1145.             }
  1146.  
  1147.             private Color BackColor = Color.FromArgb(45, 47, 49);
  1148.             private Color CheckedColor = Helpers.FlatColor;
  1149.             private Color BorderColor = Color.FromArgb(53, 58, 60);
  1150.  
  1151.             public override Color ButtonSelectedBorder
  1152.             {
  1153.                 get { return BackColor; }
  1154.             }
  1155.  
  1156.             public override Color CheckBackground
  1157.             {
  1158.                 get { return CheckedColor; }
  1159.             }
  1160.  
  1161.             public override Color CheckPressedBackground
  1162.             {
  1163.                 get { return CheckedColor; }
  1164.             }
  1165.  
  1166.             public override Color CheckSelectedBackground
  1167.             {
  1168.                 get { return CheckedColor; }
  1169.             }
  1170.  
  1171.             public override Color ImageMarginGradientBegin
  1172.             {
  1173.                 get { return CheckedColor; }
  1174.             }
  1175.  
  1176.             public override Color ImageMarginGradientEnd
  1177.             {
  1178.                 get { return CheckedColor; }
  1179.             }
  1180.  
  1181.             public override Color ImageMarginGradientMiddle
  1182.             {
  1183.                 get { return CheckedColor; }
  1184.             }
  1185.  
  1186.             public override Color MenuBorder
  1187.             {
  1188.                 get { return BorderColor; }
  1189.             }
  1190.  
  1191.             public override Color MenuItemBorder
  1192.             {
  1193.                 get { return BorderColor; }
  1194.             }
  1195.  
  1196.             public override Color MenuItemSelected
  1197.             {
  1198.                 get { return CheckedColor; }
  1199.             }
  1200.  
  1201.             public override Color SeparatorDark
  1202.             {
  1203.                 get { return BorderColor; }
  1204.             }
  1205.  
  1206.             public override Color ToolStripDropDownBackground
  1207.             {
  1208.                 get { return BackColor; }
  1209.             }
  1210.         }
  1211.     }
  1212. }
  1213. namespace FlatUI
  1214. {
  1215.     public class FlatGroupBox : ContainerControl
  1216.     {
  1217.         private int W;
  1218.         private int H;
  1219.         private bool _ShowText = true;
  1220.  
  1221.         [Category("Colors")]
  1222.         public Color BaseColor
  1223.         {
  1224.             get { return _BaseColor; }
  1225.             set { _BaseColor = value; }
  1226.         }
  1227.  
  1228.         public bool ShowText
  1229.         {
  1230.             get { return _ShowText; }
  1231.             set { _ShowText = value; }
  1232.         }
  1233.  
  1234.         private Color _BaseColor = Color.FromArgb(60, 70, 73);
  1235.         private Color _TextColor = Helpers.FlatColor;
  1236.  
  1237.         public FlatGroupBox()
  1238.         {
  1239.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  1240.             DoubleBuffered = true;
  1241.             BackColor = Color.Transparent;
  1242.             Size = new Size(240, 180);
  1243.             Font = new Font("Segoe ui", 10);
  1244.         }
  1245.  
  1246.         protected override void OnPaint(PaintEventArgs e)
  1247.         {
  1248.             this.UpdateColors();
  1249.  
  1250.             Bitmap B = new Bitmap(Width, Height);
  1251.             Graphics G = Graphics.FromImage(B);
  1252.             W = Width - 1;
  1253.             H = Height - 1;
  1254.  
  1255.             GraphicsPath GP = new GraphicsPath();
  1256.             GraphicsPath GP2 = new GraphicsPath();
  1257.             GraphicsPath GP3 = new GraphicsPath();
  1258.             Rectangle Base = new Rectangle(8, 8, W - 16, H - 16);
  1259.  
  1260.             var _with7 = G;
  1261.             _with7.SmoothingMode = SmoothingMode.HighQuality;
  1262.             _with7.PixelOffsetMode = PixelOffsetMode.HighQuality;
  1263.             _with7.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1264.             _with7.Clear(BackColor);
  1265.  
  1266.             //-- Base
  1267.             GP = Helpers.RoundRec(Base, 8);
  1268.             _with7.FillPath(new SolidBrush(_BaseColor), GP);
  1269.  
  1270.             //-- Arrows
  1271.             GP2 = Helpers.DrawArrow(28, 2, false);
  1272.             _with7.FillPath(new SolidBrush(_BaseColor), GP2);
  1273.             GP3 = Helpers.DrawArrow(28, 8, true);
  1274.             _with7.FillPath(new SolidBrush(Color.FromArgb(60, 70, 73)), GP3);
  1275.  
  1276.             //-- if ShowText
  1277.             if (ShowText)
  1278.             {
  1279.                 _with7.DrawString(Text, Font, new SolidBrush(_TextColor), new Rectangle(16, 16, W, H), Helpers.NearSF);
  1280.             }
  1281.  
  1282.             base.OnPaint(e);
  1283.             G.Dispose();
  1284.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  1285.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  1286.             B.Dispose();
  1287.         }
  1288.  
  1289.         private void UpdateColors()
  1290.         {
  1291.             FlatColors colors = Helpers.GetColors(this);
  1292.  
  1293.             _TextColor = colors.Flat;
  1294.         }
  1295.     }
  1296. }
  1297. namespace FlatUI
  1298. {
  1299.     public class FlatLabel : Label
  1300.     {
  1301.         protected override void OnTextChanged(EventArgs e)
  1302.         {
  1303.             base.OnTextChanged(e);
  1304.             Invalidate();
  1305.         }
  1306.  
  1307.         public FlatLabel()
  1308.         {
  1309.             SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  1310.             Font = new Font("Segoe UI", 8);
  1311.             ForeColor = Color.White;
  1312.             BackColor = Color.Transparent;
  1313.             Text = Text;
  1314.         }
  1315.     }
  1316. }
  1317. namespace FlatUI
  1318. {
  1319.     public class FlatListBox : Control
  1320.     {
  1321.         private ListBox withEventsField_ListBx = new ListBox();
  1322.         private ListBox ListBx
  1323.         {
  1324.             get { return withEventsField_ListBx; }
  1325.             set
  1326.             {
  1327.                 if (withEventsField_ListBx != null)
  1328.                 {
  1329.                     withEventsField_ListBx.DrawItem -= Drawitem;
  1330.                 }
  1331.                 withEventsField_ListBx = value;
  1332.                 if (withEventsField_ListBx != null)
  1333.                 {
  1334.                     withEventsField_ListBx.DrawItem += Drawitem;
  1335.                 }
  1336.             }
  1337.         }
  1338.  
  1339.         private string[] _items = { "" };
  1340.  
  1341.         [Category("Options")]
  1342.         public string[] items
  1343.         {
  1344.             get { return _items; }
  1345.             set
  1346.             {
  1347.                 _items = value;
  1348.                 ListBx.Items.Clear();
  1349.                 ListBx.Items.AddRange(value);
  1350.                 Invalidate();
  1351.             }
  1352.         }
  1353.  
  1354.         [Category("Colors")]
  1355.         public Color SelectedColor
  1356.         {
  1357.             get { return _SelectedColor; }
  1358.             set { _SelectedColor = value; }
  1359.         }
  1360.  
  1361.         public string SelectedItem
  1362.         {
  1363.             get { return ListBx.SelectedItem.ToString(); }
  1364.         }
  1365.  
  1366.         public int SelectedIndex
  1367.         {
  1368.             get
  1369.             {
  1370.                 int functionReturnValue = 0;
  1371.                 return ListBx.SelectedIndex;
  1372.                 if (ListBx.SelectedIndex < 0)
  1373.                     return functionReturnValue;
  1374.                 return functionReturnValue;
  1375.             }
  1376.         }
  1377.  
  1378.         public void Clear()
  1379.         {
  1380.             ListBx.Items.Clear();
  1381.         }
  1382.  
  1383.         public void ClearSelected()
  1384.         {
  1385.             for (int i = (ListBx.SelectedItems.Count - 1); i >= 0; i += -1)
  1386.             {
  1387.                 ListBx.Items.Remove(ListBx.SelectedItems[i]);
  1388.             }
  1389.         }
  1390.  
  1391.         public void Drawitem(object sender, DrawItemEventArgs e)
  1392.         {
  1393.             if (e.Index < 0)
  1394.                 return;
  1395.             e.DrawBackground();
  1396.             e.DrawFocusRectangle();
  1397.  
  1398.             e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
  1399.             e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
  1400.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  1401.             e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1402.  
  1403.             //-- if selected
  1404.             if (e.State.ToString().IndexOf("Selected,") >= 0)
  1405.             {
  1406.                 //-- Base
  1407.                 e.Graphics.FillRectangle(new SolidBrush(_SelectedColor), new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
  1408.  
  1409.                 //-- Text
  1410.                 e.Graphics.DrawString(" " + ListBx.Items[e.Index].ToString(), new Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2);
  1411.             }
  1412.             else
  1413.             {
  1414.                 //-- Base
  1415.                 e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(51, 53, 55)), new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
  1416.  
  1417.                 //-- Text
  1418.                 e.Graphics.DrawString(" " + ListBx.Items[e.Index].ToString(), new Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2);
  1419.             }
  1420.  
  1421.             e.Graphics.Dispose();
  1422.         }
  1423.  
  1424.         protected override void OnCreateControl()
  1425.         {
  1426.             base.OnCreateControl();
  1427.             if (!Controls.Contains(ListBx))
  1428.             {
  1429.                 Controls.Add(ListBx);
  1430.             }
  1431.         }
  1432.  
  1433.         public void AddRange(object[] items)
  1434.         {
  1435.             ListBx.Items.Remove("");
  1436.             ListBx.Items.AddRange(items);
  1437.         }
  1438.  
  1439.         public void AddItem(object item)
  1440.         {
  1441.             ListBx.Items.Remove("");
  1442.             ListBx.Items.Add(item);
  1443.         }
  1444.  
  1445.         private Color BaseColor = Color.FromArgb(45, 47, 49);
  1446.         private Color _SelectedColor = Helpers.FlatColor;
  1447.  
  1448.         public FlatListBox()
  1449.         {
  1450.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  1451.             DoubleBuffered = true;
  1452.  
  1453.             ListBx.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
  1454.             ListBx.ScrollAlwaysVisible = false;
  1455.             ListBx.HorizontalScrollbar = false;
  1456.             ListBx.BorderStyle = BorderStyle.None;
  1457.             ListBx.BackColor = BaseColor;
  1458.             ListBx.ForeColor = Color.White;
  1459.             ListBx.Location = new Point(3, 3);
  1460.             ListBx.Font = new Font("Segoe UI", 8);
  1461.             ListBx.ItemHeight = 20;
  1462.             ListBx.Items.Clear();
  1463.             ListBx.IntegralHeight = false;
  1464.  
  1465.             Size = new Size(131, 101);
  1466.             BackColor = BaseColor;
  1467.         }
  1468.  
  1469.         protected override void OnPaint(PaintEventArgs e)
  1470.         {
  1471.             this.UpdateColors();
  1472.  
  1473.             Bitmap B = new Bitmap(Width, Height);
  1474.             Graphics G = Graphics.FromImage(B);
  1475.  
  1476.             Rectangle Base = new Rectangle(0, 0, Width, Height);
  1477.  
  1478.             var _with19 = G;
  1479.             _with19.SmoothingMode = SmoothingMode.HighQuality;
  1480.             _with19.PixelOffsetMode = PixelOffsetMode.HighQuality;
  1481.             _with19.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1482.             _with19.Clear(BackColor);
  1483.  
  1484.             //-- Size
  1485.             ListBx.Size = new Size(Width - 6, Height - 2);
  1486.  
  1487.             //-- Base
  1488.             _with19.FillRectangle(new SolidBrush(BaseColor), Base);
  1489.  
  1490.             base.OnPaint(e);
  1491.             G.Dispose();
  1492.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  1493.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  1494.             B.Dispose();
  1495.         }
  1496.  
  1497.         private void UpdateColors()
  1498.         {
  1499.             FlatColors colors = Helpers.GetColors(this);
  1500.  
  1501.             _SelectedColor = colors.Flat;
  1502.         }
  1503.     }
  1504. }
  1505. namespace FlatUI
  1506. {
  1507.     public class FlatMax : Control
  1508.     {
  1509.         private MouseState State = MouseState.None;
  1510.         private int x;
  1511.  
  1512.         protected override void OnMouseEnter(EventArgs e)
  1513.         {
  1514.             base.OnMouseEnter(e);
  1515.             State = MouseState.Over;
  1516.             Invalidate();
  1517.         }
  1518.  
  1519.         protected override void OnMouseDown(MouseEventArgs e)
  1520.         {
  1521.             base.OnMouseDown(e);
  1522.             State = MouseState.Down;
  1523.             Invalidate();
  1524.         }
  1525.  
  1526.         protected override void OnMouseLeave(EventArgs e)
  1527.         {
  1528.             base.OnMouseLeave(e);
  1529.             State = MouseState.None;
  1530.             Invalidate();
  1531.         }
  1532.  
  1533.         protected override void OnMouseUp(MouseEventArgs e)
  1534.         {
  1535.             base.OnMouseUp(e);
  1536.             State = MouseState.Over;
  1537.             Invalidate();
  1538.         }
  1539.  
  1540.         protected override void OnMouseMove(MouseEventArgs e)
  1541.         {
  1542.             base.OnMouseMove(e);
  1543.             x = e.X;
  1544.             Invalidate();
  1545.         }
  1546.  
  1547.         protected override void OnClick(EventArgs e)
  1548.         {
  1549.             base.OnClick(e);
  1550.             switch (FindForm().WindowState)
  1551.             {
  1552.                 case FormWindowState.Maximized:
  1553.                     FindForm().WindowState = FormWindowState.Normal;
  1554.                     break;
  1555.                 case FormWindowState.Normal:
  1556.                     FindForm().WindowState = FormWindowState.Maximized;
  1557.                     break;
  1558.             }
  1559.         }
  1560.  
  1561.         [Category("Colors")]
  1562.         public Color BaseColor
  1563.         {
  1564.             get { return _BaseColor; }
  1565.             set { _BaseColor = value; }
  1566.         }
  1567.  
  1568.         [Category("Colors")]
  1569.         public Color TextColor
  1570.         {
  1571.             get { return _TextColor; }
  1572.             set { _TextColor = value; }
  1573.         }
  1574.  
  1575.         protected override void OnResize(EventArgs e)
  1576.         {
  1577.             base.OnResize(e);
  1578.             Size = new Size(18, 18);
  1579.         }
  1580.  
  1581.         private Color _BaseColor = Color.FromArgb(45, 47, 49);
  1582.         private Color _TextColor = Color.FromArgb(243, 243, 243);
  1583.  
  1584.         public FlatMax()
  1585.         {
  1586.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  1587.             DoubleBuffered = true;
  1588.             BackColor = Color.White;
  1589.             Size = new Size(18, 18);
  1590.             Anchor = AnchorStyles.Top | AnchorStyles.Right;
  1591.             Font = new Font("Marlett", 12);
  1592.         }
  1593.  
  1594.         protected override void OnPaint(PaintEventArgs e)
  1595.         {
  1596.             Bitmap B = new Bitmap(Width, Height);
  1597.             Graphics G = Graphics.FromImage(B);
  1598.  
  1599.             Rectangle Base = new Rectangle(0, 0, Width, Height);
  1600.  
  1601.             var _with4 = G;
  1602.             _with4.SmoothingMode = SmoothingMode.HighQuality;
  1603.             _with4.PixelOffsetMode = PixelOffsetMode.HighQuality;
  1604.             _with4.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1605.             _with4.Clear(BackColor);
  1606.  
  1607.             //-- Base
  1608.             _with4.FillRectangle(new SolidBrush(_BaseColor), Base);
  1609.  
  1610.             //-- Maximize
  1611.             if (FindForm().WindowState == FormWindowState.Maximized)
  1612.             {
  1613.                 _with4.DrawString("1", Font, new SolidBrush(TextColor), new Rectangle(1, 1, Width, Height), Helpers.CenterSF);
  1614.             }
  1615.             else if (FindForm().WindowState == FormWindowState.Normal)
  1616.             {
  1617.                 _with4.DrawString("2", Font, new SolidBrush(TextColor), new Rectangle(1, 1, Width, Height), Helpers.CenterSF);
  1618.             }
  1619.  
  1620.             //-- Hover/down
  1621.             switch (State)
  1622.             {
  1623.                 case MouseState.Over:
  1624.                     _with4.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.White)), Base);
  1625.                     break;
  1626.                 case MouseState.Down:
  1627.                     _with4.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.Black)), Base);
  1628.                     break;
  1629.             }
  1630.  
  1631.             base.OnPaint(e);
  1632.             G.Dispose();
  1633.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  1634.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  1635.             B.Dispose();
  1636.         }
  1637.     }
  1638. }
  1639. namespace FlatUI
  1640. {
  1641.     public class FlatMini : Control
  1642.     {
  1643.         private MouseState State = MouseState.None;
  1644.         private int x;
  1645.  
  1646.         protected override void OnMouseEnter(EventArgs e)
  1647.         {
  1648.             base.OnMouseEnter(e);
  1649.             State = MouseState.Over;
  1650.             Invalidate();
  1651.         }
  1652.  
  1653.         protected override void OnMouseDown(MouseEventArgs e)
  1654.         {
  1655.             base.OnMouseDown(e);
  1656.             State = MouseState.Down;
  1657.             Invalidate();
  1658.         }
  1659.  
  1660.         protected override void OnMouseLeave(EventArgs e)
  1661.         {
  1662.             base.OnMouseLeave(e);
  1663.             State = MouseState.None;
  1664.             Invalidate();
  1665.         }
  1666.  
  1667.         protected override void OnMouseUp(MouseEventArgs e)
  1668.         {
  1669.             base.OnMouseUp(e);
  1670.             State = MouseState.Over;
  1671.             Invalidate();
  1672.         }
  1673.  
  1674.         protected override void OnMouseMove(MouseEventArgs e)
  1675.         {
  1676.             base.OnMouseMove(e);
  1677.             x = e.X;
  1678.             Invalidate();
  1679.         }
  1680.  
  1681.         protected override void OnClick(EventArgs e)
  1682.         {
  1683.             base.OnClick(e);
  1684.             switch (FindForm().WindowState)
  1685.             {
  1686.                 case FormWindowState.Normal:
  1687.                     FindForm().WindowState = FormWindowState.Minimized;
  1688.                     break;
  1689.                 case FormWindowState.Maximized:
  1690.                     FindForm().WindowState = FormWindowState.Minimized;
  1691.                     break;
  1692.             }
  1693.         }
  1694.  
  1695.         [Category("Colors")]
  1696.         public Color BaseColor
  1697.         {
  1698.             get { return _BaseColor; }
  1699.             set { _BaseColor = value; }
  1700.         }
  1701.  
  1702.         [Category("Colors")]
  1703.         public Color TextColor
  1704.         {
  1705.             get { return _TextColor; }
  1706.             set { _TextColor = value; }
  1707.         }
  1708.  
  1709.         protected override void OnResize(EventArgs e)
  1710.         {
  1711.             base.OnResize(e);
  1712.             Size = new Size(18, 18);
  1713.         }
  1714.  
  1715.         private Color _BaseColor = Color.FromArgb(45, 47, 49);
  1716.         private Color _TextColor = Color.FromArgb(243, 243, 243);
  1717.  
  1718.         public FlatMini()
  1719.         {
  1720.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  1721.             DoubleBuffered = true;
  1722.             BackColor = Color.White;
  1723.             Size = new Size(18, 18);
  1724.             Anchor = AnchorStyles.Top | AnchorStyles.Right;
  1725.             Font = new Font("Marlett", 12);
  1726.         }
  1727.  
  1728.         protected override void OnPaint(PaintEventArgs e)
  1729.         {
  1730.             Bitmap B = new Bitmap(Width, Height);
  1731.             Graphics G = Graphics.FromImage(B);
  1732.  
  1733.             Rectangle Base = new Rectangle(0, 0, Width, Height);
  1734.  
  1735.             var _with5 = G;
  1736.             _with5.SmoothingMode = SmoothingMode.HighQuality;
  1737.             _with5.PixelOffsetMode = PixelOffsetMode.HighQuality;
  1738.             _with5.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1739.             _with5.Clear(BackColor);
  1740.  
  1741.             //-- Base
  1742.             _with5.FillRectangle(new SolidBrush(_BaseColor), Base);
  1743.  
  1744.             //-- Minimize
  1745.             _with5.DrawString("0", Font, new SolidBrush(TextColor), new Rectangle(2, 1, Width, Height), Helpers.CenterSF);
  1746.  
  1747.             //-- Hover/down
  1748.             switch (State)
  1749.             {
  1750.                 case MouseState.Over:
  1751.                     _with5.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.White)), Base);
  1752.                     break;
  1753.                 case MouseState.Down:
  1754.                     _with5.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.Black)), Base);
  1755.                     break;
  1756.             }
  1757.  
  1758.             base.OnPaint(e);
  1759.             G.Dispose();
  1760.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  1761.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  1762.             B.Dispose();
  1763.         }
  1764.     }
  1765. }
  1766. namespace FlatUI
  1767. {
  1768.     public class FlatNumeric : Control
  1769.     {
  1770.         private int W;
  1771.         private int H;
  1772.         private MouseState State = MouseState.None;
  1773.         private int x;
  1774.         private int y;
  1775.         private long _Value;
  1776.         private long _Min;
  1777.         private long _Max;
  1778.         private bool Bool;
  1779.  
  1780.         public long Value
  1781.         {
  1782.             get { return _Value; }
  1783.             set
  1784.             {
  1785.                 if (value <= _Max & value >= _Min)
  1786.                     _Value = value;
  1787.                 Invalidate();
  1788.             }
  1789.         }
  1790.  
  1791.         public long Maximum
  1792.         {
  1793.             get { return _Max; }
  1794.             set
  1795.             {
  1796.                 if (value > _Min)
  1797.                     _Max = value;
  1798.                 if (_Value > _Max)
  1799.                     _Value = _Max;
  1800.                 Invalidate();
  1801.             }
  1802.         }
  1803.  
  1804.         public long Minimum
  1805.         {
  1806.             get { return _Min; }
  1807.             set
  1808.             {
  1809.                 if (value < _Max)
  1810.                     _Min = value;
  1811.                 if (_Value < _Min)
  1812.                     _Value = Minimum;
  1813.                 Invalidate();
  1814.             }
  1815.         }
  1816.  
  1817.         protected override void OnMouseMove(MouseEventArgs e)
  1818.         {
  1819.             base.OnMouseMove(e);
  1820.             x = e.Location.X;
  1821.             y = e.Location.Y;
  1822.             Invalidate();
  1823.             if (e.X < Width - 23)
  1824.                 Cursor = Cursors.IBeam;
  1825.             else
  1826.                 Cursor = Cursors.Hand;
  1827.         }
  1828.  
  1829.         protected override void OnMouseDown(MouseEventArgs e)
  1830.         {
  1831.             base.OnMouseDown(e);
  1832.             if (x > Width - 21 && x < Width - 3)
  1833.             {
  1834.                 if (y < 15)
  1835.                 {
  1836.                     if ((Value + 1) <= _Max)
  1837.                         _Value += 1;
  1838.                 }
  1839.                 else
  1840.                 {
  1841.                     if ((Value - 1) >= _Min)
  1842.                         _Value -= 1;
  1843.                 }
  1844.             }
  1845.             else
  1846.             {
  1847.                 Bool = !Bool;
  1848.                 Focus();
  1849.             }
  1850.             Invalidate();
  1851.         }
  1852.  
  1853.         protected override void OnKeyPress(KeyPressEventArgs e)
  1854.         {
  1855.             base.OnKeyPress(e);
  1856.             try
  1857.             {
  1858.                 if (Bool)
  1859.                     _Value = Convert.ToInt64(_Value.ToString() + e.KeyChar.ToString());
  1860.                 if (_Value > _Max)
  1861.                     _Value = _Max;
  1862.                 Invalidate();
  1863.             }
  1864.             catch
  1865.             {
  1866.             }
  1867.         }
  1868.  
  1869.         protected override void OnKeyDown(KeyEventArgs e)
  1870.         {
  1871.             base.OnKeyDown(e);
  1872.             if (e.KeyCode == Keys.Back)
  1873.             {
  1874.                 Value = 0;
  1875.             }
  1876.         }
  1877.  
  1878.         protected override void OnResize(EventArgs e)
  1879.         {
  1880.             base.OnResize(e);
  1881.             Height = 30;
  1882.         }
  1883.  
  1884.         [Category("Colors")]
  1885.         public Color BaseColor
  1886.         {
  1887.             get { return _BaseColor; }
  1888.             set { _BaseColor = value; }
  1889.         }
  1890.  
  1891.         [Category("Colors")]
  1892.         public Color ButtonColor
  1893.         {
  1894.             get { return _ButtonColor; }
  1895.             set { _ButtonColor = value; }
  1896.         }
  1897.  
  1898.         private Color _BaseColor = Color.FromArgb(45, 47, 49);
  1899.         private Color _ButtonColor = Helpers.FlatColor;
  1900.  
  1901.         public FlatNumeric()
  1902.         {
  1903.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  1904.             DoubleBuffered = true;
  1905.             Font = new Font("Segoe UI", 10);
  1906.             BackColor = Color.FromArgb(60, 70, 73);
  1907.             ForeColor = Color.White;
  1908.             _Min = 0;
  1909.             _Max = 9999999;
  1910.         }
  1911.  
  1912.         protected override void OnPaint(PaintEventArgs e)
  1913.         {
  1914.             this.UpdateColors();
  1915.  
  1916.             Bitmap B = new Bitmap(Width, Height);
  1917.             Graphics G = Graphics.FromImage(B);
  1918.             W = Width;
  1919.             H = Height;
  1920.  
  1921.             Rectangle Base = new Rectangle(0, 0, W, H);
  1922.  
  1923.             var _with18 = G;
  1924.             _with18.SmoothingMode = SmoothingMode.HighQuality;
  1925.             _with18.PixelOffsetMode = PixelOffsetMode.HighQuality;
  1926.             _with18.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1927.             _with18.Clear(BackColor);
  1928.  
  1929.             //-- Base
  1930.             _with18.FillRectangle(new SolidBrush(_BaseColor), Base);
  1931.             _with18.FillRectangle(new SolidBrush(_ButtonColor), new Rectangle(Width - 24, 0, 24, H));
  1932.  
  1933.             //-- Add
  1934.             _with18.DrawString("+", new Font("Segoe UI", 12), Brushes.White, new Point(Width - 12, 8), Helpers.CenterSF);
  1935.             //-- Subtract
  1936.             _with18.DrawString("-", new Font("Segoe UI", 10, FontStyle.Bold), Brushes.White, new Point(Width - 12, 22), Helpers.CenterSF);
  1937.  
  1938.             //-- Text
  1939.             _with18.DrawString(Value.ToString(), Font, Brushes.White, new Rectangle(5, 1, W, H), new StringFormat { LineAlignment = StringAlignment.Center });
  1940.  
  1941.             base.OnPaint(e);
  1942.             G.Dispose();
  1943.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  1944.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  1945.             B.Dispose();
  1946.         }
  1947.  
  1948.         private void UpdateColors()
  1949.         {
  1950.             FlatColors colors = Helpers.GetColors(this);
  1951.  
  1952.             _ButtonColor = colors.Flat;
  1953.         }
  1954.     }
  1955. }
  1956. namespace FlatUI
  1957. {
  1958.     public class FlatProgressBar : Control
  1959.     {
  1960.         private int W;
  1961.         private int H;
  1962.         private int _Value = 0;
  1963.         private int _Maximum = 100;
  1964.         private bool _Pattern = true;
  1965.         private bool _ShowBalloon = true;
  1966.         private bool _PercentSign = false;
  1967.  
  1968.         [Category("Control")]
  1969.         public int Maximum
  1970.         {
  1971.             get { return _Maximum; }
  1972.             set
  1973.             {
  1974.                 if (value < _Value)
  1975.                     _Value = value;
  1976.                 _Maximum = value;
  1977.                 Invalidate();
  1978.             }
  1979.         }
  1980.  
  1981.         [Category("Control")]
  1982.         public int Value
  1983.         {
  1984.             get
  1985.             {
  1986.                 return _Value;
  1987.                 /*
  1988.                 switch (_Value)
  1989.                 {
  1990.                     case 0:
  1991.                         return 0;
  1992.                         Invalidate();
  1993.                         break;
  1994.                     default:
  1995.                         return _Value;
  1996.                         Invalidate();
  1997.                         break;
  1998.                 }
  1999.                 */
  2000.             }
  2001.             set
  2002.             {
  2003.                 if (value > _Maximum)
  2004.                 {
  2005.                     value = _Maximum;
  2006.                     Invalidate();
  2007.                 }
  2008.  
  2009.                 _Value = value;
  2010.                 Invalidate();
  2011.             }
  2012.         }
  2013.  
  2014.         public bool Pattern
  2015.         {
  2016.             get { return _Pattern; }
  2017.             set { _Pattern = value; }
  2018.         }
  2019.  
  2020.         public bool ShowBalloon
  2021.         {
  2022.             get { return _ShowBalloon; }
  2023.             set { _ShowBalloon = value; }
  2024.         }
  2025.  
  2026.         public bool PercentSign
  2027.         {
  2028.             get { return _PercentSign; }
  2029.             set { _PercentSign = value; }
  2030.         }
  2031.  
  2032.         [Category("Colors")]
  2033.         public Color ProgressColor
  2034.         {
  2035.             get { return _ProgressColor; }
  2036.             set { _ProgressColor = value; }
  2037.         }
  2038.  
  2039.         [Category("Colors")]
  2040.         public Color DarkerProgress
  2041.         {
  2042.             get { return _DarkerProgress; }
  2043.             set { _DarkerProgress = value; }
  2044.         }
  2045.  
  2046.         protected override void OnResize(EventArgs e)
  2047.         {
  2048.             base.OnResize(e);
  2049.             Height = 42;
  2050.         }
  2051.  
  2052.         protected override void CreateHandle()
  2053.         {
  2054.             base.CreateHandle();
  2055.             Height = 42;
  2056.         }
  2057.  
  2058.         public void Increment(int Amount)
  2059.         {
  2060.             Value += Amount;
  2061.         }
  2062.  
  2063.         private Color _BaseColor = Color.FromArgb(45, 47, 49);
  2064.         private Color _ProgressColor = Helpers.FlatColor;
  2065.         private Color _DarkerProgress = Color.FromArgb(23, 148, 92);
  2066.  
  2067.         public FlatProgressBar()
  2068.         {
  2069.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  2070.             DoubleBuffered = true;
  2071.             BackColor = Color.FromArgb(60, 70, 73);
  2072.             Height = 42;
  2073.         }
  2074.  
  2075.         protected override void OnPaint(PaintEventArgs e)
  2076.         {
  2077.             this.UpdateColors();
  2078.  
  2079.             Bitmap B = new Bitmap(Width, Height);
  2080.             Graphics G = Graphics.FromImage(B);
  2081.             W = Width - 1;
  2082.             H = Height - 1;
  2083.  
  2084.             Rectangle Base = new Rectangle(0, 24, W, H);
  2085.             GraphicsPath GP = new GraphicsPath();
  2086.             GraphicsPath GP2 = new GraphicsPath();
  2087.             GraphicsPath GP3 = new GraphicsPath();
  2088.  
  2089.             var _with15 = G;
  2090.             _with15.SmoothingMode = SmoothingMode.HighQuality;
  2091.             _with15.PixelOffsetMode = PixelOffsetMode.HighQuality;
  2092.             _with15.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  2093.             _with15.Clear(BackColor);
  2094.  
  2095.             //-- Progress Value
  2096.             //int iValue = Convert.ToInt32(((float)_Value) / ((float)(_Maximum * Width)));
  2097.             float percent = ((float)_Value) / ((float)_Maximum);
  2098.             int iValue = (int)(percent * ((float)Width));
  2099.  
  2100.             switch (Value)
  2101.             {
  2102.                 case 0:
  2103.                     //-- Base
  2104.                     _with15.FillRectangle(new SolidBrush(_BaseColor), Base);
  2105.                     //--Progress
  2106.                     _with15.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(0, 24, iValue - 1, H - 1));
  2107.                     break;
  2108.                 case 100:
  2109.                     //-- Base
  2110.                     _with15.FillRectangle(new SolidBrush(_BaseColor), Base);
  2111.                     //--Progress
  2112.                     _with15.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(0, 24, iValue - 1, H - 1));
  2113.                     break;
  2114.                 default:
  2115.                     //-- Base
  2116.                     _with15.FillRectangle(new SolidBrush(_BaseColor), Base);
  2117.  
  2118.                     //--Progress
  2119.                     GP.AddRectangle(new Rectangle(0, 24, iValue - 1, H - 1));
  2120.                     _with15.FillPath(new SolidBrush(_ProgressColor), GP);
  2121.  
  2122.                     if (_Pattern)
  2123.                     {
  2124.                         //-- Hatch Brush
  2125.                         HatchBrush HB = new HatchBrush(HatchStyle.Plaid, _DarkerProgress, _ProgressColor);
  2126.                         _with15.FillRectangle(HB, new Rectangle(0, 24, iValue - 1, H - 1));
  2127.                     }
  2128.  
  2129.                     if (_ShowBalloon)
  2130.                     {
  2131.                         //-- Balloon
  2132.                         Rectangle Balloon = new Rectangle(iValue - 18, 0, 34, 16);
  2133.                         GP2 = Helpers.RoundRec(Balloon, 4);
  2134.                         _with15.FillPath(new SolidBrush(_BaseColor), GP2);
  2135.  
  2136.                         //-- Arrow
  2137.                         GP3 = Helpers.DrawArrow(iValue - 9, 16, true);
  2138.                         _with15.FillPath(new SolidBrush(_BaseColor), GP3);
  2139.  
  2140.                         //-- Value > You can add "%" > value & "%"
  2141.                         string text = (_PercentSign ? Value.ToString() + "%" : Value.ToString());
  2142.                         int wOffset = (_PercentSign ? iValue - 15 : iValue - 11);
  2143.                         _with15.DrawString(text, new Font("Segoe UI", 10), new SolidBrush(_ProgressColor), new Rectangle(wOffset, -2, W, H), Helpers.NearSF);
  2144.                     }
  2145.  
  2146.                     break;
  2147.             }
  2148.  
  2149.             base.OnPaint(e);
  2150.             G.Dispose();
  2151.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  2152.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  2153.             B.Dispose();
  2154.         }
  2155.  
  2156.         private void UpdateColors()
  2157.         {
  2158.             FlatColors colors = Helpers.GetColors(this);
  2159.  
  2160.             _ProgressColor = colors.Flat;
  2161.         }
  2162.     }
  2163. }
  2164. namespace FlatUI
  2165. {
  2166.     [DefaultEvent("CheckedChanged")]
  2167.     public class FlatRadioButton : Control
  2168.     {
  2169.         private MouseState State = MouseState.None;
  2170.         private int W;
  2171.         private int H;
  2172.         private _Options O;
  2173.  
  2174.         private bool _Checked;
  2175.         public bool Checked
  2176.         {
  2177.             get { return _Checked; }
  2178.             set
  2179.             {
  2180.                 _Checked = value;
  2181.                 InvalidateControls();
  2182.                 if (CheckedChanged != null)
  2183.                 {
  2184.                     CheckedChanged(this);
  2185.                 }
  2186.                 Invalidate();
  2187.             }
  2188.         }
  2189.  
  2190.         public event CheckedChangedEventHandler CheckedChanged;
  2191.         public delegate void CheckedChangedEventHandler(object sender);
  2192.  
  2193.         protected override void OnClick(EventArgs e)
  2194.         {
  2195.             if (!_Checked)
  2196.                 Checked = true;
  2197.             base.OnClick(e);
  2198.         }
  2199.  
  2200.         private void InvalidateControls()
  2201.         {
  2202.             if (!IsHandleCreated || !_Checked)
  2203.                 return;
  2204.             foreach (Control C in Parent.Controls)
  2205.             {
  2206.                 if (!object.ReferenceEquals(C, this) && C is FlatRadioButton)
  2207.                 {
  2208.                     ((FlatRadioButton)C).Checked = false;
  2209.                     Invalidate();
  2210.                 }
  2211.             }
  2212.         }
  2213.  
  2214.         protected override void OnCreateControl()
  2215.         {
  2216.             base.OnCreateControl();
  2217.             InvalidateControls();
  2218.         }
  2219.  
  2220.         [Flags()]
  2221.         public enum _Options
  2222.         {
  2223.             Style1,
  2224.             Style2
  2225.         }
  2226.  
  2227.         [Category("Options")]
  2228.         public _Options Options
  2229.         {
  2230.             get { return O; }
  2231.             set { O = value; }
  2232.         }
  2233.  
  2234.         protected override void OnResize(EventArgs e)
  2235.         {
  2236.             base.OnResize(e);
  2237.             Height = 22;
  2238.         }
  2239.  
  2240.         protected override void OnMouseDown(MouseEventArgs e)
  2241.         {
  2242.             base.OnMouseDown(e);
  2243.             State = MouseState.Down;
  2244.             Invalidate();
  2245.         }
  2246.  
  2247.         protected override void OnMouseUp(MouseEventArgs e)
  2248.         {
  2249.             base.OnMouseUp(e);
  2250.             State = MouseState.Over;
  2251.             Invalidate();
  2252.         }
  2253.  
  2254.         protected override void OnMouseEnter(EventArgs e)
  2255.         {
  2256.             base.OnMouseEnter(e);
  2257.             State = MouseState.Over;
  2258.             Invalidate();
  2259.         }
  2260.  
  2261.         protected override void OnMouseLeave(EventArgs e)
  2262.         {
  2263.             base.OnMouseLeave(e);
  2264.             State = MouseState.None;
  2265.             Invalidate();
  2266.         }
  2267.  
  2268.         private Color _BaseColor = Color.FromArgb(45, 47, 49);
  2269.         private Color _BorderColor = Helpers.FlatColor;
  2270.         private Color _TextColor = Color.FromArgb(243, 243, 243);
  2271.  
  2272.         public FlatRadioButton()
  2273.         {
  2274.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  2275.             DoubleBuffered = true;
  2276.             Cursor = Cursors.Hand;
  2277.             Size = new Size(100, 22);
  2278.             BackColor = Color.FromArgb(60, 70, 73);
  2279.             Font = new Font("Segoe UI", 10);
  2280.         }
  2281.  
  2282.         protected override void OnPaint(PaintEventArgs e)
  2283.         {
  2284.             this.UpdateColors();
  2285.  
  2286.             Bitmap B = new Bitmap(Width, Height);
  2287.             Graphics G = Graphics.FromImage(B);
  2288.             W = Width - 1;
  2289.             H = Height - 1;
  2290.  
  2291.             Rectangle Base = new Rectangle(0, 2, Height - 5, Height - 5);
  2292.             Rectangle Dot = new Rectangle(4, 6, H - 12, H - 12);
  2293.  
  2294.             var _with10 = G;
  2295.             _with10.SmoothingMode = SmoothingMode.HighQuality;
  2296.             _with10.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  2297.             _with10.Clear(BackColor);
  2298.  
  2299.             switch (O)
  2300.             {
  2301.                 case _Options.Style1:
  2302.                     //-- Base
  2303.                     _with10.FillEllipse(new SolidBrush(_BaseColor), Base);
  2304.  
  2305.                     switch (State)
  2306.                     {
  2307.                         case MouseState.Over:
  2308.                             _with10.DrawEllipse(new Pen(_BorderColor), Base);
  2309.                             break;
  2310.                         case MouseState.Down:
  2311.                             _with10.DrawEllipse(new Pen(_BorderColor), Base);
  2312.                             break;
  2313.                     }
  2314.  
  2315.                     //-- If Checked
  2316.                     if (Checked)
  2317.                     {
  2318.                         _with10.FillEllipse(new SolidBrush(_BorderColor), Dot);
  2319.                     }
  2320.                     break;
  2321.                 case _Options.Style2:
  2322.                     //-- Base
  2323.                     _with10.FillEllipse(new SolidBrush(_BaseColor), Base);
  2324.  
  2325.                     switch (State)
  2326.                     {
  2327.                         case MouseState.Over:
  2328.                             //-- Base
  2329.                             _with10.DrawEllipse(new Pen(_BorderColor), Base);
  2330.                             _with10.FillEllipse(new SolidBrush(Color.FromArgb(118, 213, 170)), Base);
  2331.                             break;
  2332.                         case MouseState.Down:
  2333.                             //-- Base
  2334.                             _with10.DrawEllipse(new Pen(_BorderColor), Base);
  2335.                             _with10.FillEllipse(new SolidBrush(Color.FromArgb(118, 213, 170)), Base);
  2336.                             break;
  2337.                     }
  2338.  
  2339.                     //-- If Checked
  2340.                     if (Checked)
  2341.                     {
  2342.                         //-- Base
  2343.                         _with10.FillEllipse(new SolidBrush(_BorderColor), Dot);
  2344.                     }
  2345.                     break;
  2346.             }
  2347.  
  2348.             _with10.DrawString(Text, Font, new SolidBrush(_TextColor), new Rectangle(20, 2, W, H), Helpers.NearSF);
  2349.  
  2350.             base.OnPaint(e);
  2351.             G.Dispose();
  2352.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  2353.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  2354.             B.Dispose();
  2355.         }
  2356.  
  2357.         private void UpdateColors()
  2358.         {
  2359.             FlatColors colors = Helpers.GetColors(this);
  2360.  
  2361.             _BorderColor = colors.Flat;
  2362.         }
  2363.     }
  2364. }
  2365. namespace FlatUI
  2366. {
  2367.     public class FlatStatusBar : Control
  2368.     {
  2369.         private int W;
  2370.         private int H;
  2371.         private bool _ShowTimeDate = false;
  2372.  
  2373.         protected override void CreateHandle()
  2374.         {
  2375.             base.CreateHandle();
  2376.             Dock = DockStyle.Bottom;
  2377.         }
  2378.  
  2379.         protected override void OnTextChanged(EventArgs e)
  2380.         {
  2381.             base.OnTextChanged(e);
  2382.             Invalidate();
  2383.         }
  2384.  
  2385.         [Category("Colors")]
  2386.         public Color BaseColor
  2387.         {
  2388.             get { return _BaseColor; }
  2389.             set { _BaseColor = value; }
  2390.         }
  2391.  
  2392.         [Category("Colors")]
  2393.         public Color TextColor
  2394.         {
  2395.             get { return _TextColor; }
  2396.             set { _TextColor = value; }
  2397.         }
  2398.  
  2399.         [Category("Colors")]
  2400.         public Color RectColor
  2401.         {
  2402.             get { return _RectColor; }
  2403.             set { _RectColor = value; }
  2404.         }
  2405.  
  2406.         public bool ShowTimeDate
  2407.         {
  2408.             get { return _ShowTimeDate; }
  2409.             set { _ShowTimeDate = value; }
  2410.         }
  2411.  
  2412.         public string GetTimeDate()
  2413.         {
  2414.             return DateTime.Now.Date + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  2415.         }
  2416.  
  2417.         private Color _BaseColor = Color.FromArgb(45, 47, 49);
  2418.         private Color _TextColor = Color.White;
  2419.         private Color _RectColor = Helpers.FlatColor;
  2420.  
  2421.         public FlatStatusBar()
  2422.         {
  2423.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  2424.             DoubleBuffered = true;
  2425.             Font = new Font("Segoe UI", 8);
  2426.             ForeColor = Color.White;
  2427.             Size = new Size(Width, 20);
  2428.         }
  2429.  
  2430.         protected override void OnPaint(PaintEventArgs e)
  2431.         {
  2432.             this.UpdateColors();
  2433.  
  2434.             Bitmap B = new Bitmap(Width, Height);
  2435.             Graphics G = Graphics.FromImage(B);
  2436.             W = Width;
  2437.             H = Height;
  2438.  
  2439.             Rectangle Base = new Rectangle(0, 0, W, H);
  2440.  
  2441.             var _with21 = G;
  2442.             _with21.SmoothingMode = SmoothingMode.HighQuality;
  2443.             _with21.PixelOffsetMode = PixelOffsetMode.HighQuality;
  2444.             _with21.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  2445.             _with21.Clear(BaseColor);
  2446.  
  2447.             //-- Base
  2448.             _with21.FillRectangle(new SolidBrush(BaseColor), Base);
  2449.  
  2450.             //-- Text
  2451.             _with21.DrawString(Text, Font, Brushes.White, new Rectangle(10, 4, W, H), Helpers.NearSF);
  2452.  
  2453.             //-- Rectangle
  2454.             _with21.FillRectangle(new SolidBrush(_RectColor), new Rectangle(4, 4, 4, 14));
  2455.  
  2456.             //-- TimeDate
  2457.             if (ShowTimeDate)
  2458.             {
  2459.                 _with21.DrawString(GetTimeDate(), Font, new SolidBrush(_TextColor), new Rectangle(-4, 2, W, H), new StringFormat
  2460.                 {
  2461.                     Alignment = StringAlignment.Far,
  2462.                     LineAlignment = StringAlignment.Center
  2463.                 });
  2464.             }
  2465.  
  2466.             base.OnPaint(e);
  2467.             G.Dispose();
  2468.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  2469.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  2470.             B.Dispose();
  2471.         }
  2472.  
  2473.         private void UpdateColors()
  2474.         {
  2475.             FlatColors colors = Helpers.GetColors(this);
  2476.  
  2477.             _RectColor = colors.Flat;
  2478.         }
  2479.     }
  2480. }
  2481. namespace FlatUI
  2482. {
  2483.     public class FlatStickyButton : Control
  2484.     {
  2485.         private int W;
  2486.         private int H;
  2487.         private MouseState State = MouseState.None;
  2488.         private bool _Rounded = false;
  2489.  
  2490.         protected override void OnMouseDown(MouseEventArgs e)
  2491.         {
  2492.             base.OnMouseDown(e);
  2493.             State = MouseState.Down;
  2494.             Invalidate();
  2495.         }
  2496.  
  2497.         protected override void OnMouseUp(MouseEventArgs e)
  2498.         {
  2499.             base.OnMouseUp(e);
  2500.             State = MouseState.Over;
  2501.             Invalidate();
  2502.         }
  2503.  
  2504.         protected override void OnMouseEnter(EventArgs e)
  2505.         {
  2506.             base.OnMouseEnter(e);
  2507.             State = MouseState.Over;
  2508.             Invalidate();
  2509.         }
  2510.  
  2511.         protected override void OnMouseLeave(EventArgs e)
  2512.         {
  2513.             base.OnMouseLeave(e);
  2514.             State = MouseState.None;
  2515.             Invalidate();
  2516.         }
  2517.  
  2518.         private bool[] GetConnectedSides()
  2519.         {
  2520.             bool[] Bool = new bool[4] { false, false, false, false };
  2521.  
  2522.             foreach (Control B in Parent.Controls)
  2523.             {
  2524.                 if (B is FlatStickyButton)
  2525.                 {
  2526.                     if (object.ReferenceEquals(B, this) || !Rect.IntersectsWith(Rect))
  2527.                         continue;
  2528.                     double A = (Math.Atan2(Left - B.Left, Top - B.Top) * 2 / Math.PI);
  2529.                     if (A / 1 == A)
  2530.                         Bool[(int)A + 1] = true;
  2531.                 }
  2532.             }
  2533.  
  2534.             return Bool;
  2535.         }
  2536.  
  2537.         private Rectangle Rect
  2538.         {
  2539.             get { return new Rectangle(Left, Top, Width, Height); }
  2540.         }
  2541.  
  2542.         [Category("Colors")]
  2543.         public Color BaseColor
  2544.         {
  2545.             get { return _BaseColor; }
  2546.             set { _BaseColor = value; }
  2547.         }
  2548.  
  2549.         [Category("Colors")]
  2550.         public Color TextColor
  2551.         {
  2552.             get { return _TextColor; }
  2553.             set { _TextColor = value; }
  2554.         }
  2555.  
  2556.         [Category("Options")]
  2557.         public bool Rounded
  2558.         {
  2559.             get { return _Rounded; }
  2560.             set { _Rounded = value; }
  2561.         }
  2562.  
  2563.         protected override void OnResize(EventArgs e)
  2564.         {
  2565.             base.OnResize(e);
  2566.             //Height = 32
  2567.         }
  2568.  
  2569.         protected override void OnCreateControl()
  2570.         {
  2571.             base.OnCreateControl();
  2572.             //Size = New Size(112, 32)
  2573.         }
  2574.  
  2575.         private Color _BaseColor = Helpers.FlatColor;
  2576.         private Color _TextColor = Color.FromArgb(243, 243, 243);
  2577.  
  2578.         public FlatStickyButton()
  2579.         {
  2580.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  2581.             DoubleBuffered = true;
  2582.             Size = new Size(106, 32);
  2583.             BackColor = Color.Transparent;
  2584.             Font = new Font("Segoe UI", 12);
  2585.             Cursor = Cursors.Hand;
  2586.         }
  2587.  
  2588.         protected override void OnPaint(PaintEventArgs e)
  2589.         {
  2590.             this.UpdateColors();
  2591.  
  2592.             Bitmap B = new Bitmap(Width, Height);
  2593.             Graphics G = Graphics.FromImage(B);
  2594.             W = Width;
  2595.             H = Height;
  2596.  
  2597.             GraphicsPath GP = new GraphicsPath();
  2598.  
  2599.             bool[] GCS = GetConnectedSides();
  2600.             // dynamic RoundedBase = Helpers.RoundRect(0, 0, W, H, ???, !(GCS(2) | GCS(1)), !(GCS(1) | GCS(0)), !(GCS(3) | GCS(0)), !(GCS(3) | GCS(2)));
  2601.             GraphicsPath RoundedBase = Helpers.RoundRect(0, 0, W, H, 0.3, !(GCS[2] || GCS[1]), !(GCS[1] || GCS[0]), !(GCS[3] || GCS[0]), !(GCS[3] || GCS[2]));
  2602.             Rectangle Base = new Rectangle(0, 0, W, H);
  2603.  
  2604.             var _with17 = G;
  2605.             _with17.SmoothingMode = SmoothingMode.HighQuality;
  2606.             _with17.PixelOffsetMode = PixelOffsetMode.HighQuality;
  2607.             _with17.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  2608.             _with17.Clear(BackColor);
  2609.  
  2610.             switch (State)
  2611.             {
  2612.                 case MouseState.None:
  2613.                     if (Rounded)
  2614.                     {
  2615.                         //-- Base
  2616.                         GP = RoundedBase;
  2617.                         _with17.FillPath(new SolidBrush(_BaseColor), GP);
  2618.  
  2619.                         //-- Text
  2620.                         _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  2621.                     }
  2622.                     else
  2623.                     {
  2624.                         //-- Base
  2625.                         _with17.FillRectangle(new SolidBrush(_BaseColor), Base);
  2626.  
  2627.                         //-- Text
  2628.                         _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  2629.                     }
  2630.                     break;
  2631.                 case MouseState.Over:
  2632.                     if (Rounded)
  2633.                     {
  2634.                         //-- Base
  2635.                         GP = RoundedBase;
  2636.                         _with17.FillPath(new SolidBrush(_BaseColor), GP);
  2637.                         _with17.FillPath(new SolidBrush(Color.FromArgb(20, Color.White)), GP);
  2638.  
  2639.                         //-- Text
  2640.                         _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  2641.                     }
  2642.                     else
  2643.                     {
  2644.                         //-- Base
  2645.                         _with17.FillRectangle(new SolidBrush(_BaseColor), Base);
  2646.                         _with17.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.White)), Base);
  2647.  
  2648.                         //-- Text
  2649.                         _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  2650.                     }
  2651.                     break;
  2652.                 case MouseState.Down:
  2653.                     if (Rounded)
  2654.                     {
  2655.                         //-- Base
  2656.                         GP = RoundedBase;
  2657.                         _with17.FillPath(new SolidBrush(_BaseColor), GP);
  2658.                         _with17.FillPath(new SolidBrush(Color.FromArgb(20, Color.Black)), GP);
  2659.  
  2660.                         //-- Text
  2661.                         _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  2662.                     }
  2663.                     else
  2664.                     {
  2665.                         //-- Base
  2666.                         _with17.FillRectangle(new SolidBrush(_BaseColor), Base);
  2667.                         _with17.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.Black)), Base);
  2668.  
  2669.                         //-- Text
  2670.                         _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
  2671.                     }
  2672.                     break;
  2673.             }
  2674.  
  2675.             base.OnPaint(e);
  2676.             G.Dispose();
  2677.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  2678.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  2679.             B.Dispose();
  2680.         }
  2681.  
  2682.         private void UpdateColors()
  2683.         {
  2684.             FlatColors colors = Helpers.GetColors(this);
  2685.  
  2686.             _BaseColor = colors.Flat;
  2687.         }
  2688.     }
  2689. }
  2690. namespace FlatUI
  2691. {
  2692.     public class FlatTabControl : TabControl
  2693.     {
  2694.         private int W;
  2695.         private int H;
  2696.  
  2697.         protected override void CreateHandle()
  2698.         {
  2699.             base.CreateHandle();
  2700.             Alignment = TabAlignment.Top;
  2701.         }
  2702.  
  2703.         [Category("Colors")]
  2704.         public Color BaseColor
  2705.         {
  2706.             get { return _BaseColor; }
  2707.             set { _BaseColor = value; }
  2708.         }
  2709.  
  2710.         [Category("Colors")]
  2711.         public Color ActiveColor
  2712.         {
  2713.             get { return _ActiveColor; }
  2714.             set { _ActiveColor = value; }
  2715.         }
  2716.  
  2717.         private Color BGColor = Color.FromArgb(60, 70, 73);
  2718.         private Color _BaseColor = Color.FromArgb(45, 47, 49);
  2719.         private Color _ActiveColor = Helpers.FlatColor;
  2720.  
  2721.         public FlatTabControl()
  2722.         {
  2723.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  2724.             DoubleBuffered = true;
  2725.             BackColor = Color.FromArgb(60, 70, 73);
  2726.  
  2727.             Font = new Font("Segoe UI", 10);
  2728.             SizeMode = TabSizeMode.Fixed;
  2729.             ItemSize = new Size(120, 40);
  2730.         }
  2731.  
  2732.         protected override void OnPaint(PaintEventArgs e)
  2733.         {
  2734.             this.UpdateColors();
  2735.  
  2736.             Bitmap B = new Bitmap(Width, Height);
  2737.             Graphics G = Graphics.FromImage(B);
  2738.             W = Width - 1;
  2739.             H = Height - 1;
  2740.  
  2741.             var _with13 = G;
  2742.             _with13.SmoothingMode = SmoothingMode.HighQuality;
  2743.             _with13.PixelOffsetMode = PixelOffsetMode.HighQuality;
  2744.             _with13.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  2745.             _with13.Clear(_BaseColor);
  2746.  
  2747.             try
  2748.             {
  2749.                 SelectedTab.BackColor = BGColor;
  2750.             }
  2751.             catch
  2752.             {
  2753.             }
  2754.  
  2755.             for (int i = 0; i <= TabCount - 1; i++)
  2756.             {
  2757.                 Rectangle Base = new Rectangle(new Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y), new Size(GetTabRect(i).Width, GetTabRect(i).Height));
  2758.                 Rectangle BaseSize = new Rectangle(Base.Location, new Size(Base.Width, Base.Height));
  2759.  
  2760.                 if (i == SelectedIndex)
  2761.                 {
  2762.                     //-- Base
  2763.                     _with13.FillRectangle(new SolidBrush(_BaseColor), BaseSize);
  2764.  
  2765.                     //-- Gradiant
  2766.                     //.fill
  2767.                     _with13.FillRectangle(new SolidBrush(_ActiveColor), BaseSize);
  2768.  
  2769.                     //-- ImageList
  2770.                     if (ImageList != null)
  2771.                     {
  2772.                         try
  2773.                         {
  2774.                             if (ImageList.Images[TabPages[i].ImageIndex] != null)
  2775.                             {
  2776.                                 //-- Image
  2777.                                 _with13.DrawImage(ImageList.Images[TabPages[i].ImageIndex], new Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6));
  2778.                                 //-- Text
  2779.                                 _with13.DrawString("      " + TabPages[i].Text, Font, Brushes.White, BaseSize, Helpers.CenterSF);
  2780.                             }
  2781.                             else
  2782.                             {
  2783.                                 //-- Text
  2784.                                 _with13.DrawString(TabPages[i].Text, Font, Brushes.White, BaseSize, Helpers.CenterSF);
  2785.                             }
  2786.                         }
  2787.                         catch (Exception ex)
  2788.                         {
  2789.                             throw new Exception(ex.Message);
  2790.                         }
  2791.                     }
  2792.                     else
  2793.                     {
  2794.                         //-- Text
  2795.                         _with13.DrawString(TabPages[i].Text, Font, Brushes.White, BaseSize, Helpers.CenterSF);
  2796.                     }
  2797.                 }
  2798.                 else
  2799.                 {
  2800.                     //-- Base
  2801.                     _with13.FillRectangle(new SolidBrush(_BaseColor), BaseSize);
  2802.  
  2803.                     //-- ImageList
  2804.                     if (ImageList != null)
  2805.                     {
  2806.                         try
  2807.                         {
  2808.                             if (ImageList.Images[TabPages[i].ImageIndex] != null)
  2809.                             {
  2810.                                 //-- Image
  2811.                                 _with13.DrawImage(ImageList.Images[TabPages[i].ImageIndex], new Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6));
  2812.                                 //-- Text
  2813.                                 _with13.DrawString("      " + TabPages[i].Text, Font, new SolidBrush(Color.White), BaseSize, new StringFormat
  2814.                                 {
  2815.                                     LineAlignment = StringAlignment.Center,
  2816.                                     Alignment = StringAlignment.Center
  2817.                                 });
  2818.                             }
  2819.                             else
  2820.                             {
  2821.                                 //-- Text
  2822.                                 _with13.DrawString(TabPages[i].Text, Font, new SolidBrush(Color.White), BaseSize, new StringFormat
  2823.                                 {
  2824.                                     LineAlignment = StringAlignment.Center,
  2825.                                     Alignment = StringAlignment.Center
  2826.                                 });
  2827.                             }
  2828.                         }
  2829.                         catch (Exception ex)
  2830.                         {
  2831.                             throw new Exception(ex.Message);
  2832.                         }
  2833.                     }
  2834.                     else
  2835.                     {
  2836.                         //-- Text
  2837.                         _with13.DrawString(TabPages[i].Text, Font, new SolidBrush(Color.White), BaseSize, new StringFormat
  2838.                         {
  2839.                             LineAlignment = StringAlignment.Center,
  2840.                             Alignment = StringAlignment.Center
  2841.                         });
  2842.                     }
  2843.                 }
  2844.             }
  2845.  
  2846.             base.OnPaint(e);
  2847.             G.Dispose();
  2848.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  2849.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  2850.             B.Dispose();
  2851.         }
  2852.  
  2853.         private void UpdateColors()
  2854.         {
  2855.             FlatColors colors = Helpers.GetColors(this);
  2856.  
  2857.             _ActiveColor = colors.Flat;
  2858.         }
  2859.     }
  2860. }
  2861. namespace FlatUI
  2862. {
  2863.     [DefaultEvent("TextChanged")]
  2864.     public class FlatTextBox : Control
  2865.     {
  2866.         private int W;
  2867.         private int H;
  2868.         private MouseState State = MouseState.None;
  2869.         private System.Windows.Forms.TextBox TB;
  2870.  
  2871.         private HorizontalAlignment _TextAlign = HorizontalAlignment.Left;
  2872.         [Category("Options")]
  2873.         public HorizontalAlignment TextAlign
  2874.         {
  2875.             get { return _TextAlign; }
  2876.             set
  2877.             {
  2878.                 _TextAlign = value;
  2879.                 if (TB != null)
  2880.                 {
  2881.                     TB.TextAlign = value;
  2882.                 }
  2883.             }
  2884.         }
  2885.  
  2886.         private int _MaxLength = 32767;
  2887.         [Category("Options")]
  2888.         public int MaxLength
  2889.         {
  2890.             get { return _MaxLength; }
  2891.             set
  2892.             {
  2893.                 _MaxLength = value;
  2894.                 if (TB != null)
  2895.                 {
  2896.                     TB.MaxLength = value;
  2897.                 }
  2898.             }
  2899.         }
  2900.  
  2901.         private bool _ReadOnly;
  2902.         [Category("Options")]
  2903.         public bool ReadOnly
  2904.         {
  2905.             get { return _ReadOnly; }
  2906.             set
  2907.             {
  2908.                 _ReadOnly = value;
  2909.                 if (TB != null)
  2910.                 {
  2911.                     TB.ReadOnly = value;
  2912.                 }
  2913.             }
  2914.         }
  2915.  
  2916.         private bool _UseSystemPasswordChar;
  2917.         [Category("Options")]
  2918.         public bool UseSystemPasswordChar
  2919.         {
  2920.             get { return _UseSystemPasswordChar; }
  2921.             set
  2922.             {
  2923.                 _UseSystemPasswordChar = value;
  2924.                 if (TB != null)
  2925.                 {
  2926.                     TB.UseSystemPasswordChar = value;
  2927.                 }
  2928.             }
  2929.         }
  2930.  
  2931.         private bool _Multiline;
  2932.         [Category("Options")]
  2933.         public bool Multiline
  2934.         {
  2935.             get { return _Multiline; }
  2936.             set
  2937.             {
  2938.                 _Multiline = value;
  2939.                 if (TB != null)
  2940.                 {
  2941.                     TB.Multiline = value;
  2942.  
  2943.                     if (value)
  2944.                     {
  2945.                         TB.Height = Height - 11;
  2946.                     }
  2947.                     else
  2948.                     {
  2949.                         Height = TB.Height + 11;
  2950.                     }
  2951.  
  2952.                 }
  2953.             }
  2954.         }
  2955.  
  2956.         private bool _FocusOnHover = false;
  2957.         [Category("Options")]
  2958.         public bool FocusOnHover
  2959.         {
  2960.             get { return _FocusOnHover; }
  2961.             set { _FocusOnHover = value; }
  2962.         }
  2963.  
  2964.         [Category("Options")]
  2965.         public override string Text
  2966.         {
  2967.             get { return base.Text; }
  2968.             set
  2969.             {
  2970.                 base.Text = value;
  2971.                 if (TB != null)
  2972.                 {
  2973.                     TB.Text = value;
  2974.                 }
  2975.             }
  2976.         }
  2977.  
  2978.         [Category("Options")]
  2979.         public override Font Font
  2980.         {
  2981.             get { return base.Font; }
  2982.             set
  2983.             {
  2984.                 base.Font = value;
  2985.                 if (TB != null)
  2986.                 {
  2987.                     TB.Font = value;
  2988.                     TB.Location = new Point(3, 5);
  2989.                     TB.Width = Width - 6;
  2990.  
  2991.                     if (!_Multiline)
  2992.                     {
  2993.                         Height = TB.Height + 11;
  2994.                     }
  2995.                 }
  2996.             }
  2997.         }
  2998.  
  2999.         protected override void OnCreateControl()
  3000.         {
  3001.             base.OnCreateControl();
  3002.             if (!Controls.Contains(TB))
  3003.             {
  3004.                 Controls.Add(TB);
  3005.             }
  3006.         }
  3007.  
  3008.         private void OnBaseTextChanged(object s, EventArgs e)
  3009.         {
  3010.             Text = TB.Text;
  3011.         }
  3012.  
  3013.         private void OnBaseKeyDown(object s, KeyEventArgs e)
  3014.         {
  3015.             if (e.Control && e.KeyCode == Keys.A)
  3016.             {
  3017.                 TB.SelectAll();
  3018.                 e.SuppressKeyPress = true;
  3019.             }
  3020.             if (e.Control && e.KeyCode == Keys.C)
  3021.             {
  3022.                 TB.Copy();
  3023.                 e.SuppressKeyPress = true;
  3024.             }
  3025.         }
  3026.  
  3027.         protected override void OnResize(EventArgs e)
  3028.         {
  3029.             TB.Location = new Point(5, 5);
  3030.             TB.Width = Width - 10;
  3031.  
  3032.             if (_Multiline)
  3033.             {
  3034.                 TB.Height = Height - 11;
  3035.             }
  3036.             else
  3037.             {
  3038.                 Height = TB.Height + 11;
  3039.             }
  3040.  
  3041.             base.OnResize(e);
  3042.         }
  3043.  
  3044.         [Category("Colors")]
  3045.         public Color TextColor
  3046.         {
  3047.             get { return _TextColor; }
  3048.             set { _TextColor = value; }
  3049.         }
  3050.  
  3051.         public override Color ForeColor
  3052.         {
  3053.             get { return _TextColor; }
  3054.             set { _TextColor = value; }
  3055.         }
  3056.  
  3057.         protected override void OnMouseDown(MouseEventArgs e)
  3058.         {
  3059.             base.OnMouseDown(e);
  3060.             State = MouseState.Down;
  3061.             Invalidate();
  3062.         }
  3063.  
  3064.         protected override void OnMouseUp(MouseEventArgs e)
  3065.         {
  3066.             base.OnMouseUp(e);
  3067.             State = MouseState.Over;
  3068.             TB.Focus();
  3069.             Invalidate();
  3070.         }
  3071.  
  3072.         protected override void OnMouseEnter(EventArgs e)
  3073.         {
  3074.             base.OnMouseEnter(e);
  3075.             State = MouseState.Over;
  3076.             if (FocusOnHover) TB.Focus();
  3077.             Invalidate();
  3078.         }
  3079.  
  3080.         protected override void OnMouseLeave(EventArgs e)
  3081.         {
  3082.             base.OnMouseLeave(e);
  3083.             State = MouseState.None;
  3084.             Invalidate();
  3085.         }
  3086.  
  3087.         private Color _BaseColor = Color.FromArgb(45, 47, 49);
  3088.         private Color _TextColor = Color.FromArgb(192, 192, 192);
  3089.         private Color _BorderColor = Helpers.FlatColor;
  3090.  
  3091.         public FlatTextBox()
  3092.         {
  3093.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  3094.             DoubleBuffered = true;
  3095.  
  3096.             BackColor = Color.Transparent;
  3097.  
  3098.             TB = new System.Windows.Forms.TextBox();
  3099.             TB.Font = new Font("Segoe UI", 10);
  3100.             TB.Text = Text;
  3101.             TB.BackColor = _BaseColor;
  3102.             TB.ForeColor = _TextColor;
  3103.             TB.MaxLength = _MaxLength;
  3104.             TB.Multiline = _Multiline;
  3105.             TB.ReadOnly = _ReadOnly;
  3106.             TB.UseSystemPasswordChar = _UseSystemPasswordChar;
  3107.             TB.BorderStyle = BorderStyle.None;
  3108.             TB.Location = new Point(5, 5);
  3109.             TB.Width = Width - 10;
  3110.  
  3111.             TB.Cursor = Cursors.IBeam;
  3112.  
  3113.             if (_Multiline)
  3114.             {
  3115.                 TB.Height = Height - 11;
  3116.             }
  3117.             else
  3118.             {
  3119.                 Height = TB.Height + 11;
  3120.             }
  3121.  
  3122.             TB.TextChanged += OnBaseTextChanged;
  3123.             TB.KeyDown += OnBaseKeyDown;
  3124.         }
  3125.  
  3126.         protected override void OnPaint(PaintEventArgs e)
  3127.         {
  3128.             this.UpdateColors();
  3129.  
  3130.             Bitmap B = new Bitmap(Width, Height);
  3131.             Graphics G = Graphics.FromImage(B);
  3132.             W = Width - 1;
  3133.             H = Height - 1;
  3134.  
  3135.             Rectangle Base = new Rectangle(0, 0, W, H);
  3136.  
  3137.             var _with12 = G;
  3138.             _with12.SmoothingMode = SmoothingMode.HighQuality;
  3139.             _with12.PixelOffsetMode = PixelOffsetMode.HighQuality;
  3140.             _with12.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  3141.             _with12.Clear(BackColor);
  3142.  
  3143.             //-- Colors
  3144.             TB.BackColor = _BaseColor;
  3145.             TB.ForeColor = _TextColor;
  3146.  
  3147.             //-- Base
  3148.             _with12.FillRectangle(new SolidBrush(_BaseColor), Base);
  3149.  
  3150.             base.OnPaint(e);
  3151.             G.Dispose();
  3152.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  3153.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  3154.             B.Dispose();
  3155.         }
  3156.  
  3157.         private void UpdateColors()
  3158.         {
  3159.             FlatColors colors = Helpers.GetColors(this);
  3160.  
  3161.             _BorderColor = colors.Flat;
  3162.         }
  3163.     }
  3164. }
  3165. namespace FlatUI
  3166. {
  3167.     [DefaultEvent("CheckedChanged")]
  3168.     public class FlatToggle : Control
  3169.     {
  3170.         private int W;
  3171.         private int H;
  3172.         private _Options O;
  3173.         private bool _Checked = false;
  3174.         private MouseState State = MouseState.None;
  3175.  
  3176.         public event CheckedChangedEventHandler CheckedChanged;
  3177.         public delegate void CheckedChangedEventHandler(object sender);
  3178.  
  3179.         [Flags()]
  3180.         public enum _Options
  3181.         {
  3182.             Style1,
  3183.             Style2,
  3184.             Style3,
  3185.             Style4,
  3186.             //-- TODO: New Style
  3187.             Style5
  3188.             //-- TODO: New Style
  3189.         }
  3190.  
  3191.         [Category("Options")]
  3192.         public _Options Options
  3193.         {
  3194.             get { return O; }
  3195.             set { O = value; }
  3196.         }
  3197.  
  3198.         [Category("Options")]
  3199.         public bool Checked
  3200.         {
  3201.             get { return _Checked; }
  3202.             set { _Checked = value; }
  3203.         }
  3204.  
  3205.         protected override void OnTextChanged(EventArgs e)
  3206.         {
  3207.             base.OnTextChanged(e);
  3208.             Invalidate();
  3209.         }
  3210.  
  3211.         protected override void OnResize(EventArgs e)
  3212.         {
  3213.             base.OnResize(e);
  3214.             Width = 76;
  3215.             Height = 33;
  3216.         }
  3217.  
  3218.         protected override void OnMouseEnter(System.EventArgs e)
  3219.         {
  3220.             base.OnMouseEnter(e);
  3221.             State = MouseState.Over;
  3222.             Invalidate();
  3223.         }
  3224.  
  3225.         protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
  3226.         {
  3227.             base.OnMouseDown(e);
  3228.             State = MouseState.Down;
  3229.             Invalidate();
  3230.         }
  3231.  
  3232.         protected override void OnMouseLeave(System.EventArgs e)
  3233.         {
  3234.             base.OnMouseLeave(e);
  3235.             State = MouseState.None;
  3236.             Invalidate();
  3237.         }
  3238.         protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
  3239.         {
  3240.             base.OnMouseUp(e);
  3241.             State = MouseState.Over;
  3242.             Invalidate();
  3243.         }
  3244.  
  3245.         protected override void OnClick(EventArgs e)
  3246.         {
  3247.             base.OnClick(e);
  3248.             _Checked = !_Checked;
  3249.             if (CheckedChanged != null)
  3250.             {
  3251.                 CheckedChanged(this);
  3252.             }
  3253.         }
  3254.  
  3255.         private Color BaseColor = Helpers.FlatColor;
  3256.         private Color BaseColorRed = Color.FromArgb(220, 85, 96);
  3257.         private Color BGColor = Color.FromArgb(84, 85, 86);
  3258.         private Color ToggleColor = Color.FromArgb(45, 47, 49);
  3259.         private Color TextColor = Color.FromArgb(243, 243, 243);
  3260.  
  3261.         public FlatToggle()
  3262.         {
  3263.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  3264.             DoubleBuffered = true;
  3265.             BackColor = Color.Transparent;
  3266.             Size = new Size(44, Height + 1);
  3267.             Cursor = Cursors.Hand;
  3268.             Font = new Font("Segoe UI", 10);
  3269.             Size = new Size(76, 33);
  3270.         }
  3271.  
  3272.         protected override void OnPaint(PaintEventArgs e)
  3273.         {
  3274.             this.UpdateColors();
  3275.  
  3276.             Bitmap B = new Bitmap(Width, Height);
  3277.             Graphics G = Graphics.FromImage(B);
  3278.             W = Width - 1;
  3279.             H = Height - 1;
  3280.  
  3281.             GraphicsPath GP = new GraphicsPath();
  3282.             GraphicsPath GP2 = new GraphicsPath();
  3283.             Rectangle Base = new Rectangle(0, 0, W, H);
  3284.             Rectangle Toggle = new Rectangle(Convert.ToInt32(W / 2), 0, 38, H);
  3285.  
  3286.             var _with9 = G;
  3287.             _with9.SmoothingMode = SmoothingMode.HighQuality;
  3288.             _with9.PixelOffsetMode = PixelOffsetMode.HighQuality;
  3289.             _with9.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  3290.             _with9.Clear(BackColor);
  3291.  
  3292.             switch (O)
  3293.             {
  3294.                 case _Options.Style1:
  3295.                     //-- Style 1
  3296.                     //-- Base
  3297.                     GP = Helpers.RoundRec(Base, 6);
  3298.                     GP2 = Helpers.RoundRec(Toggle, 6);
  3299.                     _with9.FillPath(new SolidBrush(BGColor), GP);
  3300.                     _with9.FillPath(new SolidBrush(ToggleColor), GP2);
  3301.  
  3302.                     //-- Text
  3303.                     _with9.DrawString("OFF", Font, new SolidBrush(BGColor), new Rectangle(19, 1, W, H), Helpers.CenterSF);
  3304.  
  3305.                     if (Checked)
  3306.                     {
  3307.                         //-- Base
  3308.                         GP = Helpers.RoundRec(Base, 6);
  3309.                         GP2 = Helpers.RoundRec(new Rectangle(Convert.ToInt32(W / 2), 0, 38, H), 6);
  3310.                         _with9.FillPath(new SolidBrush(ToggleColor), GP);
  3311.                         _with9.FillPath(new SolidBrush(BaseColor), GP2);
  3312.  
  3313.                         //-- Text
  3314.                         _with9.DrawString("ON", Font, new SolidBrush(BaseColor), new Rectangle(8, 7, W, H), Helpers.NearSF);
  3315.                     }
  3316.                     break;
  3317.                 case _Options.Style2:
  3318.                     //-- Style 2
  3319.                     //-- Base
  3320.                     GP = Helpers.RoundRec(Base, 6);
  3321.                     Toggle = new Rectangle(4, 4, 36, H - 8);
  3322.                     GP2 = Helpers.RoundRec(Toggle, 4);
  3323.                     _with9.FillPath(new SolidBrush(BaseColorRed), GP);
  3324.                     _with9.FillPath(new SolidBrush(ToggleColor), GP2);
  3325.  
  3326.                     //-- Lines
  3327.                     _with9.DrawLine(new Pen(BGColor), 18, 20, 18, 12);
  3328.                     _with9.DrawLine(new Pen(BGColor), 22, 20, 22, 12);
  3329.                     _with9.DrawLine(new Pen(BGColor), 26, 20, 26, 12);
  3330.  
  3331.                     //-- Text
  3332.                     _with9.DrawString("r", new Font("Marlett", 8), new SolidBrush(TextColor), new Rectangle(19, 2, Width, Height), Helpers.CenterSF);
  3333.  
  3334.                     if (Checked)
  3335.                     {
  3336.                         GP = Helpers.RoundRec(Base, 6);
  3337.                         Toggle = new Rectangle(Convert.ToInt32(W / 2) - 2, 4, 36, H - 8);
  3338.                         GP2 = Helpers.RoundRec(Toggle, 4);
  3339.                         _with9.FillPath(new SolidBrush(BaseColor), GP);
  3340.                         _with9.FillPath(new SolidBrush(ToggleColor), GP2);
  3341.  
  3342.                         //-- Lines
  3343.                         _with9.DrawLine(new Pen(BGColor), Convert.ToInt32(W / 2) + 12, 20, Convert.ToInt32(W / 2) + 12, 12);
  3344.                         _with9.DrawLine(new Pen(BGColor), Convert.ToInt32(W / 2) + 16, 20, Convert.ToInt32(W / 2) + 16, 12);
  3345.                         _with9.DrawLine(new Pen(BGColor), Convert.ToInt32(W / 2) + 20, 20, Convert.ToInt32(W / 2) + 20, 12);
  3346.  
  3347.                         //-- Text
  3348.                         _with9.DrawString("ΓΌ", new Font("Wingdings", 14), new SolidBrush(TextColor), new Rectangle(8, 7, Width, Height), Helpers.NearSF);
  3349.                     }
  3350.                     break;
  3351.                 case _Options.Style3:
  3352.                     //-- Style 3
  3353.                     //-- Base
  3354.                     GP = Helpers.RoundRec(Base, 16);
  3355.                     Toggle = new Rectangle(W - 28, 4, 22, H - 8);
  3356.                     GP2.AddEllipse(Toggle);
  3357.                     _with9.FillPath(new SolidBrush(ToggleColor), GP);
  3358.                     _with9.FillPath(new SolidBrush(BaseColorRed), GP2);
  3359.  
  3360.                     //-- Text
  3361.                     _with9.DrawString("OFF", Font, new SolidBrush(BaseColorRed), new Rectangle(-12, 2, W, H), Helpers.CenterSF);
  3362.  
  3363.                     if (Checked)
  3364.                     {
  3365.                         //-- Base
  3366.                         GP = Helpers.RoundRec(Base, 16);
  3367.                         Toggle = new Rectangle(6, 4, 22, H - 8);
  3368.                         GP2.Reset();
  3369.                         GP2.AddEllipse(Toggle);
  3370.                         _with9.FillPath(new SolidBrush(ToggleColor), GP);
  3371.                         _with9.FillPath(new SolidBrush(BaseColor), GP2);
  3372.  
  3373.                         //-- Text
  3374.                         _with9.DrawString("ON", Font, new SolidBrush(BaseColor), new Rectangle(12, 2, W, H), Helpers.CenterSF);
  3375.                     }
  3376.                     break;
  3377.                 case _Options.Style4:
  3378.                     //-- TODO: New Styles
  3379.                     if (Checked)
  3380.                     {
  3381.                         //--
  3382.                     }
  3383.                     break;
  3384.                 case _Options.Style5:
  3385.                     //-- TODO: New Styles
  3386.                     if (Checked)
  3387.                     {
  3388.                         //--
  3389.                     }
  3390.                     break;
  3391.             }
  3392.  
  3393.             base.OnPaint(e);
  3394.             G.Dispose();
  3395.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  3396.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  3397.             B.Dispose();
  3398.         }
  3399.  
  3400.         private void UpdateColors()
  3401.         {
  3402.             FlatColors colors = Helpers.GetColors(this);
  3403.  
  3404.             BaseColor = colors.Flat;
  3405.         }
  3406.     }
  3407. }
  3408. namespace FlatUI
  3409. {
  3410.     [DefaultEvent("Scroll")]
  3411.     public class FlatTrackBar : Control
  3412.     {
  3413.         private int W;
  3414.         private int H;
  3415.         private int Val;
  3416.         private bool Bool;
  3417.         private Rectangle Track;
  3418.         private Rectangle Knob;
  3419.         private _Style Style_;
  3420.  
  3421.         protected override void OnMouseDown(MouseEventArgs e)
  3422.         {
  3423.             base.OnMouseDown(e);
  3424.             if (e.Button == System.Windows.Forms.MouseButtons.Left)
  3425.             {
  3426.                 Val = Convert.ToInt32((float)(_Value - _Minimum) / (float)(_Maximum - _Minimum) * (float)(Width - 11));
  3427.                 Track = new Rectangle(Val, 0, 10, 20);
  3428.  
  3429.                 Bool = Track.Contains(e.Location);
  3430.             }
  3431.         }
  3432.  
  3433.         protected override void OnMouseMove(MouseEventArgs e)
  3434.         {
  3435.             base.OnMouseMove(e);
  3436.             if (Bool && e.X > -1 && e.X < (Width + 1))
  3437.             {
  3438.                 Value = _Minimum + Convert.ToInt32((float)(_Maximum - _Minimum) * ((float)e.X / (float)Width));
  3439.             }
  3440.         }
  3441.  
  3442.         protected override void OnMouseUp(MouseEventArgs e)
  3443.         {
  3444.             base.OnMouseUp(e);
  3445.             Bool = false;
  3446.         }
  3447.  
  3448.         [Flags()]
  3449.         public enum _Style
  3450.         {
  3451.             Slider,
  3452.             Knob
  3453.         }
  3454.  
  3455.         public _Style Style
  3456.         {
  3457.             get { return Style_; }
  3458.             set { Style_ = value; }
  3459.         }
  3460.  
  3461.         [Category("Colors")]
  3462.         public Color TrackColor
  3463.         {
  3464.             get { return _TrackColor; }
  3465.             set { _TrackColor = value; }
  3466.         }
  3467.  
  3468.         [Category("Colors")]
  3469.         public Color HatchColor
  3470.         {
  3471.             get { return _HatchColor; }
  3472.             set { _HatchColor = value; }
  3473.         }
  3474.  
  3475.         public event ScrollEventHandler Scroll;
  3476.         public delegate void ScrollEventHandler(object sender);
  3477.  
  3478.         private int _Minimum;
  3479.         public int Minimum
  3480.         {
  3481.             get
  3482.             {
  3483.                 int functionReturnValue = 0;
  3484.                 return functionReturnValue;
  3485.                 return functionReturnValue;
  3486.             }
  3487.             set
  3488.             {
  3489.                 if (value < 0)
  3490.                 {
  3491.                 }
  3492.  
  3493.                 _Minimum = value;
  3494.  
  3495.                 if (value > _Value)
  3496.                     _Value = value;
  3497.                 if (value > _Maximum)
  3498.                     _Maximum = value;
  3499.                 Invalidate();
  3500.             }
  3501.         }
  3502.  
  3503.         private int _Maximum = 10;
  3504.         public int Maximum
  3505.         {
  3506.             get { return _Maximum; }
  3507.             set
  3508.             {
  3509.                 if (value < 0)
  3510.                 {
  3511.                 }
  3512.  
  3513.                 _Maximum = value;
  3514.                 if (value < _Value)
  3515.                     _Value = value;
  3516.                 if (value < _Minimum)
  3517.                     _Minimum = value;
  3518.                 Invalidate();
  3519.             }
  3520.         }
  3521.  
  3522.         private int _Value;
  3523.         public int Value
  3524.         {
  3525.             get { return _Value; }
  3526.             set
  3527.             {
  3528.                 if (value == _Value)
  3529.                     return;
  3530.  
  3531.                 if (value > _Maximum || value < _Minimum)
  3532.                 {
  3533.                 }
  3534.  
  3535.                 _Value = value;
  3536.                 Invalidate();
  3537.                 if (Scroll != null)
  3538.                 {
  3539.                     Scroll(this);
  3540.                 }
  3541.             }
  3542.         }
  3543.  
  3544.         private bool _ShowValue = false;
  3545.         public bool ShowValue
  3546.         {
  3547.             get { return _ShowValue; }
  3548.             set { _ShowValue = value; }
  3549.         }
  3550.  
  3551.         protected override void OnKeyDown(KeyEventArgs e)
  3552.         {
  3553.             base.OnKeyDown(e);
  3554.             if (e.KeyCode == Keys.Subtract)
  3555.             {
  3556.                 if (Value == 0)
  3557.                     return;
  3558.                 Value -= 1;
  3559.             }
  3560.             else if (e.KeyCode == Keys.Add)
  3561.             {
  3562.                 if (Value == _Maximum)
  3563.                     return;
  3564.                 Value += 1;
  3565.             }
  3566.         }
  3567.  
  3568.         protected override void OnTextChanged(EventArgs e)
  3569.         {
  3570.             base.OnTextChanged(e);
  3571.             Invalidate();
  3572.         }
  3573.  
  3574.         protected override void OnResize(EventArgs e)
  3575.         {
  3576.             base.OnResize(e);
  3577.             Height = 23;
  3578.         }
  3579.  
  3580.         private Color BaseColor = Color.FromArgb(45, 47, 49);
  3581.         private Color _TrackColor = Helpers.FlatColor;
  3582.         private Color SliderColor = Color.FromArgb(25, 27, 29);
  3583.         private Color _HatchColor = Color.FromArgb(23, 148, 92);
  3584.  
  3585.         public FlatTrackBar()
  3586.         {
  3587.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  3588.             DoubleBuffered = true;
  3589.             Height = 18;
  3590.  
  3591.             BackColor = Color.FromArgb(60, 70, 73);
  3592.         }
  3593.  
  3594.         protected override void OnPaint(PaintEventArgs e)
  3595.         {
  3596.             this.UpdateColors();
  3597.  
  3598.             Bitmap B = new Bitmap(Width, Height);
  3599.             Graphics G = Graphics.FromImage(B);
  3600.             W = Width - 1;
  3601.             H = Height - 1;
  3602.  
  3603.             Rectangle Base = new Rectangle(1, 6, W - 2, 8);
  3604.             GraphicsPath GP = new GraphicsPath();
  3605.             GraphicsPath GP2 = new GraphicsPath();
  3606.  
  3607.             var _with20 = G;
  3608.             _with20.SmoothingMode = SmoothingMode.HighQuality;
  3609.             _with20.PixelOffsetMode = PixelOffsetMode.HighQuality;
  3610.             _with20.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  3611.             _with20.Clear(BackColor);
  3612.  
  3613.             //-- Value
  3614.             Val = Convert.ToInt32((float)(_Value - _Minimum) / (float)(_Maximum - _Minimum) * (float)(W - 10));
  3615.             Track = new Rectangle(Val, 0, 10, 20);
  3616.             Knob = new Rectangle(Val, 4, 11, 14);
  3617.  
  3618.             //-- Base
  3619.             GP.AddRectangle(Base);
  3620.             _with20.SetClip(GP);
  3621.             _with20.FillRectangle(new SolidBrush(BaseColor), new Rectangle(0, 7, W, 8));
  3622.             _with20.FillRectangle(new SolidBrush(_TrackColor), new Rectangle(0, 7, Track.X + Track.Width, 8));
  3623.             _with20.ResetClip();
  3624.  
  3625.             //-- Hatch Brush
  3626.             HatchBrush HB = new HatchBrush(HatchStyle.Plaid, HatchColor, _TrackColor);
  3627.             _with20.FillRectangle(HB, new Rectangle(-10, 7, Track.X + Track.Width, 8));
  3628.  
  3629.             //-- Slider/Knob
  3630.             switch (Style)
  3631.             {
  3632.                 case _Style.Slider:
  3633.                     GP2.AddRectangle(Track);
  3634.                     _with20.FillPath(new SolidBrush(SliderColor), GP2);
  3635.                     break;
  3636.                 case _Style.Knob:
  3637.                     GP2.AddEllipse(Knob);
  3638.                     _with20.FillPath(new SolidBrush(SliderColor), GP2);
  3639.                     break;
  3640.             }
  3641.  
  3642.             //-- Show the value
  3643.             if (ShowValue)
  3644.             {
  3645.                 _with20.DrawString(Value.ToString(), new Font("Segoe UI", 8), Brushes.White, new Rectangle(1, 6, W, H), new StringFormat
  3646.                 {
  3647.                     Alignment = StringAlignment.Far,
  3648.                     LineAlignment = StringAlignment.Far
  3649.                 });
  3650.             }
  3651.  
  3652.             base.OnPaint(e);
  3653.             G.Dispose();
  3654.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  3655.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  3656.             B.Dispose();
  3657.         }
  3658.  
  3659.         private void UpdateColors()
  3660.         {
  3661.             FlatColors colors = Helpers.GetColors(this);
  3662.  
  3663.             _TrackColor = colors.Flat;
  3664.         }
  3665.     }
  3666. }
  3667. namespace FlatUI
  3668. {
  3669.     public class FlatTreeView : TreeView
  3670.     {
  3671.         private TreeNodeStates State;
  3672.  
  3673.         protected override void OnDrawNode(DrawTreeNodeEventArgs e)
  3674.         {
  3675.             try
  3676.             {
  3677.                 Rectangle Bounds = new Rectangle(e.Bounds.Location.X, e.Bounds.Location.Y, e.Bounds.Width, e.Bounds.Height);
  3678.                 //e.Node.Nodes.Item.
  3679.                 switch (State)
  3680.                 {
  3681.                     case TreeNodeStates.Default:
  3682.                         e.Graphics.FillRectangle(Brushes.Red, Bounds);
  3683.                         e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8), Brushes.LimeGreen, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), Helpers.NearSF);
  3684.                         Invalidate();
  3685.                         break;
  3686.                     case TreeNodeStates.Checked:
  3687.                         e.Graphics.FillRectangle(Brushes.Green, Bounds);
  3688.                         e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8), Brushes.Black, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), Helpers.NearSF);
  3689.                         Invalidate();
  3690.                         break;
  3691.                     case TreeNodeStates.Selected:
  3692.                         e.Graphics.FillRectangle(Brushes.Green, Bounds);
  3693.                         e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8), Brushes.Black, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), Helpers.NearSF);
  3694.                         Invalidate();
  3695.                         break;
  3696.                 }
  3697.  
  3698.             }
  3699.             catch (Exception ex)
  3700.             {
  3701.                 MessageBox.Show(ex.Message);
  3702.             }
  3703.  
  3704.             base.OnDrawNode(e);
  3705.         }
  3706.  
  3707.         private Color _BaseColor = Color.FromArgb(45, 47, 49);
  3708.         private Color _LineColor = Color.FromArgb(25, 27, 29);
  3709.  
  3710.         public FlatTreeView()
  3711.         {
  3712.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  3713.             DoubleBuffered = true;
  3714.  
  3715.             BackColor = _BaseColor;
  3716.             ForeColor = Color.White;
  3717.             LineColor = _LineColor;
  3718.             DrawMode = TreeViewDrawMode.OwnerDrawAll;
  3719.         }
  3720.  
  3721.         protected override void OnPaint(PaintEventArgs e)
  3722.         {
  3723.             Bitmap B = new Bitmap(Width, Height);
  3724.             Graphics G = Graphics.FromImage(B);
  3725.  
  3726.             Rectangle Base = new Rectangle(0, 0, Width, Height);
  3727.  
  3728.             var _with22 = G;
  3729.             _with22.SmoothingMode = SmoothingMode.HighQuality;
  3730.             _with22.PixelOffsetMode = PixelOffsetMode.HighQuality;
  3731.             _with22.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  3732.             _with22.Clear(BackColor);
  3733.  
  3734.             _with22.FillRectangle(new SolidBrush(_BaseColor), Base);
  3735.             _with22.DrawString(Text, new Font("Segoe UI", 8), Brushes.Black, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), Helpers.NearSF);
  3736.  
  3737.  
  3738.             base.OnPaint(e);
  3739.             G.Dispose();
  3740.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  3741.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  3742.             B.Dispose();
  3743.         }
  3744.     }
  3745. }
  3746. namespace FlatUI
  3747. {
  3748.     public class FormSkin : ContainerControl
  3749.     {
  3750.         private int W;
  3751.         private int H;
  3752.         private bool Cap = false;
  3753.         private bool _HeaderMaximize = false;
  3754.         private Point MousePoint = new Point(0, 0);
  3755.         private int MoveHeight = 50;
  3756.  
  3757.         [Category("Colors")]
  3758.         public Color HeaderColor
  3759.         {
  3760.             get { return _HeaderColor; }
  3761.             set { _HeaderColor = value; }
  3762.         }
  3763.  
  3764.         [Category("Colors")]
  3765.         public Color BaseColor
  3766.         {
  3767.             get { return _BaseColor; }
  3768.             set { _BaseColor = value; }
  3769.         }
  3770.  
  3771.         [Category("Colors")]
  3772.         public Color BorderColor
  3773.         {
  3774.             get { return _BorderColor; }
  3775.             set { _BorderColor = value; }
  3776.         }
  3777.  
  3778.         [Category("Colors")]
  3779.         public Color FlatColor
  3780.         {
  3781.             // get { return Helpers.FlatColor; }
  3782.             // set { Helpers.FlatColor = value; }
  3783.             get { return _FlatColor; }
  3784.             set { _FlatColor = value; }
  3785.         }
  3786.  
  3787.         [Category("Options")]
  3788.         public bool HeaderMaximize
  3789.         {
  3790.             get { return _HeaderMaximize; }
  3791.             set { _HeaderMaximize = value; }
  3792.         }
  3793.  
  3794.         protected override void OnMouseDown(MouseEventArgs e)
  3795.         {
  3796.             base.OnMouseDown(e);
  3797.             if (e.Button == System.Windows.Forms.MouseButtons.Left & new Rectangle(0, 0, Width, MoveHeight).Contains(e.Location))
  3798.             {
  3799.                 Cap = true;
  3800.                 MousePoint = e.Location;
  3801.             }
  3802.         }
  3803.  
  3804.         private void FormSkin_MouseDoubleClick(object sender, MouseEventArgs e)
  3805.         {
  3806.             if (HeaderMaximize)
  3807.             {
  3808.                 if (e.Button == System.Windows.Forms.MouseButtons.Left & new Rectangle(0, 0, Width, MoveHeight).Contains(e.Location))
  3809.                 {
  3810.                     if (FindForm().WindowState == FormWindowState.Normal)
  3811.                     {
  3812.                         FindForm().WindowState = FormWindowState.Maximized;
  3813.                         FindForm().Refresh();
  3814.                     }
  3815.                     else if (FindForm().WindowState == FormWindowState.Maximized)
  3816.                     {
  3817.                         FindForm().WindowState = FormWindowState.Normal;
  3818.                         FindForm().Refresh();
  3819.                     }
  3820.                 }
  3821.             }
  3822.         }
  3823.  
  3824.         protected override void OnMouseUp(MouseEventArgs e)
  3825.         {
  3826.             base.OnMouseUp(e);
  3827.             Cap = false;
  3828.         }
  3829.  
  3830.         protected override void OnMouseMove(MouseEventArgs e)
  3831.         {
  3832.             base.OnMouseMove(e);
  3833.             if (Cap)
  3834.             {
  3835.                 // Parent.Location = MousePosition - MousePoint;
  3836.                 Parent.Location = new Point(
  3837.                     MousePosition.X - MousePoint.X,
  3838.                     MousePosition.Y - MousePoint.Y
  3839.                 );
  3840.             }
  3841.         }
  3842.  
  3843.         protected override void OnCreateControl()
  3844.         {
  3845.             base.OnCreateControl();
  3846.             ParentForm.FormBorderStyle = FormBorderStyle.None;
  3847.             ParentForm.AllowTransparency = false;
  3848.             ParentForm.TransparencyKey = Color.Fuchsia;
  3849.             ParentForm.FindForm().StartPosition = FormStartPosition.CenterScreen;
  3850.             Dock = DockStyle.Fill;
  3851.             Invalidate();
  3852.         }
  3853.  
  3854.         private Color _HeaderColor = Color.FromArgb(45, 47, 49);
  3855.         private Color _BaseColor = Color.FromArgb(60, 70, 73);
  3856.         private Color _BorderColor = Color.FromArgb(53, 58, 60);
  3857.         private Color _FlatColor = Helpers.FlatColor;
  3858.         private Color TextColor = Color.FromArgb(234, 234, 234);
  3859.  
  3860.         private Color _HeaderLight = Color.FromArgb(171, 171, 172);
  3861.         private Color _BaseLight = Color.FromArgb(196, 199, 200);
  3862.         public Color TextLight = Color.FromArgb(45, 47, 49);
  3863.  
  3864.         public FormSkin()
  3865.         {
  3866.             MouseDoubleClick += FormSkin_MouseDoubleClick;
  3867.             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
  3868.             DoubleBuffered = true;
  3869.             BackColor = Color.White;
  3870.             Font = new Font("Segoe UI", 12);
  3871.         }
  3872.  
  3873.         protected override void OnPaint(PaintEventArgs e)
  3874.         {
  3875.             Bitmap B = new Bitmap(Width, Height);
  3876.             Graphics G = Graphics.FromImage(B);
  3877.             W = Width;
  3878.             H = Height;
  3879.  
  3880.             Rectangle Base = new Rectangle(0, 0, W, H);
  3881.             Rectangle Header = new Rectangle(0, 0, W, 50);
  3882.  
  3883.             var _with2 = G;
  3884.             _with2.SmoothingMode = SmoothingMode.HighQuality;
  3885.             _with2.PixelOffsetMode = PixelOffsetMode.HighQuality;
  3886.             _with2.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  3887.             _with2.Clear(BackColor);
  3888.  
  3889.             //-- Base
  3890.             _with2.FillRectangle(new SolidBrush(_BaseColor), Base);
  3891.  
  3892.             //-- Header
  3893.             _with2.FillRectangle(new SolidBrush(_HeaderColor), Header);
  3894.  
  3895.             //-- Logo
  3896.             _with2.FillRectangle(new SolidBrush(Color.FromArgb(243, 243, 243)), new Rectangle(8, 16, 4, 18));
  3897.             _with2.FillRectangle(new SolidBrush(FlatColor), 16, 16, 4, 18);
  3898.             _with2.DrawString(Text, Font, new SolidBrush(TextColor), new Rectangle(26, 15, W, H), Helpers.NearSF);
  3899.  
  3900.             //-- Border
  3901.             _with2.DrawRectangle(new Pen(_BorderColor), Base);
  3902.  
  3903.             base.OnPaint(e);
  3904.             G.Dispose();
  3905.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  3906.             e.Graphics.DrawImageUnscaled(B, 0, 0);
  3907.             B.Dispose();
  3908.         }
  3909.     }
  3910. }
  3911. namespace FlatUI
  3912. {
  3913.     public static class Helpers
  3914.     {
  3915.         public static Color FlatColor = Color.FromArgb(35, 168, 109);
  3916.  
  3917.         public static readonly StringFormat NearSF = new StringFormat
  3918.         {
  3919.             Alignment = StringAlignment.Near,
  3920.             LineAlignment = StringAlignment.Near
  3921.         };
  3922.  
  3923.         public static readonly StringFormat CenterSF = new StringFormat
  3924.         {
  3925.             Alignment = StringAlignment.Center,
  3926.             LineAlignment = StringAlignment.Center
  3927.         };
  3928.  
  3929.         public static GraphicsPath RoundRec(Rectangle Rectangle, int Curve)
  3930.         {
  3931.             GraphicsPath P = new GraphicsPath();
  3932.             int ArcRectangleWidth = Curve * 2;
  3933.             P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
  3934.             P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
  3935.             P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
  3936.             P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
  3937.             P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
  3938.             return P;
  3939.         }
  3940.  
  3941.         public static GraphicsPath RoundRect(float x, float y, float w, float h, double r = 0.3,
  3942.             bool TL = true, bool TR = true, bool BR = true, bool BL = true)
  3943.         {
  3944.             GraphicsPath functionReturnValue = null;
  3945.             float d = Math.Min(w, h) * (float)r;
  3946.             float xw = x + w;
  3947.             float yh = y + h;
  3948.             functionReturnValue = new GraphicsPath();
  3949.  
  3950.             var _with1 = functionReturnValue;
  3951.             if (TL)
  3952.                 _with1.AddArc(x, y, d, d, 180, 90);
  3953.             else
  3954.                 _with1.AddLine(x, y, x, y);
  3955.             if (TR)
  3956.                 _with1.AddArc(xw - d, y, d, d, 270, 90);
  3957.             else
  3958.                 _with1.AddLine(xw, y, xw, y);
  3959.             if (BR)
  3960.                 _with1.AddArc(xw - d, yh - d, d, d, 0, 90);
  3961.             else
  3962.                 _with1.AddLine(xw, yh, xw, yh);
  3963.             if (BL)
  3964.                 _with1.AddArc(x, yh - d, d, d, 90, 90);
  3965.             else
  3966.                 _with1.AddLine(x, yh, x, yh);
  3967.  
  3968.             _with1.CloseFigure();
  3969.             return functionReturnValue;
  3970.         }
  3971.  
  3972.         //-- Credit: AeonHack
  3973.         public static GraphicsPath DrawArrow(int x, int y, bool flip)
  3974.         {
  3975.             GraphicsPath GP = new GraphicsPath();
  3976.  
  3977.             int W = 12;
  3978.             int H = 6;
  3979.  
  3980.             if (flip)
  3981.             {
  3982.                 GP.AddLine(x + 1, y, x + W + 1, y);
  3983.                 GP.AddLine(x + W, y, x + H, y + H - 1);
  3984.             }
  3985.             else
  3986.             {
  3987.                 GP.AddLine(x, y + H, x + W, y + H);
  3988.                 GP.AddLine(x + W, y + H, x + H, y);
  3989.             }
  3990.  
  3991.             GP.CloseFigure();
  3992.             return GP;
  3993.         }
  3994.  
  3995.         /// <summary>
  3996.         /// Get the colorscheme of a Control from a parent FormSkin.
  3997.         /// </summary>
  3998.         /// <param name="control">Control</param>
  3999.         /// <returns>Colors</returns>
  4000.         /// <exception cref="System.ArgumentNullException"></exception>
  4001.         public static FlatColors GetColors(Control control)
  4002.         {
  4003.             if (control == null)
  4004.                 throw new ArgumentNullException();
  4005.  
  4006.             FlatColors colors = new FlatColors();
  4007.  
  4008.             while (control != null && (control.GetType() != typeof(FormSkin)))
  4009.             {
  4010.                 control = control.Parent;
  4011.             }
  4012.  
  4013.             if (control != null)
  4014.             {
  4015.                 FormSkin skin = (FormSkin)control;
  4016.                 colors.Flat = skin.FlatColor;
  4017.             }
  4018.  
  4019.             return colors;
  4020.         }
  4021.     }
  4022. }
  4023. namespace FlatUI
  4024. {
  4025.     public enum MouseState : byte
  4026.     {
  4027.         None = 0,
  4028.         Over = 1,
  4029.         Down = 2,
  4030.         Block = 3
  4031.     }
  4032. }
Add Comment
Please, Sign In to add comment