Beispiel #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();
        }
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item = e.Item;
            Graphics      g    = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            ////你真没救了!好吧,我承认我是个具有文艺气质的2B程序员
            if (item.Tag != null && item.Tag.Equals("Vicky"))
            {
                int       temp = item.Width >= item.Height ? item.Height : item.Width;
                Rectangle rect = new Rectangle(0, 0, temp, temp);
                rect.Inflate(-1, -1);
                Color c1 = Color.Empty, c2 = Color.Empty, c3 = Color.FromArgb(255, 220, 102);
                Blend blend = new Blend();
                blend.Positions = new float[] { 0f, 0.5f, 1f };
                blend.Factors   = new float[] { 0.25f, 0.75f, 1f };
                Color borderColor = item.Selected || item.Pressed ? Color.FromArgb(24, 116, 205) :
                                    SkinManager.CurrentSkin.BorderColor;
                float w = 1.0F;
                g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                if (item.Selected || item.Pressed)
                {
                    w  = 2.0F;
                    c1 = Color.FromArgb(255, 226, 48);
                    c2 = Color.FromArgb(255, 220, 102);
                    GDIHelper.DrawCrystalButton(g, rect, c1, c2, c3, blend);
                }

                using (Pen p = new Pen(borderColor, w))
                {
                    g.DrawEllipse(p, rect);
                }
            }
            else
            {
                Rectangle      rect      = new Rectangle(1, 1, item.Width - 4, item.Height - 3);
                RoundRectangle roundRect = new RoundRectangle(rect, this.ItemCornerRadius);
                if (item.Selected || item.Pressed)
                {
                    GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor);
                    GDIHelper.DrawPathBorder(g, roundRect);
                }
            }
        }