←Select platform

FillRectangle(Brush,Rect) Method

Summary

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

Syntax
C#
VB
C++
publicvoidFillRectangle(Brushbrush,Rectrect)
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.

Remarks

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

Example
C#
VB
usingLeadtools.Windows.D2DRendering;publicvoidD2DSurfaceExample(){//Create a new instance of the D2DSurface objectD2DSurface d2dSurface =newD2DSurface();//Set the surface Sized2dSurface.SurfaceSize =newSize(1000, 1000);//Pass an empty rect to redraw the entire surfaced2dSurface.BeginDraw(Rect.Empty);//Save the surface drawing stateD2DDrawingState drawingState = d2dSurface.Save();//Create a rect having the specified dimensionsRect rect =newRect(40, 40, 500, 200);//Create a new instance of a brush from a new solid color brushBrush fill =newSolidColorBrush(Colors.Green);//Fill the interior of the specified rectangle using the specified brushd2dSurface.FillRectangle(fill, rect);//Create a new instance of the D2DPen objectD2DPen pen =newD2DPen(newSolidColorBrush(Colors.Red), 2);//Draw an outline using the specified rectangle and D2DPend2dSurface.DrawRectangle(pen, rect);//Restore the surface drawing stated2dSurface.Restore(drawingState);//End the Draw operation and invalidate the surfaced2dSurface.EndDraw();d2dSurface.Invalidate(Rect.Empty);}
ImportsLeadtools.Windows.D2DRenderingPublicSubD2DSurfaceExample()'Create new instance of D2DSurfaceDimd2dSurfaceAsD2DSurface =NewD2DSurface()'Set the surface Sized2dSurface.SurfaceSize =NewSize(1000, 1000)'Pass an empty rectangle to redraw the whole surfaced2dSurface.BeginDraw(System.Windows.Rect.Empty)'Save the surface drawing stateDimdrawingStateAsD2DDrawingState = d2dSurface.Save()'Create a rectangle with the specified dimensionsDimrectAsRect =NewRect(40, 40, 500, 200)创建一个新的实例of a brush from a new solid color brushDimfillAsBrush =NewSolidColorBrush(Colors.Green)'Fill the interior of the specified rectangle using the specified brushd2dSurface.FillRectangle(fill, rect)创建一个新的实例of D2DPenDimpenAsD2DPen =NewD2DPen(NewSolidColorBrush(Colors.Red), 2)'Draw an Outline of the specified rectangle using the D2DPend2dSurface.DrawRectangle(pen, rect)'Restore the surface drawing stated2dSurface.Restore(drawingState)'End the Draw operation and invalidate the surfaced2dSurface.EndDraw()d2dSurface.Invalidate(System.Windows.Rect.Empty)EndSub
Requirements
Target Platforms
Leadtools.Windows.D2DRendering Assembly
188金宝搏的网址客服|Support|Contact Us|Intellectual Property Notices
© 1991-2021LEAD Technologies, Inc.All Rights Reserved.