コード例 #1
0
        /// <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;
            }
        }
コード例 #2
0
ファイル: TXCheckBox.cs プロジェクト: menglou/winformyunche
        /// <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;
            }
        }