Advertisement
Astekk

Theme Converted to C#

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