Ethernal_Five

[C#] CrystalClear Theme by Mavamaarten

Apr 4th, 2012
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 101.30 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Collections;
  6. using System.Diagnostics;
  7. using System.Windows.Forms;
  8. using Microsoft.VisualBasic;
  9. using System.ComponentModel;
  10. using System.Drawing.Imaging;
  11. using System.Drawing.Drawing2D;
  12. using System.Collections.Generic;
  13. using System.Runtime.InteropServices;
  14.  
  15. #region "Themebase"
  16. //------------------
  17. //Creator: aeonhack
  18. //Site: elitevs.net
  19. //Created: 08/02/2011
  20. //Changed: 12/06/2011
  21. //Version: 1.5.4
  22. //------------------
  23.  
  24. abstract class ThemeContainer154 : ContainerControl
  25. {
  26.  
  27.     #region " Initialization "
  28.  
  29.     protected Graphics G;
  30.  
  31.     protected Bitmap B;
  32.     public ThemeContainer154()
  33.     {
  34.         SetStyle((ControlStyles)139270, true);
  35.  
  36.         _ImageSize = Size.Empty;
  37.         Font = new Font("Verdana", 8);
  38.  
  39.         MeasureBitmap = new Bitmap(1, 1);
  40.         MeasureGraphics = Graphics.FromImage(MeasureBitmap);
  41.  
  42.         DrawRadialPath = new GraphicsPath();
  43.  
  44.         InvalidateCustimization();
  45.     }
  46.  
  47.     protected override sealed void OnHandleCreated(EventArgs e)
  48.     {
  49.         if (DoneCreation)
  50.             InitializeMessages();
  51.  
  52.         InvalidateCustimization();
  53.         ColorHook();
  54.  
  55.         if (!(_LockWidth == 0))
  56.             Width = _LockWidth;
  57.         if (!(_LockHeight == 0))
  58.             Height = _LockHeight;
  59.         if (!_ControlMode)
  60.             base.Dock = DockStyle.Fill;
  61.  
  62.         Transparent = _Transparent;
  63.         if (_Transparent && _BackColor)
  64.             BackColor = Color.Transparent;
  65.  
  66.         base.OnHandleCreated(e);
  67.     }
  68.  
  69.     private bool DoneCreation;
  70.     protected override sealed void OnParentChanged(EventArgs e)
  71.     {
  72.         base.OnParentChanged(e);
  73.  
  74.         if (Parent == null)
  75.             return;
  76.         _IsParentForm = Parent is Form;
  77.  
  78.         if (!_ControlMode)
  79.         {
  80.             InitializeMessages();
  81.  
  82.             if (_IsParentForm)
  83.             {
  84.                 ParentForm.FormBorderStyle = _BorderStyle;
  85.                 ParentForm.TransparencyKey = _TransparencyKey;
  86.  
  87.                 if (!DesignMode)
  88.                 {
  89.                     ParentForm.Shown += FormShown;
  90.                 }
  91.             }
  92.  
  93.             Parent.BackColor = BackColor;
  94.         }
  95.  
  96.         OnCreation();
  97.         DoneCreation = true;
  98.         InvalidateTimer();
  99.     }
  100.  
  101.     #endregion
  102.  
  103.     private void DoAnimation(bool i)
  104.     {
  105.         OnAnimation();
  106.         if (i)
  107.             Invalidate();
  108.     }
  109.  
  110.     protected override sealed void OnPaint(PaintEventArgs e)
  111.     {
  112.         if (Width == 0 || Height == 0)
  113.             return;
  114.  
  115.         if (_Transparent && _ControlMode)
  116.         {
  117.             PaintHook();
  118.             e.Graphics.DrawImage(B, 0, 0);
  119.         }
  120.         else
  121.         {
  122.             G = e.Graphics;
  123.             PaintHook();
  124.         }
  125.     }
  126.  
  127.     protected override void OnHandleDestroyed(EventArgs e)
  128.     {
  129.         ThemeShare.RemoveAnimationCallback(DoAnimation);
  130.         base.OnHandleDestroyed(e);
  131.     }
  132.  
  133.     private bool HasShown;
  134.     private void FormShown(object sender, EventArgs e)
  135.     {
  136.         if (_ControlMode || HasShown)
  137.             return;
  138.  
  139.         if (_StartPosition == FormStartPosition.CenterParent || _StartPosition == FormStartPosition.CenterScreen)
  140.         {
  141.             Rectangle SB = Screen.PrimaryScreen.Bounds;
  142.             Rectangle CB = ParentForm.Bounds;
  143.             ParentForm.Location = new Point(SB.Width / 2 - CB.Width / 2, SB.Height / 2 - CB.Width / 2);
  144.         }
  145.  
  146.         HasShown = true;
  147.     }
  148.  
  149.  
  150.     #region " Size Handling "
  151.  
  152.     private Rectangle Frame;
  153.     protected override sealed void OnSizeChanged(EventArgs e)
  154.     {
  155.         if (_Movable && !_ControlMode)
  156.         {
  157.             Frame = new Rectangle(7, 7, Width - 14, _Header - 7);
  158.         }
  159.  
  160.         InvalidateBitmap();
  161.         Invalidate();
  162.  
  163.         base.OnSizeChanged(e);
  164.     }
  165.  
  166.     protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
  167.     {
  168.         if (!(_LockWidth == 0))
  169.             width = _LockWidth;
  170.         if (!(_LockHeight == 0))
  171.             height = _LockHeight;
  172.         base.SetBoundsCore(x, y, width, height, specified);
  173.     }
  174.  
  175.     #endregion
  176.  
  177.     #region " State Handling "
  178.  
  179.     protected MouseState State;
  180.     private void SetState(MouseState current)
  181.     {
  182.         State = current;
  183.         Invalidate();
  184.     }
  185.  
  186.     protected override void OnMouseMove(MouseEventArgs e)
  187.     {
  188.         if (!(_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized))
  189.         {
  190.             if (_Sizable && !_ControlMode)
  191.                 InvalidateMouse();
  192.         }
  193.  
  194.         base.OnMouseMove(e);
  195.     }
  196.  
  197.     protected override void OnEnabledChanged(EventArgs e)
  198.     {
  199.         if (Enabled)
  200.             SetState(MouseState.None);
  201.         else
  202.             SetState(MouseState.Block);
  203.         base.OnEnabledChanged(e);
  204.     }
  205.  
  206.     protected override void OnMouseEnter(EventArgs e)
  207.     {
  208.         SetState(MouseState.Over);
  209.         base.OnMouseEnter(e);
  210.     }
  211.  
  212.     protected override void OnMouseUp(MouseEventArgs e)
  213.     {
  214.         SetState(MouseState.Over);
  215.         base.OnMouseUp(e);
  216.     }
  217.  
  218.     protected override void OnMouseLeave(EventArgs e)
  219.     {
  220.         SetState(MouseState.None);
  221.  
  222.         if (GetChildAtPoint(PointToClient(MousePosition)) != null)
  223.         {
  224.             if (_Sizable && !_ControlMode)
  225.             {
  226.                 Cursor = Cursors.Default;
  227.                 Previous = 0;
  228.             }
  229.         }
  230.  
  231.         base.OnMouseLeave(e);
  232.     }
  233.  
  234.     protected override void OnMouseDown(MouseEventArgs e)
  235.     {
  236.         if (e.Button == System.Windows.Forms.MouseButtons.Left)
  237.             SetState(MouseState.Down);
  238.  
  239.         if (!(_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized || _ControlMode))
  240.         {
  241.             if (_Movable && Frame.Contains(e.Location))
  242.             {
  243.                 Capture = false;
  244.                 WM_LMBUTTONDOWN = true;
  245.                 DefWndProc(ref Messages[0]);
  246.             }
  247.             else if (_Sizable && !(Previous == 0))
  248.             {
  249.                 Capture = false;
  250.                 WM_LMBUTTONDOWN = true;
  251.                 DefWndProc(ref Messages[Previous]);
  252.             }
  253.         }
  254.  
  255.         base.OnMouseDown(e);
  256.     }
  257.  
  258.     private bool WM_LMBUTTONDOWN;
  259.     protected override void WndProc(ref Message m)
  260.     {
  261.         base.WndProc(ref m);
  262.  
  263.         if (WM_LMBUTTONDOWN && m.Msg == 513)
  264.         {
  265.             WM_LMBUTTONDOWN = false;
  266.  
  267.             SetState(MouseState.Over);
  268.             if (!_SmartBounds)
  269.                 return;
  270.  
  271.             if (IsParentMdi)
  272.             {
  273.                 CorrectBounds(new Rectangle(Point.Empty, Parent.Parent.Size));
  274.             }
  275.             else
  276.             {
  277.                 CorrectBounds(Screen.FromControl(Parent).WorkingArea);
  278.             }
  279.         }
  280.     }
  281.  
  282.     private Point GetIndexPoint;
  283.     private bool B1;
  284.     private bool B2;
  285.     private bool B3;
  286.     private bool B4;
  287.     private int GetIndex()
  288.     {
  289.         GetIndexPoint = PointToClient(MousePosition);
  290.         B1 = GetIndexPoint.X < 7;
  291.         B2 = GetIndexPoint.X > Width - 7;
  292.         B3 = GetIndexPoint.Y < 7;
  293.         B4 = GetIndexPoint.Y > Height - 7;
  294.  
  295.         if (B1 && B3)
  296.             return 4;
  297.         if (B1 && B4)
  298.             return 7;
  299.         if (B2 && B3)
  300.             return 5;
  301.         if (B2 && B4)
  302.             return 8;
  303.         if (B1)
  304.             return 1;
  305.         if (B2)
  306.             return 2;
  307.         if (B3)
  308.             return 3;
  309.         if (B4)
  310.             return 6;
  311.         return 0;
  312.     }
  313.  
  314.     private int Current;
  315.     private int Previous;
  316.     private void InvalidateMouse()
  317.     {
  318.         Current = GetIndex();
  319.         if (Current == Previous)
  320.             return;
  321.  
  322.         Previous = Current;
  323.         switch (Previous)
  324.         {
  325.             case 0:
  326.                 Cursor = Cursors.Default;
  327.                 break;
  328.             case 1:
  329.             case 2:
  330.                 Cursor = Cursors.SizeWE;
  331.                 break;
  332.             case 3:
  333.             case 6:
  334.                 Cursor = Cursors.SizeNS;
  335.                 break;
  336.             case 4:
  337.             case 8:
  338.                 Cursor = Cursors.SizeNWSE;
  339.                 break;
  340.             case 5:
  341.             case 7:
  342.                 Cursor = Cursors.SizeNESW;
  343.                 break;
  344.         }
  345.     }
  346.  
  347.     private Message[] Messages = new Message[9];
  348.     private void InitializeMessages()
  349.     {
  350.         Messages[0] = Message.Create(Parent.Handle, 161, new IntPtr(2), IntPtr.Zero);
  351.         for (int I = 1; I <= 8; I++)
  352.         {
  353.             Messages[I] = Message.Create(Parent.Handle, 161, new IntPtr(I + 9), IntPtr.Zero);
  354.         }
  355.     }
  356.  
  357.     private void CorrectBounds(Rectangle bounds)
  358.     {
  359.         if (Parent.Width > bounds.Width)
  360.             Parent.Width = bounds.Width;
  361.         if (Parent.Height > bounds.Height)
  362.             Parent.Height = bounds.Height;
  363.  
  364.         int X = Parent.Location.X;
  365.         int Y = Parent.Location.Y;
  366.  
  367.         if (X < bounds.X)
  368.             X = bounds.X;
  369.         if (Y < bounds.Y)
  370.             Y = bounds.Y;
  371.  
  372.         int Width = bounds.X + bounds.Width;
  373.         int Height = bounds.Y + bounds.Height;
  374.  
  375.         if (X + Parent.Width > Width)
  376.             X = Width - Parent.Width;
  377.         if (Y + Parent.Height > Height)
  378.             Y = Height - Parent.Height;
  379.  
  380.         Parent.Location = new Point(X, Y);
  381.     }
  382.  
  383.     #endregion
  384.  
  385.  
  386.     #region " Base Properties "
  387.  
  388.     public override DockStyle Dock
  389.     {
  390.         get { return base.Dock; }
  391.         set
  392.         {
  393.             if (!_ControlMode)
  394.                 return;
  395.             base.Dock = value;
  396.         }
  397.     }
  398.  
  399.     private bool _BackColor;
  400.     [Category("Misc")]
  401.     public override Color BackColor
  402.     {
  403.         get { return base.BackColor; }
  404.         set
  405.         {
  406.             if (value == base.BackColor)
  407.                 return;
  408.  
  409.             if (!IsHandleCreated && _ControlMode && value == Color.Transparent)
  410.             {
  411.                 _BackColor = true;
  412.                 return;
  413.             }
  414.  
  415.             base.BackColor = value;
  416.             if (Parent != null)
  417.             {
  418.                 if (!_ControlMode)
  419.                     Parent.BackColor = value;
  420.                 ColorHook();
  421.             }
  422.         }
  423.     }
  424.  
  425.     public override Size MinimumSize
  426.     {
  427.         get { return base.MinimumSize; }
  428.         set
  429.         {
  430.             base.MinimumSize = value;
  431.             if (Parent != null)
  432.                 Parent.MinimumSize = value;
  433.         }
  434.     }
  435.  
  436.     public override Size MaximumSize
  437.     {
  438.         get { return base.MaximumSize; }
  439.         set
  440.         {
  441.             base.MaximumSize = value;
  442.             if (Parent != null)
  443.                 Parent.MaximumSize = value;
  444.         }
  445.     }
  446.  
  447.     public override string Text
  448.     {
  449.         get { return base.Text; }
  450.         set
  451.         {
  452.             base.Text = value;
  453.             Invalidate();
  454.         }
  455.     }
  456.  
  457.     public override Font Font
  458.     {
  459.         get { return base.Font; }
  460.         set
  461.         {
  462.             base.Font = value;
  463.             Invalidate();
  464.         }
  465.     }
  466.  
  467.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  468.     public override Color ForeColor
  469.     {
  470.         get { return Color.Empty; }
  471.         set { }
  472.     }
  473.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  474.     public override Image BackgroundImage
  475.     {
  476.         get { return null; }
  477.         set { }
  478.     }
  479.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  480.     public override ImageLayout BackgroundImageLayout
  481.     {
  482.         get { return ImageLayout.None; }
  483.         set { }
  484.     }
  485.  
  486.     #endregion
  487.  
  488.     #region " Public Properties "
  489.  
  490.     private bool _SmartBounds = true;
  491.     public bool SmartBounds
  492.     {
  493.         get { return _SmartBounds; }
  494.         set { _SmartBounds = value; }
  495.     }
  496.  
  497.     private bool _Movable = true;
  498.     public bool Movable
  499.     {
  500.         get { return _Movable; }
  501.         set { _Movable = value; }
  502.     }
  503.  
  504.     private bool _Sizable = true;
  505.     public bool Sizable
  506.     {
  507.         get { return _Sizable; }
  508.         set { _Sizable = value; }
  509.     }
  510.  
  511.     private Color _TransparencyKey;
  512.     public Color TransparencyKey
  513.     {
  514.         get
  515.         {
  516.             if (_IsParentForm && !_ControlMode)
  517.                 return ParentForm.TransparencyKey;
  518.             else
  519.                 return _TransparencyKey;
  520.         }
  521.         set
  522.         {
  523.             if (value == _TransparencyKey)
  524.                 return;
  525.             _TransparencyKey = value;
  526.  
  527.             if (_IsParentForm && !_ControlMode)
  528.             {
  529.                 ParentForm.TransparencyKey = value;
  530.                 ColorHook();
  531.             }
  532.         }
  533.     }
  534.  
  535.     private FormBorderStyle _BorderStyle;
  536.     public FormBorderStyle BorderStyle
  537.     {
  538.         get
  539.         {
  540.             if (_IsParentForm && !_ControlMode)
  541.                 return ParentForm.FormBorderStyle;
  542.             else
  543.                 return _BorderStyle;
  544.         }
  545.         set
  546.         {
  547.             _BorderStyle = value;
  548.  
  549.             if (_IsParentForm && !_ControlMode)
  550.             {
  551.                 ParentForm.FormBorderStyle = value;
  552.  
  553.                 if (!(value == FormBorderStyle.None))
  554.                 {
  555.                     Movable = false;
  556.                     Sizable = false;
  557.                 }
  558.             }
  559.         }
  560.     }
  561.  
  562.     private FormStartPosition _StartPosition;
  563.     public FormStartPosition StartPosition
  564.     {
  565.         get
  566.         {
  567.             if (_IsParentForm && !_ControlMode)
  568.                 return ParentForm.StartPosition;
  569.             else
  570.                 return _StartPosition;
  571.         }
  572.         set
  573.         {
  574.             _StartPosition = value;
  575.  
  576.             if (_IsParentForm && !_ControlMode)
  577.             {
  578.                 ParentForm.StartPosition = value;
  579.             }
  580.         }
  581.     }
  582.  
  583.     private bool _NoRounding;
  584.     public bool NoRounding
  585.     {
  586.         get { return _NoRounding; }
  587.         set
  588.         {
  589.             _NoRounding = value;
  590.             Invalidate();
  591.         }
  592.     }
  593.  
  594.     private Image _Image;
  595.     public Image Image
  596.     {
  597.         get { return _Image; }
  598.         set
  599.         {
  600.             if (value == null)
  601.                 _ImageSize = Size.Empty;
  602.             else
  603.                 _ImageSize = value.Size;
  604.  
  605.             _Image = value;
  606.             Invalidate();
  607.         }
  608.     }
  609.  
  610.     private Dictionary<string, Color> Items = new Dictionary<string, Color>();
  611.     public Bloom[] Colors
  612.     {
  613.         get
  614.         {
  615.             List<Bloom> T = new List<Bloom>();
  616.             Dictionary<string, Color>.Enumerator E = Items.GetEnumerator();
  617.  
  618.             while (E.MoveNext())
  619.             {
  620.                 T.Add(new Bloom(E.Current.Key, E.Current.Value));
  621.             }
  622.  
  623.             return T.ToArray();
  624.         }
  625.         set
  626.         {
  627.             foreach (Bloom B in value)
  628.             {
  629.                 if (Items.ContainsKey(B.Name))
  630.                     Items[B.Name] = B.Value;
  631.             }
  632.  
  633.             InvalidateCustimization();
  634.             ColorHook();
  635.             Invalidate();
  636.         }
  637.     }
  638.  
  639.     private string _Customization;
  640.     public string Customization
  641.     {
  642.         get { return _Customization; }
  643.         set
  644.         {
  645.             if (value == _Customization)
  646.                 return;
  647.  
  648.             byte[] Data = null;
  649.             Bloom[] Items = Colors;
  650.  
  651.             try
  652.             {
  653.                 Data = Convert.FromBase64String(value);
  654.                 for (int I = 0; I <= Items.Length - 1; I++)
  655.                 {
  656.                     Items[I].Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4));
  657.                 }
  658.             }
  659.             catch
  660.             {
  661.                 return;
  662.             }
  663.  
  664.             _Customization = value;
  665.  
  666.             Colors = Items;
  667.             ColorHook();
  668.             Invalidate();
  669.         }
  670.     }
  671.  
  672.     private bool _Transparent;
  673.     public bool Transparent
  674.     {
  675.         get { return _Transparent; }
  676.         set
  677.         {
  678.             _Transparent = value;
  679.             if (!(IsHandleCreated || _ControlMode))
  680.                 return;
  681.  
  682.             if (!value && !(BackColor.A == 255))
  683.             {
  684.                 throw new Exception("Unable to change value to false while a transparent BackColor is in use.");
  685.             }
  686.  
  687.             SetStyle(ControlStyles.Opaque, !value);
  688.             SetStyle(ControlStyles.SupportsTransparentBackColor, value);
  689.  
  690.             InvalidateBitmap();
  691.             Invalidate();
  692.         }
  693.     }
  694.  
  695.     #endregion
  696.  
  697.     #region " Private Properties "
  698.  
  699.     private Size _ImageSize;
  700.     protected Size ImageSize
  701.     {
  702.         get { return _ImageSize; }
  703.     }
  704.  
  705.     private bool _IsParentForm;
  706.     protected bool IsParentForm
  707.     {
  708.         get { return _IsParentForm; }
  709.     }
  710.  
  711.     protected bool IsParentMdi
  712.     {
  713.         get
  714.         {
  715.             if (Parent == null)
  716.                 return false;
  717.             return Parent.Parent != null;
  718.         }
  719.     }
  720.  
  721.     private int _LockWidth;
  722.     protected int LockWidth
  723.     {
  724.         get { return _LockWidth; }
  725.         set
  726.         {
  727.             _LockWidth = value;
  728.             if (!(LockWidth == 0) && IsHandleCreated)
  729.                 Width = LockWidth;
  730.         }
  731.     }
  732.  
  733.     private int _LockHeight;
  734.     protected int LockHeight
  735.     {
  736.         get { return _LockHeight; }
  737.         set
  738.         {
  739.             _LockHeight = value;
  740.             if (!(LockHeight == 0) && IsHandleCreated)
  741.                 Height = LockHeight;
  742.         }
  743.     }
  744.  
  745.     private int _Header = 24;
  746.     protected int Header
  747.     {
  748.         get { return _Header; }
  749.         set
  750.         {
  751.             _Header = value;
  752.  
  753.             if (!_ControlMode)
  754.             {
  755.                 Frame = new Rectangle(7, 7, Width - 14, value - 7);
  756.                 Invalidate();
  757.             }
  758.         }
  759.     }
  760.  
  761.     private bool _ControlMode;
  762.     protected bool ControlMode
  763.     {
  764.         get { return _ControlMode; }
  765.         set
  766.         {
  767.             _ControlMode = value;
  768.  
  769.             Transparent = _Transparent;
  770.             if (_Transparent && _BackColor)
  771.                 BackColor = Color.Transparent;
  772.  
  773.             InvalidateBitmap();
  774.             Invalidate();
  775.         }
  776.     }
  777.  
  778.     private bool _IsAnimated;
  779.     protected bool IsAnimated
  780.     {
  781.         get { return _IsAnimated; }
  782.         set
  783.         {
  784.             _IsAnimated = value;
  785.             InvalidateTimer();
  786.         }
  787.     }
  788.  
  789.     #endregion
  790.  
  791.  
  792.     #region " Property Helpers "
  793.  
  794.     protected Pen GetPen(string name)
  795.     {
  796.         return new Pen(Items[name]);
  797.     }
  798.     protected Pen GetPen(string name, float width)
  799.     {
  800.         return new Pen(Items[name], width);
  801.     }
  802.  
  803.     protected SolidBrush GetBrush(string name)
  804.     {
  805.         return new SolidBrush(Items[name]);
  806.     }
  807.  
  808.     protected Color GetColor(string name)
  809.     {
  810.         return Items[name];
  811.     }
  812.  
  813.     protected void SetColor(string name, Color value)
  814.     {
  815.         if (Items.ContainsKey(name))
  816.             Items[name] = value;
  817.         else
  818.             Items.Add(name, value);
  819.     }
  820.     protected void SetColor(string name, byte r, byte g, byte b)
  821.     {
  822.         SetColor(name, Color.FromArgb(r, g, b));
  823.     }
  824.     protected void SetColor(string name, byte a, byte r, byte g, byte b)
  825.     {
  826.         SetColor(name, Color.FromArgb(a, r, g, b));
  827.     }
  828.     protected void SetColor(string name, byte a, Color value)
  829.     {
  830.         SetColor(name, Color.FromArgb(a, value));
  831.     }
  832.  
  833.     private void InvalidateBitmap()
  834.     {
  835.         if (_Transparent && _ControlMode)
  836.         {
  837.             if (Width == 0 || Height == 0)
  838.                 return;
  839.             B = new Bitmap(Width, Height, PixelFormat.Format32bppPArgb);
  840.             G = Graphics.FromImage(B);
  841.         }
  842.         else
  843.         {
  844.             G = null;
  845.             B = null;
  846.         }
  847.     }
  848.  
  849.     private void InvalidateCustimization()
  850.     {
  851.         MemoryStream M = new MemoryStream(Items.Count * 4);
  852.  
  853.         foreach (Bloom B in Colors)
  854.         {
  855.             M.Write(BitConverter.GetBytes(B.Value.ToArgb()), 0, 4);
  856.         }
  857.  
  858.         M.Close();
  859.         _Customization = Convert.ToBase64String(M.ToArray());
  860.     }
  861.  
  862.     private void InvalidateTimer()
  863.     {
  864.         if (DesignMode || !DoneCreation)
  865.             return;
  866.  
  867.         if (_IsAnimated)
  868.         {
  869.             ThemeShare.AddAnimationCallback(DoAnimation);
  870.         }
  871.         else
  872.         {
  873.             ThemeShare.RemoveAnimationCallback(DoAnimation);
  874.         }
  875.     }
  876.  
  877.     #endregion
  878.  
  879.  
  880.     #region " User Hooks "
  881.  
  882.     protected abstract void ColorHook();
  883.     protected abstract void PaintHook();
  884.  
  885.     protected virtual void OnCreation()
  886.     {
  887.     }
  888.  
  889.     protected virtual void OnAnimation()
  890.     {
  891.     }
  892.  
  893.     #endregion
  894.  
  895.  
  896.     #region " Offset "
  897.  
  898.     private Rectangle OffsetReturnRectangle;
  899.     protected Rectangle Offset(Rectangle r, int amount)
  900.     {
  901.         OffsetReturnRectangle = new Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2));
  902.         return OffsetReturnRectangle;
  903.     }
  904.  
  905.     private Size OffsetReturnSize;
  906.     protected Size Offset(Size s, int amount)
  907.     {
  908.         OffsetReturnSize = new Size(s.Width + amount, s.Height + amount);
  909.         return OffsetReturnSize;
  910.     }
  911.  
  912.     private Point OffsetReturnPoint;
  913.     protected Point Offset(Point p, int amount)
  914.     {
  915.         OffsetReturnPoint = new Point(p.X + amount, p.Y + amount);
  916.         return OffsetReturnPoint;
  917.     }
  918.  
  919.     #endregion
  920.  
  921.     #region " Center "
  922.  
  923.  
  924.     private Point CenterReturn;
  925.     protected Point Center(Rectangle p, Rectangle c)
  926.     {
  927.         CenterReturn = new Point((p.Width / 2 - c.Width / 2) + p.X + c.X, (p.Height / 2 - c.Height / 2) + p.Y + c.Y);
  928.         return CenterReturn;
  929.     }
  930.     protected Point Center(Rectangle p, Size c)
  931.     {
  932.         CenterReturn = new Point((p.Width / 2 - c.Width / 2) + p.X, (p.Height / 2 - c.Height / 2) + p.Y);
  933.         return CenterReturn;
  934.     }
  935.  
  936.     protected Point Center(Rectangle child)
  937.     {
  938.         return Center(Width, Height, child.Width, child.Height);
  939.     }
  940.     protected Point Center(Size child)
  941.     {
  942.         return Center(Width, Height, child.Width, child.Height);
  943.     }
  944.     protected Point Center(int childWidth, int childHeight)
  945.     {
  946.         return Center(Width, Height, childWidth, childHeight);
  947.     }
  948.  
  949.     protected Point Center(Size p, Size c)
  950.     {
  951.         return Center(p.Width, p.Height, c.Width, c.Height);
  952.     }
  953.  
  954.     protected Point Center(int pWidth, int pHeight, int cWidth, int cHeight)
  955.     {
  956.         CenterReturn = new Point(pWidth / 2 - cWidth / 2, pHeight / 2 - cHeight / 2);
  957.         return CenterReturn;
  958.     }
  959.  
  960.     #endregion
  961.  
  962.     #region " Measure "
  963.  
  964.     private Bitmap MeasureBitmap;
  965.  
  966.     private Graphics MeasureGraphics;
  967.     protected Size Measure()
  968.     {
  969.         lock (MeasureGraphics)
  970.         {
  971.             return MeasureGraphics.MeasureString(Text, Font, Width).ToSize();
  972.         }
  973.     }
  974.     protected Size Measure(string text)
  975.     {
  976.         lock (MeasureGraphics)
  977.         {
  978.             return MeasureGraphics.MeasureString(text, Font, Width).ToSize();
  979.         }
  980.     }
  981.  
  982.     #endregion
  983.  
  984.  
  985.     #region " DrawPixel "
  986.  
  987.  
  988.     private SolidBrush DrawPixelBrush;
  989.     protected void DrawPixel(Color c1, int x, int y)
  990.     {
  991.         if (_Transparent)
  992.         {
  993.             B.SetPixel(x, y, c1);
  994.         }
  995.         else
  996.         {
  997.             DrawPixelBrush = new SolidBrush(c1);
  998.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1);
  999.         }
  1000.     }
  1001.  
  1002.     #endregion
  1003.  
  1004.     #region " DrawCorners "
  1005.  
  1006.  
  1007.     private SolidBrush DrawCornersBrush;
  1008.     protected void DrawCorners(Color c1, int offset)
  1009.     {
  1010.         DrawCorners(c1, 0, 0, Width, Height, offset);
  1011.     }
  1012.     protected void DrawCorners(Color c1, Rectangle r1, int offset)
  1013.     {
  1014.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset);
  1015.     }
  1016.     protected void DrawCorners(Color c1, int x, int y, int width, int height, int offset)
  1017.     {
  1018.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
  1019.     }
  1020.  
  1021.     protected void DrawCorners(Color c1)
  1022.     {
  1023.         DrawCorners(c1, 0, 0, Width, Height);
  1024.     }
  1025.     protected void DrawCorners(Color c1, Rectangle r1)
  1026.     {
  1027.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height);
  1028.     }
  1029.     protected void DrawCorners(Color c1, int x, int y, int width, int height)
  1030.     {
  1031.         if (_NoRounding)
  1032.             return;
  1033.  
  1034.         if (_Transparent)
  1035.         {
  1036.             B.SetPixel(x, y, c1);
  1037.             B.SetPixel(x + (width - 1), y, c1);
  1038.             B.SetPixel(x, y + (height - 1), c1);
  1039.             B.SetPixel(x + (width - 1), y + (height - 1), c1);
  1040.         }
  1041.         else
  1042.         {
  1043.             DrawCornersBrush = new SolidBrush(c1);
  1044.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1);
  1045.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1);
  1046.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1);
  1047.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1);
  1048.         }
  1049.     }
  1050.  
  1051.     #endregion
  1052.  
  1053.     #region " DrawBorders "
  1054.  
  1055.     protected void DrawBorders(Pen p1, int offset)
  1056.     {
  1057.         DrawBorders(p1, 0, 0, Width, Height, offset);
  1058.     }
  1059.     protected void DrawBorders(Pen p1, Rectangle r, int offset)
  1060.     {
  1061.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset);
  1062.     }
  1063.     protected void DrawBorders(Pen p1, int x, int y, int width, int height, int offset)
  1064.     {
  1065.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
  1066.     }
  1067.  
  1068.     protected void DrawBorders(Pen p1)
  1069.     {
  1070.         DrawBorders(p1, 0, 0, Width, Height);
  1071.     }
  1072.     protected void DrawBorders(Pen p1, Rectangle r)
  1073.     {
  1074.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height);
  1075.     }
  1076.     protected void DrawBorders(Pen p1, int x, int y, int width, int height)
  1077.     {
  1078.         G.DrawRectangle(p1, x, y, width - 1, height - 1);
  1079.     }
  1080.  
  1081.     #endregion
  1082.  
  1083.     #region " DrawText "
  1084.  
  1085.     private Point DrawTextPoint;
  1086.  
  1087.     private Size DrawTextSize;
  1088.     protected void DrawText(Brush b1, HorizontalAlignment a, int x, int y)
  1089.     {
  1090.         DrawText(b1, Text, a, x, y);
  1091.     }
  1092.     protected void DrawText(Brush b1, string text, HorizontalAlignment a, int x, int y)
  1093.     {
  1094.         if (text.Length == 0)
  1095.             return;
  1096.  
  1097.         DrawTextSize = Measure(text);
  1098.         DrawTextPoint = new Point(Width / 2 - DrawTextSize.Width / 2, Header / 2 - DrawTextSize.Height / 2);
  1099.  
  1100.         switch (a)
  1101.         {
  1102.             case HorizontalAlignment.Left:
  1103.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y);
  1104.                 break;
  1105.             case HorizontalAlignment.Center:
  1106.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y);
  1107.                 break;
  1108.             case HorizontalAlignment.Right:
  1109.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y);
  1110.                 break;
  1111.         }
  1112.     }
  1113.  
  1114.     protected void DrawText(Brush b1, Point p1)
  1115.     {
  1116.         if (Text.Length == 0)
  1117.             return;
  1118.         G.DrawString(Text, Font, b1, p1);
  1119.     }
  1120.     protected void DrawText(Brush b1, int x, int y)
  1121.     {
  1122.         if (Text.Length == 0)
  1123.             return;
  1124.         G.DrawString(Text, Font, b1, x, y);
  1125.     }
  1126.  
  1127.     #endregion
  1128.  
  1129.     #region " DrawImage "
  1130.  
  1131.  
  1132.     private Point DrawImagePoint;
  1133.     protected void DrawImage(HorizontalAlignment a, int x, int y)
  1134.     {
  1135.         DrawImage(_Image, a, x, y);
  1136.     }
  1137.     protected void DrawImage(Image image, HorizontalAlignment a, int x, int y)
  1138.     {
  1139.         if (image == null)
  1140.             return;
  1141.         DrawImagePoint = new Point(Width / 2 - image.Width / 2, Header / 2 - image.Height / 2);
  1142.  
  1143.         switch (a)
  1144.         {
  1145.             case HorizontalAlignment.Left:
  1146.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height);
  1147.                 break;
  1148.             case HorizontalAlignment.Center:
  1149.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height);
  1150.                 break;
  1151.             case HorizontalAlignment.Right:
  1152.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height);
  1153.                 break;
  1154.         }
  1155.     }
  1156.  
  1157.     protected void DrawImage(Point p1)
  1158.     {
  1159.         DrawImage(_Image, p1.X, p1.Y);
  1160.     }
  1161.     protected void DrawImage(int x, int y)
  1162.     {
  1163.         DrawImage(_Image, x, y);
  1164.     }
  1165.  
  1166.     protected void DrawImage(Image image, Point p1)
  1167.     {
  1168.         DrawImage(image, p1.X, p1.Y);
  1169.     }
  1170.     protected void DrawImage(Image image, int x, int y)
  1171.     {
  1172.         if (image == null)
  1173.             return;
  1174.         G.DrawImage(image, x, y, image.Width, image.Height);
  1175.     }
  1176.  
  1177.     #endregion
  1178.  
  1179.     #region " DrawGradient "
  1180.  
  1181.     private LinearGradientBrush DrawGradientBrush;
  1182.  
  1183.     private Rectangle DrawGradientRectangle;
  1184.     protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height)
  1185.     {
  1186.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  1187.         DrawGradient(blend, DrawGradientRectangle);
  1188.     }
  1189.     protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height, float angle)
  1190.     {
  1191.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  1192.         DrawGradient(blend, DrawGradientRectangle, angle);
  1193.     }
  1194.  
  1195.     protected void DrawGradient(ColorBlend blend, Rectangle r)
  1196.     {
  1197.         DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, 90f);
  1198.         DrawGradientBrush.InterpolationColors = blend;
  1199.         G.FillRectangle(DrawGradientBrush, r);
  1200.     }
  1201.     protected void DrawGradient(ColorBlend blend, Rectangle r, float angle)
  1202.     {
  1203.         DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, angle);
  1204.         DrawGradientBrush.InterpolationColors = blend;
  1205.         G.FillRectangle(DrawGradientBrush, r);
  1206.     }
  1207.  
  1208.  
  1209.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height)
  1210.     {
  1211.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  1212.         DrawGradient(c1, c2, DrawGradientRectangle);
  1213.     }
  1214.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
  1215.     {
  1216.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  1217.         DrawGradient(c1, c2, DrawGradientRectangle, angle);
  1218.     }
  1219.  
  1220.     protected void DrawGradient(Color c1, Color c2, Rectangle r)
  1221.     {
  1222.         DrawGradientBrush = new LinearGradientBrush(r, c1, c2, 90f);
  1223.         G.FillRectangle(DrawGradientBrush, r);
  1224.     }
  1225.     protected void DrawGradient(Color c1, Color c2, Rectangle r, float angle)
  1226.     {
  1227.         DrawGradientBrush = new LinearGradientBrush(r, c1, c2, angle);
  1228.         G.FillRectangle(DrawGradientBrush, r);
  1229.     }
  1230.  
  1231.     #endregion
  1232.  
  1233.     #region " DrawRadial "
  1234.  
  1235.     private GraphicsPath DrawRadialPath;
  1236.     private PathGradientBrush DrawRadialBrush1;
  1237.     private LinearGradientBrush DrawRadialBrush2;
  1238.  
  1239.     private Rectangle DrawRadialRectangle;
  1240.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height)
  1241.     {
  1242.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  1243.         DrawRadial(blend, DrawRadialRectangle, width / 2, height / 2);
  1244.     }
  1245.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, Point center)
  1246.     {
  1247.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  1248.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y);
  1249.     }
  1250.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, int cx, int cy)
  1251.     {
  1252.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  1253.         DrawRadial(blend, DrawRadialRectangle, cx, cy);
  1254.     }
  1255.  
  1256.     public void DrawRadial(ColorBlend blend, Rectangle r)
  1257.     {
  1258.         DrawRadial(blend, r, r.Width / 2, r.Height / 2);
  1259.     }
  1260.     public void DrawRadial(ColorBlend blend, Rectangle r, Point center)
  1261.     {
  1262.         DrawRadial(blend, r, center.X, center.Y);
  1263.     }
  1264.     public void DrawRadial(ColorBlend blend, Rectangle r, int cx, int cy)
  1265.     {
  1266.         DrawRadialPath.Reset();
  1267.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1);
  1268.  
  1269.         DrawRadialBrush1 = new PathGradientBrush(DrawRadialPath);
  1270.         DrawRadialBrush1.CenterPoint = new Point(r.X + cx, r.Y + cy);
  1271.         DrawRadialBrush1.InterpolationColors = blend;
  1272.  
  1273.         if (G.SmoothingMode == SmoothingMode.AntiAlias)
  1274.         {
  1275.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3);
  1276.         }
  1277.         else
  1278.         {
  1279.             G.FillEllipse(DrawRadialBrush1, r);
  1280.         }
  1281.     }
  1282.  
  1283.  
  1284.     protected void DrawRadial(Color c1, Color c2, int x, int y, int width, int height)
  1285.     {
  1286.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  1287.         DrawRadial(c1, c2, DrawGradientRectangle);
  1288.     }
  1289.     protected void DrawRadial(Color c1, Color c2, int x, int y, int width, int height, float angle)
  1290.     {
  1291.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  1292.         DrawRadial(c1, c2, DrawGradientRectangle, angle);
  1293.     }
  1294.  
  1295.     protected void DrawRadial(Color c1, Color c2, Rectangle r)
  1296.     {
  1297.         DrawRadialBrush2 = new LinearGradientBrush(r, c1, c2, 90f);
  1298.         G.FillRectangle(DrawGradientBrush, r);
  1299.     }
  1300.     protected void DrawRadial(Color c1, Color c2, Rectangle r, float angle)
  1301.     {
  1302.         DrawRadialBrush2 = new LinearGradientBrush(r, c1, c2, angle);
  1303.         G.FillEllipse(DrawGradientBrush, r);
  1304.     }
  1305.  
  1306.     #endregion
  1307.  
  1308.     #region " CreateRound "
  1309.  
  1310.     private GraphicsPath CreateRoundPath;
  1311.  
  1312.     private Rectangle CreateRoundRectangle;
  1313.     public GraphicsPath CreateRound(int x, int y, int width, int height, int slope)
  1314.     {
  1315.         CreateRoundRectangle = new Rectangle(x, y, width, height);
  1316.         return CreateRound(CreateRoundRectangle, slope);
  1317.     }
  1318.  
  1319.     public GraphicsPath CreateRound(Rectangle r, int slope)
  1320.     {
  1321.         CreateRoundPath = new GraphicsPath(FillMode.Winding);
  1322.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180f, 90f);
  1323.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270f, 90f);
  1324.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0f, 90f);
  1325.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90f, 90f);
  1326.         CreateRoundPath.CloseFigure();
  1327.         return CreateRoundPath;
  1328.     }
  1329.  
  1330.     #endregion
  1331.  
  1332. }
  1333.  
  1334. abstract class ThemeControl154 : Control
  1335. {
  1336.  
  1337.  
  1338.     #region " Initialization "
  1339.  
  1340.     protected Graphics G;
  1341.  
  1342.     protected Bitmap B;
  1343.     public ThemeControl154()
  1344.     {
  1345.         SetStyle((ControlStyles)139270, true);
  1346.  
  1347.         _ImageSize = Size.Empty;
  1348.         Font = new Font("Verdana", 8);
  1349.  
  1350.         MeasureBitmap = new Bitmap(1, 1);
  1351.         MeasureGraphics = Graphics.FromImage(MeasureBitmap);
  1352.  
  1353.         DrawRadialPath = new GraphicsPath();
  1354.  
  1355.         InvalidateCustimization();
  1356.         //Remove?
  1357.     }
  1358.  
  1359.     protected override sealed void OnHandleCreated(EventArgs e)
  1360.     {
  1361.         InvalidateCustimization();
  1362.         ColorHook();
  1363.  
  1364.         if (!(_LockWidth == 0))
  1365.             Width = _LockWidth;
  1366.         if (!(_LockHeight == 0))
  1367.             Height = _LockHeight;
  1368.  
  1369.         Transparent = _Transparent;
  1370.         if (_Transparent && _BackColor)
  1371.             BackColor = Color.Transparent;
  1372.  
  1373.         base.OnHandleCreated(e);
  1374.     }
  1375.  
  1376.     private bool DoneCreation;
  1377.     protected override sealed void OnParentChanged(EventArgs e)
  1378.     {
  1379.         if (Parent != null)
  1380.         {
  1381.             OnCreation();
  1382.             DoneCreation = true;
  1383.             InvalidateTimer();
  1384.         }
  1385.  
  1386.         base.OnParentChanged(e);
  1387.     }
  1388.  
  1389.     #endregion
  1390.  
  1391.     private void DoAnimation(bool i)
  1392.     {
  1393.         OnAnimation();
  1394.         if (i)
  1395.             Invalidate();
  1396.     }
  1397.  
  1398.     protected override sealed void OnPaint(PaintEventArgs e)
  1399.     {
  1400.         if (Width == 0 || Height == 0)
  1401.             return;
  1402.  
  1403.         if (_Transparent)
  1404.         {
  1405.             PaintHook();
  1406.             e.Graphics.DrawImage(B, 0, 0);
  1407.         }
  1408.         else
  1409.         {
  1410.             G = e.Graphics;
  1411.             PaintHook();
  1412.         }
  1413.     }
  1414.  
  1415.     protected override void OnHandleDestroyed(EventArgs e)
  1416.     {
  1417.         ThemeShare.RemoveAnimationCallback(DoAnimation);
  1418.         base.OnHandleDestroyed(e);
  1419.     }
  1420.  
  1421.     #region " Size Handling "
  1422.  
  1423.     protected override sealed void OnSizeChanged(EventArgs e)
  1424.     {
  1425.         if (_Transparent)
  1426.         {
  1427.             InvalidateBitmap();
  1428.         }
  1429.  
  1430.         Invalidate();
  1431.         base.OnSizeChanged(e);
  1432.     }
  1433.  
  1434.     protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
  1435.     {
  1436.         if (!(_LockWidth == 0))
  1437.             width = _LockWidth;
  1438.         if (!(_LockHeight == 0))
  1439.             height = _LockHeight;
  1440.         base.SetBoundsCore(x, y, width, height, specified);
  1441.     }
  1442.  
  1443.     #endregion
  1444.  
  1445.     #region " State Handling "
  1446.  
  1447.     private bool InPosition;
  1448.     protected override void OnMouseEnter(EventArgs e)
  1449.     {
  1450.         InPosition = true;
  1451.         SetState(MouseState.Over);
  1452.         base.OnMouseEnter(e);
  1453.     }
  1454.  
  1455.     protected override void OnMouseUp(MouseEventArgs e)
  1456.     {
  1457.         if (InPosition)
  1458.             SetState(MouseState.Over);
  1459.         base.OnMouseUp(e);
  1460.     }
  1461.  
  1462.     protected override void OnMouseDown(MouseEventArgs e)
  1463.     {
  1464.         if (e.Button == System.Windows.Forms.MouseButtons.Left)
  1465.             SetState(MouseState.Down);
  1466.         base.OnMouseDown(e);
  1467.     }
  1468.  
  1469.     protected override void OnMouseLeave(EventArgs e)
  1470.     {
  1471.         InPosition = false;
  1472.         SetState(MouseState.None);
  1473.         base.OnMouseLeave(e);
  1474.     }
  1475.  
  1476.     protected override void OnEnabledChanged(EventArgs e)
  1477.     {
  1478.         if (Enabled)
  1479.             SetState(MouseState.None);
  1480.         else
  1481.             SetState(MouseState.Block);
  1482.         base.OnEnabledChanged(e);
  1483.     }
  1484.  
  1485.     protected MouseState State;
  1486.     private void SetState(MouseState current)
  1487.     {
  1488.         State = current;
  1489.         Invalidate();
  1490.     }
  1491.  
  1492.     #endregion
  1493.  
  1494.  
  1495.     #region " Base Properties "
  1496.  
  1497.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1498.     public override Color ForeColor
  1499.     {
  1500.         get { return Color.Empty; }
  1501.         set { }
  1502.     }
  1503.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1504.     public override Image BackgroundImage
  1505.     {
  1506.         get { return null; }
  1507.         set { }
  1508.     }
  1509.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1510.     public override ImageLayout BackgroundImageLayout
  1511.     {
  1512.         get { return ImageLayout.None; }
  1513.         set { }
  1514.     }
  1515.  
  1516.     public override string Text
  1517.     {
  1518.         get { return base.Text; }
  1519.         set
  1520.         {
  1521.             base.Text = value;
  1522.             Invalidate();
  1523.         }
  1524.     }
  1525.     public override Font Font
  1526.     {
  1527.         get { return base.Font; }
  1528.         set
  1529.         {
  1530.             base.Font = value;
  1531.             Invalidate();
  1532.         }
  1533.     }
  1534.  
  1535.     private bool _BackColor;
  1536.     [Category("Misc")]
  1537.     public override Color BackColor
  1538.     {
  1539.         get { return base.BackColor; }
  1540.         set
  1541.         {
  1542.             if (!IsHandleCreated && value == Color.Transparent)
  1543.             {
  1544.                 _BackColor = true;
  1545.                 return;
  1546.             }
  1547.  
  1548.             base.BackColor = value;
  1549.             if (Parent != null)
  1550.                 ColorHook();
  1551.         }
  1552.     }
  1553.  
  1554.     #endregion
  1555.  
  1556.     #region " Public Properties "
  1557.  
  1558.     private bool _NoRounding;
  1559.     public bool NoRounding
  1560.     {
  1561.         get { return _NoRounding; }
  1562.         set
  1563.         {
  1564.             _NoRounding = value;
  1565.             Invalidate();
  1566.         }
  1567.     }
  1568.  
  1569.     private Image _Image;
  1570.     public Image Image
  1571.     {
  1572.         get { return _Image; }
  1573.         set
  1574.         {
  1575.             if (value == null)
  1576.             {
  1577.                 _ImageSize = Size.Empty;
  1578.             }
  1579.             else
  1580.             {
  1581.                 _ImageSize = value.Size;
  1582.             }
  1583.  
  1584.             _Image = value;
  1585.             Invalidate();
  1586.         }
  1587.     }
  1588.  
  1589.     private bool _Transparent;
  1590.     public bool Transparent
  1591.     {
  1592.         get { return _Transparent; }
  1593.         set
  1594.         {
  1595.             _Transparent = value;
  1596.             if (!IsHandleCreated)
  1597.                 return;
  1598.  
  1599.             if (!value && !(BackColor.A == 255))
  1600.             {
  1601.                 throw new Exception("Unable to change value to false while a transparent BackColor is in use.");
  1602.             }
  1603.  
  1604.             SetStyle(ControlStyles.Opaque, !value);
  1605.             SetStyle(ControlStyles.SupportsTransparentBackColor, value);
  1606.  
  1607.             if (value)
  1608.                 InvalidateBitmap();
  1609.             else
  1610.                 B = null;
  1611.             Invalidate();
  1612.         }
  1613.     }
  1614.  
  1615.     private Dictionary<string, Color> Items = new Dictionary<string, Color>();
  1616.     public Bloom[] Colors
  1617.     {
  1618.         get
  1619.         {
  1620.             List<Bloom> T = new List<Bloom>();
  1621.             Dictionary<string, Color>.Enumerator E = Items.GetEnumerator();
  1622.  
  1623.             while (E.MoveNext())
  1624.             {
  1625.                 T.Add(new Bloom(E.Current.Key, E.Current.Value));
  1626.             }
  1627.  
  1628.             return T.ToArray();
  1629.         }
  1630.         set
  1631.         {
  1632.             foreach (Bloom B in value)
  1633.             {
  1634.                 if (Items.ContainsKey(B.Name))
  1635.                     Items[B.Name] = B.Value;
  1636.             }
  1637.  
  1638.             InvalidateCustimization();
  1639.             ColorHook();
  1640.             Invalidate();
  1641.         }
  1642.     }
  1643.  
  1644.     private string _Customization;
  1645.     public string Customization
  1646.     {
  1647.         get { return _Customization; }
  1648.         set
  1649.         {
  1650.             if (value == _Customization)
  1651.                 return;
  1652.  
  1653.             byte[] Data = null;
  1654.             Bloom[] Items = Colors;
  1655.  
  1656.             try
  1657.             {
  1658.                 Data = Convert.FromBase64String(value);
  1659.                 for (int I = 0; I <= Items.Length - 1; I++)
  1660.                 {
  1661.                     Items[I].Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4));
  1662.                 }
  1663.             }
  1664.             catch
  1665.             {
  1666.                 return;
  1667.             }
  1668.  
  1669.             _Customization = value;
  1670.  
  1671.             Colors = Items;
  1672.             ColorHook();
  1673.             Invalidate();
  1674.         }
  1675.     }
  1676.  
  1677.     #endregion
  1678.  
  1679.     #region " Private Properties "
  1680.  
  1681.     private Size _ImageSize;
  1682.     protected Size ImageSize
  1683.     {
  1684.         get { return _ImageSize; }
  1685.     }
  1686.  
  1687.     private int _LockWidth;
  1688.     protected int LockWidth
  1689.     {
  1690.         get { return _LockWidth; }
  1691.         set
  1692.         {
  1693.             _LockWidth = value;
  1694.             if (!(LockWidth == 0) && IsHandleCreated)
  1695.                 Width = LockWidth;
  1696.         }
  1697.     }
  1698.  
  1699.     private int _LockHeight;
  1700.     protected int LockHeight
  1701.     {
  1702.         get { return _LockHeight; }
  1703.         set
  1704.         {
  1705.             _LockHeight = value;
  1706.             if (!(LockHeight == 0) && IsHandleCreated)
  1707.                 Height = LockHeight;
  1708.         }
  1709.     }
  1710.  
  1711.     private bool _IsAnimated;
  1712.     protected bool IsAnimated
  1713.     {
  1714.         get { return _IsAnimated; }
  1715.         set
  1716.         {
  1717.             _IsAnimated = value;
  1718.             InvalidateTimer();
  1719.         }
  1720.     }
  1721.  
  1722.     #endregion
  1723.  
  1724.  
  1725.     #region " Property Helpers "
  1726.  
  1727.     protected Pen GetPen(string name)
  1728.     {
  1729.         return new Pen(Items[name]);
  1730.     }
  1731.     protected Pen GetPen(string name, float width)
  1732.     {
  1733.         return new Pen(Items[name], width);
  1734.     }
  1735.  
  1736.     protected SolidBrush GetBrush(string name)
  1737.     {
  1738.         return new SolidBrush(Items[name]);
  1739.     }
  1740.  
  1741.     protected Color GetColor(string name)
  1742.     {
  1743.         return Items[name];
  1744.     }
  1745.  
  1746.     protected void SetColor(string name, Color value)
  1747.     {
  1748.         if (Items.ContainsKey(name))
  1749.             Items[name] = value;
  1750.         else
  1751.             Items.Add(name, value);
  1752.     }
  1753.     protected void SetColor(string name, byte r, byte g, byte b)
  1754.     {
  1755.         SetColor(name, Color.FromArgb(r, g, b));
  1756.     }
  1757.     protected void SetColor(string name, byte a, byte r, byte g, byte b)
  1758.     {
  1759.         SetColor(name, Color.FromArgb(a, r, g, b));
  1760.     }
  1761.     protected void SetColor(string name, byte a, Color value)
  1762.     {
  1763.         SetColor(name, Color.FromArgb(a, value));
  1764.     }
  1765.  
  1766.     private void InvalidateBitmap()
  1767.     {
  1768.         if (Width == 0 || Height == 0)
  1769.             return;
  1770.         B = new Bitmap(Width, Height, PixelFormat.Format32bppPArgb);
  1771.         G = Graphics.FromImage(B);
  1772.     }
  1773.  
  1774.     private void InvalidateCustimization()
  1775.     {
  1776.         MemoryStream M = new MemoryStream(Items.Count * 4);
  1777.  
  1778.         foreach (Bloom B in Colors)
  1779.         {
  1780.             M.Write(BitConverter.GetBytes(B.Value.ToArgb()), 0, 4);
  1781.         }
  1782.  
  1783.         M.Close();
  1784.         _Customization = Convert.ToBase64String(M.ToArray());
  1785.     }
  1786.  
  1787.     private void InvalidateTimer()
  1788.     {
  1789.         if (DesignMode || !DoneCreation)
  1790.             return;
  1791.  
  1792.         if (_IsAnimated)
  1793.         {
  1794.             ThemeShare.AddAnimationCallback(DoAnimation);
  1795.         }
  1796.         else
  1797.         {
  1798.             ThemeShare.RemoveAnimationCallback(DoAnimation);
  1799.         }
  1800.     }
  1801.     #endregion
  1802.  
  1803.  
  1804.     #region " User Hooks "
  1805.  
  1806.     protected abstract void ColorHook();
  1807.     protected abstract void PaintHook();
  1808.  
  1809.     protected virtual void OnCreation()
  1810.     {
  1811.     }
  1812.  
  1813.     protected virtual void OnAnimation()
  1814.     {
  1815.     }
  1816.  
  1817.     #endregion
  1818.  
  1819.  
  1820.     #region " Offset "
  1821.  
  1822.     private Rectangle OffsetReturnRectangle;
  1823.     protected Rectangle Offset(Rectangle r, int amount)
  1824.     {
  1825.         OffsetReturnRectangle = new Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2));
  1826.         return OffsetReturnRectangle;
  1827.     }
  1828.  
  1829.     private Size OffsetReturnSize;
  1830.     protected Size Offset(Size s, int amount)
  1831.     {
  1832.         OffsetReturnSize = new Size(s.Width + amount, s.Height + amount);
  1833.         return OffsetReturnSize;
  1834.     }
  1835.  
  1836.     private Point OffsetReturnPoint;
  1837.     protected Point Offset(Point p, int amount)
  1838.     {
  1839.         OffsetReturnPoint = new Point(p.X + amount, p.Y + amount);
  1840.         return OffsetReturnPoint;
  1841.     }
  1842.  
  1843.     #endregion
  1844.  
  1845.     #region " Center "
  1846.  
  1847.  
  1848.     private Point CenterReturn;
  1849.     protected Point Center(Rectangle p, Rectangle c)
  1850.     {
  1851.         CenterReturn = new Point((p.Width / 2 - c.Width / 2) + p.X + c.X, (p.Height / 2 - c.Height / 2) + p.Y + c.Y);
  1852.         return CenterReturn;
  1853.     }
  1854.     protected Point Center(Rectangle p, Size c)
  1855.     {
  1856.         CenterReturn = new Point((p.Width / 2 - c.Width / 2) + p.X, (p.Height / 2 - c.Height / 2) + p.Y);
  1857.         return CenterReturn;
  1858.     }
  1859.  
  1860.     protected Point Center(Rectangle child)
  1861.     {
  1862.         return Center(Width, Height, child.Width, child.Height);
  1863.     }
  1864.     protected Point Center(Size child)
  1865.     {
  1866.         return Center(Width, Height, child.Width, child.Height);
  1867.     }
  1868.     protected Point Center(int childWidth, int childHeight)
  1869.     {
  1870.         return Center(Width, Height, childWidth, childHeight);
  1871.     }
  1872.  
  1873.     protected Point Center(Size p, Size c)
  1874.     {
  1875.         return Center(p.Width, p.Height, c.Width, c.Height);
  1876.     }
  1877.  
  1878.     protected Point Center(int pWidth, int pHeight, int cWidth, int cHeight)
  1879.     {
  1880.         CenterReturn = new Point(pWidth / 2 - cWidth / 2, pHeight / 2 - cHeight / 2);
  1881.         return CenterReturn;
  1882.     }
  1883.  
  1884.     #endregion
  1885.  
  1886.     #region " Measure "
  1887.  
  1888.     private Bitmap MeasureBitmap;
  1889.     //TODO: Potential issues during multi-threading.
  1890.     private Graphics MeasureGraphics;
  1891.  
  1892.     protected Size Measure()
  1893.     {
  1894.         return MeasureGraphics.MeasureString(Text, Font, Width).ToSize();
  1895.     }
  1896.     protected Size Measure(string text)
  1897.     {
  1898.         return MeasureGraphics.MeasureString(text, Font, Width).ToSize();
  1899.     }
  1900.  
  1901.     #endregion
  1902.  
  1903.  
  1904.     #region " DrawPixel "
  1905.  
  1906.  
  1907.     private SolidBrush DrawPixelBrush;
  1908.     protected void DrawPixel(Color c1, int x, int y)
  1909.     {
  1910.         if (_Transparent)
  1911.         {
  1912.             B.SetPixel(x, y, c1);
  1913.         }
  1914.         else
  1915.         {
  1916.             DrawPixelBrush = new SolidBrush(c1);
  1917.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1);
  1918.         }
  1919.     }
  1920.  
  1921.     #endregion
  1922.  
  1923.     #region " DrawCorners "
  1924.  
  1925.  
  1926.     private SolidBrush DrawCornersBrush;
  1927.     protected void DrawCorners(Color c1, int offset)
  1928.     {
  1929.         DrawCorners(c1, 0, 0, Width, Height, offset);
  1930.     }
  1931.     protected void DrawCorners(Color c1, Rectangle r1, int offset)
  1932.     {
  1933.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset);
  1934.     }
  1935.     protected void DrawCorners(Color c1, int x, int y, int width, int height, int offset)
  1936.     {
  1937.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
  1938.     }
  1939.  
  1940.     protected void DrawCorners(Color c1)
  1941.     {
  1942.         DrawCorners(c1, 0, 0, Width, Height);
  1943.     }
  1944.     protected void DrawCorners(Color c1, Rectangle r1)
  1945.     {
  1946.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height);
  1947.     }
  1948.     protected void DrawCorners(Color c1, int x, int y, int width, int height)
  1949.     {
  1950.         if (_NoRounding)
  1951.             return;
  1952.  
  1953.         if (_Transparent)
  1954.         {
  1955.             B.SetPixel(x, y, c1);
  1956.             B.SetPixel(x + (width - 1), y, c1);
  1957.             B.SetPixel(x, y + (height - 1), c1);
  1958.             B.SetPixel(x + (width - 1), y + (height - 1), c1);
  1959.         }
  1960.         else
  1961.         {
  1962.             DrawCornersBrush = new SolidBrush(c1);
  1963.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1);
  1964.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1);
  1965.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1);
  1966.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1);
  1967.         }
  1968.     }
  1969.  
  1970.     #endregion
  1971.  
  1972.     #region " DrawBorders "
  1973.  
  1974.     protected void DrawBorders(Pen p1, int offset)
  1975.     {
  1976.         DrawBorders(p1, 0, 0, Width, Height, offset);
  1977.     }
  1978.     protected void DrawBorders(Pen p1, Rectangle r, int offset)
  1979.     {
  1980.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset);
  1981.     }
  1982.     protected void DrawBorders(Pen p1, int x, int y, int width, int height, int offset)
  1983.     {
  1984.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
  1985.     }
  1986.  
  1987.     protected void DrawBorders(Pen p1)
  1988.     {
  1989.         DrawBorders(p1, 0, 0, Width, Height);
  1990.     }
  1991.     protected void DrawBorders(Pen p1, Rectangle r)
  1992.     {
  1993.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height);
  1994.     }
  1995.     protected void DrawBorders(Pen p1, int x, int y, int width, int height)
  1996.     {
  1997.         G.DrawRectangle(p1, x, y, width - 1, height - 1);
  1998.     }
  1999.  
  2000.     #endregion
  2001.  
  2002.     #region " DrawText "
  2003.  
  2004.     private Point DrawTextPoint;
  2005.  
  2006.     private Size DrawTextSize;
  2007.     protected void DrawText(Brush b1, HorizontalAlignment a, int x, int y)
  2008.     {
  2009.         DrawText(b1, Text, a, x, y);
  2010.     }
  2011.     protected void DrawText(Brush b1, string text, HorizontalAlignment a, int x, int y)
  2012.     {
  2013.         if (text.Length == 0)
  2014.             return;
  2015.  
  2016.         DrawTextSize = Measure(text);
  2017.         DrawTextPoint = Center(DrawTextSize);
  2018.  
  2019.         switch (a)
  2020.         {
  2021.             case HorizontalAlignment.Left:
  2022.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y);
  2023.                 break;
  2024.             case HorizontalAlignment.Center:
  2025.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y);
  2026.                 break;
  2027.             case HorizontalAlignment.Right:
  2028.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y);
  2029.                 break;
  2030.         }
  2031.     }
  2032.  
  2033.     protected void DrawText(Brush b1, Point p1)
  2034.     {
  2035.         if (Text.Length == 0)
  2036.             return;
  2037.         G.DrawString(Text, Font, b1, p1);
  2038.     }
  2039.     protected void DrawText(Brush b1, int x, int y)
  2040.     {
  2041.         if (Text.Length == 0)
  2042.             return;
  2043.         G.DrawString(Text, Font, b1, x, y);
  2044.     }
  2045.  
  2046.     #endregion
  2047.  
  2048.     #region " DrawImage "
  2049.  
  2050.  
  2051.     private Point DrawImagePoint;
  2052.     protected void DrawImage(HorizontalAlignment a, int x, int y)
  2053.     {
  2054.         DrawImage(_Image, a, x, y);
  2055.     }
  2056.     protected void DrawImage(Image image, HorizontalAlignment a, int x, int y)
  2057.     {
  2058.         if (image == null)
  2059.             return;
  2060.         DrawImagePoint = Center(image.Size);
  2061.  
  2062.         switch (a)
  2063.         {
  2064.             case HorizontalAlignment.Left:
  2065.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height);
  2066.                 break;
  2067.             case HorizontalAlignment.Center:
  2068.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height);
  2069.                 break;
  2070.             case HorizontalAlignment.Right:
  2071.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height);
  2072.                 break;
  2073.         }
  2074.     }
  2075.  
  2076.     protected void DrawImage(Point p1)
  2077.     {
  2078.         DrawImage(_Image, p1.X, p1.Y);
  2079.     }
  2080.     protected void DrawImage(int x, int y)
  2081.     {
  2082.         DrawImage(_Image, x, y);
  2083.     }
  2084.  
  2085.     protected void DrawImage(Image image, Point p1)
  2086.     {
  2087.         DrawImage(image, p1.X, p1.Y);
  2088.     }
  2089.     protected void DrawImage(Image image, int x, int y)
  2090.     {
  2091.         if (image == null)
  2092.             return;
  2093.         G.DrawImage(image, x, y, image.Width, image.Height);
  2094.     }
  2095.  
  2096.     #endregion
  2097.  
  2098.     #region " DrawGradient "
  2099.  
  2100.     private LinearGradientBrush DrawGradientBrush;
  2101.  
  2102.     private Rectangle DrawGradientRectangle;
  2103.     protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height)
  2104.     {
  2105.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  2106.         DrawGradient(blend, DrawGradientRectangle);
  2107.     }
  2108.     protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height, float angle)
  2109.     {
  2110.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  2111.         DrawGradient(blend, DrawGradientRectangle, angle);
  2112.     }
  2113.  
  2114.     protected void DrawGradient(ColorBlend blend, Rectangle r)
  2115.     {
  2116.         DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, 90f);
  2117.         DrawGradientBrush.InterpolationColors = blend;
  2118.         G.FillRectangle(DrawGradientBrush, r);
  2119.     }
  2120.     protected void DrawGradient(ColorBlend blend, Rectangle r, float angle)
  2121.     {
  2122.         DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, angle);
  2123.         DrawGradientBrush.InterpolationColors = blend;
  2124.         G.FillRectangle(DrawGradientBrush, r);
  2125.     }
  2126.  
  2127.  
  2128.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height)
  2129.     {
  2130.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  2131.         DrawGradient(c1, c2, DrawGradientRectangle);
  2132.     }
  2133.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
  2134.     {
  2135.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  2136.         DrawGradient(c1, c2, DrawGradientRectangle, angle);
  2137.     }
  2138.  
  2139.     protected void DrawGradient(Color c1, Color c2, Rectangle r)
  2140.     {
  2141.         DrawGradientBrush = new LinearGradientBrush(r, c1, c2, 90f);
  2142.         G.FillRectangle(DrawGradientBrush, r);
  2143.     }
  2144.     protected void DrawGradient(Color c1, Color c2, Rectangle r, float angle)
  2145.     {
  2146.         DrawGradientBrush = new LinearGradientBrush(r, c1, c2, angle);
  2147.         G.FillRectangle(DrawGradientBrush, r);
  2148.     }
  2149.  
  2150.     #endregion
  2151.  
  2152.     #region " DrawRadial "
  2153.  
  2154.     private GraphicsPath DrawRadialPath;
  2155.     private PathGradientBrush DrawRadialBrush1;
  2156.     private LinearGradientBrush DrawRadialBrush2;
  2157.  
  2158.     private Rectangle DrawRadialRectangle;
  2159.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height)
  2160.     {
  2161.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  2162.         DrawRadial(blend, DrawRadialRectangle, width / 2, height / 2);
  2163.     }
  2164.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, Point center)
  2165.     {
  2166.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  2167.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y);
  2168.     }
  2169.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, int cx, int cy)
  2170.     {
  2171.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  2172.         DrawRadial(blend, DrawRadialRectangle, cx, cy);
  2173.     }
  2174.  
  2175.     public void DrawRadial(ColorBlend blend, Rectangle r)
  2176.     {
  2177.         DrawRadial(blend, r, r.Width / 2, r.Height / 2);
  2178.     }
  2179.     public void DrawRadial(ColorBlend blend, Rectangle r, Point center)
  2180.     {
  2181.         DrawRadial(blend, r, center.X, center.Y);
  2182.     }
  2183.     public void DrawRadial(ColorBlend blend, Rectangle r, int cx, int cy)
  2184.     {
  2185.         DrawRadialPath.Reset();
  2186.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1);
  2187.  
  2188.         DrawRadialBrush1 = new PathGradientBrush(DrawRadialPath);
  2189.         DrawRadialBrush1.CenterPoint = new Point(r.X + cx, r.Y + cy);
  2190.         DrawRadialBrush1.InterpolationColors = blend;
  2191.  
  2192.         if (G.SmoothingMode == SmoothingMode.AntiAlias)
  2193.         {
  2194.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3);
  2195.         }
  2196.         else
  2197.         {
  2198.             G.FillEllipse(DrawRadialBrush1, r);
  2199.         }
  2200.     }
  2201.  
  2202.  
  2203.     protected void DrawRadial(Color c1, Color c2, int x, int y, int width, int height)
  2204.     {
  2205.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  2206.         DrawRadial(c1, c2, DrawRadialRectangle);
  2207.     }
  2208.     protected void DrawRadial(Color c1, Color c2, int x, int y, int width, int height, float angle)
  2209.     {
  2210.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  2211.         DrawRadial(c1, c2, DrawRadialRectangle, angle);
  2212.     }
  2213.  
  2214.     protected void DrawRadial(Color c1, Color c2, Rectangle r)
  2215.     {
  2216.         DrawRadialBrush2 = new LinearGradientBrush(r, c1, c2, 90f);
  2217.         G.FillEllipse(DrawRadialBrush2, r);
  2218.     }
  2219.     protected void DrawRadial(Color c1, Color c2, Rectangle r, float angle)
  2220.     {
  2221.         DrawRadialBrush2 = new LinearGradientBrush(r, c1, c2, angle);
  2222.         G.FillEllipse(DrawRadialBrush2, r);
  2223.     }
  2224.  
  2225.     #endregion
  2226.  
  2227.     #region " CreateRound "
  2228.  
  2229.     private GraphicsPath CreateRoundPath;
  2230.  
  2231.     private Rectangle CreateRoundRectangle;
  2232.     public GraphicsPath CreateRound(int x, int y, int width, int height, int slope)
  2233.     {
  2234.         CreateRoundRectangle = new Rectangle(x, y, width, height);
  2235.         return CreateRound(CreateRoundRectangle, slope);
  2236.     }
  2237.  
  2238.     public GraphicsPath CreateRound(Rectangle r, int slope)
  2239.     {
  2240.         CreateRoundPath = new GraphicsPath(FillMode.Winding);
  2241.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180f, 90f);
  2242.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270f, 90f);
  2243.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0f, 90f);
  2244.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90f, 90f);
  2245.         CreateRoundPath.CloseFigure();
  2246.         return CreateRoundPath;
  2247.     }
  2248.  
  2249.     #endregion
  2250.  
  2251. }
  2252.  
  2253. static class ThemeShare
  2254. {
  2255.  
  2256.     #region " Animation "
  2257.  
  2258.     private static int Frames;
  2259.     private static bool Invalidate;
  2260.  
  2261.     public static PrecisionTimer ThemeTimer = new PrecisionTimer();
  2262.     //1000 / 50 = 20 FPS
  2263.     private const int FPS = 50;
  2264.  
  2265.     private const int Rate = 50;
  2266.     public delegate void AnimationDelegate(bool invalidate);
  2267.  
  2268.  
  2269.     private static List<AnimationDelegate> Callbacks = new List<AnimationDelegate>();
  2270.     private static void HandleCallbacks(IntPtr state, bool reserve)
  2271.     {
  2272.         Invalidate = (Frames >= FPS);
  2273.         if (Invalidate)
  2274.             Frames = 0;
  2275.  
  2276.         lock (Callbacks)
  2277.         {
  2278.             for (int I = 0; I <= Callbacks.Count - 1; I++)
  2279.             {
  2280.                 Callbacks[I].Invoke(Invalidate);
  2281.             }
  2282.         }
  2283.  
  2284.         Frames += Rate;
  2285.     }
  2286.  
  2287.     private static void InvalidateThemeTimer()
  2288.     {
  2289.         if (Callbacks.Count == 0)
  2290.         {
  2291.             ThemeTimer.Delete();
  2292.         }
  2293.         else
  2294.         {
  2295.             ThemeTimer.Create(0, Rate, HandleCallbacks);
  2296.         }
  2297.     }
  2298.  
  2299.     public static void AddAnimationCallback(AnimationDelegate callback)
  2300.     {
  2301.         lock (Callbacks)
  2302.         {
  2303.             if (Callbacks.Contains(callback))
  2304.                 return;
  2305.  
  2306.             Callbacks.Add(callback);
  2307.             InvalidateThemeTimer();
  2308.         }
  2309.     }
  2310.  
  2311.     public static void RemoveAnimationCallback(AnimationDelegate callback)
  2312.     {
  2313.         lock (Callbacks)
  2314.         {
  2315.             if (!Callbacks.Contains(callback))
  2316.                 return;
  2317.  
  2318.             Callbacks.Remove(callback);
  2319.             InvalidateThemeTimer();
  2320.         }
  2321.     }
  2322.  
  2323.     #endregion
  2324.  
  2325. }
  2326.  
  2327. enum MouseState : byte
  2328. {
  2329.     None = 0,
  2330.     Over = 1,
  2331.     Down = 2,
  2332.     Block = 3
  2333. }
  2334.  
  2335. struct Bloom
  2336. {
  2337.  
  2338.     public string _Name;
  2339.     public string Name
  2340.     {
  2341.         get { return _Name; }
  2342.     }
  2343.  
  2344.     private Color _Value;
  2345.     public Color Value
  2346.     {
  2347.         get { return _Value; }
  2348.         set { _Value = value; }
  2349.     }
  2350.  
  2351.     public string ValueHex
  2352.     {
  2353.         get { return string.Concat("#", _Value.R.ToString("X2", null), _Value.G.ToString("X2", null), _Value.B.ToString("X2", null)); }
  2354.         set
  2355.         {
  2356.             try
  2357.             {
  2358.                 _Value = ColorTranslator.FromHtml(value);
  2359.             }
  2360.             catch
  2361.             {
  2362.                 return;
  2363.             }
  2364.         }
  2365.     }
  2366.  
  2367.  
  2368.     public Bloom(string name, Color value)
  2369.     {
  2370.         _Name = name;
  2371.         _Value = value;
  2372.     }
  2373. }
  2374.  
  2375. //------------------
  2376. //Creator: aeonhack
  2377. //Site: elitevs.net
  2378. //Created: 11/30/2011
  2379. //Changed: 11/30/2011
  2380. //Version: 1.0.0
  2381. //------------------
  2382. class PrecisionTimer : IDisposable
  2383. {
  2384.  
  2385.     private bool _Enabled;
  2386.     public bool Enabled
  2387.     {
  2388.         get { return _Enabled; }
  2389.     }
  2390.  
  2391.     private IntPtr Handle;
  2392.  
  2393.     private TimerDelegate TimerCallback;
  2394.     [DllImport("kernel32.dll", EntryPoint = "CreateTimerQueueTimer")]
  2395.     private static extern bool CreateTimerQueueTimer(ref IntPtr handle, IntPtr queue, TimerDelegate callback, IntPtr state, uint dueTime, uint period, uint flags);
  2396.  
  2397.     [DllImport("kernel32.dll", EntryPoint = "DeleteTimerQueueTimer")]
  2398.     private static extern bool DeleteTimerQueueTimer(IntPtr queue, IntPtr handle, IntPtr callback);
  2399.  
  2400.     public delegate void TimerDelegate(IntPtr r1, bool r2);
  2401.  
  2402.     public void Create(uint dueTime, uint period, TimerDelegate callback)
  2403.     {
  2404.         if (_Enabled)
  2405.             return;
  2406.  
  2407.         TimerCallback = callback;
  2408.         bool Success = CreateTimerQueueTimer(ref Handle, IntPtr.Zero, TimerCallback, IntPtr.Zero, dueTime, period, 0);
  2409.  
  2410.         if (!Success)
  2411.             ThrowNewException("CreateTimerQueueTimer");
  2412.         _Enabled = Success;
  2413.     }
  2414.  
  2415.     public void Delete()
  2416.     {
  2417.         if (!_Enabled)
  2418.             return;
  2419.         bool Success = DeleteTimerQueueTimer(IntPtr.Zero, Handle, IntPtr.Zero);
  2420.  
  2421.         if (!Success && !(Marshal.GetLastWin32Error() == 997))
  2422.         {
  2423.             ThrowNewException("DeleteTimerQueueTimer");
  2424.         }
  2425.  
  2426.         _Enabled = !Success;
  2427.     }
  2428.  
  2429.     private void ThrowNewException(string name)
  2430.     {
  2431.         throw new Exception(string.Format("{0} failed. Win32Error: {1}", name, Marshal.GetLastWin32Error()));
  2432.     }
  2433.  
  2434.     public void Dispose()
  2435.     {
  2436.         Delete();
  2437.     }
  2438. }
  2439.  
  2440. #endregion
  2441.  
  2442. //#############################################
  2443. //#               ! CREDITS !                 #
  2444. //#############################################
  2445. //# Themebase 1.5.4: Aeonhack                 #
  2446. //# Theme: Mavamaarten                        #
  2447. //#############################################
  2448. //# Thanks to Tyrant (Reptile) for helping me #
  2449. //# with the progressbar animation !          #
  2450. //#############################################
  2451. //# Converted to C# by: Ethernal Five         #
  2452. //# On 04/04/2012                             #
  2453. //#############################################
  2454.  
  2455. class CrystalClearThemeContainer : ThemeContainer154
  2456. {
  2457.     Color G1;
  2458.     Color G2;
  2459.     Color Glow;
  2460.     Color BG;
  2461.     Color Edge;
  2462.  
  2463.     private RoundingType _Rounding;
  2464.     public enum RoundingType : int
  2465.     {
  2466.         TypeOne = 1,
  2467.         TypeTwo = 2,
  2468.         None = 0
  2469.     }
  2470.  
  2471.     protected override void ColorHook()
  2472.     {
  2473.         G1 = GetColor("Gradient 1");
  2474.         G2 = GetColor("Gradient 2");
  2475.         Glow = GetColor("Glow");
  2476.         BG = GetColor("Background");
  2477.         Edge = GetColor("Edges");
  2478.     }
  2479.  
  2480.     public RoundingType Rounding
  2481.     {
  2482.         get { return _Rounding; }
  2483.         set { _Rounding = value; }
  2484.     }
  2485.  
  2486.  
  2487.     public CrystalClearThemeContainer()
  2488.     {
  2489.         SetColor("Gradient 1", Color.FromArgb(230, 230, 230));
  2490.         SetColor("Gradient 2", Color.FromArgb(210, 210, 210));
  2491.         SetColor("Glow", Color.FromArgb(230, 230, 230));
  2492.         SetColor("Background", Color.FromArgb(230, 230, 230));
  2493.         SetColor("Edges", Color.FromArgb(170, 170, 170));
  2494.         TransparencyKey = Color.Fuchsia;
  2495.         MinimumSize = new Size(175, 150);
  2496.         BackColor = Color.FromArgb(230, 230, 230);
  2497.     }
  2498.  
  2499.  
  2500.     protected override void PaintHook()
  2501.     {
  2502.         G.Clear(BG);
  2503.  
  2504.         //Draw titlebar gradient
  2505.         LinearGradientBrush LB = new LinearGradientBrush(new Rectangle(new Point(1, 1), new Size(Width - 2, 25)), G1, G2, 90f);
  2506.         G.FillRectangle(LB, new Rectangle(new Point(1, 1), new Size(Width - 2, 25)));
  2507.  
  2508.         //Draw glow
  2509.         G.FillRectangle(new SolidBrush(BG), new Rectangle(new Point(1, 1), new Size(Width - 2, 11)));
  2510.  
  2511.         //Draw outline + rounded corners
  2512.         G.DrawRectangle(new Pen(Edge), new Rectangle(0, 0, Width - 1, Height - 1));
  2513.         G.DrawLine(new Pen(Edge), new Point(0, 26), new Point(Width, 26));
  2514.  
  2515.         switch (_Rounding)
  2516.         {
  2517.             case RoundingType.TypeOne:
  2518.                 //////left upper corner
  2519.                 DrawPixel(Color.Fuchsia, 0, 0);
  2520.                 DrawPixel(Color.Fuchsia, 1, 0);
  2521.                 DrawPixel(Color.Fuchsia, 0, 1);
  2522.                 DrawPixel(Edge, 1, 1);
  2523.                 //////right upper corner
  2524.                 DrawPixel(Color.Fuchsia, Width - 1, 0);
  2525.                 DrawPixel(Color.Fuchsia, Width - 2, 0);
  2526.                 DrawPixel(Color.Fuchsia, Width - 1, 1);
  2527.                 DrawPixel(Edge, Width - 2, 1);
  2528.                 //////left bottom corner
  2529.                 DrawPixel(Color.Fuchsia, 0, Height - 1);
  2530.                 DrawPixel(Color.Fuchsia, 1, Height - 1);
  2531.                 DrawPixel(Color.Fuchsia, 0, Height - 2);
  2532.                 DrawPixel(Edge, 1, Height - 2);
  2533.                 //////right bottom corner
  2534.                 DrawPixel(Color.Fuchsia, Width - 1, Height - 1);
  2535.                 DrawPixel(Color.Fuchsia, Width - 2, Height - 1);
  2536.                 DrawPixel(Color.Fuchsia, Width - 1, Height - 2);
  2537.                 DrawPixel(Edge, Width - 2, Height - 2);
  2538.                 break;
  2539.             case RoundingType.TypeTwo:
  2540.                 //////left upper corner
  2541.                 DrawPixel(Color.Fuchsia, 0, 0);
  2542.                 DrawPixel(Color.Fuchsia, 1, 0);
  2543.                 DrawPixel(Color.Fuchsia, 2, 0);
  2544.                 DrawPixel(Color.Fuchsia, 3, 0);
  2545.                 DrawPixel(Color.Fuchsia, 0, 1);
  2546.                 DrawPixel(Color.Fuchsia, 0, 2);
  2547.                 DrawPixel(Color.Fuchsia, 0, 3);
  2548.                 DrawPixel(Color.Fuchsia, 1, 1);
  2549.                 DrawPixel(Edge, 2, 1);
  2550.                 DrawPixel(Edge, 3, 1);
  2551.                 DrawPixel(Edge, 1, 2);
  2552.                 DrawPixel(Edge, 1, 3);
  2553.                 //////right upper corner
  2554.                 DrawPixel(Color.Fuchsia, Width - 1, 0);
  2555.                 DrawPixel(Color.Fuchsia, Width - 2, 0);
  2556.                 DrawPixel(Color.Fuchsia, Width - 3, 0);
  2557.                 DrawPixel(Color.Fuchsia, Width - 4, 0);
  2558.                 DrawPixel(Color.Fuchsia, Width - 1, 1);
  2559.                 DrawPixel(Color.Fuchsia, Width - 1, 2);
  2560.                 DrawPixel(Color.Fuchsia, Width - 1, 3);
  2561.                 DrawPixel(Color.Fuchsia, Width - 2, 1);
  2562.                 DrawPixel(Edge, Width - 3, 1);
  2563.                 DrawPixel(Edge, Width - 4, 1);
  2564.                 DrawPixel(Edge, Width - 2, 2);
  2565.                 DrawPixel(Edge, Width - 2, 3);
  2566.                 //////left bottom corner
  2567.                 DrawPixel(Color.Fuchsia, 0, Height - 1);
  2568.                 DrawPixel(Color.Fuchsia, 0, Height - 2);
  2569.                 DrawPixel(Color.Fuchsia, 0, Height - 3);
  2570.                 DrawPixel(Color.Fuchsia, 0, Height - 4);
  2571.                 DrawPixel(Color.Fuchsia, 1, Height - 1);
  2572.                 DrawPixel(Color.Fuchsia, 2, Height - 1);
  2573.                 DrawPixel(Color.Fuchsia, 3, Height - 1);
  2574.                 DrawPixel(Color.Fuchsia, 1, Height - 2);
  2575.                 DrawPixel(Edge, 2, Height - 2);
  2576.                 DrawPixel(Edge, 3, Height - 2);
  2577.                 DrawPixel(Edge, 1, Height - 3);
  2578.                 DrawPixel(Edge, 1, Height - 4);
  2579.                 //////right bottom corner
  2580.                 DrawPixel(Color.Fuchsia, Width - 1, Height - 1);
  2581.                 DrawPixel(Color.Fuchsia, Width - 1, Height - 2);
  2582.                 DrawPixel(Color.Fuchsia, Width - 1, Height - 3);
  2583.                 DrawPixel(Color.Fuchsia, Width - 1, Height - 4);
  2584.                 DrawPixel(Color.Fuchsia, Width - 2, Height - 1);
  2585.                 DrawPixel(Color.Fuchsia, Width - 3, Height - 1);
  2586.                 DrawPixel(Color.Fuchsia, Width - 4, Height - 1);
  2587.                 DrawPixel(Color.Fuchsia, Width - 2, Height - 2);
  2588.                 DrawPixel(Edge, Width - 3, Height - 2);
  2589.                 DrawPixel(Edge, Width - 4, Height - 2);
  2590.                 DrawPixel(Edge, Width - 2, Height - 3);
  2591.                 DrawPixel(Edge, Width - 2, Height - 4);
  2592.                 break;
  2593.         }
  2594.  
  2595.  
  2596.  
  2597.         //Draw title & icon
  2598.         G.DrawString(FindForm().Text, new Font("Segoe UI", 9), Brushes.Black, new Point(27, 5));
  2599.         G.DrawIcon(FindForm().Icon, new Rectangle(7, 6, 16, 16));
  2600.     }
  2601. }
  2602. class CrystalClearControlBox : ThemeControl154
  2603. {
  2604.     private int X;
  2605.     Color BG;
  2606.     Pen Edge;
  2607.     Color Icons;
  2608.  
  2609.     SolidBrush glow;
  2610.     int a;
  2611.     int b;
  2612.  
  2613.     int c;
  2614.     protected override void ColorHook()
  2615.     {
  2616.         Icons = GetColor("Icons");
  2617.         BG = GetColor("Background");
  2618.         Edge = GetPen("Button edge color");
  2619.         glow = GetBrush("Glow");
  2620.     }
  2621.  
  2622.     public CrystalClearControlBox()
  2623.     {
  2624.         IsAnimated = true;
  2625.         SetColor("Icons", Color.FromArgb(100, 100, 100));
  2626.         SetColor("Background", Color.FromArgb(231, 231, 231));
  2627.         SetColor("Button edge color", Color.FromArgb(165, 165, 165));
  2628.         SetColor("Glow", Color.FromArgb(240, 240, 240));
  2629.         this.Size = new Size(84, 18);
  2630.         this.Anchor = AnchorStyles.Top | AnchorStyles.Right;
  2631.     }
  2632.  
  2633.     protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
  2634.     {
  2635.         base.OnMouseMove(e);
  2636.         X = e.X;
  2637.         Invalidate();
  2638.     }
  2639.  
  2640.     protected override void OnClick(System.EventArgs e)
  2641.     {
  2642.         base.OnClick(e);
  2643.         if (X <= 22)
  2644.         {
  2645.             FindForm().WindowState = FormWindowState.Minimized;
  2646.         }
  2647.         else if (X > 22 & X <= 46)
  2648.         {
  2649.             if (FindForm().WindowState == FormWindowState.Maximized)
  2650.                 FindForm().WindowState = FormWindowState.Normal;
  2651.             else
  2652.                 FindForm().WindowState = FormWindowState.Maximized;
  2653.         }
  2654.         else
  2655.         {
  2656.             FindForm().Close();
  2657.         }
  2658.     }
  2659.  
  2660.     protected override void OnAnimation()
  2661.     {
  2662.         base.OnAnimation();
  2663.         switch (State)
  2664.         {
  2665.             case MouseState.Over:
  2666.                 if (a < 24 & X <= 22)
  2667.                 {
  2668.                     a += 4;
  2669.                     if (b > 0)
  2670.                     {
  2671.                         b -= 4;
  2672.                     }
  2673.                     if (c > 0)
  2674.                     {
  2675.                         c -= 4;
  2676.                     }
  2677.                     if (b < 0)
  2678.                         b = 0;
  2679.                     if (c < 0)
  2680.                         c = 0;
  2681.                     Invalidate();
  2682.                     Application.DoEvents();
  2683.                 }
  2684.  
  2685.                 if (b < 24 & X > 22 & X <= 46)
  2686.                 {
  2687.                     b += 4;
  2688.                     if (a > 0)
  2689.                     {
  2690.                         a -= 4;
  2691.                     }
  2692.                     if (a < 0)
  2693.                         a = 0;
  2694.                     if (c > 0)
  2695.                     {
  2696.                         c -= 4;
  2697.                     }
  2698.                     if (c < 0)
  2699.                         c = 0;
  2700.                     Invalidate();
  2701.                     Application.DoEvents();
  2702.                 }
  2703.  
  2704.                 if (c < 32 & X > 46)
  2705.                 {
  2706.                     c += 4;
  2707.                     if (a > 0)
  2708.                     {
  2709.                         a -= 4;
  2710.                     }
  2711.                     if (b > 0)
  2712.                     {
  2713.                         b -= 4;
  2714.                     }
  2715.                     if (a < 0)
  2716.                         a = 0;
  2717.                     if (b < 0)
  2718.                         b = 0;
  2719.                     Invalidate();
  2720.                     Application.DoEvents();
  2721.                 }
  2722.  
  2723.                 break;
  2724.             case MouseState.None:
  2725.                 if (a > 0)
  2726.                 {
  2727.                     a -= 4;
  2728.                 }
  2729.                 if (b > 0)
  2730.                 {
  2731.                     b -= 4;
  2732.                 }
  2733.                 if (c > 0)
  2734.                 {
  2735.                     c -= 4;
  2736.                 }
  2737.                 if (a < 0)
  2738.                     a = 0;
  2739.                 if (b < 0)
  2740.                     b = 0;
  2741.                 if (c < 0)
  2742.                     c = 0;
  2743.                 Invalidate();
  2744.                 Application.DoEvents();
  2745.                 break;
  2746.         }
  2747.     }
  2748.  
  2749.     protected override void PaintHook()
  2750.     {
  2751.         //Draw outer edge
  2752.         G.Clear(BG);
  2753.  
  2754.         //Fill buttons
  2755.         G.FillRectangle(glow, new Rectangle(0, 0, 21, 8));
  2756.         //min button
  2757.         G.FillRectangle(glow, new Rectangle(23, 0, 22, 8));
  2758.         //max button
  2759.         G.FillRectangle(glow, new Rectangle(47, 0, 36, 8));
  2760.         //X button
  2761.  
  2762.         //Draw button outlines
  2763.         G.DrawRectangle(Edge, new Rectangle(0, 0, 21, 17));
  2764.         //min button
  2765.         G.DrawRectangle(Edge, new Rectangle(23, 0, 22, 17));
  2766.         //max button
  2767.         G.DrawRectangle(Edge, new Rectangle(47, 0, 36, 17));
  2768.         //X button
  2769.  
  2770.         //Mouse states
  2771.         SolidBrush SB1 = new SolidBrush(Color.FromArgb(a, Color.Cyan));
  2772.         SolidBrush SB1_ = new SolidBrush(Color.FromArgb(b, Color.Cyan));
  2773.         SolidBrush SB2 = new SolidBrush(Color.FromArgb(c, Color.OrangeRed));
  2774.         SolidBrush SB3 = new SolidBrush(Color.FromArgb(20, Color.Black));
  2775.         switch (State)
  2776.         {
  2777.             case MouseState.Down:
  2778.                 if (X <= 22)
  2779.                 {
  2780.                     a = 0;
  2781.                     G.FillRectangle(SB3, new Rectangle(0, 0, 21, 17));
  2782.                 }
  2783.                 else if (X > 22 & X <= 46)
  2784.                 {
  2785.                     b = 0;
  2786.                     G.FillRectangle(SB3, new Rectangle(23, 0, 22, 17));
  2787.                 }
  2788.                 else
  2789.                 {
  2790.                     c = 0;
  2791.                     G.FillRectangle(SB3, new Rectangle(47, 0, 36, 17));
  2792.                 }
  2793.                 break;
  2794.             default:
  2795.                 if (X <= 22)
  2796.                 {
  2797.                     G.FillRectangle(SB1, new Rectangle(0, 0, 21, 17));
  2798.                 }
  2799.                 else if (X > 22 & X <= 46)
  2800.                 {
  2801.                     G.FillRectangle(SB1_, new Rectangle(23, 0, 22, 17));
  2802.                 }
  2803.                 else
  2804.                 {
  2805.                     G.FillRectangle(SB2, new Rectangle(47, 0, 36, 17));
  2806.                 }
  2807.                 break;
  2808.         }
  2809.  
  2810.         //Draw icons
  2811.         G.DrawString("0", new Font("Marlett", 8.25F), GetBrush("Icons"), new Point(5, 4));
  2812.         if (FindForm().WindowState != FormWindowState.Maximized)
  2813.             G.DrawString("1", new Font("Marlett", 8), GetBrush("Icons"), new Point(28, 4));
  2814.         else
  2815.             G.DrawString("2", new Font("Marlett", 8.25F), GetBrush("Icons"), new Point(28, 4));
  2816.         G.DrawString("r", new Font("Marlett", 10), GetBrush("Icons"), new Point(56, 3));
  2817.  
  2818.         //Round min button corners
  2819.         DrawPixel(BG, 0, 0);
  2820.         DrawPixel(Edge.Color, 1, 1);
  2821.         DrawPixel(Color.FromArgb(210, 210, 210), 0, 17);
  2822.         DrawPixel(Edge.Color, 1, 16);
  2823.  
  2824.         //Round X button corners
  2825.         DrawPixel(BG, Width - 1, 0);
  2826.         DrawPixel(Edge.Color, Width - 2, 1);
  2827.         DrawPixel(Color.FromArgb(210, 210, 210), Width - 1, 17);
  2828.         DrawPixel(Edge.Color, Width - 2, 16);
  2829.     }
  2830. }
  2831. class CrystalClearButton : ThemeControl154
  2832. {
  2833.     Color G1;
  2834.     Color G2;
  2835.     Color Glow;
  2836.     Color Edge;
  2837.     Color TextColor;
  2838.     Color Hovercolor;
  2839.  
  2840.     int a = 0;
  2841.     protected override void ColorHook()
  2842.     {
  2843.         G1 = GetColor("Gradient 1");
  2844.         G2 = GetColor("Gradient 2");
  2845.         Glow = GetColor("Glow");
  2846.         Edge = GetColor("Edge");
  2847.         TextColor = GetColor("Text");
  2848.         Hovercolor = GetColor("HoverColor");
  2849.     }
  2850.  
  2851.     protected override void OnAnimation()
  2852.     {
  2853.         base.OnAnimation();
  2854.         switch (State)
  2855.         {
  2856.             case MouseState.Over:
  2857.                 if (a < 40)
  2858.                 {
  2859.                     a += 8;
  2860.                     Invalidate();
  2861.                     Application.DoEvents();
  2862.                 }
  2863.                 break;
  2864.             case MouseState.None:
  2865.                 if (a > 0)
  2866.                 {
  2867.                     a -= 10;
  2868.                     if (a < 0)
  2869.                         a = 0;
  2870.                     Invalidate();
  2871.                     Application.DoEvents();
  2872.                 }
  2873.                 break;
  2874.         }
  2875.     }
  2876.  
  2877.     protected override void PaintHook()
  2878.     {
  2879.         G.Clear(G1);
  2880.         LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(1, 1), new Size(Width - 2, Height - 2)), G1, G2, 90f);
  2881.         HatchBrush HB = new HatchBrush(HatchStyle.LightDownwardDiagonal, Color.FromArgb(7, Color.Black), Color.Transparent);
  2882.         G.FillRectangle(LGB, new Rectangle(new Point(1, 1), new Size(Width - 2, Height - 2)));
  2883.         G.FillRectangle(new SolidBrush(Glow), new Rectangle(new Point(1, 1), new Size(Width - 2, (Height / 2) - 3)));
  2884.         G.FillRectangle(HB, new Rectangle(new Point(1, 1), new Size(Width - 2, Height - 2)));
  2885.  
  2886.         if (State == MouseState.Over | State == MouseState.None)
  2887.         {
  2888.             SolidBrush SB = new SolidBrush(Color.FromArgb(a * 2, Color.White));
  2889.             G.FillRectangle(SB, new Rectangle(new Point(1, 1), new Size(Width - 2, Height - 2)));
  2890.         }
  2891.         else if (State == MouseState.Down)
  2892.         {
  2893.             SolidBrush SB = new SolidBrush(Color.FromArgb(2, Color.Black));
  2894.             G.FillRectangle(SB, new Rectangle(new Point(1, 1), new Size(Width - 2, Height - 2)));
  2895.         }
  2896.  
  2897.         G.DrawRectangle(new Pen(Edge), new Rectangle(new Point(1, 1), new Size(Width - 2, Height - 2)));
  2898.         StringFormat sf = new StringFormat();
  2899.         sf.LineAlignment = StringAlignment.Center;
  2900.         sf.Alignment = StringAlignment.Center;
  2901.         G.DrawString(Text, Font, GetBrush("Text"), new RectangleF(2, 2, this.Width - 5, this.Height - 4), sf);
  2902.     }
  2903.  
  2904.     public CrystalClearButton()
  2905.     {
  2906.         IsAnimated = true;
  2907.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
  2908.         SetColor("Gradient 1", 230, 230, 230);
  2909.         SetColor("Gradient 2", 210, 210, 210);
  2910.         SetColor("Glow", 230, 230, 230);
  2911.         SetColor("Edge", 170, 170, 170);
  2912.         SetColor("Text", Color.Black);
  2913.         SetColor("HoverColor", Color.White);
  2914.         Size = new Size(145, 25);
  2915.     }
  2916. }
  2917. [DefaultEvent("CheckedChanged")]
  2918. class CrystalClearCheckBox : ThemeControl154
  2919. {
  2920.  
  2921.     public CrystalClearCheckBox()
  2922.     {
  2923.         LockHeight = 17;
  2924.         SetColor("Text", Color.Black);
  2925.         SetColor("Gradient 1", 230, 230, 230);
  2926.         SetColor("Gradient 2", 210, 210, 210);
  2927.         SetColor("Glow", 230, 230, 230);
  2928.         SetColor("Edges", 170, 170, 170);
  2929.         SetColor("Backcolor", BackColor);
  2930.         Width = 160;
  2931.     }
  2932.  
  2933.     private int X;
  2934.     private Color TextColor;
  2935.     private Color G1;
  2936.     private Color G2;
  2937.     private Color Glow;
  2938.     private Color Edge;
  2939.  
  2940.     private Color BG;
  2941.     protected override void ColorHook()
  2942.     {
  2943.         TextColor = GetColor("Text");
  2944.         G1 = GetColor("Gradient 1");
  2945.         G2 = GetColor("Gradient 2");
  2946.         Glow = GetColor("Glow");
  2947.         Edge = GetColor("Edges");
  2948.         BG = GetColor("Backcolor");
  2949.     }
  2950.  
  2951.     protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
  2952.     {
  2953.         base.OnMouseMove(e);
  2954.         X = e.Location.X;
  2955.         Invalidate();
  2956.     }
  2957.  
  2958.     protected override void PaintHook()
  2959.     {
  2960.         G.Clear(BG);
  2961.         if (_Checked)
  2962.         {
  2963.             LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(0, 0), new Size(14, 14)), G1, G2, 90f);
  2964.             G.FillRectangle(LGB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  2965.             G.FillRectangle(new SolidBrush(Glow), new Rectangle(new Point(0, 0), new Size(14, 7)));
  2966.         }
  2967.         else
  2968.         {
  2969.             LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(0, 0), new Size(14, 16)), G1, G2, 90f);
  2970.             G.FillRectangle(LGB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  2971.             G.FillRectangle(new SolidBrush(Glow), new Rectangle(new Point(0, 0), new Size(14, 7)));
  2972.         }
  2973.  
  2974.         if (State == MouseState.Over & X < 15)
  2975.         {
  2976.             SolidBrush SB = new SolidBrush(Color.FromArgb(70, Color.White));
  2977.             G.FillRectangle(SB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  2978.         }
  2979.         else if (State == MouseState.Down & X < 15)
  2980.         {
  2981.             SolidBrush SB = new SolidBrush(Color.FromArgb(10, Color.Black));
  2982.             G.FillRectangle(SB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  2983.         }
  2984.  
  2985.         HatchBrush HB = new HatchBrush(HatchStyle.LightDownwardDiagonal, Color.FromArgb(7, Color.Black), Color.Transparent);
  2986.         G.FillRectangle(HB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  2987.         G.DrawRectangle(new Pen(Edge), new Rectangle(new Point(0, 0), new Size(14, 14)));
  2988.  
  2989.         if (_Checked)
  2990.             G.DrawString("a", new Font("Marlett", 12), Brushes.Black, new Point(-3, -1));
  2991.         DrawText(new SolidBrush(TextColor), HorizontalAlignment.Left, 19, -1);
  2992.     }
  2993.  
  2994.     private bool _Checked;
  2995.     public bool Checked
  2996.     {
  2997.         get { return _Checked; }
  2998.         set
  2999.         {
  3000.             _Checked = value;
  3001.             Invalidate();
  3002.         }
  3003.     }
  3004.  
  3005.     protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
  3006.     {
  3007.         _Checked = !_Checked;
  3008.         if (CheckedChanged != null)
  3009.         {
  3010.             CheckedChanged(this);
  3011.         }
  3012.         base.OnMouseDown(e);
  3013.     }
  3014.  
  3015.     public event CheckedChangedEventHandler CheckedChanged;
  3016.     public delegate void CheckedChangedEventHandler(object sender);
  3017.  
  3018. }
  3019. [DefaultEvent("CheckedChanged")]
  3020. class CrystalClearRadioButton : ThemeControl154
  3021. {
  3022.  
  3023.     public CrystalClearRadioButton()
  3024.     {
  3025.         LockHeight = 17;
  3026.         SetColor("Text", Color.Black);
  3027.         SetColor("Gradient 1", 230, 230, 230);
  3028.         SetColor("Gradient 2", 210, 210, 210);
  3029.         SetColor("Glow", 230, 230, 230);
  3030.         SetColor("Edges", 170, 170, 170);
  3031.         SetColor("Backcolor", BackColor);
  3032.         SetColor("Bullet", 40, 40, 40);
  3033.         Width = 180;
  3034.     }
  3035.  
  3036.     private int X;
  3037.     private Color TextColor;
  3038.     private Color G1;
  3039.     private Color G2;
  3040.     private Color Glow;
  3041.     private Color Edge;
  3042.  
  3043.     private Color BG;
  3044.     protected override void ColorHook()
  3045.     {
  3046.         TextColor = GetColor("Text");
  3047.         G1 = GetColor("Gradient 1");
  3048.         G2 = GetColor("Gradient 2");
  3049.         Glow = GetColor("Glow");
  3050.         Edge = GetColor("Edges");
  3051.         BG = GetColor("Backcolor");
  3052.     }
  3053.  
  3054.     protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
  3055.     {
  3056.         base.OnMouseMove(e);
  3057.         X = e.Location.X;
  3058.         Invalidate();
  3059.     }
  3060.  
  3061.     protected override void PaintHook()
  3062.     {
  3063.         G.Clear(BG);
  3064.         G.SmoothingMode = SmoothingMode.HighQuality;
  3065.         if (_Checked)
  3066.         {
  3067.             LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(0, 0), new Size(14, 14)), G1, G2, 90f);
  3068.             G.FillEllipse(LGB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  3069.             G.FillEllipse(new SolidBrush(Glow), new Rectangle(new Point(0, 0), new Size(14, 7)));
  3070.         }
  3071.         else
  3072.         {
  3073.             LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(0, 0), new Size(14, 16)), G1, G2, 90f);
  3074.             G.FillEllipse(LGB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  3075.             G.FillEllipse(new SolidBrush(Glow), new Rectangle(new Point(0, 0), new Size(14, 7)));
  3076.         }
  3077.  
  3078.         if (State == MouseState.Over & X < 15)
  3079.         {
  3080.             SolidBrush SB = new SolidBrush(Color.FromArgb(70, Color.White));
  3081.             G.FillEllipse(SB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  3082.         }
  3083.         else if (State == MouseState.Down & X < 15)
  3084.         {
  3085.             SolidBrush SB = new SolidBrush(Color.FromArgb(10, Color.Black));
  3086.             G.FillEllipse(SB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  3087.         }
  3088.  
  3089.         HatchBrush HB = new HatchBrush(HatchStyle.LightDownwardDiagonal, Color.FromArgb(7, Color.Black), Color.Transparent);
  3090.         G.FillEllipse(HB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  3091.         G.DrawEllipse(new Pen(Edge), new Rectangle(new Point(0, 0), new Size(14, 14)));
  3092.  
  3093.         if (_Checked)
  3094.             G.FillEllipse(GetBrush("Bullet"), new Rectangle(new Point(4, 4), new Size(6, 6)));
  3095.         DrawText(new SolidBrush(TextColor), HorizontalAlignment.Left, 19, -1);
  3096.     }
  3097.  
  3098.     private int _Field = 16;
  3099.     public int Field
  3100.     {
  3101.         get { return _Field; }
  3102.         set
  3103.         {
  3104.             if (value < 4)
  3105.                 return;
  3106.             _Field = value;
  3107.             LockHeight = value;
  3108.             Invalidate();
  3109.         }
  3110.     }
  3111.  
  3112.     private bool _Checked;
  3113.     public bool Checked
  3114.     {
  3115.         get { return _Checked; }
  3116.         set
  3117.         {
  3118.             _Checked = value;
  3119.             InvalidateControls();
  3120.             if (CheckedChanged != null)
  3121.             {
  3122.                 CheckedChanged(this);
  3123.             }
  3124.             Invalidate();
  3125.         }
  3126.     }
  3127.  
  3128.     protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
  3129.     {
  3130.         if (!_Checked)
  3131.             Checked = true;
  3132.         base.OnMouseDown(e);
  3133.     }
  3134.  
  3135.     public event CheckedChangedEventHandler CheckedChanged;
  3136.     public delegate void CheckedChangedEventHandler(object sender);
  3137.  
  3138.     protected override void OnCreation()
  3139.     {
  3140.         InvalidateControls();
  3141.     }
  3142.  
  3143.     private void InvalidateControls()
  3144.     {
  3145.         if (!IsHandleCreated || !_Checked)
  3146.             return;
  3147.  
  3148.         foreach (Control C in Parent.Controls)
  3149.         {
  3150.             if (!object.ReferenceEquals(C, this) && C is CrystalClearRadioButton)
  3151.             {
  3152.                 ((CrystalClearRadioButton)C).Checked = false;
  3153.             }
  3154.         }
  3155.     }
  3156.  
  3157. }
  3158. class CrystalClearProgressBar : ThemeControl154
  3159. {
  3160.  
  3161.     Color G1;
  3162.     Color G2;
  3163.     Color Glow;
  3164.     Color Edge;
  3165.  
  3166.     int GlowPosition;
  3167.     private int _Minimum;
  3168.     public int Minimum
  3169.     {
  3170.         get { return _Minimum; }
  3171.         set
  3172.         {
  3173.             if (value < 0)
  3174.             {
  3175.                 throw new Exception("Property value is not valid.");
  3176.             }
  3177.  
  3178.             _Minimum = value;
  3179.             if (value > _Value)
  3180.                 _Value = value;
  3181.             if (value > _Maximum)
  3182.                 _Maximum = value;
  3183.             Invalidate();
  3184.         }
  3185.     }
  3186.  
  3187.     private int _Maximum = 100;
  3188.     public int Maximum
  3189.     {
  3190.         get { return _Maximum; }
  3191.         set
  3192.         {
  3193.             if (value < 0)
  3194.             {
  3195.                 throw new Exception("Property value is not valid.");
  3196.             }
  3197.  
  3198.             _Maximum = value;
  3199.             if (value < _Value)
  3200.                 _Value = value;
  3201.             if (value < _Minimum)
  3202.                 _Minimum = value;
  3203.             Invalidate();
  3204.         }
  3205.     }
  3206.  
  3207.     public bool Animated
  3208.     {
  3209.         get { return IsAnimated; }
  3210.         set
  3211.         {
  3212.             IsAnimated = value;
  3213.             Invalidate();
  3214.         }
  3215.     }
  3216.  
  3217.     private int _Value;
  3218.     public int Value
  3219.     {
  3220.         get { return _Value; }
  3221.         set
  3222.         {
  3223.             if (value > _Maximum || value < _Minimum)
  3224.             {
  3225.                 throw new Exception("Property value is not valid.");
  3226.             }
  3227.  
  3228.             _Value = value;
  3229.             Invalidate();
  3230.         }
  3231.     }
  3232.  
  3233.     private void Increment(int amount)
  3234.     {
  3235.         Value += amount;
  3236.     }
  3237.  
  3238.     public CrystalClearProgressBar()
  3239.     {
  3240.         SetColor("Gradient 1", 230, 230, 230);
  3241.         SetColor("Gradient 2", 210, 210, 210);
  3242.         SetColor("Glow", 230, 230, 230);
  3243.         SetColor("Edge", 170, 170, 170);
  3244.         IsAnimated = true;
  3245.  
  3246.     }
  3247.  
  3248.     protected override void ColorHook()
  3249.     {
  3250.         G1 = GetColor("Gradient 1");
  3251.         G2 = GetColor("Gradient 2");
  3252.         Glow = GetColor("Glow");
  3253.         Edge = GetColor("Edge");
  3254.     }
  3255.  
  3256.     protected override void OnAnimation()
  3257.     {
  3258.         if (GlowPosition == 0)
  3259.         {
  3260.             GlowPosition = 7;
  3261.         }
  3262.         else
  3263.         {
  3264.             GlowPosition -= 1;
  3265.         }
  3266.     }
  3267.  
  3268.     protected override void PaintHook()
  3269.     {
  3270.         G.Clear(G1);
  3271.         LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(1, 1), new Size(Width - 2, Height - 2)), G1, G2, 90f);
  3272.         G.FillRectangle(LGB, new Rectangle(new Point(1, 1), new Size((Width / Maximum) * Value - 1, Height - 2)));
  3273.         G.FillRectangle(new SolidBrush(Glow), new Rectangle(new Point(1, 1), new Size((Width / Maximum) * Value - 1, (Height / 2) - 3)));
  3274.  
  3275.         G.RenderingOrigin = new Point(GlowPosition, 0);
  3276.         HatchBrush HB = new HatchBrush(HatchStyle.ForwardDiagonal, Color.FromArgb(20, Color.Black), Color.Transparent);
  3277.         G.FillRectangle(HB, new Rectangle(new Point(1, 2), new Size((Width / Maximum) * Value - 1, Height - 3)));
  3278.  
  3279.         G.DrawLine(new Pen(Edge), new Point((Width / Maximum) * Value - 1, 1), new Point((Width / Maximum) * Value - 1, Height - 1));
  3280.         G.DrawRectangle(new Pen(Edge), new Rectangle(new Point(1, 1), new Size(Width - 2, Height - 2)));
  3281.     }
  3282.  
  3283. }
  3284. class CrystalClearListbox : ListBox
  3285. {
  3286.  
  3287.     public CrystalClearListbox()
  3288.     {
  3289.         SetStyle(ControlStyles.DoubleBuffer, true);
  3290.         Font = new Font("Microsoft Sans Serif", 9);
  3291.         BorderStyle = System.Windows.Forms.BorderStyle.None;
  3292.         DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
  3293.         ItemHeight = 21;
  3294.         ForeColor = Color.Black;
  3295.         BackColor = Color.FromArgb(230, 230, 230);
  3296.         IntegralHeight = false;
  3297.     }
  3298.  
  3299.     protected override void WndProc(ref System.Windows.Forms.Message m)
  3300.     {
  3301.         base.WndProc(ref m);
  3302.         if (m.Msg == 15)
  3303.             CustomPaint();
  3304.     }
  3305.  
  3306.     private Image _Image;
  3307.     public Image ItemImage
  3308.     {
  3309.         get { return _Image; }
  3310.         set { _Image = value; }
  3311.     }
  3312.  
  3313.     protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
  3314.     {
  3315.         try
  3316.         {
  3317.             if (e.Index < 0)
  3318.                 return;
  3319.             e.DrawBackground();
  3320.             Rectangle rect = new Rectangle(new Point(e.Bounds.Left, e.Bounds.Top + 2), new Size(Bounds.Width, 16));
  3321.             e.DrawFocusRectangle();
  3322.             if (Strings.InStr(e.State.ToString(), "Selected,") > 0)
  3323.             {
  3324.                 Rectangle x2 = e.Bounds;
  3325.                 Rectangle x3 = new Rectangle(x2.Location, new Size(x2.Width, (x2.Height / 2)));
  3326.                 LinearGradientBrush G1 = new LinearGradientBrush(new Point(x2.X, x2.Y), new Point(x2.X, x2.Y + x2.Height), Color.FromArgb(230, 230, 230), Color.FromArgb(210, 210, 210));
  3327.                 HatchBrush H = new HatchBrush(HatchStyle.LightDownwardDiagonal, Color.FromArgb(10, Color.Black), Color.Transparent);
  3328.                 e.Graphics.FillRectangle(G1, x2);
  3329.                 G1.Dispose();
  3330.                 e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(230, 230, 230)), x3);
  3331.                 e.Graphics.FillRectangle(H, x2);
  3332.                 G1.Dispose();
  3333.                 e.Graphics.DrawString(" " + Items[e.Index].ToString(), Font, Brushes.Black, 5, e.Bounds.Y + (e.Bounds.Height / 2) - 9);
  3334.                 e.Graphics.DrawRectangle(new Pen(Color.FromArgb(170, 170, 170)), new Rectangle(new Point(x2.Location.X, x2.Location.Y), new Size(x2.Width, x2.Height)));
  3335.             }
  3336.             else
  3337.             {
  3338.                 Rectangle x2 = e.Bounds;
  3339.                 e.Graphics.DrawString(" " + Items[e.Index].ToString(), Font, Brushes.Black, 5, e.Bounds.Y + (e.Bounds.Height / 2) - 9);
  3340.                 e.Graphics.DrawRectangle(new Pen(Color.FromArgb(215, 215, 215)), new Rectangle(new Point(x2.Location.X, x2.Location.Y), new Size(x2.Width, x2.Height)));
  3341.             }
  3342.             e.Graphics.DrawRectangle(new Pen(Color.FromArgb(170, 170, 170)), new Rectangle(0, 0, Width - 1, Height - 1));
  3343.             base.OnDrawItem(e);
  3344.         }
  3345.         catch (Exception ex)
  3346.         {
  3347.         }
  3348.     }
  3349.  
  3350.     public void CustomPaint()
  3351.     {
  3352.         CreateGraphics().DrawRectangle(new Pen(Color.FromArgb(170, 170, 170)), new Rectangle(0, 0, Width - 1, Height - 1));
  3353.     }
  3354. }
  3355. class CrystalClearTabControl : TabControl
  3356. {
  3357.  
  3358.     private Color _BG;
  3359.     public Color Backcolor
  3360.     {
  3361.         get { return _BG; }
  3362.         set { _BG = value; }
  3363.     }
  3364.  
  3365.     public CrystalClearTabControl()
  3366.     {
  3367.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
  3368.         DoubleBuffered = true;
  3369.         Backcolor = Color.FromArgb(230, 230, 230);
  3370.     }
  3371.     protected override void CreateHandle()
  3372.     {
  3373.         base.CreateHandle();
  3374.         Alignment = TabAlignment.Top;
  3375.     }
  3376.  
  3377.     public Pen ToPen(Color color)
  3378.     {
  3379.         return new Pen(color);
  3380.     }
  3381.  
  3382.     public Brush ToBrush(Color color)
  3383.     {
  3384.         return new SolidBrush(color);
  3385.     }
  3386.  
  3387.     protected override void OnPaint(PaintEventArgs e)
  3388.     {
  3389.         Bitmap B = new Bitmap(Width, Height);
  3390.         Graphics G = Graphics.FromImage(B);
  3391.         try
  3392.         {
  3393.             SelectedTab.BackColor = Backcolor;
  3394.         }
  3395.         catch
  3396.         {
  3397.         }
  3398.         G.Clear(Backcolor);
  3399.         G.DrawRectangle(new Pen(Color.FromArgb(170, 170, 170)), new Rectangle(0, 21, Width - 1, Height - 22));
  3400.         for (int i = 0; i <= TabCount - 1; i++)
  3401.         {
  3402.             if (i == SelectedIndex)
  3403.             {
  3404.                 Rectangle x2 = new Rectangle(GetTabRect(i).X - 2, GetTabRect(i).Y, GetTabRect(i).Width, GetTabRect(i).Height - 2);
  3405.                 Rectangle x3 = new Rectangle(GetTabRect(i).X - 2, GetTabRect(i).Y, GetTabRect(i).Width, GetTabRect(i).Height - 1);
  3406.                 Rectangle x4 = new Rectangle(GetTabRect(i).X - 2, GetTabRect(i).Y, GetTabRect(i).Width, GetTabRect(i).Height);
  3407.                 LinearGradientBrush G1 = new LinearGradientBrush(x3, Color.FromArgb(10, 0, 0, 0), Color.FromArgb(230, 230, 230), 90f);
  3408.                 HatchBrush HB = new HatchBrush(HatchStyle.LightDownwardDiagonal, Color.FromArgb(10, Color.Black), Color.Transparent);
  3409.  
  3410.                 G.FillRectangle(HB, x3);
  3411.                 HB.Dispose();
  3412.                 G.FillRectangle(G1, x3);
  3413.                 G1.Dispose();
  3414.                 G.DrawLine(new Pen(Color.FromArgb(170, 170, 170)), x2.Location, new Point(x2.Location.X, x2.Location.Y + x2.Height));
  3415.                 G.DrawLine(new Pen(Color.FromArgb(170, 170, 170)), new Point(x2.Location.X + x2.Width, x2.Location.Y), new Point(x2.Location.X + x2.Width, x2.Location.Y + x2.Height));
  3416.                 G.DrawLine(new Pen(Color.FromArgb(170, 170, 170)), new Point(x2.Location.X, x2.Location.Y), new Point(x2.Location.X + x2.Width, x2.Location.Y));
  3417.                 G.DrawString(TabPages[i].Text, Font, new SolidBrush(Color.Black), x4, new StringFormat
  3418.                 {
  3419.                     LineAlignment = StringAlignment.Center,
  3420.                     Alignment = StringAlignment.Center
  3421.                 });
  3422.             }
  3423.             else
  3424.             {
  3425.                 Rectangle x2 = new Rectangle(GetTabRect(i).X - 2, GetTabRect(i).Y + 3, GetTabRect(i).Width, GetTabRect(i).Height - 5);
  3426.                 LinearGradientBrush G1 = new LinearGradientBrush(x2, Color.FromArgb(215, 215, 215), Color.FromArgb(230, 230, 230), -90f);
  3427.                 G.FillRectangle(G1, x2);
  3428.                 G1.Dispose();
  3429.                 G.DrawRectangle(new Pen(Color.FromArgb(170, 170, 170)), x2);
  3430.                 G.DrawString(TabPages[i].Text, Font, new SolidBrush(Color.Black), x2, new StringFormat
  3431.                 {
  3432.                     LineAlignment = StringAlignment.Center,
  3433.                     Alignment = StringAlignment.Center
  3434.                 });
  3435.             }
  3436.         }
  3437.  
  3438.         e.Graphics.DrawImage(B, 0, 0);
  3439.         G.Dispose();
  3440.         B.Dispose();
  3441.     }
  3442. }
  3443. [DefaultEvent("TextChanged")]
  3444. class CrystalClearTextBox : ThemeControl154
  3445. {
  3446.  
  3447.     private HorizontalAlignment _TextAlign = HorizontalAlignment.Left;
  3448.     public HorizontalAlignment TextAlign
  3449.     {
  3450.         get { return _TextAlign; }
  3451.         set
  3452.         {
  3453.             _TextAlign = value;
  3454.             if (Base != null)
  3455.             {
  3456.                 Base.TextAlign = value;
  3457.             }
  3458.         }
  3459.     }
  3460.     private int _MaxLength = 32767;
  3461.     public int MaxLength
  3462.     {
  3463.         get { return _MaxLength; }
  3464.         set
  3465.         {
  3466.             _MaxLength = value;
  3467.             if (Base != null)
  3468.             {
  3469.                 Base.MaxLength = value;
  3470.             }
  3471.         }
  3472.     }
  3473.     private bool _ReadOnly;
  3474.     public bool ReadOnly
  3475.     {
  3476.         get { return _ReadOnly; }
  3477.         set
  3478.         {
  3479.             _ReadOnly = value;
  3480.             if (Base != null)
  3481.             {
  3482.                 Base.ReadOnly = value;
  3483.             }
  3484.         }
  3485.     }
  3486.     private bool _UseSystemPasswordChar;
  3487.     public bool UseSystemPasswordChar
  3488.     {
  3489.         get { return _UseSystemPasswordChar; }
  3490.         set
  3491.         {
  3492.             _UseSystemPasswordChar = value;
  3493.             if (Base != null)
  3494.             {
  3495.                 Base.UseSystemPasswordChar = value;
  3496.             }
  3497.         }
  3498.     }
  3499.     private bool _Multiline;
  3500.     public bool Multiline
  3501.     {
  3502.         get { return _Multiline; }
  3503.         set
  3504.         {
  3505.             _Multiline = value;
  3506.             if (Base != null)
  3507.             {
  3508.                 Base.Multiline = value;
  3509.  
  3510.                 if (value)
  3511.                 {
  3512.                     LockHeight = 0;
  3513.                     Base.Height = Height - 11;
  3514.                 }
  3515.                 else
  3516.                 {
  3517.                     LockHeight = Base.Height + 11;
  3518.                 }
  3519.             }
  3520.         }
  3521.     }
  3522.     public override string Text
  3523.     {
  3524.         get { return base.Text; }
  3525.         set
  3526.         {
  3527.             base.Text = value;
  3528.             if (Base != null)
  3529.             {
  3530.                 Base.Text = value;
  3531.             }
  3532.         }
  3533.     }
  3534.     public override Font Font
  3535.     {
  3536.         get { return base.Font; }
  3537.         set
  3538.         {
  3539.             base.Font = value;
  3540.             if (Base != null)
  3541.             {
  3542.                 Base.Font = value;
  3543.                 Base.Location = new Point(3, 5);
  3544.                 Base.Width = Width - 6;
  3545.  
  3546.                 if (!_Multiline)
  3547.                 {
  3548.                     LockHeight = Base.Height + 11;
  3549.                 }
  3550.             }
  3551.         }
  3552.     }
  3553.  
  3554.     protected override void OnCreation()
  3555.     {
  3556.         if (!Controls.Contains(Base))
  3557.         {
  3558.             Controls.Add(Base);
  3559.         }
  3560.     }
  3561.  
  3562.     private TextBox Base;
  3563.     public CrystalClearTextBox()
  3564.     {
  3565.         Base = new TextBox();
  3566.  
  3567.         Base.Font = Font;
  3568.         Base.Text = Text;
  3569.         Base.MaxLength = _MaxLength;
  3570.         Base.Multiline = _Multiline;
  3571.         Base.ReadOnly = _ReadOnly;
  3572.         Base.UseSystemPasswordChar = _UseSystemPasswordChar;
  3573.  
  3574.         Base.BorderStyle = BorderStyle.None;
  3575.  
  3576.         Base.Location = new Point(4, 4);
  3577.         Base.Width = Width - 10;
  3578.  
  3579.         if (_Multiline)
  3580.         {
  3581.             Base.Height = Height - 11;
  3582.         }
  3583.         else
  3584.         {
  3585.             LockHeight = Base.Height + 11;
  3586.         }
  3587.  
  3588.         Base.TextChanged += OnBaseTextChanged;
  3589.         Base.KeyDown += OnBaseKeyDown;
  3590.  
  3591.  
  3592.         SetColor("Text", Color.Black);
  3593.         SetColor("Backcolor", BackColor);
  3594.         SetColor("Border", 170, 170, 170);
  3595.     }
  3596.  
  3597.     private Color BG;
  3598.  
  3599.     private Pen P1;
  3600.     protected override void ColorHook()
  3601.     {
  3602.         BG = GetColor("Backcolor");
  3603.  
  3604.         P1 = GetPen("Border");
  3605.  
  3606.         Base.ForeColor = GetColor("Text");
  3607.         Base.BackColor = GetColor("Backcolor");
  3608.     }
  3609.  
  3610.     protected override void PaintHook()
  3611.     {
  3612.         G.Clear(BG);
  3613.         DrawBorders(P1);
  3614.     }
  3615.     private void OnBaseTextChanged(object s, EventArgs e)
  3616.     {
  3617.         Text = Base.Text;
  3618.     }
  3619.     private void OnBaseKeyDown(object s, KeyEventArgs e)
  3620.     {
  3621.         if (e.Control && e.KeyCode == Keys.A)
  3622.         {
  3623.             Base.SelectAll();
  3624.             e.SuppressKeyPress = true;
  3625.         }
  3626.     }
  3627.     protected override void OnResize(EventArgs e)
  3628.     {
  3629.         Base.Location = new Point(4, 5);
  3630.         Base.Width = Width - 8;
  3631.  
  3632.         if (_Multiline)
  3633.         {
  3634.             Base.Height = Height - 5;
  3635.         }
  3636.  
  3637.  
  3638.         base.OnResize(e);
  3639.     }
  3640.  
  3641. }
Advertisement
Add Comment
Please, Sign In to add comment