Пример #1
0
        /// <summary>
        /// 绘制水晶按钮
        /// </summary>
        /// <param name="g">The g.</param>
        /// User:Ryan  CreateTime:2012-8-5 14:13.
        protected void DrawRibbonBtn(Graphics g)
        {
            Rectangle exRect = new Rectangle(0, base.CaptionHeight, this.Width, this.Height - base.CaptionHeight + 1);

            g.SetClip(exRect, CombineMode.Exclude);
            GDIHelper.InitializeGraphics(g);
            Rectangle rect = this.RibbonBtnRect;

            rect.Inflate(-1, -1);
            GDIHelper.FillEllipse(g, rect, Color.White);
            Color c1 = Color.Empty, c2 = Color.Empty, c3 = Color.FromArgb(232, 246, 250);
            Blend blend = new Blend();

            blend.Positions = new float[] { 0f, 0.3f, 0.5f, 0.8f, 1f };
            blend.Factors   = new float[] { 0.15f, 0.55f, 0.7f, 0.8f, 0.95f };
            switch (this._RibbonBtnState)
            {
            case EnumControlState.HeightLight:
                c1 = Color.FromArgb(225, 179, 27);
                c2 = Color.FromArgb(255, 251, 232);
                break;

            case EnumControlState.Focused:
                c1 = Color.FromArgb(191, 113, 5);
                c2 = Color.FromArgb(248, 227, 222);
                break;

            default:
                c1 = Color.FromArgb(239, 246, 249);
                c2 = Color.FromArgb(224, 221, 231);
                blend.Positions = new float[] { 0f, 0.3f, 0.5f, 0.85f, 1f };
                blend.Factors   = new float[] { 0.95f, 0.70f, 0.45f, 0.3f, 0.15f };
                break;
            }

            GDIHelper.DrawCrystalButton(g, rect, c1, c2, c3, blend);
            Color borderColor = Color.FromArgb(65, 177, 199);

            GDIHelper.DrawEllipseBorder(g, rect, borderColor, 1);
            Size imgSize = new System.Drawing.Size(20, 20);

            GDIHelper.DrawImage(g, rect, Properties.Resources.naruto, imgSize);
            g.ResetClip();
        }
Пример #2
0
        /// <summary>
        /// 绘制复选框和内容.
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// User:Ryan  CreateTime:2011-07-29 15:44.
        private void DrawContent(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            int       w        = this.Width;
            int       h        = this.Height;
            Rectangle maxRect  = new Rectangle(this._Margin, h / 2 - this._MaxRadius, this._MaxRadius * 2, this._MaxRadius * 2);
            Rectangle minRect  = new Rectangle(this._Margin + this._MaxRadius - this._MinRadius, h / 2 - this._MinRadius, this._MinRadius * 2, this._MinRadius * 2);
            Size      textSize = g.MeasureString(this.Text, this.Font).ToSize();
            Rectangle textRect = new Rectangle();

            textRect.X      = maxRect.Right + this._Margin;
            textRect.Y      = h / 2 - textSize.Height / 2 + 1;
            textRect.Height = textSize.Height;
            textRect.Width  = this.Width - textRect.Left;
            GDIHelper.DrawEllipseBorder(g, maxRect, SkinManager.CurrentSkin.BorderColor, 2);
            //GDIHelper.DrawEllipseBorder(g, minRect, SkinManager.CurrentSkin.BorderColor, 2);
            GDIHelper.FillEllipse(g, minRect, SkinManager.CurrentSkin.DefaultControlColor.First);
            GDIHelper.DrawEllipseBorder(g, minRect, SkinManager.CurrentSkin.BorderColor, 1);
            switch (this._ControlState)
            {
            case EnumControlState.HeightLight:
            case EnumControlState.Focused:
                maxRect.Inflate(1, 1);
                GDIHelper.DrawEllipseBorder(g, maxRect, SkinManager.CurrentSkin.OuterBorderColor, 1);
                maxRect.Inflate(-2, -2);
                GDIHelper.DrawEllipseBorder(g, maxRect, SkinManager.CurrentSkin.InnerBorderColor, 1);
                break;
            }

            Color c = this.Enabled ? this.ForeColor : SkinManager.CurrentSkin.UselessColor;

            TextRenderer.DrawText(g, this.Text, this.Font, textRect, c, TextFormatFlags.Default);
            if (this.Checked)
            {
                GDIHelper.FillEllipse(g, minRect, Color.FromArgb(15, 216, 32), Color.Green);
                c = SkinManager.CurrentSkin.BorderColor;
                GDIHelper.DrawEllipseBorder(g, minRect, c, 1);
            }
        }