←Select platform

FillRectangle(Brush,float,float,float,float) Method

Summary

Fills the interior of a rectangle that has the specified dimensions and the specified brush.

Syntax
C#
VB
C++
public void FillRectangle( 
   Brush brush, 
   float x, 
   float y, 
   float width, 
   float height 
) 
Public Sub FillRectangle( 
   ByVal brush As Brush, 
   ByVal x As Single, 
   ByVal y As Single, 
   ByVal width As Single, 
   ByVal height As Single 
) 
public:  
   void FillRectangle( 
      Brush^ brush, 
      Single x, 
      Single y, 
      Single width, 
      Single height 
   ) 

Parameters

brush

The brush used to fill the rectangle's interior.

x

The x-coordinate of the upper-left corner of the rectangle to draw.

y

The y-coordinate of the upper-left corner of the rectangle to draw.

width

Width of the rectangle to draw.

height

Height of the rectangle to draw.

Remarks

FillRectangle(Brush,float,float,float,float) fills the interior of a rectangle with the specified brush.

Example
C#
VB
using Leadtools.Windows.D2DRendering; 
 
public void D2DSurfaceExample() 
{ 
   //Create a new instance of the D2DSurface object 
   D2DSurface d2dSurface = new D2DSurface(); 
 
   //Set the surface Size 
   d2dSurface.SurfaceSize = new Size(1000, 1000); 
 
   //Pass an empty rect to redraw the entire surface 
   d2dSurface.BeginDraw(Rect.Empty); 
 
   //Save the surface drawing state 
   D2DDrawingState drawingState = d2dSurface.Save(); 
 
   //Create a rect having the specified dimensions 
   Rect rect = new Rect(40, 40, 500, 200); 
 
   //Create a new instance of a brush from a new solid color brush 
   Brush fill = new SolidColorBrush(Colors.Green); 
 
   //Fill the interior of the specified rectangle using the specified brush 
   d2dSurface.FillRectangle(fill, rect); 
 
   //Create a new instance of the D2DPen object 
   D2DPen pen = new D2DPen(new SolidColorBrush(Colors.Red), 2); 
 
   //Draw an outline using the specified rectangle and D2DPen 
   d2dSurface.DrawRectangle(pen, rect); 
 
   //Restore the surface drawing state 
   d2dSurface.Restore(drawingState); 
 
   //End the Draw operation and invalidate the surface 
   d2dSurface.EndDraw(); 
 
   d2dSurface.Invalidate(Rect.Empty); 
} 
Imports Leadtools.Windows.D2DRendering 
 
 
Public Sub D2DSurfaceExample() 
   'Create new instance of D2DSurface 
   Dim d2dSurface As D2DSurface = New D2DSurface() 
 
   'Set the surface Size 
   d2dSurface.SurfaceSize = New Size(1000, 1000) 
 
   'Pass an empty rectangle to redraw the whole surface 
   d2dSurface.BeginDraw(System.Windows.Rect.Empty) 
 
   'Save the surface drawing state 
   Dim drawingState As D2DDrawingState = d2dSurface.Save() 
 
   'Create a rectangle with the specified dimensions 
   Dim rect As Rect = New Rect(40, 40, 500, 200) 
 
   'Create a new instance of a brush from a new solid color brush 
   Dim fill As Brush = New SolidColorBrush(Colors.Green) 
 
   'Fill the interior of the specified rectangle using the specified brush 
   d2dSurface.FillRectangle(fill, rect) 
 
   'Create a new instance of D2DPen 
   Dim pen As D2DPen = New D2DPen(New SolidColorBrush(Colors.Red), 2) 
 
   'Draw an Outline of the specified rectangle using the D2DPen 
   d2dSurface.DrawRectangle(pen, rect) 
 
   'Restore the surface drawing state 
   d2dSurface.Restore(drawingState) 
 
   'End the Draw operation and invalidate the surface 
   d2dSurface.EndDraw() 
 
   d2dSurface.Invalidate(System.Windows.Rect.Empty) 
End Sub 
Requirements
Target Platforms
Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Windows.D2DRendering Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.