Drawingcontext.pop Method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.