System.Drawing.Graphics.FillRectangle C# (CSharp) Method

FillRectangle() public method

public FillRectangle ( Brush brush, Rectangle rect ) : void
brush Brush
rect Rectangle
return void
        public void FillRectangle(Brush brush, Rectangle rect)
        {
            if (brush == null)
                throw new ArgumentNullException ("brush");
            RectanglePath (new RectangleF(rect.X, rect.Y, rect.Width, rect.Height));
            FillBrush (brush);
        }

Same methods

Graphics::FillRectangle ( Brush brush, RectangleF rect ) : void
Graphics::FillRectangle ( Brush brush, float x1, float y1, float x2, float y2 ) : void
Graphics::FillRectangle ( Brush brush, int x1, int y1, int x2, int y2 ) : void

Usage Example

        public override void Draw(Graphics g, Pen p)
        {
            base.Draw(g, p);

            var r = this.RectangleF;

            var sText = g.MeasureString(this.ColouredPlace.ColorSetName, new Font("Arial", 8));
            g.FillRectangle(Brushes.Gray, r.Right, r.Top - sText.Height, sText.Width, sText.Height);

            g.DrawString(
                this.ColouredPlace.ColorSetName,
                new Font("Arial", 8),
                Brushes.Blue,
                r.Right,
                r.Top - sText.Height
            );

            var tokensString = this.ColouredPlace.Tokens.ToString();
            var f = new Font("", 7);
            sText = g.MeasureString(tokensString, f);

            g.FillRectangle(Brushes.Green, r.Right, r.Bottom, sText.Width, sText.Height);
            g.DrawString(
                tokensString,
                new Font("", 7),
                Brushes.Black,
                r.Right,
                r.Bottom
            );
        }
All Usage Examples Of System.Drawing.Graphics::FillRectangle