/// <summary>
        /// 绘制背景和边框等
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// User:Ryan  CreateTime:2011-08-01 16:47.
        private void DrawBackGround(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            Rectangle      rect      = new Rectangle(1, 1, this.Width - 3, this.Height - 3);
            RoundRectangle roundRect = new RoundRectangle(rect, new Model.CornerRadius(this._CornerRadius));

            switch (this._ControlState)
            {
            case EnumControlState.Default:
                if (this.FlatStyle != FlatStyle.Flat)
                {
                    GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.DefaultControlColor);
                    GDIHelper.DrawPathBorder(g, roundRect);
                }
                break;

            case EnumControlState.HeightLight:
                GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor);
                GDIHelper.DrawPathBorder(g, roundRect);
                break;

            case EnumControlState.Focused:
                GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.FocusedControlColor);
                GDIHelper.DrawPathBorder(g, roundRect);
                GDIHelper.DrawPathInnerBorder(g, roundRect);
                break;
            }
        }
Exemple #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //Graphics g = e.Graphics;
            //GDIHelper.InitializeGraphics(g);
            //this.DrawFormBackGround(g);
            //this.DrawCaption(g);
            //this.DrawFormBorder(g);


            BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
            BufferedGraphics        myBuffer       = currentContext.Allocate(e.Graphics, e.ClipRectangle);
            Graphics g = myBuffer.Graphics;

            GDIHelper.InitializeGraphics(g);
            this.DrawFormBackGround(g);
            this.DrawCaption(g);
            this.DrawFormBorder(g);

            g.SmoothingMode   = SmoothingMode.HighQuality;
            g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
            // g.Clear(this.BackColor);
            myBuffer.Render(e.Graphics);
            g.Dispose();
            myBuffer.Dispose();//释放资源
        }
Exemple #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            base.OnPaintBackground(e);
            Graphics g = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle textRect  = this.GetTextRect(g);
            Color     textColor = this.Enabled ? this._CaptionColor : SkinManager.CurrentSkin.UselessColor;

            switch (this._BorderStyle)
            {
            case EnumBorderStyle.QQStyle:
                this.DrawQQStyleBorder(g, textRect);
                break;

            case EnumBorderStyle.Default:
                this.DrawDefaultBorder(g, textRect);
                break;

            default:
                break;
            }

            TextRenderer.DrawText(g, this.Text, this._CaptionFont, textRect, textColor, TextFormatFlags.Left);
        }
Exemple #4
0
 protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
 {
     try
     {
         base.OnDrawColumnHeader(e);
         string key = this.Columns[e.ColumnIndex].ImageKey;
         if (!string.IsNullOrEmpty(key))
         {
             Rectangle rect      = e.Bounds;
             int       offset    = 3;
             Size      arrowSize = new System.Drawing.Size(8, 6);
             Rectangle sortRect  = new Rectangle(rect.Right - offset - arrowSize.Width,
                                                 rect.Y + (rect.Height - arrowSize.Height) / 2,
                                                 arrowSize.Width, arrowSize.Height);
             Graphics g = e.Graphics;
             GDIHelper.InitializeGraphics(g);
             Color c = Color.FromArgb(46, 117, 35);
             if (key == "up")
             {
                 GDIHelper.DrawArrow(g, ArrowDirection.Up, sortRect, arrowSize, 1.5f, c);
             }
             else
             {
                 GDIHelper.DrawArrow(g, ArrowDirection.Down, sortRect, arrowSize, 1.5f, c);
             }
         }
     }catch {}
 }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            int      w = this.BorderWidth > 0 ? this.BorderWidth : 0;
            Graphics g = e.Graphics;

            //缓冲
            //BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
            //BufferedGraphics myBuffer = currentContext.Allocate(e.Graphics, e.ClipRectangle);
            //Graphics g = myBuffer.Graphics;

            GDIHelper.InitializeGraphics(g);
            GradientColor  color     = new GradientColor(this._BackBeginColor, this._BackEndColor, null, null);
            Rectangle      rect      = new Rectangle(0, 0, this.Size.Width - 1, this.Size.Height - 1);
            RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(this._CornerRadius));

            GDIHelper.FillRectangle(g, roundRect, color);
            if (this._BorderWidth > 0)
            {
                rect.X     += this._BorderWidth - 1; rect.Y += this._BorderWidth - 1;
                rect.Width -= this._BorderWidth - 1; rect.Height -= this._BorderWidth - 1;

                GDIHelper.DrawPathBorder(g, new RoundRectangle(rect, new CornerRadius(this._CornerRadius)), this._BorderColor, this.BorderWidth);
                // 上容器的边框
                Rectangle rectPanel1 = new Rectangle(0, 0, this.Panel1.Width - 1, this.Panel1.Height - 1);
                GDIHelper.DrawPathBorder(g, new RoundRectangle(rectPanel1, new CornerRadius(0)), this._BorderColor, this.BorderWidth);
            }

            //g.SmoothingMode = SmoothingMode.HighQuality;
            //g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
            //myBuffer.Render(e.Graphics);
            //g.Dispose();
            //myBuffer.Dispose();//释放资源
        }
Exemple #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            this.DrawFormBackGround(g);
            this.DrawCaption(g);
            this.DrawFormBorder(g);
        }
        /// <summary>
        ///  绘制按钮
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// User:Ryan  CreateTime:2011-08-02 14:23.
        private void DrawButton(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            RoundRectangle btnRoundRect = new RoundRectangle(this.ButtonRect, 0);
            Color          c            = this.Enabled ? this._BackColor : SystemColors.Control;
            Size           btnSize      = new Size(20, 20);

            GDIHelper.FillRectangle(g, btnRoundRect, c);
            GDIHelper.DrawImage(g, this.ButtonRect, Properties.Resources.calendar, btnSize);
        }
        protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
        {
            Size     arrowSize = new Size(8, 8);
            Graphics g         = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle rect = e.ArrowRectangle;

            rect.X -= 2;
            GDIHelper.DrawArrow(g, e.Direction, rect, arrowSize);
        }
        /// <summary>
        /// 绘制下拉框区域.
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// User:Ryan  CreateTime:2011-07-29 15:44.
        private void DrawComboBoxBorder(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            Rectangle rect = new Rectangle(Point.Empty, this.Size);

            rect.Width--;
            rect.Height--;
            using (Pen pen = new Pen(SkinManager.CurrentSkin.BorderColor, 1))
            {
                g.DrawRectangle(pen, rect);
            }
        }
        protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
        {
            base.OnRenderOverflowButtonBackground(e);
            Graphics g = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            ToolStripItem item = e.Item;
            Rectangle     rect = item.Bounds;

            rect = new Rectangle(0, 0, rect.Width, rect.Height);
            Size arrowSize = new Size(8, 8);

            GDIHelper.DrawArrow(g, ArrowDirection.Down, rect, arrowSize);
        }
Exemple #11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics  g    = e.Graphics;
            Rectangle rect = new Rectangle(0, 0, this.Width - 1, this.Height - 1);

            rect.Inflate(-1, -1);
            GDIHelper.InitializeGraphics(g);
            GDIHelper.DrawPathBorder(g, new RoundRectangle(rect, this._CornerRadius), this._BorderColor);
            if (this._ControlState == EnumControlState.HeightLight)
            {
                GDIHelper.DrawPathOuterBorder(g, new RoundRectangle(rect, this._CornerRadius), this._HeightLightBolorColor);
            }
        }
Exemple #12
0
        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            base.OnDrawSubItem(e);
            if (View != View.Details || e.ItemIndex == -1)
            {
                return;
            }

            Rectangle          bounds    = e.Bounds;
            ListViewItemStates itemState = e.ItemState;
            Graphics           g         = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Blend blen = new Blend();

            blen.Positions = new float[] { 0f, 0.4f, 0.7f, 1f };
            blen.Factors   = new float[] { 0f, 0.3f, 0.8f, 0.2f };
            Color c1, c2;

            if ((itemState & ListViewItemStates.Selected) == ListViewItemStates.Selected)
            {
                c1 = this._SelectedBeginColor;
                c2 = this._SelectedEndColor;
                //使用全局皮肤色彩,注意选择文字需要反色处理
                c1             = SkinManager.CurrentSkin.HeightLightControlColor.First;
                c2             = SkinManager.CurrentSkin.HeightLightControlColor.Second;
                blen.Factors   = SkinManager.CurrentSkin.HeightLightControlColor.Factors;
                blen.Positions = SkinManager.CurrentSkin.HeightLightControlColor.Positions;
                GDIHelper.FillPath(g, new RoundRectangle(bounds, 0), c1, c2, blen);
            }
            else
            {
                if (e.ColumnIndex == 0)
                {
                    bounds.Inflate(0, -1);
                }
                c1 = e.ItemIndex % 2 == 0 ? this._RowBackColor1 : this._RowBackColor2;
                c2 = c1;
                GDIHelper.FillPath(g, new RoundRectangle(bounds, 0), c1, c2, blen);
            }

            if (e.ColumnIndex == 0)
            {
                this.OnDrawFirstSubItem(e, g);
            }
            else
            {
                this.DrawNormalSubItem(e, g);
            }
        }
        protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item = e.Item;
            Graphics      g    = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle      rect      = new Rectangle(0, 0, item.Width - 1, item.Height - 1);
            RoundRectangle roundRect = new RoundRectangle(rect, this.ItemCornerRadius);

            if (item.Selected || item.Pressed)
            {
                GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor);
                GDIHelper.DrawPathBorder(g, roundRect);
            }
        }
        /// <summary>
        /// 绘制下拉框区域.
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// User:Ryan  CreateTime:2011-07-29 15:44.
        private void DrawComboBox(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            Rectangle rect = new Rectangle(Point.Empty, this.Size);

            rect.Width--; rect.Height--;
            ////背景
            RoundRectangle roundRect = new RoundRectangle(rect, 0);
            Color          backColor = this.Enabled ? this._BackColor : SystemColors.Control;

            g.SetClip(this.EditRect, CombineMode.Exclude);
            GDIHelper.FillRectangle(g, roundRect, backColor);
            g.ResetClip();
            this.DrawButton(g);
            GDIHelper.DrawPathBorder(g, roundRect);
        }
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item = e.Item;
            Graphics      g    = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle      rect      = new Rectangle(2, -1, item.Width - 4, item.Height + 1);
            RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(0));

            if (item.Selected || item.Pressed)
            {
                Color c1 = Color.FromArgb(200, SkinManager.CurrentSkin.HeightLightControlColor.First);
                Color c2 = Color.FromArgb(250, c1);
                GDIHelper.FillRectangle(g, rect, SkinManager.CurrentSkin.HeightLightControlColor);
                //GDIHelper.DrawPathBorder(g, roundRect);
            }
        }
Exemple #16
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 boxRect  = new Rectangle(this._Margin, h / 2 - this._BoxSize.Height / 2, this._BoxSize.Width, this._BoxSize.Height);
            Size      textSize = g.MeasureString(this.Text, this.Font).ToSize();
            Rectangle textRect = new Rectangle();

            textRect.X      = boxRect.Right + this._Margin;
            textRect.Y      = this._Margin;
            textRect.Height = this.Height - this._Margin * 2;
            textRect.Width  = textSize.Width;
            RoundRectangle roundRect = new RoundRectangle(boxRect, this._CornerRadius);

            switch (this._ControlState)
            {
            case EnumControlState.HeightLight:
                //GDIHelper.DrawPathOuterBorder(g, roundRect, SkinManager.CurrentSkin.OuterBorderColor);
                GDIHelper.DrawPathBorder(g, roundRect, SkinManager.CurrentSkin.OuterBorderColor);
                GDIHelper.DrawPathInnerBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.First);
                break;

            default:
                GDIHelper.DrawCheckBox(g, roundRect);
                break;
            }

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

            //TextRenderer.DrawText(g, this.Text, this.Font, textRect, c, TextFormatFlags.Default);
            GDIHelper.DrawImageAndString(g, textRect, null, Size.Empty, this.Text, this.Font, c);
            switch (this.CheckState)
            {
            case System.Windows.Forms.CheckState.Checked:
                GDIHelper.DrawCheckedStateByImage(g, boxRect);
                break;

            case System.Windows.Forms.CheckState.Indeterminate:
                Rectangle innerRect = boxRect;
                innerRect.Inflate(-3, -3);
                Color cc = Color.FromArgb(46, 117, 35);
                GDIHelper.FillRectangle(g, new RoundRectangle(innerRect, this._CornerRadius), cc);
                break;
            }
        }
Exemple #17
0
        private void DrawBorder(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            Rectangle      rect      = new Rectangle(1, 1, this.Width - 3, this.Height - 3);
            RoundRectangle roundRect = new RoundRectangle(rect, this._CornerRadius);
            Color          c         = (!this._TextBox.Enabled || this._TextBox.ReadOnly) ? Color.FromArgb(215, 250, 243) : Color.White;

            this._TextBox.BackColor = c;
            //this._TextBox.Font = this._Font;
            //this._TextBox.ForeColor = this._ForeColor;
            GDIHelper.FillPath(g, roundRect, c, c);
            GDIHelper.DrawPathBorder(g, roundRect, this._BorderColor);
            if (this._ControlState == EnumControlState.HeightLight)
            {
                GDIHelper.DrawPathBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.Second);
                GDIHelper.DrawPathOuterBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.First);
            }
        }
Exemple #18
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);
                }
            }
        }
Exemple #20
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            int      w = this.BorderWidth > 0 ? this.BorderWidth : 0;
            Graphics g = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            GradientColor  color     = new GradientColor(this._BackBeginColor, this._BackEndColor, null, null);
            Rectangle      rect      = new Rectangle(0, 0, this.Size.Width - 1, this.Size.Height - 1);
            RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(this._CornerRadius));

            GDIHelper.FillRectangle(g, roundRect, color);
            if (this._BorderWidth > 0)
            {
                rect.X     += this._BorderWidth - 1; rect.Y += this._BorderWidth - 1;
                rect.Width -= this._BorderWidth - 1; rect.Height -= this._BorderWidth - 1;
                GDIHelper.DrawPathBorder(g, new RoundRectangle(rect, new CornerRadius(this._CornerRadius)), this._BorderColor, this.BorderWidth);
            }
        }
Exemple #21
0
        protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
        {
            base.OnDrawColumnHeader(e);
            Graphics g = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle bounds = e.Bounds;

            GDIHelper.FillPath(g, new RoundRectangle(bounds, 0), this._HeaderBeginColor, this._HeaderEndColor);
            bounds.Height--;
            if (this.BorderStyle != BorderStyle.None)
            {
                using (Pen p = new Pen(this.BorderColor))
                {
                    g.DrawLine(p, new Point(bounds.Right, bounds.Bottom), new Point(bounds.Right, bounds.Top));
                    g.DrawLine(p, new Point(bounds.Left, bounds.Bottom), new Point(bounds.Right, bounds.Bottom));
                }
            }
            else
            {
                GDIHelper.DrawPathBorder(g, new RoundRectangle(bounds, 0), this._BorderColor);
            }

            bounds.Height++;
            TextFormatFlags flags    = GetFormatFlags(e.Header.TextAlign);
            Rectangle       textRect = new Rectangle(
                bounds.X + 3,
                bounds.Y,
                bounds.Width - 6,
                bounds.Height);;
            Image     image     = null;
            Size      imgSize   = new System.Drawing.Size(16, 16);
            Rectangle imageRect = Rectangle.Empty;

            if (e.Header.ImageList != null)
            {
                image = e.Header.ImageIndex == -1 ?
                        null : e.Header.ImageList.Images[e.Header.ImageIndex];
            }

            GDIHelper.DrawImageAndString(g, bounds, image, imgSize, e.Header.Text, this._Font, e.ForeColor);
        }
        protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  g         = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle rect = e.ImageRectangle;

            if (toolStrip is ToolStripDropDown)
            {
                rect.Width -= 2; rect.Height -= 2;
                RoundRectangle roundRect = new RoundRectangle(rect, 1);
                GDIHelper.DrawCheckBox(g, roundRect);
                GDIHelper.DrawCheckedStateByImage(g, rect);
            }
            else
            {
                base.OnRenderItemCheck(e);
            }
        }
        protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  g         = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle rect = e.AffectedBounds;

            if (toolStrip is ToolStripDropDown)
            {
                ////阴影边框
                rect.Width--; rect.Height--;
                CornerRadius   toolStripCornerRadius = new CornerRadius(this.MenuCornerRadius);
                RoundRectangle roundRect             = new RoundRectangle(rect, toolStripCornerRadius);
                GDIHelper.DrawPathBorder(g, roundRect, this.MenuBorderColor);
            }
            else
            {
                base.OnRenderToolStripBorder(e);
            }
        }
Exemple #24
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);
            }
        }
Exemple #25
0
 protected override void WndProc(ref Message m)
 {
     base.WndProc(ref m);
     switch (m.Msg)
     {
     case (int)WindowMessages.WM_PAINT:
     case (int)WindowMessages.WM_WINDOWPOSCHANGED:
         IntPtr hdc = Win32.GetDC(m.HWnd);
         try
         {
             using (Graphics g = Graphics.FromHdc(hdc))
             {
                 Rectangle bounds = _owner.HeaderEndRect();
                 GDIHelper.InitializeGraphics(g);
                 GDIHelper.FillPath(g, new RoundRectangle(bounds, 0), this._owner._HeaderBeginColor, this._owner._HeaderEndColor);
                 bounds.Width--; bounds.Height--;
                 if (this._owner.BorderStyle != BorderStyle.None)
                 {
                     using (Pen p = new Pen(this._owner.BorderColor))
                     {
                         g.DrawLine(p, new Point(bounds.Left, bounds.Bottom), new Point(bounds.Left, bounds.Top));
                         g.DrawLine(p, new Point(bounds.Right, bounds.Bottom), new Point(bounds.Right, bounds.Top));
                         g.DrawLine(p, new Point(bounds.Left, bounds.Bottom), new Point(bounds.Right, bounds.Bottom));
                     }
                 }
                 else
                 {
                     GDIHelper.DrawPathBorder(g, new RoundRectangle(bounds, 0), this._owner._BorderColor);
                 }
             }
         }
         finally
         {
             Win32.ReleaseDC(m.HWnd, hdc);
         }
         break;
     }
 }
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  g         = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle      rect = e.AffectedBounds;
            CornerRadius   toolStripCornerRadius = new CornerRadius(this.MenuCornerRadius);
            RoundRectangle roundRect             = new RoundRectangle(rect, toolStripCornerRadius);

            if (toolStrip is ToolStripDropDown || toolStrip is ContextMenuStrip)
            {
                this.CreateToolStripRegion(toolStrip, roundRect);
                GDIHelper.FillPath(g, roundRect, this.BackColor, this.BackColor);
            }
            else if (toolStrip is TXMenuStrip)
            {
                TXMenuStrip ms = toolStrip as TXMenuStrip;
                Color       c1 = ms.BeginBackColor;
                Color       c2 = ms.EndBackColor;
                GDIHelper.FillPath(g, new RoundRectangle(rect, new CornerRadius(0)), c1, c2);
            }
            else if (toolStrip is TXToolStrip)
            {
                rect.Inflate(1, 1);
                TXToolStrip ts = toolStrip as TXToolStrip;
                Color       c1 = ts.BeginBackColor;
                Color       c2 = ts.EndBackColor;
                GDIHelper.FillPath(g, new RoundRectangle(rect, new CornerRadius(0)), c1, c2);
            }
            else if (toolStrip is TXStatusStrip)
            {
                TXStatusStrip ss = toolStrip as TXStatusStrip;
                Color         c1 = ss.BeginBackColor;
                Color         c2 = ss.EndBackColor;
                GDIHelper.FillPath(g, new RoundRectangle(rect, new CornerRadius(0)), c1, c2);
            }
        }
        protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  g         = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle rect = e.AffectedBounds;

            rect.Width -= 1; rect.Height -= 1;
            if (toolStrip is ToolStripDropDown)
            {
                rect.Width = this._OffsetMargin;
                Color          c = this.MenuImageMarginBackColor;
                CornerRadius   toolStripCornerRadius = new CornerRadius(this.MenuCornerRadius);
                RoundRectangle roundRect             = new RoundRectangle(rect, toolStripCornerRadius);
                GDIHelper.FillPath(g, new RoundRectangle(rect, new CornerRadius(this.MenuCornerRadius, 0, this.MenuCornerRadius, 0)), c, c);
                Image img = this.MenuImageBackImage;
                if (img != null && this.ShowMenuBackImage)
                {
                    ImageAttributes imgAttributes = new ImageAttributes();
                    GDIHelper.SetImageOpacity(imgAttributes, this.MenuImageBackImageOpacity);
                    g.DrawImage(Properties.Resources.logo_mini, new Rectangle(rect.X + 1, rect.Y + 2, img.Width, img.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imgAttributes);
                }

                ////绘制间隔线
                Point p1, p2;
                p1 = new Point(rect.X + this._OffsetMargin, rect.Y + 3);
                p2 = new Point(rect.X + this._OffsetMargin, rect.Bottom - 3);
                using (Pen pen = new Pen(SkinManager.CurrentSkin.BorderColor))
                {
                    g.DrawLine(pen, p1, p2);
                }
            }
            else
            {
                base.OnRenderImageMargin(e);
            }
        }
Exemple #28
0
        private void DrawTabPages(Graphics g)
        {
            Rectangle tabRect;
            Point     cusorPoint = PointToClient(MousePosition);
            bool      hover;
            bool      selected;
            bool      hasSetClip      = false;
            bool      alignHorizontal =
                (Alignment == TabAlignment.Top ||
                 Alignment == TabAlignment.Bottom);
            LinearGradientMode mode = alignHorizontal ?
                                      LinearGradientMode.Vertical : LinearGradientMode.Horizontal;

            if (alignHorizontal)
            {
                IntPtr upDownButtonHandle = UpDownButtonHandle;
                bool   hasUpDown          = upDownButtonHandle != IntPtr.Zero;
                if (hasUpDown)
                {
                    if (Win32.IsWindowVisible(upDownButtonHandle))
                    {
                        RECT upDownButtonRect = new RECT();
                        Win32.GetWindowRect(
                            upDownButtonHandle, ref upDownButtonRect);
                        Rectangle upDownRect = Rectangle.FromLTRB(
                            upDownButtonRect.left,
                            upDownButtonRect.top,
                            upDownButtonRect.right,
                            upDownButtonRect.bottom);
                        upDownRect = RectangleToClient(upDownRect);

                        switch (Alignment)
                        {
                        case TabAlignment.Top:
                            upDownRect.Y = 0;
                            break;

                        case TabAlignment.Bottom:
                            upDownRect.Y =
                                ClientRectangle.Height - DisplayRectangle.Height;
                            break;
                        }
                        upDownRect.Height = ClientRectangle.Height;
                        g.SetClip(upDownRect, CombineMode.Exclude);
                        hasSetClip = true;
                    }
                }
            }

            for (int index = 0; index < base.TabCount; index++)
            {
                TabPage page = TabPages[index];
                tabRect  = GetTabRect(index);
                hover    = tabRect.Contains(cusorPoint);
                selected = SelectedIndex == index;
                Color baseColor   = _BaseTabolor;
                Color borderColor = _BorderColor;
                Blend blend       = new Blend();
                blend.Positions = new float[] { 0f, 0.3f, 0.5f, 0.7f, 1.0f };
                blend.Factors   = new float[] { 0.1f, 0.3f, 0.5f, 0.8f, 1.0f };
                if (selected)
                {
                    baseColor = this._CheckedTabColor;
                }
                else if (hover)
                {
                    baseColor       = this._HeightLightTabColor;
                    blend.Positions = new float[] { 0f, 0.3f, 0.6f, 0.8f, 1f };
                    blend.Factors   = new float[] { .2f, 0.4f, 0.6f, 0.5f, .4f };
                }
                Rectangle exRect = new Rectangle(tabRect.Left, tabRect.Bottom, tabRect.Width, 1);
                g.SetClip(exRect, CombineMode.Exclude);
                CornerRadius cr = new CornerRadius(this._TabCornerRadius, this._TabCornerRadius, 0, 0);
                tabRect.X += this._TabMargin; tabRect.Width -= this._TabMargin;
                tabRect.Y++;
                tabRect.Height--;
                RoundRectangle roundRect = new RoundRectangle(tabRect, cr);
                GDIHelper.InitializeGraphics(g);
                switch (this._TabStyle)
                {
                case EnumTabStyle.AnglesWing:
                    cr         = new CornerRadius(this._TabCornerRadius);
                    tabRect.X += this._TabCornerRadius; tabRect.Width -= this._TabCornerRadius * 2;
                    roundRect  = new RoundRectangle(tabRect, cr);
                    using (GraphicsPath path = roundRect.ToGraphicsAnglesWingPath())
                    {
                        using (LinearGradientBrush brush = new LinearGradientBrush(roundRect.Rect, baseColor, this._BackColor, LinearGradientMode.Vertical))
                        {
                            brush.Blend = blend;
                            g.FillPath(brush, path);
                        }
                    }
                    using (GraphicsPath path = roundRect.ToGraphicsAnglesWingPath())
                    {
                        using (Pen pen = new Pen(this._BorderColor, 1))
                        {
                            g.DrawPath(pen, path);
                        }
                    }
                    break;

                case EnumTabStyle.Default:
                    GDIHelper.FillPath(g, roundRect, baseColor, this._BackColor, blend);
                    GDIHelper.DrawPathBorder(g, roundRect, this._BorderColor);
                    break;
                }

                g.ResetClip();
                if (this.Alignment == TabAlignment.Top)
                {
                    Image img     = null;
                    Size  imgSize = Size.Empty;
                    if (this.ImageList != null && page.ImageIndex >= 0)
                    {
                        img     = this.ImageList.Images[page.ImageIndex];
                        imgSize = img.Size;
                    }

                    GDIHelper.DrawImageAndString(g, tabRect, img, imgSize, page.Text, this._CaptionFont, this._CaptionForceColor);
                }
                else
                {
                    bool hasImage = DrawTabImage(g, page, tabRect);
                    DrawtabText(g, page, tabRect, hasImage);
                }
            }
            if (hasSetClip)
            {
                g.ResetClip();
            }
        }