Exemple #1
0
        /// <summary>
        /// 重绘
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g      = e.Graphics;
            int      radius = 1;

            int width  = this.ClientRectangle.Width;
            int height = this.ClientRectangle.Height;

            if (width % 2 != 0)
            {
                width++;
            }
            if (height % 2 != 0)
            {
                height++;
            }
            this.Width  = width;
            this.Height = height;

            Rectangle clientRect = new Rectangle(new Point(0, 0), new Size(width, height));

            GraphicsPath gp = DrawRectUtil.CreatePath(clientRect, radius, RoundStyle.All, true);

            g.SmoothingMode = SmoothingMode.HighQuality;
            //绘制背景
            g.FillPath(new SolidBrush(Color.White), gp);
            //绘制阴影
            e.Graphics.DrawLine(new Pen(Color.FromArgb(50, _BorderColor), 2), 1, 1, clientRect.Width - 1, 1);
            //绘制圆角
            g.DrawPath(new Pen(_BorderColor), gp);
        }
Exemple #2
0
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            bool chk = false;

            chk = (e.Item as ToolStripButton).Checked;
            if (e.Item.Pressed && e.Item.Selected)
            {
                i = 2;
            }
            else if (e.Item.Selected)
            {
                i = 1;
            }
            else if (chk)
            {
                i = 2;
            }
            else
            {
                i = 0;
            }
            DrawRectUtil.DrawRect(e.Graphics, backImg, new Rectangle(Point.Empty, e.Item.Size), Rectangle.FromLTRB(5, 15, 5, 5), i, 2);
        }