Sunday, November 28, 2010

Windows Phone 7 Quick Tip #22 – Force Orientation in an XNA Game

While creating a Windows Phone 7 XNA game that uses the accelerometer, I noticed that as I tilted and rotated my phone, the screen orientation would switch from Landscape Left to Landscape Right, this obviously made the game a little difficult to play.

To resolve this, I simply changed the SupportedOrientations property on the graphics instance.  By default this is set to a landscape where the orientation changed based upon accelerometer input.  Adding the following line of code to my constructor resolved the issue.

graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft;

-twb

Windows Phone 7 Quick Tip #21 – Good Vibrations

Not an earth shattering tip this time, but I just spent the last 30 minutes “binging” how to make my phone vibrate and didn’t come up with anything.

As with most stuff in programming, it’s easy once you know how:

  1. Add a reference to Microsoft.Phone (if you are working in XNA and don’t already have one)
  2. Then call Start on Microsoft.Devices.VibrateController.Default with the number of milliseconds you want the phone to vibrate.

-twb

Saturday, November 20, 2010

Windows Phone 7 Quick Tip #20 - Use ShellTileSchedule to easily update your Live Tiles

Live tiles are an important and key feature of Windows Phone 7.  You can create personalized Live Tiles using the notification services.  Although this isn’t terribly difficult it does require a bit of programming and at a minimum a simple server side service and some sort of persistence to track subscriptions on the server.

A simple option to update your Live Tiles is to use ShellTileSchedule to refresh your applications Live Tile.  This can be done in just a few lines of code:

var mySchedule = new ShellTileSchedule
{
    Interval = UpdateInterval.EveryHour,
    Recurrence = UpdateRecurrence.Interval,
    RemoteImageUri = new Uri(@
http://www.mysite.com/background.png,
                                       UriKind.Absolute)
};
mySchedule.Start();

Then all you need to do is setup some sort of process to update the live tile on the server, which in our case is at the fictional site http://www.mysite.com/background.png.  Your graphic should be the traditional 173x173 and must be smaller than 80kb.  Also if downloading the image takes more than fifteen seconds the operation will be aborted.  Finally if the operation fails more than three times, SchellTileSchedule will stop checking, until SchellTileSchedule.Start() is called again.

Please don’t stop reading yet

If you use ShellTileSchedule, you MUST add the following to your WMAppManifest.xml file.


<Capability Name="ID_CAP_PUSH_NOTIFICATION"/>



Even though this technically isn’t a Push Notification, you will get an InvalidOperationException when you call mySchedule.Start() without adding this capability.


Keep Reading!



UPDATED: 11/28/2010



Last week I submitted an application that used the above technique.  Even though it didn’t use any sort of “push-notifications” per-se I did have to add the ability to enable/disable and let the user opt out of doing this update via my applications user interface to get my application certified.




-twb


Tuesday, November 9, 2010

Florida Windows Phone 7 Applications

My company, Software Logistics, LLC was proud to create and will be hosting a Silverlight 4 application that will allow us in the Florida .NET developer community to post our Windows Phone 7 applications.

Find the site at http://www.flwp7.com.

Creating your application is only half the work, the other half is letting people know about it.  The goal of this site is to provide a forum where we can help each other in Florida Developer Community to spread the word about our applications.

In version one, we just provide a place for you to add your applications, as well as see who else has apps so you can download and add a rating.

In version two, we will extend the facebook integration so you can update your wall with a deep zoom link and a comment.

In version three…well I’m still looking for feedback :)

Enjoy and please send any feedback to wp7@software-logisitics.com

-twb

Windows Phone 7 Quick Tip #19 – Use custom images on the WP7 emulator

By default there are a number of pictures installed on your Windows Phone 7 emulator.  I needed to add some custom pictures to shoot some video and the defaults just were not appropriate.

To add your custom pictures just add them to a web site (or search for them on the web) then open up Internet Explorer, find your web side, press-and-hold the image, that will save the image to the picture hub (even though you can’t see that on the emulator).  Then you can use a picker within your application to select the image you downloaded from the web.

These pictures will be removed from your emulator when it is shut down.

-twb

Windows Phone Quick Tip #18 – Fiddler and WP7 Emulator

Sorry for the time off from the tips, bizy, bizy, bizy on non Windows Phone 7 related work.  So sad :(

Anyway – here’s a quick one that might save you a little bit of time and a few gray (or lost) hair.

If you are using fiddler on your desktop machine and then fire up your Windows Phone 7 Emulator, the emulator won’t be able to connect to the internet. 

Even if you quit fiddler, you will need to restart your emulator before you can connect.

-twb