Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region " Graphics Functions "
- static class Draw
- {
- public static GraphicsPath RoundRect(Rectangle Rectangle, int Curve)
- {
- GraphicsPath P = new GraphicsPath();
- int ArcRectangleWidth = Curve * 2;
- P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
- P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
- P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
- P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
- P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
- return P;
- }
- public static GraphicsPath RoundRect(int X, int Y, int Width, int Height, int Curve)
- {
- Rectangle Rectangle = new Rectangle(X, Y, Width, Height);
- GraphicsPath P = new GraphicsPath();
- int ArcRectangleWidth = Curve * 2;
- P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
- P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
- P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
- P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
- P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
- return P;
- }
- private static Image ImageFromCode(string str)
- {
- byte[] imageBytes = Convert.FromBase64String(str);
- System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBytes, 0, imageBytes.Length);
- ms.Write(imageBytes, 0, imageBytes.Length);
- Image i = Image.FromStream(ms, true);
- return i;
- }
- public static TextureBrush TiledTextureFromCode(string str)
- {
- return new TextureBrush(Draw.ImageFromCode(str), WrapMode.Tile);
- }
- }
- public struct Rect
- {
- public int left;
- public int top;
- public int right;
- public int bottom;
- }
- enum MouseState : byte
- {
- None = 0,
- Over = 1,
- Down = 2,
- Block = 3
- }
- #endregion
- public class Trackbar : WForms.TrackBar
- {
- private bool _IsMouseDown;
- public Trackbar()
- {
- this.Value = 0;
- this.Maximum = 100;
- SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
- WForms.ControlStyles.UserPaint |
- WForms.ControlStyles.OptimizedDoubleBuffer |
- WForms.ControlStyles.ResizeRedraw |
- WForms.ControlStyles.UserMouse |
- WForms.ControlStyles.FixedHeight |
- WForms.ControlStyles.SupportsTransparentBackColor, true);
- this.BackColor = Color.Transparent;
- this.Width = 250;
- this.Height = 25;
- }
- protected override void CreateHandle()
- {
- base.CreateHandle();
- this.AutoSize = false;
- }
- protected override void OnPaint(WForms.PaintEventArgs e)
- {
- Bitmap B = new Bitmap(Width, Height);
- Graphics G = Graphics.FromImage(B);
- int curve = 1;
- base.OnPaint(e);
- float progressWidth = ((float)Convert.ToDouble(Value) / (float)Maximum) * Width;
- G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- G.Clear(BackColor);
- G.FillPath(new SolidBrush(Color.FromArgb(64, 68, 71)), Draw.RoundRect(new Rectangle(0, (Height / 4), Width - 1, (Height / 2) - 1), curve));
- G.DrawPath(new Pen(Color.FromArgb(64, 68, 71)), Draw.RoundRect(new Rectangle(0, (Height / 4), Width - 1, (Height / 2) - 1), curve));
- G.FillPath(new SolidBrush(Color.FromArgb(30, 255, 255, 255)), Draw.RoundRect(new Rectangle((int)(progressWidth) - 5, (Height / 4), 10, (Height / 2) - 1), curve));
- G.DrawPath(new Pen(Color.FromArgb(30, 255, 255, 255)), Draw.RoundRect(new Rectangle(((int)progressWidth) - 5, (Height / 4), 10, (Height / 2) - 1), curve));
- StringFormat centerTxt = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
- G.DrawString(Value.ToString(), Font, Brushes.White, new Rectangle(0, (Height / 4) + 1, Width - 1, (Height / 2) - 1), centerTxt);
- e.Graphics.DrawImage((Image)B.Clone(), new Point(0, 0));
- }
- private bool IsCursorInSelector(Point mPos)
- {
- return (mPos.X > (((float)Convert.ToDouble(Value) / (float)Maximum) * Width) && mPos.X < ((((float)Convert.ToDouble(Value) / (float)Maximum) * Width) + 10));
- }
- protected override void OnMouseMove(WForms.MouseEventArgs e)
- {
- base.OnMouseMove(e);
- if (_IsMouseDown)
- {
- float newScale = ((float)e.Location.X) / (float)Width;
- newScale *= (float)Maximum;
- if (newScale > Maximum) newScale = Maximum;
- if (newScale < Minimum) newScale = Minimum;
- Value = (int)newScale;
- Invalidate();
- }
- }
- protected override void OnMouseDown(WForms.MouseEventArgs e)
- {
- base.OnMouseDown(e);
- _IsMouseDown = true;
- }
- protected override void OnMouseUp(WForms.MouseEventArgs e)
- {
- base.OnMouseUp(e);
- _IsMouseDown = false;
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- _IsMouseDown = false;
- }
- }
- public class SectionHeader : WForms.CheckBox
- {
- public SectionHeader()
- {
- SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
- WForms.ControlStyles.UserPaint |
- WForms.ControlStyles.OptimizedDoubleBuffer |
- WForms.ControlStyles.ResizeRedraw |
- WForms.ControlStyles.UserMouse |
- WForms.ControlStyles.FixedHeight |
- WForms.ControlStyles.SupportsTransparentBackColor, true);
- this.BackColor = Color.FromArgb(35, 42, 46);
- this.Size = new Size(253, 21);
- this.DoubleBuffered = true;
- }
- protected override void CreateHandle()
- {
- base.CreateHandle();
- this.AutoSize = false;
- }
- protected override void OnMouseDown(WForms.MouseEventArgs mevent)
- {
- base.OnMouseDown(mevent);
- Invalidate();
- }
- protected override void OnMouseUp(WForms.MouseEventArgs mevent)
- {
- base.OnMouseUp(mevent);
- Invalidate();
- }
- protected override void OnPaint(WForms.PaintEventArgs pevent)
- {
- base.OnPaint(pevent);
- pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- pevent.Graphics.Clear(BackColor);
- pevent.Graphics.FillPath(new SolidBrush(Color.FromArgb(68, 79, 114)), Draw.RoundRect(new Rectangle(0, 0, this.Width - 1, this.Height - 1), 2));
- pevent.Graphics.DrawPath(new Pen(Color.FromArgb(68, 79, 114)), Draw.RoundRect(new Rectangle(0, 0, this.Width - 1, this.Height - 1), 2));
- 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 });
- 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 });
- }
- }
- public class SubsectionHeader : WForms.CheckBox
- {
- public SubsectionHeader()
- {
- SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
- WForms.ControlStyles.UserPaint |
- WForms.ControlStyles.OptimizedDoubleBuffer |
- WForms.ControlStyles.ResizeRedraw |
- WForms.ControlStyles.UserMouse |
- WForms.ControlStyles.FixedHeight |
- WForms.ControlStyles.SupportsTransparentBackColor, true);
- this.BackColor = Color.FromArgb(35, 42, 46);
- this.Size = new Size(253, 15);
- this.DoubleBuffered = true;
- }
- protected override void CreateHandle()
- {
- base.CreateHandle();
- this.AutoSize = false;
- }
- protected override void OnMouseDown(WForms.MouseEventArgs mevent)
- {
- base.OnMouseDown(mevent);
- Invalidate();
- }
- protected override void OnMouseUp(WForms.MouseEventArgs mevent)
- {
- base.OnMouseUp(mevent);
- Invalidate();
- }
- protected override void OnPaint(WForms.PaintEventArgs pevent)
- {
- base.OnPaint(pevent);
- pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- pevent.Graphics.Clear(BackColor);
- 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 });
- 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 });
- }
- }
- public class CheckBox : WForms.CheckBox
- {
- public CheckBox()
- {
- SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
- WForms.ControlStyles.UserPaint |
- WForms.ControlStyles.OptimizedDoubleBuffer |
- WForms.ControlStyles.ResizeRedraw |
- WForms.ControlStyles.UserMouse |
- WForms.ControlStyles.FixedHeight |
- WForms.ControlStyles.SupportsTransparentBackColor, true);
- this.AutoSize = false;
- this.BackColor = Color.FromArgb(35, 42, 46);
- this.DoubleBuffered = true;
- }
- protected override void OnMouseDown(WForms.MouseEventArgs mevent)
- {
- base.OnMouseDown(mevent);
- Invalidate();
- }
- protected override void OnMouseUp(WForms.MouseEventArgs mevent)
- {
- base.OnMouseUp(mevent);
- Invalidate();
- }
- protected override void OnPaint(WForms.PaintEventArgs pevent)
- {
- base.OnPaint(pevent);
- pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- pevent.Graphics.Clear(BackColor);
- int curve = 1;
- pevent.Graphics.FillPath(new SolidBrush(Color.FromArgb(64, 68, 71)), Draw.RoundRect(new Rectangle(-1, -1, this.Height, this.Height), curve + 1));
- pevent.Graphics.DrawPath(new Pen(Color.FromArgb(64, 68, 71)), Draw.RoundRect(new Rectangle(-1, -1, this.Height, this.Height), curve + 1));
- 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));
- 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));
- 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 });
- }
- }
- public class RadioButton : WForms.RadioButton
- {
- public RadioButton()
- {
- SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
- WForms.ControlStyles.UserPaint |
- WForms.ControlStyles.OptimizedDoubleBuffer |
- WForms.ControlStyles.ResizeRedraw |
- WForms.ControlStyles.UserMouse |
- WForms.ControlStyles.FixedHeight |
- WForms.ControlStyles.SupportsTransparentBackColor, true);
- this.BackColor = Color.FromArgb(35, 42, 46);
- this.DoubleBuffered = true;
- }
- protected override void OnPaint(WForms.PaintEventArgs pevent)
- {
- base.OnPaint(pevent);
- pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- pevent.Graphics.Clear(BackColor);
- pevent.Graphics.FillEllipse(new SolidBrush(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, this.Height - 1 , this.Height - 1));
- pevent.Graphics.DrawEllipse(new Pen(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, this.Height - 1, this.Height - 1));
- if (this.Checked) pevent.Graphics.FillEllipse(new SolidBrush(Color.FromArgb(124, 124, 127)), new Rectangle(2, 2, this.Height - 5, this.Height - 5));
- if (this.Checked) pevent.Graphics.DrawEllipse(new Pen(Color.FromArgb(124, 124, 127)), new Rectangle(2, 2, this.Height - 5, this.Height - 5));
- 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 });
- }
- }
- public class Button : WForms.Button
- {
- public Graphics graphics;
- public Button()
- {
- SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
- WForms.ControlStyles.UserPaint |
- WForms.ControlStyles.OptimizedDoubleBuffer |
- WForms.ControlStyles.ResizeRedraw |
- WForms.ControlStyles.UserMouse |
- WForms.ControlStyles.FixedHeight |
- WForms.ControlStyles.SupportsTransparentBackColor, true);
- this.BackColor = Color.Transparent;
- this.DoubleBuffered = true;
- }
- private MouseState State = MouseState.None;
- protected override void OnMouseEnter(System.EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseLeave(System.EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnTextChanged(System.EventArgs e)
- {
- base.OnTextChanged(e);
- Invalidate();
- }
- protected override void OnPaint(WForms.PaintEventArgs pevent)
- {
- base.OnPaint(pevent);
- pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
- int curve = 2;
- pevent.Graphics.Clear(BackColor);
- switch(State)
- {
- case MouseState.None:
- pevent.Graphics.FillPath(new SolidBrush(Color.FromArgb(68, 79, 114)), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
- pevent.Graphics.DrawPath(new Pen(Color.FromArgb(68, 79, 114)), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
- break;
- case MouseState.Over:
- pevent.Graphics.FillPath(new SolidBrush(WForms.ControlPaint.Light(Color.FromArgb(68, 79, 114))), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
- pevent.Graphics.DrawPath(new Pen(WForms.ControlPaint.Light(Color.FromArgb(68, 79, 114))), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
- break;
- case MouseState.Down:
- pevent.Graphics.FillPath(new SolidBrush(Color.FromArgb(94, 56, 55)), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
- pevent.Graphics.DrawPath(new Pen(Color.FromArgb(94, 56, 55)), Draw.RoundRect(new Rectangle(0, 0, this.Width, this.Height), curve));
- break;
- }
- 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);
- }
- }
- public class HorizontalSeparator : WForms.Panel
- {
- public HorizontalSeparator()
- {
- SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
- WForms.ControlStyles.UserPaint |
- WForms.ControlStyles.OptimizedDoubleBuffer |
- WForms.ControlStyles.ResizeRedraw |
- WForms.ControlStyles.UserMouse |
- WForms.ControlStyles.FixedHeight |
- WForms.ControlStyles.SupportsTransparentBackColor, true);
- this.BackColor = Color.Transparent;
- }
- protected override void OnPaint(WForms.PaintEventArgs pevent)
- {
- base.OnPaint(pevent);
- pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- pevent.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, this.Width, 1));
- }
- }
- public class VerticalSeparator : WForms.Panel
- {
- public VerticalSeparator()
- {
- SetStyle(WForms.ControlStyles.AllPaintingInWmPaint |
- WForms.ControlStyles.UserPaint |
- WForms.ControlStyles.OptimizedDoubleBuffer |
- WForms.ControlStyles.ResizeRedraw |
- WForms.ControlStyles.UserMouse |
- WForms.ControlStyles.FixedHeight |
- WForms.ControlStyles.SupportsTransparentBackColor, true);
- this.BackColor = Color.Transparent;
- }
- protected override void OnPaint(WForms.PaintEventArgs pevent)
- {
- base.OnPaint(pevent);
- pevent.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- pevent.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, 1, this.Height));
- }
- }
- public class ComboBox : WForms.ComboBox
- {
- public void ReplaceItem(object sender, WForms.DrawItemEventArgs e)
- {
- if (e.Index < 0) return;
- e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
- e.DrawBackground();
- if ((e.State & WForms.DrawItemState.Selected) == WForms.DrawItemState.Selected)
- e.Graphics.FillRectangle((Brush)new SolidBrush(Color.FromArgb(86, 90, 160)), e.Bounds);
- else
- e.Graphics.FillRectangle((Brush)new SolidBrush(Color.FromArgb(64, 68, 71)), e.Bounds);
- using (SolidBrush solidBrush1 = new SolidBrush(e.ForeColor))
- {
- string itemText = this.GetItemText(this.Items[e.Index]);
- Font font = e.Font;
- SolidBrush solidBrush2 = solidBrush1;
- Rectangle bounds1 = e.Bounds;
- int x = bounds1.X;
- bounds1 = e.Bounds;
- int y = checked(bounds1.Y + 1);
- Rectangle bounds2 = e.Bounds;
- int width = bounds2.Width;
- bounds2 = e.Bounds;
- int height = bounds2.Height;
- e.Graphics.DrawString(itemText, font, (Brush)solidBrush2, new Rectangle(x, y, width, height), new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
- }
- }
- protected void DrawTriangle(Color Clr, Point FirstPoint, Point SecondPoint, Point ThirdPoint, Graphics G)
- {
- G.FillPolygon((Brush)new SolidBrush(Clr), new List<Point>()
- {
- FirstPoint,
- SecondPoint,
- ThirdPoint
- }.ToArray());
- }
- public ComboBox()
- {
- this.DrawItem += new WForms.DrawItemEventHandler(this.ReplaceItem);
- this.SetStyle(WForms.ControlStyles.AllPaintingInWmPaint, true);
- this.SetStyle(WForms.ControlStyles.ResizeRedraw, true);
- this.SetStyle(WForms.ControlStyles.UserPaint, true);
- this.SetStyle(WForms.ControlStyles.DoubleBuffer, true);
- this.SetStyle(WForms.ControlStyles.SupportsTransparentBackColor, true);
- this.DrawMode = WForms.DrawMode.OwnerDrawFixed;
- this.BackColor = Color.FromArgb(35, 42, 46);
- this.ForeColor = Color.White;
- this.DropDownStyle = WForms.ComboBoxStyle.DropDownList;
- this.ItemHeight = 15;
- this.DoubleBuffered = true;
- }
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- this.Width = 250;
- }
- protected override void OnPaint(WForms.PaintEventArgs e)
- {
- Bitmap bitmap = new Bitmap(this.Width, this.Height);
- Graphics G = Graphics.FromImage((Image)bitmap);
- G.TextRenderingHint = TextRenderingHint.AntiAlias;
- G.SmoothingMode = SmoothingMode.AntiAlias;
- G.Clear(BackColor);
- G.FillRectangle(new SolidBrush(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, Width - 1, Height - 1));
- G.DrawRectangle(new Pen(Color.FromArgb(64, 68, 71)), new Rectangle(0, 0, Width - 1, Height - 1));
- G.FillRectangle(new SolidBrush(Color.FromArgb(86, 90, 160)), new Rectangle(Width - Height - 1, 0, Height - 1, Height - 1));
- G.DrawRectangle(new Pen(Color.FromArgb(86, 90, 160)), new Rectangle(Width - Height - 1, 0, Height - 1, Height - 1));
- 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()
- {
- LineAlignment = StringAlignment.Center,
- Alignment = StringAlignment.Near
- });
- G.DrawString("▼", this.Font, (Brush)new SolidBrush(ForeColor), (RectangleF)new Rectangle(Width - Height, 1, checked(this.Height - 1), checked(this.Height - 1)), new StringFormat()
- {
- LineAlignment = StringAlignment.Center,
- Alignment = StringAlignment.Center
- });
- e.Graphics.DrawImage((Image)bitmap.Clone(), new Point(0, 0));
- G.Dispose();
- bitmap.Dispose();
- }
- }
- public class VerticalScrollbar : WForms.VScrollBar
- {
- public VerticalScrollbar()
- {
- SetStyle(WForms.ControlStyles.UserPaint | WForms.ControlStyles.AllPaintingInWmPaint | WForms.ControlStyles.FixedWidth | WForms.ControlStyles.OptimizedDoubleBuffer, true);
- this.DoubleBuffered = true;
- this.BackColor = Color.FromArgb(35, 42, 46);
- }
- protected override void OnPaint(WForms.PaintEventArgs e)
- {
- Bitmap B = new Bitmap(Width, Height);
- Graphics G = Graphics.FromImage(B);
- base.OnPaint(e);
- float progressHeight = ((float)Convert.ToDouble(Value) / (float)Maximum) * Height;
- G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- G.Clear(BackColor);
- G.FillRectangle(new SolidBrush(Color.FromArgb(30, 255, 255, 255)), new RectangleF(0, (progressHeight) - 5, Width - 1, 10));
- G.DrawRectangle(new Pen(Color.FromArgb(30, 255, 255, 255)), new Rectangle(0, (int)(progressHeight) - 5, Width - 1, 10));
- StringFormat centerTxt = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
- G.DrawString(Value.ToString(), Font, Brushes.White, new Rectangle(0, (Height / 4) + 1, Width - 1, (Height / 2) - 1), centerTxt);
- e.Graphics.DrawImage((Image)B.Clone(), new Point(0, 0));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement