THE_LORD

Modal Theme

Jan 15th, 2017
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 96.84 KB | None | 0 0
  1. /// <summary>
  2. /// Modal Theme
  3. /// Author : THE LORD
  4. /// Release Date : Monday, January 16, 2017
  5. /// HF Account : https://hackforums.net/member.php?action=profile&uid=3304362
  6. /// PM Me for any bug.
  7. /// </summary>
  8.  
  9. #region NampeSpaces
  10.  
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Text;
  14. using System.Drawing.Drawing2D;
  15. using System.Windows.Forms;
  16. using System.Drawing;
  17. using System.ComponentModel;
  18.  
  19. #endregion
  20.  
  21. #region Helper Methods
  22.  
  23. public class HelperMethods
  24. {
  25.  
  26.     public GraphicsPath GP = null;
  27.  
  28.     public enum MouseMode
  29.     {
  30.         NormalMode,
  31.         Hovered,
  32.         Pushed
  33.     };
  34.  
  35.     public void DrawImageFromBase64(Graphics G, string Base64Image, Rectangle Rect)
  36.     {
  37.         Image IM = null;
  38.         using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Convert.FromBase64String(Base64Image)))
  39.         {
  40.             IM = System.Drawing.Image.FromStream(ms);
  41.         }
  42.         G.DrawImage(IM, Rect);
  43.     }
  44.  
  45.     public GraphicsPath RoundRec(Rectangle r, int Curve, bool TopLeft = true, bool TopRight = true, bool BottomLeft = true, bool BottomRight = true)
  46.     {
  47.         GraphicsPath CreateRoundPath = new GraphicsPath(FillMode.Winding);
  48.         if (TopLeft)
  49.         {
  50.             CreateRoundPath.AddArc(r.X, r.Y, Curve, Curve, 180f, 90f);
  51.         }
  52.         else
  53.         {
  54.             CreateRoundPath.AddLine(r.X, r.Y, r.X, r.Y);
  55.         }
  56.         if (TopRight)
  57.         {
  58.             CreateRoundPath.AddArc(r.Right - Curve, r.Y, Curve, Curve, 270f, 90f);
  59.         }
  60.         else
  61.         {
  62.             CreateRoundPath.AddLine(r.Right - r.Width, r.Y, r.Width, r.Y);
  63.         }
  64.         if (BottomRight)
  65.         {
  66.             CreateRoundPath.AddArc(r.Right - Curve, r.Bottom - Curve, Curve, Curve, 0f, 90f);
  67.         }
  68.         else
  69.         {
  70.             CreateRoundPath.AddLine(r.Right, r.Bottom, r.Right, r.Bottom);
  71.  
  72.         }
  73.         if (BottomLeft)
  74.         {
  75.             CreateRoundPath.AddArc(r.X, r.Bottom - Curve, Curve, Curve, 90f, 90f);
  76.         }
  77.         else
  78.         {
  79.             CreateRoundPath.AddLine(r.X, r.Bottom, r.X, r.Bottom);
  80.         }
  81.         CreateRoundPath.CloseFigure();
  82.         return CreateRoundPath;
  83.     }
  84.  
  85.     public void FillRoundedPath(Graphics G, Color C, Rectangle Rect, int Curve)
  86.     {
  87.         G.FillPath(new SolidBrush(C), RoundRec(Rect, Curve));
  88.     }
  89.  
  90.     public void FillRoundedPath(Graphics G, Brush B, Rectangle Rect, int Curve)
  91.     {
  92.         G.FillPath(B, RoundRec(Rect, Curve));
  93.     }
  94.  
  95.     public void DrawRoundedPath(Graphics G, Color C, Single Size, Rectangle Rect, int Curve)
  96.     {
  97.         G.DrawPath(new Pen(C, Size), RoundRec(Rect, Curve));
  98.  
  99.     }
  100.  
  101.     public void DrawTriangle(Graphics G, Color C, Single Size, Point P1_0, Point P1_1, Point P2_0, Point P2_1, Point P3_0, Point P3_1)
  102.     {
  103.  
  104.         G.DrawLine(new Pen(C, Size), P1_0, P1_1);
  105.         G.DrawLine(new Pen(C, Size), P2_0, P2_1);
  106.         G.DrawLine(new Pen(C, Size), P3_0, P3_1);
  107.  
  108.     }
  109.  
  110.     public Pen PenRGBColor(int R, int G, int B, Single size)
  111.     { return new Pen(System.Drawing.Color.FromArgb(R, G, B), size); }
  112.  
  113.     public Pen PenHTMlColor(String C_WithoutHash, float Thick)
  114.     { return new Pen(GetHTMLColor(C_WithoutHash), Thick); }
  115.  
  116.     public SolidBrush SolidBrushRGBColor(int R, int G, int B, int A = 0)
  117.     { return new SolidBrush(System.Drawing.Color.FromArgb(A, R, G, B)); }
  118.  
  119.     public SolidBrush SolidBrushHTMlColor(String C_WithoutHash)
  120.     { return new SolidBrush(GetHTMLColor(C_WithoutHash)); }
  121.  
  122.     public Color GetHTMLColor(String C_WithoutHash)
  123.     { return ColorTranslator.FromHtml("#" + C_WithoutHash); }
  124.  
  125.     public String ColorToHTML(Color C)
  126.     { return ColorTranslator.ToHtml(C); }
  127.  
  128.     public Color SetARGB(int A, int R, int G, int B)
  129.     { return System.Drawing.Color.FromArgb(A, R, G, B); }
  130.  
  131.     public Color SetRGB(int R, int G, int B)
  132.     { return System.Drawing.Color.FromArgb(R, G, B); }
  133.  
  134.     public void CentreString(Graphics G, String Text, Font font, Brush brush, Rectangle Rect)
  135.     { G.DrawString(Text, font, brush, new Rectangle(Rect.X, Rect.Y, Rect.Width, Rect.Height), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); }
  136.  
  137.     public void LeftString(Graphics G, String Text, Font font, Brush brush, Rectangle Rect)
  138.     {
  139.         G.DrawString(Text, font, brush, new Rectangle(4, Rect.Y + Convert.ToInt32(Rect.Height / 2) - Convert.ToInt32(G.MeasureString(Text, font).Height / 2) + 0, Rect.Width, Rect.Height), new StringFormat { Alignment = StringAlignment.Near });
  140.     }
  141.  
  142.     public void RightString(Graphics G, string Text, Font font, Brush brush, Rectangle Rect)
  143.     {
  144.         G.DrawString(Text, font, brush, new Rectangle(4, Convert.ToInt32(Rect.Y + (Rect.Height / 2) - (G.MeasureString(Text, font).Height / 2)), Rect.Width - Rect.Height + 10, Rect.Height), new StringFormat { Alignment = StringAlignment.Far });
  145.     }
  146. }
  147.  
  148. #endregion
  149.  
  150. #region Skin
  151.  
  152. public class ModalTheme : ContainerControl
  153. {
  154.  
  155.     #region  Variables
  156.  
  157.     bool Movable = false;
  158.     private TitlePostion _TitleTextPostion = TitlePostion.Left;
  159.     private Point MousePoint = new Point(0, 0);
  160.     private int MoveHeight = 50;
  161.     private static HelperMethods H = new HelperMethods();
  162.     private int _BorderThickness = 1;
  163.     private bool _ShowIcon;
  164.  
  165.     #endregion
  166.  
  167.     #region Draw Control
  168.  
  169.     protected override void OnPaint(PaintEventArgs e)
  170.     {
  171.         using (Bitmap B = new Bitmap(Width, Height))
  172.         using (Graphics G = Graphics.FromImage(B))
  173.         {
  174.            
  175.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  176.  
  177.             G.FillRectangle(H.SolidBrushHTMlColor("331f35"), new Rectangle(0, 0, Width, Height));
  178.  
  179.             G.FillRectangle(H.SolidBrushHTMlColor("241525"), new Rectangle(0, 0, Width, 55));
  180.  
  181.             G.DrawLine(H.PenHTMlColor("231024", 1), new Point(0, 55), new Point(Width, 55));
  182.  
  183.             G.DrawRectangle(H.PenHTMlColor("241525", BorderThickness), new Rectangle(0, 0, Width, Height));
  184.  
  185.             if (FindForm().ShowIcon)
  186.             {
  187.                 if (FindForm().Icon != null)
  188.                 {
  189.                     switch (TitleTextPostion)
  190.                     {
  191.                         case TitlePostion.Left:
  192.                             G.DrawString(Text.ToUpper(), Font, H.SolidBrushHTMlColor("f3ebf3"), 27, 15);
  193.                             G.DrawIcon(FindForm().Icon, new Rectangle(5, 16, 20, 20));
  194.                             break;
  195.                         case TitlePostion.Center:
  196.                             H.CentreString(G, Text.ToUpper(), Font, H.SolidBrushHTMlColor("f3ebf3"), new Rectangle(0, 0, Width, 50));
  197.                             G.DrawIcon(FindForm().Icon, new Rectangle(5, 16, 20, 20));
  198.                             break;
  199.                         case TitlePostion.Right:
  200.                             H.RightString(G, Text.ToUpper(), Font, H.SolidBrushHTMlColor("f3ebf3"), new Rectangle(0, 0, Width, 50));
  201.                             G.DrawIcon(FindForm().Icon, new Rectangle(Width - 30, 16, 20, 20));
  202.                             break;
  203.                     }
  204.                 }
  205.  
  206.             }
  207.             else
  208.             {
  209.                 switch (TitleTextPostion)
  210.                 {
  211.                     case TitlePostion.Left:
  212.                         G.DrawString(Text.ToUpper(), Font, H.SolidBrushHTMlColor("f3ebf3"), 5, 17);
  213.                         break;
  214.                     case TitlePostion.Center:
  215.                         H.CentreString(G, Text.ToUpper(), Font, H.SolidBrushHTMlColor("f3ebf3"), new Rectangle(0, 2, Width, 50));
  216.                         break;
  217.                     case TitlePostion.Right:
  218.                         H.RightString(G, Text.ToUpper(), Font, H.SolidBrushHTMlColor("f3ebf3"), new Rectangle(0, 2, Width, 50));
  219.                         break;
  220.                 }
  221.             }
  222.  
  223.             e.Graphics.DrawImage(B, 0, 0);
  224.             G.Dispose();
  225.             B.Dispose();
  226.         }
  227.     }
  228.  
  229.     #endregion
  230.  
  231.     #region Constructors
  232.  
  233.     public ModalTheme()
  234.     {
  235.  
  236.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.ContainerControl, true);
  237.         DoubleBuffered = true;
  238.         Font = new Font("Ubuntu", 13, FontStyle.Bold);
  239.         UpdateStyles();
  240.  
  241.     }
  242.  
  243.     #endregion
  244.  
  245.     #region  Properties
  246.    
  247.     public int BorderThickness
  248.     {
  249.         get
  250.         {
  251.             return _BorderThickness;
  252.         }
  253.         set
  254.         {
  255.             _BorderThickness = value;
  256.             Invalidate();
  257.         }
  258.     }
  259.  
  260.     public bool ShowIcon
  261.     {
  262.         get { return _ShowIcon; }
  263.         set
  264.         {
  265.             if (value == _ShowIcon) { return; }
  266.             FindForm().ShowIcon = value;
  267.             Invalidate();
  268.             _ShowIcon = value;
  269.  
  270.         }
  271.     }
  272.  
  273.  
  274.     public TitlePostion TitleTextPostion
  275.     {
  276.         get { return _TitleTextPostion; }
  277.  
  278.         set
  279.         {
  280.             _TitleTextPostion = value;
  281.             Invalidate();
  282.         }
  283.  
  284.     }
  285.  
  286.  
  287.     public enum TitlePostion
  288.     {
  289.         Left,
  290.         Center,
  291.         Right
  292.     };
  293.  
  294.     #endregion
  295.  
  296.     #region Events
  297.  
  298.     protected override void OnCreateControl()
  299.     {
  300.  
  301.         base.OnCreateControl();
  302.         ParentForm.FormBorderStyle = FormBorderStyle.None;
  303.         ParentForm.Dock = DockStyle.None;
  304.         Dock = DockStyle.Fill;
  305.         Invalidate();
  306.  
  307.     }
  308.  
  309.     protected override void OnMouseMove(MouseEventArgs e)
  310.     {
  311.  
  312.         base.OnMouseMove(e);
  313.         int x = MousePosition.X;
  314.         int y = MousePosition.Y;
  315.         int x1 = MousePoint.X;
  316.         int y1 = MousePoint.Y;
  317.  
  318.         if (Movable)
  319.             Parent.Location = new Point(x - x1, y - y1);
  320.         Focus();
  321.  
  322.     }
  323.  
  324.     protected override void OnMouseDown(MouseEventArgs e)
  325.     {
  326.         try
  327.         {
  328.             base.OnMouseDown(e);
  329.  
  330.             if (e.Button == System.Windows.Forms.MouseButtons.Left && new Rectangle(0, 0, Width, MoveHeight).Contains(e.Location))
  331.             {
  332.                 Movable = true;
  333.                 MousePoint = e.Location;
  334.             }
  335.  
  336.         }
  337.         catch
  338.         {
  339.  
  340.         }
  341.     }
  342.  
  343.     protected override void OnMouseUp(MouseEventArgs e)
  344.     {
  345.  
  346.         base.OnMouseUp(e);
  347.  
  348.         Movable = false;
  349.  
  350.  
  351.     }
  352.  
  353.     #endregion
  354.  
  355.  
  356. }
  357.  
  358. #endregion
  359.  
  360. #region Flat Button
  361.  
  362. public class ModalFlatButton : Control
  363. {
  364.  
  365.     #region Variables
  366.  
  367.     private HelperMethods.MouseMode State;
  368.     private static HelperMethods H = new HelperMethods();
  369.  
  370.     #endregion
  371.  
  372.     #region Draw Control
  373.  
  374.     protected override void OnPaint(PaintEventArgs e)
  375.     {
  376.         using (Bitmap B = new Bitmap(Width, Height))
  377.         using (Graphics G = Graphics.FromImage(B))
  378.         {
  379.             G.SmoothingMode = SmoothingMode.AntiAlias;
  380.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  381.  
  382.             Rectangle R = new Rectangle(0, 0, Width - 1, Height - 1);
  383.  
  384.             switch (State)
  385.             {
  386.                 case HelperMethods.MouseMode.NormalMode:
  387.  
  388.                  H.FillRoundedPath(G, H.SolidBrushHTMlColor("291a2a"), R, 2);
  389.                  H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, R, 2);
  390.  
  391.                     break;
  392.                 case HelperMethods.MouseMode.Hovered:
  393.                     Cursor=Cursors.Hand;
  394.  
  395.                     H.FillRoundedPath(G, H.SolidBrushHTMlColor("231625"), R, 2);
  396.                     H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, R, 2);
  397.  
  398.                     break;
  399.                 case HelperMethods.MouseMode.Pushed:
  400.  
  401.                     H.FillRoundedPath(G, H.SolidBrushHTMlColor("291a2a"), R, 2);
  402.                     H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, R, 2);
  403.  
  404.                     break;
  405.             }
  406.  
  407.             H.CentreString(G, Text, Font, H.SolidBrushHTMlColor("e5d2e6"), new Rectangle(0,0,Width-2,Height-4));
  408.  
  409.             e.Graphics.DrawImage(B, 0, 0);
  410.             G.Dispose();
  411.             B.Dispose();
  412.         }
  413.     }
  414.  
  415.     #endregion
  416.  
  417.     #region Constructors
  418.  
  419.     public ModalFlatButton()
  420.     {
  421.         SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
  422.         ControlStyles.SupportsTransparentBackColor, true);
  423.         DoubleBuffered = true;
  424.         BackColor = Color.Transparent;
  425.         Font = new Font("Ubuntu", 14, FontStyle.Regular, GraphicsUnit.Pixel);
  426.         UpdateStyles();
  427.  
  428.     }
  429.  
  430.     #endregion
  431.  
  432.     #region Events
  433.  
  434.     protected override void OnMouseEnter(EventArgs e)
  435.     {
  436.  
  437.         base.OnMouseEnter(e);
  438.         State = HelperMethods.MouseMode.Hovered;
  439.         Invalidate();
  440.     }
  441.  
  442.     protected override void OnMouseUp(MouseEventArgs e)
  443.     {
  444.  
  445.         base.OnMouseUp(e);
  446.         State = HelperMethods.MouseMode.Hovered;
  447.         Invalidate();
  448.     }
  449.  
  450.     protected override void OnMouseDown(MouseEventArgs e)
  451.     {
  452.  
  453.         base.OnMouseDown(e);
  454.         State = HelperMethods.MouseMode.Pushed;
  455.         Invalidate();
  456.     }
  457.  
  458.     protected override void OnMouseLeave(EventArgs e)
  459.     {
  460.  
  461.         base.OnMouseLeave(e);
  462.         State = HelperMethods.MouseMode.NormalMode;
  463.         Invalidate();
  464.     }
  465.  
  466.     #endregion
  467.    
  468. }
  469.  
  470. #endregion
  471.  
  472. #region Button
  473.  
  474. public class ModalButton : Control
  475. {
  476.  
  477.     #region Variables
  478.  
  479.     private HelperMethods.MouseMode State;
  480.     private static HelperMethods H = new HelperMethods();
  481.    
  482.     #endregion
  483.  
  484.     #region Draw Control
  485.  
  486.     protected override void OnPaint(PaintEventArgs e)
  487.     {
  488.         using (Bitmap B = new Bitmap(Width, Height))
  489.         using (Graphics G = Graphics.FromImage(B))
  490.         {
  491.             G.SmoothingMode = SmoothingMode.AntiAlias;
  492.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  493.  
  494.             Rectangle R = new Rectangle(0, 0, Width - 1, Height - 1);
  495.  
  496.             switch (State)
  497.             {
  498.                 case HelperMethods.MouseMode.NormalMode:
  499.  
  500.                     using (LinearGradientBrush LB = new LinearGradientBrush(R,Color.FromArgb(200, H.GetHTMLColor("431448")), Color.FromArgb(200, H.GetHTMLColor("5b2960")), 270f))
  501.                     {
  502.                         H.FillRoundedPath(G, LB, R, 2);
  503.                         using (LinearGradientBrush LB2 = new LinearGradientBrush(R, Color.FromArgb(230, H.GetHTMLColor("431448")), Color.FromArgb(230, H.GetHTMLColor("5b2960")), 270f))
  504.                         {
  505.                             H.FillRoundedPath(G, LB2, R, 2);
  506.                         }
  507.                         H.DrawRoundedPath(G, H.GetHTMLColor("311833"), 1, R, 2);
  508.                     }
  509.  
  510.                     break;
  511.  
  512.                 case HelperMethods.MouseMode.Hovered:
  513.                     Cursor = Cursors.Hand;
  514.                     using (LinearGradientBrush LB = new LinearGradientBrush(R, Color.FromArgb(200, H.GetHTMLColor("241525")), Color.FromArgb(200, H.GetHTMLColor("241525")), 270f))
  515.                     {
  516.                         H.FillRoundedPath(G, LB, R, 2);
  517.                         using (LinearGradientBrush LB2 = new LinearGradientBrush(R, Color.FromArgb(230, H.GetHTMLColor("431448")), Color.FromArgb(230, H.GetHTMLColor("5b2960")), 270f))
  518.                         {
  519.                             H.FillRoundedPath(G, LB2, R, 2);
  520.                         }
  521.                         H.DrawRoundedPath(G, H.GetHTMLColor("311833"), 1, R, 2);
  522.                     }
  523.  
  524.                     break;
  525.                 case HelperMethods.MouseMode.Pushed:
  526.                     using (LinearGradientBrush LB = new LinearGradientBrush(R, Color.FromArgb(200, H.GetHTMLColor("431448")), Color.FromArgb(200, H.GetHTMLColor("5b2960")), 270f))
  527.                     {
  528.                         H.FillRoundedPath(G, LB, R, 2);
  529.                         using (LinearGradientBrush LB2 = new LinearGradientBrush(R, Color.FromArgb(230, H.GetHTMLColor("431448")), Color.FromArgb(230, H.GetHTMLColor("5b2960")), 270f))
  530.                         {
  531.                             H.FillRoundedPath(G, LB2, R, 2);
  532.                         }
  533.                         H.DrawRoundedPath(G, H.GetHTMLColor("311833"), 1, R, 2);
  534.                     }
  535.  
  536.                     break;
  537.             }
  538.  
  539.             H.CentreString(G, Text, Font, H.SolidBrushHTMlColor("e5d2e6"), new Rectangle(0,0,Width-2,Height-4));
  540.  
  541.             e.Graphics.DrawImage(B, 0, 0);
  542.             G.Dispose();
  543.             B.Dispose();
  544.         }
  545.     }
  546.  
  547.     #endregion
  548.        
  549.     #region Constructors
  550.  
  551.     public ModalButton()
  552.     {
  553.         SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
  554.         ControlStyles.Selectable | ControlStyles.SupportsTransparentBackColor, true);
  555.         DoubleBuffered = true;
  556.         BackColor = Color.Transparent;
  557.         Font = new Font("Ubuntu", 14, FontStyle.Regular, GraphicsUnit.Pixel);
  558.         UpdateStyles();
  559.  
  560.     }
  561.  
  562.     #endregion
  563.  
  564.     #region Events
  565.  
  566.     protected override void OnMouseEnter(EventArgs e)
  567.     {
  568.  
  569.         base.OnMouseEnter(e);
  570.         State = HelperMethods.MouseMode.Hovered;
  571.         Invalidate();
  572.     }
  573.  
  574.     protected override void OnMouseUp(MouseEventArgs e)
  575.     {
  576.  
  577.         base.OnMouseUp(e);
  578.         State = HelperMethods.MouseMode.Hovered;
  579.         Invalidate();
  580.     }
  581.  
  582.     protected override void OnMouseDown(MouseEventArgs e)
  583.     {
  584.  
  585.         base.OnMouseDown(e);
  586.         State = HelperMethods.MouseMode.Pushed;
  587.         Invalidate();
  588.     }
  589.  
  590.     protected override void OnMouseLeave(EventArgs e)
  591.     {
  592.  
  593.         base.OnMouseLeave(e);
  594.         State = HelperMethods.MouseMode.NormalMode;
  595.         Invalidate();
  596.     }
  597.  
  598.     #endregion
  599.    
  600. }
  601.  
  602. #endregion
  603.  
  604. #region Textbox
  605.  
  606. [DefaultEvent("TextChanged")] public class ModalTextbox : Control
  607. {
  608.  
  609.     #region Variables
  610.  
  611.     private TextBox T = new TextBox();
  612.     private HorizontalAlignment _TextAlign = HorizontalAlignment.Left;
  613.     private int _MaxLength = 32767;
  614.     private bool _ReadOnly;
  615.     private bool _UseSystemPasswordChar = false;
  616.     private string _WatermarkText = "";
  617.     private Image _SideImage;
  618.     private bool _Multiline = false;
  619.     protected HelperMethods.MouseMode State = HelperMethods.MouseMode.NormalMode;
  620.     private static HelperMethods H = new HelperMethods();
  621.     private static Color TBC = H.GetHTMLColor("291a2a");
  622.     private static Color TFC = H.GetHTMLColor("a89ea9");
  623.     private SideAligin _SideImageAlign = SideAligin.Left;
  624.     private Color _BackColor = TBC;
  625.     #endregion
  626.  
  627.     #region  Native Methods
  628.     [System.Runtime.InteropServices.DllImport("user32.dll")]
  629.     private static extern Int32 SendMessage(IntPtr hWnd, int msg, int wParam, [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
  630. string lParam);
  631.  
  632.     #endregion
  633.  
  634.     #region Draw Control
  635.  
  636.     protected override void OnPaint(PaintEventArgs e)
  637.     {
  638.         using (Bitmap B = new Bitmap(Width, Height))
  639.         using (Graphics G = Graphics.FromImage(B))
  640.         {
  641.                      
  642.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  643.             Rectangle Rect = new Rectangle(0, 0, Width - 1, Height - 1);
  644.             Height = 30;
  645.  
  646.             G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), Rect);
  647.  
  648.             G.DrawLine(H.PenHTMlColor("231625", 1), new Point(0, Height - 1), new Point(Width - 2, Height - 1));
  649.                          
  650.  
  651.  
  652.             if (SideImage != null)
  653.             {
  654.                 if (SideImageAlign == SideAligin.Right)
  655.                 {
  656.                     T.Location = new Point(7, 5);
  657.                     T.Width = Width - 60;
  658.                     G.InterpolationMode = InterpolationMode.HighQualityBicubic;
  659.                     G.DrawImage(SideImage, new Rectangle(Rect.Width - 24, 6, 16, 16));
  660.                 }
  661.                 else
  662.                 {
  663.                 T.Location = new Point(33,5);
  664.                 T.Width = Width - 60;
  665.                 G.InterpolationMode = InterpolationMode.HighQualityBicubic;
  666.                 G.DrawImage(SideImage, new Rectangle(8, 6, 16, 16));
  667.                 }
  668.                
  669.  
  670.             }
  671.             else
  672.             {
  673.                 T.Location = new Point(7,5);
  674.                 T.Width = Width - 10;
  675.             }
  676.  
  677.             if (ContextMenuStrip != null) { T.ContextMenuStrip = ContextMenuStrip; }
  678.  
  679.             e.Graphics.DrawImage(B, 0, 0);
  680.             G.Dispose();
  681.             B.Dispose();
  682.         }
  683.     }
  684.  
  685.     #endregion
  686.  
  687.     #region Constructors
  688.  
  689.     public ModalTextbox()
  690.     {
  691.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
  692.                 ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer |
  693.                 ControlStyles.SupportsTransparentBackColor, true);
  694.         DoubleBuffered = true;
  695.         UpdateStyles();
  696.         Font = new Font("Arial", 11, FontStyle.Regular);
  697.         Size = new Size(135, 30);
  698.         T.Multiline = _Multiline;
  699.         T.Cursor = Cursors.IBeam;
  700.         T.BackColor = TBC;
  701.         T.ForeColor = TFC;
  702.         T.BorderStyle = BorderStyle.None;
  703.         T.Location = new Point(7, 7);
  704.         T.Font = Font;
  705.         T.Size = new Size(Width - 10, 30);
  706.         T.UseSystemPasswordChar = _UseSystemPasswordChar;
  707.         T.TextChanged += T_TextChanged;
  708.         T.MouseDown += T_MouseDown;
  709.         T.MouseEnter += T_MouseEnter;
  710.         T.MouseUp += T_MouseUp;
  711.         T.MouseLeave += T_MouseLeave;
  712.         T.MouseHover += T_MouseHover;
  713.         T.KeyDown += T_KeyDown;
  714.     }
  715.  
  716.     #endregion
  717.  
  718.     #region Properties
  719.  
  720.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  721.     public BorderStyle BorderStyle
  722.     {
  723.         get
  724.         {
  725.             return BorderStyle.None;
  726.         }
  727.     }
  728.  
  729.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  730.     public bool Multiline
  731.     {
  732.         get
  733.         {
  734.             return _Multiline;
  735.         }
  736.         set
  737.         {
  738.             _Multiline = value;
  739.             if (T != null)
  740.             {
  741.                 T.Multiline = value;
  742.             }
  743.  
  744.         }
  745.     }
  746.  
  747.     public HorizontalAlignment TextAlign
  748.     {
  749.         get
  750.         {
  751.             return _TextAlign;
  752.         }
  753.         set
  754.         {
  755.             _TextAlign = value;
  756.             if (T != null)
  757.             {
  758.                 T.TextAlign = value;
  759.             }
  760.         }
  761.     }
  762.  
  763.     public int MaxLength
  764.     {
  765.         get
  766.         {
  767.             return _MaxLength;
  768.         }
  769.         set
  770.         {
  771.             _MaxLength = value;
  772.             if (T != null)
  773.             {
  774.                 T.MaxLength = value;
  775.             }
  776.         }
  777.     }
  778.  
  779.     public bool ReadOnly
  780.     {
  781.         get
  782.         {
  783.             return _ReadOnly;
  784.         }
  785.         set
  786.         {
  787.             _ReadOnly = value;
  788.             if (T != null)
  789.             {
  790.                 T.ReadOnly = value;
  791.             }
  792.         }
  793.     }
  794.  
  795.     public bool UseSystemPasswordChar
  796.     {
  797.         get
  798.         {
  799.             return _UseSystemPasswordChar;
  800.         }
  801.         set
  802.         {
  803.             _UseSystemPasswordChar = value;
  804.             if (T != null)
  805.             {
  806.                 T.UseSystemPasswordChar = value;
  807.             }
  808.         }
  809.     }
  810.  
  811.     public string WatermarkText
  812.     {
  813.         get
  814.         {
  815.             return _WatermarkText;
  816.         }
  817.         set
  818.         {
  819.             _WatermarkText = value;
  820.             SendMessage(T.Handle, 0x1501, 0, value);
  821.             Invalidate();
  822.         }
  823.     }
  824.  
  825.     public Image SideImage
  826.     {
  827.         get
  828.         {
  829.             return _SideImage;
  830.         }
  831.         set
  832.         {
  833.             _SideImage = value;
  834.             Invalidate();
  835.         }
  836.     }
  837.  
  838.     [Browsable(false)]
  839.     public override Image BackgroundImage
  840.     {
  841.         get
  842.         {
  843.             return base.BackgroundImage;
  844.         }
  845.         set
  846.         {
  847.             base.BackgroundImage = value;
  848.         }
  849.     }
  850.  
  851.     [Browsable(false)]
  852.     public override ImageLayout BackgroundImageLayout
  853.     {
  854.         get
  855.         {
  856.             return base.BackgroundImageLayout;
  857.         }
  858.         set
  859.         {
  860.             base.BackgroundImageLayout = value;
  861.         }
  862.     }
  863.  
  864.     public override string Text
  865.     {
  866.         get
  867.         {
  868.             return base.Text;
  869.         }
  870.         set
  871.         {
  872.             base.Text = value;
  873.         }
  874.     }
  875.  
  876.     public enum SideAligin
  877.     {
  878.         Left,
  879.         Right
  880.     }
  881.  
  882.     public SideAligin SideImageAlign
  883.     {
  884.         get
  885.         {
  886.             return _SideImageAlign;
  887.         }
  888.         set
  889.         {
  890.             _SideImageAlign = value;
  891.             Invalidate();
  892.         }
  893.     }
  894.  
  895.     override public Color BackColor
  896.     {
  897.  
  898.         get { return _BackColor; }
  899.         set
  900.         {
  901.             base.BackColor = value;
  902.             _BackColor = value;
  903.             T.BackColor = value;
  904.             Invalidate();
  905.         }
  906.     }
  907.  
  908.  
  909.     #endregion
  910.  
  911.     #region Events
  912.  
  913.     private void T_MouseHover(object sender, EventArgs e)
  914.     {
  915.         State = HelperMethods.MouseMode.Hovered;
  916.         Invalidate();
  917.     }
  918.  
  919.     private void T_MouseLeave(object sender, EventArgs e)
  920.     {
  921.         State = HelperMethods.MouseMode.NormalMode;
  922.         Invalidate();
  923.     }
  924.  
  925.     private void T_MouseUp(object sender, EventArgs e)
  926.     {
  927.         State = HelperMethods.MouseMode.Pushed;
  928.         Invalidate();
  929.     }
  930.  
  931.     private void T_MouseEnter(object sender, EventArgs e)
  932.     {
  933.         State = HelperMethods.MouseMode.Pushed;
  934.         Invalidate();
  935.     }
  936.  
  937.     private void T_MouseDown(object sender, EventArgs e)
  938.     {
  939.         State = HelperMethods.MouseMode.Pushed;
  940.         Invalidate();
  941.     }
  942.  
  943.     private void T_TextChanged(object sender, EventArgs e)
  944.     {
  945.         Text = T.Text;
  946.     }
  947.  
  948.     protected override void OnTextChanged(EventArgs e)
  949.     {
  950.         base.OnTextChanged(e);
  951.         T.Text = Text;
  952.     }
  953.  
  954.     private void T_KeyDown(object sender, KeyEventArgs e)
  955.     {
  956.         if (e.Control && e.KeyCode == Keys.A) { e.SuppressKeyPress = true; }
  957.         if (e.Control && e.KeyCode == Keys.C)
  958.         {
  959.             T.Copy();
  960.             e.SuppressKeyPress = true;
  961.         }
  962.     }
  963.  
  964.     protected override void OnCreateControl()
  965.     {
  966.         base.OnCreateControl();
  967.         if (!Controls.Contains(T))
  968.             Controls.Add(T);
  969.         if (T.Text == "" && WatermarkText != "")
  970.  
  971.             T.Text = WatermarkText;
  972.  
  973.     }
  974.  
  975.     protected override void OnResize(EventArgs e)
  976.     {
  977.         base.OnResize(e);
  978.         if (_Multiline == false)
  979.             Height = 30;
  980.     }
  981.  
  982.     #endregion
  983.  
  984.  
  985. }
  986.  
  987. #endregion
  988.  
  989. #region ComboBox
  990.  
  991. public class ModalComboBox : ComboBox
  992. {
  993.  
  994.     #region Variables
  995.  
  996.     private int _StartIndex = 0;
  997.     private static HelperMethods H = new HelperMethods();
  998.  
  999.     #endregion
  1000.  
  1001.     #region Constructors
  1002.  
  1003.     public ModalComboBox()
  1004.     {
  1005.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
  1006.               ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  1007.         DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
  1008.         DoubleBuffered = true;
  1009.         StartIndex = 0;
  1010.         DropDownHeight = 100;
  1011.         BackColor = H.GetHTMLColor("291a2a");
  1012.         Font = new Font("Ubuntu", 12, FontStyle.Regular);
  1013.         DropDownStyle = ComboBoxStyle.DropDownList;
  1014.         UpdateStyles();
  1015.  
  1016.     }
  1017.  
  1018.     #endregion
  1019.  
  1020.     #region Properties
  1021.  
  1022.     public int StartIndex
  1023.     {
  1024.         get
  1025.         {
  1026.             return _StartIndex;
  1027.         }
  1028.         set
  1029.         {
  1030.             _StartIndex = value;
  1031.             try
  1032.             {
  1033.                 base.SelectedIndex = value;
  1034.             }
  1035.             catch
  1036.             {
  1037.  
  1038.             }
  1039.             Invalidate();
  1040.         }
  1041.     }
  1042.  
  1043.     #endregion
  1044.  
  1045.     #region Draw Control
  1046.  
  1047.     protected override void OnPaint(PaintEventArgs e)
  1048.     {
  1049.         using (Bitmap B = new Bitmap(Width, Height))
  1050.         using (Graphics G = Graphics.FromImage(B))
  1051.         {
  1052.             Rectangle Rect = new Rectangle(0, 0, Width - 1, Height - 1);
  1053.  
  1054.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  1055.  
  1056.             G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), Rect);
  1057.          
  1058.             G.DrawLine(H.PenHTMlColor("231625", 2), new Point(Width - 21, (Height / 2) - 3), new Point(Width - 7, (Height / 2) - 3));
  1059.          
  1060.             G.DrawLine(H.PenHTMlColor("231625", 2), new Point(Width - 21, (Height / 2)+1), new Point(Width - 7, (Height / 2)+1));
  1061.            
  1062.             G.DrawLine(H.PenHTMlColor("231625", 2), new Point(Width - 21, (Height / 2) + 5), new Point(Width - 7, (Height / 2) + 5));
  1063.            
  1064.             G.DrawLine(H.PenHTMlColor("231625", 1), new Point(1, Height - 1), new Point(Width - 2, Height - 1));
  1065.            
  1066.             G.DrawString(Text, Font, new SolidBrush(H.GetHTMLColor("a89ea9")), new Rectangle(5, 1, Width - 1, Height - 1), new StringFormat {LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Near});
  1067.            
  1068.             e.Graphics.DrawImage(B, 0, 0);
  1069.             G.Dispose();
  1070.             B.Dispose();
  1071.         }
  1072.     }
  1073.  
  1074.     protected override void OnDrawItem(DrawItemEventArgs e)
  1075.     {
  1076.         try
  1077.         {            
  1078.             e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  1079.             if (System.Convert.ToInt32((e.State & DrawItemState.Selected)) == (int)DrawItemState.Selected)
  1080.             {
  1081.                 if (!(e.Index == -1))
  1082.                 {
  1083.                     Cursor = Cursors.Hand;
  1084.                     e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(120, H.GetHTMLColor("291a2a"))), new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 2, e.Bounds.Width - 2, e.Bounds.Height - 2));
  1085.                     e.Graphics.DrawString(GetItemText(Items[e.Index]), new Font("Ubuntu", 10, FontStyle.Bold), H.SolidBrushHTMlColor("a89ea9"), new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 3, e.Bounds.Width - 2, e.Bounds.Height - 2));
  1086.                 }
  1087.             }
  1088.             else
  1089.             {
  1090.                 if (!(e.Index == -1))
  1091.                 {
  1092.                     e.Graphics.FillRectangle(H.SolidBrushHTMlColor("291a2a"), new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 2, e.Bounds.Width - 2, e.Bounds.Height - 2));
  1093.                     e.Graphics.DrawString(GetItemText(Items[e.Index]), new Font("Ubuntu", 10, FontStyle.Regular), Brushes.Gainsboro, new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 3, e.Bounds.Width - 2, e.Bounds.Height - 2));
  1094.                 }
  1095.             }
  1096.  
  1097.         }
  1098.         catch
  1099.         {
  1100.  
  1101.         }
  1102.         Invalidate();
  1103.     }
  1104.  
  1105.     #endregion
  1106.  
  1107.     #region Events
  1108.  
  1109.     protected override void OnResize(EventArgs e)
  1110.     {
  1111.         base.OnResize(e);
  1112.         Invalidate();
  1113.     }
  1114.  
  1115.     protected override void OnCreateControl()
  1116.     {
  1117.         base.OnCreateControl();
  1118.  
  1119.     }
  1120.  
  1121.     protected override void OnLostFocus(EventArgs e)
  1122.     {
  1123.         base.OnLostFocus(e);
  1124.         SuspendLayout();
  1125.         Update();
  1126.         ResumeLayout();
  1127.     }
  1128.  
  1129.     #endregion
  1130.  
  1131. }
  1132.  
  1133. #endregion
  1134.  
  1135. #region CheckBox
  1136.  
  1137. [DefaultEvent("CheckedChanged")] public class ModalCheckBox : Control
  1138. {
  1139.  
  1140.     #region Variables
  1141.  
  1142.     protected bool _Checked;
  1143.     protected HelperMethods.MouseMode State = HelperMethods.MouseMode.NormalMode;
  1144.     public event CheckedChangedEventHandler CheckedChanged;
  1145.     public delegate void CheckedChangedEventHandler(object sender);
  1146.     private static HelperMethods H = new HelperMethods();
  1147.  
  1148.     #endregion
  1149.  
  1150.     #region Properties
  1151.  
  1152.     protected override void OnTextChanged(EventArgs e)
  1153.     {
  1154.         base.OnTextChanged(e);
  1155.         Invalidate();
  1156.     }
  1157.  
  1158.     public bool Checked
  1159.     {
  1160.         get
  1161.         {
  1162.             return _Checked;
  1163.         }
  1164.         set
  1165.         {
  1166.             _Checked = value;
  1167.             Invalidate();
  1168.         }
  1169.     }
  1170.  
  1171.     #endregion
  1172.  
  1173.     #region Draw Control
  1174.  
  1175.     protected override void OnPaint(PaintEventArgs e)
  1176.     {
  1177.         using (Bitmap B = new Bitmap(Width, Height))
  1178.         using (Graphics G = Graphics.FromImage(B))
  1179.         {
  1180.  
  1181.             Rectangle R = new Rectangle(1, 1, 18, 18);
  1182.  
  1183.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  1184.  
  1185.             G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), R);
  1186.             G.DrawRectangle(H.PenHTMlColor("231625", (int)1.5), R);
  1187.  
  1188.             if (Checked)
  1189.             {
  1190.                 G.DrawString("b", new Font("Marlett", 16, FontStyle.Regular), H.SolidBrushHTMlColor("5b2960"), new Rectangle(Convert.ToInt32(-2.7), 0, Width - 4, Height));                              
  1191.             }
  1192.  
  1193.             G.DrawString(Text, Font, H.SolidBrushHTMlColor("e4ecf2"), new Rectangle(22, Convert.ToInt32(1.6), Width, Height - 2), new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
  1194.  
  1195.             e.Graphics.DrawImage(B, 0, 0);
  1196.             G.Dispose();
  1197.             B.Dispose();
  1198.         }
  1199.     }
  1200.  
  1201.     #endregion
  1202.  
  1203.     #region Constructors
  1204.  
  1205.     public ModalCheckBox()
  1206.     {
  1207.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
  1208.                  ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  1209.         DoubleBuffered = true;
  1210.         BackColor = Color.Transparent;
  1211.         Font = new Font("Ubuntu", 11, FontStyle.Regular);
  1212.         Cursor = Cursors.Hand;
  1213.         UpdateStyles();
  1214.     }
  1215.  
  1216.     #endregion
  1217.  
  1218.     #region  Events
  1219.  
  1220.     protected override void OnMouseHover(EventArgs e)
  1221.     {
  1222.         base.OnMouseHover(e);
  1223.         State = HelperMethods.MouseMode.Hovered;
  1224.         Invalidate();
  1225.     }
  1226.  
  1227.     protected override void OnMouseLeave(EventArgs e)
  1228.     {
  1229.         base.OnMouseLeave(e);
  1230.         State = HelperMethods.MouseMode.NormalMode;
  1231.         Invalidate();
  1232.     }
  1233.  
  1234.     protected override void OnResize(EventArgs e)
  1235.     {
  1236.         base.OnResize(e);
  1237.         Height = 20;
  1238.         Invalidate();
  1239.     }
  1240.  
  1241.     protected override void OnCreateControl()
  1242.     {
  1243.         base.OnCreateControl();
  1244.     }
  1245.  
  1246.     protected override void OnClick(EventArgs e)
  1247.     {
  1248.         _Checked = !_Checked;
  1249.         if (CheckedChanged != null)
  1250.         {
  1251.             CheckedChanged(this);
  1252.         }
  1253.         base.OnClick(e);
  1254.         Invalidate();
  1255.     }
  1256.  
  1257.     #endregion
  1258.  
  1259. }
  1260.  
  1261. #endregion
  1262.  
  1263. #region RadioButton
  1264.  
  1265. [DefaultEvent("CheckedChanged")] public class ModalRadioButton : Control
  1266. {
  1267.  
  1268.     #region Variables
  1269.  
  1270.     protected bool _Checked;
  1271.     protected HelperMethods.MouseMode State = HelperMethods.MouseMode.NormalMode;
  1272.     protected static int _Group = 1;
  1273.     public event CheckedChangedEventHandler CheckedChanged;
  1274.     public delegate void CheckedChangedEventHandler(object sender);
  1275.     private static HelperMethods H = new HelperMethods();
  1276.  
  1277.     #endregion
  1278.  
  1279.     #region Properties
  1280.  
  1281.     protected override void OnTextChanged(EventArgs e)
  1282.     {
  1283.         base.OnTextChanged(e);
  1284.         Invalidate();
  1285.     }
  1286.  
  1287.     public bool Checked
  1288.     {
  1289.         get
  1290.         {
  1291.             return _Checked;
  1292.         }
  1293.         set
  1294.         {
  1295.             _Checked = value;
  1296.             UpdateCheckState();
  1297.             Invalidate();
  1298.         }
  1299.     }
  1300.  
  1301.     public int Group
  1302.     {
  1303.         get
  1304.         {
  1305.             return _Group;
  1306.         }
  1307.         set
  1308.         {
  1309.             _Group = value;
  1310.         }
  1311.     }
  1312.  
  1313.     #endregion
  1314.  
  1315.     #region Draw Control
  1316.  
  1317.     protected override void OnPaint(PaintEventArgs e)
  1318.     {
  1319.         using (Bitmap B = new Bitmap(Width, Height))
  1320.         using (Graphics G = Graphics.FromImage(B))
  1321.         {
  1322.             G.SmoothingMode = SmoothingMode.AntiAlias;
  1323.  
  1324.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  1325.  
  1326.             G.FillEllipse(H.SolidBrushHTMlColor("291a2a"), new Rectangle(1, 1, 18, 18));
  1327.             G.DrawEllipse(H.PenHTMlColor("231625", (int)2.8), new Rectangle(1, 1, 18, 18));
  1328.            
  1329.             if (Checked)
  1330.             {
  1331.                 G.DrawString("-", Font, H.SolidBrushHTMlColor("5b2960"), new Rectangle(5, Convert.ToInt32(0.8), Width - 4, Height));
  1332.             }
  1333.             else
  1334.             {
  1335.                 G.DrawString("+", Font, H.SolidBrushHTMlColor("5b2960"), new Rectangle((int)4.5, 3, Width - 4, Height));
  1336.             }
  1337.  
  1338.             G.DrawString(Text, Font, H.SolidBrushHTMlColor("a89ea9"), new Rectangle(22, Convert.ToInt32(1.6), Width, Height - 2), new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
  1339.  
  1340.             e.Graphics.DrawImage(B, 0, 0);
  1341.             G.Dispose();
  1342.             B.Dispose();
  1343.         }
  1344.     }
  1345.  
  1346.     #endregion
  1347.  
  1348.     #region Constructors
  1349.  
  1350.     public ModalRadioButton()
  1351.     {
  1352.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
  1353.                  ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  1354.         DoubleBuffered = true;
  1355.         Cursor = Cursors.Hand;
  1356.         BackColor = Color.Transparent;
  1357.         Font = new Font("Ubuntu", 11, FontStyle.Regular);
  1358.         UpdateStyles();
  1359.     }
  1360.  
  1361.     #endregion
  1362.  
  1363.     #region  Events
  1364.  
  1365.     private void UpdateCheckState()
  1366.     {
  1367.         if (!IsHandleCreated || !_Checked)
  1368.             return;
  1369.  
  1370.         foreach (Control C in Parent.Controls)
  1371.         {
  1372.             if (!object.ReferenceEquals(C, this) && C is ModalRadioButton && ((ModalRadioButton)C).Group == _Group)
  1373.             {
  1374.                 ((ModalRadioButton)C).Checked = false;
  1375.             }
  1376.         }
  1377.         if (CheckedChanged != null)
  1378.         {
  1379.             CheckedChanged(this);
  1380.         }
  1381.     }
  1382.  
  1383.     protected override void OnMouseDown(MouseEventArgs e)
  1384.     {
  1385.         if (!_Checked)
  1386.             Checked = true;
  1387.         base.OnMouseDown(e);
  1388.     }
  1389.  
  1390.     protected override void OnMouseHover(EventArgs e)
  1391.     {
  1392.         base.OnMouseHover(e);
  1393.         State = HelperMethods.MouseMode.Hovered;
  1394.         Invalidate();
  1395.     }
  1396.  
  1397.     protected override void OnMouseLeave(EventArgs e)
  1398.     {
  1399.         base.OnMouseLeave(e);
  1400.         State = HelperMethods.MouseMode.NormalMode;
  1401.         Invalidate();
  1402.     }
  1403.  
  1404.     protected override void OnResize(EventArgs e)
  1405.     {
  1406.         base.OnResize(e);
  1407.         Height = 21;
  1408.         Invalidate();
  1409.     }
  1410.  
  1411.     protected override void OnCreateControl()
  1412.     {
  1413.         base.OnCreateControl();
  1414.         UpdateCheckState();
  1415.     }
  1416.  
  1417.     #endregion
  1418.  
  1419. }
  1420.  
  1421. #endregion
  1422.  
  1423. #region Label
  1424.  
  1425. [DefaultEvent("TextChanged")] public class ModalLabel : Control
  1426. {
  1427.     #region Variables
  1428.  
  1429.     private static HelperMethods H = new HelperMethods();
  1430.  
  1431.     #endregion
  1432.  
  1433.     #region Constructors
  1434.  
  1435.     public ModalLabel()
  1436.     {
  1437.         SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
  1438.         DoubleBuffered = true;
  1439.         BackColor = Color.Transparent;
  1440.         Font = new Font("Ubuntu", 12, FontStyle.Regular);
  1441.         UpdateStyles();
  1442.     }
  1443.  
  1444.     #endregion
  1445.  
  1446.     #region DrawControl
  1447.  
  1448.     protected override void OnPaint(PaintEventArgs e)
  1449.     {
  1450.         e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  1451.         e.Graphics.DrawString(Text, Font, H.SolidBrushHTMlColor("a89ea9"), ClientRectangle);
  1452.  
  1453.     }
  1454.  
  1455.     #endregion
  1456.  
  1457.     #region Events
  1458.  
  1459.     protected override void OnResize(EventArgs e)
  1460.     {
  1461.         base.OnResize(e);
  1462.         Height = Font.Height;
  1463.     }
  1464.  
  1465.     protected override void OnTextChanged(EventArgs e)
  1466.     {
  1467.         base.OnTextChanged(e);
  1468.     }
  1469.  
  1470.     #endregion;
  1471.  
  1472. }
  1473.  
  1474. #endregion
  1475.  
  1476. #region Link Label
  1477.  
  1478. [DefaultEvent("TextChanged")] public class ModalLinkLabel : Control
  1479. {
  1480.  
  1481.     #region Variables
  1482.  
  1483.     private HelperMethods.MouseMode State;
  1484.     private static HelperMethods H = new HelperMethods();
  1485.     private string _URL = string.Empty;
  1486.     private Color _HoverColor = H.GetHTMLColor("311833");
  1487.     private Color _PushedColor = H.GetHTMLColor("431448");
  1488.  
  1489.     #endregion
  1490.  
  1491.     #region Properties
  1492.  
  1493.     public string URL
  1494.     {
  1495.         get
  1496.         {
  1497.             return _URL;
  1498.         }
  1499.         set
  1500.         {
  1501.             _URL = value;
  1502.             Invalidate();
  1503.         }
  1504.     }
  1505.  
  1506.     public Color HoverColor
  1507.     {
  1508.         get
  1509.         {
  1510.             return _HoverColor;
  1511.         }
  1512.         set
  1513.         {
  1514.             _HoverColor = value;
  1515.             Invalidate();
  1516.         }
  1517.     }
  1518.  
  1519.     public Color PushedColor
  1520.     {
  1521.         get
  1522.         {
  1523.             return _PushedColor;
  1524.         }
  1525.         set
  1526.         {
  1527.             _PushedColor = value;
  1528.             Invalidate();
  1529.         }
  1530.     }
  1531.  
  1532.     #endregion
  1533.  
  1534.     #region Constructors
  1535.  
  1536.     public ModalLinkLabel()
  1537.     {
  1538.         SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
  1539.         DoubleBuffered = true;
  1540.         BackColor = Color.Transparent;
  1541.         Font = new Font("Ubuntu", 12, FontStyle.Underline);
  1542.         UpdateStyles();
  1543.     }
  1544.  
  1545.     #endregion
  1546.  
  1547.     #region DrawControl
  1548.  
  1549.     protected override void OnPaint(PaintEventArgs e)
  1550.     {
  1551.         e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  1552.          switch(State)
  1553.          {
  1554.              case HelperMethods.MouseMode.NormalMode:
  1555.                  e.Graphics.DrawString(Text, Font, H.SolidBrushHTMlColor("a89ea9"), ClientRectangle);
  1556.                     break;
  1557.              case HelperMethods.MouseMode.Hovered:
  1558.                     Cursor = Cursors.Hand;
  1559.                     e.Graphics.DrawString(Text, Font, new SolidBrush(HoverColor), ClientRectangle);
  1560.                     break;
  1561.              case HelperMethods.MouseMode.Pushed:
  1562.                     e.Graphics.DrawString(Text, Font, new SolidBrush(PushedColor), ClientRectangle);
  1563.                     break;
  1564.          }
  1565.  
  1566.     }
  1567.  
  1568.     #endregion
  1569.  
  1570.     #region Events
  1571.  
  1572.     protected override void OnResize(EventArgs e)
  1573.     {
  1574.         base.OnResize(e);
  1575.         Height = Font.Height+2;
  1576.     }
  1577.  
  1578.     protected override void OnClick(EventArgs e)
  1579.     {
  1580.         base.OnClick(e);
  1581.         if (URL !=null)
  1582.         {
  1583.             if (!URL.StartsWith("http://www."))
  1584.             {
  1585.                 if (URL == "http://www.")
  1586.                 {
  1587.                     MessageBox.Show("You must put the link to go");
  1588.                 }
  1589.                 else
  1590.                 {
  1591.                     URL = "http://www." + URL;
  1592.                     System.Diagnostics.Process.Start(URL);
  1593.                 }
  1594.             }
  1595.         }
  1596.     }
  1597.  
  1598.     protected override void OnTextChanged(EventArgs e)
  1599.     {
  1600.         base.OnTextChanged(e);
  1601.     }
  1602.  
  1603.  
  1604.     protected override void OnMouseEnter(EventArgs e)
  1605.     {
  1606.  
  1607.         base.OnMouseEnter(e);
  1608.         State = HelperMethods.MouseMode.Hovered;
  1609.         Invalidate();
  1610.     }
  1611.  
  1612.     protected override void OnMouseUp(MouseEventArgs e)
  1613.     {
  1614.  
  1615.         base.OnMouseUp(e);
  1616.         State = HelperMethods.MouseMode.Hovered;
  1617.         Invalidate();
  1618.     }
  1619.  
  1620.     protected override void OnMouseDown(MouseEventArgs e)
  1621.     {
  1622.  
  1623.         base.OnMouseDown(e);
  1624.         State = HelperMethods.MouseMode.Pushed;
  1625.         Invalidate();
  1626.     }
  1627.  
  1628.     protected override void OnMouseLeave(EventArgs e)
  1629.     {
  1630.  
  1631.         base.OnMouseLeave(e);
  1632.         State = HelperMethods.MouseMode.NormalMode;
  1633.         Invalidate();
  1634.     }
  1635.  
  1636.     #endregion;
  1637.  
  1638. }
  1639.  
  1640. #endregion
  1641.  
  1642. #region Seperator
  1643.  
  1644. public class ModalSeperator : Control
  1645. {
  1646.  
  1647.     #region Variables
  1648.  
  1649.     private Style _SepStyle = Style.Horizental;
  1650.     private static HelperMethods H = new HelperMethods();
  1651.  
  1652.     #endregion
  1653.  
  1654.     #region Constructors
  1655.  
  1656.     public ModalSeperator()
  1657.     {
  1658.         SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint |
  1659.         ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
  1660.         ControlStyles.SupportsTransparentBackColor, true);
  1661.         DoubleBuffered = true;
  1662.         BackColor = Color.Transparent;      
  1663.         UpdateStyles();
  1664.  
  1665.     }
  1666.  
  1667.     #endregion
  1668.  
  1669.     #region Enumerators
  1670.  
  1671.     public enum Style
  1672.     {
  1673.         Horizental,
  1674.         Vertiacal
  1675.     };
  1676.  
  1677.     #endregion
  1678.  
  1679.     #region Properties
  1680.  
  1681.     public Style SepStyle
  1682.     {
  1683.         get
  1684.         {
  1685.             return _SepStyle;
  1686.         }
  1687.         set
  1688.         {
  1689.             _SepStyle = value;
  1690.             if (value == Style.Horizental)
  1691.             {
  1692.                 Height = 4;
  1693.             }
  1694.             else
  1695.             {
  1696.                 Width = 4;
  1697.             }
  1698.             Invalidate();
  1699.         }
  1700.     }
  1701.  
  1702.     #endregion
  1703.  
  1704.     #region DrawControl
  1705.  
  1706.     protected override void OnPaint(PaintEventArgs e)
  1707.     {
  1708.  
  1709.         using (Bitmap B = new Bitmap(Width, Height))
  1710.         using (Graphics G = Graphics.FromImage(B))
  1711.         {
  1712.  
  1713.             G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
  1714.  
  1715.             switch (SepStyle)
  1716.             {
  1717.                 case Style.Horizental:
  1718.                     using (System.Drawing.Drawing2D.LinearGradientBrush lb1 = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, Color.Empty, Color.Empty, 0.0F))
  1719.                     {                        
  1720.                         G.DrawLine(H.PenHTMlColor("231625", 1), 0, 1, Width, 1);
  1721.                     }
  1722.                     break;
  1723.                 case Style.Vertiacal:
  1724.                     using (System.Drawing.Drawing2D.LinearGradientBrush lb1 = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, Color.Empty, Color.Empty, 90.0F))
  1725.                     {                      
  1726.                         G.DrawLine(H.PenHTMlColor("231625", 1), 1, 0, 1, Height);
  1727.                     }
  1728.                     break;
  1729.             }
  1730.  
  1731.             e.Graphics.DrawImage(B, 0, 0);
  1732.             G.Dispose();
  1733.             B.Dispose();
  1734.         }
  1735.  
  1736.     }
  1737.  
  1738.     #endregion
  1739.  
  1740.     #region Events
  1741.  
  1742.     protected override void OnResize(EventArgs e)
  1743.     {
  1744.         base.OnResize(e);
  1745.         if (SepStyle == Style.Horizental) { Height = 4; } else { Width = 4; }
  1746.     }
  1747.  
  1748.     #endregion
  1749.  
  1750. }
  1751.  
  1752. #endregion
  1753.  
  1754. #region Panel
  1755.  
  1756. public class ModalPanel : ContainerControl
  1757. {
  1758.  
  1759.     #region Variables
  1760.  
  1761.     private static HelperMethods H = new HelperMethods();
  1762.  
  1763.     #endregion
  1764.  
  1765.     #region Constructors
  1766.  
  1767.     public ModalPanel()
  1768.     {
  1769.  
  1770.         SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw |
  1771.             ControlStyles.SupportsTransparentBackColor, true);
  1772.         DoubleBuffered = true;
  1773.         BackColor = Color.Transparent;
  1774.         UpdateStyles();
  1775.  
  1776.     }
  1777.  
  1778.     #endregion
  1779.  
  1780.     #region Draw Control
  1781.  
  1782.     protected override void OnPaint(PaintEventArgs e)
  1783.     {
  1784.         using (Bitmap B = new Bitmap(Width, Height))
  1785.         using (Graphics G = Graphics.FromImage(B))
  1786.         {
  1787.             Rectangle Rect = new Rectangle(0, 0, Width - 1, Height - 1);
  1788.  
  1789.             H.FillRoundedPath(G, H.SolidBrushHTMlColor("291a2a"), Rect, 2);
  1790.  
  1791.             H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, Rect, 2);
  1792.  
  1793.             e.Graphics.DrawImage(B, 0, 0);
  1794.             G.Dispose();
  1795.             B.Dispose();
  1796.         }
  1797.     }
  1798.  
  1799.     #endregion
  1800.  
  1801.     #region Events
  1802.  
  1803.     protected override void OnResize(EventArgs e)
  1804.     {
  1805.         base.OnResize(e);
  1806.         Invalidate();
  1807.     }
  1808.  
  1809.     protected override void OnCreateControl()
  1810.     {
  1811.         base.OnCreateControl();
  1812.         Invalidate();
  1813.     }
  1814.  
  1815.     #endregion
  1816.  
  1817. }
  1818.  
  1819. #endregion
  1820.  
  1821. #region GroupBox
  1822.  
  1823. public class ModalGroupBox : ContainerControl
  1824. {
  1825.  
  1826.     #region Variables
  1827.  
  1828.     private static HelperMethods H = new HelperMethods();
  1829.     private Style _GroupBoxStyle = Style.I;
  1830.  
  1831.     #endregion
  1832.  
  1833.     #region Draw Control
  1834.  
  1835.     protected override void OnPaint(PaintEventArgs e)
  1836.     {
  1837.         using (Bitmap B = new Bitmap(Width, Height))
  1838.         using (Graphics G = Graphics.FromImage(B))
  1839.         {
  1840.             Rectangle Rect = new Rectangle(0, 0, Width - 1, Height - 1);
  1841.  
  1842.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  1843.  
  1844.             if (GroupBoxStyle==Style.I)
  1845.             {
  1846.             H.FillRoundedPath(G, H.SolidBrushHTMlColor("291a2a"), Rect, 2);
  1847.             H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, Rect, 2);
  1848.  
  1849.             G.DrawString(Text, Font, H.SolidBrushHTMlColor("a89ea9"), new Point(5, 6), StringFormat.GenericTypographic);
  1850.             G.DrawLine(H.PenHTMlColor("231625", 1), new Point(3, 32), new Point(130, 32));
  1851.             }
  1852.             else
  1853.             {
  1854.                 H.FillRoundedPath(G, H.SolidBrushHTMlColor("291a2a"), new Rectangle(0, 0, Width - 1, 32), 2);
  1855.             H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, Rect, 2);
  1856.  
  1857.             G.DrawString(Text, Font, H.SolidBrushHTMlColor("a89ea9"), new Point(5, 6), StringFormat.GenericTypographic);
  1858.             G.DrawLine(H.PenHTMlColor("231625", 1), new Point(1, 32), new Point(Width - 1, 32));
  1859.             }
  1860.  
  1861.             e.Graphics.DrawImage(B, 0, 0);
  1862.             G.Dispose();
  1863.             B.Dispose();
  1864.         }
  1865.     }
  1866.  
  1867.     #endregion
  1868.  
  1869.     #region Constructors
  1870.  
  1871.     public ModalGroupBox()
  1872.     {
  1873.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.ContainerControl, true);
  1874.         DoubleBuffered = true;
  1875.         Font = new Font("Ubuntu", 11, FontStyle.Regular);
  1876.         BackColor = Color.Transparent;
  1877.         UpdateStyles();
  1878.  
  1879.     }
  1880.  
  1881.     #endregion
  1882.  
  1883.     #region Properties
  1884.  
  1885.     public Style GroupBoxStyle
  1886.     {
  1887.         get
  1888.         {
  1889.             return _GroupBoxStyle;
  1890.         }
  1891.         set
  1892.         {
  1893.             _GroupBoxStyle = value;
  1894.             Invalidate();
  1895.         }
  1896.     }
  1897.  
  1898.     #endregion
  1899.  
  1900.     #region Enumerators
  1901.  
  1902.     public enum Style
  1903.     {
  1904.         I,
  1905.         O
  1906.     };
  1907.  
  1908.     #endregion
  1909.  
  1910. }
  1911.  
  1912. #endregion
  1913.  
  1914. #region Progress
  1915.  
  1916. public class ModalProgressBar : Control
  1917. {
  1918.  
  1919.     #region Variables
  1920.  
  1921.     private int _Maximum = 100;
  1922.     private int _Value;
  1923.     protected int CurrentValue;
  1924.     private static HelperMethods H = new HelperMethods();
  1925.  
  1926.  
  1927.     #endregion
  1928.  
  1929.     #region Properties
  1930.  
  1931.     public int Value
  1932.     {
  1933.         get
  1934.         {
  1935.             if (_Value < 0)
  1936.             {
  1937.                 return 0;
  1938.             }
  1939.             else
  1940.             {
  1941.                 return _Value;
  1942.             }
  1943.         }
  1944.         set
  1945.         {
  1946.             if (value > Maximum)
  1947.             {
  1948.                 _Value = Maximum;
  1949.             }
  1950.             _Value = value;
  1951.             RenewCurrentValue();
  1952.             Invalidate();
  1953.             if (ValueChanged != null)
  1954.                 ValueChanged(this);
  1955.             Invalidate();
  1956.            
  1957.         }
  1958.     }
  1959.  
  1960.     public int Maximum
  1961.     {
  1962.         get
  1963.         {
  1964.             return _Maximum;
  1965.  
  1966.         }
  1967.         set
  1968.         {
  1969.             if (_Maximum < value)
  1970.             {
  1971.                 _Value = value;
  1972.             }
  1973.             _Maximum = value;
  1974.             Invalidate();
  1975.         }
  1976.     }
  1977.  
  1978.  
  1979.     #endregion
  1980.  
  1981.     #region Draw Control
  1982.  
  1983.     protected override void OnPaint(PaintEventArgs e)
  1984.     {
  1985.         using (Bitmap B = new Bitmap(Width, Height))
  1986.         using (Graphics G = Graphics.FromImage(B))
  1987.         {
  1988.             Rectangle Rect = new Rectangle(0, 0, Width, Height);
  1989.  
  1990.             G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), Rect);
  1991.             G.DrawRectangle(H.PenHTMlColor("231625", 1), new Rectangle(0, 0, Width - 1, Height - 1));
  1992.  
  1993.             if (CurrentValue != 0)
  1994.             {
  1995.                 G.FillRectangle(new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(Rect.X + 1, Rect.Y + 1, CurrentValue - 2, Rect.Height - 2));
  1996.  
  1997.             }
  1998.             e.Graphics.DrawImage(B, 0, 0);
  1999.             G.Dispose();
  2000.             B.Dispose();
  2001.         }
  2002.  
  2003.     }
  2004.  
  2005.     #endregion
  2006.  
  2007.     #region Constructors
  2008.  
  2009.     public ModalProgressBar()
  2010.     {
  2011.  
  2012.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw |
  2013.                        ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  2014.         DoubleBuffered = true;
  2015.         BackColor = Color.Transparent;
  2016.         UpdateStyles();
  2017.         CurrentValue = Convert.ToInt32(_Value / _Maximum * Width);
  2018.     }
  2019.  
  2020.     #endregion
  2021.  
  2022.     #region Events
  2023.  
  2024.     public event ValueChangedEventHandler ValueChanged;
  2025.     public delegate void ValueChangedEventHandler(object sender);
  2026.     public void RenewCurrentValue()
  2027.     {
  2028.         CurrentValue = (int)Math.Round((double)(Value) / (double)(Maximum) * (double)(Width));
  2029.     }
  2030.  
  2031.     #endregion
  2032.  
  2033. }
  2034.  
  2035. #endregion
  2036.  
  2037. #region Trackbar
  2038.  
  2039. [DefaultEvent("Scroll")] public class ModalTrackBar : Control
  2040. {
  2041.  
  2042.     #region Variables
  2043.  
  2044.     private int _Maximum = 100;
  2045.     private int _Minimum;
  2046.     private int _Value;
  2047.     private int CurrentValue;
  2048.     bool Variable;
  2049.     Rectangle Track, TrackSide;
  2050.     private static HelperMethods H = new HelperMethods();
  2051.  
  2052.     #endregion
  2053.  
  2054.     #region Properties
  2055.  
  2056.     public int Minimum
  2057.     {
  2058.         get
  2059.         {
  2060.             return _Minimum;
  2061.  
  2062.         }
  2063.  
  2064.         set
  2065.         {
  2066.             if (!(value < 0))
  2067.             {
  2068.                 _Minimum = value;
  2069.                 RenewCurrentValue();
  2070.                 MoveTrack();
  2071.                 Invalidate();
  2072.             }
  2073.  
  2074.         }
  2075.     }
  2076.  
  2077.     public int Maximum
  2078.     {
  2079.         get
  2080.         {
  2081.             return _Maximum;
  2082.  
  2083.         }
  2084.         set
  2085.         {
  2086.             _Maximum = value;
  2087.             RenewCurrentValue();
  2088.             MoveTrack();
  2089.             Invalidate();
  2090.  
  2091.         }
  2092.     }
  2093.  
  2094.     public int Value
  2095.     {
  2096.         get
  2097.         {
  2098.             return _Value;
  2099.         }
  2100.         set
  2101.         {
  2102.             if (value != _Value)
  2103.             {
  2104.                 _Value = value;
  2105.                 RenewCurrentValue();
  2106.                 MoveTrack();
  2107.                 Invalidate();
  2108.                 if (Scroll != null)
  2109.                     Scroll(this);
  2110.  
  2111.             }
  2112.  
  2113.         }
  2114.     }
  2115.  
  2116.  
  2117.     #endregion
  2118.  
  2119.     #region Draw Control
  2120.  
  2121.     protected override void OnPaint(PaintEventArgs e)
  2122.     {
  2123.         using (Bitmap B = new Bitmap(Width, Height))
  2124.         using (Graphics G = Graphics.FromImage(B))
  2125.         {
  2126.  
  2127.             Cursor = Cursors.Hand;
  2128.             G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), new Rectangle(0, (int)5.5, Width, 8));
  2129.             G.DrawRectangle(H.PenHTMlColor("231625", 1), new Rectangle(0, 5, Width - 1, 8));
  2130.  
  2131.             if (CurrentValue != 0)
  2132.             {
  2133.                 G.FillRectangle(new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(1, Convert.ToInt32(5.5), CurrentValue + 4, 7));
  2134.             }
  2135.  
  2136.             G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), Track);
  2137.             G.DrawRectangle(H.PenHTMlColor("231625", 1), Track);
  2138.             G.FillRectangle(new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), TrackSide);
  2139.             G.DrawRectangle(H.PenHTMlColor("231625", 1), TrackSide);
  2140.  
  2141.             e.Graphics.DrawImage(B, 0, 0);
  2142.             G.Dispose();
  2143.             B.Dispose();
  2144.         }
  2145.     }
  2146.  
  2147.     #endregion
  2148.  
  2149.     #region Constructors
  2150.  
  2151.     public ModalTrackBar()
  2152.     {
  2153.         SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint |
  2154.         ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
  2155.         ControlStyles.SupportsTransparentBackColor, true);
  2156.         DoubleBuffered = true;
  2157.         BackColor = Color.Transparent;
  2158.         UpdateStyles();
  2159.         CurrentValue = Convert.ToInt32((Math.Round(Convert.ToDouble(Value / Maximum - 2) * Convert.ToDouble(Width))));
  2160.     }
  2161.  
  2162.     #endregion
  2163.  
  2164.     #region Events
  2165.  
  2166.     public event ScrollEventHandler Scroll;
  2167.     public delegate void ScrollEventHandler(object sender);
  2168.  
  2169.     protected override void OnMouseMove(MouseEventArgs e)
  2170.     {
  2171.         if (Variable && e.X > -1 && e.X < Width + 1)
  2172.         {
  2173.             Value = Minimum + (int)Math.Round((double)(Maximum - Minimum) * (double)e.X / Width);
  2174.         }
  2175.  
  2176.         base.OnMouseMove(e);
  2177.     }
  2178.  
  2179.     protected override void OnMouseDown(MouseEventArgs e)
  2180.     {
  2181.         if (e.Button == MouseButtons.Left && Height > 0)
  2182.         {
  2183.             RenewCurrentValue();
  2184.             if (Width > 0 && Height > 0) Track = new Rectangle(CurrentValue + Convert.ToInt32(0.8), 0, 25, 24);
  2185.  
  2186.             Variable = new Rectangle(CurrentValue, 0, 24, Height).Contains(e.Location);
  2187.         }
  2188.         base.OnMouseDown(e);
  2189.     }
  2190.  
  2191.     protected override void OnMouseUp(MouseEventArgs e)
  2192.     {
  2193.         Variable = false;
  2194.         base.OnMouseUp(e);
  2195.     }
  2196.  
  2197.     protected override void OnKeyDown(KeyEventArgs e)
  2198.     {
  2199.         if (e.KeyCode == Keys.Subtract || e.KeyCode == Keys.Down || e.KeyCode == Keys.Left)
  2200.         {
  2201.             if (Value != 0)
  2202.             {
  2203.                 Value -= 1;
  2204.  
  2205.             }
  2206.  
  2207.         }
  2208.         else if (e.KeyCode == Keys.Add || e.KeyCode == Keys.Up || e.KeyCode == Keys.Right)
  2209.         {
  2210.             if (Value != Maximum)
  2211.             {
  2212.                 Value += 1;
  2213.             }
  2214.  
  2215.         }
  2216.         base.OnKeyDown(e);
  2217.     }
  2218.  
  2219.     protected override void OnResize(EventArgs e)
  2220.     {
  2221.         if (Width > 0 && Height > 0)
  2222.         {
  2223.             RenewCurrentValue();
  2224.             MoveTrack();
  2225.  
  2226.         }
  2227.         Height = 19;
  2228.         Invalidate();
  2229.         base.OnResize(e);
  2230.     }
  2231.  
  2232.     private void MoveTrack()
  2233.     {
  2234.         if (Height > 0 && Width > 0) {Track = new Rectangle(CurrentValue ,0, 21, (int)18.5);}
  2235.         TrackSide = new Rectangle(CurrentValue + Convert.ToInt32(5.6), 5, 8, 8);
  2236.     }
  2237.  
  2238.     public void RenewCurrentValue()
  2239.     {
  2240.  
  2241.         CurrentValue = Convert.ToInt32(Math.Round((double)(Value - Minimum) / (double)(Maximum - Minimum) * (double)(Width - Convert.ToInt32(22.5))));
  2242.     }
  2243.  
  2244.     #endregion
  2245.  
  2246. }
  2247.  
  2248. #endregion
  2249.  
  2250. #region Control Button
  2251.  
  2252. public class ModalControlButton : Control
  2253. {
  2254.  
  2255.     #region Variables
  2256.  
  2257.     private HelperMethods.MouseMode State;
  2258.     private static HelperMethods H = new HelperMethods();
  2259.     private Style _ControlStyle = Style.Close;
  2260.  
  2261.     #endregion
  2262.  
  2263.     #region Properties
  2264.  
  2265.     public Style ControlStyle
  2266.     {
  2267.         get
  2268.         {
  2269.             return _ControlStyle;
  2270.         }
  2271.         set
  2272.         {
  2273.             _ControlStyle = value;
  2274.             Invalidate();
  2275.         }
  2276.     }
  2277.  
  2278.     #endregion
  2279.  
  2280.     #region Enumenators
  2281.  
  2282.     public enum Style
  2283.     {
  2284.         Close,
  2285.         Minimize,
  2286.         Maximize
  2287.     }
  2288.  
  2289.     #endregion
  2290.  
  2291.     #region Draw Control
  2292.  
  2293.     protected override void OnPaint(PaintEventArgs e)
  2294.     {
  2295.         using (Bitmap B = new Bitmap(Width, Height))
  2296.         using (Graphics G = Graphics.FromImage(B))
  2297.         {
  2298.             G.SmoothingMode = SmoothingMode.AntiAlias;
  2299.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  2300.  
  2301.             Rectangle R = new Rectangle(0, 0, Convert.ToInt32(18.5), 21);
  2302.  
  2303.             switch (State)
  2304.             {
  2305.                 case HelperMethods.MouseMode.NormalMode:
  2306.  
  2307.                     H.FillRoundedPath(G, H.SolidBrushHTMlColor("291a2a"), R, 2);
  2308.                     H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, R, 2);;
  2309.  
  2310.                       switch (ControlStyle)
  2311.                       {
  2312.  
  2313.                           case Style.Close:
  2314.                               H.FillRoundedPath(G, new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(Convert.ToInt32(5.4), Convert.ToInt32(5.4), 8, 11), 2);
  2315.                               H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, new Rectangle(Convert.ToInt32(5.4), Convert.ToInt32(5.4), 8, 11), 2);
  2316.                               break;
  2317.                           case Style.Maximize:
  2318.                               H.FillRoundedPath(G, new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(Convert.ToInt32(4.5), 6, 9, 9), 2);
  2319.                               H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, new Rectangle(Convert.ToInt32(4.5), 6, 9, 9), 2);
  2320.                               break;
  2321.                           case Style.Minimize:
  2322.                               H.FillRoundedPath(G, new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(3, Convert.ToInt32(7.5), 12, 5), 2);
  2323.                               H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, new Rectangle(3, Convert.ToInt32(7.5), 12, 5), 2);
  2324.                               break;
  2325.                       }
  2326.  
  2327.                     break;
  2328.                 case HelperMethods.MouseMode.Hovered:
  2329.                     Cursor = Cursors.Hand;
  2330.  
  2331.                     H.FillRoundedPath(G, new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("291a2a"))), R, 2);
  2332.                     H.DrawRoundedPath(G, Color.FromArgb(130, H.GetHTMLColor("291a2a")), 1, R, 2);;
  2333.  
  2334.                       switch (ControlStyle)
  2335.                       {
  2336.  
  2337.                           case Style.Close:
  2338.                               H.FillRoundedPath(G, new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(Convert.ToInt32(5.4), Convert.ToInt32(5.4), 8, 11), 2);
  2339.                               H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, new Rectangle(Convert.ToInt32(5.4), Convert.ToInt32(5.4), 8, 11), 2);
  2340.                               break;
  2341.                           case Style.Maximize:
  2342.                               H.FillRoundedPath(G, new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(Convert.ToInt32(4.5), 6, 9, 9), 2);
  2343.                               H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, new Rectangle(Convert.ToInt32(4.5), 6, 9, 9), 2);
  2344.                               break;
  2345.                           case Style.Minimize:
  2346.                               H.FillRoundedPath(G, new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(3, Convert.ToInt32(7.5), 12, 5), 2);
  2347.                               H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, new Rectangle(3, Convert.ToInt32(7.5), 12, 5), 2);
  2348.                               break;
  2349.                       }
  2350.  
  2351.                     break;
  2352.                 case HelperMethods.MouseMode.Pushed:
  2353.  
  2354.                     H.FillRoundedPath(G, H.SolidBrushHTMlColor("291a2a"), R, 2);
  2355.                     H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, R, 2);;
  2356.  
  2357.                       switch (ControlStyle)
  2358.                       {
  2359.  
  2360.                           case Style.Close:
  2361.                               H.FillRoundedPath(G, new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(Convert.ToInt32(5.4), Convert.ToInt32(5.4), 8, 11), 2);
  2362.                               H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, new Rectangle(Convert.ToInt32(5.4), Convert.ToInt32(5.4), 8, 11), 2);
  2363.                               break;
  2364.                           case Style.Maximize:
  2365.                               H.FillRoundedPath(G, new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(Convert.ToInt32(4.5), 6, 9, 9), 2);
  2366.                               H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, new Rectangle(Convert.ToInt32(4.5), 6, 9, 9), 2);
  2367.                               break;
  2368.                           case Style.Minimize:
  2369.                               H.FillRoundedPath(G, new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(3, Convert.ToInt32(7.5), 12, 5), 2);
  2370.                               H.DrawRoundedPath(G, H.GetHTMLColor("231625"), 1, new Rectangle(3, Convert.ToInt32(7.5), 12, 5), 2);
  2371.                               break;
  2372.                       }
  2373.  
  2374.                     break;
  2375.             }
  2376.  
  2377.             e.Graphics.DrawImage(B, 0, 0);
  2378.             G.Dispose();
  2379.             B.Dispose();
  2380.         }
  2381.     }
  2382.  
  2383.     #endregion
  2384.  
  2385.     #region Constructors
  2386.  
  2387.     public ModalControlButton()
  2388.     {
  2389.         SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
  2390.         ControlStyles.SupportsTransparentBackColor, true);
  2391.         DoubleBuffered = true;
  2392.         BackColor = Color.Transparent;
  2393.         Anchor = AnchorStyles.Top | AnchorStyles.Right;
  2394.         UpdateStyles();
  2395.  
  2396.     }
  2397.  
  2398.     #endregion
  2399.  
  2400.     #region Events
  2401.  
  2402.     protected override void OnClick(EventArgs e)
  2403.     {
  2404.         base.OnClick(e);
  2405.         if (ControlStyle == Style.Close)
  2406.         {
  2407.             Environment.Exit(0);
  2408.             Application.Exit();
  2409.         }
  2410.         else if (ControlStyle == Style.Minimize)
  2411.         {
  2412.             if (FindForm().WindowState == FormWindowState.Normal)
  2413.             {
  2414.                 FindForm().WindowState = FormWindowState.Minimized;
  2415.             }
  2416.         }
  2417.         else if (ControlStyle == Style.Maximize)
  2418.         {
  2419.             if (FindForm().WindowState == FormWindowState.Normal)
  2420.             {
  2421.                 FindForm().WindowState = FormWindowState.Maximized;
  2422.             }
  2423.             else if (FindForm().WindowState == FormWindowState.Maximized)
  2424.             {
  2425.                 FindForm().WindowState = FormWindowState.Normal;
  2426.             }
  2427.         }
  2428.     }
  2429.  
  2430.     protected override void OnResize(EventArgs e)
  2431.     {
  2432.         base.OnResize(e);
  2433.         Size = new Size(20, 23);
  2434.     }
  2435.  
  2436.     protected override void OnMouseEnter(EventArgs e)
  2437.     {
  2438.  
  2439.         base.OnMouseEnter(e);
  2440.         State = HelperMethods.MouseMode.Hovered;
  2441.         Invalidate();
  2442.     }
  2443.  
  2444.     protected override void OnMouseUp(MouseEventArgs e)
  2445.     {
  2446.  
  2447.         base.OnMouseUp(e);
  2448.         State = HelperMethods.MouseMode.Hovered;
  2449.         Invalidate();
  2450.     }
  2451.  
  2452.     protected override void OnMouseDown(MouseEventArgs e)
  2453.     {
  2454.  
  2455.         base.OnMouseDown(e);
  2456.         State = HelperMethods.MouseMode.Pushed;
  2457.         Invalidate();
  2458.     }
  2459.  
  2460.     protected override void OnMouseLeave(EventArgs e)
  2461.     {
  2462.  
  2463.         base.OnMouseLeave(e);
  2464.         State = HelperMethods.MouseMode.NormalMode;
  2465.         Invalidate();
  2466.     }
  2467.  
  2468.     #endregion
  2469.  
  2470. }
  2471.  
  2472. #endregion
  2473.  
  2474. #region Horizental TabControl
  2475.  
  2476. public class ModalHorizentalTabControl : TabControl
  2477. {
  2478.  
  2479.     #region Variables
  2480.  
  2481.     private static HelperMethods H = new HelperMethods();
  2482.     protected Color TabColor = H.GetHTMLColor("331f35");
  2483.    
  2484.     #endregion
  2485.  
  2486.     #region Draw Control
  2487.  
  2488.     protected override void OnPaint(PaintEventArgs e)
  2489.     {
  2490.         using (Bitmap B = new Bitmap(Width, Height))
  2491.         using (Graphics G = Graphics.FromImage(B))
  2492.         {
  2493.  
  2494.                 G.Clear(H.GetHTMLColor("331f35"));
  2495.                 G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  2496.                 G.DrawLine(new Pen(Color.FromArgb(130, H.GetHTMLColor("5b2960")), 2), new Point(4, ItemSize.Height + 1), new Point(Width - 4, ItemSize.Height + 1));
  2497.                 for (int i = 0; i <= TabCount - 1; i++)
  2498.                 {
  2499.                     Rectangle R = GetTabRect(i);
  2500.                     if (i == SelectedIndex)
  2501.                     {
  2502.                         G.DrawLine(H.PenHTMlColor("5b2960", 2), new Point(R.X + 10, ItemSize.Height + 1), new Point(R.X - 10 + R.Width, ItemSize.Height + 1));
  2503.                         H.CentreString(G, TabPages[i].Text, Font, H.SolidBrushHTMlColor("5b2960"), R);
  2504.                         H.CentreString(G, TabPages[i].Text, Font, new SolidBrush(Color.FromArgb(30, Color.White)), R);
  2505.                     }
  2506.                     else
  2507.                     {
  2508.                         H.CentreString(G, TabPages[i].Text, Font, H.SolidBrushHTMlColor("a89ea9"), R);
  2509.                     }
  2510.                 }
  2511.  
  2512.             e.Graphics.DrawImage(B, 0, 0);
  2513.             G.Dispose();
  2514.             B.Dispose();
  2515.         }
  2516.     }
  2517.  
  2518.     #endregion
  2519.  
  2520.     #region Constructors
  2521.  
  2522.     public ModalHorizentalTabControl()
  2523.     {
  2524.         SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor, true);
  2525.         DoubleBuffered = true;
  2526.         Alignment = TabAlignment.Top;
  2527.         SizeMode = TabSizeMode.Fixed;
  2528.         DrawMode = TabDrawMode.OwnerDrawFixed;
  2529.         ItemSize = new Size(110, 35);
  2530.         Font = new Font("Ubuntu", 13, FontStyle.Regular, GraphicsUnit.Pixel);
  2531.         Dock = DockStyle.None;
  2532.         UpdateStyles();
  2533.  
  2534.     }
  2535.  
  2536.     #endregion
  2537.  
  2538.     #region Events
  2539.  
  2540.     protected override void OnCreateControl()
  2541.     {
  2542.         base.OnCreateControl();
  2543.         foreach (TabPage Tab in base.TabPages)
  2544.         {
  2545.             Tab.BackColor = TabColor;
  2546.         }
  2547.     }
  2548.  
  2549.     #endregion
  2550.  
  2551. }
  2552.  
  2553. #endregion
  2554.  
  2555. #region Vertical TabControl
  2556.  
  2557. public class ModalVerticalTabControl : TabControl
  2558. {
  2559.  
  2560.     #region Variables
  2561.        
  2562.     private static HelperMethods H = new HelperMethods();
  2563.     private Color TabColor = H.GetHTMLColor("331f35");
  2564.     private bool _ShowBorder = true;
  2565.  
  2566.     #endregion
  2567.  
  2568.     #region Draw Control
  2569.  
  2570.     protected override void OnPaint(PaintEventArgs e)
  2571.     {
  2572.         using (Bitmap B = new Bitmap(Width, Height))
  2573.         using (Graphics G = Graphics.FromImage(B))
  2574.         {
  2575.  
  2576.             G.Clear(H.GetHTMLColor("331f35"));
  2577.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  2578.          
  2579.             for (int i = 0; i <= TabCount - 1; i++)
  2580.             {
  2581.                 Rectangle R = GetTabRect(i);
  2582.                 if (TabPages[i].Tag !=null)
  2583.                 {
  2584.                     G.DrawString(TabPages[i].Text.ToUpper(), Font, new SolidBrush(Color.FromArgb(180, H.GetHTMLColor("5b2960"))), new Point(R.X + 5, R.Y + 9));
  2585.                 }
  2586.                 else if (i == SelectedIndex)
  2587.                 {
  2588.                     G.FillRectangle(new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), R);
  2589.                     G.FillRectangle(new SolidBrush(Color.FromArgb(230, H.GetHTMLColor("291a2a"))), new Rectangle(R.X, R.Y, 5, R.Height));
  2590.                     H.CentreString(G, TabPages[i].Text, Font, H.SolidBrushHTMlColor("5b2960"), R);                  
  2591.                 }
  2592.                 else
  2593.                 {
  2594.                     H.CentreString(G, TabPages[i].Text, Font, H.SolidBrushHTMlColor("a89ea9"), R);
  2595.                 }
  2596.             }
  2597.                if (ShowBorder)
  2598.                {
  2599.                    G.DrawRectangle(H.PenHTMlColor("291a2a", 1), new Rectangle(0, 0, Width - 1, Height - 1));
  2600.                }
  2601.             e.Graphics.DrawImage(B, 0, 0);
  2602.             G.Dispose();
  2603.             B.Dispose();
  2604.         }
  2605.     }
  2606.  
  2607.     #endregion
  2608.  
  2609.     #region Constructors
  2610.  
  2611.     public ModalVerticalTabControl()
  2612.     {
  2613.         SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor, true);
  2614.         DoubleBuffered = true;
  2615.         SizeMode = TabSizeMode.Fixed;
  2616.         ItemSize = new Size(30, 120);
  2617.         DrawMode = TabDrawMode.OwnerDrawFixed;
  2618.         Alignment = TabAlignment.Left;
  2619.         Dock = DockStyle.None;
  2620.         Font = new Font("Ubuntu", 13, FontStyle.Regular, GraphicsUnit.Pixel);
  2621.         UpdateStyles();
  2622.  
  2623.     }
  2624.  
  2625.     #endregion
  2626.  
  2627.     #region Events
  2628.  
  2629.     protected override void OnCreateControl()
  2630.     {
  2631.         base.OnCreateControl();
  2632.         foreach (TabPage Tab in base.TabPages)
  2633.         {
  2634.             Tab.BackColor = TabColor;
  2635.         }
  2636.     }
  2637.  
  2638.     #endregion
  2639.  
  2640.     #region Properties
  2641.  
  2642.     public bool ShowBorder
  2643.     {
  2644.         get
  2645.         {
  2646.             return _ShowBorder;
  2647.         }
  2648.         set
  2649.         {
  2650.             _ShowBorder = value;
  2651.             Invalidate();
  2652.         }
  2653.     }
  2654.  
  2655.     #endregion
  2656.  
  2657. }
  2658.  
  2659. #endregion
  2660.  
  2661. #region RichTextbox
  2662.  
  2663. [DefaultEvent("TextChanged")] public class ModalRichTextbox : Control
  2664. {
  2665.  
  2666.     #region Variables
  2667.  
  2668.     private RichTextBox T = new RichTextBox();
  2669.  
  2670.     private bool _ReadOnly;
  2671.     protected HelperMethods.MouseMode State = HelperMethods.MouseMode.NormalMode;
  2672.     private static HelperMethods H = new HelperMethods();
  2673.     private static Color TBC = H.GetHTMLColor("291a2a");
  2674.     private static Color TFC = H.GetHTMLColor("a89ea9");
  2675.     private bool _WordWrap;
  2676.     private bool _AutoWordSelection;
  2677.     private Color _BackColor = TBC;
  2678.     #endregion
  2679.  
  2680.     #region  Native Methods
  2681.     [System.Runtime.InteropServices.DllImport("user32.dll")]
  2682.     private static extern Int32 SendMessage(IntPtr hWnd, int msg, int wParam, [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
  2683. string lParam);
  2684.  
  2685.     #endregion
  2686.  
  2687.     #region Draw Control
  2688.  
  2689.     protected override void OnPaint(PaintEventArgs e)
  2690.     {
  2691.         using (Bitmap B = new Bitmap(Width, Height))
  2692.         using (Graphics G = Graphics.FromImage(B))
  2693.         {
  2694.  
  2695.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  2696.             Rectangle Rect = new Rectangle(0, 0, Width - 1, Height - 1);
  2697.            
  2698.             G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), Rect);
  2699.             G.DrawRectangle(H.PenHTMlColor("231625", 1), Rect);
  2700.  
  2701.             if (ContextMenuStrip != null) { T.ContextMenuStrip = ContextMenuStrip; }
  2702.  
  2703.             e.Graphics.DrawImage(B, 0, 0);
  2704.             G.Dispose();
  2705.             B.Dispose();
  2706.         }
  2707.     }
  2708.  
  2709.     #endregion
  2710.  
  2711.     #region Constructors
  2712.  
  2713.     public ModalRichTextbox()
  2714.     {
  2715.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
  2716.                 ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer |
  2717.                 ControlStyles.SupportsTransparentBackColor, true);
  2718.         DoubleBuffered = true;
  2719.         UpdateStyles();
  2720.         Font = new Font("Arial", 11, FontStyle.Regular);
  2721.         Size = new Size(135, 30);
  2722.         T.Multiline = true;
  2723.         T.Cursor = Cursors.IBeam;
  2724.         T.BackColor = TBC;
  2725.         T.ForeColor = TFC;
  2726.         T.BorderStyle = BorderStyle.None;
  2727.         T.Location = new Point(7, 7);
  2728.         T.Font = Font;
  2729.         T.Size = new Size(Width - 10, 30);
  2730.         T.TextChanged += T_TextChanged;
  2731.         T.MouseDown += T_MouseDown;
  2732.         T.MouseEnter += T_MouseEnter;
  2733.         T.MouseUp += T_MouseUp;
  2734.         T.MouseLeave += T_MouseLeave;
  2735.         T.MouseHover += T_MouseHover;
  2736.         T.KeyDown += T_KeyDown;
  2737.     }
  2738.  
  2739.     #endregion
  2740.  
  2741.     #region Properties
  2742.  
  2743.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  2744.     public BorderStyle BorderStyle
  2745.     {
  2746.         get
  2747.         {
  2748.             return BorderStyle.None;
  2749.         }
  2750.     }
  2751.  
  2752.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  2753.     public bool Multiline
  2754.     {
  2755.         get
  2756.         {
  2757.             return true;
  2758.         }
  2759.        
  2760.     }
  2761.  
  2762.     public bool ReadOnly
  2763.     {
  2764.         get { return _ReadOnly; }
  2765.         set
  2766.         {
  2767.             _ReadOnly = value;
  2768.             if (T != null)
  2769.             {
  2770.                 T.ReadOnly = value;
  2771.             }
  2772.         }
  2773.     }
  2774.  
  2775.     [Browsable(false)] public override Image BackgroundImage
  2776.     {
  2777.         get
  2778.         {
  2779.             return null;
  2780.         }      
  2781.     }
  2782.  
  2783.     [Browsable(false)] public override ImageLayout BackgroundImageLayout
  2784.     {
  2785.         get
  2786.         {
  2787.             return base.BackgroundImageLayout;
  2788.         }
  2789.         set
  2790.         {
  2791.             base.BackgroundImageLayout = value;
  2792.         }
  2793.     }
  2794.  
  2795.     public override string Text
  2796.     {
  2797.         get
  2798.         {
  2799.             return base.Text;
  2800.         }
  2801.         set
  2802.         {
  2803.             base.Text = value;
  2804.             if (T != null)
  2805.             {
  2806.                 T.Text = value;
  2807.             }
  2808.         }
  2809.     }
  2810.  
  2811.     override public Color BackColor
  2812.     {
  2813.  
  2814.         get { return Color.Transparent; }
  2815.    
  2816.     }
  2817.  
  2818.     override public Color ForeColor
  2819.     {
  2820.  
  2821.         get { return Color.Transparent; }
  2822.  
  2823.     }
  2824.  
  2825.     public bool WordWrap
  2826.     {
  2827.         get
  2828.         {
  2829.             return _WordWrap;
  2830.         }
  2831.         set
  2832.         {
  2833.             _WordWrap = value;
  2834.             if (T != null)
  2835.             {
  2836.                 T.WordWrap = value;
  2837.             }
  2838.         }
  2839.     }
  2840.  
  2841.     public bool AutoWordSelection
  2842.     {
  2843.         get
  2844.         {
  2845.             return _AutoWordSelection;
  2846.         }
  2847.         set
  2848.         {
  2849.             _AutoWordSelection = value;
  2850.             if(T !=null)
  2851.             {
  2852.                 T.AutoWordSelection = value;
  2853.             }
  2854.         }
  2855.     }
  2856.  
  2857.     #endregion
  2858.  
  2859.     #region Events
  2860.  
  2861.     private void T_MouseHover(object sender, EventArgs e)
  2862.     {
  2863.         State = HelperMethods.MouseMode.Hovered;
  2864.         Invalidate();
  2865.     }
  2866.  
  2867.     private void T_MouseLeave(object sender, EventArgs e)
  2868.     {
  2869.         State = HelperMethods.MouseMode.NormalMode;
  2870.         Invalidate();
  2871.     }
  2872.  
  2873.     private void T_MouseUp(object sender, EventArgs e)
  2874.     {
  2875.         State = HelperMethods.MouseMode.Pushed;
  2876.         Invalidate();
  2877.     }
  2878.  
  2879.     private void T_MouseEnter(object sender, EventArgs e)
  2880.     {
  2881.         State = HelperMethods.MouseMode.Pushed;
  2882.         Invalidate();
  2883.     }
  2884.  
  2885.     private void T_MouseDown(object sender, EventArgs e)
  2886.     {
  2887.         State = HelperMethods.MouseMode.Pushed;
  2888.         Invalidate();
  2889.     }
  2890.  
  2891.     private void T_TextChanged(object sender, EventArgs e)
  2892.     {
  2893.         Text = T.Text;
  2894.     }
  2895.  
  2896.     protected override void OnTextChanged(EventArgs e)
  2897.     {
  2898.         base.OnTextChanged(e);
  2899.         T.Text = Text;
  2900.     }
  2901.  
  2902.     private void T_KeyDown(object sender, KeyEventArgs e)
  2903.     {
  2904.         if (e.Control && e.KeyCode == Keys.A) { e.SuppressKeyPress = true; }
  2905.         if (e.Control && e.KeyCode == Keys.C)
  2906.         {
  2907.             T.Copy();
  2908.             e.SuppressKeyPress = true;
  2909.         }
  2910.     }
  2911.  
  2912.     protected override void OnCreateControl()
  2913.     {
  2914.         base.OnCreateControl();
  2915.         if (!Controls.Contains(T)) { Controls.Add(T); }
  2916.    
  2917.  
  2918.     }
  2919.  
  2920.     protected override void OnFontChanged(EventArgs e)
  2921.     {
  2922.         base.OnFontChanged(e);
  2923.         T.Font = Font;
  2924.     }
  2925.  
  2926.     protected override void OnSizeChanged(EventArgs e)
  2927.     {
  2928.         base.OnSizeChanged(e);
  2929.         T.Size = new Size(Width - 10, Height - 5);
  2930.     }
  2931.  
  2932.     #endregion
  2933.  
  2934.  
  2935. }
  2936.  
  2937. #endregion
  2938.  
  2939. #region Switch
  2940.  
  2941. [DefaultEvent("Switch")] public class ModalSwitch : Control
  2942. {
  2943.  
  2944.     #region Variables
  2945.  
  2946.     private bool _Switched = false;
  2947.     private static HelperMethods H = new HelperMethods();
  2948.  
  2949.     #endregion
  2950.  
  2951.     #region Constructors
  2952.  
  2953.     public ModalSwitch()
  2954.     {
  2955.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
  2956.         ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  2957.         DoubleBuffered = true;
  2958.         UpdateStyles();
  2959.         BackColor = Color.Transparent;
  2960.         Cursor = Cursors.Hand;
  2961.         Font = new Font("Ubuntu", 10, FontStyle.Regular);
  2962.         Size = new Size(70, 28);
  2963.     }
  2964.  
  2965.     #endregion
  2966.  
  2967.     #region Properties
  2968.  
  2969.     public bool Switched
  2970.     {
  2971.         get { return _Switched; }
  2972.  
  2973.         set
  2974.         { _Switched = value;
  2975.         Invalidate();
  2976.         }
  2977.     }
  2978.  
  2979.     #endregion
  2980.  
  2981.     #region Draw Control
  2982.  
  2983.     protected override void OnPaint(PaintEventArgs e)
  2984.     {
  2985.         base.OnPaint(e);
  2986.         Bitmap B = new Bitmap(Width, Height);
  2987.         using (Graphics G = Graphics.FromImage(B))
  2988.         {
  2989.  
  2990.             G.SmoothingMode = SmoothingMode.HighQuality;
  2991.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  2992.             if (Switched)
  2993.             {
  2994.  
  2995.                 G.FillRectangle(new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(0, 0, 70, 27));
  2996.  
  2997.                 G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), new Rectangle(Width - Convert.ToInt32(28.5), Convert.ToInt32(1.5), 25, 23));
  2998.                 G.DrawRectangle(H.PenHTMlColor("231625", 1), new Rectangle(Width - Convert.ToInt32(28.5), Convert.ToInt32(1.5), 25, 23));
  2999.                 G.DrawLine(H.PenHTMlColor("5b2960", 1), Width - 13, 8, Width - 13, 18);
  3000.                 G.DrawLine(H.PenHTMlColor("5b2960", 1), Width - 16, 7, Width - 16, 19);
  3001.                 G.DrawLine(H.PenHTMlColor("5b2960", 1), Width - 19, 8, Width - 19, 18);
  3002.  
  3003.                 G.DrawString("ON", Font, Brushes.Silver, new Point(Width - 62, 5));
  3004.             }
  3005.             else
  3006.             {
  3007.                 G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), new Rectangle(0, 0, 70, 27));
  3008.  
  3009.                 G.FillRectangle(new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), new Rectangle(3, Convert.ToInt32(1.5), 25, 23));
  3010.                 G.DrawRectangle(H.PenHTMlColor("231625", 1), new Rectangle(3, Convert.ToInt32(1.5), 25, 23));
  3011.  
  3012.                 G.DrawLine(H.PenHTMlColor("231625", 1), 12, 8, 12, 18);
  3013.                 G.DrawLine(H.PenHTMlColor("231625", 1), 15, 7, 15, 19);
  3014.                 G.DrawLine(H.PenHTMlColor("231625", 1), 18, 8, 18, 18);
  3015.  
  3016.                 G.DrawString("OFF", Font, H.SolidBrushHTMlColor("a89ea9"), new Point(33, 5));
  3017.             }
  3018.  
  3019.             G.DrawRectangle(H.PenHTMlColor("231625", 1), new Rectangle(0, 0, 69, 27));
  3020.  
  3021.         e.Graphics.DrawImage(B, 0, 0);
  3022.         G.Dispose();
  3023.         B.Dispose();
  3024.         }
  3025.    
  3026.     }
  3027.  
  3028.     #endregion
  3029.  
  3030.     #region Events
  3031.  
  3032.     public event CheckedChangedEventHandler Switch;
  3033.     public delegate void CheckedChangedEventHandler(object sender);
  3034.  
  3035.     protected override void OnClick(EventArgs e)
  3036.     {
  3037.  
  3038.         _Switched = !_Switched;
  3039.         if (Switch != null)
  3040.         {
  3041.             Switch(this);
  3042.         }
  3043.         base.OnClick(e);
  3044.         Invalidate();
  3045.     }
  3046.  
  3047.     protected override void OnResize(EventArgs e)
  3048.     {
  3049.         base.OnResize(e);
  3050.         Size = new Size(70, 28);
  3051.     }
  3052.  
  3053.     #endregion
  3054.  
  3055. }
  3056.  
  3057. #endregion
  3058.  
  3059. #region ContextMenuStrip
  3060.  
  3061. public class ModalContextMenuStrip : ContextMenuStrip
  3062. {
  3063.  
  3064.     #region Variables
  3065.  
  3066.     private ToolStripItemClickedEventArgs ClickedEventArgs;
  3067.     private static HelperMethods H = new HelperMethods();
  3068.  
  3069.     #endregion
  3070.  
  3071.     #region Constructors
  3072.  
  3073.     public ModalContextMenuStrip()
  3074.     {
  3075.         Renderer = new ModalToolStripRender();
  3076.         BackColor = H.GetHTMLColor("291a2a");
  3077.     }
  3078.  
  3079.     #endregion
  3080.  
  3081.     #region Events
  3082.  
  3083.     public event ClickedEventHandler Clicked;
  3084.     public delegate void ClickedEventHandler(object sender);
  3085.  
  3086.     protected override void OnItemClicked(ToolStripItemClickedEventArgs e)
  3087.     {
  3088.         if ((e.ClickedItem != null) && !(e.ClickedItem is ToolStripSeparator))
  3089.         {
  3090.             if (object.ReferenceEquals(e, ClickedEventArgs))
  3091.                 OnItemClicked(e);
  3092.             else
  3093.             {
  3094.                 ClickedEventArgs = e; if (Clicked != null)
  3095.                 {
  3096.                     Clicked(this);
  3097.                 }
  3098.             }
  3099.         }
  3100.     }
  3101.  
  3102.     protected override void OnMouseHover(EventArgs e)
  3103.     {
  3104.         base.OnMouseHover(e);
  3105.         Cursor = Cursors.Hand;
  3106.         Invalidate();
  3107.     }
  3108.  
  3109.     protected override void OnMouseUp(MouseEventArgs e)
  3110.     {
  3111.         base.OnMouseUp(e);
  3112.         Cursor = Cursors.Hand;
  3113.         Invalidate();
  3114.     }
  3115.  
  3116.     #endregion
  3117.    
  3118.     #region ModalToolStripMenuItem
  3119.  
  3120. public sealed class ModalToolStripMenuItem : ToolStripMenuItem
  3121.     {
  3122.  
  3123.         #region Constructors
  3124.  
  3125.         public ModalToolStripMenuItem()
  3126.         {
  3127.             AutoSize = false;
  3128.             Size = new Size(160, 30);
  3129.         }
  3130.  
  3131.         #endregion
  3132.  
  3133.         #region Adding DropDowns
  3134.  
  3135.         protected override ToolStripDropDown CreateDefaultDropDown()
  3136.         {
  3137.             if (DesignMode)
  3138.             { return base.CreateDefaultDropDown(); }
  3139.             ModalContextMenuStrip DP = new ModalContextMenuStrip();
  3140.             DP.Items.AddRange(base.CreateDefaultDropDown().Items);
  3141.             return DP;
  3142.         }
  3143.  
  3144.         #endregion
  3145.  
  3146.     }
  3147.  
  3148.     #endregion
  3149.  
  3150.     #region ModalToolStripRender
  3151.  
  3152.     public sealed class ModalToolStripRender : ToolStripProfessionalRenderer
  3153.     {
  3154.  
  3155.         #region Drawing Text
  3156.  
  3157.         protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
  3158.         {
  3159.             e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  3160.             Rectangle textRect = new Rectangle(25, e.Item.ContentRectangle.Y, e.Item.ContentRectangle.Width - (24 + 16), e.Item.ContentRectangle.Height - 4);
  3161.             using (Font F = new Font("Ubuntu", 11, FontStyle.Regular))
  3162.             {
  3163.                 using (Brush B = e.Item.Enabled ? H.SolidBrushHTMlColor("a89ea9") : new SolidBrush(Color.FromArgb(70, H.GetHTMLColor("5b2960"))))
  3164.                 {
  3165.                     using (StringFormat ST = new StringFormat { LineAlignment = StringAlignment.Center })
  3166.                     {
  3167.                         e.Graphics.DrawString(e.Text, F, B, textRect);
  3168.                     }
  3169.                 }
  3170.             }
  3171.         }
  3172.  
  3173.         #endregion
  3174.  
  3175.         #region Drawing Backgrounds
  3176.  
  3177.         protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
  3178.         {
  3179.             base.OnRenderToolStripBackground(e);  
  3180.             e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  3181.             e.Graphics.InterpolationMode = InterpolationMode.High;
  3182.             e.Graphics.Clear(H.GetHTMLColor("291a2a"));
  3183.         }
  3184.  
  3185.         protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
  3186.         {
  3187.             e.Graphics.InterpolationMode = InterpolationMode.High;
  3188.             e.Graphics.Clear(H.GetHTMLColor("291a2a"));
  3189.             Rectangle R = new Rectangle(0, e.Item.ContentRectangle.Y - 2, e.Item.ContentRectangle.Width + 4, e.Item.ContentRectangle.Height + 3);
  3190.  
  3191.             e.Graphics.FillRectangle(e.Item.Selected && e.Item.Enabled ? new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))) : H.SolidBrushHTMlColor("291a2a"), R);
  3192.  
  3193.         }
  3194.  
  3195.         #endregion
  3196.  
  3197.         #region Set Image Margin
  3198.  
  3199.         protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
  3200.         {
  3201.             //MyBase.OnRenderImageMargin(e)
  3202.             //I Make above line comment which makes users to be able to add images to ToolStrips
  3203.         }
  3204.  
  3205.         #endregion
  3206.  
  3207.         #region Drawing Seperators & Borders
  3208.  
  3209.         protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
  3210.         {
  3211.             e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  3212.             e.Graphics.DrawLine(new Pen(Color.FromArgb(200, H.GetHTMLColor("231625")), 1), new Point(e.Item.Bounds.Left, e.Item.Bounds.Height / 2), new Point(e.Item.Bounds.Right - 5, e.Item.Bounds.Height / 2));
  3213.         }
  3214.  
  3215.         protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
  3216.         {
  3217.             e.Graphics.InterpolationMode = InterpolationMode.High;
  3218.             e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  3219.             H.DrawRoundedPath(e.Graphics, H.GetHTMLColor("231625"), 1, new Rectangle(e.AffectedBounds.X, e.AffectedBounds.Y, e.AffectedBounds.Width - 1, e.AffectedBounds.Height - 1), 4);
  3220.         }
  3221.  
  3222.         #endregion
  3223.  
  3224.         #region Drawing DropDown Arrows
  3225.  
  3226.         protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
  3227.         {
  3228.             int ArrowX,ArrowY;
  3229.             ArrowX = e.ArrowRectangle.X + e.ArrowRectangle.Width / 2;
  3230.             ArrowY = e.ArrowRectangle.Y + e.ArrowRectangle.Height / 2;
  3231.             Point[] ArrowPoints = new Point[] {
  3232.                 new Point(ArrowX - 5, ArrowY - 5),
  3233.                 new Point(ArrowX, ArrowY),
  3234.                 new Point(ArrowX - 5, ArrowY + 5)
  3235.             };
  3236.             if (e.Item.Enabled)
  3237.             {
  3238.                 e.Graphics.FillPolygon(new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), ArrowPoints);
  3239.             }
  3240.             else
  3241.             {
  3242.                 e.Graphics.FillPolygon(new SolidBrush(Color.FromArgb(40, H.GetHTMLColor("5b2960"))), ArrowPoints);
  3243.             }
  3244.         }
  3245.  
  3246.         #endregion
  3247.  
  3248.     }
  3249.  
  3250.     #endregion
  3251.  
  3252. }
  3253.  
  3254. #endregion
  3255.  
  3256. #region NumericalUpDown
  3257.  
  3258. public class ModalNumericUpDown : Control
  3259. {
  3260.  
  3261.     #region  Variables
  3262.  
  3263.     private int X, Y, _Value, _Maximum, _Minimum;
  3264.     private static HelperMethods H = new HelperMethods();
  3265.  
  3266.     #endregion
  3267.  
  3268.     #region Draw Control
  3269.  
  3270.     protected override void OnPaint(PaintEventArgs e)
  3271.     {
  3272.         using (Bitmap B = new Bitmap(Width, Height))
  3273.         using (Graphics G = Graphics.FromImage(B))
  3274.         {
  3275.  
  3276.                 G.SmoothingMode = SmoothingMode.AntiAlias;
  3277.                 G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  3278.  
  3279.             Rectangle Rect = new Rectangle(0,0, Width - 1, Height - 1);
  3280.            
  3281.                 G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), Rect);
  3282.  
  3283.                 G.FillPath(new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), H.RoundRec(new Rectangle(Width - 25, Convert.ToInt32(0.6), 23, Height - Convert.ToInt32(2.6)), 2));
  3284.                 G.DrawLine(H.PenHTMlColor("231625", 1), new Point(Width - 25, 1), new Point(Width - 25, Height - 2));
  3285.                 G.DrawRectangle(H.PenHTMlColor("231625", 1), Rect);
  3286.                 using (GraphicsPath AboveWardTriangle = new GraphicsPath())
  3287.                  {
  3288.                 AboveWardTriangle.AddLine(Width - 17, 10, Width - 2, 10);
  3289.                     AboveWardTriangle.AddLine(Width - 9, 10, Width - 13, 4);
  3290.                     AboveWardTriangle.CloseFigure();
  3291.                     G.FillPath(H.SolidBrushHTMlColor("291a2a"), AboveWardTriangle);
  3292.                  }
  3293.  
  3294.                 using (GraphicsPath DownWardTriangle = new GraphicsPath())
  3295.                  {
  3296.                     DownWardTriangle.AddLine(Width - 17, 13, Width - 2, 13);
  3297.                     DownWardTriangle.AddLine(Width - 9, 13, Width - 13, 19);
  3298.                     DownWardTriangle.CloseFigure();
  3299.                     G.FillPath(H.SolidBrushHTMlColor("291a2a"), DownWardTriangle);
  3300.                  }
  3301.  
  3302.                 H.CentreString(G, Value.ToString(), Font, H.SolidBrushHTMlColor("a89ea9"), new Rectangle(0, 0, Width - 18, Height - 1));
  3303.            
  3304.  
  3305.             e.Graphics.DrawImage(B, 0, 0);
  3306.             G.Dispose();
  3307.             B.Dispose();
  3308.         }
  3309.     }
  3310.  
  3311.     #endregion
  3312.  
  3313.     #region Properties
  3314.  
  3315.     public int Value
  3316.     {
  3317.         get
  3318.         {
  3319.             return _Value;
  3320.         }
  3321.         set
  3322.         {
  3323.             if (value <= Maximum & value >= Minimum) { _Value = value; }
  3324.             Invalidate();
  3325.         }
  3326.     }
  3327.  
  3328.     public int Maximum
  3329.     {
  3330.         get
  3331.         {
  3332.             return _Maximum;
  3333.         }
  3334.         set
  3335.         {
  3336.             if (value > Minimum) { _Maximum = value; }
  3337.             if (value > _Maximum) { value = _Maximum; }
  3338.             Invalidate();
  3339.         }
  3340.     }
  3341.  
  3342.     public int Minimum
  3343.     {
  3344.  
  3345.         get
  3346.         {
  3347.             return _Minimum;
  3348.         }
  3349.         set
  3350.         {
  3351.             if (value < Maximum) { _Minimum = value; }
  3352.             if (value < _Minimum) { value = _Minimum; }
  3353.             Invalidate();
  3354.         }
  3355.  
  3356.     }
  3357.  
  3358.  
  3359.     #endregion
  3360.  
  3361.     #region Constructors
  3362.  
  3363.     public ModalNumericUpDown()
  3364.     {
  3365.         SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  3366.         DoubleBuffered = true;
  3367.         BackColor = Color.Transparent;
  3368.         Font = new Font("Ubuntu", 10, FontStyle.Regular);
  3369.         UpdateStyles();
  3370.     }
  3371.  
  3372.     #endregion
  3373.  
  3374.     #region Events
  3375.  
  3376.     protected override void OnCreateControl()
  3377.     {
  3378.         base.OnCreateControl();
  3379.  
  3380.     }
  3381.  
  3382.     protected override void OnMouseMove(MouseEventArgs e)
  3383.     {
  3384.         base.OnMouseMove(e);
  3385.         X = e.Location.X;
  3386.         Y = e.Location.Y;
  3387.         Invalidate();
  3388.         if (e.X < Width - 24) { Cursor = Cursors.IBeam; } else { Cursor = Cursors.Default; }
  3389.     }
  3390.  
  3391.     protected override void OnMouseDown(MouseEventArgs e)
  3392.     {
  3393.         base.OnMouseDown(e);
  3394.         if (X > Width - 18 && X < Width - 4)
  3395.         {
  3396.             if (Y < 14)
  3397.             {
  3398.                 if ((Value + 1) <= Maximum) { Value += 1; }
  3399.             }
  3400.         }
  3401.         else
  3402.         {
  3403.             if ((Value - 1) >= Minimum) { Value -= 1; }
  3404.  
  3405.         }
  3406.         Invalidate();
  3407.     }
  3408.  
  3409.     protected override void OnResize(EventArgs e)
  3410.     {
  3411.         base.OnResize(e);
  3412.  
  3413.         Invalidate();
  3414.     }
  3415.  
  3416.     #endregion
  3417.  
  3418. }
  3419.  
  3420. #endregion
  3421.  
  3422. #region ListBox
  3423.  
  3424. public class ModalListBox : Control
  3425. {
  3426.  
  3427.     #region Variables
  3428.  
  3429.     private ListBox LB = new ListBox();
  3430.     private static HelperMethods H = new HelperMethods();
  3431.     private string[] _Items = new string[]{string.Empty};
  3432.  
  3433.     #endregion
  3434.  
  3435.     #region Properties
  3436.  
  3437.     public string[] Items
  3438.     {
  3439.         get { return _Items; }
  3440.         set
  3441.         {
  3442.             _Items = value;
  3443.             LB.Items.Clear();
  3444.             LB.Items.AddRange(value);
  3445.             Invalidate();
  3446.         }
  3447.     }
  3448.  
  3449.     public string SelectedItem
  3450.     {
  3451.         get
  3452.         {
  3453.             return LB.SelectedItem.ToString();          
  3454.         }
  3455.     }
  3456.  
  3457.     public int SelectedIndex
  3458.     {
  3459.         get
  3460.         {
  3461.            
  3462.             if (LB.SelectedIndex < 0)
  3463.             {
  3464.                return 0;
  3465.             }
  3466.             else
  3467.             {
  3468.                return LB.SelectedIndex;  
  3469.             }
  3470.         }
  3471.     }
  3472.  
  3473.     public void Clear()
  3474.     {
  3475.         LB.Items.Clear();
  3476.     }
  3477.  
  3478.     #endregion
  3479.  
  3480.     #region Events
  3481.  
  3482.     public void ClearSelected()
  3483.     {
  3484.         for (int i = (LB.SelectedItems.Count - 1); i >= 0; i += -1)
  3485.         {
  3486.             LB.Items.Remove(LB.SelectedItems[i]);
  3487.         }
  3488.     }
  3489.  
  3490.     protected override void OnCreateControl()
  3491.     {
  3492.         base.OnCreateControl();
  3493.         LB.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
  3494.         LB.ScrollAlwaysVisible = false;
  3495.         LB.HorizontalScrollbar = false;
  3496.         LB.BorderStyle = BorderStyle.None;
  3497.         LB.ItemHeight = 20;
  3498.         LB.IntegralHeight = false;
  3499.         LB.DrawItem += OnDrawItem;
  3500.         if (!Controls.Contains(LB))
  3501.         {
  3502.             Controls.Add(LB);
  3503.         }
  3504.     }
  3505.  
  3506.     public void AddRange(object[] items)
  3507.     {
  3508.         LB.Items.Remove(string.Empty);
  3509.         LB.Items.AddRange(items);
  3510.     }
  3511.  
  3512.     public void AddItem(object item)
  3513.     {
  3514.         LB.Items.Remove(string.Empty);
  3515.         LB.Items.Add(item);
  3516.     }
  3517.  
  3518.     private void LB_SelectIndexChanged(object sender, EventArgs e)
  3519.     {
  3520.         LB.Invalidate();
  3521.     }
  3522.  
  3523.     #endregion
  3524.  
  3525.     #region Constructors
  3526.  
  3527.     public ModalListBox()
  3528.     {
  3529.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
  3530.         DoubleBuffered = true;
  3531.         Font = new Font("Ubuntu", 10, FontStyle.Regular);
  3532.         BackColor = Color.Transparent;
  3533.         LB.BackColor = H.GetHTMLColor("291a2a");
  3534.         LB.ForeColor = H.GetHTMLColor("a89ea9");
  3535.         LB.Location = new Point(2, 2);
  3536.         LB.SelectedIndexChanged += LB_SelectIndexChanged;
  3537.         LB.Font = Font;
  3538.         LB.Items.Clear();
  3539.         Size = new Size(130, 100);
  3540.     }
  3541.  
  3542.     #endregion
  3543.  
  3544.     #region Draw Control
  3545.  
  3546.     protected void OnDrawItem(object sender, DrawItemEventArgs e)
  3547.     {
  3548.         //e.DrawBackground();
  3549.  
  3550.         using (Bitmap B = new Bitmap(Width, Height))
  3551.         {
  3552.             using (Graphics G = Graphics.FromImage(B))
  3553.             {
  3554.                 G.SmoothingMode = SmoothingMode.HighQuality;
  3555.                 G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  3556.  
  3557.                 if (e.Index < 0 | Items.Length < 1)
  3558.                     return;
  3559.  
  3560.  
  3561.                 Rectangle MainRect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width + 2, e.Bounds.Height - 1);
  3562.                 Rectangle ItemRect = new Rectangle(e.Bounds.X-1, e.Bounds.Y + 4, e.Bounds.Width, e.Bounds.Height +2);
  3563.  
  3564.                 G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), ItemRect);
  3565.                
  3566.  
  3567.                 if (e.State > 0)
  3568.                 {
  3569.                     G.FillRectangle(new SolidBrush(Color.FromArgb(130, H.GetHTMLColor("5b2960"))), ItemRect);
  3570.                     G.DrawRectangle(H.PenHTMlColor("231625", 1), ItemRect);
  3571.                     G.DrawString(Items[e.Index].ToString(), Font, H.SolidBrushHTMlColor("a89ea9"), 3, e.Bounds.Y + 4);
  3572.                    
  3573.                 }
  3574.                 else
  3575.                 {
  3576.                     G.DrawString(Items[e.Index].ToString(), Font, H.SolidBrushHTMlColor("a89ea9"), 3, e.Bounds.Y + 4);
  3577.  
  3578.                 }
  3579.  
  3580.                
  3581.                 e.Graphics.DrawImage(B, 0, 0);
  3582.                 G.Dispose();
  3583.                 B.Dispose();
  3584.          
  3585.             }
  3586.         }
  3587.  
  3588.     }
  3589.    
  3590.     protected override void OnPaint(PaintEventArgs e)
  3591.     {
  3592.         using (Bitmap B = new Bitmap(Width, Height))
  3593.         {
  3594.             using (Graphics G = Graphics.FromImage(B))
  3595.             {
  3596.  
  3597.                 G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  3598.  
  3599.                 Rectangle MainRect = new Rectangle(0, 0, Width - 1, Height - 1);
  3600.  
  3601.                 LB.Size = new Size(Width - 6, Height - 5);
  3602.                 G.FillRectangle(H.SolidBrushHTMlColor("291a2a"), MainRect);
  3603.                 G.DrawRectangle(H.PenHTMlColor("231625", 1), MainRect);
  3604.  
  3605.  
  3606.                 e.Graphics.DrawImage(B, 0, 0);
  3607.                 G.Dispose();
  3608.                 B.Dispose();
  3609.  
  3610.             }
  3611.         }
  3612.     }
  3613.  
  3614.     #endregion
  3615.  
  3616. }
  3617.  
  3618. #endregion
Add Comment
Please, Sign In to add comment