Example #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            this.UpdateColors();

            Bitmap   B = new Bitmap(Width, Height);
            Graphics G = Graphics.FromImage(B);

            W = Width - 1;
            H = Height - 1;

            GraphicsPath GP   = new GraphicsPath();
            Rectangle    Base = new Rectangle(0, 0, W, H);

            var _with8 = G;

            _with8.SmoothingMode     = SmoothingMode.HighQuality;
            _with8.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            _with8.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            _with8.Clear(BackColor);

            switch (State)
            {
            case MouseState.None:
                if (Rounded)
                {
                    //-- Base
                    GP = Helpers.RoundRec(Base, 6);
                    _with8.FillPath(new SolidBrush(_BaseColor), GP);

                    //-- Text
                    _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                else
                {
                    //-- Base
                    _with8.FillRectangle(new SolidBrush(_BaseColor), Base);

                    //-- Text
                    _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                break;

            case MouseState.Over:
                if (Rounded)
                {
                    //-- Base
                    GP = Helpers.RoundRec(Base, 6);
                    _with8.FillPath(new SolidBrush(_BaseColor), GP);
                    _with8.FillPath(new SolidBrush(Color.FromArgb(20, Color.White)), GP);

                    //-- Text
                    _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                else
                {
                    //-- Base
                    _with8.FillRectangle(new SolidBrush(_BaseColor), Base);
                    _with8.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.White)), Base);

                    //-- Text
                    _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                break;

            case MouseState.Down:
                if (Rounded)
                {
                    //-- Base
                    GP = Helpers.RoundRec(Base, 6);
                    _with8.FillPath(new SolidBrush(_BaseColor), GP);
                    _with8.FillPath(new SolidBrush(Color.FromArgb(20, Color.Black)), GP);

                    //-- Text
                    _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                else
                {
                    //-- Base
                    _with8.FillRectangle(new SolidBrush(_BaseColor), Base);
                    _with8.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.Black)), Base);

                    //-- Text
                    _with8.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                break;
            }

            base.OnPaint(e);
            G.Dispose();
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            e.Graphics.DrawImageUnscaled(B, 0, 0);
            B.Dispose();
        }
Example #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            UpdateColors();

            Bitmap   b = new Bitmap(Width, Height);
            Graphics g = Graphics.FromImage(b);

            _w = Width - 1;
            _h = Height - 1;

            GraphicsPath gp     = new GraphicsPath();
            GraphicsPath gp2    = new GraphicsPath();
            Rectangle    Base   = new Rectangle(0, 0, _w, _h);
            Rectangle    toggle = new Rectangle(Convert.ToInt32(_w / 2), 0, 38, _h);

            var with9 = g;

            with9.SmoothingMode     = SmoothingMode.HighQuality;
            with9.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            with9.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            with9.Clear(BackColor);

            switch (_o)
            {
            case _Options.Style1:
                //-- Style 1
                //-- Base
                gp  = Helpers.RoundRec(Base, 6);
                gp2 = Helpers.RoundRec(toggle, 6);
                with9.FillPath(new SolidBrush(_bgColor), gp);
                with9.FillPath(new SolidBrush(_toggleColor), gp2);

                //-- Text
                with9.DrawString("OFF", Font, new SolidBrush(_bgColor), new Rectangle(19, 1, _w, _h), Helpers.CenterSf);

                if (Checked)
                {
                    //-- Base
                    gp  = Helpers.RoundRec(Base, 6);
                    gp2 = Helpers.RoundRec(new Rectangle(Convert.ToInt32(_w / 2), 0, 38, _h), 6);
                    with9.FillPath(new SolidBrush(_toggleColor), gp);
                    with9.FillPath(new SolidBrush(_baseColor), gp2);

                    //-- Text
                    with9.DrawString("ON", Font, new SolidBrush(_baseColor), new Rectangle(8, 7, _w, _h), Helpers.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);
                with9.FillPath(new SolidBrush(_baseColorRed), gp);
                with9.FillPath(new SolidBrush(_toggleColor), gp2);

                //-- Lines
                with9.DrawLine(new Pen(_bgColor), 18, 20, 18, 12);
                with9.DrawLine(new Pen(_bgColor), 22, 20, 22, 12);
                with9.DrawLine(new Pen(_bgColor), 26, 20, 26, 12);

                //-- Text
                with9.DrawString("r", new Font("Marlett", 8), new SolidBrush(_textColor), new Rectangle(19, 2, Width, Height), Helpers.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);
                    with9.FillPath(new SolidBrush(_baseColor), gp);
                    with9.FillPath(new SolidBrush(_toggleColor), gp2);

                    //-- Lines
                    with9.DrawLine(new Pen(_bgColor), Convert.ToInt32(_w / 2) + 12, 20, Convert.ToInt32(_w / 2) + 12, 12);
                    with9.DrawLine(new Pen(_bgColor), Convert.ToInt32(_w / 2) + 16, 20, Convert.ToInt32(_w / 2) + 16, 12);
                    with9.DrawLine(new Pen(_bgColor), Convert.ToInt32(_w / 2) + 20, 20, Convert.ToInt32(_w / 2) + 20, 12);

                    //-- Text
                    with9.DrawString("ü", new Font("Wingdings", 14), new SolidBrush(_textColor), new Rectangle(8, 7, Width, Height), Helpers.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);
                with9.FillPath(new SolidBrush(_toggleColor), gp);
                with9.FillPath(new SolidBrush(_baseColorRed), gp2);

                //-- Text
                with9.DrawString("OFF", Font, new SolidBrush(_baseColorRed), new Rectangle(-12, 2, _w, _h), Helpers.CenterSf);

                if (Checked)
                {
                    //-- Base
                    gp     = Helpers.RoundRec(Base, 16);
                    toggle = new Rectangle(6, 4, 22, _h - 8);
                    gp2.Reset();
                    gp2.AddEllipse(toggle);
                    with9.FillPath(new SolidBrush(_toggleColor), gp);
                    with9.FillPath(new SolidBrush(_baseColor), gp2);

                    //-- Text
                    with9.DrawString("ON", Font, new SolidBrush(_baseColor), new Rectangle(12, 2, _w, _h), Helpers.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 = InterpolationMode.HighQualityBicubic;
            e.Graphics.DrawImageUnscaled(b, 0, 0);
            b.Dispose();
        }
Example #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            this.UpdateColors();
            Bitmap   bitmap    = new Bitmap(this.Width, this.Height);
            Graphics graphics1 = Graphics.FromImage((Image)bitmap);

            this.W = this.Width - 1;
            this.H = this.Height - 1;
            GraphicsPath graphicsPath = new GraphicsPath();
            Rectangle    rectangle    = new Rectangle(0, 0, this.W, this.H);
            Graphics     graphics2    = graphics1;

            graphics2.SmoothingMode     = SmoothingMode.HighQuality;
            graphics2.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics2.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics2.Clear(this.BackColor);
            switch (this.State)
            {
            case MouseState.None:
                if (this.Rounded)
                {
                    GraphicsPath path = Helpers.RoundRec(rectangle, 6);
                    graphics2.FillPath((Brush) new SolidBrush(this._BaseColor), path);
                    graphics2.DrawString(this.Text, this.Font, (Brush) new SolidBrush(this._TextColor), (RectangleF)rectangle, Helpers.CenterSF);
                    break;
                }
                graphics2.FillRectangle((Brush) new SolidBrush(this._BaseColor), rectangle);
                graphics2.DrawString(this.Text, this.Font, (Brush) new SolidBrush(this._TextColor), (RectangleF)rectangle, Helpers.CenterSF);
                break;

            case MouseState.Over:
                if (this.Rounded)
                {
                    GraphicsPath path = Helpers.RoundRec(rectangle, 6);
                    graphics2.FillPath((Brush) new SolidBrush(this._BaseColor), path);
                    graphics2.FillPath((Brush) new SolidBrush(Color.FromArgb(20, Color.White)), path);
                    graphics2.DrawString(this.Text, this.Font, (Brush) new SolidBrush(this._TextColor), (RectangleF)rectangle, Helpers.CenterSF);
                    break;
                }
                graphics2.FillRectangle((Brush) new SolidBrush(this._BaseColor), rectangle);
                graphics2.FillRectangle((Brush) new SolidBrush(Color.FromArgb(20, Color.White)), rectangle);
                graphics2.DrawString(this.Text, this.Font, (Brush) new SolidBrush(this._TextColor), (RectangleF)rectangle, Helpers.CenterSF);
                break;

            case MouseState.Down:
                if (this.Rounded)
                {
                    GraphicsPath path = Helpers.RoundRec(rectangle, 6);
                    graphics2.FillPath((Brush) new SolidBrush(this._BaseColor), path);
                    graphics2.FillPath((Brush) new SolidBrush(Color.FromArgb(20, Color.Black)), path);
                    graphics2.DrawString(this.Text, this.Font, (Brush) new SolidBrush(this._TextColor), (RectangleF)rectangle, Helpers.CenterSF);
                    break;
                }
                graphics2.FillRectangle((Brush) new SolidBrush(this._BaseColor), rectangle);
                graphics2.FillRectangle((Brush) new SolidBrush(Color.FromArgb(20, Color.Black)), rectangle);
                graphics2.DrawString(this.Text, this.Font, (Brush) new SolidBrush(this._TextColor), (RectangleF)rectangle, Helpers.CenterSF);
                break;
            }
            base.OnPaint(e);
            graphics1.Dispose();
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            e.Graphics.DrawImageUnscaled((Image)bitmap, 0, 0);
            bitmap.Dispose();
        }
Example #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            UpdateColors();

            var B = new Bitmap(Width, Height);
            var G = Graphics.FromImage(B);

            W = Width - 1;
            H = Height - 1;

            var GP     = new GraphicsPath();
            var GP2    = new GraphicsPath();
            var Base   = new Rectangle(0, 0, W, H);
            var Toggle = new Rectangle(Convert.ToInt32(W / 2), 0, 38, H);

            var _with9 = G;

            _with9.SmoothingMode     = SmoothingMode.HighQuality;
            _with9.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            _with9.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            _with9.Clear(BackColor);

            switch (Options)
            {
            case _Options.Style1:
                //-- Style 1
                //-- Base
                GP  = Helpers.RoundRec(Base, 6);
                GP2 = Helpers.RoundRec(Toggle, 6);
                _with9.FillPath(new SolidBrush(BGColor), GP);
                _with9.FillPath(new SolidBrush(ToggleColor), GP2);

                //-- Text
                _with9.DrawString("OFF", Font, new SolidBrush(BGColor), new Rectangle(19, 1, W, H),
                                  Helpers.CenterSF);

                if (Checked)
                {
                    //-- Base
                    GP  = Helpers.RoundRec(Base, 6);
                    GP2 = Helpers.RoundRec(new Rectangle(Convert.ToInt32(W / 2 + 1), 0, 38, H + 1), 6);
                    _with9.FillPath(new SolidBrush(ToggleColor), GP);
                    _with9.FillPath(new SolidBrush(BaseColor), GP2);

                    //-- Text
                    _with9.DrawString("ON", Font, new SolidBrush(BaseColor), new Rectangle(8, 7, W, H),
                                      Helpers.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);
                _with9.FillPath(new SolidBrush(BaseColorRed), GP);
                _with9.FillPath(new SolidBrush(ToggleColor), GP2);

                //-- Lines
                _with9.DrawLine(new Pen(TextColor), 18, 20, 18, 12);
                _with9.DrawLine(new Pen(TextColor), 22, 20, 22, 12);
                _with9.DrawLine(new Pen(TextColor), 26, 20, 26, 12);

                //-- Text
                _with9.DrawString("r", new Font("Marlett", 8), new SolidBrush(TextColor),
                                  new Rectangle(19, 2, Width, Height), Helpers.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);
                    _with9.FillPath(new SolidBrush(BaseColor), GP);
                    _with9.FillPath(new SolidBrush(ToggleColor), GP2);

                    //-- Lines
                    _with9.DrawLine(new Pen(BGColor), Convert.ToInt32(W / 2) + 12, 20,
                                    Convert.ToInt32(W / 2) + 12, 12);
                    _with9.DrawLine(new Pen(BGColor), Convert.ToInt32(W / 2) + 16, 20,
                                    Convert.ToInt32(W / 2) + 16, 12);
                    _with9.DrawLine(new Pen(BGColor), Convert.ToInt32(W / 2) + 20, 20,
                                    Convert.ToInt32(W / 2) + 20, 12);

                    //-- Text
                    _with9.DrawString("ü", new Font("Wingdings", 14), new SolidBrush(TextColor),
                                      new Rectangle(8, 7, Width, Height), Helpers.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);
                _with9.FillPath(new SolidBrush(ToggleColor), GP);
                _with9.FillPath(new SolidBrush(BaseColorRed), GP2);

                //-- Text
                _with9.DrawString("OFF", Font, new SolidBrush(BaseColorRed), new Rectangle(-12, 2, W, H),
                                  Helpers.CenterSF);

                if (Checked)
                {
                    //-- Base
                    GP     = Helpers.RoundRec(Base, 16);
                    Toggle = new Rectangle(6, 4, 22, H - 8);
                    GP2.Reset();
                    GP2.AddEllipse(Toggle);
                    _with9.FillPath(new SolidBrush(ToggleColor), GP);
                    _with9.FillPath(new SolidBrush(BaseColor), GP2);

                    //-- Text
                    _with9.DrawString("ON", Font, new SolidBrush(BaseColor), new Rectangle(12, 2, W, H),
                                      Helpers.CenterSF);
                }

                break;
            }

            base.OnPaint(e);
            G.Dispose();
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            e.Graphics.DrawImageUnscaled(B, 0, 0);
            B.Dispose();
        }
Example #5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            UpdateColors();

            Bitmap   B = new Bitmap(Width, Height);
            Graphics G = Graphics.FromImage(B);

            W = Width - 1;
            H = Height - 1;

            Rectangle    Base = new Rectangle(0, 24, W, H);
            GraphicsPath GP   = new GraphicsPath();
            GraphicsPath GP2  = new GraphicsPath();
            GraphicsPath GP3  = new GraphicsPath();

            var _with15 = G;

            _with15.SmoothingMode     = SmoothingMode.HighQuality;
            _with15.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            _with15.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            _with15.Clear(BackColor);

            //-- Progress Value
            //int iValue = Convert.ToInt32(((float)_Value) / ((float)(_Maximum * Width)));
            float percent = ((float)_Value) / ((float)_Maximum);
            int   iValue  = (int)(percent * ((float)Width));

            switch (Value)
            {
            case 0:
                //-- Base
                _with15.FillRectangle(new SolidBrush(_BaseColor), Base);
                //--Progress
                _with15.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(0, 24, iValue - 1, H - 1));
                break;

            case 100:
                //-- Base
                _with15.FillRectangle(new SolidBrush(_BaseColor), Base);
                //--Progress
                _with15.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(0, 24, iValue - 1, H - 1));
                break;

            default:
                //-- Base
                _with15.FillRectangle(new SolidBrush(_BaseColor), Base);

                //--Progress
                GP.AddRectangle(new Rectangle(0, 24, iValue - 1, H - 1));
                _with15.FillPath(new SolidBrush(_ProgressColor), GP);

                if (_Pattern)
                {
                    //-- Hatch Brush
                    HatchBrush HB = new HatchBrush(HatchStyle.Plaid, _DarkerProgress, _ProgressColor);
                    _with15.FillRectangle(HB, new Rectangle(0, 24, iValue - 1, H - 1));
                }

                if (_ShowBalloon)
                {
                    //-- Balloon
                    Rectangle Balloon = new Rectangle(iValue - 18, 0, 34, 16);
                    GP2 = Helpers.RoundRec(Balloon, 4);
                    _with15.FillPath(new SolidBrush(_BaseColor), GP2);

                    //-- Arrow
                    GP3 = Helpers.DrawArrow(iValue - 9, 16, true);
                    _with15.FillPath(new SolidBrush(_BaseColor), GP3);

                    //-- Value > You can add "%" > value & "%"
                    string text    = (_PercentSign ? Value.ToString() + "%" : Value.ToString());
                    int    wOffset = (_PercentSign ? iValue - 15 : iValue - 11);
                    _with15.DrawString(text, new Font("Segoe UI", 10), new SolidBrush(_ProgressColor), new Rectangle(wOffset, -2, W, H), Helpers.NearSF);
                }

                break;
            }

            base.OnPaint(e);
            G.Dispose();
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            e.Graphics.DrawImageUnscaled(B, 0, 0);
            B.Dispose();
        }
Example #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            UpdateColors();

            var b = new Bitmap(Width, Height);
            var g = Graphics.FromImage(b);

            _w = Width - 1;
            _h = Height - 1;

            GraphicsPath gp;
            var          Base = new Rectangle(0, 0, _w, _h);

            var with8 = g;

            with8.SmoothingMode     = SmoothingMode.HighQuality;
            with8.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            with8.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            with8.Clear(BackColor);

            switch (_state)
            {
            case MouseState.None:
                if (Rounded)
                {
                    //-- Base
                    gp = Helpers.RoundRec(Base, 6);
                    with8.FillPath(new SolidBrush(BaseColor), gp);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }
                else
                {
                    //-- Base
                    with8.FillRectangle(new SolidBrush(BaseColor), Base);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }

                break;

            case MouseState.Over:
                if (Rounded)
                {
                    //-- Base
                    gp = Helpers.RoundRec(Base, 6);
                    with8.FillPath(new SolidBrush(BaseColor), gp);
                    with8.FillPath(new SolidBrush(Color.FromArgb(20, Color.White)), gp);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }
                else
                {
                    //-- Base
                    with8.FillRectangle(new SolidBrush(BaseColor), Base);
                    with8.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.White)), Base);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }

                break;

            case MouseState.Down:
                if (Rounded)
                {
                    //-- Base
                    gp = Helpers.RoundRec(Base, 6);
                    with8.FillPath(new SolidBrush(BaseColor), gp);
                    with8.FillPath(new SolidBrush(Color.FromArgb(20, Color.Black)), gp);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }
                else
                {
                    //-- Base
                    with8.FillRectangle(new SolidBrush(BaseColor), Base);
                    with8.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.Black)), Base);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }

                break;
            }

            base.OnPaint(e);
            g.Dispose();
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            e.Graphics.DrawImageUnscaled(b, 0, 0);
            b.Dispose();
        }