Life with Visio and other Microsoft Toys!

Which way is up?

leave a comment »

I have been programing for decades and fell into a rut with VBA. It was so easy to code. With the introduction of WP7 I bit the bit the bullet and took another look at C#. I had played with C when it first came out (that is the original C with no qualifiers ūüėČ ), but I found it almost as cryptic as APL.

With WP7 most of the examples of testing for orientation involved

if ( ( e.Orientation == PageOrientation.LandscapeRight ) || ( e.Orientation == PageOrientation.LandscapeLeft ) )
// do something for landscape orientation

Since there is no PortraitDown orientation, this could be simplied by just checking for PortraitUp. Of course, we have no guarantee that any future version of WP7 will never have a PortraitDown orientation, so we will just have to continue testing for all cases.

Today, I did come across an alternate, but because of its’ style, verges on being APL like and would need some comments.

if ( ( e.Orientation & PagePrientation.Landscape ) != 0 )
// do something for landscape orientation

this will also work…

if ( ( e.Orientation & PagePrientation.Portrait ) != 0 )
// do something for portrait orientation

Definitely something I have added to my bag of tricks. It does not matter if they introduce PortraitDown orientation.

John Marshall… Visio MVP¬†¬†¬†¬†¬†¬†

Written by johnvisiomvp

June 25, 2011 at 1:51 am

Posted in Windows Phone 7, WP7

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: