示例#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();
        }
示例#2
0
        private void UpdateColors()
        {
            NicolauColors colors = Helpers.GetColors(this);

            _BaseColor = colors.Nicolau;
        }