Alex-Trader

Play UI C#

Jul 26th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #region  Imports
  2.  
  3.     using System;
  4.     using System.Drawing;
  5.     using System.Windows.Forms;
  6.     using System.Drawing.Drawing2D;
  7.     using System.ComponentModel;
  8.    
  9. #endregion
  10.    
  11.     //|------DO-NOT-REMOVE------|
  12.     //
  13.     // Creator: HazelDev
  14.     // Site   : HazelDev.com
  15.     // Created: 16.Oct.2014
  16.     // Changed: 18.Oct.2014
  17.     // Version: 1.0.0
  18.     //
  19.     //|------DO-NOT-REMOVE------|
  20.    
  21. #region  Theme Container
  22.    
  23.     public class PlayUI_ThemeContainer : ContainerControl
  24.     {
  25.        
  26. #region  Enums
  27.        
  28.         public enum MouseState
  29.         {
  30.             None = 0,
  31.             Over = 1,
  32.             Down = 2,
  33.             Block = 3
  34.         }
  35.        
  36. #endregion
  37. #region  Variables
  38.        
  39.         private Rectangle HeaderRect;
  40.         protected MouseState State;
  41.         private int MoveHeight;
  42.         private Point MouseP = new Point(0, 0);
  43.         private bool Cap = false;
  44.         private bool HasShown;
  45.        
  46. #endregion
  47. #region  Properties
  48.        
  49.         private bool _Sizable = true;
  50. public bool Sizable
  51.         {
  52.             get
  53.             {
  54.                 return _Sizable;
  55.             }
  56.             set
  57.             {
  58.                 _Sizable = value;
  59.             }
  60.         }
  61.        
  62.         private bool _SmartBounds = true;
  63. public bool SmartBounds
  64.         {
  65.             get
  66.             {
  67.                 return _SmartBounds;
  68.             }
  69.             set
  70.             {
  71.                 _SmartBounds = value;
  72.             }
  73.         }
  74.        
  75.         private bool _RoundCorners = true;
  76. public bool RoundCorners
  77.         {
  78.             get
  79.             {
  80.                 return _RoundCorners;
  81.             }
  82.             set
  83.             {
  84.                 _RoundCorners = value;
  85.                 Invalidate();
  86.             }
  87.         }
  88.        
  89.         private bool _IsParentForm;
  90. protected bool IsParentForm
  91.         {
  92.             get
  93.             {
  94.                 return _IsParentForm;
  95.             }
  96.         }
  97.        
  98. protected bool IsParentMdi
  99.         {
  100.             get
  101.             {
  102.                 if (Parent == null)
  103.                 {
  104.                     return false;
  105.                 }
  106.                 return Parent.Parent != null;
  107.             }
  108.         }
  109.        
  110.         private bool _ControlMode;
  111. protected bool ControlMode
  112.         {
  113.             get
  114.             {
  115.                 return _ControlMode;
  116.             }
  117.             set
  118.             {
  119.                 _ControlMode = value;
  120.                 Invalidate();
  121.             }
  122.         }
  123.        
  124.         private FormStartPosition _StartPosition;
  125. public FormStartPosition StartPosition
  126.         {
  127.             get
  128.             {
  129.                 if (_IsParentForm && !_ControlMode)
  130.                 {
  131.                     return ParentForm.StartPosition;
  132.                 }
  133.                 else
  134.                 {
  135.                     return _StartPosition;
  136.                 }
  137.             }
  138.             set
  139.             {
  140.                 _StartPosition = value;
  141.                
  142.                 if (_IsParentForm && !_ControlMode)
  143.                 {
  144.                     ParentForm.StartPosition = value;
  145.                 }
  146.             }
  147.         }
  148.        
  149. #endregion
  150. #region  EventArgs
  151.        
  152.         protected sealed override void OnParentChanged(EventArgs e)
  153.         {
  154.             base.OnParentChanged(e);
  155.            
  156.             if (Parent == null)
  157.             {
  158.                 return ;
  159.             }
  160.             _IsParentForm = Parent is Form;
  161.            
  162.             if (!_ControlMode)
  163.             {
  164.                 InitializeMessages();
  165.                
  166.                 if (_IsParentForm)
  167.                 {
  168.                     this.ParentForm.FormBorderStyle = FormBorderStyle.None;
  169.                     this.ParentForm.TransparencyKey = Color.Fuchsia;
  170.                    
  171.                     if (!DesignMode)
  172.                     {
  173.                         ParentForm.Shown += FormShown;
  174.                     }
  175.                 }
  176.                 Parent.BackColor = BackColor;
  177.                 Parent.MinimumSize = new Size(261, 65);
  178.             }
  179.         }
  180.        
  181.         protected sealed override void OnSizeChanged(EventArgs e)
  182.         {
  183.             base.OnSizeChanged(e);
  184.             if (!_ControlMode)
  185.             {
  186.                 HeaderRect = new Rectangle(0, 0, Width - 14, MoveHeight - 7);
  187.             }
  188.             Invalidate();
  189.         }
  190.        
  191.         protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
  192.         {
  193.             base.OnMouseDown(e);
  194.             if (e.Button == MouseButtons.Left)
  195.             {
  196.                 SetState(MouseState.Down);
  197.             }
  198.             if (!(_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized || _ControlMode))
  199.             {
  200.                 if (HeaderRect.Contains(e.Location))
  201.                 {
  202.                     Capture = false;
  203.                     WM_LMBUTTONDOWN = true;
  204.                     DefWndProc(ref Messages[0]);
  205.                 }
  206.                 else if (_Sizable && !(Previous == 0))
  207.                 {
  208.                     Capture = false;
  209.                     WM_LMBUTTONDOWN = true;
  210.                     DefWndProc(ref Messages[Previous]);
  211.                 }
  212.             }
  213.         }
  214.        
  215.         protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
  216.         {
  217.             base.OnMouseUp(e);
  218.             Cap = false;
  219.         }
  220.        
  221.         protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
  222.         {
  223.             base.OnMouseMove(e);
  224.             if (!(_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized))
  225.             {
  226.                 if (_Sizable && !_ControlMode)
  227.                 {
  228.                     InvalidateMouse();
  229.                 }
  230.             }
  231.             if (Cap)
  232.             {
  233.                 Parent.Location = (System.Drawing.Point) ((object) (System.Convert.ToDouble(MousePosition ) - System.Convert.ToDouble( MouseP)));
  234.             }
  235.         }
  236.        
  237.         protected override void OnInvalidated(System.Windows.Forms.InvalidateEventArgs e)
  238.         {
  239.             base.OnInvalidated(e);
  240.             ParentForm.Text = Text;
  241.         }
  242.        
  243.         protected override void OnPaintBackground(PaintEventArgs e)
  244.         {
  245.             base.OnPaintBackground(e);
  246.         }
  247.        
  248.         protected override void OnTextChanged(System.EventArgs e)
  249.         {
  250.             base.OnTextChanged(e);
  251.             Invalidate();
  252.         }
  253.        
  254.         private void FormShown(object sender, EventArgs e)
  255.         {
  256.             if (_ControlMode || HasShown)
  257.             {
  258.                 return ;
  259.             }
  260.            
  261.             if (_StartPosition == FormStartPosition.CenterParent || _StartPosition == FormStartPosition.CenterScreen)
  262.             {
  263.                 Rectangle SB = Screen.PrimaryScreen.Bounds;
  264.                 Rectangle CB = ParentForm.Bounds;
  265.                 ParentForm.Location = new Point(SB.Width / 2 - CB.Width / 2, SB.Height / 2 - CB.Width / 2);
  266.             }
  267.             HasShown = true;
  268.         }
  269.        
  270. #endregion
  271. #region  Mouse & Size
  272.        
  273.         private void SetState(MouseState current)
  274.         {
  275.             State = current;
  276.             Invalidate();
  277.         }
  278.        
  279.         private Point GetIndexPoint;
  280.         private bool B1x;
  281.         private bool B2x;
  282.         private bool B3;
  283.         private bool B4;
  284.         private int GetIndex()
  285.         {
  286.             GetIndexPoint = PointToClient(MousePosition);
  287.             B1x = GetIndexPoint.X < 7;
  288.             B2x = GetIndexPoint.X > Width - 7;
  289.             B3 = GetIndexPoint.Y < 7;
  290.             B4 = GetIndexPoint.Y > Height - 7;
  291.            
  292.             if (B1x && B3)
  293.             {
  294.                 return 4;
  295.             }
  296.             if (B1x && B4)
  297.             {
  298.                 return 7;
  299.             }
  300.             if (B2x && B3)
  301.             {
  302.                 return 5;
  303.             }
  304.             if (B2x && B4)
  305.             {
  306.                 return 8;
  307.             }
  308.             if (B1x)
  309.             {
  310.                 return 1;
  311.             }
  312.             if (B2x)
  313.             {
  314.                 return 2;
  315.             }
  316.             if (B3)
  317.             {
  318.                 return 3;
  319.             }
  320.             if (B4)
  321.             {
  322.                 return 6;
  323.             }
  324.             return 0;
  325.         }
  326.        
  327.         private int Current;
  328.         private int Previous;
  329.         private void InvalidateMouse()
  330.         {
  331.             Current = GetIndex();
  332.             if (Current == Previous)
  333.             {
  334.                 return ;
  335.             }
  336.            
  337.             Previous = Current;
  338.             switch (Previous)
  339.             {
  340.                 case 0:
  341.                     Cursor = Cursors.Default;
  342.                     break;
  343.                 case 6:
  344.                     Cursor = Cursors.SizeNS;
  345.                     break;
  346.                 case 8:
  347.                     Cursor = Cursors.SizeNWSE;
  348.                     break;
  349.                 case 7:
  350.                     Cursor = Cursors.SizeNESW;
  351.                     break;
  352.             }
  353.         }
  354.        
  355.         private Message[] Messages = new Message[9];
  356.         private void InitializeMessages()
  357.         {
  358.             Messages[0] = Message.Create(Parent.Handle, 161, new IntPtr(2), IntPtr.Zero);
  359.             for (int I = 1; I <= 8; I++)
  360.             {
  361.                 Messages[I] = Message.Create(Parent.Handle, 161, new IntPtr(I + 9), IntPtr.Zero);
  362.             }
  363.         }
  364.        
  365.         private void CorrectBounds(Rectangle bounds)
  366.         {
  367.             if (Parent.Width > bounds.Width)
  368.             {
  369.                 Parent.Width = bounds.Width;
  370.             }
  371.             if (Parent.Height > bounds.Height)
  372.             {
  373.                 Parent.Height = bounds.Height;
  374.             }
  375.            
  376.             int X = Parent.Location.X;
  377.             int Y = Parent.Location.Y;
  378.            
  379.             if (X < bounds.X)
  380.             {
  381.                 X = bounds.X;
  382.             }
  383.             if (Y < bounds.Y)
  384.             {
  385.                 Y = bounds.Y;
  386.             }
  387.            
  388.             int Width = bounds.X + bounds.Width;
  389.             int Height = bounds.Y + bounds.Height;
  390.            
  391.             if (X + Parent.Width > Width)
  392.             {
  393.                 X = Width - Parent.Width;
  394.             }
  395.             if (Y + Parent.Height > Height)
  396.             {
  397.                 Y = Height - Parent.Height;
  398.             }
  399.            
  400.             Parent.Location = new Point(X, Y);
  401.         }
  402.        
  403.         private bool WM_LMBUTTONDOWN;
  404.         protected override void WndProc(ref Message m)
  405.         {
  406.             base.WndProc(ref m);
  407.            
  408.             if (WM_LMBUTTONDOWN && m.Msg == 513)
  409.             {
  410.                 WM_LMBUTTONDOWN = false;
  411.                
  412.                 SetState(MouseState.Over);
  413.                 if (!_SmartBounds)
  414.                 {
  415.                     return ;
  416.                 }
  417.                
  418.                 if (IsParentMdi)
  419.                 {
  420.                     CorrectBounds(new Rectangle(Point.Empty, Parent.Parent.Size));
  421.                 }
  422.                 else
  423.                 {
  424.                     CorrectBounds(Screen.FromControl(Parent).WorkingArea);
  425.                 }
  426.             }
  427.         }
  428.        
  429. #endregion
  430.        
  431.         protected override void CreateHandle()
  432.         {
  433.             base.CreateHandle();
  434.         }
  435.        
  436.         public PlayUI_ThemeContainer()
  437.         {
  438.             SetStyle((ControlStyles) (139270), true);
  439.             BackColor = Color.FromArgb(43, 46, 50);
  440.             Padding = new Padding(20, 56, 20, 16);
  441.             DoubleBuffered = true;
  442.             Dock = DockStyle.Fill;
  443.             MoveHeight = 40;
  444.             Font = new Font("Segoe UI", 9);
  445.             _RoundCorners = true;
  446.             _Sizable = false;
  447.         }
  448.        
  449.         protected override void OnPaint(PaintEventArgs e)
  450.         {
  451.             base.OnPaint(e);
  452.             Graphics G = e.Graphics;
  453.             G.Clear(Color.FromArgb(43, 46, 50));
  454.            
  455.             G.DrawRectangle(new Pen(Color.FromArgb(26, 26, 26)), new Rectangle(0, 0, Width - 1, Height - 1));
  456.             G.FillRectangle(new LinearGradientBrush(new Point(0, 0), new Point(0, ClientRectangle.Height - 38), Color.FromArgb(43, 46, 51), Color.FromArgb(35, 37, 40)), new Rectangle(1, 1, Width - 2, ClientRectangle.Height - 38));
  457.             G.DrawLine(new Pen(Color.FromArgb(65, 69, 75)), 1, 1, Width - 2, 1);
  458.             G.DrawLine(new Pen(Color.FromArgb(161, 166, 171)), 1, Height - 37, Width - 2, Height - 37);
  459.             G.FillRectangle(new LinearGradientBrush(new Point(0, 0), new Point(0, Height), Color.FromArgb(124, 127, 134), Color.FromArgb(114, 117, 124)), new Rectangle(1, Height - 36, Width - 2, 35));
  460.             G.DrawLine(new Pen(Color.FromArgb(65, 69, 75)), 1, 4, 1, this.Height - 38);
  461.             G.DrawLine(new Pen(Color.FromArgb(65, 69, 75)), Width - 2, 4, Width - 2, this.Height - 38);
  462.            
  463.             if (_RoundCorners == true)
  464.             {
  465.                
  466.                 // Draw Left upper corner
  467.                 G.FillRectangle(Brushes.Fuchsia, 0, 0, 1, 1);
  468.                 G.FillRectangle(Brushes.Fuchsia, 1, 0, 1, 1);
  469.                 G.FillRectangle(Brushes.Fuchsia, 2, 0, 1, 1);
  470.                 G.FillRectangle(Brushes.Fuchsia, 3, 0, 1, 1);
  471.                 G.FillRectangle(Brushes.Fuchsia, 0, 1, 1, 1);
  472.                 G.FillRectangle(Brushes.Fuchsia, 0, 2, 1, 1);
  473.                 G.FillRectangle(Brushes.Fuchsia, 0, 3, 1, 1);
  474.                 G.FillRectangle(Brushes.Fuchsia, 1, 1, 1, 1);
  475.                
  476.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), 1, 3, 1, 1);
  477.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), 1, 2, 1, 1);
  478.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), 2, 1, 1, 1);
  479.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), 3, 1, 1, 1);
  480.                
  481.                 // Draw right upper corner
  482.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, 0, 1, 1);
  483.                 G.FillRectangle(Brushes.Fuchsia, Width - 2, 0, 1, 1);
  484.                 G.FillRectangle(Brushes.Fuchsia, Width - 3, 0, 1, 1);
  485.                 G.FillRectangle(Brushes.Fuchsia, Width - 4, 0, 1, 1);
  486.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, 1, 1, 1);
  487.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, 2, 1, 1);
  488.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, 3, 1, 1);
  489.                 G.FillRectangle(Brushes.Fuchsia, Width - 2, 1, 1, 1);
  490.                
  491.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), Width - 2, 3, 1, 1);
  492.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), Width - 2, 2, 1, 1);
  493.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), Width - 3, 1, 1, 1);
  494.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), Width - 4, 1, 1, 1);
  495.                
  496.                 // Draw Left bottom corner
  497.                 G.FillRectangle(Brushes.Fuchsia, 0, Height - 1, 1, 1);
  498.                 G.FillRectangle(Brushes.Fuchsia, 0, Height - 2, 1, 1);
  499.                 G.FillRectangle(Brushes.Fuchsia, 0, Height - 3, 1, 1);
  500.                 G.FillRectangle(Brushes.Fuchsia, 0, Height - 4, 1, 1);
  501.                 G.FillRectangle(Brushes.Fuchsia, 1, Height - 1, 1, 1);
  502.                 G.FillRectangle(Brushes.Fuchsia, 2, Height - 1, 1, 1);
  503.                 G.FillRectangle(Brushes.Fuchsia, 3, Height - 1, 1, 1);
  504.                 G.FillRectangle(Brushes.Fuchsia, 1, Height - 1, 1, 1);
  505.                 G.FillRectangle(Brushes.Fuchsia, 1, Height - 2, 1, 1);
  506.                
  507.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), 1, Height - 3, 1, 1);
  508.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), 1, Height - 4, 1, 1);
  509.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), 3, Height - 2, 1, 1);
  510.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), 2, Height - 2, 1, 1);
  511.                
  512.                 // Draw right bottom corner
  513.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, Height, 1, 1);
  514.                 G.FillRectangle(Brushes.Fuchsia, Width - 2, Height, 1, 1);
  515.                 G.FillRectangle(Brushes.Fuchsia, Width - 3, Height, 1, 1);
  516.                 G.FillRectangle(Brushes.Fuchsia, Width - 4, Height, 1, 1);
  517.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, Height - 1, 1, 1);
  518.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, Height - 2, 1, 1);
  519.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, Height - 3, 1, 1);
  520.                 G.FillRectangle(Brushes.Fuchsia, Width - 2, Height - 1, 1, 1);
  521.                 G.FillRectangle(Brushes.Fuchsia, Width - 3, Height - 1, 1, 1);
  522.                 G.FillRectangle(Brushes.Fuchsia, Width - 4, Height - 1, 1, 1);
  523.                 G.FillRectangle(Brushes.Fuchsia, Width - 1, Height - 4, 1, 1);
  524.                 G.FillRectangle(Brushes.Fuchsia, Width - 2, Height - 2, 1, 1);
  525.                
  526.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), Width - 2, Height - 3, 1, 1);
  527.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), Width - 2, Height - 4, 1, 1);
  528.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), Width - 4, Height - 2, 1, 1);
  529.                 G.FillRectangle(new SolidBrush(Color.FromArgb(26, 26, 26)), Width - 3, Height - 2, 1, 1);
  530.             }
  531.            
  532.         }
  533.     }
  534.    
  535. #endregion
  536. #region  ControlBox
  537.    
  538.     public class PlayUI_ControlBox : Control
  539.     {
  540.        
  541. #region  Enums
  542.        
  543.         public enum MouseState
  544.         {
  545.             None = 0,
  546.             Over = 1,
  547.             Down = 2
  548.         }
  549.        
  550. #endregion
  551. #region  MouseStates
  552.        
  553.         MouseState State = MouseState.None;
  554.         int X;
  555.         Rectangle MinBtn = new Rectangle(3, 2, 17, 17);
  556.         Rectangle CloseBtn = new Rectangle(23, 2, 17, 17);
  557.        
  558.         protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
  559.         {
  560.             base.OnMouseDown(e);
  561.             State = MouseState.Down;
  562.             Invalidate();
  563.         }
  564.         protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
  565.         {
  566.             base.OnMouseUp(e);
  567.             if (X > 0 && X < 17)
  568.             {
  569.                 FindForm().WindowState = FormWindowState.Minimized;
  570.             }
  571.             else if (X > 20 && X < 40)
  572.             {
  573.                 FindForm().Close();
  574.             }
  575.            
  576.             State = MouseState.Over;
  577.             Invalidate();
  578.         }
  579.         protected override void OnMouseEnter(System.EventArgs e)
  580.         {
  581.             base.OnMouseEnter(e);
  582.             State = MouseState.Over;
  583.             Invalidate();
  584.         }
  585.         protected override void OnMouseLeave(System.EventArgs e)
  586.         {
  587.             base.OnMouseLeave(e);
  588.             State = MouseState.None;
  589.             Invalidate();
  590.         }
  591.         protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
  592.         {
  593.             base.OnMouseMove(e);
  594.             X = e.Location.X;
  595.             Invalidate();
  596.         }
  597. #endregion
  598.        
  599.         public PlayUI_ControlBox()
  600.         {
  601.             SetStyle((System.Windows.Forms.ControlStyles) (ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor | ControlStyles.ResizeRedraw | ControlStyles.DoubleBuffer), true);
  602.             DoubleBuffered = true;
  603.             BackColor = Color.Transparent;
  604.             Font = new Font("Marlett", 7);
  605.             Anchor = (System.Windows.Forms.AnchorStyles) (AnchorStyles.Top | AnchorStyles.Right);
  606.         }
  607.        
  608.         protected override void OnResize(EventArgs e)
  609.         {
  610.             base.OnResize(e);
  611.             this.Size = new Size(45, 23);
  612.         }
  613.        
  614.         protected override void OnCreateControl()
  615.         {
  616.             base.OnCreateControl();
  617.             Location = new Point(Parent.Width - 50, 5);
  618.         }
  619.        
  620.         protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  621.         {
  622.             Bitmap B = new Bitmap(Width, Height);
  623.             Graphics G = Graphics.FromImage(B);
  624.            
  625.             base.OnPaint(e);
  626.             G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  627.            
  628.             LinearGradientBrush LGBClose = new LinearGradientBrush(CloseBtn, Color.FromArgb(29, 29, 29), Color.FromArgb(29, 29, 29), 90);
  629.             G.FillEllipse(LGBClose, CloseBtn);
  630.             G.DrawString("r", new Font("Marlett", 7), new SolidBrush(Color.FromArgb(117, 117, 119)), new Rectangle(26, 8, 0, 0));
  631.            
  632.             LinearGradientBrush LGBMinimize = new LinearGradientBrush(MinBtn, Color.FromArgb(29, 29, 29), Color.FromArgb(29, 29, 29), 90);
  633.             G.FillEllipse(LGBMinimize, MinBtn);
  634.             G.DrawString("0", new Font("Marlett", 7), new SolidBrush(Color.FromArgb(117, 117, 119)), new Rectangle((int) 6.5, 8, 0, 0));
  635.            
  636.             switch (State)
  637.             {
  638.                 case MouseState.None:
  639.                     LinearGradientBrush xLGBClose_1 = new LinearGradientBrush(CloseBtn, Color.FromArgb(29, 29, 29), Color.FromArgb(29, 29, 29), 90);
  640.                     G.FillEllipse(xLGBClose_1, CloseBtn);
  641.                     G.DrawString("r", new Font("Marlett", 7), new SolidBrush(Color.FromArgb(117, 117, 119)), new Rectangle(26, 8, 0, 0));
  642.                    
  643.                     LinearGradientBrush xLGBMinimize_1 = new LinearGradientBrush(MinBtn, Color.FromArgb(29, 29, 29), Color.FromArgb(29, 29, 29), 90);
  644.                     G.FillEllipse(xLGBMinimize_1, MinBtn);
  645.                     G.DrawString("0", new Font("Marlett", 7), new SolidBrush(Color.FromArgb(117, 117, 119)), new Rectangle((int) 6.5, 8, 0, 0));
  646.                     break;
  647.                 case MouseState.Over:
  648.                     if (X > 23 && X < 40)
  649.                     {
  650.                         LinearGradientBrush xLGBClose = new LinearGradientBrush(CloseBtn, Color.FromArgb(37, 37, 37), Color.FromArgb(37, 37, 37), 90);
  651.                         G.FillEllipse(xLGBClose, CloseBtn);
  652.                         G.DrawString("r", new Font("Marlett", 7), new SolidBrush(Color.FromArgb(117, 117, 119)), new Rectangle(26, 8, 0, 0));
  653.                     }
  654.                     else if (X > 3 && X < 20)
  655.                     {
  656.                         LinearGradientBrush xLGBMinimize = new LinearGradientBrush(MinBtn, Color.FromArgb(37, 37, 37), Color.FromArgb(37, 37, 37), 90);
  657.                         G.FillEllipse(xLGBMinimize, MinBtn);
  658.                         G.DrawString("0", new Font("Marlett", 7), new SolidBrush(Color.FromArgb(117, 117, 119)), new Rectangle((int) 6.5, 8, 0, 0));
  659.                     }
  660.                     break;
  661.             }
  662.            
  663.             e.Graphics.DrawImage((Image) (B.Clone()), 0, 0);
  664.             G.Dispose();
  665.             B.Dispose();
  666.         }
  667.     }
  668.    
  669. #endregion
  670. #region  Header Label
  671.    
  672.     public class PlayUI_HeaderLabel : Label
  673.     {
  674.        
  675.         public PlayUI_HeaderLabel()
  676.         {
  677.             Font = new Font("Arial", 9, FontStyle.Bold);
  678.             ForeColor = Color.FromArgb(253, 254, 255);
  679.             BackColor = Color.Transparent;
  680.         }
  681.     }
  682.    
  683. #endregion
  684. #region  Label
  685.    
  686.     public class PlayUI_Label : Label
  687.     {
  688.        
  689.         public PlayUI_Label()
  690.         {
  691.             Font = new Font("Arial", 8, FontStyle.Regular);
  692.             ForeColor = Color.FromArgb(116, 119, 124);
  693.             BackColor = Color.Transparent;
  694.         }
  695.     }
  696.    
  697. #endregion
  698. #region  Link Label
  699.     public class PlayUI_LinkLabel : LinkLabel
  700.     {
  701.        
  702.         public PlayUI_LinkLabel()
  703.         {
  704.             Font = new Font("Arial", 8, FontStyle.Regular);
  705.             BackColor = Color.Transparent;
  706.             LinkColor = Color.FromArgb(115, 118, 125);
  707.             ActiveLinkColor = Color.FromArgb(103, 105, 112);
  708.             VisitedLinkColor = Color.FromArgb(115, 118, 125);
  709.             LinkBehavior = LinkBehavior.NeverUnderline;
  710.         }
  711.     }
  712.    
  713. #endregion
  714. #region  Separator
  715.  
  716.     public class PlayUI_Separator : Control
  717.     {
  718.  
  719.         public PlayUI_Separator()
  720.         {
  721.             SetStyle(ControlStyles.ResizeRedraw, true);
  722.             SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  723.             BackColor = Color.Transparent;
  724.             this.Size = (System.Drawing.Size)(new Point(120, 10));
  725.  
  726.         }
  727.  
  728.         protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  729.         {
  730.             base.OnPaint(e);
  731.             e.Graphics.DrawLine(new Pen(Color.FromArgb(56, 60, 65)), 0, 5, Width, 5);
  732.         }
  733.     }
  734.  
  735.     #endregion
  736. #region  Panel
  737.    
  738.     public class PlayUI_Panel : ContainerControl
  739.     {
  740.        
  741.         private GraphicsPath Shape;
  742.        
  743.         public PlayUI_Panel()
  744.         {
  745.             SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  746.             SetStyle(ControlStyles.UserPaint, true);
  747.            
  748.             BackColor = Color.Transparent;
  749.             this.Size = new Size(187, 117);
  750.             Padding = new Padding(5, 5, 5, 5);
  751.             DoubleBuffered = true;
  752.         }
  753.        
  754.         protected override void OnResize(System.EventArgs e)
  755.         {
  756.             base.OnResize(e);
  757.            
  758.             Shape = new GraphicsPath();
  759.             Shape.AddArc(0, 0, 10, 10, 180, 90);
  760.             Shape.AddArc(Width - 11, 0, 10, 10, -90, 90);
  761.             Shape.AddArc(Width - 11, Height - 11, 10, 10, 0, 90);
  762.             Shape.AddArc(0, Height - 11, 10, 10, 90, 90);
  763.             Shape.CloseAllFigures();
  764.         }
  765.        
  766.         protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  767.         {
  768.             base.OnPaint(e);
  769.             Bitmap B = new Bitmap(Width, Height);
  770.             var G = Graphics.FromImage(B);
  771.            
  772.             G.SmoothingMode = SmoothingMode.HighQuality;
  773.            
  774.             G.Clear(Color.Transparent); // Set control background to transparent
  775.             G.FillPath(new SolidBrush(Color.FromArgb(47, 49, 53)), Shape); // Draw RTB background
  776.             G.DrawPath(new Pen(Color.FromArgb(37, 38, 41)), Shape); // Draw border
  777.            
  778.             G.Dispose();
  779.             e.Graphics.DrawImage((Image) (B.Clone()), 0, 0);
  780.             B.Dispose();
  781.         }
  782.     }
  783.    
  784. #endregion
  785. #region  Button Base
  786.    
  787.     public class PlayUI_ButtonBase : ContainerControl
  788.     {
  789.        
  790.         public PlayUI_ButtonBase()
  791.         {
  792.             DoubleBuffered = true;
  793.             SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  794.             this.BackColor = Color.Transparent;
  795.         }
  796.        
  797.         protected override void OnResize(EventArgs e)
  798.         {
  799.             base.OnResize(e);
  800.             Size = new Size(110, 50);
  801.         }
  802.        
  803.         protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  804.         {
  805.             base.OnPaint(e);
  806.            
  807.             Graphics G = e.Graphics;
  808.            
  809.             G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  810.            
  811.             LinearGradientBrush LGB1 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.FromArgb(36, 38, 41), Color.FromArgb(36, 38, 41), 90.0F);
  812.            
  813.             G.FillEllipse(LGB1, new Rectangle(0, 9, 30, 30));
  814.             G.FillEllipse(LGB1, new Rectangle(29, 0, 48, 48));
  815.             G.FillEllipse(LGB1, new Rectangle(76, 9, 30, 30));
  816.            
  817.             LGB1.Dispose();
  818.         }
  819.     }
  820.    
  821. #endregion
  822. #region  Normal Button
  823.    
  824.     public class PlayUI_Button_N : Control
  825.     {
  826.        
  827. #region  Variables
  828.        
  829.         private int MouseState;
  830.         private GraphicsPath Shape;
  831.         private LinearGradientBrush InactiveGB;
  832.         private LinearGradientBrush PressedGB;
  833.         private LinearGradientBrush PressedContourGB;
  834.         private Rectangle R1;
  835.         private Pen P1;
  836.         private Pen P3;
  837.         private StringAlignment _TextAlignment = StringAlignment.Center;
  838.         private Color _TextColor; // VBConversions Note: Initial value cannot be assigned here since it is non-static.  Assignment has been moved to the class constructors.
  839.        
  840. #endregion
  841. #region  Properties
  842.        
  843. public StringAlignment TextAlignment
  844.         {
  845.             get
  846.             {
  847.                 return this._TextAlignment;
  848.             }
  849.             set
  850.             {
  851.                 this._TextAlignment = value;
  852.                 this.Invalidate();
  853.             }
  854.         }
  855.        
  856. public override Color ForeColor
  857.         {
  858.             get
  859.             {
  860.                 return this._TextColor;
  861.             }
  862.             set
  863.             {
  864.                 this._TextColor = value;
  865.                 this.Invalidate();
  866.             }
  867.         }
  868.        
  869. #endregion
  870. #region  EventArgs
  871.        
  872.         protected override void OnMouseUp(MouseEventArgs e)
  873.         {
  874.             MouseState = 0;
  875.             Invalidate();
  876.             base.OnMouseUp(e);
  877.         }
  878.         protected override void OnMouseDown(MouseEventArgs e)
  879.         {
  880.             MouseState = 1;
  881.             Invalidate();
  882.             base.OnMouseDown(e);
  883.         }
  884.        
  885.         protected override void OnMouseLeave(EventArgs e)
  886.         {
  887.             MouseState = 0;
  888.             Invalidate();
  889.             base.OnMouseLeave(e);
  890.         }
  891.        
  892.         protected override void OnTextChanged(System.EventArgs e)
  893.         {
  894.             Invalidate();
  895.             base.OnTextChanged(e);
  896.         }
  897.        
  898. #endregion
  899.        
  900.         public PlayUI_Button_N()
  901.         {
  902.             SetStyle((System.Windows.Forms.ControlStyles) (ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint), true);
  903.            
  904.             BackColor = Color.Transparent;
  905.             DoubleBuffered = true;
  906.             Font = new Font("Segoe UI", 8);
  907.             ForeColor = Color.FromArgb(255, 255, 255);
  908.             Size = new Size(42, 24);
  909.             _TextAlignment = StringAlignment.Center;
  910.             P1 = new Pen(Color.FromArgb(25, 26, 28)); // P1 = Border color
  911.         }
  912.        
  913.         protected override void OnResize(System.EventArgs e)
  914.         {
  915.             if (Width > 0 && Height > 0)
  916.             {
  917.                
  918.                 Shape = new GraphicsPath();
  919.                 R1 = new Rectangle(0, 0, Width, Height);
  920.                
  921.                 InactiveGB = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.FromArgb(31, 31, 31), Color.FromArgb(30, 30, 30), 90.0F);
  922.                 PressedGB = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.FromArgb(26, 26, 26), Color.FromArgb(26, 26, 26), 90.0F);
  923.                 PressedContourGB = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.FromArgb(23, 23, 23), Color.FromArgb(23, 23, 23), 90.0F);
  924.                
  925.                 P3 = new Pen(PressedContourGB);
  926.             }
  927.            
  928.             Shape.AddArc(0, 0, 10, 10, 180, 90);
  929.             Shape.AddArc(Width - 11, 0, 10, 10, -90, 90);
  930.             Shape.AddArc(Width - 11, Height - 11, 10, 10, 0, 90);
  931.             Shape.AddArc(0, Height - 11, 10, 10, 90, 90);
  932.             Shape.CloseAllFigures();
  933.            
  934.             Invalidate();
  935.             base.OnResize(e);
  936.         }
  937.        
  938.         protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  939.         {
  940.             e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
  941.            
  942.             switch (MouseState)
  943.             {
  944.                 case 0: //Inactive
  945.                     e.Graphics.FillPath(InactiveGB, Shape); // Fill button body with InactiveGB color gradient
  946.                     e.Graphics.DrawLine(new Pen(Color.FromArgb(39, 39, 39)), 2, 1, Width - 3, 1);
  947.                     e.Graphics.DrawPath(P1, Shape); // Draw button border [InactiveGB]
  948.                     e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), R1, new StringFormat() {Alignment = _TextAlignment, LineAlignment = StringAlignment.Center});
  949.                     break;
  950.                 case 1: //Pressed
  951.                     e.Graphics.FillPath(PressedGB, Shape); // Fill button body with PressedGB color gradient
  952.                     e.Graphics.DrawPath(P3, Shape); // Draw button border [PressedGB]
  953.                     e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), R1, new StringFormat() {Alignment = _TextAlignment, LineAlignment = StringAlignment.Center});
  954.                     break;
  955.             }
  956.             base.OnPaint(e);
  957.         }
  958.     }
  959.    
  960. #endregion
  961. #region  Round Button
  962.    
  963.     public class PlayUI_Button_R : Control
  964.     {
  965.        
  966. #region  Enums
  967.        
  968.         public enum MyRadius
  969.         {
  970.             R12,
  971.             R21
  972.         }
  973.        
  974. #endregion
  975. #region  Variables
  976.        
  977.         private int MouseState;
  978.         private LinearGradientBrush InactiveGB;
  979.         private LinearGradientBrush PressedGB;
  980.         private LinearGradientBrush PressedContourGB;
  981.         private Pen P1;
  982.         private Pen P3;
  983.         private Image _Image;
  984.         private Size _ImageSize;
  985.         private MyRadius _Radius;
  986.        
  987. #endregion
  988. #region  Properties
  989.        
  990. public Image Image
  991.         {
  992.             get
  993.             {
  994.                 return _Image;
  995.             }
  996.             set
  997.             {
  998.                 if (value == null)
  999.                 {
  1000.                     _ImageSize = Size.Empty;
  1001.                 }
  1002.                 else
  1003.                 {
  1004.                     _ImageSize = value.Size;
  1005.                 }
  1006.                
  1007.                 _Image = value;
  1008.                 Invalidate();
  1009.             }
  1010.         }
  1011.        
  1012. protected Size ImageSize
  1013.         {
  1014.             get
  1015.             {
  1016.                 return _ImageSize;
  1017.             }
  1018.         }
  1019.        
  1020. public MyRadius Radius
  1021.         {
  1022.             get
  1023.             {
  1024.                 return _Radius;
  1025.             }
  1026.             set
  1027.             {
  1028.                 _Radius = value;
  1029.                 switch (_Radius)
  1030.                 {
  1031.                     case MyRadius.R12:
  1032.                         Size = new Size(25, 25);
  1033.                         break;
  1034.                     case MyRadius.R21:
  1035.                         Size = new Size(44, 44);
  1036.                         break;
  1037.                 }
  1038.                 Invalidate();
  1039.             }
  1040.         }
  1041.        
  1042. #endregion
  1043. #region  EventArgs
  1044.        
  1045.         protected override void OnMouseUp(MouseEventArgs e)
  1046.         {
  1047.             MouseState = 0;
  1048.             Invalidate();
  1049.             base.OnMouseUp(e);
  1050.         }
  1051.         protected override void OnMouseDown(MouseEventArgs e)
  1052.         {
  1053.             MouseState = 1;
  1054.             Invalidate();
  1055.             base.OnMouseDown(e);
  1056.         }
  1057.        
  1058.         protected override void OnMouseLeave(EventArgs e)
  1059.         {
  1060.             MouseState = 0;
  1061.             Invalidate();
  1062.             base.OnMouseLeave(e);
  1063.         }
  1064.        
  1065. #endregion
  1066.        
  1067.         public PlayUI_Button_R()
  1068.         {
  1069.             SetStyle((System.Windows.Forms.ControlStyles) (ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint), true);
  1070.            
  1071.             BackColor = Color.Transparent;
  1072.             DoubleBuffered = true;
  1073.             Size = new Size(25, 25);
  1074.             P1 = new Pen(Color.FromArgb(116, 119, 126)); // P1 = Border color
  1075.         }
  1076.        
  1077.         protected override void OnResize(System.EventArgs e)
  1078.         {
  1079.             switch (_Radius)
  1080.             {
  1081.                 case MyRadius.R12:
  1082.                     this.Size = new Size(25, 25);
  1083.                     break;
  1084.                 case MyRadius.R21:
  1085.                     this.Size = new Size(44, 44);
  1086.                     break;
  1087.             }
  1088.            
  1089.             InactiveGB = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.FromArgb(116, 119, 126), Color.FromArgb(116, 119, 126), 90.0F);
  1090.             PressedGB = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.FromArgb(95, 97, 103), Color.FromArgb(95, 97, 103), 90.0F);
  1091.             PressedContourGB = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.FromArgb(95, 97, 103), Color.FromArgb(95, 97, 103), 90.0F);
  1092.             P3 = new Pen(PressedContourGB); // P3 = Border color when button is pressed
  1093.            
  1094.             Invalidate();
  1095.             base.OnResize(e);
  1096.         }
  1097.         private void FinishDrawing(Graphics g, Point center, int radius)
  1098.         {
  1099.             Rectangle MyCircle = new Rectangle((int) (center.X / 2), (int) (center.Y / 2), radius * 2, radius * 2);
  1100.            
  1101.             switch (MouseState)
  1102.             {
  1103.                 case 0: //Inactive
  1104.                     g.FillEllipse(InactiveGB, MyCircle);
  1105.                     g.DrawEllipse(P1, MyCircle);
  1106.                    
  1107.                     if (Image == null)
  1108.                     {
  1109.                     }
  1110.                     else
  1111.                     {
  1112.                         g.DrawImage(_Image, 5, 5, ImageSize.Width, ImageSize.Height);
  1113.                     }
  1114.                     break;
  1115.                    
  1116.                 case 1: //Pressed
  1117.                     g.FillEllipse(PressedGB, MyCircle);
  1118.                     g.DrawEllipse(P3, MyCircle);
  1119.                    
  1120.                     if (Image == null)
  1121.                     {
  1122.                     }
  1123.                     else
  1124.                     {
  1125.                         g.DrawImage(_Image, 5, 5, ImageSize.Width, ImageSize.Height);
  1126.                     }
  1127.                     break;
  1128.             }
  1129.         }
  1130.        
  1131.         protected override void OnPaint(PaintEventArgs e)
  1132.         {
  1133.             base.OnPaint(e);
  1134.             e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
  1135.             switch (_Radius)
  1136.             {
  1137.                 case MyRadius.R12:
  1138.                     FinishDrawing(e.Graphics, new Point(0, 0), 12);
  1139.                     break;
  1140.                 case MyRadius.R21:
  1141.                     FinishDrawing(e.Graphics, new Point(0, 0), 21);
  1142.                     break;
  1143.             }
  1144.         }
  1145.     }
  1146.    
  1147. #endregion
  1148. #region  Star Rating
  1149.    
  1150.     public class PlayUI_StarRating : UserControl
  1151.     {
  1152.        
  1153. #region  Variables
  1154.        
  1155.         private Size _ImageSize;
  1156.         private Image _ImageRated;
  1157.         private Image _ImageUnrated;
  1158.         private int _Stars = 0;
  1159.         private int _MaximumStars = 5;
  1160.         private int TempStar = -1;
  1161.        
  1162. #endregion
  1163. #region  Properties
  1164.        
  1165. protected Size ImageSize
  1166.         {
  1167.             get
  1168.             {
  1169.                 return _ImageSize;
  1170.             }
  1171.         }
  1172.        
  1173. public int Stars
  1174.         {
  1175.             get
  1176.             {
  1177.                 return this._Stars;
  1178.             }
  1179.             set
  1180.             {
  1181.                 if (value > _MaximumStars)
  1182.                 {
  1183.                     MessageBox.Show("Value can\'t be higher than the maximum number of stars!");
  1184.                 }
  1185.                 this._Stars = value;
  1186.                 this.Invalidate();
  1187.             }
  1188.         }
  1189.        
  1190. public int MaximumStars
  1191.         {
  1192.             get
  1193.             {
  1194.                 return this._MaximumStars;
  1195.             }
  1196.             set
  1197.             {
  1198.                 this._MaximumStars = value;
  1199.             }
  1200.         }
  1201.        
  1202. public Image ImageRated
  1203.         {
  1204.             get
  1205.             {
  1206.                 return _ImageRated;
  1207.             }
  1208.             set
  1209.             {
  1210.                 if (value == null)
  1211.                 {
  1212.                     _ImageSize = Size.Empty;
  1213.                 }
  1214.                 else
  1215.                 {
  1216.                     _ImageSize = value.Size;
  1217.                 }
  1218.                 _ImageRated = value;
  1219.                 Invalidate();
  1220.             }
  1221.         }
  1222.        
  1223. public Image ImageUnrated
  1224.         {
  1225.             get
  1226.             {
  1227.                 return _ImageUnrated;
  1228.             }
  1229.             set
  1230.             {
  1231.                 if (value == null)
  1232.                 {
  1233.                     _ImageSize = Size.Empty;
  1234.                 }
  1235.                 else
  1236.                 {
  1237.                     _ImageSize = value.Size;
  1238.                 }
  1239.                 _ImageUnrated = value;
  1240.                 Invalidate();
  1241.             }
  1242.         }
  1243.        
  1244. #endregion
  1245. #region  EventArgs
  1246.                
  1247.         protected override void OnMouseMove(MouseEventArgs e)
  1248.         {
  1249.             base.OnMouseMove(e);
  1250.             double StarLoc = (e.X + _ImageRated.Width - 5) / _ImageRated.Width;
  1251.             int HoverStar = Convert.ToInt32(Math.Floor(StarLoc));
  1252.            
  1253.             if (!HoverStar.Equals(TempStar))
  1254.             {
  1255.                 TempStar = HoverStar;
  1256.                 this.Invalidate();
  1257.             }
  1258.         }
  1259.        
  1260.         protected override void OnMouseLeave(EventArgs e)
  1261.         {
  1262.             base.OnMouseLeave(e);
  1263.             TempStar = -1;
  1264.             this.Invalidate();
  1265.         }
  1266.        
  1267.         protected override void OnMouseDown(MouseEventArgs e)
  1268.         {
  1269.             base.OnMouseDown(e);
  1270.             double StarLoc = (e.X + _ImageRated.Width - 5) / _ImageRated.Width;
  1271.             int StarToAdd = Convert.ToInt32(Math.Floor(StarLoc));
  1272.            
  1273.             if (!StarToAdd.Equals(_Stars))
  1274.             {
  1275.                 _Stars = StarToAdd;
  1276.                 if (_Stars > _MaximumStars)
  1277.                 {
  1278.                     _Stars = _MaximumStars;
  1279.                 }
  1280.                 this.Invalidate();
  1281.             }
  1282.         }
  1283.        
  1284. #endregion
  1285.        
  1286.         public PlayUI_StarRating()
  1287.         {
  1288.             Size = new Size(82, 17);
  1289.             BackColor = Color.Transparent;
  1290.             DoubleBuffered = true;
  1291.         }
  1292.        
  1293.         protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  1294.         {
  1295.             base.OnPaint(e);
  1296.             Graphics G = e.Graphics;
  1297.            
  1298.             if (_ImageRated == null || _ImageUnrated == null)
  1299.             {
  1300.                 return ;
  1301.             }
  1302.            
  1303.             for (int i = 0; i <= _MaximumStars - 1; i++)
  1304.             {
  1305.                 if (i < (TempStar == -1 ? _Stars : TempStar))
  1306.                 {
  1307.                     G.DrawImage(_ImageRated, _ImageRated.Width * i, 0, ImageSize.Width, ImageSize.Height);
  1308.                 }
  1309.                 else
  1310.                 {
  1311.                     G.DrawImage(_ImageUnrated, _ImageRated.Width * i, 0, ImageSize.Width, ImageSize.Height);
  1312.                 }
  1313.             }
  1314.         }
  1315.     }
  1316.    
  1317. #endregion
  1318. #region  ProgressBar
  1319.    
  1320.     public class PlayUI_ProgressBar : Control
  1321.     {
  1322.        
  1323. #region  RoundRect
  1324.        
  1325.         private GraphicsPath CreateRoundPath;
  1326.        
  1327.         public GraphicsPath CreateRound(Rectangle r, int slope)
  1328.         {
  1329.             CreateRoundPath = new GraphicsPath(FillMode.Winding);
  1330.             CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F);
  1331.             CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F);
  1332.             CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F);
  1333.             CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F);
  1334.             CreateRoundPath.CloseFigure();
  1335.             return CreateRoundPath;
  1336.         }
  1337.        
  1338. #endregion
  1339. #region  Custom Properties
  1340.        
  1341.         private int _Maximum = 100;
  1342. public int Maximum
  1343.         {
  1344.             get
  1345.             {
  1346.                 return _Maximum;
  1347.             }
  1348.             set
  1349.             {
  1350.                 if (value < 1)
  1351.                 {
  1352.                     value = 1;
  1353.                 }
  1354.                 if (value < _Value)
  1355.                 {
  1356.                     _Value = value;
  1357.                 }
  1358.                 _Maximum = value;
  1359.                 Invalidate();
  1360.             }
  1361.         }
  1362.        
  1363.         private int _Minimum;
  1364. public int Minimum
  1365.         {
  1366.             get
  1367.             {
  1368.                 return _Minimum;
  1369.             }
  1370.             set
  1371.             {
  1372.                 _Minimum = value;
  1373.                
  1374.                 if (value > _Maximum)
  1375.                 {
  1376.                     _Maximum = value;
  1377.                 }
  1378.                 if (value > _Value)
  1379.                 {
  1380.                     _Value = value;
  1381.                 }
  1382.                
  1383.                 Invalidate();
  1384.             }
  1385.         }
  1386.        
  1387.         private int _Value;
  1388. public int Value
  1389.         {
  1390.             get
  1391.             {
  1392.                 return _Value;
  1393.             }
  1394.             set
  1395.             {
  1396.                 if (value > _Maximum)
  1397.                 {
  1398.                     value = Maximum;
  1399.                 }
  1400.                 _Value = value;
  1401.                 Invalidate();
  1402.             }
  1403.         }
  1404.  
  1405. private Color _ValueColour = Color.FromArgb(42, 119, 220);
  1406. [Category("Colours")]public Color ValueColour
  1407.             {
  1408.             get
  1409.             {
  1410.                 return _ValueColour;
  1411.             }
  1412.             set
  1413.             {
  1414.                 _ValueColour = value;
  1415.                 Invalidate();
  1416.             }
  1417.         }
  1418.        
  1419. #endregion
  1420.  
  1421.         private double Percent;
  1422.        
  1423.         public PlayUI_ProgressBar()
  1424.         {
  1425.             SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  1426.             BackColor = Color.Transparent;
  1427.             DoubleBuffered = true;
  1428.             Size = new Size(100, 10);
  1429.         }
  1430.  
  1431.         public void Increment(int value)
  1432.         {
  1433.             this._Value += value;
  1434.             Invalidate();
  1435.         }
  1436.  
  1437.         public void Deincrement(int value)
  1438.         {
  1439.             this._Value -= value;
  1440.             Invalidate();
  1441.         }
  1442.        
  1443.         protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  1444.         {
  1445.             Graphics G = e.Graphics;
  1446.             G.SmoothingMode = SmoothingMode.HighQuality;
  1447.  
  1448.             this.Percent = (double)this._Value / (double)this._Maximum * 100;
  1449.            
  1450.             int Slope = 8;
  1451.             Rectangle MyRect = new Rectangle(0, 0, Width - 1, Height - 1);
  1452.            
  1453.             GraphicsPath BorderPath = CreateRound(MyRect, Slope);
  1454.             G.FillPath(new SolidBrush(Color.FromArgb(51, 52, 55)), BorderPath);
  1455.            
  1456.             ColorBlend ProgressBlend = new ColorBlend(3);
  1457.             ProgressBlend.Colors[0] = _ValueColour;
  1458.             ProgressBlend.Colors[1] = _ValueColour;
  1459.             ProgressBlend.Colors[2] = _ValueColour;
  1460.             ProgressBlend.Positions = new Single[] {0, 0.5F, 1};
  1461.             LinearGradientBrush LGB = new LinearGradientBrush(MyRect, Color.Black, Color.Black, 90.0F);
  1462.             LGB.InterpolationColors = ProgressBlend;
  1463.  
  1464.             Rectangle ProgressRect = new Rectangle(1, 1, (int)Math.Round(((double)this.Width / (double)this._Maximum * (double)this._Value - 3.0)), this.Height - 3);
  1465.             GraphicsPath ProgressPath = CreateRound(ProgressRect, Slope);
  1466.  
  1467.             if (Percent >= 1)
  1468.             {
  1469.                 G.FillPath(LGB, ProgressPath);
  1470.             }
  1471.            
  1472.             try
  1473.             {
  1474.                 G.DrawPath(new Pen(Color.FromArgb(51, 52, 55)), BorderPath);
  1475.             }
  1476.             catch (Exception)
  1477.             {
  1478.             }
  1479.         }
  1480.     }
  1481.    
  1482. #endregion
Add Comment
Please, Sign In to add comment