Advertisement
Guest User

VibeLander Theme (Converted to C#)

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