Guest User

Theme

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