PushLayer(Rect) Method
Summary
Adds the specified layer to the surface so that it receives all subsequent drawing operations until PopLayer is called.
Syntax
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.
Example
usingLeadtools.Windows.D2DRendering;
publicvoidD2DSurfacePushLayerExample()
{
//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 an ellipse geometry
EllipseGeometry 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 operations
d2dSurface.PushLayer(geometryGroup);
//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
SolidColorBrush fill =newSolidColorBrush(Colors.Green);
//Clear the pushed Layer with the fill brush
d2dSurface.Clear(fill);
//Stop redirecting drawing operations to the layer
d2dSurface.PopLayer ();
//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
PublicSubD2DSurfacePushLayerExample()
'Create a new instance of a 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 an ellipse geometry
DimellipseAsEllipseGeometry =NewEllipseGeometry()
ellipse.Center =NewPoint(500, 500)
ellipse.RadiusX = 100
ellipse.RadiusY = 100
DimgeomeTryGroupAsGeometryGroup =NewGeometryGroup()
geomeTryGroup.Children.Add(ellipse)
'Push the geometry object to receive all subsequent drawing operations
d2dSurface.PushLayer(geomeTryGroup)
'Create a rectangle having the specified dimensions
DimrectAsRect =NewRect(40, 40, 500, 200)
'Create a new instance of a brush from a new solid color brush
DimfillAsSolidColorBrush =NewSolidColorBrush(Colors.Green)
'Clear the pushed Layer with the fill brush
d2dSurface.Clear(fill)
'Stop redirecting drawing operations to the layer
d2dSurface.PopLayer ()
'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