FillRectangle(Brush,Rect) Method
Summary
Fills the interior of a rectangle that has the specified dimensions and the specified brush.
Syntax
PublicSubFillRectangle(
ByValbrushAsBrush,
ByValrectAsRect
)
public:
voidFillRectangle(
Brush^brush,
Rect^rect
)
Parameters
brush
The brush used to fill the rectangle's interior.
rect
The dimensions of the rectangle to draw.
Example
usingLeadtools.Windows.D2DRendering;
publicvoidD2DSurfaceExample()
{
//Create a new instance of the D2DSurface object
D2DSurface d2dSurface =newD2DSurface();
//Set the surface Size
d2dSurface.SurfaceSize =newSize(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 =newRect(40, 40, 500, 200);
//Create a new instance of a brush from a new solid color brush
Brush fill =newSolidColorBrush(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 =newD2DPen(newSolidColorBrush(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);
}
ImportsLeadtools.Windows.D2DRendering
PublicSubD2DSurfaceExample()
'Create new instance of D2DSurface
Dimd2dSurfaceAsD2DSurface =NewD2DSurface()
'Set the surface Size
d2dSurface.SurfaceSize =NewSize(1000, 1000)
'Pass an empty rectangle to redraw the whole surface
d2dSurface.BeginDraw(System.Windows.Rect.Empty)
'Save the surface drawing state
DimdrawingStateAsD2DDrawingState = d2dSurface.Save()
'Create a rectangle with the specified dimensions
DimrectAsRect =NewRect(40, 40, 500, 200)
创建一个新的实例of a brush from a new solid color brush
DimfillAsBrush =NewSolidColorBrush(Colors.Green)
'Fill the interior of the specified rectangle using the specified brush
d2dSurface.FillRectangle(fill, rect)
创建一个新的实例of D2DPen
DimpenAsD2DPen =NewD2DPen(NewSolidColorBrush(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)
EndSub