Advertisement
xZ3ROxPROJ3CTx

Untitled

Mar 1st, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 26.01 KB | None | 0 0
  1.     #region " Graphics Functions "
  2.     static class Draw
  3.     {
  4.         public static GraphicsPath RoundRect(Rectangle Rectangle, int Curve)
  5.         {
  6.             GraphicsPath P = new GraphicsPath();
  7.             int ArcRectangleWidth = Curve * 2;
  8.             P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
  9.             P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
  10.             P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
  11.             P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
  12.             P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
  13.             return P;
  14.         }
  15.         public static GraphicsPath RoundRect(int X, int Y, int Width, int Height, int Curve)
  16.         {
  17.             Rectangle Rectangle = new Rectangle(X, Y, Width, Height);
  18.             GraphicsPath P = new GraphicsPath();
  19.             int ArcRectangleWidth = Curve * 2;
  20.             P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
  21.             P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
  22.             P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
  23.             P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
  24.             P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
  25.             return P;
  26.         }
  27.         private static Image ImageFromCode(string str)
  28.         {
  29.             byte[] imageBytes = Convert.FromBase64String(str);
  30.             System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBytes, 0, imageBytes.Length);
  31.             ms.Write(imageBytes, 0, imageBytes.Length);
  32.             Image i = Image.FromStream(ms, true);
  33.             return i;
  34.         }
  35.  
  36.         public static TextureBrush TiledTextureFromCode(string str)
  37.         {
  38.             return new TextureBrush(Draw.ImageFromCode(str), WrapMode.Tile);
  39.         }
  40.     }
  41.  
  42.     public struct Rect
  43.     {
  44.         public int left;
  45.         public int top;
  46.         public int right;
  47.         public int bottom;
  48.     }
  49.     enum MouseState : byte
  50.     {
  51.         None = 0,
  52.         Over = 1,
  53.         Down = 2,
  54.         Block = 3
  55.     }
  56.     #endregion
  57.  
  58.     public class Trackbar : WForms.TrackBar
  59.     {
  60.         private bool _IsMouseDown;
  61.         public Trackbar()
  62.         {
  63.             this.Value = 0;
  64.             this.Maximum = 100;
  65.             SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
  66.                 WForms.ControlStyles.UserPaint |
  67.                 WForms.ControlStyles.OptimizedDoubleBuffer |
  68.                 WForms.ControlStyles.ResizeRedraw |
  69.                 WForms.ControlStyles.UserMouse |
  70.                 WForms.ControlStyles.FixedHeight |
  71.                 WForms.ControlStyles.SupportsTransparentBackColor, true);
  72.             this.BackColor = Color.Transparent;
  73.             this.Width = 250;
  74.             this.Height = 25;
  75.         }
  76.         protected override void CreateHandle()
  77.         {
  78.             base.CreateHandle();
  79.             this.AutoSize = false;
  80.         }
  81.         protected override void OnPaint(WForms.PaintEventArgs e)
  82.         {
  83.             Bitmap B = new Bitmap(Width, Height);
  84.             Graphics G = Graphics.FromImage(B);
  85.             int curve = 1;
  86.  
  87.             base.OnPaint(e);
  88.  
  89.             float progressWidth = ((float)Convert.ToDouble(Value) / (float)Maximum) * Width;
  90.  
  91.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  92.             G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  93.             G.Clear(BackColor);
  94.             G.FillPath(new SolidBrush(Color.FromArgb(64, 68, 71)), Draw.RoundRect(new Rectangle(0, (Height / 4), Width - 1, (Height / 2) - 1), curve));
  95.             G.DrawPath(new Pen(Color.FromArgb(64, 68, 71)), Draw.RoundRect(new Rectangle(0, (Height / 4), Width - 1, (Height / 2) - 1), curve));
  96.  
  97.             G.FillPath(new SolidBrush(Color.FromArgb(30, 255, 255, 255)), Draw.RoundRect(new Rectangle((int)(progressWidth) - 5, (Height / 4), 10, (Height / 2) - 1), curve));
  98.             G.DrawPath(new Pen(Color.FromArgb(30, 255, 255, 255)), Draw.RoundRect(new Rectangle(((int)progressWidth) - 5, (Height / 4), 10, (Height / 2) - 1), curve));
  99.  
  100.             StringFormat centerTxt = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
  101.             G.DrawString(Value.ToString(), Font, Brushes.White, new Rectangle(0, (Height / 4) + 1, Width - 1, (Height / 2) - 1), centerTxt);
  102.  
  103.             e.Graphics.DrawImage((Image)B.Clone(), new Point(0, 0));
  104.         }
  105.         private bool IsCursorInSelector(Point mPos)
  106.         {
  107.             return (mPos.X > (((float)Convert.ToDouble(Value) / (float)Maximum) * Width) && mPos.X < ((((float)Convert.ToDouble(Value) / (float)Maximum) * Width) + 10));
  108.         }
  109.         protected override void OnMouseMove(WForms.MouseEventArgs e)
  110.         {
  111.             base.OnMouseMove(e);
  112.             if (_IsMouseDown)
  113.             {
  114.                 float newScale = ((float)e.Location.X) / (float)Width;
  115.                 newScale *= (float)Maximum;
  116.                 if (newScale > Maximum) newScale = Maximum;
  117.                 if (newScale < Minimum) newScale = Minimum;
  118.                 Value = (int)newScale;
  119.                 Invalidate();
  120.             }
  121.         }
  122.         protected override void OnMouseDown(WForms.MouseEventArgs e)
  123.         {
  124.             base.OnMouseDown(e);
  125.             _IsMouseDown = true;
  126.         }
  127.         protected override void OnMouseUp(WForms.MouseEventArgs e)
  128.         {
  129.             base.OnMouseUp(e);
  130.             _IsMouseDown = false;
  131.         }
  132.         protected override void OnMouseLeave(EventArgs e)
  133.         {
  134.             base.OnMouseLeave(e);
  135.             _IsMouseDown = false;
  136.         }
  137.     }
  138.     public class SectionHeader : WForms.CheckBox
  139.     {
  140.         public SectionHeader()
  141.         {
  142.             SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
  143.                 WForms.ControlStyles.UserPaint |
  144.                 WForms.ControlStyles.OptimizedDoubleBuffer |
  145.                 WForms.ControlStyles.ResizeRedraw |
  146.                 WForms.ControlStyles.UserMouse |
  147.                 WForms.ControlStyles.FixedHeight |
  148.                 WForms.ControlStyles.SupportsTransparentBackColor, true);
  149.             this.BackColor = Color.FromArgb(35, 42, 46);
  150.             this.Size = new Size(253, 21);
  151.             this.DoubleBuffered = true;
  152.         }
  153.         protected override void CreateHandle()
  154.         {
  155.             base.CreateHandle();
  156.             this.AutoSize = false;
  157.         }
  158.         protected override void OnMouseDown(WForms.MouseEventArgs mevent)
  159.         {
  160.             base.OnMouseDown(mevent);
  161.             Invalidate();
  162.         }
  163.         protected override void OnMouseUp(WForms.MouseEventArgs mevent)
  164.         {
  165.             base.OnMouseUp(mevent);
  166.             Invalidate();
  167.         }
  168.         protected override void OnPaint(WForms.PaintEventArgs pevent)
  169.         {
  170.             base.OnPaint(pevent);
  171.             pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  172.             pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  173.             pevent.Graphics.Clear(BackColor);
  174.  
  175.             pevent.Graphics.FillPath(new SolidBrush(Color.FromArgb(68, 79, 114)), Draw.RoundRect(new Rectangle(0, 0, this.Width - 1, this.Height - 1), 2));
  176.             pevent.Graphics.DrawPath(new Pen(Color.FromArgb(68, 79, 114)), Draw.RoundRect(new Rectangle(0, 0, this.Width - 1, this.Height - 1), 2));
  177.             pevent.Graphics.DrawString(this.Checked ? "▼" : "►", new Font("Franklin Gothic Medium", 9.15f, FontStyle.Bold), new SolidBrush(ForeColor), new Rectangle(2, 1, this.Height, this.Height), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
  178.             pevent.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(this.Height + 2, 1, this.Width, this.Height), new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
  179.         }
  180.     }
  181.     public class SubsectionHeader : WForms.CheckBox
  182.     {
  183.         public SubsectionHeader()
  184.         {
  185.             SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
  186.                 WForms.ControlStyles.UserPaint |
  187.                 WForms.ControlStyles.OptimizedDoubleBuffer |
  188.                 WForms.ControlStyles.ResizeRedraw |
  189.                 WForms.ControlStyles.UserMouse |
  190.                 WForms.ControlStyles.FixedHeight |
  191.                 WForms.ControlStyles.SupportsTransparentBackColor, true);
  192.             this.BackColor = Color.FromArgb(35, 42, 46);
  193.             this.Size = new Size(253, 15);
  194.             this.DoubleBuffered = true;
  195.         }
  196.         protected override void CreateHandle()
  197.         {
  198.             base.CreateHandle();
  199.             this.AutoSize = false;
  200.         }
  201.         protected override void OnMouseDown(WForms.MouseEventArgs mevent)
  202.         {
  203.             base.OnMouseDown(mevent);
  204.             Invalidate();
  205.         }
  206.         protected override void OnMouseUp(WForms.MouseEventArgs mevent)
  207.         {
  208.             base.OnMouseUp(mevent);
  209.             Invalidate();
  210.         }
  211.         protected override void OnPaint(WForms.PaintEventArgs pevent)
  212.         {
  213.             base.OnPaint(pevent);
  214.             pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  215.             pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  216.             pevent.Graphics.Clear(BackColor);
  217.  
  218.             pevent.Graphics.DrawString(this.Checked ? "▼" : "►", new Font("Franklin Gothic Medium", 9.15f, FontStyle.Bold), new SolidBrush(ForeColor), new Rectangle(2, 1, this.Height, this.Height), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
  219.             pevent.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(this.Height + 3, 1, this.Width, this.Height), new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
  220.         }
  221.     }
  222.     public class CheckBox : WForms.CheckBox
  223.     {
  224.         public CheckBox()
  225.         {
  226.             SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
  227.                 WForms.ControlStyles.UserPaint |
  228.                 WForms.ControlStyles.OptimizedDoubleBuffer |
  229.                 WForms.ControlStyles.ResizeRedraw |
  230.                 WForms.ControlStyles.UserMouse |
  231.                 WForms.ControlStyles.FixedHeight |
  232.                 WForms.ControlStyles.SupportsTransparentBackColor, true);
  233.             this.AutoSize = false;
  234.             this.BackColor = Color.FromArgb(35, 42, 46);
  235.             this.DoubleBuffered = true;
  236.         }
  237.         protected override void OnMouseDown(WForms.MouseEventArgs mevent)
  238.         {
  239.             base.OnMouseDown(mevent);
  240.             Invalidate();
  241.         }
  242.         protected override void OnMouseUp(WForms.MouseEventArgs mevent)
  243.         {
  244.             base.OnMouseUp(mevent);
  245.             Invalidate();
  246.         }
  247.         protected override void OnPaint(WForms.PaintEventArgs pevent)
  248.         {
  249.             base.OnPaint(pevent);
  250.             pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  251.             pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  252.             pevent.Graphics.Clear(BackColor);
  253.             int curve = 1;
  254.  
  255.             pevent.Graphics.FillPath(new SolidBrush(Color.FromArgb(64, 68, 71)), Draw.RoundRect(new Rectangle(-1, -1, this.Height, this.Height), curve + 1));
  256.             pevent.Graphics.DrawPath(new Pen(Color.FromArgb(64, 68, 71)), Draw.RoundRect(new Rectangle(-1, -1, this.Height, this.Height), curve + 1));
  257.             if (this.Checked) pevent.Graphics.FillPath(new SolidBrush(Color.FromArgb(124, 124, 127)), Draw.RoundRect(new Rectangle(2,2, this.Height - 5, this.Height - 5), curve));
  258.             if (this.Checked) pevent.Graphics.DrawPath(new Pen(Color.FromArgb(124, 124, 127)), Draw.RoundRect(new Rectangle(2,2, this.Height - 5, this.Height - 5), curve));
  259.  
  260.             pevent.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(this.Height + 2, 1, this.Width, this.Height), new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
  261.         }
  262.     }
  263.     public class RadioButton : WForms.RadioButton
  264.     {
  265.         public RadioButton()
  266.         {
  267.             SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
  268.                 WForms.ControlStyles.UserPaint |
  269.                 WForms.ControlStyles.OptimizedDoubleBuffer |
  270.                 WForms.ControlStyles.ResizeRedraw |
  271.                 WForms.ControlStyles.UserMouse |
  272.                 WForms.ControlStyles.FixedHeight |
  273.                 WForms.ControlStyles.SupportsTransparentBackColor, true);
  274.             this.BackColor = Color.FromArgb(35, 42, 46);
  275.             this.DoubleBuffered = true;
  276.         }
  277.  
  278.         protected override void OnPaint(WForms.PaintEventArgs pevent)
  279.         {
  280.             base.OnPaint(pevent);
  281.             pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  282.             pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  283.             pevent.Graphics.Clear(BackColor);
  284.             pevent.Graphics.FillEllipse(new SolidBrush(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, this.Height - 1 , this.Height - 1));
  285.             pevent.Graphics.DrawEllipse(new Pen(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, this.Height - 1, this.Height - 1));
  286.             if (this.Checked) pevent.Graphics.FillEllipse(new SolidBrush(Color.FromArgb(124, 124, 127)), new Rectangle(2, 2, this.Height - 5, this.Height - 5));
  287.             if (this.Checked) pevent.Graphics.DrawEllipse(new Pen(Color.FromArgb(124, 124, 127)), new Rectangle(2, 2, this.Height - 5, this.Height - 5));
  288.             pevent.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(this.Height + 2, 1, this.Width, this.Height), new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
  289.         }
  290.     }
  291.     public class Button : WForms.Button
  292.     {
  293.         public Graphics graphics;
  294.         public Button()
  295.         {
  296.             SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
  297.                 WForms.ControlStyles.UserPaint |
  298.                 WForms.ControlStyles.OptimizedDoubleBuffer |
  299.                 WForms.ControlStyles.ResizeRedraw |
  300.                 WForms.ControlStyles.UserMouse |
  301.                 WForms.ControlStyles.FixedHeight |
  302.                 WForms.ControlStyles.SupportsTransparentBackColor, true);
  303.             this.BackColor = Color.Transparent;
  304.             this.DoubleBuffered = true;
  305.         }
  306.         private MouseState State = MouseState.None;
  307.         protected override void OnMouseEnter(System.EventArgs e)
  308.         {
  309.             base.OnMouseEnter(e);
  310.             State = MouseState.Over;
  311.             Invalidate();
  312.         }
  313.         protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
  314.         {
  315.             base.OnMouseDown(e);
  316.             State = MouseState.Down;
  317.             Invalidate();
  318.         }
  319.         protected override void OnMouseLeave(System.EventArgs e)
  320.         {
  321.             base.OnMouseLeave(e);
  322.             State = MouseState.None;
  323.             Invalidate();
  324.         }
  325.         protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
  326.         {
  327.             base.OnMouseUp(e);
  328.             State = MouseState.Over;
  329.             Invalidate();
  330.         }
  331.         protected override void OnTextChanged(System.EventArgs e)
  332.         {
  333.             base.OnTextChanged(e);
  334.             Invalidate();
  335.         }
  336.  
  337.         protected override void OnPaint(WForms.PaintEventArgs pevent)
  338.         {
  339.             base.OnPaint(pevent);
  340.  
  341.             pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  342.             pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
  343.             int curve = 2;
  344.  
  345.             pevent.Graphics.Clear(BackColor);
  346.  
  347.             switch(State)
  348.             {
  349.                 case MouseState.None:
  350.                     pevent.Graphics.FillPath(new SolidBrush(Color.FromArgb(68, 79, 114)), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
  351.                     pevent.Graphics.DrawPath(new Pen(Color.FromArgb(68, 79, 114)), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
  352.                     break;
  353.                 case MouseState.Over:
  354.                     pevent.Graphics.FillPath(new SolidBrush(WForms.ControlPaint.Light(Color.FromArgb(68, 79, 114))), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
  355.                     pevent.Graphics.DrawPath(new Pen(WForms.ControlPaint.Light(Color.FromArgb(68, 79, 114))), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
  356.                     break;
  357.                 case MouseState.Down:
  358.                     pevent.Graphics.FillPath(new SolidBrush(Color.FromArgb(94, 56, 55)), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
  359.                     pevent.Graphics.DrawPath(new Pen(Color.FromArgb(94, 56, 55)), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
  360.                     break;
  361.             }
  362.  
  363.             pevent.Graphics.DrawString(this.Text, Font, new SolidBrush(ForeColor), Width / 2 - WForms.TextRenderer.MeasureText(this.Text, Font).Width / 2, Height / 2 - WForms.TextRenderer.MeasureText(this.Text, Font).Height / 2);
  364.         }
  365.     }
  366.     public class HorizontalSeparator : WForms.Panel
  367.     {
  368.         public HorizontalSeparator()
  369.         {
  370.             SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
  371.                 WForms.ControlStyles.UserPaint |
  372.                 WForms.ControlStyles.OptimizedDoubleBuffer |
  373.                 WForms.ControlStyles.ResizeRedraw |
  374.                 WForms.ControlStyles.UserMouse |
  375.                 WForms.ControlStyles.FixedHeight |
  376.                 WForms.ControlStyles.SupportsTransparentBackColor, true);
  377.             this.BackColor = Color.Transparent;
  378.         }
  379.  
  380.         protected override void OnPaint(WForms.PaintEventArgs pevent)
  381.         {
  382.             base.OnPaint(pevent);
  383.  
  384.             pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  385.             pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  386.  
  387.             pevent.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, this.Width, 1));
  388.         }
  389.     }
  390.     public class VerticalSeparator : WForms.Panel
  391.     {
  392.         public VerticalSeparator()
  393.         {
  394.             SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
  395.                 WForms.ControlStyles.UserPaint |
  396.                 WForms.ControlStyles.OptimizedDoubleBuffer |
  397.                 WForms.ControlStyles.ResizeRedraw |
  398.                 WForms.ControlStyles.UserMouse |
  399.                 WForms.ControlStyles.FixedHeight |
  400.                 WForms.ControlStyles.SupportsTransparentBackColor, true);
  401.             this.BackColor = Color.Transparent;
  402.         }
  403.  
  404.         protected override void OnPaint(WForms.PaintEventArgs pevent)
  405.         {
  406.             base.OnPaint(pevent);
  407.  
  408.             pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  409.             pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  410.  
  411.             pevent.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, 1, this.Height));
  412.         }
  413.     }
  414.     public class ComboBox : WForms.ComboBox
  415.     {
  416.  
  417.         public void ReplaceItem(object sender, WForms.DrawItemEventArgs e)
  418.         {
  419.             if (e.Index < 0) return;
  420.  
  421.             e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
  422.             e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  423.  
  424.             e.DrawBackground();
  425.  
  426.             if ((e.State & WForms.DrawItemState.Selected) == WForms.DrawItemState.Selected)
  427.                 e.Graphics.FillRectangle((Brush)new SolidBrush(Color.FromArgb(86, 90, 160)), e.Bounds);
  428.             else
  429.                 e.Graphics.FillRectangle((Brush)new SolidBrush(Color.FromArgb(64, 68, 71)), e.Bounds);
  430.  
  431.             using (SolidBrush solidBrush1 = new SolidBrush(e.ForeColor))
  432.             {
  433.                 string itemText = this.GetItemText(this.Items[e.Index]);
  434.                 Font font = e.Font;
  435.                 SolidBrush solidBrush2 = solidBrush1;
  436.                 Rectangle bounds1 = e.Bounds;
  437.                 int x = bounds1.X;
  438.                 bounds1 = e.Bounds;
  439.                 int y = checked(bounds1.Y + 1);
  440.                 Rectangle bounds2 = e.Bounds;
  441.                 int width = bounds2.Width;
  442.                 bounds2 = e.Bounds;
  443.                 int height = bounds2.Height;
  444.                 e.Graphics.DrawString(itemText, font, (Brush)solidBrush2, new Rectangle(x, y, width, height), new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
  445.             }
  446.         }
  447.  
  448.         protected void DrawTriangle(Color Clr, Point FirstPoint, Point SecondPoint, Point ThirdPoint, Graphics G)
  449.         {
  450.             G.FillPolygon((Brush)new SolidBrush(Clr), new List<Point>()
  451.               {
  452.                 FirstPoint,
  453.                 SecondPoint,
  454.                 ThirdPoint
  455.               }.ToArray());
  456.         }
  457.  
  458.         public ComboBox()
  459.         {
  460.             this.DrawItem += new WForms.DrawItemEventHandler(this.ReplaceItem);
  461.             this.SetStyle(WForms.ControlStyles.AllPaintingInWmPaint, true);
  462.             this.SetStyle(WForms.ControlStyles.ResizeRedraw, true);
  463.             this.SetStyle(WForms.ControlStyles.UserPaint, true);
  464.             this.SetStyle(WForms.ControlStyles.DoubleBuffer, true);
  465.             this.SetStyle(WForms.ControlStyles.SupportsTransparentBackColor, true);
  466.             this.DrawMode = WForms.DrawMode.OwnerDrawFixed;
  467.             this.BackColor = Color.FromArgb(35, 42, 46);
  468.             this.ForeColor = Color.White;
  469.             this.DropDownStyle = WForms.ComboBoxStyle.DropDownList;
  470.  
  471.             this.ItemHeight = 15;
  472.             this.DoubleBuffered = true;
  473.         }
  474.  
  475.         protected override void OnResize(EventArgs e)
  476.         {
  477.             base.OnResize(e);
  478.             this.Width = 250;
  479.         }
  480.  
  481.         protected override void OnPaint(WForms.PaintEventArgs e)
  482.         {
  483.             Bitmap bitmap = new Bitmap(this.Width, this.Height);
  484.             Graphics G = Graphics.FromImage((Image)bitmap);
  485.             G.TextRenderingHint = TextRenderingHint.AntiAlias;
  486.             G.SmoothingMode = SmoothingMode.AntiAlias;
  487.  
  488.             G.Clear(BackColor);
  489.  
  490.             G.FillRectangle(new SolidBrush(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, Width - 1, Height - 1));
  491.             G.DrawRectangle(new Pen(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, Width - 1, Height - 1));
  492.  
  493.             G.FillRectangle(new SolidBrush(Color.FromArgb(86, 90, 160)), new Rectangle(Width - Height - 1, 0, Height - 1, Height - 1));
  494.             G.DrawRectangle(new Pen(Color.FromArgb(86, 90, 160)), new Rectangle(Width - Height - 1, 0, Height - 1, Height - 1));
  495.  
  496.             G.DrawString(this.Text, this.Font, (Brush)new SolidBrush(ForeColor), (RectangleF)new Rectangle(7, 1, checked(this.Width - 1), checked(this.Height - 1)), new StringFormat()
  497.             {
  498.                 LineAlignment = StringAlignment.Center,
  499.                 Alignment = StringAlignment.Near
  500.             });
  501.             G.DrawString("▼", this.Font, (Brush)new SolidBrush(ForeColor), (RectangleF)new Rectangle(Width - Height, 1, checked(this.Height - 1), checked(this.Height - 1)), new StringFormat()
  502.             {
  503.                 LineAlignment = StringAlignment.Center,
  504.                 Alignment = StringAlignment.Center
  505.             });
  506.             e.Graphics.DrawImage((Image)bitmap.Clone(), new Point(0, 0));
  507.             G.Dispose();
  508.             bitmap.Dispose();
  509.         }
  510.     }
  511.     public class VerticalScrollbar : WForms.VScrollBar
  512.     {
  513.         public VerticalScrollbar()
  514.         {
  515.             SetStyle(WForms.ControlStyles.UserPaint | WForms.ControlStyles.AllPaintingInWmPaint | WForms.ControlStyles.FixedWidth | WForms.ControlStyles.OptimizedDoubleBuffer, true);
  516.             this.DoubleBuffered = true;
  517.             this.BackColor = Color.FromArgb(35, 42, 46);
  518.         }
  519.         protected override void OnPaint(WForms.PaintEventArgs e)
  520.         {
  521.             Bitmap B = new Bitmap(Width, Height);
  522.             Graphics G = Graphics.FromImage(B);
  523.  
  524.             base.OnPaint(e);
  525.  
  526.             float progressHeight = ((float)Convert.ToDouble(Value) / (float)Maximum) * Height;
  527.  
  528.             G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  529.             G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  530.             G.Clear(BackColor);
  531.             G.FillRectangle(new SolidBrush(Color.FromArgb(30, 255, 255, 255)), new RectangleF(0, (progressHeight) - 5, Width - 1, 10));
  532.             G.DrawRectangle(new Pen(Color.FromArgb(30, 255, 255, 255)), new Rectangle(0, (int)(progressHeight) - 5, Width - 1, 10));
  533.             StringFormat centerTxt = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
  534.             G.DrawString(Value.ToString(), Font, Brushes.White, new Rectangle(0, (Height / 4) + 1, Width - 1, (Height / 2) - 1), centerTxt);
  535.  
  536.             e.Graphics.DrawImage((Image)B.Clone(), new Point(0, 0));
  537.  
  538.         }
  539.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement