Advertisement
Astekk

[C#] Theme

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