FillRoundedRectangle() public static method

public static FillRoundedRectangle ( Graphics, graphics, Brush, brush, Rectangle, bounds, int cornerRadius ) : void
graphics Graphics,
brush Brush,
bounds Rectangle,
cornerRadius int
return void
Exemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            Brush brush = new SolidBrush(_isHovering ? _onHoverBorderColor : _borderColor);

            brush.Dispose();
            brush = new SolidBrush(_isHovering ? _onHoverButtonColor : _buttonColor);

            RectangleF myRectangleF = new RectangleF(0F, 0F, Width - 3, Height - 3);

            Rectangle roundedRectangle = Rectangle.Round(myRectangleF);

            Pen redPen = new Pen(brush, 1);

            RoundedRectangle.FillRoundedRectangle(e.Graphics, brush, roundedRectangle, 5);

            brush.Dispose();
            brush = new SolidBrush(_isHovering ? _onHoverTextColor : _textColor);

            SizeF stringSize = g.MeasureString(Text, Font);

            g.DrawString(Text, Font, brush, ((Width) - stringSize.Width) / 2, ((Height) - stringSize.Height) / 2);
        }
 private void DrawForm(object pSender, EventArgs pE)
 {
     using (Bitmap backImage = new Bitmap(this.Width, this.Height))
     {
         using (Graphics graphics = Graphics.FromImage(backImage))
         {
             Rectangle gradientRectangle = new Rectangle(0, 0, this.Width - 1, this.Height - 1);
             using (Brush b = new LinearGradientBrush(gradientRectangle, Color.DarkSlateBlue, Color.MediumPurple, 0.0f))
             {
                 graphics.SmoothingMode = SmoothingMode.HighQuality;
                 RoundedRectangle.FillRoundedRectangle(graphics, b, gradientRectangle, 35);
                 foreach (Control ctrl in this.Controls)
                 {
                     using (Bitmap bmp = new Bitmap(ctrl.Width, ctrl.Height))
                     {
                         Rectangle rect = new Rectangle(0, 0, ctrl.Width, ctrl.Height);
                         ctrl.DrawToBitmap(bmp, rect);
                         graphics.DrawImage(bmp, ctrl.Location);
                     }
                 }
                 PerPixelAlphaBlend.SetBitmap(backImage, Left, Top, Handle);
             }
         }
     }
 }
 protected override void OnPaint(PaintEventArgs e)
 {
     if (DesignMode)
     {
         Graphics graphics = e.Graphics;
         Rectangle gradientRectangle = new Rectangle(0, 0, this.Width - 1, this.Height - 1);
         Brush b = new LinearGradientBrush(gradientRectangle, Color.DarkSlateBlue, Color.MediumPurple, 0.0f);
         graphics.SmoothingMode = SmoothingMode.HighQuality;
         RoundedRectangle.FillRoundedRectangle(graphics, b, gradientRectangle, 35);
     }
     base.OnPaint(e);
 }
Exemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            g.SmoothingMode          = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            Brush brush = new SolidBrush(_flowPanelColor);

            RectangleF myRectangleF = new RectangleF(0F, 0F, Width - 3, Height - 3);

            Rectangle roundedRectangle = Rectangle.Round(myRectangleF);

            Pen redPen = new Pen(brush, 1);

            RoundedRectangle.FillRoundedRectangle(e.Graphics, brush, roundedRectangle, 5);

            brush.Dispose();
        }