PushLayer(Rect) Method

Summary
Adds the specified layer to the surface so that it receives all subsequent drawing operations until PopLayer is called.
Syntax
C#
VB
C++
publicboolPushLayer(Rectrect)
PublicOverloadsFunctionPushLayer( _ByValrectAsRect _)AsBoolean
public:boolPushLayer(Rectrect)

Parameters

rect
The content rectangle mask for the layer.

Return Value

If this method succeeds, it returns true. Otherwise, it returns false.

Remarks

The PushLayer method allows a caller to begin redirecting drawing to a layer. All drawing operations are valid in a layer. The location of the layer is affected by the transform set on the surface.

Each PushLayer must have a matching PopLayer call. If there are more PopLayer calls than PushLayer calls, the EndDraw return false indicates that an error occurs.

Example
C#
VB
usingLeadtools.Windows.D2DRendering;publicvoidD2DSurfacePushLayerExample(){//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 an ellipse geometryEllipseGeometry ellipse =newEllipseGeometry();ellipse.Center =newPoint(500, 500);ellipse.RadiusX = 100;ellipse.RadiusY = 100;GeometryGroup geometryGroup =newGeometryGroup();geometryGroup.Children.Add(ellipse);//Push geometry to receive all subsequent drawing operationsd2dSurface.PushLayer(geometryGroup);//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 brushSolidColorBrush fill =newSolidColorBrush(Colors.Green);//Clear the pushed Layer with the fill brushd2dSurface.Clear(fill);//Stop redirecting drawing operations to the layerd2dSurface.PopLayer ();//Restore the surface drawing stated2dSurface.Restore(drawingState);//End the Draw operation and invalidate the surfaced2dSurface.EndDraw();d2dSurface.Invalidate(Rect.Empty);}
ImportsLeadtools.Windows.D2DRenderingPublicSubD2DSurfacePushLayerExample()'Create a new instance of a 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 an ellipse geometryDimellipseAsEllipseGeometry =NewEllipseGeometry()ellipse.Center =NewPoint(500, 500)ellipse.RadiusX = 100ellipse.RadiusY = 100DimgeomeTryGroupAsGeometryGroup =NewGeometryGroup()geomeTryGroup.Children.Add(ellipse)'Push the geometry object to receive all subsequent drawing operationsd2dSurface.PushLayer(geomeTryGroup)'Create a rectangle having the specified dimensionsDimrectAsRect =NewRect(40, 40, 500, 200)'Create a new instance of a brush from a new solid color brushDimfillAsSolidColorBrush =NewSolidColorBrush(Colors.Green)'Clear the pushed Layer with the fill brushd2dSurface.Clear(fill)'Stop redirecting drawing operations to the layerd2dSurface.PopLayer ()'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.