Tuesday, December 7, 2010

Windows Phone 7 Quick Tip #24 – Hide the Status Bar in your XNA Application

To hide the status bar:

image

Simply set the property IsFullScreen on the GraphicsDeviceManager instance to true:

public Game1()
{
    graphics = new GraphicsDeviceManager(this);
    graphics.IsFullScreen = true;

Not only will this let your application take advantage of the full height of the device and not display the status bar it also will fill the width of your device to maintain the proper aspect ratio.  Let me explain.  If you specify your PreferredBackBuffer Width and Height to be 480x800 and not hide the status bar, there will be a margin on both the right and left of your screen.  Your screen will maintain your aspect ratio of 3/5.  This means since the height of your screen is not actually 800 pixels (because the status bar takes up a portion of the top of the screen), to maintain the aspect ratio, your width won’t be 480. 

This is especially obvious when you use Snippet in Windows Mode to capture a screen shot of your application, you will see a black border across the top and sides of your screen.  Setting graphics.IsFullScreen = true will allow your applications height to be 800 and thus the width will be 480 maintaining the correct aspect ratio and making the full use of the real-estate on the device.

-twb

Jingle Balls – A Christmas Windows Phone 7 Application

This morning the follow-up to my smash hit GotBalls! (which DevFish can’t see nearly enough good things about) was published to the Windows Phone Marketplace.

Jingle Balls is a nice little XNA application to help you get in the holiday spirit.

Enjoy!

-twb

Windows Phone 7 Quick Tip #23 – Determine if you are running on the Emulator or a Device

When you are developing your Windows Phone 7 application you might want to know if you are running on an emulator or on the device.  Fortunately there’s a property for that:

Microsoft.Devices.Environment.DeviceType

It can have the values:

Microsoft.Devices.DeviceType.Device
Microsoft.Devices.DeviceType.Emulator

So a simple check of:

if(Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Device)
             MessageBox.Show(“On the emulator”);

will let you know that you are on the emulator.

-twb

Windows Phone 7 – GPS Simulator

A couple of months ago, I released a link on this blog to the source code for a project I created to simulate GPS on a Windows Phone 7.  This is now packaged up to make it easier to use and has been deployed to codeplex.  This can be found at http://wp7gps.codeplex.com.

Usage is described on the site but is straight forward, include FakeGPS.cs within your Windows Phone 7 project, modify your GeoPositionWatcher code to use the simulator and then build the route on the Silverlight control on the CodePlex site.

For a post on how to get started with location services within your application check out this getting started guide.

-twb