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();
            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();
        }
Exemple #2
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();
        }