Astekk

Google Chrome Theme c#

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