The following example shows the effect of the POP command.
usingSystem;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Media;usingSystem.Windows.Media.Animation;usingSystem.Windows.Navigation;namespacesdksample{ Public classPopexample:page { Publicpopexample () {Pen Shapeoutlinepen=NewPen (Brushes.black,2); Shapeoutlinepen.freeze (); //Create a DrawingGroupDrawingGroup DGroup =NewDrawingGroup (); //obtain a drawingcontext from//The drawinggroup. using(DrawingContext DC =Dgroup.open ()) { //Draw a rectangle at full opacity.dc. DrawRectangle (Brushes.blue, Shapeoutlinepen,NewRect (0,0, -, -)); //Push An opacity change of 0.5. //The opacity of each subsequent drawing would//Would be multiplied by 0.5.dc. Pushopacity (0.5); //This rectangle are drawn at 50% opacity.dc. DrawRectangle (Brushes.blue, Shapeoutlinepen,NewRect ( -, -, -, -)); //Push An opacity change of 0.5. //The opacity of each subsequent drawing would//Would be multiplied by 0.5. Note that//Push Operations is cumulative (until they is//popped). dc. Pushopacity (0.5); //This rectangle are drawn at 25% opacity (0.5 x 0.5).dc. DrawRectangle (Brushes.blue, Shapeoutlinepen,NewRect ( -, -, -, -)); //changes the opacity back to 0.5.DC. Pop (); //This rectangle are drawn at 50% opacity.dc. DrawRectangle (Brushes.blue, Shapeoutlinepen,NewRect ( the, the, -, -)); //changes the opacity back to 1.0.DC. Pop (); //This rectangle are drawn at 100% opacity.dc. DrawRectangle (Brushes.blue, Shapeoutlinepen,NewRect ( -, -, -, -)); } //Display the drawing using an image control.Image theimage =NewImage (); Drawingimage Dimagesource=Newdrawingimage (DGroup); Theimage.source=Dimagesource; This. Content =theimage; } }}
The following illustration shows this example ' s output:
Drawingcontext.pop Method