Exercise: Create a polygon and rotate, translate and scale it

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend the Wise Owl course listed below!

Category ==> WPF - Visual C#  (20 exercises)
Topic ==> Drawing and transformations  (1 exercise)
Level ==> Average difficulty
Course ==> WPF using Visual C#

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Create a new form called Transformers (what else?), and create a polygon within it:

Polygon with radial gradient

The Points propert of the polygon contains a set of X,Y coordinate values.

 

Now put this in a WrapPanel (again, don't bother about the labels) and create the following transforms:

Transforms on polygon

The table overleaf gives notes on what to do for each transform.

Here are the transforms to create:

Shape Transforms
2nd shape A layout transform, rotating the polygon with an Angle property of 45 degrees.
3rd shape A render transform consisting of a transformation group, containing scaling with ScaleX and ScaleY both set to 0.5 and translating with Y set to 150 (ie moving down).

Note that because the last transform is a render one, space is allocated to the polygon and then it's moved and scaled, so the shape lies on top of the text.

This page has 0 threads Add post