Advertisement
Guest User

VibeLander Theme C# - UnReLaTeDScript

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