Advertisement
Astekk

C# Theme Base 1.5.2

Dec 3rd, 2014
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Drawing;
  5. using System.Drawing.Drawing2D;
  6. using System.ComponentModel;
  7. using System.Windows.Forms;
  8.  
  9. //------------------
  10. //Creator: aeonhack
  11. //Site: elitevs.net
  12. //Created: 08/02/2011
  13. //Changed: 09/23/2011
  14. //Version: 1.5.2
  15. //------------------
  16.  
  17. abstract class ThemeContainer152 : ContainerControl
  18. {
  19.  
  20.  
  21. protected Graphics G;
  22. public ThemeContainer152()
  23. {
  24. SetStyle((ControlStyles)139270, true);
  25. _ImageSize = Size.Empty;
  26.  
  27. MeasureBitmap = new Bitmap(1, 1);
  28. MeasureGraphics = Graphics.FromImage(MeasureBitmap);
  29.  
  30. Font = new Font("Verdana", 8);
  31.  
  32. InvalidateCustimization();
  33. }
  34.  
  35. protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
  36. {
  37. if (!(_LockWidth == 0))
  38. width = _LockWidth;
  39. if (!(_LockHeight == 0))
  40. height = _LockHeight;
  41. base.SetBoundsCore(x, y, width, height, specified);
  42. }
  43.  
  44. private Rectangle Header;
  45. protected override sealed void OnSizeChanged(EventArgs e)
  46. {
  47. if (_Movable && !_ControlMode)
  48. Header = new Rectangle(7, 7, Width - 14, _MoveHeight - 7);
  49. Invalidate();
  50. base.OnSizeChanged(e);
  51. }
  52.  
  53. protected override sealed void OnPaint(PaintEventArgs e)
  54. {
  55. if (Width == 0 || Height == 0)
  56. return;
  57. G = e.Graphics;
  58. PaintHook();
  59. }
  60.  
  61. protected override sealed void OnHandleCreated(EventArgs e)
  62. {
  63. InvalidateCustimization();
  64. ColorHook();
  65.  
  66. if (!(_LockWidth == 0))
  67. Width = _LockWidth;
  68. if (!(_LockHeight == 0))
  69. Height = _LockHeight;
  70. if (!_ControlMode)
  71. base.Dock = DockStyle.Fill;
  72.  
  73. base.OnHandleCreated(e);
  74. }
  75.  
  76. protected override sealed void OnParentChanged(EventArgs e)
  77. {
  78. base.OnParentChanged(e);
  79.  
  80. if (Parent == null)
  81. return;
  82. _IsParentForm = Parent is Form;
  83.  
  84. if (!_ControlMode)
  85. {
  86. InitializeMessages();
  87.  
  88. if (_IsParentForm)
  89. {
  90. ParentForm.FormBorderStyle = _BorderStyle;
  91. ParentForm.TransparencyKey = _TransparencyKey;
  92. }
  93.  
  94. Parent.BackColor = BackColor;
  95. }
  96.  
  97. OnCreation();
  98. }
  99.  
  100. protected virtual void OnCreation()
  101. {
  102. }
  103.  
  104. #region " Sizing and Movement "
  105.  
  106. protected MouseState State;
  107. private void SetState(MouseState current)
  108. {
  109. State = current;
  110. Invalidate();
  111. }
  112.  
  113. protected override void OnMouseMove(MouseEventArgs e)
  114. {
  115. if (!(_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized))
  116. {
  117. if (_Sizable && !_ControlMode)
  118. InvalidateMouse();
  119. }
  120.  
  121. base.OnMouseMove(e);
  122. }
  123.  
  124. protected override void OnEnabledChanged(EventArgs e)
  125. {
  126. if (Enabled)
  127. SetState(MouseState.None);
  128. else
  129. SetState(MouseState.Block);
  130. base.OnEnabledChanged(e);
  131. }
  132.  
  133. protected override void OnMouseEnter(EventArgs e)
  134. {
  135. SetState(MouseState.Over);
  136. base.OnMouseEnter(e);
  137. }
  138.  
  139. protected override void OnMouseUp(MouseEventArgs e)
  140. {
  141. SetState(MouseState.Over);
  142. base.OnMouseUp(e);
  143. }
  144.  
  145. protected override void OnMouseLeave(EventArgs e)
  146. {
  147. SetState(MouseState.None);
  148.  
  149. if (GetChildAtPoint(PointToClient(MousePosition)) != null)
  150. {
  151. if (_Sizable && !_ControlMode)
  152. {
  153. Cursor = Cursors.Default;
  154. Previous = 0;
  155. }
  156. }
  157.  
  158. base.OnMouseLeave(e);
  159. }
  160.  
  161. protected override void OnMouseDown(MouseEventArgs e)
  162. {
  163. if (e.Button == System.Windows.Forms.MouseButtons.Left)
  164. SetState(MouseState.Down);
  165.  
  166. if (!(_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized || _ControlMode))
  167. {
  168. if (_Movable && Header.Contains(e.Location))
  169. {
  170. Capture = false;
  171. WM_LMBUTTONDOWN = true;
  172. DefWndProc(ref Messages[0]);
  173. }
  174. else if (_Sizable && !(Previous == 0))
  175. {
  176. Capture = false;
  177. WM_LMBUTTONDOWN = true;
  178. DefWndProc(ref Messages[Previous]);
  179. }
  180. }
  181.  
  182. base.OnMouseDown(e);
  183. }
  184.  
  185. private bool WM_LMBUTTONDOWN;
  186. protected override void WndProc(ref Message m)
  187. {
  188. base.WndProc(ref m);
  189.  
  190. if (WM_LMBUTTONDOWN && m.Msg == 513)
  191. {
  192. WM_LMBUTTONDOWN = false;
  193.  
  194. SetState(MouseState.Over);
  195. if (!_SmartBounds)
  196. return;
  197.  
  198. if (IsParentMdi)
  199. {
  200. CorrectBounds(new Rectangle(Point.Empty, Parent.Parent.Size));
  201. }
  202. else
  203. {
  204. CorrectBounds(Screen.FromControl(Parent).WorkingArea);
  205. }
  206. }
  207. }
  208.  
  209. private Point GetIndexPoint;
  210. private bool B1;
  211. private bool B2;
  212. private bool B3;
  213. private bool B4;
  214. private int GetIndex()
  215. {
  216. GetIndexPoint = PointToClient(MousePosition);
  217. B1 = GetIndexPoint.X < 7;
  218. B2 = GetIndexPoint.X > Width - 7;
  219. B3 = GetIndexPoint.Y < 7;
  220. B4 = GetIndexPoint.Y > Height - 7;
  221.  
  222. if (B1 && B3)
  223. return 4;
  224. if (B1 && B4)
  225. return 7;
  226. if (B2 && B3)
  227. return 5;
  228. if (B2 && B4)
  229. return 8;
  230. if (B1)
  231. return 1;
  232. if (B2)
  233. return 2;
  234. if (B3)
  235. return 3;
  236. if (B4)
  237. return 6;
  238. return 0;
  239. }
  240.  
  241. private int Current;
  242. private int Previous;
  243. private void InvalidateMouse()
  244. {
  245. Current = GetIndex();
  246. if (Current == Previous)
  247. return;
  248.  
  249. Previous = Current;
  250. switch (Previous)
  251. {
  252. case 0:
  253. Cursor = Cursors.Default;
  254. break;
  255. case 1:
  256. case 2:
  257. Cursor = Cursors.SizeWE;
  258. break;
  259. case 3:
  260. case 6:
  261. Cursor = Cursors.SizeNS;
  262. break;
  263. case 4:
  264. case 8:
  265. Cursor = Cursors.SizeNWSE;
  266. break;
  267. case 5:
  268. case 7:
  269. Cursor = Cursors.SizeNESW;
  270. break;
  271. }
  272. }
  273.  
  274. private Message[] Messages = new Message[9];
  275. private void InitializeMessages()
  276. {
  277. Messages[0] = Message.Create(Parent.Handle, 161, new IntPtr(2), IntPtr.Zero);
  278. for (int I = 1; I <= 8; I++)
  279. {
  280. Messages[I] = Message.Create(Parent.Handle, 161, new IntPtr(I + 9), IntPtr.Zero);
  281. }
  282. }
  283.  
  284. private void CorrectBounds(Rectangle bounds)
  285. {
  286. if (Parent.Width > bounds.Width)
  287. Parent.Width = bounds.Width;
  288. if (Parent.Height > bounds.Height)
  289. Parent.Height = bounds.Height;
  290.  
  291. int X = Parent.Location.X;
  292. int Y = Parent.Location.Y;
  293.  
  294. if (X < bounds.X)
  295. X = bounds.X;
  296. if (Y < bounds.Y)
  297. Y = bounds.Y;
  298.  
  299. int Width = bounds.X + bounds.Width;
  300. int Height = bounds.Y + bounds.Height;
  301.  
  302. if (X + Parent.Width > Width)
  303. X = Width - Parent.Width;
  304. if (Y + Parent.Height > Height)
  305. Y = Height - Parent.Height;
  306.  
  307. Parent.Location = new Point(X, Y);
  308. }
  309.  
  310. #endregion
  311.  
  312.  
  313. #region " Property Overrides "
  314.  
  315. public override DockStyle Dock
  316. {
  317. get { return base.Dock; }
  318. set
  319. {
  320. if (!_ControlMode)
  321. return;
  322. base.Dock = value;
  323. }
  324. }
  325.  
  326. [Category("Misc")]
  327. public override Color BackColor
  328. {
  329. get { return base.BackColor; }
  330. set
  331. {
  332. if (value == BackColor)
  333. return;
  334. base.BackColor = value;
  335.  
  336. if (Parent != null)
  337. {
  338. if (!_ControlMode)
  339. Parent.BackColor = value;
  340. ColorHook();
  341. }
  342. }
  343. }
  344.  
  345. public override Size MinimumSize
  346. {
  347. get { return base.MinimumSize; }
  348. set
  349. {
  350. base.MinimumSize = value;
  351. if (Parent != null)
  352. Parent.MinimumSize = value;
  353. }
  354. }
  355.  
  356. public override Size MaximumSize
  357. {
  358. get { return base.MaximumSize; }
  359. set
  360. {
  361. base.MaximumSize = value;
  362. if (Parent != null)
  363. Parent.MaximumSize = value;
  364. }
  365. }
  366.  
  367. public override string Text
  368. {
  369. get { return base.Text; }
  370. set
  371. {
  372. base.Text = value;
  373. Invalidate();
  374. }
  375. }
  376.  
  377. public override Font Font
  378. {
  379. get { return base.Font; }
  380. set
  381. {
  382. base.Font = value;
  383. Invalidate();
  384. }
  385. }
  386.  
  387. [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  388. public override Color ForeColor
  389. {
  390. get { return Color.Empty; }
  391. set { }
  392. }
  393. [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  394. public override Image BackgroundImage
  395. {
  396. get { return null; }
  397. set { }
  398. }
  399. [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  400. public override ImageLayout BackgroundImageLayout
  401. {
  402. get { return ImageLayout.None; }
  403. set { }
  404. }
  405.  
  406. #endregion
  407.  
  408. #region " Properties "
  409.  
  410. private bool _SmartBounds = true;
  411. public bool SmartBounds
  412. {
  413. get { return _SmartBounds; }
  414. set { _SmartBounds = value; }
  415. }
  416.  
  417. private bool _Movable = true;
  418. public bool Movable
  419. {
  420. get { return _Movable; }
  421. set { _Movable = value; }
  422. }
  423.  
  424. private bool _Sizable = true;
  425. public bool Sizable
  426. {
  427. get { return _Sizable; }
  428. set { _Sizable = value; }
  429. }
  430.  
  431. private Color _TransparencyKey;
  432. public Color TransparencyKey
  433. {
  434. get
  435. {
  436. if (_IsParentForm && !_ControlMode)
  437. return ParentForm.TransparencyKey;
  438. else
  439. return _TransparencyKey;
  440. }
  441. set
  442. {
  443. if (value == _TransparencyKey)
  444. return;
  445. _TransparencyKey = value;
  446.  
  447. if (_IsParentForm && !_ControlMode)
  448. {
  449. ParentForm.TransparencyKey = value;
  450. ColorHook();
  451. }
  452. }
  453. }
  454.  
  455. private FormBorderStyle _BorderStyle;
  456. public FormBorderStyle BorderStyle
  457. {
  458. get
  459. {
  460. if (_IsParentForm && !_ControlMode)
  461. return ParentForm.FormBorderStyle;
  462. else
  463. return _BorderStyle;
  464. }
  465. set
  466. {
  467. _BorderStyle = value;
  468.  
  469. if (_IsParentForm && !_ControlMode)
  470. {
  471. ParentForm.FormBorderStyle = value;
  472.  
  473. if (!(value == FormBorderStyle.None))
  474. {
  475. Movable = false;
  476. Sizable = false;
  477. }
  478. }
  479. }
  480. }
  481.  
  482. private bool _NoRounding;
  483. public bool NoRounding
  484. {
  485. get { return _NoRounding; }
  486. set
  487. {
  488. _NoRounding = value;
  489. Invalidate();
  490. }
  491. }
  492.  
  493. private Image _Image;
  494. public Image Image
  495. {
  496. get { return _Image; }
  497. set
  498. {
  499. if (value == null)
  500. _ImageSize = Size.Empty;
  501. else
  502. _ImageSize = value.Size;
  503.  
  504. _Image = value;
  505. Invalidate();
  506. }
  507. }
  508.  
  509. private Size _ImageSize;
  510. protected Size ImageSize
  511. {
  512. get { return _ImageSize; }
  513. }
  514.  
  515. private bool _IsParentForm;
  516. protected bool IsParentForm
  517. {
  518. get { return _IsParentForm; }
  519. }
  520.  
  521. protected bool IsParentMdi
  522. {
  523. get
  524. {
  525. if (Parent == null)
  526. return false;
  527. return Parent.Parent != null;
  528. }
  529. }
  530.  
  531. private int _LockWidth;
  532. protected int LockWidth
  533. {
  534. get { return _LockWidth; }
  535. set
  536. {
  537. _LockWidth = value;
  538. if (!(LockWidth == 0) && IsHandleCreated)
  539. Width = LockWidth;
  540. }
  541. }
  542.  
  543. private int _LockHeight;
  544. protected int LockHeight
  545. {
  546. get { return _LockHeight; }
  547. set
  548. {
  549. _LockHeight = value;
  550. if (!(LockHeight == 0) && IsHandleCreated)
  551. Height = LockHeight;
  552. }
  553. }
  554.  
  555. private int _MoveHeight = 24;
  556. protected int MoveHeight
  557. {
  558. get { return _MoveHeight; }
  559. set
  560. {
  561. if (value < 8)
  562. return;
  563. Header = new Rectangle(7, 7, Width - 14, value - 7);
  564. _MoveHeight = value;
  565. Invalidate();
  566. }
  567. }
  568.  
  569. private bool _ControlMode;
  570. protected bool ControlMode
  571. {
  572. get { return _ControlMode; }
  573. set { _ControlMode = value; }
  574. }
  575.  
  576. private Dictionary<string, Color> Items = new Dictionary<string, Color>();
  577. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  578. public Bloom[] Colors
  579. {
  580. get
  581. {
  582. List<Bloom> T = new List<Bloom>();
  583. Dictionary<string, Color>.Enumerator E = Items.GetEnumerator();
  584.  
  585. while (E.MoveNext())
  586. {
  587. T.Add(new Bloom(E.Current.Key, E.Current.Value));
  588. }
  589.  
  590. return T.ToArray();
  591. }
  592. set
  593. {
  594. foreach (Bloom B in value)
  595. {
  596. if (Items.ContainsKey(B.Name))
  597. Items[B.Name] = B.Value;
  598. }
  599.  
  600. InvalidateCustimization();
  601. ColorHook();
  602. Invalidate();
  603. }
  604. }
  605.  
  606. private string _Customization;
  607. public string Customization
  608. {
  609. get { return _Customization; }
  610. set
  611. {
  612. if (value == _Customization)
  613. return;
  614.  
  615. byte[] Data = null;
  616. Bloom[] Items = Colors;
  617.  
  618. try
  619. {
  620. Data = Convert.FromBase64String(value);
  621. for (int I = 0; I <= Items.Length - 1; I++)
  622. {
  623. Items[I].Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4));
  624. }
  625. }
  626. catch
  627. {
  628. return;
  629. }
  630.  
  631. _Customization = value;
  632.  
  633. Colors = Items;
  634. ColorHook();
  635. Invalidate();
  636. }
  637. }
  638.  
  639. #endregion
  640.  
  641. #region " Property Helpers "
  642.  
  643. protected Color GetColor(string name)
  644. {
  645. return Items[name];
  646. }
  647.  
  648. protected void SetColor(string name, Color value)
  649. {
  650. if (Items.ContainsKey(name))
  651. Items[name] = value;
  652. else
  653. Items.Add(name, value);
  654. }
  655. protected void SetColor(string name, byte r, byte g, byte b)
  656. {
  657. SetColor(name, Color.FromArgb(r, g, b));
  658. }
  659. protected void SetColor(string name, byte a, byte r, byte g, byte b)
  660. {
  661. SetColor(name, Color.FromArgb(a, r, g, b));
  662. }
  663. protected void SetColor(string name, byte a, Color value)
  664. {
  665. SetColor(name, Color.FromArgb(a, value));
  666. }
  667.  
  668. private void InvalidateCustimization()
  669. {
  670. MemoryStream M = new MemoryStream(Items.Count * 4);
  671.  
  672. foreach (Bloom B in Colors)
  673. {
  674. M.Write(BitConverter.GetBytes(B.Value.ToArgb()), 0, 4);
  675. }
  676.  
  677. M.Close();
  678. _Customization = Convert.ToBase64String(M.ToArray());
  679. }
  680.  
  681. #endregion
  682.  
  683.  
  684. #region " User Hooks "
  685.  
  686. protected abstract void ColorHook();
  687. protected abstract void PaintHook();
  688.  
  689. #endregion
  690.  
  691.  
  692. #region " Center Overloads "
  693.  
  694.  
  695. private Point CenterReturn;
  696. protected Point Center(Rectangle r1, Size s1)
  697. {
  698. CenterReturn = new Point((r1.Width / 2 - s1.Width / 2) + r1.X, (r1.Height / 2 - s1.Height / 2) + r1.Y);
  699. return CenterReturn;
  700. }
  701. protected Point Center(Rectangle r1, Rectangle r2)
  702. {
  703. return Center(r1, r2.Size);
  704. }
  705.  
  706. protected Point Center(int w1, int h1, int w2, int h2)
  707. {
  708. CenterReturn = new Point(w1 / 2 - w2 / 2, h1 / 2 - h2 / 2);
  709. return CenterReturn;
  710. }
  711.  
  712. protected Point Center(Size s1, Size s2)
  713. {
  714. return Center(s1.Width, s1.Height, s2.Width, s2.Height);
  715. }
  716.  
  717. protected Point Center(Rectangle r1)
  718. {
  719. return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height);
  720. }
  721. protected Point Center(Size s1)
  722. {
  723. return Center(Width, Height, s1.Width, s1.Height);
  724. }
  725. protected Point Center(int w1, int h1)
  726. {
  727. return Center(Width, Height, w1, h1);
  728. }
  729.  
  730. #endregion
  731.  
  732. #region " Measure Overloads "
  733.  
  734. private Bitmap MeasureBitmap;
  735.  
  736. private Graphics MeasureGraphics;
  737. protected Size Measure(string text)
  738. {
  739. return MeasureGraphics.MeasureString(text, Font, Width).ToSize();
  740. }
  741. protected Size Measure()
  742. {
  743. return MeasureGraphics.MeasureString(Text, Font).ToSize();
  744. }
  745.  
  746. #endregion
  747.  
  748. #region " DrawCorners Overloads "
  749.  
  750.  
  751. private SolidBrush DrawCornersBrush;
  752. protected void DrawCorners(Color c1)
  753. {
  754. DrawCorners(c1, 0, 0, Width, Height);
  755. }
  756. protected void DrawCorners(Color c1, Rectangle r1)
  757. {
  758. DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height);
  759. }
  760. protected void DrawCorners(Color c1, int x, int y, int width, int height)
  761. {
  762. if (_NoRounding)
  763. return;
  764. DrawCornersBrush = new SolidBrush(c1);
  765. G.FillRectangle(DrawCornersBrush, x, y, 1, 1);
  766. G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1);
  767. G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1);
  768. G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1);
  769. }
  770.  
  771. #endregion
  772.  
  773. #region " DrawBorders Overloads "
  774.  
  775. //TODO: Remove triple overload?
  776.  
  777. protected void DrawBorders(Pen p1, int x, int y, int width, int height, int offset)
  778. {
  779. DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
  780. }
  781. protected void DrawBorders(Pen p1, int offset)
  782. {
  783. DrawBorders(p1, 0, 0, Width, Height, offset);
  784. }
  785. protected void DrawBorders(Pen p1, Rectangle r, int offset)
  786. {
  787. DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset);
  788. }
  789.  
  790. protected void DrawBorders(Pen p1, int x, int y, int width, int height)
  791. {
  792. G.DrawRectangle(p1, x, y, width - 1, height - 1);
  793. }
  794. protected void DrawBorders(Pen p1)
  795. {
  796. DrawBorders(p1, 0, 0, Width, Height);
  797. }
  798. protected void DrawBorders(Pen p1, Rectangle r)
  799. {
  800. DrawBorders(p1, r.X, r.Y, r.Width, r.Height);
  801. }
  802.  
  803. #endregion
  804.  
  805. #region " DrawText Overloads "
  806.  
  807. //TODO: Remove triple overloads?
  808.  
  809. private Point DrawTextPoint;
  810.  
  811. private Size DrawTextSize;
  812. protected void DrawText(Brush b1, HorizontalAlignment a, int x, int y)
  813. {
  814. DrawText(b1, Text, a, x, y);
  815. }
  816. protected void DrawText(Brush b1, Point p1)
  817. {
  818. DrawText(b1, Text, p1.X, p1.Y);
  819. }
  820. protected void DrawText(Brush b1, int x, int y)
  821. {
  822. DrawText(b1, Text, x, y);
  823. }
  824.  
  825. protected void DrawText(Brush b1, string text, HorizontalAlignment a, int x, int y)
  826. {
  827. if (text.Length == 0)
  828. return;
  829. DrawTextSize = Measure(text);
  830.  
  831. if (_ControlMode)
  832. {
  833. DrawTextPoint = Center(DrawTextSize);
  834. }
  835. else
  836. {
  837. DrawTextPoint = new Point(Width / 2 - DrawTextSize.Width / 2, MoveHeight / 2 - DrawTextSize.Height / 2);
  838. }
  839.  
  840. switch (a)
  841. {
  842. case HorizontalAlignment.Left:
  843. DrawText(b1, text, x, DrawTextPoint.Y + y);
  844. break;
  845. case HorizontalAlignment.Center:
  846. DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y);
  847. break;
  848. case HorizontalAlignment.Right:
  849. DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y);
  850. break;
  851. }
  852. }
  853. protected void DrawText(Brush b1, string text, Point p1)
  854. {
  855. DrawText(b1, text, p1.X, p1.Y);
  856. }
  857. protected void DrawText(Brush b1, string text, int x, int y)
  858. {
  859. if (text.Length == 0)
  860. return;
  861. G.DrawString(text, Font, b1, x, y);
  862. }
  863.  
  864. #endregion
  865.  
  866. #region " DrawImage Overloads "
  867.  
  868. //TODO: Remove triple overloads?
  869.  
  870.  
  871. private Point DrawImagePoint;
  872. protected void DrawImage(HorizontalAlignment a, int x, int y)
  873. {
  874. DrawImage(_Image, a, x, y);
  875. }
  876. protected void DrawImage(Point p1)
  877. {
  878. DrawImage(_Image, p1.X, p1.Y);
  879. }
  880. protected void DrawImage(int x, int y)
  881. {
  882. DrawImage(_Image, x, y);
  883. }
  884.  
  885. protected void DrawImage(Image image, HorizontalAlignment a, int x, int y)
  886. {
  887. if (image == null)
  888. return;
  889.  
  890. if (_ControlMode)
  891. {
  892. DrawImagePoint = Center(image.Size);
  893. }
  894. else
  895. {
  896. DrawImagePoint = new Point(Width / 2 - image.Width / 2, MoveHeight / 2 - image.Height / 2);
  897. }
  898.  
  899. switch (a)
  900. {
  901. case HorizontalAlignment.Left:
  902. DrawImage(image, x, DrawImagePoint.Y + y);
  903. break;
  904. case HorizontalAlignment.Center:
  905. DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y);
  906. break;
  907. case HorizontalAlignment.Right:
  908. DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y);
  909. break;
  910. }
  911. }
  912. protected void DrawImage(Image image, Point p1)
  913. {
  914. DrawImage(image, p1.X, p1.Y);
  915. }
  916. protected void DrawImage(Image image, int x, int y)
  917. {
  918. if (image == null)
  919. return;
  920. G.DrawImage(image, x, y, image.Width, image.Height);
  921. }
  922.  
  923. #endregion
  924.  
  925. #region " DrawGradient Overloads "
  926.  
  927. //TODO: Remove triple overload?
  928.  
  929. private LinearGradientBrush DrawGradientBrush;
  930.  
  931. private Rectangle DrawGradientRectangle;
  932. protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height)
  933. {
  934. DrawGradient(blend, x, y, width, height, 90);
  935. }
  936. protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height)
  937. {
  938. DrawGradient(c1, c2, x, y, width, height, 90);
  939. }
  940.  
  941. protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height, float angle)
  942. {
  943. DrawGradientRectangle = new Rectangle(x, y, width, height);
  944. DrawGradient(blend, DrawGradientRectangle, angle);
  945. }
  946. protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
  947. {
  948. DrawGradientRectangle = new Rectangle(x, y, width, height);
  949. DrawGradient(c1, c2, DrawGradientRectangle, angle);
  950. }
  951.  
  952. protected void DrawGradient(ColorBlend blend, Rectangle r, float angle)
  953. {
  954. DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, angle);
  955. DrawGradientBrush.InterpolationColors = blend;
  956. G.FillRectangle(DrawGradientBrush, r);
  957. }
  958. protected void DrawGradient(Color c1, Color c2, Rectangle r, float angle)
  959. {
  960. DrawGradientBrush = new LinearGradientBrush(r, c1, c2, angle);
  961. G.FillRectangle(DrawGradientBrush, r);
  962. }
  963.  
  964. #endregion
  965.  
  966. }
  967.  
  968. abstract class ThemeControl152 : Control
  969. {
  970.  
  971. protected Graphics G;
  972.  
  973. protected Bitmap B;
  974. public ThemeControl152()
  975. {
  976. SetStyle((ControlStyles)139270, true);
  977.  
  978. _ImageSize = Size.Empty;
  979.  
  980. MeasureBitmap = new Bitmap(1, 1);
  981. MeasureGraphics = Graphics.FromImage(MeasureBitmap);
  982.  
  983. Font = new Font("Verdana", 8);
  984.  
  985. InvalidateCustimization();
  986. }
  987.  
  988. protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
  989. {
  990. if (!(_LockWidth == 0))
  991. width = _LockWidth;
  992. if (!(_LockHeight == 0))
  993. height = _LockHeight;
  994. base.SetBoundsCore(x, y, width, height, specified);
  995. }
  996.  
  997. protected override sealed void OnSizeChanged(EventArgs e)
  998. {
  999. if (_Transparent && !(Width == 0 || Height == 0))
  1000. {
  1001. B = new Bitmap(Width, Height);
  1002. G = Graphics.FromImage(B);
  1003. }
  1004.  
  1005. Invalidate();
  1006. base.OnSizeChanged(e);
  1007. }
  1008.  
  1009. protected override sealed void OnPaint(PaintEventArgs e)
  1010. {
  1011. if (Width == 0 || Height == 0)
  1012. return;
  1013.  
  1014. if (_Transparent)
  1015. {
  1016. PaintHook();
  1017. e.Graphics.DrawImage(B, 0, 0);
  1018. }
  1019. else
  1020. {
  1021. G = e.Graphics;
  1022. PaintHook();
  1023. }
  1024. }
  1025.  
  1026. protected override sealed void OnHandleCreated(EventArgs e)
  1027. {
  1028. InvalidateCustimization();
  1029. ColorHook();
  1030.  
  1031. if (!(_LockWidth == 0))
  1032. Width = _LockWidth;
  1033. if (!(_LockHeight == 0))
  1034. Height = _LockHeight;
  1035.  
  1036. Transparent = _Transparent;
  1037. if (_BackColorU && _Transparent)
  1038. BackColor = Color.Transparent;
  1039.  
  1040. base.OnHandleCreated(e);
  1041. }
  1042.  
  1043. protected override sealed void OnParentChanged(EventArgs e)
  1044. {
  1045. if (Parent != null)
  1046. OnCreation();
  1047. base.OnParentChanged(e);
  1048. }
  1049.  
  1050. protected virtual void OnCreation()
  1051. {
  1052. }
  1053.  
  1054. #region " State Handling "
  1055.  
  1056. private bool InPosition;
  1057. protected override void OnMouseEnter(EventArgs e)
  1058. {
  1059. InPosition = true;
  1060. SetState(MouseState.Over);
  1061. base.OnMouseEnter(e);
  1062. }
  1063.  
  1064. protected override void OnMouseUp(MouseEventArgs e)
  1065. {
  1066. if (InPosition)
  1067. SetState(MouseState.Over);
  1068. base.OnMouseUp(e);
  1069. }
  1070.  
  1071. protected override void OnMouseDown(MouseEventArgs e)
  1072. {
  1073. if (e.Button == System.Windows.Forms.MouseButtons.Left)
  1074. SetState(MouseState.Down);
  1075. base.OnMouseDown(e);
  1076. }
  1077.  
  1078. protected override void OnMouseLeave(EventArgs e)
  1079. {
  1080. InPosition = false;
  1081. SetState(MouseState.None);
  1082. base.OnMouseLeave(e);
  1083. }
  1084.  
  1085. protected override void OnEnabledChanged(EventArgs e)
  1086. {
  1087. if (Enabled)
  1088. SetState(MouseState.None);
  1089. else
  1090. SetState(MouseState.Block);
  1091. base.OnEnabledChanged(e);
  1092. }
  1093.  
  1094. protected MouseState State;
  1095. private void SetState(MouseState current)
  1096. {
  1097. State = current;
  1098. Invalidate();
  1099. }
  1100.  
  1101. #endregion
  1102.  
  1103.  
  1104. #region " Property Overrides "
  1105.  
  1106. private bool _BackColorU;
  1107. [Category("Misc")]
  1108. public override Color BackColor
  1109. {
  1110. get { return base.BackColor; }
  1111. set
  1112. {
  1113. if (!IsHandleCreated && value == Color.Transparent)
  1114. {
  1115. _BackColorU = true;
  1116. return;
  1117. }
  1118.  
  1119. base.BackColor = value;
  1120. if (Parent != null)
  1121. ColorHook();
  1122. }
  1123. }
  1124.  
  1125. [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1126. public override Color ForeColor
  1127. {
  1128. get { return Color.Empty; }
  1129. set { }
  1130. }
  1131. [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1132. public override Image BackgroundImage
  1133. {
  1134. get { return null; }
  1135. set { }
  1136. }
  1137. [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1138. public override ImageLayout BackgroundImageLayout
  1139. {
  1140. get { return ImageLayout.None; }
  1141. set { }
  1142. }
  1143.  
  1144. public override string Text
  1145. {
  1146. get { return base.Text; }
  1147. set
  1148. {
  1149. base.Text = value;
  1150. Invalidate();
  1151. }
  1152. }
  1153.  
  1154. public override Font Font
  1155. {
  1156. get { return base.Font; }
  1157. set
  1158. {
  1159. base.Font = value;
  1160. Invalidate();
  1161. }
  1162. }
  1163.  
  1164. #endregion
  1165.  
  1166. #region " Properties "
  1167.  
  1168. private bool _NoRounding;
  1169. public bool NoRounding
  1170. {
  1171. get { return _NoRounding; }
  1172. set
  1173. {
  1174. _NoRounding = value;
  1175. Invalidate();
  1176. }
  1177. }
  1178.  
  1179. private Image _Image;
  1180. public Image Image
  1181. {
  1182. get { return _Image; }
  1183. set
  1184. {
  1185. if (value == null)
  1186. {
  1187. _ImageSize = Size.Empty;
  1188. }
  1189. else
  1190. {
  1191. _ImageSize = value.Size;
  1192. }
  1193.  
  1194. _Image = value;
  1195. Invalidate();
  1196. }
  1197. }
  1198.  
  1199. private Size _ImageSize;
  1200. protected Size ImageSize
  1201. {
  1202. get { return _ImageSize; }
  1203. }
  1204.  
  1205. private int _LockWidth;
  1206. protected int LockWidth
  1207. {
  1208. get { return _LockWidth; }
  1209. set
  1210. {
  1211. _LockWidth = value;
  1212. if (!(LockWidth == 0) && IsHandleCreated)
  1213. Width = LockWidth;
  1214. }
  1215. }
  1216.  
  1217. private int _LockHeight;
  1218. protected int LockHeight
  1219. {
  1220. get { return _LockHeight; }
  1221. set
  1222. {
  1223. _LockHeight = value;
  1224. if (!(LockHeight == 0) && IsHandleCreated)
  1225. Height = LockHeight;
  1226. }
  1227. }
  1228.  
  1229. private bool _Transparent;
  1230. public bool Transparent
  1231. {
  1232. get { return _Transparent; }
  1233. set
  1234. {
  1235. _Transparent = value;
  1236. if (!IsHandleCreated)
  1237. return;
  1238.  
  1239. if (!value && !(BackColor.A == 255))
  1240. {
  1241. throw new Exception("Unable to change value to false while a transparent BackColor is in use.");
  1242. }
  1243.  
  1244. SetStyle(ControlStyles.Opaque, !value);
  1245. SetStyle(ControlStyles.SupportsTransparentBackColor, value);
  1246.  
  1247. if (value)
  1248. InvalidateBitmap();
  1249. else
  1250. B = null;
  1251. Invalidate();
  1252. }
  1253. }
  1254.  
  1255. private Dictionary<string, Color> Items = new Dictionary<string, Color>();
  1256. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  1257. public Bloom[] Colors
  1258. {
  1259. get
  1260. {
  1261. List<Bloom> T = new List<Bloom>();
  1262. Dictionary<string, Color>.Enumerator E = Items.GetEnumerator();
  1263.  
  1264. while (E.MoveNext())
  1265. {
  1266. T.Add(new Bloom(E.Current.Key, E.Current.Value));
  1267. }
  1268.  
  1269. return T.ToArray();
  1270. }
  1271. set
  1272. {
  1273. foreach (Bloom B in value)
  1274. {
  1275. if (Items.ContainsKey(B.Name))
  1276. Items[B.Name] = B.Value;
  1277. }
  1278.  
  1279. InvalidateCustimization();
  1280. ColorHook();
  1281. Invalidate();
  1282. }
  1283. }
  1284.  
  1285. private string _Customization;
  1286. public string Customization
  1287. {
  1288. get { return _Customization; }
  1289. set
  1290. {
  1291. if (value == _Customization)
  1292. return;
  1293.  
  1294. byte[] Data = null;
  1295. Bloom[] Items = Colors;
  1296.  
  1297. try
  1298. {
  1299. Data = Convert.FromBase64String(value);
  1300. for (int I = 0; I <= Items.Length - 1; I++)
  1301. {
  1302. Items[I].Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4));
  1303. }
  1304. }
  1305. catch
  1306. {
  1307. return;
  1308. }
  1309.  
  1310. _Customization = value;
  1311.  
  1312. Colors = Items;
  1313. ColorHook();
  1314. Invalidate();
  1315. }
  1316. }
  1317.  
  1318. #endregion
  1319.  
  1320. #region " Property Helpers "
  1321.  
  1322. private void InvalidateBitmap()
  1323. {
  1324. if (Width == 0 || Height == 0)
  1325. return;
  1326. B = new Bitmap(Width, Height);
  1327. G = Graphics.FromImage(B);
  1328. }
  1329.  
  1330. protected Color GetColor(string name)
  1331. {
  1332. return Items[name];
  1333. }
  1334.  
  1335. protected void SetColor(string name, Color value)
  1336. {
  1337. if (Items.ContainsKey(name))
  1338. Items[name] = value;
  1339. else
  1340. Items.Add(name, value);
  1341. }
  1342. protected void SetColor(string name, byte r, byte g, byte b)
  1343. {
  1344. SetColor(name, Color.FromArgb(r, g, b));
  1345. }
  1346. protected void SetColor(string name, byte a, byte r, byte g, byte b)
  1347. {
  1348. SetColor(name, Color.FromArgb(a, r, g, b));
  1349. }
  1350. protected void SetColor(string name, byte a, Color value)
  1351. {
  1352. SetColor(name, Color.FromArgb(a, value));
  1353. }
  1354.  
  1355. private void InvalidateCustimization()
  1356. {
  1357. MemoryStream M = new MemoryStream(Items.Count * 4);
  1358.  
  1359. foreach (Bloom B in Colors)
  1360. {
  1361. M.Write(BitConverter.GetBytes(B.Value.ToArgb()), 0, 4);
  1362. }
  1363.  
  1364. M.Close();
  1365. _Customization = Convert.ToBase64String(M.ToArray());
  1366. }
  1367.  
  1368. #endregion
  1369.  
  1370.  
  1371. #region " User Hooks "
  1372.  
  1373. protected abstract void ColorHook();
  1374. protected abstract void PaintHook();
  1375.  
  1376. #endregion
  1377.  
  1378.  
  1379. #region " Center Overloads "
  1380.  
  1381.  
  1382. private Point CenterReturn;
  1383. protected Point Center(Rectangle r1, Size s1)
  1384. {
  1385. CenterReturn = new Point((r1.Width / 2 - s1.Width / 2) + r1.X, (r1.Height / 2 - s1.Height / 2) + r1.Y);
  1386. return CenterReturn;
  1387. }
  1388. protected Point Center(Rectangle r1, Rectangle r2)
  1389. {
  1390. return Center(r1, r2.Size);
  1391. }
  1392.  
  1393. protected Point Center(int w1, int h1, int w2, int h2)
  1394. {
  1395. CenterReturn = new Point(w1 / 2 - w2 / 2, h1 / 2 - h2 / 2);
  1396. return CenterReturn;
  1397. }
  1398.  
  1399. protected Point Center(Size s1, Size s2)
  1400. {
  1401. return Center(s1.Width, s1.Height, s2.Width, s2.Height);
  1402. }
  1403.  
  1404. protected Point Center(Rectangle r1)
  1405. {
  1406. return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height);
  1407. }
  1408. protected Point Center(Size s1)
  1409. {
  1410. return Center(Width, Height, s1.Width, s1.Height);
  1411. }
  1412. protected Point Center(int w1, int h1)
  1413. {
  1414. return Center(Width, Height, w1, h1);
  1415. }
  1416.  
  1417. #endregion
  1418.  
  1419. #region " Measure Overloads "
  1420.  
  1421. private Bitmap MeasureBitmap;
  1422.  
  1423. private Graphics MeasureGraphics;
  1424. protected Size Measure(string text)
  1425. {
  1426. return MeasureGraphics.MeasureString(text, Font, Width).ToSize();
  1427. }
  1428. protected Size Measure()
  1429. {
  1430. return MeasureGraphics.MeasureString(Text, Font, Width).ToSize();
  1431. }
  1432.  
  1433. #endregion
  1434.  
  1435. #region " DrawCorners Overloads "
  1436.  
  1437.  
  1438. private SolidBrush DrawCornersBrush;
  1439. protected void DrawCorners(Color c1)
  1440. {
  1441. DrawCorners(c1, 0, 0, Width, Height);
  1442. }
  1443. protected void DrawCorners(Color c1, Rectangle r1)
  1444. {
  1445. DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height);
  1446. }
  1447. protected void DrawCorners(Color c1, int x, int y, int width, int height)
  1448. {
  1449. if (_NoRounding)
  1450. return;
  1451.  
  1452. if (_Transparent)
  1453. {
  1454. B.SetPixel(x, y, c1);
  1455. B.SetPixel(x + (width - 1), y, c1);
  1456. B.SetPixel(x, y + (height - 1), c1);
  1457. B.SetPixel(x + (width - 1), y + (height - 1), c1);
  1458. }
  1459. else
  1460. {
  1461. DrawCornersBrush = new SolidBrush(c1);
  1462. G.FillRectangle(DrawCornersBrush, x, y, 1, 1);
  1463. G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1);
  1464. G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1);
  1465. G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1);
  1466. }
  1467. }
  1468.  
  1469. #endregion
  1470.  
  1471. #region " DrawBorders Overloads "
  1472.  
  1473. //TODO: Remove triple overload?
  1474.  
  1475. protected void DrawBorders(Pen p1, int x, int y, int width, int height, int offset)
  1476. {
  1477. DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
  1478. }
  1479. protected void DrawBorders(Pen p1, int offset)
  1480. {
  1481. DrawBorders(p1, 0, 0, Width, Height, offset);
  1482. }
  1483. protected void DrawBorders(Pen p1, Rectangle r, int offset)
  1484. {
  1485. DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset);
  1486. }
  1487.  
  1488. protected void DrawBorders(Pen p1, int x, int y, int width, int height)
  1489. {
  1490. G.DrawRectangle(p1, x, y, width - 1, height - 1);
  1491. }
  1492. protected void DrawBorders(Pen p1)
  1493. {
  1494. DrawBorders(p1, 0, 0, Width, Height);
  1495. }
  1496. protected void DrawBorders(Pen p1, Rectangle r)
  1497. {
  1498. DrawBorders(p1, r.X, r.Y, r.Width, r.Height);
  1499. }
  1500.  
  1501. #endregion
  1502.  
  1503. #region " DrawText Overloads "
  1504.  
  1505. //TODO: Remove triple overloads?
  1506.  
  1507. private Point DrawTextPoint;
  1508.  
  1509. private Size DrawTextSize;
  1510. protected void DrawText(Brush b1, HorizontalAlignment a, int x, int y)
  1511. {
  1512. DrawText(b1, Text, a, x, y);
  1513. }
  1514. protected void DrawText(Brush b1, Point p1)
  1515. {
  1516. DrawText(b1, Text, p1.X, p1.Y);
  1517. }
  1518. protected void DrawText(Brush b1, int x, int y)
  1519. {
  1520. DrawText(b1, Text, x, y);
  1521. }
  1522.  
  1523. protected void DrawText(Brush b1, string text, HorizontalAlignment a, int x, int y)
  1524. {
  1525. if (text.Length == 0)
  1526. return;
  1527. DrawTextSize = Measure(text);
  1528. DrawTextPoint = Center(DrawTextSize);
  1529.  
  1530. switch (a)
  1531. {
  1532. case HorizontalAlignment.Left:
  1533. DrawText(b1, text, x, DrawTextPoint.Y + y);
  1534. break;
  1535. case HorizontalAlignment.Center:
  1536. DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y);
  1537. break;
  1538. case HorizontalAlignment.Right:
  1539. DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y);
  1540. break;
  1541. }
  1542. }
  1543. protected void DrawText(Brush b1, string text, Point p1)
  1544. {
  1545. DrawText(b1, text, p1.X, p1.Y);
  1546. }
  1547. protected void DrawText(Brush b1, string text, int x, int y)
  1548. {
  1549. if (text.Length == 0)
  1550. return;
  1551. G.DrawString(text, Font, b1, x, y);
  1552. }
  1553.  
  1554. #endregion
  1555.  
  1556. #region " DrawImage Overloads "
  1557.  
  1558. //TODO: Remove triple overloads?
  1559.  
  1560.  
  1561. private Point DrawImagePoint;
  1562. protected void DrawImage(HorizontalAlignment a, int x, int y)
  1563. {
  1564. DrawImage(_Image, a, x, y);
  1565. }
  1566. protected void DrawImage(Point p1)
  1567. {
  1568. DrawImage(_Image, p1.X, p1.Y);
  1569. }
  1570. protected void DrawImage(int x, int y)
  1571. {
  1572. DrawImage(_Image, x, y);
  1573. }
  1574.  
  1575. protected void DrawImage(Image image, HorizontalAlignment a, int x, int y)
  1576. {
  1577. if (image == null)
  1578. return;
  1579. DrawImagePoint = Center(image.Size);
  1580.  
  1581. switch (a)
  1582. {
  1583. case HorizontalAlignment.Left:
  1584. DrawImage(image, x, DrawImagePoint.Y + y);
  1585. break;
  1586. case HorizontalAlignment.Center:
  1587. DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y);
  1588. break;
  1589. case HorizontalAlignment.Right:
  1590. DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y);
  1591. break;
  1592. }
  1593. }
  1594. protected void DrawImage(Image image, Point p1)
  1595. {
  1596. DrawImage(image, p1.X, p1.Y);
  1597. }
  1598. protected void DrawImage(Image image, int x, int y)
  1599. {
  1600. if (image == null)
  1601. return;
  1602. G.DrawImage(image, x, y, image.Width, image.Height);
  1603. }
  1604.  
  1605. #endregion
  1606.  
  1607. #region " DrawGradient Overloads "
  1608.  
  1609. //TODO: Remove triple overload?
  1610.  
  1611. private LinearGradientBrush DrawGradientBrush;
  1612.  
  1613. private Rectangle DrawGradientRectangle;
  1614. protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height)
  1615. {
  1616. DrawGradient(blend, x, y, width, height, 90);
  1617. }
  1618. protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height)
  1619. {
  1620. DrawGradient(c1, c2, x, y, width, height, 90);
  1621. }
  1622.  
  1623. protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height, float angle)
  1624. {
  1625. DrawGradientRectangle = new Rectangle(x, y, width, height);
  1626. DrawGradient(blend, DrawGradientRectangle, angle);
  1627. }
  1628. protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
  1629. {
  1630. DrawGradientRectangle = new Rectangle(x, y, width, height);
  1631. DrawGradient(c1, c2, DrawGradientRectangle, angle);
  1632. }
  1633.  
  1634. protected void DrawGradient(ColorBlend blend, Rectangle r, float angle)
  1635. {
  1636. DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, angle);
  1637. DrawGradientBrush.InterpolationColors = blend;
  1638. G.FillRectangle(DrawGradientBrush, r);
  1639. }
  1640. protected void DrawGradient(Color c1, Color c2, Rectangle r, float angle)
  1641. {
  1642. DrawGradientBrush = new LinearGradientBrush(r, c1, c2, angle);
  1643. G.FillRectangle(DrawGradientBrush, r);
  1644. }
  1645.  
  1646. #endregion
  1647.  
  1648. }
  1649.  
  1650. enum MouseState : byte
  1651. {
  1652. None = 0,
  1653. Over = 1,
  1654. Down = 2,
  1655. Block = 3
  1656. }
  1657.  
  1658. class Bloom
  1659. {
  1660.  
  1661. private string _Name;
  1662. public string Name
  1663. {
  1664. get { return _Name; }
  1665. set { _Name = value; }
  1666. }
  1667.  
  1668. private Color _Value;
  1669. public Color Value
  1670. {
  1671. get { return _Value; }
  1672. set { _Value = value; }
  1673. }
  1674.  
  1675. public Bloom()
  1676. {
  1677. }
  1678.  
  1679. public Bloom(string name, Color value)
  1680. {
  1681. _Name = name;
  1682. _Value = value;
  1683. }
  1684. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement