Alex-Trader

Chrome ThemeC#

Jul 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Drawing.Drawing2D;
  6. using System.Drawing.Imaging;
  7. using System.IO;
  8. using System.Runtime.InteropServices;
  9. using System.Windows.Forms;
  10.  
  11. // Google Chrome Theme - Ported to C# by Ecco
  12. // Original Theme http://www.hackforums.net/showthread.php?tid=2926688
  13. // Credit to Mavamaarten~ for Google Chrome Theme & Aeonhack for Themebase
  14.  
  15. class ChromeForm : ThemeContainer154
  16. {
  17.     public ChromeForm()
  18.     {
  19.         TransparencyKey = Color.Fuchsia;
  20.         BackColor = Color.White;
  21.         Font = new Font("Segoe UI", 9);
  22.         SetColor("Title color", Color.Black);
  23.         SetColor("X-color", 90, 90, 90);
  24.         SetColor("X-ellipse", 114, 114, 114);
  25.     }
  26.  
  27.     Color TitleColor;
  28.     Color Xcolor;
  29.     Color Xellipse;
  30.     protected override void ColorHook()
  31.     {
  32.         TitleColor = GetColor("Title color");
  33.         Xcolor = GetColor("X-color");
  34.         Xellipse = GetColor("X-ellipse");
  35.     }
  36.  
  37.     int X;
  38.  
  39.     int Y;
  40.     protected override void OnMouseMove(MouseEventArgs e)
  41.     {
  42.         X = e.Location.X;
  43.         Y = e.Location.Y;
  44.         base.OnMouseMove(e);
  45.         Invalidate();
  46.     }
  47.     protected override void OnMouseClick(MouseEventArgs e)
  48.     {
  49.         base.OnClick(e);
  50.         Rectangle r = new Rectangle(Width - 22, 5, 15, 15);
  51.         if (r.Contains(new Point(e.X, e.Y)) || r.Contains(new Point(X, Y)) && e.Button == MouseButtons.Left)
  52.             FindForm().Close();
  53.     }
  54.  
  55.     protected override void PaintHook()
  56.     {
  57.         G.Clear(BackColor);
  58.         DrawCorners(Color.Fuchsia);
  59.         DrawCorners(Color.Fuchsia, 1, 0, Width - 2, Height);
  60.         DrawCorners(Color.Fuchsia, 0, 1, Width, Height - 2);
  61.         DrawCorners(Color.Fuchsia, 2, 0, Width - 4, Height);
  62.         DrawCorners(Color.Fuchsia, 0, 2, Width, Height - 4);
  63.  
  64.         G.SmoothingMode = SmoothingMode.HighQuality;
  65.         if (new Rectangle(Width - 22, 5, 15, 15).Contains(new Point(X, Y)))
  66.         {
  67.             G.FillEllipse(new SolidBrush(Xellipse), new Rectangle(Width - 24, 6, 16, 16));
  68.             G.DrawString("r", new Font("Webdings", 8), new SolidBrush(BackColor), new Point(Width - 23, 5));
  69.         }
  70.         else
  71.         {
  72.             G.DrawString("r", new Font("Webdings", 8), new SolidBrush(Xcolor), new Point(Width - 23, 5));
  73.         }
  74.  
  75.         DrawText(new SolidBrush(TitleColor), new Point(8, 7));
  76.     }
  77. }
  78. class ChromeButton : ThemeControl154
  79. {
  80.     public ChromeButton()
  81.     {
  82.         Font = new Font("Segoe UI", 9);
  83.         SetColor("Gradient top normal", 237, 237, 237);
  84.         SetColor("Gradient top over", 242, 242, 242);
  85.         SetColor("Gradient top down", 235, 235, 235);
  86.         SetColor("Gradient bottom normal", 230, 230, 230);
  87.         SetColor("Gradient bottom over", 235, 235, 235);
  88.         SetColor("Gradient bottom down", 223, 223, 223);
  89.         SetColor("Border", 167, 167, 167);
  90.         SetColor("Text normal", 60, 60, 60);
  91.         SetColor("Text down/over", 20, 20, 20);
  92.         SetColor("Text disabled", Color.Gray);
  93.     }
  94.  
  95.     Color GTN;
  96.     Color GTO;
  97.     Color GTD;
  98.     Color GBN;
  99.     Color GBO;
  100.     Color GBD;
  101.     Color Bo;
  102.     Color TN;
  103.     Color TD;
  104.     Color TDO;
  105.     protected override void ColorHook()
  106.     {
  107.         GTN = GetColor("Gradient top normal");
  108.         GTO = GetColor("Gradient top over");
  109.         GTD = GetColor("Gradient top down");
  110.         GBN = GetColor("Gradient bottom normal");
  111.         GBO = GetColor("Gradient bottom over");
  112.         GBD = GetColor("Gradient bottom down");
  113.         Bo = GetColor("Border");
  114.         TN = GetColor("Text normal");
  115.         TDO = GetColor("Text down/over");
  116.         TD = GetColor("Text disabled");
  117.     }
  118.  
  119.     protected override void PaintHook()
  120.     {
  121.         G.Clear(BackColor);
  122.         LinearGradientBrush LGB = default(LinearGradientBrush);
  123.         G.SmoothingMode = SmoothingMode.HighQuality;
  124.  
  125.  
  126.         switch (State)
  127.         {
  128.             case MouseState.None:
  129.                 LGB = new LinearGradientBrush(new Rectangle(0, 0, Width - 1, Height - 1), GTN, GBN, 90f);
  130.                 break;
  131.             case MouseState.Over:
  132.                 LGB = new LinearGradientBrush(new Rectangle(0, 0, Width - 1, Height - 1), GTO, GBO, 90f);
  133.                 break;
  134.             default:
  135.                 LGB = new LinearGradientBrush(new Rectangle(0, 0, Width - 1, Height - 1), GTD, GBD, 90f);
  136.                 break;
  137.         }
  138.  
  139.         if (!Enabled)
  140.         {
  141.             LGB = new LinearGradientBrush(new Rectangle(0, 0, Width - 1, Height - 1), GTN, GBN, 90f);
  142.         }
  143.  
  144.         GraphicsPath buttonpath = CreateRound(Rectangle.Round(LGB.Rectangle), 3);
  145.         G.FillPath(LGB, CreateRound(Rectangle.Round(LGB.Rectangle), 3));
  146.         if (!Enabled)
  147.             G.FillPath(new SolidBrush(Color.FromArgb(50, Color.White)), CreateRound(Rectangle.Round(LGB.Rectangle), 3));
  148.         G.SetClip(buttonpath);
  149.         LGB = new LinearGradientBrush(new Rectangle(0, 0, Width, Height / 6), Color.FromArgb(80, Color.White), Color.Transparent, 90f);
  150.         G.FillRectangle(LGB, Rectangle.Round(LGB.Rectangle));
  151.  
  152.  
  153.  
  154.         G.ResetClip();
  155.         G.DrawPath(new Pen(Bo), buttonpath);
  156.  
  157.         if (Enabled)
  158.         {
  159.             switch (State)
  160.             {
  161.                 case MouseState.None:
  162.                     DrawText(new SolidBrush(TN), HorizontalAlignment.Center, 1, 0);
  163.                     break;
  164.                 default:
  165.                     DrawText(new SolidBrush(TDO), HorizontalAlignment.Center, 1, 0);
  166.                     break;
  167.             }
  168.         }
  169.         else
  170.         {
  171.             DrawText(new SolidBrush(TD), HorizontalAlignment.Center, 1, 0);
  172.         }
  173.     }
  174. }
  175. [DefaultEventAttribute("CheckedChanged")]
  176. class ChromeCheckbox : ThemeControl154
  177. {
  178.  
  179.     public ChromeCheckbox()
  180.     {
  181.         LockHeight = 17;
  182.         Font = new Font("Segoe UI", 9);
  183.         SetColor("Gradient top normal", 237, 237, 237);
  184.         SetColor("Gradient top over", 242, 242, 242);
  185.         SetColor("Gradient top down", 235, 235, 235);
  186.         SetColor("Gradient bottom normal", 230, 230, 230);
  187.         SetColor("Gradient bottom over", 235, 235, 235);
  188.         SetColor("Gradient bottom down", 223, 223, 223);
  189.         SetColor("Border", 167, 167, 167);
  190.         SetColor("Text", 60, 60, 60);
  191.         Width = 160;
  192.     }
  193.  
  194.     private int X;
  195.     Color GTN;
  196.     Color GTO;
  197.     Color GTD;
  198.     Color GBN;
  199.     Color GBO;
  200.     Color GBD;
  201.     Color Bo;
  202.     Color T;
  203.     protected override void ColorHook()
  204.     {
  205.         GTN = GetColor("Gradient top normal");
  206.         GTO = GetColor("Gradient top over");
  207.         GTD = GetColor("Gradient top down");
  208.         GBN = GetColor("Gradient bottom normal");
  209.         GBO = GetColor("Gradient bottom over");
  210.         GBD = GetColor("Gradient bottom down");
  211.         Bo = GetColor("Border");
  212.         T = GetColor("Text");
  213.     }
  214.  
  215.     protected override void OnMouseMove(MouseEventArgs e)
  216.     {
  217.         base.OnMouseMove(e);
  218.         X = e.Location.X;
  219.         Invalidate();
  220.     }
  221.  
  222.     protected override void PaintHook()
  223.     {
  224.         G.Clear(BackColor);
  225.         LinearGradientBrush LGB = default(LinearGradientBrush);
  226.         G.SmoothingMode = SmoothingMode.HighQuality;
  227.         switch (State)
  228.         {
  229.             case MouseState.None:
  230.                 LGB = new LinearGradientBrush(new Rectangle(0, 0, 14, 14), GTN, GBN, 90f);
  231.                 break;
  232.             case MouseState.Over:
  233.                 LGB = new LinearGradientBrush(new Rectangle(0, 0, 14, 14), GTO, GBO, 90f);
  234.                 break;
  235.             default:
  236.                 LGB = new LinearGradientBrush(new Rectangle(0, 0, 14, 14), GTD, GBD, 90f);
  237.                 break;
  238.         }
  239.         GraphicsPath buttonpath = CreateRound(Rectangle.Round(LGB.Rectangle), 5);
  240.         G.FillPath(LGB, CreateRound(Rectangle.Round(LGB.Rectangle), 3));
  241.         G.SetClip(buttonpath);
  242.         LGB = new LinearGradientBrush(new Rectangle(0, 0, 14, 5), Color.FromArgb(150, Color.White), Color.Transparent, 90f);
  243.         G.FillRectangle(LGB, Rectangle.Round(LGB.Rectangle));
  244.         G.ResetClip();
  245.         G.DrawPath(new Pen(Bo), buttonpath);
  246.  
  247.         DrawText(new SolidBrush(T), 17, -2);
  248.  
  249.  
  250.         if (Checked)
  251.         {
  252.             Image check = Image.FromStream(new System.IO.MemoryStream(Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAsAAAAJCAYAAADkZNYtAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAACHDwAAjA8AAP1SAACBQAAAfXkAAOmLAAA85QAAGcxzPIV3AAAKOWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAEjHnZZ3VFTXFofPvXd6oc0wAlKG3rvAANJ7k15FYZgZYCgDDjM0sSGiAhFFRJoiSFDEgNFQJFZEsRAUVLAHJAgoMRhFVCxvRtaLrqy89/Ly++Osb+2z97n77L3PWhcAkqcvl5cGSwGQyhPwgzyc6RGRUXTsAIABHmCAKQBMVka6X7B7CBDJy82FniFyAl8EAfB6WLwCcNPQM4BOB/+fpFnpfIHomAARm7M5GSwRF4g4JUuQLrbPipgalyxmGCVmvihBEcuJOWGRDT77LLKjmNmpPLaIxTmns1PZYu4V8bZMIUfEiK+ICzO5nCwR3xKxRoowlSviN+LYVA4zAwAUSWwXcFiJIjYRMYkfEuQi4uUA4EgJX3HcVyzgZAvEl3JJS8/hcxMSBXQdli7d1NqaQffkZKVwBALDACYrmcln013SUtOZvBwAFu/8WTLi2tJFRbY0tba0NDQzMv2qUP91829K3NtFehn4uWcQrf+L7a/80hoAYMyJarPziy2uCoDOLQDI3fti0zgAgKSobx3Xv7oPTTwviQJBuo2xcVZWlhGXwzISF/QP/U+Hv6GvvmckPu6P8tBdOfFMYYqALq4bKy0lTcinZ6QzWRy64Z+H+B8H/nUeBkGceA6fwxNFhImmjMtLELWbx+YKuGk8Opf3n5r4D8P+pMW5FonS+BFQY4yA1HUqQH7tBygKESDR+8Vd/6NvvvgwIH554SqTi3P/7zf9Z8Gl4iWDm/A5ziUohM4S8jMX98TPEqABAUgCKpAHykAd6ABDYAasgC1wBG7AG/iDEBAJVgMWSASpgA+yQB7YBApBMdgJ9oBqUAcaQTNoBcdBJzgFzoNL4Bq4AW6D+2AUTIBnYBa8BgsQBGEhMkSB5CEVSBPSh8wgBmQPuUG+UBAUCcVCCRAPEkJ50GaoGCqDqqF6qBn6HjoJnYeuQIPQXWgMmoZ+h97BCEyCqbASrAUbwwzYCfaBQ+BVcAK8Bs6FC+AdcCXcAB+FO+Dz8DX4NjwKP4PnEIAQERqiihgiDMQF8UeikHiEj6xHipAKpAFpRbqRPuQmMorMIG9RGBQFRUcZomxRnqhQFAu1BrUeVYKqRh1GdaB6UTdRY6hZ1Ec0Ga2I1kfboL3QEegEdBa6EF2BbkK3oy+ib6Mn0K8xGAwNo42xwnhiIjFJmLWYEsw+TBvmHGYQM46Zw2Kx8lh9rB3WH8vECrCF2CrsUexZ7BB2AvsGR8Sp4Mxw7rgoHA+Xj6vAHcGdwQ3hJnELeCm8Jt4G749n43PwpfhGfDf+On4Cv0CQJmgT7AghhCTCJkIloZVwkfCA8JJIJKoRrYmBRC5xI7GSeIx4mThGfEuSIemRXEjRJCFpB+kQ6RzpLuklmUzWIjuSo8gC8g5yM/kC+RH5jQRFwkjCS4ItsUGiRqJDYkjiuSReUlPSSXK1ZK5kheQJyeuSM1J4KS0pFymm1HqpGqmTUiNSc9IUaVNpf+lU6RLpI9JXpKdksDJaMm4ybJkCmYMyF2TGKQhFneJCYVE2UxopFykTVAxVm+pFTaIWU7+jDlBnZWVkl8mGyWbL1sielh2lITQtmhcthVZKO04bpr1borTEaQlnyfYlrUuGlszLLZVzlOPIFcm1yd2WeydPl3eTT5bfJd8p/1ABpaCnEKiQpbBf4aLCzFLqUtulrKVFS48vvacIK+opBimuVTyo2K84p6Ss5KGUrlSldEFpRpmm7KicpFyufEZ5WoWiYq/CVSlXOavylC5Ld6Kn0CvpvfRZVUVVT1Whar3qgOqCmrZaqFq+WpvaQ3WCOkM9Xr1cvUd9VkNFw08jT6NF454mXpOhmai5V7NPc15LWytca6tWp9aUtpy2l3audov2Ax2yjoPOGp0GnVu6GF2GbrLuPt0berCehV6iXo3edX1Y31Kfq79Pf9AAbWBtwDNoMBgxJBk6GWYathiOGdGMfI3yjTqNnhtrGEcZ7zLuM/5oYmGSYtJoct9UxtTbNN+02/R3Mz0zllmN2S1zsrm7+QbzLvMXy/SXcZbtX3bHgmLhZ7HVosfig6WVJd+y1XLaSsMq1qrWaoRBZQQwShiXrdHWztYbrE9Zv7WxtBHYHLf5zdbQNtn2iO3Ucu3lnOWNy8ft1OyYdvV2o/Z0+1j7A/ajDqoOTIcGh8eO6o5sxybHSSddpySno07PnU2c+c7tzvMuNi7rXM65Iq4erkWuA24ybqFu1W6P3NXcE9xb3Gc9LDzWepzzRHv6eO7yHPFS8mJ5NXvNelt5r/Pu9SH5BPtU+zz21fPl+3b7wX7efrv9HqzQXMFb0ekP/L38d/s/DNAOWBPwYyAmMCCwJvBJkGlQXlBfMCU4JvhI8OsQ55DSkPuhOqHC0J4wybDosOaw+XDX8LLw0QjjiHUR1yIVIrmRXVHYqLCopqi5lW4r96yciLaILoweXqW9KnvVldUKq1NWn46RjGHGnIhFx4bHHol9z/RnNjDn4rziauNmWS6svaxnbEd2OXuaY8cp40zG28WXxU8l2CXsTphOdEisSJzhunCruS+SPJPqkuaT/ZMPJX9KCU9pS8Wlxqae5Mnwknm9acpp2WmD6frphemja2zW7Fkzy/fhN2VAGasyugRU0c9Uv1BHuEU4lmmfWZP5Jiss60S2dDYvuz9HL2d7zmSue+63a1FrWWt78lTzNuWNrXNaV78eWh+3vmeD+oaCDRMbPTYe3kTYlLzpp3yT/LL8V5vDN3cXKBVsLBjf4rGlpVCikF84stV2a9021DbutoHt5turtn8sYhddLTYprih+X8IqufqN6TeV33zaEb9joNSydP9OzE7ezuFdDrsOl0mX5ZaN7/bb3VFOLy8qf7UnZs+VimUVdXsJe4V7Ryt9K7uqNKp2Vr2vTqy+XeNc01arWLu9dn4fe9/Qfsf9rXVKdcV17w5wD9yp96jvaNBqqDiIOZh58EljWGPft4xvm5sUmoqbPhziHRo9HHS4t9mqufmI4pHSFrhF2DJ9NProje9cv+tqNWytb6O1FR8Dx4THnn4f+/3wcZ/jPScYJ1p/0Pyhtp3SXtQBdeR0zHYmdo52RXYNnvQ+2dNt293+o9GPh06pnqo5LXu69AzhTMGZT2dzz86dSz83cz7h/HhPTM/9CxEXbvUG9g5c9Ll4+ZL7pQt9Tn1nL9tdPnXF5srJq4yrndcsr3X0W/S3/2TxU/uA5UDHdavrXTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxSfNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYKf5X+tfa5zvMffnP8rX82YnbiBf/Fp99LXsq/PPRq2aueuYC5R69TXy/MF72Rf3P4LeNt37vwd5MLWe+x7ys/6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEQAACxEBf2RfkQAAAK1JREFUKFN10D0OhSAQBGAOp2D8u4CNHY0kegFPYaSyM+EQFhY2NsTGcJ3xQbEvxlBMQsg3SxYGgMWitUbbtjiO40fAotBaizzPIYQI8YUo7rqO4DAM78nneYYLH2MMOOchdV3DOffH4zgiyzJM04T7vlFVFeF1XWkI27YNaZpSiqKgs1KKIC0opXwVfLksS1zX9cW+Nc9zeDpJkpBlWV7w83X7vqNpGvR9/4EePztSBhXQfRi8AAAAAElFTkSuQmCC")));
  253.             G.DrawImage(check, new Rectangle(2, 3, check.Width, check.Height));
  254.         }
  255.     }
  256.  
  257.     private bool _Checked;
  258.     public bool Checked
  259.     {
  260.         get { return _Checked; }
  261.         set
  262.         {
  263.             _Checked = value;
  264.             Invalidate();
  265.         }
  266.     }
  267.  
  268.     protected override void OnMouseDown(MouseEventArgs e)
  269.     {
  270.         _Checked = !_Checked;
  271.         if (CheckedChanged != null)
  272.             CheckedChanged(this);
  273.         base.OnMouseDown(e);
  274.     }
  275.  
  276.     public event CheckedChangedEventHandler CheckedChanged;
  277.     public delegate void CheckedChangedEventHandler(object sender);
  278.  
  279. }
  280. [DefaultEventAttribute("CheckedChanged")]
  281. class ChromeRadioButton : ThemeControl154
  282. {
  283.  
  284.     public ChromeRadioButton()
  285.     {
  286.         Font = new Font("Segoe UI", 9);
  287.         LockHeight = 17;
  288.         SetColor("Text", 60, 60, 60);
  289.         SetColor("Gradient top", 237, 237, 237);
  290.         SetColor("Gradient bottom", 230, 230, 230);
  291.         SetColor("Borders", 167, 167, 167);
  292.         SetColor("Bullet", 100, 100, 100);
  293.         Width = 180;
  294.     }
  295.  
  296.     private int X;
  297.     private Color TextColor;
  298.     private Color G1;
  299.     private Color G2;
  300.     private Color Bo;
  301.  
  302.     private Color Bb;
  303.     protected override void ColorHook()
  304.     {
  305.         TextColor = GetColor("Text");
  306.         G1 = GetColor("Gradient top");
  307.         G2 = GetColor("Gradient bottom");
  308.         Bb = GetColor("Bullet");
  309.         Bo = GetColor("Borders");
  310.     }
  311.  
  312.     protected override void OnMouseMove(MouseEventArgs e)
  313.     {
  314.         base.OnMouseMove(e);
  315.         X = e.Location.X;
  316.         Invalidate();
  317.     }
  318.  
  319.     protected override void PaintHook()
  320.     {
  321.         G.Clear(BackColor);
  322.         G.SmoothingMode = SmoothingMode.HighQuality;
  323.         if (_Checked)
  324.         {
  325.             LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(0, 0), new Size(14, 14)), G1, G2, 90f);
  326.             G.FillEllipse(LGB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  327.         }
  328.         else
  329.         {
  330.             LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(0, 0), new Size(14, 16)), G1, G2, 90f);
  331.             G.FillEllipse(LGB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  332.         }
  333.  
  334.         if (State == MouseState.Over & X < 15)
  335.         {
  336.             SolidBrush SB = new SolidBrush(Color.FromArgb(10, Color.Black));
  337.             G.FillEllipse(SB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  338.         }
  339.         else if (State == MouseState.Down & X < 15)
  340.         {
  341.             SolidBrush SB = new SolidBrush(Color.FromArgb(20, Color.Black));
  342.             G.FillEllipse(SB, new Rectangle(new Point(0, 0), new Size(14, 14)));
  343.         }
  344.  
  345.         GraphicsPath P = new GraphicsPath();
  346.         P.AddEllipse(new Rectangle(0, 0, 14, 14));
  347.         G.SetClip(P);
  348.  
  349.         LinearGradientBrush LLGGBB = new LinearGradientBrush(new Rectangle(0, 0, 14, 5), Color.FromArgb(150, Color.White), Color.Transparent, 90f);
  350.         G.FillRectangle(LLGGBB, LLGGBB.Rectangle);
  351.  
  352.         G.ResetClip();
  353.  
  354.         G.DrawEllipse(new Pen(Bo), new Rectangle(new Point(0, 0), new Size(14, 14)));
  355.  
  356.         if (_Checked)
  357.         {
  358.             SolidBrush LGB = new SolidBrush(Bb);
  359.             G.FillEllipse(LGB, new Rectangle(new Point(4, 4), new Size(6, 6)));
  360.         }
  361.  
  362.         DrawText(new SolidBrush(TextColor), HorizontalAlignment.Left, 17, -2);
  363.     }
  364.  
  365.     private int _Field = 16;
  366.     public int Field
  367.     {
  368.         get { return _Field; }
  369.         set
  370.         {
  371.             if (value < 4)
  372.                 return;
  373.             _Field = value;
  374.             LockHeight = value;
  375.             Invalidate();
  376.         }
  377.     }
  378.  
  379.     private bool _Checked;
  380.     public bool Checked
  381.     {
  382.         get { return _Checked; }
  383.         set
  384.         {
  385.             _Checked = value;
  386.             InvalidateControls();
  387.             if (CheckedChanged != null)
  388.             {
  389.                 CheckedChanged(this);
  390.             }
  391.             Invalidate();
  392.         }
  393.     }
  394.  
  395.     protected override void OnMouseDown(MouseEventArgs e)
  396.     {
  397.         if (!_Checked)
  398.             Checked = true;
  399.         base.OnMouseDown(e);
  400.     }
  401.  
  402.     public event CheckedChangedEventHandler CheckedChanged;
  403.     public delegate void CheckedChangedEventHandler(object sender);
  404.  
  405.     protected override void OnCreation()
  406.     {
  407.         InvalidateControls();
  408.     }
  409.  
  410.     private void InvalidateControls()
  411.     {
  412.         if (!IsHandleCreated || !_Checked)
  413.             return;
  414.  
  415.         foreach (Control C in Parent.Controls)
  416.         {
  417.             if (!object.ReferenceEquals(C, this) && C is ChromeRadioButton)
  418.             {
  419.                 ((ChromeRadioButton)C).Checked = false;
  420.             }
  421.         }
  422.     }
  423.  
  424. }
  425. class ChromeSeparator : ThemeControl154
  426. {
  427.  
  428.     public ChromeSeparator()
  429.     {
  430.         LockHeight = 1;
  431.         BackColor = Color.FromArgb(238, 238, 238);
  432.     }
  433.  
  434.  
  435.     protected override void ColorHook()
  436.     {
  437.     }
  438.  
  439.     protected override void PaintHook()
  440.     {
  441.         G.Clear(BackColor);
  442.     }
  443. }
  444. class ChromeTabcontrol : TabControl
  445. {
  446.  
  447.     public ChromeTabcontrol()
  448.     {
  449.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
  450.         DoubleBuffered = true;
  451.         SizeMode = TabSizeMode.Fixed;
  452.         ItemSize = new Size(30, 115);
  453.     }
  454.     protected override void CreateHandle()
  455.     {
  456.         base.CreateHandle();
  457.         Alignment = TabAlignment.Left;
  458.     }
  459.  
  460.     Color C1 = Color.FromArgb(78, 87, 100);
  461.     public Color SquareColor
  462.     {
  463.         get { return C1; }
  464.         set
  465.         {
  466.             C1 = value;
  467.             Invalidate();
  468.         }
  469.     }
  470.  
  471.     bool OB = false;
  472.     public bool ShowOuterBorders
  473.     {
  474.         get { return OB; }
  475.         set
  476.         {
  477.             OB = value;
  478.             Invalidate();
  479.         }
  480.     }
  481.  
  482.     protected override void OnPaint(PaintEventArgs e)
  483.     {
  484.         Bitmap B = new Bitmap(Width, Height);
  485.         Graphics G = Graphics.FromImage(B);
  486.         try
  487.         {
  488.             SelectedTab.BackColor = Color.White;
  489.         }
  490.         catch
  491.         {
  492.         }
  493.         G.Clear(Color.White);
  494.         for (int i = 0; i <= TabCount - 1; i++)
  495.         {
  496.             Rectangle x2 = new Rectangle(new Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), new Size(GetTabRect(i).Width + 3, GetTabRect(i).Height - 1));
  497.             Rectangle textrectangle = new Rectangle(x2.Location.X + 20, x2.Location.Y, x2.Width - 20, x2.Height);
  498.             if (i == SelectedIndex)
  499.             {
  500.                 G.FillRectangle(new SolidBrush(C1), new Rectangle(x2.Location, new Size(9, x2.Height)));
  501.  
  502.  
  503.                 if (ImageList != null)
  504.                 {
  505.                     try
  506.                     {
  507.                         if (ImageList.Images[TabPages[i].ImageIndex] != null)
  508.                         {
  509.                             G.DrawImage(ImageList.Images[TabPages[i].ImageIndex], new Point(textrectangle.Location.X + 8, textrectangle.Location.Y + 6));
  510.                             G.DrawString("      " + TabPages[i].Text, Font, Brushes.Black, textrectangle, new StringFormat
  511.                             {
  512.                                 LineAlignment = StringAlignment.Center,
  513.                                 Alignment = StringAlignment.Near
  514.                             });
  515.                         }
  516.                         else
  517.                         {
  518.                             G.DrawString(TabPages[i].Text, Font, Brushes.Black, textrectangle, new StringFormat
  519.                             {
  520.                                 LineAlignment = StringAlignment.Center,
  521.                                 Alignment = StringAlignment.Near
  522.                             });
  523.                         }
  524.                     }
  525.                     catch
  526.                     {
  527.                         G.DrawString(TabPages[i].Text, Font, Brushes.Black, textrectangle, new StringFormat
  528.                         {
  529.                             LineAlignment = StringAlignment.Center,
  530.                             Alignment = StringAlignment.Near
  531.                         });
  532.                     }
  533.                 }
  534.                 else
  535.                 {
  536.                     G.DrawString(TabPages[i].Text, Font, Brushes.Black, textrectangle, new StringFormat
  537.                     {
  538.                         LineAlignment = StringAlignment.Center,
  539.                         Alignment = StringAlignment.Near
  540.                     });
  541.                 }
  542.  
  543.             }
  544.             else
  545.             {
  546.                 if (ImageList != null)
  547.                 {
  548.                     try
  549.                     {
  550.                         if (ImageList.Images[TabPages[i].ImageIndex] != null)
  551.                         {
  552.                             G.DrawImage(ImageList.Images[TabPages[i].ImageIndex], new Point(textrectangle.Location.X + 8, textrectangle.Location.Y + 6));
  553.                             G.DrawString("      " + TabPages[i].Text, Font, Brushes.DimGray, textrectangle, new StringFormat
  554.                             {
  555.                                 LineAlignment = StringAlignment.Center,
  556.                                 Alignment = StringAlignment.Near
  557.                             });
  558.                         }
  559.                         else
  560.                         {
  561.                             G.DrawString(TabPages[i].Text, Font, Brushes.DimGray, textrectangle, new StringFormat
  562.                             {
  563.                                 LineAlignment = StringAlignment.Center,
  564.                                 Alignment = StringAlignment.Near
  565.                             });
  566.                         }
  567.                     }
  568.                     catch
  569.                     {
  570.                         G.DrawString(TabPages[i].Text, Font, Brushes.DimGray, textrectangle, new StringFormat
  571.                         {
  572.                             LineAlignment = StringAlignment.Center,
  573.                             Alignment = StringAlignment.Near
  574.                         });
  575.                     }
  576.                 }
  577.                 else
  578.                 {
  579.                     G.DrawString(TabPages[i].Text, Font, Brushes.DimGray, textrectangle, new StringFormat
  580.                     {
  581.                         LineAlignment = StringAlignment.Center,
  582.                         Alignment = StringAlignment.Near
  583.                     });
  584.                 }
  585.             }
  586.         }
  587.  
  588.         e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  589.         G.Dispose();
  590.         B.Dispose();
  591.     }
  592. }
  593.  
  594. //------------------
  595. //Creator: aeonhack
  596. //Site: elitevs.net
  597. //Created: 08/02/2011
  598. //Changed: 12/06/2011
  599. //Version: 1.5.4
  600. //------------------
  601. abstract class ThemeContainer154 : ContainerControl
  602. {
  603.  
  604.     #region " Initialization "
  605.  
  606.     protected Graphics G;
  607.  
  608.     protected Bitmap B;
  609.     public ThemeContainer154()
  610.     {
  611.         SetStyle((ControlStyles)139270, true);
  612.  
  613.         _ImageSize = Size.Empty;
  614.         Font = new Font("Verdana", 8);
  615.  
  616.         MeasureBitmap = new Bitmap(1, 1);
  617.         MeasureGraphics = Graphics.FromImage(MeasureBitmap);
  618.  
  619.         DrawRadialPath = new GraphicsPath();
  620.  
  621.         InvalidateCustimization();
  622.     }
  623.  
  624.     protected override sealed void OnHandleCreated(EventArgs e)
  625.     {
  626.         if (DoneCreation)
  627.             InitializeMessages();
  628.  
  629.         InvalidateCustimization();
  630.         ColorHook();
  631.  
  632.         if (!(_LockWidth == 0))
  633.             Width = _LockWidth;
  634.         if (!(_LockHeight == 0))
  635.             Height = _LockHeight;
  636.         if (!_ControlMode)
  637.             base.Dock = DockStyle.Fill;
  638.  
  639.         Transparent = _Transparent;
  640.         if (_Transparent && _BackColor)
  641.             BackColor = Color.Transparent;
  642.  
  643.         base.OnHandleCreated(e);
  644.     }
  645.  
  646.     private bool DoneCreation;
  647.     protected override sealed void OnParentChanged(EventArgs e)
  648.     {
  649.         base.OnParentChanged(e);
  650.  
  651.         if (Parent == null)
  652.             return;
  653.         _IsParentForm = Parent is Form;
  654.  
  655.         if (!_ControlMode)
  656.         {
  657.             InitializeMessages();
  658.  
  659.             if (_IsParentForm)
  660.             {
  661.                 ParentForm.FormBorderStyle = _BorderStyle;
  662.                 ParentForm.TransparencyKey = _TransparencyKey;
  663.  
  664.                 if (!DesignMode)
  665.                 {
  666.                     ParentForm.Shown += FormShown;
  667.                 }
  668.             }
  669.  
  670.             Parent.BackColor = BackColor;
  671.         }
  672.  
  673.         OnCreation();
  674.         DoneCreation = true;
  675.         InvalidateTimer();
  676.     }
  677.  
  678.     #endregion
  679.  
  680.     private void DoAnimation(bool i)
  681.     {
  682.         OnAnimation();
  683.         if (i)
  684.             Invalidate();
  685.     }
  686.  
  687.     protected override sealed void OnPaint(PaintEventArgs e)
  688.     {
  689.         if (Width == 0 || Height == 0)
  690.             return;
  691.  
  692.         if (_Transparent && _ControlMode)
  693.         {
  694.             PaintHook();
  695.             e.Graphics.DrawImage(B, 0, 0);
  696.         }
  697.         else
  698.         {
  699.             G = e.Graphics;
  700.             PaintHook();
  701.         }
  702.     }
  703.  
  704.     protected override void OnHandleDestroyed(EventArgs e)
  705.     {
  706.         ThemeShare.RemoveAnimationCallback(DoAnimation);
  707.         base.OnHandleDestroyed(e);
  708.     }
  709.  
  710.     private bool HasShown;
  711.     private void FormShown(object sender, EventArgs e)
  712.     {
  713.         if (_ControlMode || HasShown)
  714.             return;
  715.  
  716.         if (_StartPosition == FormStartPosition.CenterParent || _StartPosition == FormStartPosition.CenterScreen)
  717.         {
  718.             Rectangle SB = Screen.PrimaryScreen.Bounds;
  719.             Rectangle CB = ParentForm.Bounds;
  720.             ParentForm.Location = new Point(SB.Width / 2 - CB.Width / 2, SB.Height / 2 - CB.Width / 2);
  721.         }
  722.  
  723.         HasShown = true;
  724.     }
  725.  
  726.  
  727.     #region " Size Handling "
  728.  
  729.     private Rectangle Frame;
  730.     protected override sealed void OnSizeChanged(EventArgs e)
  731.     {
  732.         if (_Movable && !_ControlMode)
  733.         {
  734.             Frame = new Rectangle(7, 7, Width - 14, _Header - 7);
  735.         }
  736.  
  737.         InvalidateBitmap();
  738.         Invalidate();
  739.  
  740.         base.OnSizeChanged(e);
  741.     }
  742.  
  743.     protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
  744.     {
  745.         if (!(_LockWidth == 0))
  746.             width = _LockWidth;
  747.         if (!(_LockHeight == 0))
  748.             height = _LockHeight;
  749.         base.SetBoundsCore(x, y, width, height, specified);
  750.     }
  751.  
  752.     #endregion
  753.  
  754.     #region " State Handling "
  755.  
  756.     protected MouseState State;
  757.     private void SetState(MouseState current)
  758.     {
  759.         State = current;
  760.         Invalidate();
  761.     }
  762.  
  763.     protected override void OnMouseMove(MouseEventArgs e)
  764.     {
  765.         if (!(_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized))
  766.         {
  767.             if (_Sizable && !_ControlMode)
  768.                 InvalidateMouse();
  769.         }
  770.  
  771.         base.OnMouseMove(e);
  772.     }
  773.  
  774.     protected override void OnEnabledChanged(EventArgs e)
  775.     {
  776.         if (Enabled)
  777.             SetState(MouseState.None);
  778.         else
  779.             SetState(MouseState.Block);
  780.         base.OnEnabledChanged(e);
  781.     }
  782.  
  783.     protected override void OnMouseEnter(EventArgs e)
  784.     {
  785.         SetState(MouseState.Over);
  786.         base.OnMouseEnter(e);
  787.     }
  788.  
  789.     protected override void OnMouseUp(MouseEventArgs e)
  790.     {
  791.         SetState(MouseState.Over);
  792.         base.OnMouseUp(e);
  793.     }
  794.  
  795.     protected override void OnMouseLeave(EventArgs e)
  796.     {
  797.         SetState(MouseState.None);
  798.  
  799.         if (GetChildAtPoint(PointToClient(MousePosition)) != null)
  800.         {
  801.             if (_Sizable && !_ControlMode)
  802.             {
  803.                 Cursor = Cursors.Default;
  804.                 Previous = 0;
  805.             }
  806.         }
  807.  
  808.         base.OnMouseLeave(e);
  809.     }
  810.  
  811.     protected override void OnMouseDown(MouseEventArgs e)
  812.     {
  813.         if (e.Button == System.Windows.Forms.MouseButtons.Left)
  814.             SetState(MouseState.Down);
  815.  
  816.         if (!(_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized || _ControlMode))
  817.         {
  818.             if (_Movable && Frame.Contains(e.Location))
  819.             {
  820.                 if (!new Rectangle(Width - 22, 5, 15, 15).Contains(e.Location))
  821.                 {
  822.                     Capture = false;
  823.                 }
  824.                 WM_LMBUTTONDOWN = true;
  825.                 DefWndProc(ref Messages[0]);
  826.             }
  827.             else if (_Sizable && !(Previous == 0))
  828.             {
  829.                 Capture = false;
  830.                 WM_LMBUTTONDOWN = true;
  831.                 DefWndProc(ref Messages[Previous]);
  832.             }
  833.         }
  834.  
  835.         base.OnMouseDown(e);
  836.     }
  837.  
  838.     private bool WM_LMBUTTONDOWN;
  839.     protected override void WndProc(ref Message m)
  840.     {
  841.         base.WndProc(ref m);
  842.  
  843.         if (WM_LMBUTTONDOWN && m.Msg == 513)
  844.         {
  845.             WM_LMBUTTONDOWN = false;
  846.  
  847.             SetState(MouseState.Over);
  848.             if (!_SmartBounds)
  849.                 return;
  850.  
  851.             if (IsParentMdi)
  852.             {
  853.                 CorrectBounds(new Rectangle(Point.Empty, Parent.Parent.Size));
  854.             }
  855.             else
  856.             {
  857.                 CorrectBounds(Screen.FromControl(Parent).WorkingArea);
  858.             }
  859.         }
  860.     }
  861.  
  862.     private Point GetIndexPoint;
  863.     private bool B1;
  864.     private bool B2;
  865.     private bool B3;
  866.     private bool B4;
  867.     private int GetIndex()
  868.     {
  869.         GetIndexPoint = PointToClient(MousePosition);
  870.         B1 = GetIndexPoint.X < 7;
  871.         B2 = GetIndexPoint.X > Width - 7;
  872.         B3 = GetIndexPoint.Y < 7;
  873.         B4 = GetIndexPoint.Y > Height - 7;
  874.  
  875.         if (B1 && B3)
  876.             return 4;
  877.         if (B1 && B4)
  878.             return 7;
  879.         if (B2 && B3)
  880.             return 5;
  881.         if (B2 && B4)
  882.             return 8;
  883.         if (B1)
  884.             return 1;
  885.         if (B2)
  886.             return 2;
  887.         if (B3)
  888.             return 3;
  889.         if (B4)
  890.             return 6;
  891.         return 0;
  892.     }
  893.  
  894.     private int Current;
  895.     private int Previous;
  896.     private void InvalidateMouse()
  897.     {
  898.         Current = GetIndex();
  899.         if (Current == Previous)
  900.             return;
  901.  
  902.         Previous = Current;
  903.         switch (Previous)
  904.         {
  905.             case 0:
  906.                 Cursor = Cursors.Default;
  907.                 break;
  908.             case 1:
  909.             case 2:
  910.                 Cursor = Cursors.SizeWE;
  911.                 break;
  912.             case 3:
  913.             case 6:
  914.                 Cursor = Cursors.SizeNS;
  915.                 break;
  916.             case 4:
  917.             case 8:
  918.                 Cursor = Cursors.SizeNWSE;
  919.                 break;
  920.             case 5:
  921.             case 7:
  922.                 Cursor = Cursors.SizeNESW;
  923.                 break;
  924.         }
  925.     }
  926.  
  927.     private Message[] Messages = new Message[9];
  928.     private void InitializeMessages()
  929.     {
  930.         Messages[0] = Message.Create(Parent.Handle, 161, new IntPtr(2), IntPtr.Zero);
  931.         for (int I = 1; I <= 8; I++)
  932.         {
  933.             Messages[I] = Message.Create(Parent.Handle, 161, new IntPtr(I + 9), IntPtr.Zero);
  934.         }
  935.     }
  936.  
  937.     private void CorrectBounds(Rectangle bounds)
  938.     {
  939.         if (Parent.Width > bounds.Width)
  940.             Parent.Width = bounds.Width;
  941.         if (Parent.Height > bounds.Height)
  942.             Parent.Height = bounds.Height;
  943.  
  944.         int X = Parent.Location.X;
  945.         int Y = Parent.Location.Y;
  946.  
  947.         if (X < bounds.X)
  948.             X = bounds.X;
  949.         if (Y < bounds.Y)
  950.             Y = bounds.Y;
  951.  
  952.         int Width = bounds.X + bounds.Width;
  953.         int Height = bounds.Y + bounds.Height;
  954.  
  955.         if (X + Parent.Width > Width)
  956.             X = Width - Parent.Width;
  957.         if (Y + Parent.Height > Height)
  958.             Y = Height - Parent.Height;
  959.  
  960.         Parent.Location = new Point(X, Y);
  961.     }
  962.  
  963.     #endregion
  964.  
  965.  
  966.     #region " Base Properties "
  967.  
  968.     public override DockStyle Dock
  969.     {
  970.         get { return base.Dock; }
  971.         set
  972.         {
  973.             if (!_ControlMode)
  974.                 return;
  975.             base.Dock = value;
  976.         }
  977.     }
  978.  
  979.     private bool _BackColor;
  980.     [Category("Misc")]
  981.     public override Color BackColor
  982.     {
  983.         get { return base.BackColor; }
  984.         set
  985.         {
  986.             if (value == base.BackColor)
  987.                 return;
  988.  
  989.             if (!IsHandleCreated && _ControlMode && value == Color.Transparent)
  990.             {
  991.                 _BackColor = true;
  992.                 return;
  993.             }
  994.  
  995.             base.BackColor = value;
  996.             if (Parent != null)
  997.             {
  998.                 if (!_ControlMode)
  999.                     Parent.BackColor = value;
  1000.                 ColorHook();
  1001.             }
  1002.         }
  1003.     }
  1004.  
  1005.     public override Size MinimumSize
  1006.     {
  1007.         get { return base.MinimumSize; }
  1008.         set
  1009.         {
  1010.             base.MinimumSize = value;
  1011.             if (Parent != null)
  1012.                 Parent.MinimumSize = value;
  1013.         }
  1014.     }
  1015.  
  1016.     public override Size MaximumSize
  1017.     {
  1018.         get { return base.MaximumSize; }
  1019.         set
  1020.         {
  1021.             base.MaximumSize = value;
  1022.             if (Parent != null)
  1023.                 Parent.MaximumSize = value;
  1024.         }
  1025.     }
  1026.  
  1027.     public override string Text
  1028.     {
  1029.         get { return base.Text; }
  1030.         set
  1031.         {
  1032.             base.Text = value;
  1033.             Invalidate();
  1034.         }
  1035.     }
  1036.  
  1037.     public override Font Font
  1038.     {
  1039.         get { return base.Font; }
  1040.         set
  1041.         {
  1042.             base.Font = value;
  1043.             Invalidate();
  1044.         }
  1045.     }
  1046.  
  1047.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1048.     public override Color ForeColor
  1049.     {
  1050.         get { return Color.Empty; }
  1051.         set { }
  1052.     }
  1053.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1054.     public override Image BackgroundImage
  1055.     {
  1056.         get { return null; }
  1057.         set { }
  1058.     }
  1059.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1060.     public override ImageLayout BackgroundImageLayout
  1061.     {
  1062.         get { return ImageLayout.None; }
  1063.         set { }
  1064.     }
  1065.  
  1066.     #endregion
  1067.  
  1068.     #region " Public Properties "
  1069.  
  1070.     private bool _SmartBounds = true;
  1071.     public bool SmartBounds
  1072.     {
  1073.         get { return _SmartBounds; }
  1074.         set { _SmartBounds = value; }
  1075.     }
  1076.  
  1077.     private bool _Movable = true;
  1078.     public bool Movable
  1079.     {
  1080.         get { return _Movable; }
  1081.         set { _Movable = value; }
  1082.     }
  1083.  
  1084.     private bool _Sizable = true;
  1085.     public bool Sizable
  1086.     {
  1087.         get { return _Sizable; }
  1088.         set { _Sizable = value; }
  1089.     }
  1090.  
  1091.     private Color _TransparencyKey;
  1092.     public Color TransparencyKey
  1093.     {
  1094.         get
  1095.         {
  1096.             if (_IsParentForm && !_ControlMode)
  1097.                 return ParentForm.TransparencyKey;
  1098.             else
  1099.                 return _TransparencyKey;
  1100.         }
  1101.         set
  1102.         {
  1103.             if (value == _TransparencyKey)
  1104.                 return;
  1105.             _TransparencyKey = value;
  1106.  
  1107.             if (_IsParentForm && !_ControlMode)
  1108.             {
  1109.                 ParentForm.TransparencyKey = value;
  1110.                 ColorHook();
  1111.             }
  1112.         }
  1113.     }
  1114.  
  1115.     private FormBorderStyle _BorderStyle;
  1116.     public FormBorderStyle BorderStyle
  1117.     {
  1118.         get
  1119.         {
  1120.             if (_IsParentForm && !_ControlMode)
  1121.                 return ParentForm.FormBorderStyle;
  1122.             else
  1123.                 return _BorderStyle;
  1124.         }
  1125.         set
  1126.         {
  1127.             _BorderStyle = value;
  1128.  
  1129.             if (_IsParentForm && !_ControlMode)
  1130.             {
  1131.                 ParentForm.FormBorderStyle = value;
  1132.  
  1133.                 if (!(value == FormBorderStyle.None))
  1134.                 {
  1135.                     Movable = false;
  1136.                     Sizable = false;
  1137.                 }
  1138.             }
  1139.         }
  1140.     }
  1141.  
  1142.     private FormStartPosition _StartPosition;
  1143.     public FormStartPosition StartPosition
  1144.     {
  1145.         get
  1146.         {
  1147.             if (_IsParentForm && !_ControlMode)
  1148.                 return ParentForm.StartPosition;
  1149.             else
  1150.                 return _StartPosition;
  1151.         }
  1152.         set
  1153.         {
  1154.             _StartPosition = value;
  1155.  
  1156.             if (_IsParentForm && !_ControlMode)
  1157.             {
  1158.                 ParentForm.StartPosition = value;
  1159.             }
  1160.         }
  1161.     }
  1162.  
  1163.     private bool _NoRounding;
  1164.     public bool NoRounding
  1165.     {
  1166.         get { return _NoRounding; }
  1167.         set
  1168.         {
  1169.             _NoRounding = value;
  1170.             Invalidate();
  1171.         }
  1172.     }
  1173.  
  1174.     private Image _Image;
  1175.     public Image Image
  1176.     {
  1177.         get { return _Image; }
  1178.         set
  1179.         {
  1180.             if (value == null)
  1181.                 _ImageSize = Size.Empty;
  1182.             else
  1183.                 _ImageSize = value.Size;
  1184.  
  1185.             _Image = value;
  1186.             Invalidate();
  1187.         }
  1188.     }
  1189.  
  1190.     private Dictionary<string, Color> Items = new Dictionary<string, Color>();
  1191.     public Bloom[] Colors
  1192.     {
  1193.         get
  1194.         {
  1195.             List<Bloom> T = new List<Bloom>();
  1196.             Dictionary<string, Color>.Enumerator E = Items.GetEnumerator();
  1197.  
  1198.             while (E.MoveNext())
  1199.             {
  1200.                 T.Add(new Bloom(E.Current.Key, E.Current.Value));
  1201.             }
  1202.  
  1203.             return T.ToArray();
  1204.         }
  1205.         set
  1206.         {
  1207.             foreach (Bloom B in value)
  1208.             {
  1209.                 if (Items.ContainsKey(B.Name))
  1210.                     Items[B.Name] = B.Value;
  1211.             }
  1212.  
  1213.             InvalidateCustimization();
  1214.             ColorHook();
  1215.             Invalidate();
  1216.         }
  1217.     }
  1218.  
  1219.     private string _Customization;
  1220.     public string Customization
  1221.     {
  1222.         get { return _Customization; }
  1223.         set
  1224.         {
  1225.             if (value == _Customization)
  1226.                 return;
  1227.  
  1228.             byte[] Data = null;
  1229.             Bloom[] Items = Colors;
  1230.  
  1231.             try
  1232.             {
  1233.                 Data = Convert.FromBase64String(value);
  1234.                 for (int I = 0; I <= Items.Length - 1; I++)
  1235.                 {
  1236.                     Items[I].Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4));
  1237.                 }
  1238.             }
  1239.             catch
  1240.             {
  1241.                 return;
  1242.             }
  1243.  
  1244.             _Customization = value;
  1245.  
  1246.             Colors = Items;
  1247.             ColorHook();
  1248.             Invalidate();
  1249.         }
  1250.     }
  1251.  
  1252.     private bool _Transparent;
  1253.     public bool Transparent
  1254.     {
  1255.         get { return _Transparent; }
  1256.         set
  1257.         {
  1258.             _Transparent = value;
  1259.             if (!(IsHandleCreated || _ControlMode))
  1260.                 return;
  1261.  
  1262.             if (!value && !(BackColor.A == 255))
  1263.             {
  1264.                 throw new Exception("Unable to change value to false while a transparent BackColor is in use.");
  1265.             }
  1266.  
  1267.             SetStyle(ControlStyles.Opaque, !value);
  1268.             SetStyle(ControlStyles.SupportsTransparentBackColor, value);
  1269.  
  1270.             InvalidateBitmap();
  1271.             Invalidate();
  1272.         }
  1273.     }
  1274.  
  1275.     #endregion
  1276.  
  1277.     #region " Private Properties "
  1278.  
  1279.     private Size _ImageSize;
  1280.     protected Size ImageSize
  1281.     {
  1282.         get { return _ImageSize; }
  1283.     }
  1284.  
  1285.     private bool _IsParentForm;
  1286.     protected bool IsParentForm
  1287.     {
  1288.         get { return _IsParentForm; }
  1289.     }
  1290.  
  1291.     protected bool IsParentMdi
  1292.     {
  1293.         get
  1294.         {
  1295.             if (Parent == null)
  1296.                 return false;
  1297.             return Parent.Parent != null;
  1298.         }
  1299.     }
  1300.  
  1301.     private int _LockWidth;
  1302.     protected int LockWidth
  1303.     {
  1304.         get { return _LockWidth; }
  1305.         set
  1306.         {
  1307.             _LockWidth = value;
  1308.             if (!(LockWidth == 0) && IsHandleCreated)
  1309.                 Width = LockWidth;
  1310.         }
  1311.     }
  1312.  
  1313.     private int _LockHeight;
  1314.     protected int LockHeight
  1315.     {
  1316.         get { return _LockHeight; }
  1317.         set
  1318.         {
  1319.             _LockHeight = value;
  1320.             if (!(LockHeight == 0) && IsHandleCreated)
  1321.                 Height = LockHeight;
  1322.         }
  1323.     }
  1324.  
  1325.     private int _Header = 24;
  1326.     protected int Header
  1327.     {
  1328.         get { return _Header; }
  1329.         set
  1330.         {
  1331.             _Header = value;
  1332.  
  1333.             if (!_ControlMode)
  1334.             {
  1335.                 Frame = new Rectangle(7, 7, Width - 14, value - 7);
  1336.                 Invalidate();
  1337.             }
  1338.         }
  1339.     }
  1340.  
  1341.     private bool _ControlMode;
  1342.     protected bool ControlMode
  1343.     {
  1344.         get { return _ControlMode; }
  1345.         set
  1346.         {
  1347.             _ControlMode = value;
  1348.  
  1349.             Transparent = _Transparent;
  1350.             if (_Transparent && _BackColor)
  1351.                 BackColor = Color.Transparent;
  1352.  
  1353.             InvalidateBitmap();
  1354.             Invalidate();
  1355.         }
  1356.     }
  1357.  
  1358.     private bool _IsAnimated;
  1359.     protected bool IsAnimated
  1360.     {
  1361.         get { return _IsAnimated; }
  1362.         set
  1363.         {
  1364.             _IsAnimated = value;
  1365.             InvalidateTimer();
  1366.         }
  1367.     }
  1368.  
  1369.     #endregion
  1370.  
  1371.  
  1372.     #region " Property Helpers "
  1373.  
  1374.     protected Pen GetPen(string name)
  1375.     {
  1376.         return new Pen(Items[name]);
  1377.     }
  1378.     protected Pen GetPen(string name, float width)
  1379.     {
  1380.         return new Pen(Items[name], width);
  1381.     }
  1382.  
  1383.     protected SolidBrush GetBrush(string name)
  1384.     {
  1385.         return new SolidBrush(Items[name]);
  1386.     }
  1387.  
  1388.     protected Color GetColor(string name)
  1389.     {
  1390.         return Items[name];
  1391.     }
  1392.  
  1393.     protected void SetColor(string name, Color value)
  1394.     {
  1395.         if (Items.ContainsKey(name))
  1396.             Items[name] = value;
  1397.         else
  1398.             Items.Add(name, value);
  1399.     }
  1400.     protected void SetColor(string name, byte r, byte g, byte b)
  1401.     {
  1402.         SetColor(name, Color.FromArgb(r, g, b));
  1403.     }
  1404.     protected void SetColor(string name, byte a, byte r, byte g, byte b)
  1405.     {
  1406.         SetColor(name, Color.FromArgb(a, r, g, b));
  1407.     }
  1408.     protected void SetColor(string name, byte a, Color value)
  1409.     {
  1410.         SetColor(name, Color.FromArgb(a, value));
  1411.     }
  1412.  
  1413.     private void InvalidateBitmap()
  1414.     {
  1415.         if (_Transparent && _ControlMode)
  1416.         {
  1417.             if (Width == 0 || Height == 0)
  1418.                 return;
  1419.             B = new Bitmap(Width, Height, PixelFormat.Format32bppPArgb);
  1420.             G = Graphics.FromImage(B);
  1421.         }
  1422.         else
  1423.         {
  1424.             G = null;
  1425.             B = null;
  1426.         }
  1427.     }
  1428.  
  1429.     private void InvalidateCustimization()
  1430.     {
  1431.         MemoryStream M = new MemoryStream(Items.Count * 4);
  1432.  
  1433.         foreach (Bloom B in Colors)
  1434.         {
  1435.             M.Write(BitConverter.GetBytes(B.Value.ToArgb()), 0, 4);
  1436.         }
  1437.  
  1438.         M.Close();
  1439.         _Customization = Convert.ToBase64String(M.ToArray());
  1440.     }
  1441.  
  1442.     private void InvalidateTimer()
  1443.     {
  1444.         if (DesignMode || !DoneCreation)
  1445.             return;
  1446.  
  1447.         if (_IsAnimated)
  1448.         {
  1449.             ThemeShare.AddAnimationCallback(DoAnimation);
  1450.         }
  1451.         else
  1452.         {
  1453.             ThemeShare.RemoveAnimationCallback(DoAnimation);
  1454.         }
  1455.     }
  1456.  
  1457.     #endregion
  1458.  
  1459.  
  1460.     #region " User Hooks "
  1461.  
  1462.     protected abstract void ColorHook();
  1463.     protected abstract void PaintHook();
  1464.  
  1465.     protected virtual void OnCreation()
  1466.     {
  1467.     }
  1468.  
  1469.     protected virtual void OnAnimation()
  1470.     {
  1471.     }
  1472.  
  1473.     #endregion
  1474.  
  1475.  
  1476.     #region " Offset "
  1477.  
  1478.     private Rectangle OffsetReturnRectangle;
  1479.     protected Rectangle Offset(Rectangle r, int amount)
  1480.     {
  1481.         OffsetReturnRectangle = new Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2));
  1482.         return OffsetReturnRectangle;
  1483.     }
  1484.  
  1485.     private Size OffsetReturnSize;
  1486.     protected Size Offset(Size s, int amount)
  1487.     {
  1488.         OffsetReturnSize = new Size(s.Width + amount, s.Height + amount);
  1489.         return OffsetReturnSize;
  1490.     }
  1491.  
  1492.     private Point OffsetReturnPoint;
  1493.     protected Point Offset(Point p, int amount)
  1494.     {
  1495.         OffsetReturnPoint = new Point(p.X + amount, p.Y + amount);
  1496.         return OffsetReturnPoint;
  1497.     }
  1498.  
  1499.     #endregion
  1500.  
  1501.     #region " Center "
  1502.  
  1503.  
  1504.     private Point CenterReturn;
  1505.     protected Point Center(Rectangle p, Rectangle c)
  1506.     {
  1507.         CenterReturn = new Point((p.Width / 2 - c.Width / 2) + p.X + c.X, (p.Height / 2 - c.Height / 2) + p.Y + c.Y);
  1508.         return CenterReturn;
  1509.     }
  1510.     protected Point Center(Rectangle p, Size c)
  1511.     {
  1512.         CenterReturn = new Point((p.Width / 2 - c.Width / 2) + p.X, (p.Height / 2 - c.Height / 2) + p.Y);
  1513.         return CenterReturn;
  1514.     }
  1515.  
  1516.     protected Point Center(Rectangle child)
  1517.     {
  1518.         return Center(Width, Height, child.Width, child.Height);
  1519.     }
  1520.     protected Point Center(Size child)
  1521.     {
  1522.         return Center(Width, Height, child.Width, child.Height);
  1523.     }
  1524.     protected Point Center(int childWidth, int childHeight)
  1525.     {
  1526.         return Center(Width, Height, childWidth, childHeight);
  1527.     }
  1528.  
  1529.     protected Point Center(Size p, Size c)
  1530.     {
  1531.         return Center(p.Width, p.Height, c.Width, c.Height);
  1532.     }
  1533.  
  1534.     protected Point Center(int pWidth, int pHeight, int cWidth, int cHeight)
  1535.     {
  1536.         CenterReturn = new Point(pWidth / 2 - cWidth / 2, pHeight / 2 - cHeight / 2);
  1537.         return CenterReturn;
  1538.     }
  1539.  
  1540.     #endregion
  1541.  
  1542.     #region " Measure "
  1543.  
  1544.     private Bitmap MeasureBitmap;
  1545.  
  1546.     private Graphics MeasureGraphics;
  1547.     protected Size Measure()
  1548.     {
  1549.         lock (MeasureGraphics)
  1550.         {
  1551.             return MeasureGraphics.MeasureString(Text, Font, Width).ToSize();
  1552.         }
  1553.     }
  1554.     protected Size Measure(string text)
  1555.     {
  1556.         lock (MeasureGraphics)
  1557.         {
  1558.             return MeasureGraphics.MeasureString(text, Font, Width).ToSize();
  1559.         }
  1560.     }
  1561.  
  1562.     #endregion
  1563.  
  1564.  
  1565.     #region " DrawPixel "
  1566.  
  1567.  
  1568.     private SolidBrush DrawPixelBrush;
  1569.     protected void DrawPixel(Color c1, int x, int y)
  1570.     {
  1571.         if (_Transparent)
  1572.         {
  1573.             B.SetPixel(x, y, c1);
  1574.         }
  1575.         else
  1576.         {
  1577.             DrawPixelBrush = new SolidBrush(c1);
  1578.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1);
  1579.         }
  1580.     }
  1581.  
  1582.     #endregion
  1583.  
  1584.     #region " DrawCorners "
  1585.  
  1586.  
  1587.     private SolidBrush DrawCornersBrush;
  1588.     protected void DrawCorners(Color c1, int offset)
  1589.     {
  1590.         DrawCorners(c1, 0, 0, Width, Height, offset);
  1591.     }
  1592.     protected void DrawCorners(Color c1, Rectangle r1, int offset)
  1593.     {
  1594.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset);
  1595.     }
  1596.     protected void DrawCorners(Color c1, int x, int y, int width, int height, int offset)
  1597.     {
  1598.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
  1599.     }
  1600.  
  1601.     protected void DrawCorners(Color c1)
  1602.     {
  1603.         DrawCorners(c1, 0, 0, Width, Height);
  1604.     }
  1605.     protected void DrawCorners(Color c1, Rectangle r1)
  1606.     {
  1607.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height);
  1608.     }
  1609.     protected void DrawCorners(Color c1, int x, int y, int width, int height)
  1610.     {
  1611.         if (_NoRounding)
  1612.             return;
  1613.  
  1614.         if (_Transparent)
  1615.         {
  1616.             B.SetPixel(x, y, c1);
  1617.             B.SetPixel(x + (width - 1), y, c1);
  1618.             B.SetPixel(x, y + (height - 1), c1);
  1619.             B.SetPixel(x + (width - 1), y + (height - 1), c1);
  1620.         }
  1621.         else
  1622.         {
  1623.             DrawCornersBrush = new SolidBrush(c1);
  1624.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1);
  1625.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1);
  1626.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1);
  1627.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1);
  1628.         }
  1629.     }
  1630.  
  1631.     #endregion
  1632.  
  1633.     #region " DrawBorders "
  1634.  
  1635.     protected void DrawBorders(Pen p1, int offset)
  1636.     {
  1637.         DrawBorders(p1, 0, 0, Width, Height, offset);
  1638.     }
  1639.     protected void DrawBorders(Pen p1, Rectangle r, int offset)
  1640.     {
  1641.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset);
  1642.     }
  1643.     protected void DrawBorders(Pen p1, int x, int y, int width, int height, int offset)
  1644.     {
  1645.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
  1646.     }
  1647.  
  1648.     protected void DrawBorders(Pen p1)
  1649.     {
  1650.         DrawBorders(p1, 0, 0, Width, Height);
  1651.     }
  1652.     protected void DrawBorders(Pen p1, Rectangle r)
  1653.     {
  1654.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height);
  1655.     }
  1656.     protected void DrawBorders(Pen p1, int x, int y, int width, int height)
  1657.     {
  1658.         G.DrawRectangle(p1, x, y, width - 1, height - 1);
  1659.     }
  1660.  
  1661.     #endregion
  1662.  
  1663.     #region " DrawText "
  1664.  
  1665.     private Point DrawTextPoint;
  1666.  
  1667.     private Size DrawTextSize;
  1668.     protected void DrawText(Brush b1, HorizontalAlignment a, int x, int y)
  1669.     {
  1670.         DrawText(b1, Text, a, x, y);
  1671.     }
  1672.     protected void DrawText(Brush b1, string text, HorizontalAlignment a, int x, int y)
  1673.     {
  1674.         if (text.Length == 0)
  1675.             return;
  1676.  
  1677.         DrawTextSize = Measure(text);
  1678.         DrawTextPoint = new Point(Width / 2 - DrawTextSize.Width / 2, Header / 2 - DrawTextSize.Height / 2);
  1679.  
  1680.         switch (a)
  1681.         {
  1682.             case HorizontalAlignment.Left:
  1683.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y);
  1684.                 break;
  1685.             case HorizontalAlignment.Center:
  1686.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y);
  1687.                 break;
  1688.             case HorizontalAlignment.Right:
  1689.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y);
  1690.                 break;
  1691.         }
  1692.     }
  1693.  
  1694.     protected void DrawText(Brush b1, Point p1)
  1695.     {
  1696.         if (Text.Length == 0)
  1697.             return;
  1698.         G.DrawString(Text, Font, b1, p1);
  1699.     }
  1700.     protected void DrawText(Brush b1, int x, int y)
  1701.     {
  1702.         if (Text.Length == 0)
  1703.             return;
  1704.         G.DrawString(Text, Font, b1, x, y);
  1705.     }
  1706.  
  1707.     #endregion
  1708.  
  1709.     #region " DrawImage "
  1710.  
  1711.  
  1712.     private Point DrawImagePoint;
  1713.     protected void DrawImage(HorizontalAlignment a, int x, int y)
  1714.     {
  1715.         DrawImage(_Image, a, x, y);
  1716.     }
  1717.     protected void DrawImage(Image image, HorizontalAlignment a, int x, int y)
  1718.     {
  1719.         if (image == null)
  1720.             return;
  1721.         DrawImagePoint = new Point(Width / 2 - image.Width / 2, Header / 2 - image.Height / 2);
  1722.  
  1723.         switch (a)
  1724.         {
  1725.             case HorizontalAlignment.Left:
  1726.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height);
  1727.                 break;
  1728.             case HorizontalAlignment.Center:
  1729.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height);
  1730.                 break;
  1731.             case HorizontalAlignment.Right:
  1732.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height);
  1733.                 break;
  1734.         }
  1735.     }
  1736.  
  1737.     protected void DrawImage(Point p1)
  1738.     {
  1739.         DrawImage(_Image, p1.X, p1.Y);
  1740.     }
  1741.     protected void DrawImage(int x, int y)
  1742.     {
  1743.         DrawImage(_Image, x, y);
  1744.     }
  1745.  
  1746.     protected void DrawImage(Image image, Point p1)
  1747.     {
  1748.         DrawImage(image, p1.X, p1.Y);
  1749.     }
  1750.     protected void DrawImage(Image image, int x, int y)
  1751.     {
  1752.         if (image == null)
  1753.             return;
  1754.         G.DrawImage(image, x, y, image.Width, image.Height);
  1755.     }
  1756.  
  1757.     #endregion
  1758.  
  1759.     #region " DrawGradient "
  1760.  
  1761.     private LinearGradientBrush DrawGradientBrush;
  1762.  
  1763.     private Rectangle DrawGradientRectangle;
  1764.     protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height)
  1765.     {
  1766.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  1767.         DrawGradient(blend, DrawGradientRectangle);
  1768.     }
  1769.     protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height, float angle)
  1770.     {
  1771.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  1772.         DrawGradient(blend, DrawGradientRectangle, angle);
  1773.     }
  1774.  
  1775.     protected void DrawGradient(ColorBlend blend, Rectangle r)
  1776.     {
  1777.         DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, 90f);
  1778.         DrawGradientBrush.InterpolationColors = blend;
  1779.         G.FillRectangle(DrawGradientBrush, r);
  1780.     }
  1781.     protected void DrawGradient(ColorBlend blend, Rectangle r, float angle)
  1782.     {
  1783.         DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, angle);
  1784.         DrawGradientBrush.InterpolationColors = blend;
  1785.         G.FillRectangle(DrawGradientBrush, r);
  1786.     }
  1787.  
  1788.  
  1789.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height)
  1790.     {
  1791.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  1792.         DrawGradient(c1, c2, DrawGradientRectangle);
  1793.     }
  1794.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
  1795.     {
  1796.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  1797.         DrawGradient(c1, c2, DrawGradientRectangle, angle);
  1798.     }
  1799.  
  1800.     protected void DrawGradient(Color c1, Color c2, Rectangle r)
  1801.     {
  1802.         DrawGradientBrush = new LinearGradientBrush(r, c1, c2, 90f);
  1803.         G.FillRectangle(DrawGradientBrush, r);
  1804.     }
  1805.     protected void DrawGradient(Color c1, Color c2, Rectangle r, float angle)
  1806.     {
  1807.         DrawGradientBrush = new LinearGradientBrush(r, c1, c2, angle);
  1808.         G.FillRectangle(DrawGradientBrush, r);
  1809.     }
  1810.  
  1811.     #endregion
  1812.  
  1813.     #region " DrawRadial "
  1814.  
  1815.     private GraphicsPath DrawRadialPath;
  1816.     private PathGradientBrush DrawRadialBrush1;
  1817.     private LinearGradientBrush DrawRadialBrush2;
  1818.  
  1819.     private Rectangle DrawRadialRectangle;
  1820.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height)
  1821.     {
  1822.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  1823.         DrawRadial(blend, DrawRadialRectangle, width / 2, height / 2);
  1824.     }
  1825.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, Point center)
  1826.     {
  1827.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  1828.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y);
  1829.     }
  1830.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, int cx, int cy)
  1831.     {
  1832.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  1833.         DrawRadial(blend, DrawRadialRectangle, cx, cy);
  1834.     }
  1835.  
  1836.     public void DrawRadial(ColorBlend blend, Rectangle r)
  1837.     {
  1838.         DrawRadial(blend, r, r.Width / 2, r.Height / 2);
  1839.     }
  1840.     public void DrawRadial(ColorBlend blend, Rectangle r, Point center)
  1841.     {
  1842.         DrawRadial(blend, r, center.X, center.Y);
  1843.     }
  1844.     public void DrawRadial(ColorBlend blend, Rectangle r, int cx, int cy)
  1845.     {
  1846.         DrawRadialPath.Reset();
  1847.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1);
  1848.  
  1849.         DrawRadialBrush1 = new PathGradientBrush(DrawRadialPath);
  1850.         DrawRadialBrush1.CenterPoint = new Point(r.X + cx, r.Y + cy);
  1851.         DrawRadialBrush1.InterpolationColors = blend;
  1852.  
  1853.         if (G.SmoothingMode == SmoothingMode.AntiAlias)
  1854.         {
  1855.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3);
  1856.         }
  1857.         else
  1858.         {
  1859.             G.FillEllipse(DrawRadialBrush1, r);
  1860.         }
  1861.     }
  1862.  
  1863.  
  1864.     protected void DrawRadial(Color c1, Color c2, int x, int y, int width, int height)
  1865.     {
  1866.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  1867.         DrawRadial(c1, c2, DrawGradientRectangle);
  1868.     }
  1869.     protected void DrawRadial(Color c1, Color c2, int x, int y, int width, int height, float angle)
  1870.     {
  1871.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  1872.         DrawRadial(c1, c2, DrawGradientRectangle, angle);
  1873.     }
  1874.  
  1875.     protected void DrawRadial(Color c1, Color c2, Rectangle r)
  1876.     {
  1877.         DrawRadialBrush2 = new LinearGradientBrush(r, c1, c2, 90f);
  1878.         G.FillRectangle(DrawGradientBrush, r);
  1879.     }
  1880.     protected void DrawRadial(Color c1, Color c2, Rectangle r, float angle)
  1881.     {
  1882.         DrawRadialBrush2 = new LinearGradientBrush(r, c1, c2, angle);
  1883.         G.FillEllipse(DrawGradientBrush, r);
  1884.     }
  1885.  
  1886.     #endregion
  1887.  
  1888.     #region " CreateRound "
  1889.  
  1890.     private GraphicsPath CreateRoundPath;
  1891.  
  1892.     private Rectangle CreateRoundRectangle;
  1893.     public GraphicsPath CreateRound(int x, int y, int width, int height, int slope)
  1894.     {
  1895.         CreateRoundRectangle = new Rectangle(x, y, width, height);
  1896.         return CreateRound(CreateRoundRectangle, slope);
  1897.     }
  1898.  
  1899.     public GraphicsPath CreateRound(Rectangle r, int slope)
  1900.     {
  1901.         CreateRoundPath = new GraphicsPath(FillMode.Winding);
  1902.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180f, 90f);
  1903.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270f, 90f);
  1904.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0f, 90f);
  1905.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90f, 90f);
  1906.         CreateRoundPath.CloseFigure();
  1907.         return CreateRoundPath;
  1908.     }
  1909.  
  1910.     #endregion
  1911.  
  1912. }
  1913. abstract class ThemeControl154 : Control
  1914. {
  1915.  
  1916.  
  1917.     #region " Initialization "
  1918.  
  1919.     protected Graphics G;
  1920.  
  1921.     protected Bitmap B;
  1922.     public ThemeControl154()
  1923.     {
  1924.         SetStyle((ControlStyles)139270, true);
  1925.  
  1926.         _ImageSize = Size.Empty;
  1927.         Font = new Font("Verdana", 8);
  1928.  
  1929.         MeasureBitmap = new Bitmap(1, 1);
  1930.         MeasureGraphics = Graphics.FromImage(MeasureBitmap);
  1931.  
  1932.         DrawRadialPath = new GraphicsPath();
  1933.  
  1934.         InvalidateCustimization();
  1935.         //Remove?
  1936.     }
  1937.  
  1938.     protected override sealed void OnHandleCreated(EventArgs e)
  1939.     {
  1940.         InvalidateCustimization();
  1941.         ColorHook();
  1942.  
  1943.         if (!(_LockWidth == 0))
  1944.             Width = _LockWidth;
  1945.         if (!(_LockHeight == 0))
  1946.             Height = _LockHeight;
  1947.  
  1948.         Transparent = _Transparent;
  1949.         if (_Transparent && _BackColor)
  1950.             BackColor = Color.Transparent;
  1951.  
  1952.         base.OnHandleCreated(e);
  1953.     }
  1954.  
  1955.     private bool DoneCreation;
  1956.     protected override sealed void OnParentChanged(EventArgs e)
  1957.     {
  1958.         if (Parent != null)
  1959.         {
  1960.             OnCreation();
  1961.             DoneCreation = true;
  1962.             InvalidateTimer();
  1963.         }
  1964.  
  1965.         base.OnParentChanged(e);
  1966.     }
  1967.  
  1968.     #endregion
  1969.  
  1970.     private void DoAnimation(bool i)
  1971.     {
  1972.         OnAnimation();
  1973.         if (i)
  1974.             Invalidate();
  1975.     }
  1976.  
  1977.     protected override sealed void OnPaint(PaintEventArgs e)
  1978.     {
  1979.         if (Width == 0 || Height == 0)
  1980.             return;
  1981.  
  1982.         if (_Transparent)
  1983.         {
  1984.             PaintHook();
  1985.             e.Graphics.DrawImage(B, 0, 0);
  1986.         }
  1987.         else
  1988.         {
  1989.             G = e.Graphics;
  1990.             PaintHook();
  1991.         }
  1992.     }
  1993.  
  1994.     protected override void OnHandleDestroyed(EventArgs e)
  1995.     {
  1996.         ThemeShare.RemoveAnimationCallback(DoAnimation);
  1997.         base.OnHandleDestroyed(e);
  1998.     }
  1999.  
  2000.     #region " Size Handling "
  2001.  
  2002.     protected override sealed void OnSizeChanged(EventArgs e)
  2003.     {
  2004.         if (_Transparent)
  2005.         {
  2006.             InvalidateBitmap();
  2007.         }
  2008.  
  2009.         Invalidate();
  2010.         base.OnSizeChanged(e);
  2011.     }
  2012.  
  2013.     protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
  2014.     {
  2015.         if (!(_LockWidth == 0))
  2016.             width = _LockWidth;
  2017.         if (!(_LockHeight == 0))
  2018.             height = _LockHeight;
  2019.         base.SetBoundsCore(x, y, width, height, specified);
  2020.     }
  2021.  
  2022.     #endregion
  2023.  
  2024.     #region " State Handling "
  2025.  
  2026.     private bool InPosition;
  2027.     protected override void OnMouseEnter(EventArgs e)
  2028.     {
  2029.         InPosition = true;
  2030.         SetState(MouseState.Over);
  2031.         base.OnMouseEnter(e);
  2032.     }
  2033.  
  2034.     protected override void OnMouseUp(MouseEventArgs e)
  2035.     {
  2036.         if (InPosition)
  2037.             SetState(MouseState.Over);
  2038.         base.OnMouseUp(e);
  2039.     }
  2040.  
  2041.     protected override void OnMouseDown(MouseEventArgs e)
  2042.     {
  2043.         if (e.Button == System.Windows.Forms.MouseButtons.Left)
  2044.             SetState(MouseState.Down);
  2045.         base.OnMouseDown(e);
  2046.     }
  2047.  
  2048.     protected override void OnMouseLeave(EventArgs e)
  2049.     {
  2050.         InPosition = false;
  2051.         SetState(MouseState.None);
  2052.         base.OnMouseLeave(e);
  2053.     }
  2054.  
  2055.     protected override void OnEnabledChanged(EventArgs e)
  2056.     {
  2057.         if (Enabled)
  2058.             SetState(MouseState.None);
  2059.         else
  2060.             SetState(MouseState.Block);
  2061.         base.OnEnabledChanged(e);
  2062.     }
  2063.  
  2064.     protected MouseState State;
  2065.     private void SetState(MouseState current)
  2066.     {
  2067.         State = current;
  2068.         Invalidate();
  2069.     }
  2070.  
  2071.     #endregion
  2072.  
  2073.  
  2074.     #region " Base Properties "
  2075.  
  2076.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  2077.     public override Color ForeColor
  2078.     {
  2079.         get { return Color.Empty; }
  2080.         set { }
  2081.     }
  2082.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  2083.     public override Image BackgroundImage
  2084.     {
  2085.         get { return null; }
  2086.         set { }
  2087.     }
  2088.     [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  2089.     public override ImageLayout BackgroundImageLayout
  2090.     {
  2091.         get { return ImageLayout.None; }
  2092.         set { }
  2093.     }
  2094.  
  2095.     public override string Text
  2096.     {
  2097.         get { return base.Text; }
  2098.         set
  2099.         {
  2100.             base.Text = value;
  2101.             Invalidate();
  2102.         }
  2103.     }
  2104.     public override Font Font
  2105.     {
  2106.         get { return base.Font; }
  2107.         set
  2108.         {
  2109.             base.Font = value;
  2110.             Invalidate();
  2111.         }
  2112.     }
  2113.  
  2114.     private bool _BackColor;
  2115.     [Category("Misc")]
  2116.     public override Color BackColor
  2117.     {
  2118.         get { return base.BackColor; }
  2119.         set
  2120.         {
  2121.             if (!IsHandleCreated && value == Color.Transparent)
  2122.             {
  2123.                 _BackColor = true;
  2124.                 return;
  2125.             }
  2126.  
  2127.             base.BackColor = value;
  2128.             if (Parent != null)
  2129.                 ColorHook();
  2130.         }
  2131.     }
  2132.  
  2133.     #endregion
  2134.  
  2135.     #region " Public Properties "
  2136.  
  2137.     private bool _NoRounding;
  2138.     public bool NoRounding
  2139.     {
  2140.         get { return _NoRounding; }
  2141.         set
  2142.         {
  2143.             _NoRounding = value;
  2144.             Invalidate();
  2145.         }
  2146.     }
  2147.  
  2148.     private Image _Image;
  2149.     public Image Image
  2150.     {
  2151.         get { return _Image; }
  2152.         set
  2153.         {
  2154.             if (value == null)
  2155.             {
  2156.                 _ImageSize = Size.Empty;
  2157.             }
  2158.             else
  2159.             {
  2160.                 _ImageSize = value.Size;
  2161.             }
  2162.  
  2163.             _Image = value;
  2164.             Invalidate();
  2165.         }
  2166.     }
  2167.  
  2168.     private bool _Transparent;
  2169.     public bool Transparent
  2170.     {
  2171.         get { return _Transparent; }
  2172.         set
  2173.         {
  2174.             _Transparent = value;
  2175.             if (!IsHandleCreated)
  2176.                 return;
  2177.  
  2178.             if (!value && !(BackColor.A == 255))
  2179.             {
  2180.                 throw new Exception("Unable to change value to false while a transparent BackColor is in use.");
  2181.             }
  2182.  
  2183.             SetStyle(ControlStyles.Opaque, !value);
  2184.             SetStyle(ControlStyles.SupportsTransparentBackColor, value);
  2185.  
  2186.             if (value)
  2187.                 InvalidateBitmap();
  2188.             else
  2189.                 B = null;
  2190.             Invalidate();
  2191.         }
  2192.     }
  2193.  
  2194.     private Dictionary<string, Color> Items = new Dictionary<string, Color>();
  2195.     public Bloom[] Colors
  2196.     {
  2197.         get
  2198.         {
  2199.             List<Bloom> T = new List<Bloom>();
  2200.             Dictionary<string, Color>.Enumerator E = Items.GetEnumerator();
  2201.  
  2202.             while (E.MoveNext())
  2203.             {
  2204.                 T.Add(new Bloom(E.Current.Key, E.Current.Value));
  2205.             }
  2206.  
  2207.             return T.ToArray();
  2208.         }
  2209.         set
  2210.         {
  2211.             foreach (Bloom B in value)
  2212.             {
  2213.                 if (Items.ContainsKey(B.Name))
  2214.                     Items[B.Name] = B.Value;
  2215.             }
  2216.  
  2217.             InvalidateCustimization();
  2218.             ColorHook();
  2219.             Invalidate();
  2220.         }
  2221.     }
  2222.  
  2223.     private string _Customization;
  2224.     public string Customization
  2225.     {
  2226.         get { return _Customization; }
  2227.         set
  2228.         {
  2229.             if (value == _Customization)
  2230.                 return;
  2231.  
  2232.             byte[] Data = null;
  2233.             Bloom[] Items = Colors;
  2234.  
  2235.             try
  2236.             {
  2237.                 Data = Convert.FromBase64String(value);
  2238.                 for (int I = 0; I <= Items.Length - 1; I++)
  2239.                 {
  2240.                     Items[I].Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4));
  2241.                 }
  2242.             }
  2243.             catch
  2244.             {
  2245.                 return;
  2246.             }
  2247.  
  2248.             _Customization = value;
  2249.  
  2250.             Colors = Items;
  2251.             ColorHook();
  2252.             Invalidate();
  2253.         }
  2254.     }
  2255.  
  2256.     #endregion
  2257.  
  2258.     #region " Private Properties "
  2259.  
  2260.     private Size _ImageSize;
  2261.     protected Size ImageSize
  2262.     {
  2263.         get { return _ImageSize; }
  2264.     }
  2265.  
  2266.     private int _LockWidth;
  2267.     protected int LockWidth
  2268.     {
  2269.         get { return _LockWidth; }
  2270.         set
  2271.         {
  2272.             _LockWidth = value;
  2273.             if (!(LockWidth == 0) && IsHandleCreated)
  2274.                 Width = LockWidth;
  2275.         }
  2276.     }
  2277.  
  2278.     private int _LockHeight;
  2279.     protected int LockHeight
  2280.     {
  2281.         get { return _LockHeight; }
  2282.         set
  2283.         {
  2284.             _LockHeight = value;
  2285.             if (!(LockHeight == 0) && IsHandleCreated)
  2286.                 Height = LockHeight;
  2287.         }
  2288.     }
  2289.  
  2290.     private bool _IsAnimated;
  2291.     protected bool IsAnimated
  2292.     {
  2293.         get { return _IsAnimated; }
  2294.         set
  2295.         {
  2296.             _IsAnimated = value;
  2297.             InvalidateTimer();
  2298.         }
  2299.     }
  2300.  
  2301.     #endregion
  2302.  
  2303.  
  2304.     #region " Property Helpers "
  2305.  
  2306.     protected Pen GetPen(string name)
  2307.     {
  2308.         return new Pen(Items[name]);
  2309.     }
  2310.     protected Pen GetPen(string name, float width)
  2311.     {
  2312.         return new Pen(Items[name], width);
  2313.     }
  2314.  
  2315.     protected SolidBrush GetBrush(string name)
  2316.     {
  2317.         return new SolidBrush(Items[name]);
  2318.     }
  2319.  
  2320.     protected Color GetColor(string name)
  2321.     {
  2322.         return Items[name];
  2323.     }
  2324.  
  2325.     protected void SetColor(string name, Color value)
  2326.     {
  2327.         if (Items.ContainsKey(name))
  2328.             Items[name] = value;
  2329.         else
  2330.             Items.Add(name, value);
  2331.     }
  2332.     protected void SetColor(string name, byte r, byte g, byte b)
  2333.     {
  2334.         SetColor(name, Color.FromArgb(r, g, b));
  2335.     }
  2336.     protected void SetColor(string name, byte a, byte r, byte g, byte b)
  2337.     {
  2338.         SetColor(name, Color.FromArgb(a, r, g, b));
  2339.     }
  2340.     protected void SetColor(string name, byte a, Color value)
  2341.     {
  2342.         SetColor(name, Color.FromArgb(a, value));
  2343.     }
  2344.  
  2345.     private void InvalidateBitmap()
  2346.     {
  2347.         if (Width == 0 || Height == 0)
  2348.             return;
  2349.         B = new Bitmap(Width, Height, PixelFormat.Format32bppPArgb);
  2350.         G = Graphics.FromImage(B);
  2351.     }
  2352.  
  2353.     private void InvalidateCustimization()
  2354.     {
  2355.         MemoryStream M = new MemoryStream(Items.Count * 4);
  2356.  
  2357.         foreach (Bloom B in Colors)
  2358.         {
  2359.             M.Write(BitConverter.GetBytes(B.Value.ToArgb()), 0, 4);
  2360.         }
  2361.  
  2362.         M.Close();
  2363.         _Customization = Convert.ToBase64String(M.ToArray());
  2364.     }
  2365.  
  2366.     private void InvalidateTimer()
  2367.     {
  2368.         if (DesignMode || !DoneCreation)
  2369.             return;
  2370.  
  2371.         if (_IsAnimated)
  2372.         {
  2373.             ThemeShare.AddAnimationCallback(DoAnimation);
  2374.         }
  2375.         else
  2376.         {
  2377.             ThemeShare.RemoveAnimationCallback(DoAnimation);
  2378.         }
  2379.     }
  2380.     #endregion
  2381.  
  2382.  
  2383.     #region " User Hooks "
  2384.  
  2385.     protected abstract void ColorHook();
  2386.     protected abstract void PaintHook();
  2387.  
  2388.     protected virtual void OnCreation()
  2389.     {
  2390.     }
  2391.  
  2392.     protected virtual void OnAnimation()
  2393.     {
  2394.     }
  2395.  
  2396.     #endregion
  2397.  
  2398.  
  2399.     #region " Offset "
  2400.  
  2401.     private Rectangle OffsetReturnRectangle;
  2402.     protected Rectangle Offset(Rectangle r, int amount)
  2403.     {
  2404.         OffsetReturnRectangle = new Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2));
  2405.         return OffsetReturnRectangle;
  2406.     }
  2407.  
  2408.     private Size OffsetReturnSize;
  2409.     protected Size Offset(Size s, int amount)
  2410.     {
  2411.         OffsetReturnSize = new Size(s.Width + amount, s.Height + amount);
  2412.         return OffsetReturnSize;
  2413.     }
  2414.  
  2415.     private Point OffsetReturnPoint;
  2416.     protected Point Offset(Point p, int amount)
  2417.     {
  2418.         OffsetReturnPoint = new Point(p.X + amount, p.Y + amount);
  2419.         return OffsetReturnPoint;
  2420.     }
  2421.  
  2422.     #endregion
  2423.  
  2424.     #region " Center "
  2425.  
  2426.  
  2427.     private Point CenterReturn;
  2428.     protected Point Center(Rectangle p, Rectangle c)
  2429.     {
  2430.         CenterReturn = new Point((p.Width / 2 - c.Width / 2) + p.X + c.X, (p.Height / 2 - c.Height / 2) + p.Y + c.Y);
  2431.         return CenterReturn;
  2432.     }
  2433.     protected Point Center(Rectangle p, Size c)
  2434.     {
  2435.         CenterReturn = new Point((p.Width / 2 - c.Width / 2) + p.X, (p.Height / 2 - c.Height / 2) + p.Y);
  2436.         return CenterReturn;
  2437.     }
  2438.  
  2439.     protected Point Center(Rectangle child)
  2440.     {
  2441.         return Center(Width, Height, child.Width, child.Height);
  2442.     }
  2443.     protected Point Center(Size child)
  2444.     {
  2445.         return Center(Width, Height, child.Width, child.Height);
  2446.     }
  2447.     protected Point Center(int childWidth, int childHeight)
  2448.     {
  2449.         return Center(Width, Height, childWidth, childHeight);
  2450.     }
  2451.  
  2452.     protected Point Center(Size p, Size c)
  2453.     {
  2454.         return Center(p.Width, p.Height, c.Width, c.Height);
  2455.     }
  2456.  
  2457.     protected Point Center(int pWidth, int pHeight, int cWidth, int cHeight)
  2458.     {
  2459.         CenterReturn = new Point(pWidth / 2 - cWidth / 2, pHeight / 2 - cHeight / 2);
  2460.         return CenterReturn;
  2461.     }
  2462.  
  2463.     #endregion
  2464.  
  2465.     #region " Measure "
  2466.  
  2467.     private Bitmap MeasureBitmap;
  2468.     //TODO: Potential issues during multi-threading.
  2469.     private Graphics MeasureGraphics;
  2470.  
  2471.     protected Size Measure()
  2472.     {
  2473.         return MeasureGraphics.MeasureString(Text, Font, Width).ToSize();
  2474.     }
  2475.     protected Size Measure(string text)
  2476.     {
  2477.         return MeasureGraphics.MeasureString(text, Font, Width).ToSize();
  2478.     }
  2479.  
  2480.     #endregion
  2481.  
  2482.  
  2483.     #region " DrawPixel "
  2484.  
  2485.  
  2486.     private SolidBrush DrawPixelBrush;
  2487.     protected void DrawPixel(Color c1, int x, int y)
  2488.     {
  2489.         if (_Transparent)
  2490.         {
  2491.             B.SetPixel(x, y, c1);
  2492.         }
  2493.         else
  2494.         {
  2495.             DrawPixelBrush = new SolidBrush(c1);
  2496.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1);
  2497.         }
  2498.     }
  2499.  
  2500.     #endregion
  2501.  
  2502.     #region " DrawCorners "
  2503.  
  2504.  
  2505.     private SolidBrush DrawCornersBrush;
  2506.     protected void DrawCorners(Color c1, int offset)
  2507.     {
  2508.         DrawCorners(c1, 0, 0, Width, Height, offset);
  2509.     }
  2510.     protected void DrawCorners(Color c1, Rectangle r1, int offset)
  2511.     {
  2512.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset);
  2513.     }
  2514.     protected void DrawCorners(Color c1, int x, int y, int width, int height, int offset)
  2515.     {
  2516.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
  2517.     }
  2518.  
  2519.     protected void DrawCorners(Color c1)
  2520.     {
  2521.         DrawCorners(c1, 0, 0, Width, Height);
  2522.     }
  2523.     protected void DrawCorners(Color c1, Rectangle r1)
  2524.     {
  2525.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height);
  2526.     }
  2527.     protected void DrawCorners(Color c1, int x, int y, int width, int height)
  2528.     {
  2529.         if (_NoRounding)
  2530.             return;
  2531.  
  2532.         if (_Transparent)
  2533.         {
  2534.             B.SetPixel(x, y, c1);
  2535.             B.SetPixel(x + (width - 1), y, c1);
  2536.             B.SetPixel(x, y + (height - 1), c1);
  2537.             B.SetPixel(x + (width - 1), y + (height - 1), c1);
  2538.         }
  2539.         else
  2540.         {
  2541.             DrawCornersBrush = new SolidBrush(c1);
  2542.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1);
  2543.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1);
  2544.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1);
  2545.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1);
  2546.         }
  2547.     }
  2548.  
  2549.     #endregion
  2550.  
  2551.     #region " DrawBorders "
  2552.  
  2553.     protected void DrawBorders(Pen p1, int offset)
  2554.     {
  2555.         DrawBorders(p1, 0, 0, Width, Height, offset);
  2556.     }
  2557.     protected void DrawBorders(Pen p1, Rectangle r, int offset)
  2558.     {
  2559.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset);
  2560.     }
  2561.     protected void DrawBorders(Pen p1, int x, int y, int width, int height, int offset)
  2562.     {
  2563.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
  2564.     }
  2565.  
  2566.     protected void DrawBorders(Pen p1)
  2567.     {
  2568.         DrawBorders(p1, 0, 0, Width, Height);
  2569.     }
  2570.     protected void DrawBorders(Pen p1, Rectangle r)
  2571.     {
  2572.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height);
  2573.     }
  2574.     protected void DrawBorders(Pen p1, int x, int y, int width, int height)
  2575.     {
  2576.         G.DrawRectangle(p1, x, y, width - 1, height - 1);
  2577.     }
  2578.  
  2579.     #endregion
  2580.  
  2581.     #region " DrawText "
  2582.  
  2583.     private Point DrawTextPoint;
  2584.  
  2585.     private Size DrawTextSize;
  2586.     protected void DrawText(Brush b1, HorizontalAlignment a, int x, int y)
  2587.     {
  2588.         DrawText(b1, Text, a, x, y);
  2589.     }
  2590.     protected void DrawText(Brush b1, string text, HorizontalAlignment a, int x, int y)
  2591.     {
  2592.         if (text.Length == 0)
  2593.             return;
  2594.  
  2595.         DrawTextSize = Measure(text);
  2596.         DrawTextPoint = Center(DrawTextSize);
  2597.  
  2598.         switch (a)
  2599.         {
  2600.             case HorizontalAlignment.Left:
  2601.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y);
  2602.                 break;
  2603.             case HorizontalAlignment.Center:
  2604.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y);
  2605.                 break;
  2606.             case HorizontalAlignment.Right:
  2607.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y);
  2608.                 break;
  2609.         }
  2610.     }
  2611.  
  2612.     protected void DrawText(Brush b1, Point p1)
  2613.     {
  2614.         if (Text.Length == 0)
  2615.             return;
  2616.         G.DrawString(Text, Font, b1, p1);
  2617.     }
  2618.     protected void DrawText(Brush b1, int x, int y)
  2619.     {
  2620.         if (Text.Length == 0)
  2621.             return;
  2622.         G.DrawString(Text, Font, b1, x, y);
  2623.     }
  2624.  
  2625.     #endregion
  2626.  
  2627.     #region " DrawImage "
  2628.  
  2629.  
  2630.     private Point DrawImagePoint;
  2631.     protected void DrawImage(HorizontalAlignment a, int x, int y)
  2632.     {
  2633.         DrawImage(_Image, a, x, y);
  2634.     }
  2635.     protected void DrawImage(Image image, HorizontalAlignment a, int x, int y)
  2636.     {
  2637.         if (image == null)
  2638.             return;
  2639.         DrawImagePoint = Center(image.Size);
  2640.  
  2641.         switch (a)
  2642.         {
  2643.             case HorizontalAlignment.Left:
  2644.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height);
  2645.                 break;
  2646.             case HorizontalAlignment.Center:
  2647.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height);
  2648.                 break;
  2649.             case HorizontalAlignment.Right:
  2650.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height);
  2651.                 break;
  2652.         }
  2653.     }
  2654.  
  2655.     protected void DrawImage(Point p1)
  2656.     {
  2657.         DrawImage(_Image, p1.X, p1.Y);
  2658.     }
  2659.     protected void DrawImage(int x, int y)
  2660.     {
  2661.         DrawImage(_Image, x, y);
  2662.     }
  2663.  
  2664.     protected void DrawImage(Image image, Point p1)
  2665.     {
  2666.         DrawImage(image, p1.X, p1.Y);
  2667.     }
  2668.     protected void DrawImage(Image image, int x, int y)
  2669.     {
  2670.         if (image == null)
  2671.             return;
  2672.         G.DrawImage(image, x, y, image.Width, image.Height);
  2673.     }
  2674.  
  2675.     #endregion
  2676.  
  2677.     #region " DrawGradient "
  2678.  
  2679.     private LinearGradientBrush DrawGradientBrush;
  2680.  
  2681.     private Rectangle DrawGradientRectangle;
  2682.     protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height)
  2683.     {
  2684.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  2685.         DrawGradient(blend, DrawGradientRectangle);
  2686.     }
  2687.     protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height, float angle)
  2688.     {
  2689.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  2690.         DrawGradient(blend, DrawGradientRectangle, angle);
  2691.     }
  2692.  
  2693.     protected void DrawGradient(ColorBlend blend, Rectangle r)
  2694.     {
  2695.         DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, 90f);
  2696.         DrawGradientBrush.InterpolationColors = blend;
  2697.         G.FillRectangle(DrawGradientBrush, r);
  2698.     }
  2699.     protected void DrawGradient(ColorBlend blend, Rectangle r, float angle)
  2700.     {
  2701.         DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, angle);
  2702.         DrawGradientBrush.InterpolationColors = blend;
  2703.         G.FillRectangle(DrawGradientBrush, r);
  2704.     }
  2705.  
  2706.  
  2707.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height)
  2708.     {
  2709.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  2710.         DrawGradient(c1, c2, DrawGradientRectangle);
  2711.     }
  2712.     protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
  2713.     {
  2714.         DrawGradientRectangle = new Rectangle(x, y, width, height);
  2715.         DrawGradient(c1, c2, DrawGradientRectangle, angle);
  2716.     }
  2717.  
  2718.     protected void DrawGradient(Color c1, Color c2, Rectangle r)
  2719.     {
  2720.         DrawGradientBrush = new LinearGradientBrush(r, c1, c2, 90f);
  2721.         G.FillRectangle(DrawGradientBrush, r);
  2722.     }
  2723.     protected void DrawGradient(Color c1, Color c2, Rectangle r, float angle)
  2724.     {
  2725.         DrawGradientBrush = new LinearGradientBrush(r, c1, c2, angle);
  2726.         G.FillRectangle(DrawGradientBrush, r);
  2727.     }
  2728.  
  2729.     #endregion
  2730.  
  2731.     #region " DrawRadial "
  2732.  
  2733.     private GraphicsPath DrawRadialPath;
  2734.     private PathGradientBrush DrawRadialBrush1;
  2735.     private LinearGradientBrush DrawRadialBrush2;
  2736.  
  2737.     private Rectangle DrawRadialRectangle;
  2738.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height)
  2739.     {
  2740.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  2741.         DrawRadial(blend, DrawRadialRectangle, width / 2, height / 2);
  2742.     }
  2743.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, Point center)
  2744.     {
  2745.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  2746.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y);
  2747.     }
  2748.     public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, int cx, int cy)
  2749.     {
  2750.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  2751.         DrawRadial(blend, DrawRadialRectangle, cx, cy);
  2752.     }
  2753.  
  2754.     public void DrawRadial(ColorBlend blend, Rectangle r)
  2755.     {
  2756.         DrawRadial(blend, r, r.Width / 2, r.Height / 2);
  2757.     }
  2758.     public void DrawRadial(ColorBlend blend, Rectangle r, Point center)
  2759.     {
  2760.         DrawRadial(blend, r, center.X, center.Y);
  2761.     }
  2762.     public void DrawRadial(ColorBlend blend, Rectangle r, int cx, int cy)
  2763.     {
  2764.         DrawRadialPath.Reset();
  2765.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1);
  2766.  
  2767.         DrawRadialBrush1 = new PathGradientBrush(DrawRadialPath);
  2768.         DrawRadialBrush1.CenterPoint = new Point(r.X + cx, r.Y + cy);
  2769.         DrawRadialBrush1.InterpolationColors = blend;
  2770.  
  2771.         if (G.SmoothingMode == SmoothingMode.AntiAlias)
  2772.         {
  2773.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3);
  2774.         }
  2775.         else
  2776.         {
  2777.             G.FillEllipse(DrawRadialBrush1, r);
  2778.         }
  2779.     }
  2780.  
  2781.  
  2782.     protected void DrawRadial(Color c1, Color c2, int x, int y, int width, int height)
  2783.     {
  2784.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  2785.         DrawRadial(c1, c2, DrawRadialRectangle);
  2786.     }
  2787.     protected void DrawRadial(Color c1, Color c2, int x, int y, int width, int height, float angle)
  2788.     {
  2789.         DrawRadialRectangle = new Rectangle(x, y, width, height);
  2790.         DrawRadial(c1, c2, DrawRadialRectangle, angle);
  2791.     }
  2792.  
  2793.     protected void DrawRadial(Color c1, Color c2, Rectangle r)
  2794.     {
  2795.         DrawRadialBrush2 = new LinearGradientBrush(r, c1, c2, 90f);
  2796.         G.FillEllipse(DrawRadialBrush2, r);
  2797.     }
  2798.     protected void DrawRadial(Color c1, Color c2, Rectangle r, float angle)
  2799.     {
  2800.         DrawRadialBrush2 = new LinearGradientBrush(r, c1, c2, angle);
  2801.         G.FillEllipse(DrawRadialBrush2, r);
  2802.     }
  2803.  
  2804.     #endregion
  2805.  
  2806.     #region " CreateRound "
  2807.  
  2808.     private GraphicsPath CreateRoundPath;
  2809.  
  2810.     private Rectangle CreateRoundRectangle;
  2811.     public GraphicsPath CreateRound(int x, int y, int width, int height, int slope)
  2812.     {
  2813.         CreateRoundRectangle = new Rectangle(x, y, width, height);
  2814.         return CreateRound(CreateRoundRectangle, slope);
  2815.     }
  2816.  
  2817.     public GraphicsPath CreateRound(Rectangle r, int slope)
  2818.     {
  2819.         CreateRoundPath = new GraphicsPath(FillMode.Winding);
  2820.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180f, 90f);
  2821.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270f, 90f);
  2822.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0f, 90f);
  2823.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90f, 90f);
  2824.         CreateRoundPath.CloseFigure();
  2825.         return CreateRoundPath;
  2826.     }
  2827.  
  2828.     #endregion
  2829.  
  2830. }
  2831. static class ThemeShare
  2832. {
  2833.  
  2834.     #region " Animation "
  2835.  
  2836.     private static int Frames;
  2837.     private static bool Invalidate;
  2838.  
  2839.     public static PrecisionTimer ThemeTimer = new PrecisionTimer();
  2840.     //1000 / 50 = 20 FPS
  2841.     private const int FPS = 50;
  2842.  
  2843.     private const int Rate = 10;
  2844.     public delegate void AnimationDelegate(bool invalidate);
  2845.  
  2846.  
  2847.     private static List<AnimationDelegate> Callbacks = new List<AnimationDelegate>();
  2848.     private static void HandleCallbacks(IntPtr state, bool reserve)
  2849.     {
  2850.         Invalidate = (Frames >= FPS);
  2851.         if (Invalidate)
  2852.             Frames = 0;
  2853.  
  2854.         lock (Callbacks)
  2855.         {
  2856.             for (int I = 0; I <= Callbacks.Count - 1; I++)
  2857.             {
  2858.                 Callbacks[I].Invoke(Invalidate);
  2859.             }
  2860.         }
  2861.  
  2862.         Frames += Rate;
  2863.     }
  2864.  
  2865.     private static void InvalidateThemeTimer()
  2866.     {
  2867.         if (Callbacks.Count == 0)
  2868.         {
  2869.             ThemeTimer.Delete();
  2870.         }
  2871.         else
  2872.         {
  2873.             ThemeTimer.Create(0, Rate, HandleCallbacks);
  2874.         }
  2875.     }
  2876.  
  2877.     public static void AddAnimationCallback(AnimationDelegate callback)
  2878.     {
  2879.         lock (Callbacks)
  2880.         {
  2881.             if (Callbacks.Contains(callback))
  2882.                 return;
  2883.  
  2884.             Callbacks.Add(callback);
  2885.             InvalidateThemeTimer();
  2886.         }
  2887.     }
  2888.  
  2889.     public static void RemoveAnimationCallback(AnimationDelegate callback)
  2890.     {
  2891.         lock (Callbacks)
  2892.         {
  2893.             if (!Callbacks.Contains(callback))
  2894.                 return;
  2895.  
  2896.             Callbacks.Remove(callback);
  2897.             InvalidateThemeTimer();
  2898.         }
  2899.     }
  2900.  
  2901.     #endregion
  2902.  
  2903. }
  2904. enum MouseState : byte
  2905. {
  2906.     None = 0,
  2907.     Over = 1,
  2908.     Down = 2,
  2909.     Block = 3
  2910. }
  2911. struct Bloom
  2912. {
  2913.  
  2914.     public string _Name;
  2915.     public string Name
  2916.     {
  2917.         get { return _Name; }
  2918.     }
  2919.  
  2920.     private Color _Value;
  2921.     public Color Value
  2922.     {
  2923.         get { return _Value; }
  2924.         set { _Value = value; }
  2925.     }
  2926.  
  2927.     public string ValueHex
  2928.     {
  2929.         get { return string.Concat("#", _Value.R.ToString("X2", null), _Value.G.ToString("X2", null), _Value.B.ToString("X2", null)); }
  2930.         set
  2931.         {
  2932.             try
  2933.             {
  2934.                 _Value = ColorTranslator.FromHtml(value);
  2935.             }
  2936.             catch
  2937.             {
  2938.                 return;
  2939.             }
  2940.         }
  2941.     }
  2942.  
  2943.  
  2944.     public Bloom(string name, Color value)
  2945.     {
  2946.         _Name = name;
  2947.         _Value = value;
  2948.     }
  2949. }
  2950.  
  2951. //------------------
  2952. //Creator: aeonhack
  2953. //Site: elitevs.net
  2954. //Created: 11/30/2011
  2955. //Changed: 11/30/2011
  2956. //Version: 1.0.0
  2957. //------------------
  2958. class PrecisionTimer : IDisposable
  2959. {
  2960.  
  2961.     private bool _Enabled;
  2962.     public bool Enabled
  2963.     {
  2964.         get { return _Enabled; }
  2965.     }
  2966.  
  2967.     private IntPtr Handle;
  2968.  
  2969.     private TimerDelegate TimerCallback;
  2970.     [DllImport("kernel32.dll", EntryPoint = "CreateTimerQueueTimer")]
  2971.     private static extern bool CreateTimerQueueTimer(ref IntPtr handle, IntPtr queue, TimerDelegate callback, IntPtr state, uint dueTime, uint period, uint flags);
  2972.  
  2973.     [DllImport("kernel32.dll", EntryPoint = "DeleteTimerQueueTimer")]
  2974.     private static extern bool DeleteTimerQueueTimer(IntPtr queue, IntPtr handle, IntPtr callback);
  2975.  
  2976.     public delegate void TimerDelegate(IntPtr r1, bool r2);
  2977.  
  2978.     public void Create(uint dueTime, uint period, TimerDelegate callback)
  2979.     {
  2980.         if (_Enabled)
  2981.             return;
  2982.  
  2983.         TimerCallback = callback;
  2984.         bool Success = CreateTimerQueueTimer(ref Handle, IntPtr.Zero, TimerCallback, IntPtr.Zero, dueTime, period, 0);
  2985.  
  2986.         if (!Success)
  2987.             ThrowNewException("CreateTimerQueueTimer");
  2988.         _Enabled = Success;
  2989.     }
  2990.  
  2991.     public void Delete()
  2992.     {
  2993.         if (!_Enabled)
  2994.             return;
  2995.         bool Success = DeleteTimerQueueTimer(IntPtr.Zero, Handle, IntPtr.Zero);
  2996.  
  2997.         if (!Success && !(Marshal.GetLastWin32Error() == 997))
  2998.         {
  2999.             ThrowNewException("DeleteTimerQueueTimer");
  3000.         }
  3001.  
  3002.         _Enabled = !Success;
  3003.     }
  3004.  
  3005.     private void ThrowNewException(string name)
  3006.     {
  3007.         throw new Exception(string.Format("{0} failed. Win32Error: {1}", name, Marshal.GetLastWin32Error()));
  3008.     }
  3009.  
  3010.     public void Dispose()
  3011.     {
  3012.         Delete();
  3013.     }
  3014. }
Add Comment
Please, Sign In to add comment