Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Drawing.Drawing2D;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Drawing;
- using System;
- /// <summary>
- /// Flat UI Theme
- /// Creator: iSynthesis (HF)
- /// Version: 1.0.4
- /// Date Created: 17/06/2013
- /// Date Changed: 26/06/2013
- /// UID: 374648
- /// For any bugs / errors, PM me.
- /// </summary>
- /// <remarks></remarks>
- static class Helpers
- {
- #region " Variables"
- static internal Graphics G;
- static internal Bitmap B;
- static internal Color _FlatColor = Color.FromArgb(35, 168, 109);
- static internal StringFormat NearSF = new StringFormat {
- Alignment = StringAlignment.Near,
- LineAlignment = StringAlignment.Near
- };
- static internal StringFormat CenterSF = new StringFormat {
- Alignment = StringAlignment.Center,
- LineAlignment = StringAlignment.Center
- #endregion
- };
- #region " Functions"
- public static GraphicsPath RoundRec(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 w, int h, double r = 0.3, bool TL = true, bool TR = true, bool BR = true, bool BL = true)
- {
- GraphicsPath functionReturnValue = default(GraphicsPath);
- int d = Math.Min(w, h) * (int)r, xw = x + w, yh = y + h;
- functionReturnValue = new GraphicsPath();
- {
- if (TL)
- functionReturnValue.AddArc(x, y, d, d, 180, 90);
- else
- functionReturnValue.AddLine(x, y, x, y);
- if (TR)
- functionReturnValue.AddArc(xw - d, y, d, d, 270, 90);
- else
- functionReturnValue.AddLine(xw, y, xw, y);
- if (BR)
- functionReturnValue.AddArc(xw - d, yh - d, d, d, 0, 90);
- else
- functionReturnValue.AddLine(xw, yh, xw, yh);
- if (BL)
- functionReturnValue.AddArc(x, yh - d, d, d, 90, 90);
- else
- functionReturnValue.AddLine(x, yh, x, yh);
- functionReturnValue.CloseFigure();
- }
- return functionReturnValue;
- }
- //-- Credit: AeonHack
- public static GraphicsPath DrawArrow(int x, int y, bool flip)
- {
- GraphicsPath GP = new GraphicsPath();
- int W = 12;
- int H = 6;
- if (flip) {
- GP.AddLine(x + 1, y, x + W + 1, y);
- GP.AddLine(x + W, y, x + H, y + H - 1);
- } else {
- GP.AddLine(x, y + H, x + W, y + H);
- GP.AddLine(x + W, y + H, x + H, y);
- }
- GP.CloseFigure();
- return GP;
- }
- #endregion
- }
- #region " Mouse States"
- enum MouseState : byte
- {
- None = 0,
- Over = 1,
- Down = 2,
- Block = 3
- }
- #endregion
- class FormSkin : ContainerControl
- {
- #region " Variables"
- private int W;
- private int H;
- private bool Cap = false;
- private bool _HeaderMaximize = false;
- private Point MousePoint = new Point(0, 0);
- private Color _FlatColor;
- private int MoveHeight = 50;
- #endregion
- #region " Properties"
- #region " Colors"
- [Category("Colors")]
- public Color HeaderColor {
- get { return _HeaderColor; }
- set { _HeaderColor = value; }
- }
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- [Category("Colors")]
- public Color BorderColor {
- get { return _BorderColor; }
- set { _BorderColor = value; }
- }
- [Category("Colors")]
- public Color FlatColor {
- get { return _FlatColor; }
- set { _FlatColor = value; }
- }
- #endregion
- #region " Options"
- [Category("Options")]
- public bool HeaderMaximize {
- get { return _HeaderMaximize; }
- set { _HeaderMaximize = value; }
- }
- #endregion
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- if (e.Button == System.Windows.Forms.MouseButtons.Left & new Rectangle(0, 0, Width, MoveHeight).Contains(e.Location)) {
- Cap = true;
- MousePoint = e.Location;
- }
- }
- private void // ERROR: Handles clauses are not supported in C#
- FormSkin_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (HeaderMaximize) {
- if (e.Button == System.Windows.Forms.MouseButtons.Left & new Rectangle(0, 0, Width, MoveHeight).Contains(e.Location)) {
- if (FindForm().WindowState == FormWindowState.Normal) {
- FindForm().WindowState = FormWindowState.Maximized;
- FindForm().Refresh();
- } else if (FindForm().WindowState == FormWindowState.Maximized) {
- FindForm().WindowState = FormWindowState.Normal;
- FindForm().Refresh();
- }
- }
- }
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- Cap = false;
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- if (Cap) {
- Parent.Location = new Point(MousePosition.X-MousePoint.X,MousePosition.Y-MousePoint.Y);
- }
- }
- protected override void OnCreateControl()
- {
- base.OnCreateControl();
- ParentForm.FormBorderStyle = FormBorderStyle.None;
- ParentForm.AllowTransparency = false;
- ParentForm.TransparencyKey = Color.Fuchsia;
- ParentForm.FindForm().StartPosition = FormStartPosition.CenterScreen;
- Dock = DockStyle.Fill;
- Invalidate();
- }
- #endregion
- #region " Colors"
- #region " Dark Colors"
- private Color _HeaderColor = Color.FromArgb(45, 47, 49);
- private Color _BaseColor = Color.FromArgb(60, 70, 73);
- private Color _BorderColor = Color.FromArgb(53, 58, 60);
- private Color TextColor = Color.FromArgb(234, 234, 234);
- #endregion
- #region " Light Colors"
- private Color _HeaderLight = Color.FromArgb(171, 171, 172);
- private Color _BaseLight = Color.FromArgb(196, 199, 200);
- public Color TextLight = Color.FromArgb(45, 47, 49);
- #endregion
- #endregion
- public FormSkin()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- BackColor = Color.White;
- Font = new Font("Segoe UI", 12);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width;
- H = Height;
- Rectangle Base = new Rectangle(0, 0, W, H);
- Rectangle Header = new Rectangle(0, 0, W, 50);
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- //-- Header
- G.FillRectangle(new SolidBrush(_HeaderColor), Header);
- //-- Logo
- G.FillRectangle(new SolidBrush(Color.FromArgb(243, 243, 243)), new Rectangle(8, 16, 4, 18));
- G.FillRectangle(new SolidBrush(_FlatColor), 16, 16, 4, 18);
- G.DrawString(Text, Font, new SolidBrush(TextColor), new Rectangle(26, 15, W, H), NearSF);
- //-- Border
- G.DrawRectangle(new Pen(_BorderColor), Base);
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = (InterpolationMode)7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatClose : Control
- {
- #region " Variables"
- private MouseState State = MouseState.None;
- private int x;
- #endregion
- #region " Properties"
- #region " Mouse States"
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- x = e.X;
- Invalidate();
- }
- protected override void OnClick(EventArgs e)
- {
- base.OnClick(e);
- Environment.Exit(0);
- }
- #endregion
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Size = new Size(18, 18);
- }
- #region " Colors"
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- [Category("Colors")]
- public Color TextColor {
- get { return _TextColor; }
- set { _TextColor = value; }
- }
- #endregion
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(168, 35, 35);
- private Color _TextColor = Color.FromArgb(243, 243, 243);
- #endregion
- public FlatClose()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- BackColor = Color.White;
- Size = new Size(18, 18);
- Anchor = AnchorStyles.Top | AnchorStyles.Right;
- Font = new Font("Marlett", 10);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- Bitmap B = new Bitmap(Width, Height);
- Graphics G = Graphics.FromImage(B);
- Rectangle Base = new Rectangle(0, 0, Width, Height);
- {
- G.SmoothingMode = (SmoothingMode)2;
- G.PixelOffsetMode = (PixelOffsetMode)2;
- G.TextRenderingHint = ( System.Drawing.Text.TextRenderingHint)5;
- G.Clear(BackColor);
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- //-- X
- G.DrawString("r", Font, new SolidBrush(TextColor), new Rectangle(0, 0, Width, Height), CenterSF);
- //-- Hover/down
- switch (State) {
- case MouseState.Over:
- G.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.White)), Base);
- break;
- case MouseState.Down:
- G.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.Black)), Base);
- break;
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = (InterpolationMode)7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatMax : Control
- {
- #region " Variables"
- private MouseState State = MouseState.None;
- private int x;
- #endregion
- #region " Properties"
- #region " Mouse States"
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- x = e.X;
- Invalidate();
- }
- protected override void OnClick(EventArgs e)
- {
- base.OnClick(e);
- switch (FindForm().WindowState) {
- case FormWindowState.Maximized:
- FindForm().WindowState = FormWindowState.Normal;
- break;
- case FormWindowState.Normal:
- FindForm().WindowState = FormWindowState.Maximized;
- break;
- }
- }
- #endregion
- #region " Colors"
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- [Category("Colors")]
- public Color TextColor {
- get { return _TextColor; }
- set { _TextColor = value; }
- }
- #endregion
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Size = new Size(18, 18);
- }
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(45, 47, 49);
- private Color _TextColor = Color.FromArgb(243, 243, 243);
- #endregion
- public FlatMax()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- BackColor = Color.White;
- Size = new Size(18, 18);
- Anchor = AnchorStyles.Top | AnchorStyles.Right;
- Font = new Font("Marlett", 12);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- Bitmap B = new Bitmap(Width, Height);
- Graphics G = Graphics.FromImage(B);
- Rectangle Base = new Rectangle(0, 0, Width, Height);
- {
- G.SmoothingMode = (SmoothingMode)2;
- G.PixelOffsetMode = (PixelOffsetMode)2;
- G.TextRenderingHint = ( System.Drawing.Text.TextRenderingHint)5;
- G.Clear(BackColor);
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- //-- Maximize
- if (FindForm().WindowState == FormWindowState.Maximized) {
- G.DrawString("1", Font, new SolidBrush(TextColor), new Rectangle(1, 1, Width, Height), CenterSF);
- } else if (FindForm().WindowState == FormWindowState.Normal) {
- G.DrawString("2", Font, new SolidBrush(TextColor), new Rectangle(1, 1, Width, Height), CenterSF);
- }
- //-- Hover/down
- switch (State) {
- case MouseState.Over:
- G.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.White)), Base);
- break;
- case MouseState.Down:
- G.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.Black)), Base);
- break;
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = (InterpolationMode)7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatMini : Control
- {
- #region " Variables"
- private MouseState State = MouseState.None;
- private int x;
- #endregion
- #region " Properties"
- #region " Mouse States"
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- x = e.X;
- Invalidate();
- }
- protected override void OnClick(EventArgs e)
- {
- base.OnClick(e);
- switch (FindForm().WindowState) {
- case FormWindowState.Normal:
- FindForm().WindowState = FormWindowState.Minimized;
- break;
- case FormWindowState.Maximized:
- FindForm().WindowState = FormWindowState.Minimized;
- break;
- }
- }
- #endregion
- #region " Colors"
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- [Category("Colors")]
- public Color TextColor {
- get { return _TextColor; }
- set { _TextColor = value; }
- }
- #endregion
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Size = new Size(18, 18);
- }
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(45, 47, 49);
- private Color _TextColor = Color.FromArgb(243, 243, 243);
- #endregion
- public FlatMini()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- BackColor = Color.White;
- Size = new Size(18, 18);
- Anchor = AnchorStyles.Top | AnchorStyles.Right;
- Font = new Font("Marlett", 12);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- Bitmap B = new Bitmap(Width, Height);
- Graphics G = Graphics.FromImage(B);
- Rectangle Base = new Rectangle(0, 0, Width, Height);
- {
- G.SmoothingMode = (SmoothingMode)2;
- G.PixelOffsetMode = (PixelOffsetMode)2;
- G.TextRenderingHint = (System.Drawing.Text.TextRenderingHint)5;
- G.Clear(BackColor);
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- //-- Minimize
- G.DrawString("0", Font, new SolidBrush(TextColor), new Rectangle(2, 1, Width, Height), CenterSF);
- //-- Hover/down
- switch (State) {
- case MouseState.Over:
- G.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.White)), Base);
- break;
- case MouseState.Down:
- G.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.Black)), Base);
- break;
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = (InterpolationMode)7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatColorPalette : Control
- {
- #region " Variables"
- private int W;
- private int H;
- #endregion
- #region " Properties"
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Width = 180;
- Height = 80;
- }
- #region " Colors"
- [Category("Colors")]
- public Color Red {
- get { return _Red; }
- set { _Red = value; }
- }
- [Category("Colors")]
- public Color Cyan {
- get { return _Cyan; }
- set { _Cyan = value; }
- }
- [Category("Colors")]
- public Color Blue {
- get { return _Blue; }
- set { _Blue = value; }
- }
- [Category("Colors")]
- public Color LimeGreen {
- get { return _LimeGreen; }
- set { _LimeGreen = value; }
- }
- [Category("Colors")]
- public Color Orange {
- get { return _Orange; }
- set { _Orange = value; }
- }
- [Category("Colors")]
- public Color Purple {
- get { return _Purple; }
- set { _Purple = value; }
- }
- [Category("Colors")]
- public Color Black {
- get { return _Black; }
- set { _Black = value; }
- }
- [Category("Colors")]
- public Color Gray {
- get { return _Gray; }
- set { _Gray = value; }
- }
- [Category("Colors")]
- public Color White {
- get { return _White; }
- set { _White = value; }
- }
- #endregion
- #endregion
- #region " Colors"
- private Color _Red = Color.FromArgb(220, 85, 96);
- private Color _Cyan = Color.FromArgb(10, 154, 157);
- private Color _Blue = Color.FromArgb(0, 128, 255);
- private Color _LimeGreen = Color.FromArgb(35, 168, 109);
- private Color _Orange = Color.FromArgb(253, 181, 63);
- private Color _Purple = Color.FromArgb(155, 88, 181);
- private Color _Black = Color.FromArgb(45, 47, 49);
- private Color _Gray = Color.FromArgb(63, 70, 73);
- private Color _White = Color.FromArgb(243, 243, 243);
- #endregion
- public FlatColorPalette()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- BackColor = Color.FromArgb(60, 70, 73);
- Size = new Size(160, 80);
- Font = new Font("Segoe UI", 12);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- //-- Colors
- G.FillRectangle(new SolidBrush(_Red), new Rectangle(0, 0, 20, 40));
- G.FillRectangle(new SolidBrush(_Cyan), new Rectangle(20, 0, 20, 40));
- G.FillRectangle(new SolidBrush(_Blue), new Rectangle(40, 0, 20, 40));
- G.FillRectangle(new SolidBrush(_LimeGreen), new Rectangle(60, 0, 20, 40));
- G.FillRectangle(new SolidBrush(_Orange), new Rectangle(80, 0, 20, 40));
- G.FillRectangle(new SolidBrush(_Purple), new Rectangle(100, 0, 20, 40));
- G.FillRectangle(new SolidBrush(_Black), new Rectangle(120, 0, 20, 40));
- G.FillRectangle(new SolidBrush(_Gray), new Rectangle(140, 0, 20, 40));
- G.FillRectangle(new SolidBrush(_White), new Rectangle(160, 0, 20, 40));
- //-- Text
- G.DrawString("Color Palette", Font, new SolidBrush(_White), new Rectangle(0, 22, W, H), CenterSF);
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = (InterpolationMode)7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatGroupBox : ContainerControl
- {
- #region " Variables"
- private int W;
- private int H;
- private Color _FlatColor = Color.FromArgb(35, 168, 109);
- private bool _ShowText = true;
- #endregion
- #region " Properties"
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- public bool ShowText {
- get { return _ShowText; }
- set { _ShowText = value; }
- }
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(60, 70, 73);
- #endregion
- public FlatGroupBox()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
- DoubleBuffered = true;
- BackColor = Color.Transparent;
- Size = new Size(240, 180);
- Font = new Font("Segoe ui", 10);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- GraphicsPath GP = default(GraphicsPath), GP2 = default(GraphicsPath), GP3 = new GraphicsPath();
- Rectangle Base = new Rectangle(8, 8, W - 16, H - 16);
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- //-- Base
- GP = Helpers.RoundRec(Base, 8);
- G.FillPath(new SolidBrush(_BaseColor), GP);
- //-- Arrows
- GP2 = Helpers.DrawArrow(28, 2, false);
- G.FillPath(new SolidBrush(_BaseColor), GP2);
- GP3 = Helpers.DrawArrow(28, 8, true);
- G.FillPath(new SolidBrush(Color.FromArgb(60, 70, 73)), GP3);
- //-- if ShowText
- if (ShowText) {
- G.DrawString(Text, Font, new SolidBrush(_FlatColor), new Rectangle(16, 16, W, H), NearSF);
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = (InterpolationMode)7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatButton : Control
- {
- #region " Variables"
- private int W;
- private int H;
- private bool _Rounded = false;
- private Color _FlatColor = Color.FromArgb(35, 168, 109);
- private MouseState State = MouseState.None;
- #endregion
- #region " Properties"
- #region " Colors"
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- [Category("Colors")]
- public Color TextColor {
- get { return _TextColor; }
- set { _TextColor = value; }
- }
- [Category("Options")]
- public bool Rounded {
- get { return _Rounded; }
- set { _Rounded = value; }
- }
- #endregion
- #region " Mouse States"
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- #endregion
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(35, 168, 109);
- private Color _TextColor = Color.FromArgb(243, 243, 243);
- #endregion
- public FlatButton()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
- DoubleBuffered = true;
- Size = new Size(106, 32);
- BackColor = Color.Transparent;
- Font = new Font("Segoe UI", 12);
- Cursor = Cursors.Hand;
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- GraphicsPath GP = new GraphicsPath();
- Rectangle Base = new Rectangle(0, 0, W, H);
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- switch (State) {
- case MouseState.None:
- if (Rounded) {
- //-- Base
- GP = Helpers.RoundRec(Base, 6);
- G.FillPath(new SolidBrush(_BaseColor), GP);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- } else {
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- }
- break;
- case MouseState.Over:
- if (Rounded) {
- //-- Base
- GP = Helpers.RoundRec(Base, 6);
- G.FillPath(new SolidBrush(_BaseColor), GP);
- G.FillPath(new SolidBrush(Color.FromArgb(20, Color.White)), GP);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- } else {
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- G.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.White)), Base);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- }
- break;
- case MouseState.Down:
- if (Rounded) {
- //-- Base
- GP = Helpers.RoundRec(Base, 6);
- G.FillPath(new SolidBrush(_BaseColor), GP);
- G.FillPath(new SolidBrush(Color.FromArgb(20, Color.Black)), GP);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- } else {
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- G.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.Black)), Base);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- }
- break;
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = (InterpolationMode)7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- [DefaultEvent("CheckedChanged")]
- class FlatToggle : Control
- {
- #region " Variables"
- private int W;
- private int H;
- private _Options O;
- private bool _Checked = false;
- private Color _FlatColor = Color.FromArgb(35, 168, 109);
- private MouseState State = MouseState.None;
- #endregion
- #region " Properties"
- public event CheckedChangedEventHandler CheckedChanged;
- public delegate void CheckedChangedEventHandler(object sender);
- [Flags()]
- public enum _Options
- {
- Style1,
- Style2,
- Style3,
- Style4,
- //-- TODO: New Style
- Style5
- //-- TODO: New Style
- }
- #region " Options"
- [Category("Options")]
- public _Options Options {
- get { return O; }
- set { O = value; }
- }
- [Category("Options")]
- public bool Checked {
- get { return _Checked; }
- set { _Checked = value; }
- }
- #endregion
- protected override void OnTextChanged(EventArgs e)
- {
- base.OnTextChanged(e);
- Invalidate();
- }
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Width = 76;
- Height = 33;
- }
- #region " Mouse States"
- 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 OnClick(EventArgs e)
- {
- base.OnClick(e);
- _Checked = !_Checked;
- if (CheckedChanged != null) {
- CheckedChanged(this);
- }
- }
- #endregion
- #endregion
- #region " Colors"
- private Color BaseColor =Color.FromArgb(35, 168, 109);
- private Color BaseColorRed = Color.FromArgb(220, 85, 96);
- private Color BGColor = Color.FromArgb(84, 85, 86);
- private Color ToggleColor = Color.FromArgb(45, 47, 49);
- private Color TextColor = Color.FromArgb(243, 243, 243);
- #endregion
- public FlatToggle()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
- DoubleBuffered = true;
- BackColor = Color.Transparent;
- Size = new Size(44, Height + 1);
- Cursor = Cursors.Hand;
- Font = new Font("Segoe UI", 10);
- Size = new Size(76, 33);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- GraphicsPath GP = default(GraphicsPath), GP2 = new GraphicsPath();
- Rectangle Base = new Rectangle(0, 0, W, H);
- Rectangle Toggle = new Rectangle(Convert.ToInt32(W / 2), 0, 38, H);
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- switch (O) {
- case _Options.Style1:
- //-- Style 1
- //-- Base
- GP = Helpers.RoundRec(Base, 6);
- GP2 = Helpers.RoundRec(Toggle, 6);
- G.FillPath(new SolidBrush(BGColor), GP);
- G.FillPath(new SolidBrush(ToggleColor), GP2);
- //-- Text
- G.DrawString("OFF", Font, new SolidBrush(BGColor), new Rectangle(19, 1, W, H), CenterSF);
- if (Checked) {
- //-- Base
- GP = Helpers.RoundRec(Base, 6);
- GP2 = Helpers.RoundRec(new Rectangle(Convert.ToInt32(W / 2), 0, 38, H), 6);
- G.FillPath(new SolidBrush(ToggleColor), GP);
- G.FillPath(new SolidBrush(BaseColor), GP2);
- //-- Text
- G.DrawString("ON", Font, new SolidBrush(BaseColor), new Rectangle(8, 7, W, H), NearSF);
- }
- break;
- case _Options.Style2:
- //-- Style 2
- //-- Base
- GP = Helpers.RoundRec(Base, 6);
- Toggle = new Rectangle(4, 4, 36, H - 8);
- GP2 = Helpers.RoundRec(Toggle, 4);
- G.FillPath(new SolidBrush(BaseColorRed), GP);
- G.FillPath(new SolidBrush(ToggleColor), GP2);
- //-- Lines
- G.DrawLine(new Pen(BGColor), 18, 20, 18, 12);
- G.DrawLine(new Pen(BGColor), 22, 20, 22, 12);
- G.DrawLine(new Pen(BGColor), 26, 20, 26, 12);
- //-- Text
- G.DrawString("r", new Font("Marlett", 8), new SolidBrush(TextColor), new Rectangle(19, 2, Width, Height), CenterSF);
- if (Checked) {
- GP = Helpers.RoundRec(Base, 6);
- Toggle = new Rectangle(Convert.ToInt32(W / 2) - 2, 4, 36, H - 8);
- GP2 = Helpers.RoundRec(Toggle, 4);
- G.FillPath(new SolidBrush(BaseColor), GP);
- G.FillPath(new SolidBrush(ToggleColor), GP2);
- //-- Lines
- G.DrawLine(new Pen(BGColor), Convert.ToInt32(W / 2) + 12, 20, Convert.ToInt32(W / 2) + 12, 12);
- G.DrawLine(new Pen(BGColor), Convert.ToInt32(W / 2) + 16, 20, Convert.ToInt32(W / 2) + 16, 12);
- G.DrawLine(new Pen(BGColor), Convert.ToInt32(W / 2) + 20, 20, Convert.ToInt32(W / 2) + 20, 12);
- //-- Text
- G.DrawString("ü", new Font("Wingdings", 14), new SolidBrush(TextColor), new Rectangle(8, 7, Width, Height), NearSF);
- }
- break;
- case _Options.Style3:
- //-- Style 3
- //-- Base
- GP = Helpers.RoundRec(Base, 16);
- Toggle = new Rectangle(W - 28, 4, 22, H - 8);
- GP2.AddEllipse(Toggle);
- G.FillPath(new SolidBrush(ToggleColor), GP);
- G.FillPath(new SolidBrush(BaseColorRed), GP2);
- //-- Text
- G.DrawString("OFF", Font, new SolidBrush(BaseColorRed), new Rectangle(-12, 2, W, H), CenterSF);
- if (Checked) {
- //-- Base
- GP = Helpers.RoundRec(Base, 16);
- Toggle = new Rectangle(6, 4, 22, H - 8);
- GP2.Reset();
- GP2.AddEllipse(Toggle);
- G.FillPath(new SolidBrush(ToggleColor), GP);
- G.FillPath(new SolidBrush(BaseColor), GP2);
- //-- Text
- G.DrawString("ON", Font, new SolidBrush(BaseColor), new Rectangle(12, 2, W, H), CenterSF);
- }
- break;
- case _Options.Style4:
- //-- TODO: New Styles
- if (Checked) {
- //--
- }
- break;
- case _Options.Style5:
- //-- TODO: New Styles
- if (Checked) {
- //--
- }
- break;
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- [DefaultEvent("CheckedChanged")]
- class RadioButton : Control
- {
- #region " Variables"
- private MouseState State = MouseState.None;
- private int W;
- private int H;
- private _Options O;
- private bool _Checked;
- #endregion
- #region " Properties"
- public bool Checked {
- get { return _Checked; }
- set {
- _Checked = value;
- InvalidateControls();
- if (CheckedChanged != null) {
- CheckedChanged(this);
- }
- Invalidate();
- }
- }
- public event CheckedChangedEventHandler CheckedChanged;
- public delegate void CheckedChangedEventHandler(object sender);
- protected override void OnClick(EventArgs e)
- {
- if (!_Checked)
- Checked = true;
- base.OnClick(e);
- }
- private void InvalidateControls()
- {
- if (!IsHandleCreated || !_Checked)
- return;
- foreach (Control C in Parent.Controls) {
- if (!object.ReferenceEquals(C, this) && C is RadioButton) {
- ((RadioButton)C).Checked = false;
- Invalidate();
- }
- }
- }
- protected override void OnCreateControl()
- {
- base.OnCreateControl();
- InvalidateControls();
- }
- [Flags()]
- public enum _Options
- {
- Style1,
- Style2
- }
- [Category("Options")]
- public _Options Options {
- get { return O; }
- set { O = value; }
- }
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Height = 22;
- }
- #region " Mouse States"
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- #endregion
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(45, 47, 49);
- private Color _BorderColor = _FlatColor;
- private Color _TextColor = Color.FromArgb(243, 243, 243);
- #endregion
- public RadioButton()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- Cursor = Cursors.Hand;
- Size = new Size(100, 22);
- BackColor = Color.FromArgb(60, 70, 73);
- Font = new Font("Segoe UI", 10);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- Rectangle Base = new Rectangle(0, 2, Height - 5, Height - 5);
- Rectangle Dot = new Rectangle(4, 6, H - 12, H - 12);
- {
- G.SmoothingMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- switch (O) {
- case _Options.Style1:
- //-- Base
- G.FillEllipse(new SolidBrush(_BaseColor), Base);
- switch (State) {
- case MouseState.Over:
- G.DrawEllipse(new Pen(_BorderColor), Base);
- break;
- case MouseState.Down:
- G.DrawEllipse(new Pen(_BorderColor), Base);
- break;
- }
- //-- If Checked
- if (Checked) {
- G.FillEllipse(new SolidBrush(_BorderColor), Dot);
- }
- break;
- case _Options.Style2:
- //-- Base
- G.FillEllipse(new SolidBrush(_BaseColor), Base);
- switch (State) {
- case MouseState.Over:
- //-- Base
- G.DrawEllipse(new Pen(_BorderColor), Base);
- G.FillEllipse(new SolidBrush(Color.FromArgb(118, 213, 170)), Base);
- break;
- case MouseState.Down:
- //-- Base
- G.DrawEllipse(new Pen(_BorderColor), Base);
- G.FillEllipse(new SolidBrush(Color.FromArgb(118, 213, 170)), Base);
- break;
- }
- //-- If Checked
- if (Checked) {
- //-- Base
- G.FillEllipse(new SolidBrush(_BorderColor), Dot);
- }
- break;
- }
- G.DrawString(Text, Font, new SolidBrush(_TextColor), new Rectangle(20, 2, W, H), NearSF);
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- [DefaultEvent("CheckedChanged")]
- class FlatCheckBox : Control
- {
- #region " Variables"
- private int W;
- private int H;
- private MouseState State = MouseState.None;
- private _Options O;
- private bool _Checked;
- #endregion
- #region " Properties"
- protected override void OnTextChanged(System.EventArgs e)
- {
- base.OnTextChanged(e);
- Invalidate();
- }
- public bool Checked {
- get { return _Checked; }
- set {
- _Checked = value;
- Invalidate();
- }
- }
- public event CheckedChangedEventHandler CheckedChanged;
- public delegate void CheckedChangedEventHandler(object sender);
- protected override void OnClick(System.EventArgs e)
- {
- _Checked = !_Checked;
- if (CheckedChanged != null) {
- CheckedChanged(this);
- }
- base.OnClick(e);
- }
- [Flags()]
- public enum _Options
- {
- Style1,
- Style2
- }
- [Category("Options")]
- public _Options Options {
- get { return O; }
- set { O = value; }
- }
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Height = 22;
- }
- #region " Colors"
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- [Category("Colors")]
- public Color BorderColor {
- get { return _BorderColor; }
- set { _BorderColor = value; }
- }
- #endregion
- #region " Mouse States"
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- #endregion
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(45, 47, 49);
- private Color _BorderColor = _FlatColor;
- private Color _TextColor = Color.FromArgb(243, 243, 243);
- #endregion
- public FlatCheckBox()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- BackColor = Color.FromArgb(60, 70, 73);
- Cursor = Cursors.Hand;
- Font = new Font("Segoe UI", 10);
- Size = new Size(112, 22);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- Rectangle Base = new Rectangle(0, 2, Height - 5, Height - 5);
- {
- G.SmoothingMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- switch (O) {
- case _Options.Style1:
- //-- Style 1
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- switch (State) {
- case MouseState.Over:
- //-- Base
- G.DrawRectangle(new Pen(_BorderColor), Base);
- break;
- case MouseState.Down:
- //-- Base
- G.DrawRectangle(new Pen(_BorderColor), Base);
- break;
- }
- //-- If Checked
- if (Checked) {
- G.DrawString("ü", new Font("Wingdings", 18), new SolidBrush(_BorderColor), new Rectangle(5, 7, H - 9, H - 9), CenterSF);
- }
- //-- If Enabled
- if (this.Enabled == false) {
- G.FillRectangle(new SolidBrush(Color.FromArgb(54, 58, 61)), Base);
- G.DrawString(Text, Font, new SolidBrush(Color.FromArgb(140, 142, 143)), new Rectangle(20, 2, W, H), NearSF);
- }
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), new Rectangle(20, 2, W, H), NearSF);
- break;
- case _Options.Style2:
- //-- Style 2
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- switch (State) {
- case MouseState.Over:
- //-- Base
- G.DrawRectangle(new Pen(_BorderColor), Base);
- G.FillRectangle(new SolidBrush(Color.FromArgb(118, 213, 170)), Base);
- break;
- case MouseState.Down:
- //-- Base
- G.DrawRectangle(new Pen(_BorderColor), Base);
- G.FillRectangle(new SolidBrush(Color.FromArgb(118, 213, 170)), Base);
- break;
- }
- //-- If Checked
- if (Checked) {
- G.DrawString("ü", new Font("Wingdings", 18), new SolidBrush(_BorderColor), new Rectangle(5, 7, H - 9, H - 9), CenterSF);
- }
- //-- If Enabled
- if (this.Enabled == false) {
- G.FillRectangle(new SolidBrush(Color.FromArgb(54, 58, 61)), Base);
- G.DrawString(Text, Font, new SolidBrush(Color.FromArgb(48, 119, 91)), new Rectangle(20, 2, W, H), NearSF);
- }
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), new Rectangle(20, 2, W, H), NearSF);
- break;
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- [DefaultEvent("TextChanged")]
- class FlatTextBox : Control
- {
- #region " Variables"
- private int W;
- private int H;
- private MouseState State = MouseState.None;
- private System.Windows.Forms.TextBox TB;
- #endregion
- #region " Properties"
- #region " TextBox Properties"
- private HorizontalAlignment _TextAlign = HorizontalAlignment.Left;
- [Category("Options")]
- public HorizontalAlignment TextAlign {
- get { return _TextAlign; }
- set {
- _TextAlign = value;
- if (TB != null) {
- TB.TextAlign = value;
- }
- }
- }
- private int _MaxLength = 32767;
- [Category("Options")]
- public int MaxLength {
- get { return _MaxLength; }
- set {
- _MaxLength = value;
- if (TB != null) {
- TB.MaxLength = value;
- }
- }
- }
- private bool _ReadOnly;
- [Category("Options")]
- public bool ReadOnly {
- get { return _ReadOnly; }
- set {
- _ReadOnly = value;
- if (TB != null) {
- TB.ReadOnly = value;
- }
- }
- }
- private bool _UseSystemPasswordChar;
- [Category("Options")]
- public bool UseSystemPasswordChar {
- get { return _UseSystemPasswordChar; }
- set {
- _UseSystemPasswordChar = value;
- if (TB != null) {
- TB.UseSystemPasswordChar = value;
- }
- }
- }
- private bool _Multiline;
- [Category("Options")]
- public bool Multiline {
- get { return _Multiline; }
- set {
- _Multiline = value;
- if (TB != null) {
- TB.Multiline = value;
- if (value) {
- TB.Height = Height - 11;
- } else {
- Height = TB.Height + 11;
- }
- }
- }
- }
- [Category("Options")]
- public override string Text {
- get { return base.Text; }
- set {
- base.Text = value;
- if (TB != null) {
- TB.Text = value;
- }
- }
- }
- [Category("Options")]
- public override Font Font {
- get { return base.Font; }
- set {
- base.Font = value;
- if (TB != null) {
- TB.Font = value;
- TB.Location = new Point(3, 5);
- TB.Width = Width - 6;
- if (!_Multiline) {
- Height = TB.Height + 11;
- }
- }
- }
- }
- protected override void OnCreateControl()
- {
- base.OnCreateControl();
- if (!Controls.Contains(TB)) {
- Controls.Add(TB);
- }
- }
- private void OnBaseTextChanged(object s, EventArgs e)
- {
- Text = TB.Text;
- }
- private void OnBaseKeyDown(object s, KeyEventArgs e)
- {
- if (e.Control && e.KeyCode == Keys.A) {
- TB.SelectAll();
- e.SuppressKeyPress = true;
- }
- if (e.Control && e.KeyCode == Keys.C) {
- TB.Copy();
- e.SuppressKeyPress = true;
- }
- }
- protected override void OnResize(EventArgs e)
- {
- TB.Location = new Point(5, 5);
- TB.Width = Width - 10;
- if (_Multiline) {
- TB.Height = Height - 11;
- } else {
- Height = TB.Height + 11;
- }
- base.OnResize(e);
- }
- #endregion
- #region " Colors"
- [Category("Colors")]
- public Color TextColor {
- get { return _TextColor; }
- set { _TextColor = value; }
- }
- public override Color ForeColor {
- get { return _TextColor; }
- set { _TextColor = value; }
- }
- #endregion
- #region " Mouse States"
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- TB.Focus();
- Invalidate();
- }
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- TB.Focus();
- Invalidate();
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- #endregion
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(45, 47, 49);
- private Color _TextColor = Color.FromArgb(192, 192, 192);
- private Color _BorderColor = _FlatColor;
- #endregion
- public FlatTextBox()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
- DoubleBuffered = true;
- BackColor = Color.Transparent;
- TB = new Windows.Forms.TextBox();
- TB.Font = new Font("Segoe UI", 10);
- TB.Text = Text;
- TB.BackColor = _BaseColor;
- TB.ForeColor = _TextColor;
- TB.MaxLength = _MaxLength;
- TB.Multiline = _Multiline;
- TB.ReadOnly = _ReadOnly;
- TB.UseSystemPasswordChar = _UseSystemPasswordChar;
- TB.BorderStyle = BorderStyle.None;
- TB.Location = new Point(5, 5);
- TB.Width = Width - 10;
- TB.Cursor = Cursors.IBeam;
- if (_Multiline) {
- TB.Height = Height - 11;
- } else {
- Height = TB.Height + 11;
- }
- TB.TextChanged += OnBaseTextChanged;
- TB.KeyDown += OnBaseKeyDown;
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- Rectangle Base = new Rectangle(0, 0, W, H);
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- //-- Colors
- TB.BackColor = _BaseColor;
- TB.ForeColor = _TextColor;
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatTabControl : TabControl
- {
- #region " Variables"
- private int W;
- private int H;
- #endregion
- #region " Properties"
- protected override void CreateHandle()
- {
- base.CreateHandle();
- Alignment = TabAlignment.Top;
- }
- #region " Colors"
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- [Category("Colors")]
- public Color ActiveColor {
- get { return _ActiveColor; }
- set { _ActiveColor = value; }
- }
- #endregion
- #endregion
- #region " Colors"
- private Color BGColor = Color.FromArgb(60, 70, 73);
- private Color _BaseColor = Color.FromArgb(45, 47, 49);
- private Color _ActiveColor = _FlatColor;
- #endregion
- public FlatTabControl()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- BackColor = Color.FromArgb(60, 70, 73);
- Font = new Font("Segoe UI", 10);
- SizeMode = TabSizeMode.Fixed;
- ItemSize = new Size(120, 40);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(_BaseColor);
- try {
- SelectedTab.BackColor = BGColor;
- } catch {
- }
- for (i = 0; i <= TabCount - 1; i++) {
- Rectangle Base = new Rectangle(new Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y), new Size(GetTabRect(i).Width, GetTabRect(i).Height));
- Rectangle BaseSize = new Rectangle(Base.Location, new Size(Base.Width, Base.Height));
- if (i == SelectedIndex) {
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), BaseSize);
- //-- Gradiant
- //.fill
- G.FillRectangle(new SolidBrush(_ActiveColor), BaseSize);
- //-- ImageList
- if (ImageList != null) {
- try {
- if (ImageList.Images(TabPages(i).ImageIndex) != null) {
- //-- Image
- G.DrawImage(ImageList.Images(TabPages(i).ImageIndex), new Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6));
- //-- Text
- G.DrawString(" " + TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF);
- } else {
- //-- Text
- G.DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF);
- }
- } catch (Exception ex) {
- throw new Exception(ex.Message);
- }
- } else {
- //-- Text
- G.DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF);
- }
- } else {
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), BaseSize);
- //-- ImageList
- if (ImageList != null) {
- try {
- if (ImageList.Images(TabPages(i).ImageIndex) != null) {
- //-- Image
- G.DrawImage(ImageList.Images(TabPages(i).ImageIndex), new Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6));
- //-- Text
- G.DrawString(" " + TabPages(i).Text, Font, new SolidBrush(Color.White), BaseSize, new StringFormat {
- LineAlignment = StringAlignment.Center,
- Alignment = StringAlignment.Center
- });
- } else {
- //-- Text
- G.DrawString(TabPages(i).Text, Font, new SolidBrush(Color.White), BaseSize, new StringFormat {
- LineAlignment = StringAlignment.Center,
- Alignment = StringAlignment.Center
- });
- }
- } catch (Exception ex) {
- throw new Exception(ex.Message);
- }
- } else {
- //-- Text
- G.DrawString(TabPages(i).Text, Font, new SolidBrush(Color.White), BaseSize, new StringFormat {
- LineAlignment = StringAlignment.Center,
- Alignment = StringAlignment.Center
- });
- }
- }
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatAlertBox : Control
- {
- /// <summary>
- /// How to use: FlatAlertBox.ShowControl(Kind, String, Interval)
- /// </summary>
- /// <remarks></remarks>
- #region " Variables"
- private int W;
- private int H;
- private _Kind K;
- private string _Text;
- private MouseState State = MouseState.None;
- private int X;
- private Timer T;
- #endregion
- #region " Properties"
- [Flags()]
- public enum _Kind
- {
- Success,
- Error,
- Info
- }
- #region " Options"
- [Category("Options")]
- public _Kind kind {
- get { return K; }
- set { K = value; }
- }
- [Category("Options")]
- public override string Text {
- get { return base.Text; }
- set {
- base.Text = value;
- if (_Text != null) {
- _Text = value;
- }
- }
- }
- [Category("Options")]
- public new bool Visible {
- get { return base.Visible == false; }
- set { base.Visible = value; }
- }
- #endregion
- protected override void OnTextChanged(EventArgs e)
- {
- base.OnTextChanged(e);
- Invalidate();
- }
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Height = 42;
- }
- public void ShowControl(_Kind Kind, string Str, int Interval)
- {
- K = Kind;
- Text = Str;
- this.Visible = true;
- T = new Timer();
- T.Interval = Interval;
- T.Enabled = true;
- }
- private void // ERROR: Handles clauses are not supported in C#
- T_Tick(object sender, EventArgs e)
- {
- this.Visible = false;
- T.Enabled = false;
- T.Dispose();
- }
- #region " Mouse States"
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- X = e.X;
- Invalidate();
- }
- protected override void OnClick(EventArgs e)
- {
- base.OnClick(e);
- this.Visible = false;
- }
- #endregion
- #endregion
- #region " Colors"
- private Color SuccessColor = Color.FromArgb(60, 85, 79);
- private Color SuccessText = Color.FromArgb(35, 169, 110);
- private Color ErrorColor = Color.FromArgb(87, 71, 71);
- private Color ErrorText = Color.FromArgb(254, 142, 122);
- private Color InfoColor = Color.FromArgb(70, 91, 94);
- private Color InfoText = Color.FromArgb(97, 185, 186);
- #endregion
- public FlatAlertBox()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- BackColor = Color.FromArgb(60, 70, 73);
- Size = new Size(576, 42);
- Location = new Point(10, 61);
- Font = new Font("Segoe UI", 10);
- Cursor = Cursors.Hand;
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- Rectangle Base = new Rectangle(0, 0, W, H);
- {
- G.SmoothingMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- switch (K) {
- case _Kind.Success:
- //-- Base
- G.FillRectangle(new SolidBrush(SuccessColor), Base);
- //-- Ellipse
- G.FillEllipse(new SolidBrush(SuccessText), new Rectangle(8, 9, 24, 24));
- G.FillEllipse(new SolidBrush(SuccessColor), new Rectangle(10, 11, 20, 20));
- //-- Checked Sign
- G.DrawString("ü", new Font("Wingdings", 22), new SolidBrush(SuccessText), new Rectangle(7, 7, W, H), NearSF);
- G.DrawString(Text, Font, new SolidBrush(SuccessText), new Rectangle(48, 12, W, H), NearSF);
- //-- X button
- G.FillEllipse(new SolidBrush(Color.FromArgb(35, Color.Black)), new Rectangle(W - 30, H - 29, 17, 17));
- G.DrawString("r", new Font("Marlett", 8), new SolidBrush(SuccessColor), new Rectangle(W - 28, 16, W, H), NearSF);
- switch (State) {
- // -- Mouse Over
- case MouseState.Over:
- G.DrawString("r", new Font("Marlett", 8), new SolidBrush(Color.FromArgb(25, Color.White)), new Rectangle(W - 28, 16, W, H), NearSF);
- break;
- }
- break;
- case _Kind.Error:
- //-- Base
- G.FillRectangle(new SolidBrush(ErrorColor), Base);
- //-- Ellipse
- G.FillEllipse(new SolidBrush(ErrorText), new Rectangle(8, 9, 24, 24));
- G.FillEllipse(new SolidBrush(ErrorColor), new Rectangle(10, 11, 20, 20));
- //-- X Sign
- G.DrawString("r", new Font("Marlett", 16), new SolidBrush(ErrorText), new Rectangle(6, 11, W, H), NearSF);
- G.DrawString(Text, Font, new SolidBrush(ErrorText), new Rectangle(48, 12, W, H), NearSF);
- //-- X button
- G.FillEllipse(new SolidBrush(Color.FromArgb(35, Color.Black)), new Rectangle(W - 32, H - 29, 17, 17));
- G.DrawString("r", new Font("Marlett", 8), new SolidBrush(ErrorColor), new Rectangle(W - 30, 17, W, H), NearSF);
- switch (State) {
- case MouseState.Over:
- // -- Mouse Over
- G.DrawString("r", new Font("Marlett", 8), new SolidBrush(Color.FromArgb(25, Color.White)), new Rectangle(W - 30, 15, W, H), NearSF);
- break;
- }
- break;
- case _Kind.Info:
- //-- Base
- G.FillRectangle(new SolidBrush(InfoColor), Base);
- //-- Ellipse
- G.FillEllipse(new SolidBrush(InfoText), new Rectangle(8, 9, 24, 24));
- G.FillEllipse(new SolidBrush(InfoColor), new Rectangle(10, 11, 20, 20));
- //-- Info Sign
- G.DrawString("¡", new Font("Segoe UI", 20, FontStyle.Bold), new SolidBrush(InfoText), new Rectangle(12, -4, W, H), NearSF);
- G.DrawString(Text, Font, new SolidBrush(InfoText), new Rectangle(48, 12, W, H), NearSF);
- //-- X button
- G.FillEllipse(new SolidBrush(Color.FromArgb(35, Color.Black)), new Rectangle(W - 32, H - 29, 17, 17));
- G.DrawString("r", new Font("Marlett", 8), new SolidBrush(InfoColor), new Rectangle(W - 30, 17, W, H), NearSF);
- switch (State) {
- case MouseState.Over:
- // -- Mouse Over
- G.DrawString("r", new Font("Marlett", 8), new SolidBrush(Color.FromArgb(25, Color.White)), new Rectangle(W - 30, 17, W, H), NearSF);
- break;
- }
- break;
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatProgressBar : Control
- {
- #region " Variables"
- private int W;
- private int H;
- private int _Value = 0;
- private int _Maximum = 100;
- #endregion
- #region " Properties"
- #region " Control"
- [Category("Control")]
- public int Maximum {
- get { return _Maximum; }
- set {
- switch (value) {
- case // ERROR: Case labels with binary operators are unsupported : LessThan
- _Value:
- _Value = value;
- break;
- }
- _Maximum = value;
- Invalidate();
- }
- }
- [Category("Control")]
- public int Value {
- get {
- switch (_Value) {
- case 0:
- return 0;
- Invalidate();
- break;
- default:
- return _Value;
- Invalidate();
- break;
- }
- }
- set {
- switch (value) {
- case // ERROR: Case labels with binary operators are unsupported : GreaterThan
- _Maximum:
- value = _Maximum;
- Invalidate();
- break;
- }
- _Value = value;
- Invalidate();
- }
- }
- #endregion
- #region " Colors"
- [Category("Colors")]
- public Color ProgressColor {
- get { return _ProgressColor; }
- set { _ProgressColor = value; }
- }
- [Category("Colors")]
- public Color DarkerProgress {
- get { return _DarkerProgress; }
- set { _DarkerProgress = value; }
- }
- #endregion
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Height = 42;
- }
- protected override void CreateHandle()
- {
- base.CreateHandle();
- Height = 42;
- }
- public void Increment(int Amount)
- {
- Value += Amount;
- }
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(45, 47, 49);
- private Color _ProgressColor = _FlatColor;
- private Color _DarkerProgress = Color.FromArgb(23, 148, 92);
- #endregion
- public FlatProgressBar()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- BackColor = Color.FromArgb(60, 70, 73);
- Height = 42;
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- Rectangle Base = new Rectangle(0, 24, W, H);
- GraphicsPath GP = default(GraphicsPath), GP2 = default(GraphicsPath), GP3 = new GraphicsPath();
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- //-- Progress Value
- int iValue = Convert.ToInt32(_Value / _Maximum * Width);
- switch (Value) {
- case 0:
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- //--Progress
- G.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(0, 24, iValue - 1, H - 1));
- break;
- case 100:
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- //--Progress
- G.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(0, 24, iValue - 1, H - 1));
- break;
- default:
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- //--Progress
- GP.AddRectangle(new Rectangle(0, 24, iValue - 1, H - 1));
- G.FillPath(new SolidBrush(_ProgressColor), GP);
- //-- Hatch Brush
- HatchBrush HB = new HatchBrush(HatchStyle.Plaid, _DarkerProgress, _ProgressColor);
- G.FillRectangle(HB, new Rectangle(0, 24, iValue - 1, H - 1));
- //-- Balloon
- Rectangle Balloon = new Rectangle(iValue - 18, 0, 34, 16);
- GP2 = Helpers.RoundRec(Balloon, 4);
- G.FillPath(new SolidBrush(_BaseColor), GP2);
- //-- Arrow
- GP3 = Helpers.DrawArrow(iValue - 9, 16, true);
- G.FillPath(new SolidBrush(_BaseColor), GP3);
- //-- Value > You can add "%" > value & "%"
- G.DrawString(Value, new Font("Segoe UI", 10), new SolidBrush(_ProgressColor), new Rectangle(iValue - 11, -2, W, H), NearSF);
- break;
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatComboBox : System.Windows.Forms.ComboBox
- {
- #region " Variables"
- private int W;
- private int H;
- private int _StartIndex = 0;
- private int x;
- private int y;
- #endregion
- #region " Properties"
- #region " Mouse States"
- private MouseState State = MouseState.None;
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- x = e.Location.X;
- y = e.Location.Y;
- Invalidate();
- if (e.X < Width - 41)
- Cursor = Cursors.IBeam;
- else
- Cursor = Cursors.Hand;
- }
- protected override void OnDrawItem(DrawItemEventArgs e)
- {
- base.OnDrawItem(e);
- Invalidate();
- if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
- Invalidate();
- }
- }
- protected override void OnClick(EventArgs e)
- {
- base.OnClick(e);
- Invalidate();
- }
- #endregion
- #region " Colors"
- [Category("Colors")]
- public Color HoverColor {
- get { return _HoverColor; }
- set { _HoverColor = value; }
- }
- #endregion
- private int StartIndex {
- get { return _StartIndex; }
- set {
- _StartIndex = value;
- try {
- base.SelectedIndex = value;
- } catch {
- }
- Invalidate();
- }
- }
- public void // ERROR: Handles clauses are not supported in C#
- DrawItem_(System.Object sender, System.Windows.Forms.DrawItemEventArgs e)
- {
- if (e.Index < 0)
- return;
- e.DrawBackground();
- e.DrawFocusRectangle();
- e.Graphics.SmoothingMode = 2;
- e.Graphics.PixelOffsetMode = 2;
- e.Graphics.TextRenderingHint = 5;
- e.Graphics.InterpolationMode = 7;
- if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
- //-- Selected item
- e.Graphics.FillRectangle(new SolidBrush(_HoverColor), e.Bounds);
- } else {
- //-- Not Selected
- e.Graphics.FillRectangle(new SolidBrush(_BaseColor), e.Bounds);
- }
- //-- Text
- e.Graphics.DrawString(base.GetItemText(base.Items(e.Index)), new Font("Segoe UI", 8), Brushes.White, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height));
- e.Graphics.Dispose();
- }
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Height = 18;
- }
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(25, 27, 29);
- private Color _BGColor = Color.FromArgb(45, 47, 49);
- private Color _HoverColor = Color.FromArgb(35, 168, 109);
- #endregion
- public FlatComboBox()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- DrawMode = DrawMode.OwnerDrawFixed;
- BackColor = Color.FromArgb(45, 45, 48);
- ForeColor = Color.White;
- DropDownStyle = ComboBoxStyle.DropDownList;
- Cursor = Cursors.Hand;
- StartIndex = 0;
- ItemHeight = 18;
- Font = new Font("Segoe UI", 8, FontStyle.Regular);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width;
- H = Height;
- Rectangle Base = new Rectangle(0, 0, W, H);
- Rectangle Button = new Rectangle(Convert.ToInt32(W - 40), 0, W, H);
- GraphicsPath GP = default(GraphicsPath), GP2 = new GraphicsPath();
- {
- G.Clear(Color.FromArgb(45, 45, 48));
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- //-- Base
- G.FillRectangle(new SolidBrush(_BGColor), Base);
- //-- Button
- GP.Reset();
- GP.AddRectangle(Button);
- G.SetClip(GP);
- G.FillRectangle(new SolidBrush(_BaseColor), Button);
- G.ResetClip();
- //-- Lines
- G.DrawLine(Pens.White, W - 10, 6, W - 30, 6);
- G.DrawLine(Pens.White, W - 10, 12, W - 30, 12);
- G.DrawLine(Pens.White, W - 10, 18, W - 30, 18);
- //-- Text
- G.DrawString(Text, Font, Brushes.White, new Point(4, 6), NearSF);
- }
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatStickyButton : Control
- {
- #region " Variables"
- private int W;
- private int H;
- private MouseState State = MouseState.None;
- private bool _Rounded = false;
- #endregion
- #region " Properties"
- #region " MouseStates"
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- State = MouseState.Down;
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- State = MouseState.Over;
- Invalidate();
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- State = MouseState.None;
- Invalidate();
- }
- #endregion
- #region " Function"
- private bool[] GetConnectedSides()
- {
- object Bool = new bool[4] {
- false,
- false,
- false,
- false
- };
- foreach (Control B in Parent.Controls) {
- if (B is FlatStickyButton) {
- if (object.ReferenceEquals(B, this) | !Rect.IntersectsWith(Rect))
- continue;
- object A = Math.Atan2(Strings.Left() - B.Left, Top - B.Top) * 2 / Math.PI;
- if (A / 1 == A)
- Bool(A + 1) = true;
- }
- }
- return Bool;
- }
- private Rectangle Rect {
- get { return new Rectangle(Left, Top, Width, Height); }
- }
- #endregion
- #region " Colors"
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- [Category("Colors")]
- public Color TextColor {
- get { return _TextColor; }
- set { _TextColor = value; }
- }
- [Category("Options")]
- public bool Rounded {
- get { return _Rounded; }
- set { _Rounded = value; }
- }
- #endregion
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- //Height = 32
- }
- protected override void OnCreateControl()
- {
- base.OnCreateControl();
- //Size = New Size(112, 32)
- }
- #endregion
- #region " Colors"
- private Color _BaseColor = _FlatColor;
- private Color _TextColor = Color.FromArgb(243, 243, 243);
- #endregion
- public FlatStickyButton()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
- DoubleBuffered = true;
- Size = new Size(106, 32);
- BackColor = Color.Transparent;
- Font = new Font("Segoe UI", 12);
- Cursor = Cursors.Hand;
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width;
- H = Height;
- GraphicsPath GP = new GraphicsPath();
- object GCS = GetConnectedSides();
- object RoundedBase = Helpers.RoundRect(0, 0, W, H, 0.3, !(GCS(2) | GCS(1)), !(GCS(1) | GCS(0)), !(GCS(3) | GCS(0)), !(GCS(3) | GCS(2)));
- Rectangle Base = new Rectangle(0, 0, W, H);
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- switch (State) {
- case MouseState.None:
- if (Rounded) {
- //-- Base
- GP = RoundedBase;
- G.FillPath(new SolidBrush(_BaseColor), GP);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- } else {
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- }
- break;
- case MouseState.Over:
- if (Rounded) {
- //-- Base
- GP = RoundedBase;
- G.FillPath(new SolidBrush(_BaseColor), GP);
- G.FillPath(new SolidBrush(Color.FromArgb(20, Color.White)), GP);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- } else {
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- G.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.White)), Base);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- }
- break;
- case MouseState.Down:
- if (Rounded) {
- //-- Base
- GP = RoundedBase;
- G.FillPath(new SolidBrush(_BaseColor), GP);
- G.FillPath(new SolidBrush(Color.FromArgb(20, Color.Black)), GP);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- } else {
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- G.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.Black)), Base);
- //-- Text
- G.DrawString(Text, Font, new SolidBrush(_TextColor), Base, CenterSF);
- }
- break;
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatNumeric : Control
- {
- #region " Variables"
- private int W;
- private int H;
- private MouseState State = MouseState.None;
- private int x;
- private int y;
- private long _Value;
- private long _Min;
- private long _Max;
- private bool Bool;
- #endregion
- #region " Properties"
- public long Value {
- get { return _Value; }
- set {
- if (value <= _Max & value >= _Min)
- _Value = value;
- Invalidate();
- }
- }
- public long Maximum {
- get { return _Max; }
- set {
- if (value > _Min)
- _Max = value;
- if (_Value > _Max)
- _Value = _Max;
- Invalidate();
- }
- }
- public long Minimum {
- get { return _Min; }
- set {
- if (value < _Max)
- _Min = value;
- if (_Value < _Min)
- _Value = Minimum;
- Invalidate();
- }
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- x = e.Location.X;
- y = e.Location.Y;
- Invalidate();
- if (e.X < Width - 23)
- Cursor = Cursors.IBeam;
- else
- Cursor = Cursors.Hand;
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- if (x > Width - 21 && x < Width - 3) {
- if (y < 15) {
- if ((Value + 1) <= _Max)
- _Value += 1;
- } else {
- if ((Value - 1) >= _Min)
- _Value -= 1;
- }
- } else {
- Bool = !Bool;
- Focus();
- }
- Invalidate();
- }
- protected override void OnKeyPress(KeyPressEventArgs e)
- {
- base.OnKeyPress(e);
- try {
- if (Bool)
- _Value = Convert.ToString(Convert.ToString(_Value) + e.KeyChar.ToString());
- if (_Value > _Max)
- _Value = _Max;
- Invalidate();
- } catch {
- }
- }
- protected override void OnKeyDown(KeyEventArgs e)
- {
- base.OnKeyDown(e);
- if (e.KeyCode == Keys.Back) {
- Value = 0;
- }
- }
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Height = 30;
- }
- #region " Colors"
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- [Category("Colors")]
- public Color ButtonColor {
- get { return _ButtonColor; }
- set { _ButtonColor = value; }
- }
- #endregion
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(45, 47, 49);
- private Color _ButtonColor = _FlatColor;
- #endregion
- public FlatNumeric()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
- DoubleBuffered = true;
- Font = new Font("Segoe UI", 10);
- BackColor = Color.FromArgb(60, 70, 73);
- ForeColor = Color.White;
- _Min = 0;
- _Max = 9999999;
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width;
- H = Height;
- Rectangle Base = new Rectangle(0, 0, W, H);
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- //-- Base
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- G.FillRectangle(new SolidBrush(_ButtonColor), new Rectangle(Width - 24, 0, 24, H));
- //-- Add
- G.DrawString("+", new Font("Segoe UI", 12), Brushes.White, new Point(Width - 12, 8), CenterSF);
- //-- Subtract
- G.DrawString("-", new Font("Segoe UI", 10, FontStyle.Bold), Brushes.White, new Point(Width - 12, 22), CenterSF);
- //-- Text
- G.DrawString(Value, Font, Brushes.White, new Rectangle(5, 1, W, H), new StringFormat { LineAlignment = StringAlignment.Center });
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatListBox : Control
- {
- #region " Variables"
- private ListBox ListBx = new ListBox();
- private string[] _items = { "" };
- #endregion
- #region " Poperties"
- [Category("Options")]
- public string[] items {
- get { return _items; }
- set {
- _items = value;
- ListBx.Items.Clear();
- ListBx.Items.AddRange(value);
- Invalidate();
- }
- }
- [Category("Colors")]
- public Color SelectedColor {
- get { return _SelectedColor; }
- set { _SelectedColor = value; }
- }
- public string SelectedItem {
- get { return ListBx.SelectedItem; }
- }
- public int SelectedIndex {
- get {
- return ListBx.SelectedIndex;
- if (ListBx.SelectedIndex < 0)
- return;
- }
- }
- public void Clear()
- {
- ListBx.Items.Clear();
- }
- public void ClearSelected()
- {
- for (int i = (ListBx.SelectedItems.Count - 1); i >= 0; i += -1) {
- ListBx.Items.Remove(ListBx.SelectedItems(i));
- }
- }
- public void // ERROR: Handles clauses are not supported in C#
- Drawitem(object sender, DrawItemEventArgs e)
- {
- if (e.Index < 0)
- return;
- e.DrawBackground();
- e.DrawFocusRectangle();
- e.Graphics.SmoothingMode = 2;
- e.Graphics.PixelOffsetMode = 2;
- e.Graphics.InterpolationMode = 7;
- e.Graphics.TextRenderingHint = 5;
- //-- if selected
- if (Strings.InStr(e.State.ToString, "Selected,") > 0) {
- //-- Base
- e.Graphics.FillRectangle(new SolidBrush(_SelectedColor), new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
- //-- Text
- e.Graphics.DrawString(" " + ListBx.Items(e.Index).ToString(), new Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2);
- } else {
- //-- Base
- e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(51, 53, 55)), new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
- //-- Text
- e.Graphics.DrawString(" " + ListBx.Items(e.Index).ToString(), new Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2);
- }
- e.Graphics.Dispose();
- }
- protected override void OnCreateControl()
- {
- base.OnCreateControl();
- if (!Controls.Contains(ListBx)) {
- Controls.Add(ListBx);
- }
- }
- public void AddRange(object[] items)
- {
- ListBx.Items.Remove("");
- ListBx.Items.AddRange(items);
- }
- public void AddItem(object item)
- {
- ListBx.Items.Remove("");
- ListBx.Items.Add(item);
- }
- #endregion
- #region " Colors"
- private Color BaseColor = Color.FromArgb(45, 47, 49);
- private Color _SelectedColor = _FlatColor;
- #endregion
- public FlatListBox()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- ListBx.DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed;
- ListBx.ScrollAlwaysVisible = false;
- ListBx.HorizontalScrollbar = false;
- ListBx.BorderStyle = BorderStyle.None;
- ListBx.BackColor = BaseColor;
- ListBx.ForeColor = Color.White;
- ListBx.Location = new Point(3, 3);
- ListBx.Font = new Font("Segoe UI", 8);
- ListBx.ItemHeight = 20;
- ListBx.Items.Clear();
- ListBx.IntegralHeight = false;
- Size = new Size(131, 101);
- BackColor = BaseColor;
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- Rectangle Base = new Rectangle(0, 0, Width, Height);
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- //-- Size
- ListBx.Size = new Size(Width - 6, Height - 2);
- //-- Base
- G.FillRectangle(new SolidBrush(BaseColor), Base);
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatContextMenuStrip : ContextMenuStrip
- {
- protected override void OnTextChanged(EventArgs e)
- {
- base.OnTextChanged(e);
- Invalidate();
- }
- public FlatContextMenuStrip() : base()
- {
- Renderer = new ToolStripProfessionalRenderer(new TColorTable());
- ShowImageMargin = false;
- ForeColor = Color.White;
- Font = new Font("Segoe UI", 8);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- base.OnPaint(e);
- e.Graphics.TextRenderingHint = 5;
- }
- public class TColorTable : ProfessionalColorTable
- {
- #region " Properties"
- #region " Colors"
- [Category("Colors")]
- public Color _BackColor {
- get { return BackColor; }
- set { BackColor = value; }
- }
- [Category("Colors")]
- public Color _CheckedColor {
- get { return CheckedColor; }
- set { CheckedColor = value; }
- }
- [Category("Colors")]
- public Color _BorderColor {
- get { return BorderColor; }
- set { BorderColor = value; }
- }
- #endregion
- #endregion
- #region " Colors"
- private Color BackColor = Color.FromArgb(45, 47, 49);
- private Color CheckedColor = _FlatColor;
- private Color BorderColor = Color.FromArgb(53, 58, 60);
- #endregion
- #region " Overrides"
- public override Color ButtonSelectedBorder {
- get { return BackColor; }
- }
- public override Color CheckBackground {
- get { return CheckedColor; }
- }
- public override Color CheckPressedBackground {
- get { return CheckedColor; }
- }
- public override Color CheckSelectedBackground {
- get { return CheckedColor; }
- }
- public override Color ImageMarginGradientBegin {
- get { return CheckedColor; }
- }
- public override Color ImageMarginGradientEnd {
- get { return CheckedColor; }
- }
- public override Color ImageMarginGradientMiddle {
- get { return CheckedColor; }
- }
- public override Color MenuBorder {
- get { return BorderColor; }
- }
- public override Color MenuItemBorder {
- get { return BorderColor; }
- }
- public override Color MenuItemSelected {
- get { return CheckedColor; }
- }
- public override Color SeparatorDark {
- get { return BorderColor; }
- }
- public override Color ToolStripDropDownBackground {
- get { return BackColor; }
- }
- #endregion
- }
- }
- [DefaultEvent("Scroll")]
- class FlatTrackBar : Control
- {
- #region " Variables"
- private int W;
- private int H;
- private int Val;
- private bool Bool;
- private Rectangle Track;
- private Rectangle Knob;
- private _Style Style_;
- #endregion
- #region " Properties"
- #region " Mouse States"
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- if (e.Button == Windows.Forms.MouseButtons.Left) {
- Val = Convert.ToInt32((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11));
- Track = new Rectangle(Val, 0, 10, 20);
- Bool = Track.Contains(e.Location);
- }
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- if (Bool && e.X > -1 && e.X < (Width + 1)) {
- Value = _Minimum + Convert.ToInt32((_Maximum - _Minimum) * (e.X / Width));
- }
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- Bool = false;
- }
- #endregion
- #region " Styles"
- [Flags()]
- public enum _Style
- {
- Slider,
- Knob
- }
- public _Style Style {
- get { return Style_; }
- set { Style_ = value; }
- }
- #endregion
- #region " Colors"
- [Category("Colors")]
- public Color TrackColor {
- get { return _TrackColor; }
- set { _TrackColor = value; }
- }
- [Category("Colors")]
- public Color HatchColor {
- get { return _HatchColor; }
- set { _HatchColor = value; }
- }
- #endregion
- public event ScrollEventHandler Scroll;
- public delegate void ScrollEventHandler(object sender);
- private int _Minimum;
- public int Minimum {
- get { return Minimum; }
- set {
- if (value < 0) {
- }
- _Minimum = value;
- if (value > _Value)
- _Value = value;
- if (value > _Maximum)
- _Maximum = value;
- Invalidate();
- }
- }
- private int _Maximum = 10;
- public int Maximum {
- get { return _Maximum; }
- set {
- if (value < 0) {
- }
- _Maximum = value;
- if (value < _Value)
- _Value = value;
- if (value < _Minimum)
- _Minimum = value;
- Invalidate();
- }
- }
- private int _Value;
- public int Value {
- get { return _Value; }
- set {
- if (value == _Value)
- return;
- if (value > _Maximum || value < _Minimum) {
- }
- _Value = value;
- Invalidate();
- if (Scroll != null) {
- Scroll(this);
- }
- }
- }
- private bool _ShowValue = false;
- public bool ShowValue {
- get { return _ShowValue; }
- set { _ShowValue = value; }
- }
- protected override void OnKeyDown(KeyEventArgs e)
- {
- base.OnKeyDown(e);
- if (e.KeyCode == Keys.Subtract) {
- if (Value == 0)
- return;
- Value -= 1;
- } else if (e.KeyCode == Keys.Add) {
- if (Value == _Maximum)
- return;
- Value += 1;
- }
- }
- protected override void OnTextChanged(EventArgs e)
- {
- base.OnTextChanged(e);
- Invalidate();
- }
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
- Height = 23;
- }
- #endregion
- #region " Colors"
- private Color BaseColor = Color.FromArgb(45, 47, 49);
- private Color _TrackColor = _FlatColor;
- private Color SliderColor = Color.FromArgb(25, 27, 29);
- private Color _HatchColor = Color.FromArgb(23, 148, 92);
- #endregion
- public FlatTrackBar()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- Height = 18;
- BackColor = Color.FromArgb(60, 70, 73);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width - 1;
- H = Height - 1;
- Rectangle Base = new Rectangle(1, 6, W - 2, 8);
- GraphicsPath GP = default(GraphicsPath), GP2 = new GraphicsPath();
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- //-- Value
- Val = Convert.ToInt32((_Value - _Minimum) / (_Maximum - _Minimum) * (W - 10));
- Track = new Rectangle(Val, 0, 10, 20);
- Knob = new Rectangle(Val, 4, 11, 14);
- //-- Base
- GP.AddRectangle(Base);
- G.SetClip(GP);
- G.FillRectangle(new SolidBrush(BaseColor), new Rectangle(0, 7, W, 8));
- G.FillRectangle(new SolidBrush(_TrackColor), new Rectangle(0, 7, Track.X + Track.Width, 8));
- G.ResetClip();
- //-- Hatch Brush
- HatchBrush HB = new HatchBrush(HatchStyle.Plaid, HatchColor, _TrackColor);
- G.FillRectangle(HB, new Rectangle(-10, 7, Track.X + Track.Width, 8));
- //-- Slider/Knob
- switch (Style) {
- case _Style.Slider:
- GP2.AddRectangle(Track);
- G.FillPath(new SolidBrush(SliderColor), GP2);
- break;
- case _Style.Knob:
- GP2.AddEllipse(Knob);
- G.FillPath(new SolidBrush(SliderColor), GP2);
- break;
- }
- //-- Show the value
- if (ShowValue) {
- G.DrawString(Value, new Font("Segoe UI", 8), Brushes.White, new Rectangle(1, 6, W, H), new StringFormat {
- Alignment = StringAlignment.Far,
- LineAlignment = StringAlignment.Far
- });
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatStatusBar : Control
- {
- #region " Variables"
- private int W;
- private int H;
- private bool _ShowTimeDate = false;
- #endregion
- #region " Properties"
- protected override void CreateHandle()
- {
- base.CreateHandle();
- Dock = DockStyle.Bottom;
- }
- protected override void OnTextChanged(EventArgs e)
- {
- base.OnTextChanged(e);
- Invalidate();
- }
- #region " Colors"
- [Category("Colors")]
- public Color BaseColor {
- get { return _BaseColor; }
- set { _BaseColor = value; }
- }
- [Category("Colors")]
- public Color TextColor {
- get { return _TextColor; }
- set { _TextColor = value; }
- }
- [Category("Colors")]
- public Color RectColor {
- get { return _RectColor; }
- set { _RectColor = value; }
- }
- #endregion
- public bool ShowTimeDate {
- get { return _ShowTimeDate; }
- set { _ShowTimeDate = value; }
- }
- public string GetTimeDate()
- {
- return DateTime.Now.Date + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- }
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(45, 47, 49);
- private Color _TextColor = Color.White;
- private Color _RectColor = _FlatColor;
- #endregion
- public FlatStatusBar()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- Font = new Font("Segoe UI", 8);
- ForeColor = Color.White;
- Size = new Size(Width, 20);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- W = Width;
- H = Height;
- Rectangle Base = new Rectangle(0, 0, W, H);
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BaseColor);
- //-- Base
- G.FillRectangle(new SolidBrush(BaseColor), Base);
- //-- Text
- G.DrawString(Text, Font, Brushes.White, new Rectangle(10, 4, W, H), NearSF);
- //-- Rectangle
- G.FillRectangle(new SolidBrush(_RectColor), new Rectangle(4, 4, 4, 14));
- //-- TimeDate
- if (ShowTimeDate) {
- G.DrawString(GetTimeDate, Font, new SolidBrush(_TextColor), new Rectangle(-4, 2, W, H), new StringFormat {
- Alignment = StringAlignment.Far,
- LineAlignment = StringAlignment.Center
- });
- }
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- class FlatLabel : Label
- {
- protected override void OnTextChanged(EventArgs e)
- {
- base.OnTextChanged(e);
- Invalidate();
- }
- public FlatLabel()
- {
- SetStyle(ControlStyles.SupportsTransparentBackColor, true);
- Font = new Font("Segoe UI", 8);
- ForeColor = Color.White;
- BackColor = Color.Transparent;
- Text = Text;
- }
- }
- class FlatTreeView : TreeView
- {
- #region " Variables"
- private TreeNodeStates State;
- #endregion
- #region " Properties"
- protected override void OnDrawNode(DrawTreeNodeEventArgs e)
- {
- try {
- Rectangle Bounds = new Rectangle(e.Bounds.Location.X, e.Bounds.Location.Y, e.Bounds.Width, e.Bounds.Height);
- //e.Node.Nodes.Item.
- switch (State) {
- case TreeNodeStates.Default:
- e.Graphics.FillRectangle(Brushes.Red, Bounds);
- e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8), Brushes.LimeGreen, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF);
- Invalidate();
- break;
- case TreeNodeStates.Checked:
- e.Graphics.FillRectangle(Brushes.Green, Bounds);
- e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8), Brushes.Black, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF);
- Invalidate();
- break;
- case TreeNodeStates.Selected:
- e.Graphics.FillRectangle(Brushes.Green, Bounds);
- e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8), Brushes.Black, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF);
- Invalidate();
- break;
- }
- } catch (Exception ex) {
- Interaction.MsgBox(ex.Message);
- }
- base.OnDrawNode(e);
- }
- #endregion
- #region " Colors"
- private Color _BaseColor = Color.FromArgb(45, 47, 49);
- private Color _LineColor = Color.FromArgb(25, 27, 29);
- #endregion
- public FlatTreeView()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
- DoubleBuffered = true;
- BackColor = _BaseColor;
- ForeColor = Color.White;
- LineColor = _LineColor;
- DrawMode = TreeViewDrawMode.OwnerDrawAll;
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- Rectangle Base = new Rectangle(0, 0, Width, Height);
- {
- G.SmoothingMode = 2;
- G.PixelOffsetMode = 2;
- G.TextRenderingHint = 5;
- G.Clear(BackColor);
- G.FillRectangle(new SolidBrush(_BaseColor), Base);
- G.DrawString(Text, new Font("Segoe UI", 8), Brushes.Black, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF);
- }
- base.OnPaint(e);
- G.Dispose();
- e.Graphics.InterpolationMode = 7;
- e.Graphics.DrawImageUnscaled(B, 0, 0);
- B.Dispose();
- }
- }
- //=======================================================
- //Service provided by Telerik (www.telerik.com)
- //Conversion powered by NRefactory.
- //Twitter: @telerik, @toddanglin
- //Facebook: facebook.com/telerik
- //=======================================================
Advertisement
Add Comment
Please, Sign In to add comment