Advertisement
MephobiaHF

▲ [C#] Perplex Theme [Finally Finished] [Improved] ▲

Oct 31st, 2012
1,049
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 26.65 KB | None | 0 0
  1. //Credit to ๖ۣۜMephobia for the original theme
  2. //Credit to Ecco for recoding in C#
  3. using System;
  4. using System.ComponentModel;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8. public enum MouseState : byte
  9. {
  10.     None = 0,
  11.     Over = 1,
  12.     Down = 2,
  13.     Block = 3,
  14. }
  15. public static class Draw
  16. {
  17.     public static GraphicsPath RoundRect(Rectangle rect, int Curve)
  18.     {
  19.         GraphicsPath P = new GraphicsPath();
  20.         int ArcRectWidth = Curve * 2;
  21.         P.AddArc(new Rectangle(rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -180, 90);
  22.         P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -90, 90);
  23.         P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 0, 90);
  24.         P.AddArc(new Rectangle(rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 90, 90);
  25.         P.AddLine(new Point(rect.X, rect.Height - ArcRectWidth + rect.Y), new Point(rect.X, Curve + rect.Y));
  26.         return P;
  27.     }
  28.     public static GraphicsPath RoundRect(int X, int Y, int Width, int Height, int Curve)
  29.     {
  30.         return RoundRect(new Rectangle(X, Y, Width, Height), Curve);
  31.     }
  32. }
  33. public class PerplexTheme : ContainerControl
  34. {
  35.     public PerplexTheme()
  36.     {
  37.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  38.         SetStyle(ControlStyles.UserPaint, true);
  39.         BackColor = Color.FromArgb(25, 25, 25);
  40.         DoubleBuffered = true;
  41.     }
  42.     protected override void OnPaint(PaintEventArgs e)
  43.     {
  44.         Bitmap B = new Bitmap(Width, Height);
  45.         Graphics G = Graphics.FromImage(B);
  46.         Rectangle TopLeft = new Rectangle(0, 0, Width - 125, 28);
  47.         Rectangle TopRight = new Rectangle(Width - 82, 0, 81, 28);
  48.         Rectangle Body = new Rectangle(10, 10, Width - 21, Height - 16);
  49.         Rectangle Body2 = new Rectangle(5, 5, Width - 11, Height - 6);
  50.         base.OnPaint(e);
  51.         LinearGradientBrush BodyBrush = new LinearGradientBrush(Body2, Color.FromArgb(25, 25, 25), Color.FromArgb(30, 35, 48), 90);
  52.         LinearGradientBrush BodyBrush2 = new LinearGradientBrush(Body, Color.FromArgb(46, 46, 46), Color.FromArgb(50, 55, 58), 120);
  53.         LinearGradientBrush gloss = new LinearGradientBrush(new Rectangle(0, 0, Width - 128, 28 / 2), Color.FromArgb(240, Color.FromArgb(26, 26, 26)), Color.FromArgb(5, 255, 255, 255), 90);
  54.         LinearGradientBrush gloss2 = new LinearGradientBrush(new Rectangle(Width - 82, 0,Width - 205, 28 / 2), Color.FromArgb(240, Color.FromArgb(26, 26, 26)), Color.FromArgb(5, 255, 255, 255), 90);
  55.         LinearGradientBrush mainbrush = new LinearGradientBrush(TopLeft, Color.FromArgb(26, 26, 26), Color.FromArgb(30, 30, 30), 90);
  56.         LinearGradientBrush mainbrush2 = new LinearGradientBrush(TopRight, Color.FromArgb(26, 26, 26), Color.FromArgb(30, 30, 30), 90);
  57.         Pen P1 = new Pen(Color.FromArgb(174, 195, 30), 2);
  58.         Font drawFont = new Font("Tahoma", 10, FontStyle.Bold);
  59.            
  60.         G.Clear(Color.Fuchsia);
  61.         G.FillPath(BodyBrush, Draw.RoundRect(Body2, 3));
  62.         G.DrawPath(Pens.Black, Draw.RoundRect(Body2, 3));
  63.            
  64.         G.FillPath(BodyBrush2, Draw.RoundRect(Body, 3));
  65.         G.DrawPath(Pens.Black, Draw.RoundRect(Body, 3));
  66.  
  67.         G.FillPath(mainbrush, Draw.RoundRect(TopLeft, 3));
  68.         G.FillPath(gloss, Draw.RoundRect(TopLeft, 3));
  69.         G.DrawPath(Pens.Black, Draw.RoundRect(TopLeft, 3));
  70.  
  71.         G.FillPath(mainbrush, Draw.RoundRect(TopRight, 3));
  72.         G.FillPath(gloss2, Draw.RoundRect(TopRight, 3));
  73.         G.DrawPath(Pens.Black, Draw.RoundRect(TopRight, 3));
  74.  
  75.         G.DrawLine(P1, 14, 9, 14, 22);
  76.         G.DrawLine(P1, 17, 6, 17, 25);
  77.         G.DrawLine(P1, 20, 9, 20, 22);
  78.         G.DrawLine(P1, 11, 12, 11, 19);
  79.         G.DrawLine(P1, 23, 12, 23, 19);
  80.         G.DrawLine(P1, 8, 14, 8, 17);
  81.         G.DrawLine(P1, 26, 14, 26, 17);
  82.         G.DrawString(Text, drawFont, new SolidBrush(Color.WhiteSmoke), new Rectangle(32, 1, Width - 1, 27), new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
  83.         e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  84.         G.Dispose();
  85.         B.Dispose();
  86.     }
  87.     private Point MouseP = new Point(0, 0);
  88.     private bool cap = false;
  89.     private int moveheight = 29;
  90.     protected override void OnMouseDown(MouseEventArgs e)
  91.     {
  92.         base.OnMouseDown(e);
  93.         if (e.Button == MouseButtons.Left && new Rectangle(0, 0, Width, moveheight).Contains(e.Location))
  94.         {
  95.             cap = true;
  96.             MouseP = e.Location;
  97.         }
  98.     }
  99.     protected override void OnMouseUp(MouseEventArgs e)
  100.     {
  101.         base.OnMouseUp(e);
  102.         cap = false;
  103.     }
  104.     protected override void OnMouseMove(MouseEventArgs e)
  105.     {
  106.         base.OnMouseMove(e);
  107.         if (cap)
  108.         {
  109.             Point p = new Point();
  110.             p.X = MousePosition.X - MouseP.X;
  111.             p.Y = MousePosition.Y - MouseP.Y;
  112.             Parent.Location = p;
  113.         }
  114.     }
  115.     protected override void OnCreateControl()
  116.     {
  117.         base.OnCreateControl();
  118.         ParentForm.FormBorderStyle = FormBorderStyle.None;
  119.         ParentForm.TransparencyKey = Color.Fuchsia;
  120.         Dock = DockStyle.Fill;
  121.     }
  122. }
  123. public class PerplexButton : Control
  124. {
  125.     MouseState State = MouseState.None;
  126.     protected override void OnMouseDown(MouseEventArgs e)
  127.     {
  128.         base.OnMouseDown(e);
  129.         State = MouseState.Down;
  130.         Invalidate();
  131.     }
  132.     protected override void OnMouseUp(MouseEventArgs e)
  133.     {
  134.         base.OnMouseUp(e);
  135.         State = MouseState.Over;
  136.         Invalidate();
  137.     }
  138.     protected override void OnMouseEnter(EventArgs e)
  139.     {
  140.         base.OnMouseEnter(e);
  141.         State = MouseState.Over;
  142.         Invalidate();
  143.     }
  144.     protected override void OnMouseLeave(EventArgs e)
  145.     {
  146.         base.OnMouseLeave(e);
  147.         State = MouseState.None;
  148.         Invalidate();
  149.     }
  150.     public PerplexButton()
  151.     {
  152.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  153.         SetStyle(ControlStyles.UserPaint, true);
  154.         BackColor = Color.Transparent;
  155.         ForeColor = Color.FromArgb(205, 205, 205);
  156.         DoubleBuffered = true;
  157.     }
  158.  
  159.     protected override void OnPaint(PaintEventArgs e)
  160.     {
  161.         Bitmap B = new Bitmap(Width, Height);
  162.         Graphics G = Graphics.FromImage(B);
  163.         Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1);
  164.         base.OnPaint(e);
  165.         G.Clear(BackColor);
  166.         Font drawFont = new Font("Tahoma", 8, FontStyle.Bold);
  167.         G.SmoothingMode = SmoothingMode.HighQuality;
  168.         Rectangle R1 = new Rectangle(0, 0, Width - 125, 35 / 2);
  169.         Rectangle R2 = new Rectangle(5, Height - 10, Width - 11, 5);
  170.         Rectangle R3 = new Rectangle(6, Height - 9, Width - 13, 3);
  171.         Rectangle R4 = new Rectangle(1, 1, Width - 3, Height - 3);
  172.         Rectangle R5 = new Rectangle(1, 0, Width - 1, Height - 1);
  173.         Rectangle R6 = new Rectangle(0, -1, Width - 1, Height - 1);
  174.         LinearGradientBrush lgb = new LinearGradientBrush(ClientRectangle, Color.FromArgb(66, 67, 70), Color.FromArgb(43, 44, 48), 90);
  175.         LinearGradientBrush botbar = new LinearGradientBrush(R2, Color.FromArgb(44, 45, 49), Color.FromArgb(45, 46, 50), 90);
  176.         LinearGradientBrush fill = new LinearGradientBrush(R3, Color.FromArgb(174, 195, 30), Color.FromArgb(141, 153, 16), 90);
  177.         LinearGradientBrush gloss = null;
  178.         Pen o = new Pen(Color.FromArgb(50, 50, 50), 1);
  179.         StringFormat format = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
  180.         if (State == MouseState.Over)
  181.             gloss = new LinearGradientBrush(R1, Color.FromArgb(15, Color.FromArgb(26, 26, 26)), Color.FromArgb(1, 255, 255, 255), 90);
  182.         else if (State == MouseState.Down)
  183.             gloss = new LinearGradientBrush(R1, Color.FromArgb(100, Color.FromArgb(26, 26, 26)), Color.FromArgb(1, 255, 255, 255), 90);
  184.         else
  185.             gloss = new LinearGradientBrush(R1, Color.FromArgb(75, Color.FromArgb(26, 26, 26)), Color.FromArgb(3, 255, 255, 255), 90);
  186.  
  187.         G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 2));
  188.         G.FillPath(gloss, Draw.RoundRect(ClientRectangle, 2));
  189.         G.FillPath(botbar, Draw.RoundRect(R2, 1));
  190.         G.FillPath(fill, Draw.RoundRect(R3, 1));
  191.         G.DrawPath(o, Draw.RoundRect(ClientRectangle, 2));
  192.         G.DrawPath(Pens.Black, Draw.RoundRect(R4, 2));
  193.         G.DrawString(Text, drawFont, new SolidBrush(Color.FromArgb(5, 5, 5)), R5, format);
  194.         G.DrawString(Text, drawFont, new SolidBrush(Color.FromArgb(205, 205, 205)), R6, format);
  195.  
  196.         e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  197.         G.Dispose();
  198.         B.Dispose();
  199.     }
  200. }
  201. public class PerplexControlBox : Control
  202. {
  203.     MouseState State = MouseState.None;
  204.     Rectangle MinBtn = new Rectangle(0, 0, 20, 20);
  205.     Rectangle MaxBtn = new Rectangle(25, 0, 20, 20);
  206.     int x = 0;
  207.  
  208.     protected override void OnMouseDown(MouseEventArgs e)
  209.     {
  210.         base.OnMouseDown(e);
  211.         if (e.Location.X > 0 && e.Location.X < 20)
  212.             FindForm().WindowState = FormWindowState.Minimized;
  213.         else if (e.Location.X > 25 && e.Location.X < 45)
  214.             FindForm().Close();
  215.         State = MouseState.Down;
  216.         Invalidate();
  217.     }
  218.     protected override void OnMouseUp(MouseEventArgs e)
  219.     {
  220.         base.OnMouseUp(e);
  221.         State = MouseState.Over;
  222.         Invalidate();
  223.     }
  224.     protected override void OnMouseEnter(EventArgs e)
  225.     {
  226.         base.OnMouseEnter(e);
  227.         State = MouseState.Over;
  228.         Invalidate();
  229.     }
  230.     protected override void OnMouseLeave(EventArgs e)
  231.     {
  232.         base.OnMouseLeave(e);
  233.         State = MouseState.None;
  234.         Invalidate();
  235.     }
  236.     public PerplexControlBox()
  237.     {
  238.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  239.         SetStyle(ControlStyles.UserPaint, true);
  240.         BackColor = Color.Transparent;
  241.         ForeColor = Color.FromArgb(205, 205, 205);
  242.         DoubleBuffered = true;
  243.     }
  244.     protected override void OnPaint(PaintEventArgs e)
  245.     {
  246.         Bitmap B = new Bitmap(Width, Height);
  247.         Graphics G = Graphics.FromImage(B);
  248.         base.OnPaint(e);
  249.         G.Clear(BackColor);
  250.         G.SmoothingMode = SmoothingMode.HighQuality;
  251.  
  252.         LinearGradientBrush mlgb = null;
  253.         Font mf = new Font("Marlett", 9);
  254.         SolidBrush mfb = new SolidBrush(Color.FromArgb(174, 195, 30));
  255.         Pen P1 = new Pen(Color.FromArgb(21, 21, 21), 1);
  256.         Color C1 = Color.FromArgb(66, 67, 70);
  257.         Color C2 = Color.FromArgb(43, 44, 48);
  258.         GraphicsPath GP1 = Draw.RoundRect(MinBtn, 4);
  259.         GraphicsPath GP2 = Draw.RoundRect(MaxBtn, 4);
  260.         switch (State)
  261.         {
  262.             case MouseState.None:
  263.                 mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
  264.                 G.FillPath(mlgb, GP1);
  265.                 G.DrawPath(P1, GP1);
  266.                 G.DrawString("0", mf, mfb, 4, 4);
  267.  
  268.                 G.FillPath(mlgb, GP2);
  269.                 G.DrawPath(P1, GP2);
  270.                 G.DrawString("r", mf, mfb, 28, 4);
  271.                 break;
  272.             case MouseState.Over:
  273.                 if (x > 0 && x < 20)
  274.                 {
  275.                     mlgb = new LinearGradientBrush(MinBtn, Color.FromArgb(100, C1), Color.FromArgb(100, C2), 90);
  276.                     G.FillPath(mlgb, GP1);
  277.                     G.DrawPath(P1, GP1);
  278.                     G.DrawString("0", mf, mfb, 4, 4);
  279.  
  280.                     mlgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
  281.                     G.FillPath(mlgb, Draw.RoundRect(MaxBtn, 4));
  282.                     G.DrawPath(P1, GP2);
  283.                     G.DrawString("r", mf, mfb, 4, 4);
  284.                 }
  285.                 else if (x > 25 && x < 45)
  286.                 {
  287.                     mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
  288.                     G.FillPath(mlgb, GP1);
  289.                     G.DrawPath(P1, GP1);
  290.                     G.DrawString("0", mf, mfb, 4, 4);
  291.                     mlgb = new LinearGradientBrush(MaxBtn, Color.FromArgb(100, C1), Color.FromArgb(100, C2), 90);
  292.                     G.FillPath(mlgb, GP2);
  293.                     G.DrawPath(P1, GP2);
  294.                     G.DrawString("r", mf, mfb, 28, 4);
  295.                 }
  296.                 else
  297.                 {
  298.                     mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
  299.                     G.FillPath(mlgb, GP1);
  300.                     G.DrawPath(P1, GP1);
  301.                     G.DrawString("0", mf, mfb, 4, 4);
  302.  
  303.                     LinearGradientBrush lgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
  304.                     G.FillPath(lgb, GP2);
  305.                     G.DrawPath(P1, GP2);
  306.                     G.DrawString("r", mf, mfb, 28, 4);
  307.                 }
  308.                 break;
  309.             case MouseState.Down:
  310.                 mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
  311.                 G.FillPath(mlgb, GP1);
  312.                 G.DrawPath(P1, GP1);
  313.                 G.DrawString("0", mf, mfb, 4, 4);
  314.  
  315.                 mlgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
  316.                 G.FillPath(mlgb, GP2);
  317.                 G.DrawPath(P1, GP2);
  318.                 G.DrawString("r", mf, mfb, 28, 4);
  319.                 break;
  320.             default:
  321.                 mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
  322.                 G.FillPath(mlgb, GP1);
  323.                 G.DrawPath(P1, GP1);
  324.                 G.DrawString("0", mf, mfb, 4, 4);
  325.  
  326.                 mlgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
  327.                 G.FillPath(mlgb, GP2);
  328.                 G.DrawPath(P1, GP2);
  329.                 G.DrawString("r", mf, mfb, 28, 4);
  330.                 break;
  331.         }
  332.         e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  333.         G.Dispose();
  334.         B.Dispose();
  335.     }
  336. }
  337. public class PerplexGroupBox : ContainerControl
  338. {
  339.     public PerplexGroupBox()
  340.     {
  341.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  342.         BackColor = Color.Transparent;
  343.         DoubleBuffered = true;
  344.     }
  345.     protected override void OnPaint(PaintEventArgs e)
  346.     {
  347.         Bitmap B = new Bitmap(Width, Height);
  348.         Graphics G = Graphics.FromImage(B);
  349.         Rectangle Body = new Rectangle(4, 25, Width - 9, Height - 30);
  350.         Rectangle Body2 = new Rectangle(0, 0, Width - 1, Height - 1);
  351.         base.OnPaint(e);
  352.         G.Clear(Color.Transparent);
  353.         G.SmoothingMode = SmoothingMode.HighQuality;
  354.         G.CompositingQuality = CompositingQuality.HighQuality;
  355.  
  356.         Pen P1 = new Pen(Color.Black);
  357.         LinearGradientBrush BodyBrush = new LinearGradientBrush(Body2, Color.FromArgb(26, 26, 26), Color.FromArgb(30, 30, 30), 90);
  358.         LinearGradientBrush BodyBrush2 = new LinearGradientBrush(Body, Color.FromArgb(46, 46, 46), Color.FromArgb(50, 55, 58), 120);
  359.         Font drawFont = new Font("Tahoma", 9, FontStyle.Bold);
  360.         G.FillPath(BodyBrush, Draw.RoundRect(Body2, 3));
  361.         G.DrawPath(P1, Draw.RoundRect(Body2, 3));
  362.  
  363.         G.FillPath(BodyBrush2, Draw.RoundRect(Body, 3));
  364.         G.DrawPath(P1, Draw.RoundRect(Body, 3));
  365.  
  366.         G.DrawString(Text, drawFont, new SolidBrush(Color.WhiteSmoke), 67, 14, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
  367.         e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  368.         G.Dispose();
  369.         B.Dispose();
  370.     }
  371. }
  372. public class PerplexProgressBar : Control
  373. {
  374.     private int _Maximum = 100;
  375.  
  376.     public int Maximum {
  377.         get { return _Maximum; }
  378.         set {
  379.             _Maximum = value;
  380.             Invalidate();
  381.         }
  382.     }
  383.     private int _Value = 0;
  384.     public int Value
  385.     {
  386.         get
  387.         {
  388.             if (_Value == 0)
  389.                 return 0;
  390.             else return _Value;
  391.         }
  392.         set
  393.         {
  394.             _Value = value;
  395.             if (_Value > _Maximum)
  396.                 _Value = _Maximum;
  397.             Invalidate();
  398.         }
  399.     }
  400.     private bool _ShowPercentage = false;
  401.     public bool ShowPercentage {
  402.         get { return _ShowPercentage; }
  403.         set {
  404.             _ShowPercentage = value;
  405.             Invalidate();
  406.         }
  407.     }
  408.  
  409.     public PerplexProgressBar() : base()
  410.     {
  411.         DoubleBuffered = true;
  412.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  413.         SetStyle(ControlStyles.UserPaint, true);
  414.         BackColor = Color.Transparent;
  415.     }
  416.  
  417.     protected override void OnPaint(PaintEventArgs e)
  418.     {
  419.         Bitmap B = new Bitmap(Width, Height);
  420.         Graphics G = Graphics.FromImage(B);
  421.  
  422.         G.SmoothingMode = SmoothingMode.HighQuality;
  423.  
  424.         double val = (double)_Value / _Maximum;
  425.         int intValue = Convert.ToInt32(val * Width);
  426.         G.Clear(BackColor);
  427.         Color C1 = Color.FromArgb(174, 195, 30);
  428.         Color C2 = Color.FromArgb(141, 153, 16);
  429.         Rectangle R1 = new Rectangle(0, 0, Width - 1, Height - 1);
  430.         Rectangle R2 = new Rectangle(0, 0, intValue - 1, Height - 1);
  431.         Rectangle R3 = new Rectangle(0, 0, intValue - 1, Height - 2);
  432.         GraphicsPath GP1 = Draw.RoundRect(R1, 1);
  433.         GraphicsPath GP2 = Draw.RoundRect(R2, 2);
  434.         GraphicsPath GP3 = Draw.RoundRect(R3, 1);
  435.         LinearGradientBrush gB = new LinearGradientBrush(R1, Color.FromArgb(26, 26, 26), Color.FromArgb(30, 30, 30), 90);
  436.         LinearGradientBrush g1 = new LinearGradientBrush(new Rectangle(2, 2, intValue - 1, Height - 2), C1, C2, 90);
  437.         HatchBrush h1 = new HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(50, C1), Color.FromArgb(25, C2));
  438.         Pen P1 = new Pen(Color.Black);
  439.  
  440.         G.FillPath(gB, GP1);
  441.         G.FillPath(g1, GP3);
  442.         G.FillPath(h1, GP3);
  443.         G.DrawPath(P1, GP1);
  444.         G.DrawPath(new Pen(Color.FromArgb(150, 97, 94, 90)), GP2);
  445.         G.DrawPath(P1, GP2);
  446.  
  447.         if (_ShowPercentage)
  448.             G.DrawString(Convert.ToString(string.Concat(Value, "%")), Font, Brushes.White, R1, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
  449.  
  450.         e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  451.         G.Dispose();
  452.         B.Dispose();
  453.     }
  454. }
  455. [DefaultEvent("CheckedChanged")]
  456. public class PerplexCheckBox : Control
  457. {
  458.     MouseState State = MouseState.None;
  459.     protected override void OnMouseDown(MouseEventArgs e)
  460.     {
  461.         base.OnMouseDown(e);
  462.         State = MouseState.Down;
  463.         Invalidate();
  464.     }
  465.     protected override void OnMouseUp(MouseEventArgs e)
  466.     {
  467.         base.OnMouseUp(e);
  468.         State = MouseState.Over;
  469.         Invalidate();
  470.     }
  471.     protected override void OnMouseEnter(EventArgs e)
  472.     {
  473.         base.OnMouseEnter(e);
  474.         State = MouseState.Over;
  475.         Invalidate();
  476.     }
  477.     protected override void OnMouseLeave(EventArgs e)
  478.     {
  479.         base.OnMouseLeave(e);
  480.         State = MouseState.None;
  481.         Invalidate();
  482.     }
  483.     protected override void OnSizeChanged(EventArgs e)
  484.     {
  485.         base.OnSizeChanged(e);
  486.         Height = 16;
  487.     }
  488.     protected override void OnTextChanged(EventArgs e)
  489.     {
  490.         base.OnTextChanged(e);
  491.         Invalidate();
  492.     }
  493.     protected override void OnClick(EventArgs e)
  494.     {
  495.         _Checked = !_Checked;
  496.         if (CheckedChanged != null)
  497.             CheckedChanged(this, EventArgs.Empty);
  498.         base.OnClick(e);
  499.     }
  500.     private bool _Checked = false;
  501.     public bool Checked
  502.     {
  503.         get { return _Checked; }
  504.         set
  505.         {
  506.             _Checked = value;
  507.             if (CheckedChanged != null)
  508.                 CheckedChanged(this, EventArgs.Empty);
  509.             Invalidate();
  510.         }
  511.     }
  512.     public PerplexCheckBox()
  513.     {
  514.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  515.         SetStyle(ControlStyles.UserPaint, true);
  516.         BackColor = Color.Transparent;
  517.         ForeColor = Color.Black;
  518.         Size = new Size(145, 16);
  519.         DoubleBuffered = true;
  520.     }
  521.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  522.     {
  523.         Bitmap B = new Bitmap(Width, Height);
  524.         Graphics G = Graphics.FromImage(B);
  525.         G.SmoothingMode = SmoothingMode.HighQuality;
  526.         G.CompositingQuality = CompositingQuality.HighQuality;
  527.         Rectangle checkBoxRectangle = new Rectangle(0, 0, Height - 1, Height - 1);
  528.         LinearGradientBrush bodyGrad = new LinearGradientBrush(checkBoxRectangle, Color.FromArgb(174, 195, 30), Color.FromArgb(141, 153, 16), 90);
  529.         SolidBrush nb = new SolidBrush(Color.FromArgb(205, 205, 205));
  530.         StringFormat format = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center };
  531.         Font drawFont = new Font("Tahoma", 9, FontStyle.Bold);
  532.         G.Clear(BackColor);
  533.         G.FillRectangle(bodyGrad, bodyGrad.Rectangle);
  534.         G.DrawRectangle(new Pen(Color.Black), checkBoxRectangle);
  535.         G.DrawString(Text, drawFont, Brushes.Black, new Point(17, 9), format);
  536.         G.DrawString(Text, drawFont, nb, new Point(16, 8), format);
  537.  
  538.         if (_Checked)
  539.         {
  540.             Rectangle chkPoly = new Rectangle(checkBoxRectangle.X + checkBoxRectangle.Width / 4, checkBoxRectangle.Y + checkBoxRectangle.Height / 4, checkBoxRectangle.Width / 2, checkBoxRectangle.Height / 2);
  541.             Point[] p = new Point[] {new Point(chkPoly.X, chkPoly.Y + chkPoly.Height /2),
  542.                         new Point(chkPoly.X + chkPoly.Width / 2, chkPoly.Y + chkPoly.Height),
  543.                         new Point(chkPoly.X + chkPoly.Width, chkPoly.Y)};
  544.             Pen P1 = new Pen(Color.FromArgb(12, 12, 12), 2);
  545.             for (int i = 0; i <= p.Length - 2; i++)
  546.                 G.DrawLine(P1, p[i], p[i + 1]);
  547.         }
  548.         e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  549.         G.Dispose();
  550.         B.Dispose();
  551.     }
  552.  
  553.     public event EventHandler CheckedChanged;
  554. }
  555. [DefaultEvent("CheckedChanged")]
  556. public class PerplexRadioButton : Control
  557. {
  558.     MouseState State = MouseState.None;
  559.     protected override void OnMouseDown(MouseEventArgs e)
  560.     {
  561.         base.OnMouseDown(e);
  562.         State = MouseState.Down;
  563.         Invalidate();
  564.     }
  565.     protected override void OnMouseUp(MouseEventArgs e)
  566.     {
  567.         base.OnMouseUp(e);
  568.         State = MouseState.Over;
  569.         Invalidate();
  570.     }
  571.     protected override void OnMouseEnter(EventArgs e)
  572.     {
  573.         base.OnMouseEnter(e);
  574.         State = MouseState.Over;
  575.         Invalidate();
  576.     }
  577.     protected override void OnMouseLeave(EventArgs e)
  578.     {
  579.         base.OnMouseLeave(e);
  580.         State = MouseState.None;
  581.         Invalidate();
  582.     }
  583.     protected override void OnSizeChanged(EventArgs e)
  584.     {
  585.         base.OnSizeChanged(e);
  586.         Height = 16;
  587.     }
  588.     protected override void OnTextChanged(EventArgs e)
  589.     {
  590.         base.OnTextChanged(e);
  591.         Invalidate();
  592.     }
  593.     protected override void OnClick(EventArgs e)
  594.     {
  595.         Checked = !Checked;
  596.         base.OnClick(e);
  597.     }
  598.     private bool _Checked = false;
  599.     public bool Checked
  600.     {
  601.         get { return _Checked; }
  602.         set
  603.         {
  604.             _Checked = value;
  605.             InvalidateControls();
  606.             if (CheckedChanged != null)
  607.                 CheckedChanged(this, EventArgs.Empty);
  608.             Invalidate();
  609.         }
  610.     }
  611.     protected override void OnCreateControl()
  612.     {
  613.         base.OnCreateControl();
  614.         InvalidateControls();
  615.     }
  616.     private void InvalidateControls()
  617.     {
  618.         if (!IsHandleCreated || !_Checked) return;
  619.         foreach (Control C in Parent.Controls)
  620.             if (C is PerplexRadioButton && C != this)
  621.                 ((PerplexRadioButton)C).Checked = false;
  622.     }
  623.     public PerplexRadioButton()
  624.     {
  625.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  626.         SetStyle(ControlStyles.UserPaint, true);
  627.         BackColor = Color.Transparent;
  628.         ForeColor = Color.Black;
  629.         Size = new Size(150, 16);
  630.         DoubleBuffered = true;
  631.     }
  632.     protected override void OnPaint(PaintEventArgs e)
  633.     {
  634.         Bitmap B = new Bitmap(Width, Height);
  635.         Graphics G = Graphics.FromImage(B);
  636.         G.Clear(BackColor);
  637.         Rectangle radioBtnRectangle = new Rectangle(0, 0, Height - 1, Height - 1);
  638.         Rectangle R1 = new Rectangle(4, 4, Height - 9, Height - 9);
  639.         StringFormat format = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near };
  640.         LinearGradientBrush bgGrad = new LinearGradientBrush(radioBtnRectangle, Color.FromArgb(174, 195, 30), Color.FromArgb(141, 153, 16), 90);
  641.         Color C1 = Color.FromArgb(250, 15, 15, 15);
  642.         SolidBrush nb = new SolidBrush(Color.FromArgb(205, 205, 205));
  643.         G.SmoothingMode = SmoothingMode.HighQuality;
  644.         G.CompositingQuality = CompositingQuality.HighQuality;
  645.         Font drawFont = new Font("Tahoma", 10, FontStyle.Bold);
  646.  
  647.         G.FillEllipse(bgGrad, radioBtnRectangle);
  648.         G.DrawEllipse(new Pen(Color.Black), radioBtnRectangle);
  649.  
  650.         if (Checked)
  651.         {
  652.             LinearGradientBrush chkGrad = new LinearGradientBrush(R1, C1, C1, 90);
  653.             G.FillEllipse(chkGrad, R1);
  654.         }
  655.  
  656.         G.DrawString(Text, drawFont, Brushes.Black, new Point(17, 2), format);
  657.         G.DrawString(Text, drawFont, nb, new Point(16, 1), format);
  658.  
  659.         e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  660.         G.Dispose();
  661.         B.Dispose();
  662.     }
  663.     public event EventHandler CheckedChanged;
  664. }
  665. public class PerplexLabel : Control
  666. {
  667.     public PerplexLabel()
  668.     {
  669.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  670.         SetStyle(ControlStyles.UserPaint, true);
  671.         BackColor = Color.Transparent;
  672.         ForeColor = Color.FromArgb(205, 205, 205);
  673.         DoubleBuffered = true;
  674.     }
  675.     protected override void OnPaint(PaintEventArgs e)
  676.     {
  677.         Bitmap B = new Bitmap(Width, Height);
  678.         Graphics G = Graphics.FromImage(B);
  679.         Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1);
  680.         base.OnPaint(e);
  681.         G.Clear(BackColor);
  682.         Font drawFont = new Font("Tahoma", 9, FontStyle.Bold);
  683.         StringFormat format = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center};
  684.         G.CompositingQuality = CompositingQuality.HighQuality;
  685.         G.SmoothingMode = SmoothingMode.HighQuality;
  686.         G.DrawString(Text, drawFont, new SolidBrush(Color.FromArgb(5, 5, 5)), new Rectangle(1, 0, Width - 1, Height - 1), format);
  687.         G.DrawString(Text, drawFont, new SolidBrush(Color.FromArgb(205, 205, 205)), new Rectangle(0, -1, Width - 1, Height - 1), format);
  688.         e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  689.         G.Dispose();
  690.         B.Dispose();
  691.     }
  692. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement