Controller

Vibelander Theme C#

Dec 8th, 2012
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 30.49 KB | None | 0 0
  1. Vibelander Theme C#
  2.  
  3. Not Made By Me :)
  4.  
  5. -------------------------------------------------------
  6.  
  7. using System;
  8. using System.Windows.Forms;
  9. using System.Drawing.Drawing2D;
  10. using System.ComponentModel;
  11. using System.Runtime.InteropServices;
  12. using System.Drawing;
  13.  
  14. //.::Tweety Theme::.
  15. //Author:   UnReLaTeDScript
  16. //Converted to C# by: Deliriumâ„¢ @ HackForums.Net
  17. //Credits:  Aeonhack [Themebase]
  18. //Version:  1.0
  19. abstract class Theme : ContainerControl
  20. {
  21.  
  22.     #region " Initialization "
  23.  
  24.     protected Graphics G;
  25.     public Theme()
  26.     {
  27.         SetStyle((ControlStyles)139270, true);
  28.     }
  29.  
  30.     private bool ParentIsForm;
  31.     protected override void OnHandleCreated(EventArgs e)
  32.     {
  33.         Dock = DockStyle.Fill;
  34.         ParentIsForm = Parent is Form;
  35.         if (ParentIsForm)
  36.         {
  37.             if (!(_TransparencyKey == Color.Empty))
  38.                 ParentForm.TransparencyKey = _TransparencyKey;
  39.             ParentForm.FormBorderStyle = FormBorderStyle.None;
  40.         }
  41.         base.OnHandleCreated(e);
  42.     }
  43.  
  44.     public override string Text
  45.     {
  46.         get { return base.Text; }
  47.         set
  48.         {
  49.             base.Text = value;
  50.             Invalidate();
  51.         }
  52.     }
  53.     #endregion
  54.  
  55.     #region " Sizing and Movement "
  56.  
  57.     private bool _Resizable = true;
  58.     public bool Resizable
  59.     {
  60.         get { return _Resizable; }
  61.         set { _Resizable = value; }
  62.     }
  63.  
  64.     private int _MoveHeight = 24;
  65.     public int MoveHeight
  66.     {
  67.         get { return _MoveHeight; }
  68.         set
  69.         {
  70.             _MoveHeight = value;
  71.             Header = new Rectangle(7, 7, Width - 14, _MoveHeight - 7);
  72.         }
  73.     }
  74.  
  75.     private IntPtr Flag;
  76.     protected override void OnMouseDown(MouseEventArgs e)
  77.     {
  78.         if (!(e.Button == MouseButtons.Left))
  79.             return;
  80.         if (ParentIsForm)
  81.             if (ParentForm.WindowState == FormWindowState.Maximized)
  82.                 return;
  83.  
  84.         if (Header.Contains(e.Location))
  85.         {
  86.             Flag = new IntPtr(2);
  87.         }
  88.         else if (Current.Position == 0 | !_Resizable)
  89.         {
  90.             return;
  91.         }
  92.         else
  93.         {
  94.             Flag = new IntPtr(Current.Position);
  95.         }
  96.  
  97.         Capture = false;
  98.         Message m = Message.Create(Parent.Handle, 161, Flag, IntPtr.Zero);
  99.         DefWndProc(ref m);
  100.  
  101.         base.OnMouseDown(e);
  102.     }
  103.  
  104.     private struct Pointer
  105.     {
  106.         public readonly Cursor Cursor;
  107.         public readonly byte Position;
  108.         public Pointer(Cursor c, byte p)
  109.         {
  110.             Cursor = c;
  111.             Position = p;
  112.         }
  113.     }
  114.  
  115.     private bool F1;
  116.     private bool F2;
  117.     private bool F3;
  118.     private bool F4;
  119.     private Point PTC;
  120.     private Pointer GetPointer()
  121.     {
  122.         PTC = PointToClient(MousePosition);
  123.         F1 = PTC.X < 7;
  124.         F2 = PTC.X > Width - 7;
  125.         F3 = PTC.Y < 7;
  126.         F4 = PTC.Y > Height - 7;
  127.  
  128.         if (F1 & F3)
  129.             return new Pointer(Cursors.SizeNWSE, 13);
  130.         if (F1 & F4)
  131.             return new Pointer(Cursors.SizeNESW, 16);
  132.         if (F2 & F3)
  133.             return new Pointer(Cursors.SizeNESW, 14);
  134.         if (F2 & F4)
  135.             return new Pointer(Cursors.SizeNWSE, 17);
  136.         if (F1)
  137.             return new Pointer(Cursors.SizeWE, 10);
  138.         if (F2)
  139.             return new Pointer(Cursors.SizeWE, 11);
  140.         if (F3)
  141.             return new Pointer(Cursors.SizeNS, 12);
  142.         if (F4)
  143.             return new Pointer(Cursors.SizeNS, 15);
  144.         return new Pointer(Cursors.Default, 0);
  145.     }
  146.  
  147.     private Pointer Current;
  148.     private Pointer Pending;
  149.     private void SetCurrent()
  150.     {
  151.         Pending = GetPointer();
  152.         if (Current.Position == Pending.Position)
  153.             return;
  154.         Current = GetPointer();
  155.         Cursor = Current.Cursor;
  156.     }
  157.  
  158.     protected override void OnMouseMove(MouseEventArgs e)
  159.     {
  160.         if (_Resizable)
  161.             SetCurrent();
  162.         base.OnMouseMove(e);
  163.     }
  164.  
  165.     protected Rectangle Header;
  166.     protected override void OnSizeChanged(EventArgs e)
  167.     {
  168.         if (Width == 0 || Height == 0)
  169.             return;
  170.         Header = new Rectangle(7, 7, Width - 14, _MoveHeight - 7);
  171.         Invalidate();
  172.         base.OnSizeChanged(e);
  173.     }
  174.  
  175.     #endregion
  176.  
  177.     #region " Convienence "
  178.  
  179.     public abstract void PaintHook();
  180.     protected override sealed void OnPaint(PaintEventArgs e)
  181.     {
  182.         if (Width == 0 || Height == 0)
  183.             return;
  184.         G = e.Graphics;
  185.         PaintHook();
  186.     }
  187.  
  188.     private Color _TransparencyKey;
  189.     public Color TransparencyKey
  190.     {
  191.         get { return _TransparencyKey; }
  192.         set
  193.         {
  194.             _TransparencyKey = value;
  195.             Invalidate();
  196.         }
  197.     }
  198.  
  199.     private Image _Image;
  200.     public Image Image
  201.     {
  202.         get { return _Image; }
  203.         set
  204.         {
  205.             _Image = value;
  206.             Invalidate();
  207.         }
  208.     }
  209.     public int ImageWidth
  210.     {
  211.         get
  212.         {
  213.             if (_Image == null)
  214.                 return 0;
  215.             return _Image.Width;
  216.         }
  217.     }
  218.  
  219.     private Size _Size;
  220.     private Rectangle _Rectangle;
  221.     private LinearGradientBrush _Gradient;
  222.  
  223.     private SolidBrush _Brush;
  224.     protected void DrawCorners(Color c, Rectangle rect)
  225.     {
  226.         _Brush = new SolidBrush(c);
  227.         G.FillRectangle(_Brush, rect.X, rect.Y, 1, 1);
  228.         G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y, 1, 1);
  229.         G.FillRectangle(_Brush, rect.X, rect.Y + (rect.Height - 1), 1, 1);
  230.         G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), 1, 1);
  231.     }
  232.  
  233.     protected void DrawBorders(Pen p1, Pen p2, Rectangle rect)
  234.     {
  235.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
  236.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3);
  237.     }
  238.  
  239.     protected void DrawText(HorizontalAlignment a, Color c, int x)
  240.     {
  241.         DrawText(a, c, x, 0);
  242.     }
  243.     protected void DrawText(HorizontalAlignment a, Color c, int x, int y)
  244.     {
  245.         if (string.IsNullOrEmpty(Text))
  246.             return;
  247.         _Size = G.MeasureString(Text, Font).ToSize();
  248.         _Brush = new SolidBrush(c);
  249.  
  250.         switch (a)
  251.         {
  252.             case HorizontalAlignment.Left:
  253.                 G.DrawString(Text, Font, _Brush, x, _MoveHeight / 2 - _Size.Height / 2 + y);
  254.                 break;
  255.             case HorizontalAlignment.Right:
  256.                 G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, _MoveHeight / 2 - _Size.Height / 2 + y);
  257.                 break;
  258.             case HorizontalAlignment.Center:
  259.                 G.DrawString(Text, Font, _Brush, Width / 2 - _Size.Width / 2 + x, _MoveHeight / 2 - _Size.Height / 2 + y);
  260.                 break;
  261.         }
  262.     }
  263.  
  264.     protected void DrawIcon(HorizontalAlignment a, int x)
  265.     {
  266.         DrawIcon(a, x, 0);
  267.     }
  268.     protected void DrawIcon(HorizontalAlignment a, int x, int y)
  269.     {
  270.         if (_Image == null)
  271.             return;
  272.         switch (a)
  273.         {
  274.             case HorizontalAlignment.Left:
  275.                 G.DrawImage(_Image, x, _MoveHeight / 2 - _Image.Height / 2 + y);
  276.                 break;
  277.             case HorizontalAlignment.Right:
  278.                 G.DrawImage(_Image, Width - _Image.Width - x, _MoveHeight / 2 - _Image.Height / 2 + y);
  279.                 break;
  280.             case HorizontalAlignment.Center:
  281.                 G.DrawImage(_Image, Width / 2 - _Image.Width / 2, _MoveHeight / 2 - _Image.Height / 2);
  282.                 break;
  283.         }
  284.     }
  285.  
  286.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
  287.     {
  288.         _Rectangle = new Rectangle(x, y, width, height);
  289.         _Gradient = new LinearGradientBrush(_Rectangle, c1, c2, angle);
  290.         G.FillRectangle(_Gradient, _Rectangle);
  291.     }
  292.  
  293.     #endregion
  294.  
  295. }
  296. static class Draw
  297. {
  298.     public static GraphicsPath RoundRect(Rectangle Rectangle, int Curve)
  299.     {
  300.         GraphicsPath P = new GraphicsPath();
  301.         int ArcRectangleWidth = Curve * 2;
  302.         P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
  303.         P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
  304.         P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
  305.         P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
  306.         P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
  307.         return P;
  308.     }
  309.     //Public Function RoundRect(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal Curve As Integer) As GraphicsPath
  310.     //    Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
  311.     //    Dim P As GraphicsPath = New GraphicsPath()
  312.     //    Dim ArcRectangleWidth As Integer = Curve * 2
  313.     //    P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  314.     //    P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  315.     //    P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  316.     //    P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  317.     //    P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  318.     //    Return P
  319.     //End Function
  320. }
  321. abstract class ThemeControl : Control
  322. {
  323.  
  324.     #region " Initialization "
  325.  
  326.     protected Graphics G;
  327.     protected Bitmap B;
  328.     public ThemeControl()
  329.     {
  330.         SetStyle((ControlStyles)139270, true);
  331.         B = new Bitmap(1, 1);
  332.         G = Graphics.FromImage(B);
  333.     }
  334.  
  335.     public void AllowTransparent()
  336.     {
  337.         SetStyle(ControlStyles.Opaque, false);
  338.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  339.     }
  340.  
  341.     public override string Text
  342.     {
  343.         get { return base.Text; }
  344.         set
  345.         {
  346.             base.Text = value;
  347.             Invalidate();
  348.         }
  349.     }
  350.     #endregion
  351.  
  352.     #region " Mouse Handling "
  353.  
  354.     protected enum State : byte
  355.     {
  356.         MouseNone = 0,
  357.         MouseOver = 1,
  358.         MouseDown = 2
  359.     }
  360.  
  361.     protected State MouseState;
  362.     protected override void OnMouseLeave(EventArgs e)
  363.     {
  364.         ChangeMouseState(State.MouseNone);
  365.         base.OnMouseLeave(e);
  366.     }
  367.     protected override void OnMouseEnter(EventArgs e)
  368.     {
  369.         ChangeMouseState(State.MouseOver);
  370.         base.OnMouseEnter(e);
  371.     }
  372.     protected override void OnMouseUp(MouseEventArgs e)
  373.     {
  374.         ChangeMouseState(State.MouseOver);
  375.         base.OnMouseUp(e);
  376.     }
  377.     protected override void OnMouseDown(MouseEventArgs e)
  378.     {
  379.         if (e.Button == MouseButtons.Left)
  380.             ChangeMouseState(State.MouseDown);
  381.         base.OnMouseDown(e);
  382.     }
  383.  
  384.     private void ChangeMouseState(State e)
  385.     {
  386.         MouseState = e;
  387.         Invalidate();
  388.     }
  389.  
  390.     #endregion
  391.  
  392.     #region " Convienence "
  393.  
  394.     public abstract void PaintHook();
  395.     protected override sealed void OnPaint(PaintEventArgs e)
  396.     {
  397.         if (Width == 0 || Height == 0)
  398.             return;
  399.         PaintHook();
  400.         e.Graphics.DrawImage(B, 0, 0);
  401.     }
  402.  
  403.     protected override void OnSizeChanged(EventArgs e)
  404.     {
  405.         if (!(Width == 0) && !(Height == 0))
  406.         {
  407.             B = new Bitmap(Width, Height);
  408.             G = Graphics.FromImage(B);
  409.             Invalidate();
  410.         }
  411.         base.OnSizeChanged(e);
  412.     }
  413.  
  414.     private bool _NoRounding;
  415.     public bool NoRounding
  416.     {
  417.         get { return _NoRounding; }
  418.         set
  419.         {
  420.             _NoRounding = value;
  421.             Invalidate();
  422.         }
  423.     }
  424.  
  425.     private Image _Image;
  426.     public Image Image
  427.     {
  428.         get { return _Image; }
  429.         set
  430.         {
  431.             _Image = value;
  432.             Invalidate();
  433.         }
  434.     }
  435.     public int ImageWidth
  436.     {
  437.         get
  438.         {
  439.             if (_Image == null)
  440.                 return 0;
  441.             return _Image.Width;
  442.         }
  443.     }
  444.     public int ImageTop
  445.     {
  446.         get
  447.         {
  448.             if (_Image == null)
  449.                 return 0;
  450.             return Height / 2 - _Image.Height / 2;
  451.         }
  452.     }
  453.  
  454.     private Size _Size;
  455.     private Rectangle _Rectangle;
  456.     private LinearGradientBrush _Gradient;
  457.  
  458.     private SolidBrush _Brush;
  459.     protected void DrawCorners(Color c, Rectangle rect)
  460.     {
  461.         if (_NoRounding)
  462.             return;
  463.  
  464.         B.SetPixel(rect.X, rect.Y, c);
  465.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c);
  466.         B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c);
  467.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c);
  468.     }
  469.  
  470.     protected void DrawBorders(Pen p1, Pen p2, Rectangle rect)
  471.     {
  472.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
  473.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3);
  474.     }
  475.  
  476.     protected void DrawText(HorizontalAlignment a, Color c, int x)
  477.     {
  478.         DrawText(a, c, x, 0);
  479.     }
  480.     protected void DrawText(HorizontalAlignment a, Color c, int x, int y)
  481.     {
  482.         if (string.IsNullOrEmpty(Text))
  483.             return;
  484.         _Size = G.MeasureString(Text, Font).ToSize();
  485.         _Brush = new SolidBrush(c);
  486.  
  487.         switch (a)
  488.         {
  489.             case HorizontalAlignment.Left:
  490.                 G.DrawString(Text, Font, _Brush, x, Height / 2 - _Size.Height / 2 + y);
  491.                 break;
  492.             case HorizontalAlignment.Right:
  493.                 G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, Height / 2 - _Size.Height / 2 + y);
  494.                 break;
  495.             case HorizontalAlignment.Center:
  496.                 G.DrawString(Text, Font, _Brush, Width / 2 - _Size.Width / 2 + x, Height / 2 - _Size.Height / 2 + y);
  497.                 break;
  498.         }
  499.     }
  500.  
  501.     protected void DrawIcon(HorizontalAlignment a, int x)
  502.     {
  503.         DrawIcon(a, x, 0);
  504.     }
  505.     protected void DrawIcon(HorizontalAlignment a, int x, int y)
  506.     {
  507.         if (_Image == null)
  508.             return;
  509.         switch (a)
  510.         {
  511.             case HorizontalAlignment.Left:
  512.                 G.DrawImage(_Image, x, Height / 2 - _Image.Height / 2 + y);
  513.                 break;
  514.             case HorizontalAlignment.Right:
  515.                 G.DrawImage(_Image, Width - _Image.Width - x, Height / 2 - _Image.Height / 2 + y);
  516.                 break;
  517.             case HorizontalAlignment.Center:
  518.                 G.DrawImage(_Image, Width / 2 - _Image.Width / 2, Height / 2 - _Image.Height / 2);
  519.                 break;
  520.         }
  521.     }
  522.  
  523.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
  524.     {
  525.         _Rectangle = new Rectangle(x, y, width, height);
  526.         _Gradient = new LinearGradientBrush(_Rectangle, c1, c2, angle);
  527.         G.FillRectangle(_Gradient, _Rectangle);
  528.     }
  529.     #endregion
  530.  
  531. }
  532. abstract class ThemeContainerControl : ContainerControl
  533. {
  534.  
  535.     #region " Initialization "
  536.  
  537.     protected Graphics G;
  538.     protected Bitmap B;
  539.     public ThemeContainerControl()
  540.     {
  541.         SetStyle((ControlStyles)139270, true);
  542.         B = new Bitmap(1, 1);
  543.         G = Graphics.FromImage(B);
  544.     }
  545.  
  546.     public void AllowTransparent()
  547.     {
  548.         SetStyle(ControlStyles.Opaque, false);
  549.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  550.     }
  551.  
  552.     #endregion
  553.     #region " Convienence "
  554.  
  555.     public abstract void PaintHook();
  556.     protected override sealed void OnPaint(PaintEventArgs e)
  557.     {
  558.         if (Width == 0 || Height == 0)
  559.             return;
  560.         PaintHook();
  561.         e.Graphics.DrawImage(B, 0, 0);
  562.     }
  563.  
  564.     protected override void OnSizeChanged(EventArgs e)
  565.     {
  566.         if (!(Width == 0) && !(Height == 0))
  567.         {
  568.             B = new Bitmap(Width, Height);
  569.             G = Graphics.FromImage(B);
  570.             Invalidate();
  571.         }
  572.         base.OnSizeChanged(e);
  573.     }
  574.  
  575.     private bool _NoRounding;
  576.     public bool NoRounding
  577.     {
  578.         get { return _NoRounding; }
  579.         set
  580.         {
  581.             _NoRounding = value;
  582.             Invalidate();
  583.         }
  584.     }
  585.  
  586.     private Rectangle _Rectangle;
  587.  
  588.     private LinearGradientBrush _Gradient;
  589.     protected void DrawCorners(Color c, Rectangle rect)
  590.     {
  591.         if (_NoRounding)
  592.             return;
  593.         B.SetPixel(rect.X, rect.Y, c);
  594.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c);
  595.         B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c);
  596.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c);
  597.     }
  598.  
  599.     protected void DrawBorders(Pen p1, Pen p2, Rectangle rect)
  600.     {
  601.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
  602.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3);
  603.     }
  604.  
  605.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
  606.     {
  607.         _Rectangle = new Rectangle(x, y, width, height);
  608.         _Gradient = new LinearGradientBrush(_Rectangle, c1, c2, angle);
  609.         G.FillRectangle(_Gradient, _Rectangle);
  610.     }
  611.     #endregion
  612.  
  613. }
  614.  
  615. class TxtBox : ThemeControl
  616. {
  617.     #region "lol"
  618.     TextBox txtbox = new TextBox();
  619.     private bool _passmask = false;
  620.     public bool UseSystemPasswordChar
  621.     {
  622.         get { return _passmask; }
  623.         set
  624.         {
  625.             txtbox.UseSystemPasswordChar = UseSystemPasswordChar;
  626.             _passmask = value;
  627.             Invalidate();
  628.         }
  629.     }
  630.     private int _maxchars = 32767;
  631.     public int MaxLength
  632.     {
  633.         get { return _maxchars; }
  634.         set
  635.         {
  636.             _maxchars = value;
  637.             txtbox.MaxLength = MaxLength;
  638.             Invalidate();
  639.         }
  640.     }
  641.     private HorizontalAlignment _align;
  642.     public HorizontalAlignment TextAlignment
  643.     {
  644.         get { return _align; }
  645.         set
  646.         {
  647.             _align = value;
  648.             Invalidate();
  649.         }
  650.     }
  651.  
  652.     protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
  653.     {
  654.     }
  655.     protected override void OnTextChanged(System.EventArgs e)
  656.     {
  657.         base.OnTextChanged(e);
  658.         Invalidate();
  659.     }
  660.     protected override void OnBackColorChanged(System.EventArgs e)
  661.     {
  662.         base.OnBackColorChanged(e);
  663.         txtbox.BackColor = BackColor;
  664.         Invalidate();
  665.     }
  666.     protected override void OnForeColorChanged(System.EventArgs e)
  667.     {
  668.         base.OnForeColorChanged(e);
  669.         txtbox.ForeColor = ForeColor;
  670.         Invalidate();
  671.     }
  672.     protected override void OnFontChanged(System.EventArgs e)
  673.     {
  674.         base.OnFontChanged(e);
  675.         txtbox.Font = Font;
  676.     }
  677.     protected override void OnGotFocus(System.EventArgs e)
  678.     {
  679.         base.OnGotFocus(e);
  680.         txtbox.Focus();
  681.     }
  682.     public void  // ERROR: Handles clauses are not supported in C#
  683. TextChngTxtBox()
  684.     {
  685.         Text = txtbox.Text;
  686.     }
  687.     public void  // ERROR: Handles clauses are not supported in C#
  688. TextChng()
  689.     {
  690.         txtbox.Text = Text;
  691.     }
  692.  
  693.     #endregion
  694.  
  695.     protected override void WndProc(ref Message m)
  696.     {
  697.         switch (m.Msg)
  698.         {
  699.             case 15:
  700.                 Invalidate();
  701.                 base.WndProc(ref m);
  702.                 this.PaintHook();
  703.                 break; // TODO: might not be correct. Was : Exit Select
  704.             default:
  705.                 base.WndProc(ref m);
  706.                 break; // TODO: might not be correct. Was : Exit Select
  707.         }
  708.     }
  709.  
  710.     public TxtBox()
  711.         : base()
  712.     {
  713.  
  714.         Controls.Add(txtbox);
  715.         {
  716.             txtbox.Multiline = false;
  717.             txtbox.BackColor = Color.FromArgb(0, 0, 0);
  718.             txtbox.ForeColor = ForeColor;
  719.             txtbox.Text = string.Empty;
  720.             txtbox.TextAlign = HorizontalAlignment.Center;
  721.             txtbox.BorderStyle = BorderStyle.None;
  722.             txtbox.Location = new Point(5, 8);
  723.             txtbox.Font = new Font("Arial", 8.25f, FontStyle.Bold);
  724.             txtbox.Size = new Size(Width - 8, Height - 11);
  725.             txtbox.UseSystemPasswordChar = UseSystemPasswordChar;
  726.         }
  727.  
  728.         Text = "";
  729.  
  730.         DoubleBuffered = true;
  731.     }
  732.  
  733.     public override void PaintHook()
  734.     {
  735.         this.BackColor = Color.White;
  736.         G.Clear(Parent.BackColor);
  737.         Pen p = new Pen(Color.FromArgb(204, 204, 204), 1);
  738.         Pen o = new Pen(Color.FromArgb(249, 249, 249), 8);
  739.         G.FillPath(Brushes.White, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 2));
  740.         G.DrawPath(o, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 2));
  741.         G.DrawPath(p, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 2));
  742.         Height = txtbox.Height + 16;
  743.         Font drawFont = new Font("Tahoma", 9, FontStyle.Regular);
  744.         {
  745.             txtbox.Width = Width - 12;
  746.             txtbox.ForeColor = Color.FromArgb(72, 72, 72);
  747.             txtbox.Font = drawFont;
  748.             txtbox.TextAlign = TextAlignment;
  749.             txtbox.UseSystemPasswordChar = UseSystemPasswordChar;
  750.         }
  751.         DrawCorners(Parent.BackColor, ClientRectangle);
  752.     }
  753. }
  754.  
  755. class PanelBox : ThemeContainerControl
  756. {
  757.     public PanelBox()
  758.     {
  759.         AllowTransparent();
  760.     }
  761.     public override void PaintHook()
  762.     {
  763.         this.Font = new Font("Tahoma", 10);
  764.         this.ForeColor = Color.FromArgb(40, 40, 40);
  765.         G.SmoothingMode = SmoothingMode.AntiAlias;
  766.         G.FillRectangle(new SolidBrush(Color.FromArgb(235, 235, 235)), new Rectangle(2, 0, Width, Height));
  767.         G.FillRectangle(new SolidBrush(Color.FromArgb(249, 249, 249)), new Rectangle(1, 0, Width - 3, Height - 4));
  768.         G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 2, Height - 3);
  769.     }
  770. }
  771. class GroupDropBox : ThemeContainerControl
  772. {
  773.     private bool _Checked;
  774.     private int X;
  775.     private int y;
  776.     private Size _OpenedSize;
  777.     public bool Checked
  778.     {
  779.         get { return _Checked; }
  780.         set
  781.         {
  782.             _Checked = value;
  783.             Invalidate();
  784.         }
  785.     }
  786.     public Size OpenSize
  787.     {
  788.         get { return _OpenedSize; }
  789.         set
  790.         {
  791.             _OpenedSize = value;
  792.             Invalidate();
  793.         }
  794.     }
  795.     public GroupDropBox()
  796.     {
  797.        
  798.         AllowTransparent();
  799.         Size = new Size(90, 30);
  800.         MinimumSize = new Size(5, 30);
  801.         _Checked = true;
  802.         this.Resize += new EventHandler(GroupDropBox_Resize);
  803.         this.MouseDown += new MouseEventHandler(GroupDropBox_MouseDown);
  804.     }
  805.     public override void PaintHook()
  806.     {
  807.         this.Font = new Font("Tahoma", 10);
  808.         this.ForeColor = Color.FromArgb(40, 40, 40);
  809.         if (_Checked == true)
  810.         {
  811.             G.SmoothingMode = SmoothingMode.AntiAlias;
  812.             G.Clear(Color.FromArgb(245, 245, 245));
  813.             G.FillRectangle(new SolidBrush(Color.FromArgb(231, 231, 231)), new Rectangle(0, 0, Width, 30));
  814.             G.DrawLine(new Pen(Color.FromArgb(233, 238, 240)), 1, 1, Width - 2, 1);
  815.             G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, Height - 1);
  816.             G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, 30);
  817.             this.Size = _OpenedSize;
  818.             G.DrawString("t", new Font("Marlett", 12), new SolidBrush(this.ForeColor), Width - 25, 5);
  819.         }
  820.         else
  821.         {
  822.             G.SmoothingMode = SmoothingMode.AntiAlias;
  823.             G.Clear(Color.FromArgb(245, 245, 245));
  824.             G.FillRectangle(new SolidBrush(Color.FromArgb(231, 231, 231)), new Rectangle(0, 0, Width, 30));
  825.             G.DrawLine(new Pen(Color.FromArgb(231, 236, 238)), 1, 1, Width - 2, 1);
  826.             G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, Height - 1);
  827.             G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, 30);
  828.             this.Size = new Size(Width, 30);
  829.             G.DrawString("u", new Font("Marlett", 12), new SolidBrush(this.ForeColor), Width - 25, 5);
  830.         }
  831.         G.DrawString(Text, Font, new SolidBrush(this.ForeColor), 7, 6);
  832.     }
  833.  
  834.     private void GroupDropBox_Resize(object sender, System.EventArgs e)
  835.     {
  836.         if (_Checked == true)
  837.         {
  838.             _OpenedSize = this.Size;
  839.         }
  840.     }
  841.  
  842.  
  843.     protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
  844.     {
  845.         base.OnMouseMove(e);
  846.         X = e.X;
  847.         y = e.Y;
  848.         Invalidate();
  849.     }
  850.  
  851.  
  852.     private void GroupDropBox_MouseDown(object sender, MouseEventArgs e)
  853.     {
  854.  
  855.         if (X >= Width - 22)
  856.         {
  857.             if (y <= 30)
  858.             {
  859.                 switch (Checked)
  860.                 {
  861.                     case true:
  862.                         Checked = false;
  863.                         break;
  864.                     case false:
  865.                         Checked = true;
  866.                         break;
  867.                 }
  868.             }
  869.         }
  870.     }
  871. }
  872. class GroupPanelBox : ThemeContainerControl
  873. {
  874.     public GroupPanelBox()
  875.     {
  876.         AllowTransparent();
  877.     }
  878.     public override void PaintHook()
  879.     {
  880.         this.Font = new Font("Tahoma", 10);
  881.         this.ForeColor = Color.FromArgb(40, 40, 40);
  882.         G.SmoothingMode = SmoothingMode.AntiAlias;
  883.         G.Clear(Color.FromArgb(245, 245, 245));
  884.         G.FillRectangle(new SolidBrush(Color.FromArgb(231, 231, 231)), new Rectangle(0, 0, Width, 30));
  885.         G.DrawLine(new Pen(Color.FromArgb(233, 238, 240)), 1, 1, Width - 2, 1);
  886.         G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, Height - 1);
  887.         G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, 30);
  888.         G.DrawString(Text, Font, new SolidBrush(this.ForeColor), 7, 6);
  889.     }
  890. }
  891.  
  892. class ButtonGreen : ThemeControl
  893. {
  894.     public override void PaintHook()
  895.     {
  896.         this.Font = new Font("Arial", 10);
  897.         G.Clear(this.BackColor);
  898.         G.SmoothingMode = SmoothingMode.HighQuality;
  899.         switch (MouseState)
  900.         {
  901.             case State.MouseNone:
  902.                 Pen p1 = new Pen(Color.FromArgb(120, 159, 22), 1);
  903.                 LinearGradientBrush x1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(157, 209, 57), Color.FromArgb(130, 181, 18), LinearGradientMode.Vertical);
  904.                 G.FillPath(x1, Draw.RoundRect(ClientRectangle, 4));
  905.                 G.DrawPath(p1, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3));
  906.                 G.DrawLine(new Pen(Color.FromArgb(190, 232, 109)), 2, 1, Width - 3, 1);
  907.                 DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), 0);
  908.                 break;
  909.             case State.MouseDown:
  910.                 Pen p2 = new Pen(Color.FromArgb(120, 159, 22), 1);
  911.                 LinearGradientBrush x2 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(125, 171, 25), Color.FromArgb(142, 192, 40), LinearGradientMode.Vertical);
  912.                 G.FillPath(x2, Draw.RoundRect(ClientRectangle, 4));
  913.                 G.DrawPath(p2, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3));
  914.                 G.DrawLine(new Pen(Color.FromArgb(142, 172, 30)), 2, 1, Width - 3, 1);
  915.                 DrawText(HorizontalAlignment.Center, Color.FromArgb(250, 250, 250), 1);
  916.                 break;
  917.             case State.MouseOver:
  918.                 Pen p3 = new Pen(Color.FromArgb(120, 159, 22), 1);
  919.                 LinearGradientBrush x3 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(165, 220, 59), Color.FromArgb(137, 191, 18), LinearGradientMode.Vertical);
  920.                 G.FillPath(x3, Draw.RoundRect(ClientRectangle, 4));
  921.                 G.DrawPath(p3, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3));
  922.                 G.DrawLine(new Pen(Color.FromArgb(190, 232, 109)), 2, 1, Width - 3, 1);
  923.                 DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), -1);
  924.                 break;
  925.         }
  926.         this.Cursor = Cursors.Hand;
  927.     }
  928. }
  929. class ButtonBlue : ThemeControl
  930. {
  931.     public override void PaintHook()
  932.     {
  933.         this.Font = new Font("Arial", 10);
  934.         G.Clear(this.BackColor);
  935.         G.SmoothingMode = SmoothingMode.HighQuality;
  936.         switch (MouseState)
  937.         {
  938.             case State.MouseNone:
  939.                 Pen p = new Pen(Color.FromArgb(34, 112, 171), 1);
  940.                 LinearGradientBrush x = new LinearGradientBrush(ClientRectangle, Color.FromArgb(51, 159, 231), Color.FromArgb(33, 128, 206), LinearGradientMode.Vertical);
  941.                 G.FillPath(x, Draw.RoundRect(ClientRectangle, 4));
  942.                 G.DrawPath(p, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3));
  943.                 G.DrawLine(new Pen(Color.FromArgb(131, 197, 241)), 2, 1, Width - 3, 1);
  944.                 DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), 0);
  945.                 break;
  946.             case State.MouseDown:
  947.                 Pen p1 = new Pen(Color.FromArgb(34, 112, 171), 1);
  948.                 LinearGradientBrush x1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(37, 124, 196), Color.FromArgb(53, 153, 219), LinearGradientMode.Vertical);
  949.                 G.FillPath(x1, Draw.RoundRect(ClientRectangle, 4));
  950.                 G.DrawPath(p1, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3));
  951.  
  952.                 DrawText(HorizontalAlignment.Center, Color.FromArgb(250, 250, 250), 1);
  953.                 break;
  954.             case State.MouseOver:
  955.                 Pen p2 = new Pen(Color.FromArgb(34, 112, 171), 1);
  956.                 LinearGradientBrush x2 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(54, 167, 243), Color.FromArgb(35, 165, 217), LinearGradientMode.Vertical);
  957.                 G.FillPath(x2, Draw.RoundRect(ClientRectangle, 4));
  958.                 G.DrawPath(p2, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3));
  959.                 G.DrawLine(new Pen(Color.FromArgb(131, 197, 241)), 2, 1, Width - 3, 1);
  960.                 DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), -1);
  961.                 break;
  962.         }
  963.         this.Cursor = Cursors.Hand;
  964.     }
  965. }
Advertisement
Add Comment
Please, Sign In to add comment