Detecting whether or not Zune is connected when using photochooser task.

When a windows phone is connected to the computer and zune is open, apps on the phone can’t access the photos stored on the phone through the photochooser task. If zune is connected the photochooser task will immediately return with e.TaskResult set to TaskResult.Cancel, which is the same return value as if the user had decided not to pick a photo and just clicked the back button. This presents a problem when your app relies on the user picking an image and you need to know if the user changed their mind or needs to disconnect their phone.

There is a difference in the way the photochooser tasks returns when connected, other than returning extremely quickly. Normally when PhotoChooserTask.Show() is called, it fires off the standard navigation events. Then if the chooser exits without the user selecting a photo it returns with TaskResult.Cancel. However, if zune is connected, the navigation events are not fired and the task immediately return with TaskResult.Cancel.

What we can do is create a class level boolean which we use to determine if the picture chooser has been shown

private bool photoChooserShown;

Immediately before the picture chooser is called set it to false

photoChooserShown = false;

Then in the OnNavigatingFrom method if the URI of the page being navigated is outside of our app, then the picture chooser is being shown,

protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
            if (e.Uri.ToString() == "app://external/")
                photoChooserShown = true;

Finally, in the chooser task completed method, we can test to see if the app has navigated away from since we called the show method

void photoChooserTask_Completed(object sender, PhotoResult e)
        //zune not connected
        //zune connected
Posted in wp7Dev | Tagged , , , , | Comments closed

Applying Styles to Silverlight Controls

If you have several controls that you want to make look the same, instead of editing their properties individually, you can set them all at once with a style. Then if you change your mind you don’t have to edit the ‘Background’ property of 20 elements.

In your XAML just above your ‘LayoutRoot’ grid add a region for resources like this


Inside this block you can declare resources for the page such as Data Templates and Control Templates as well as styles. An style for a Grid can be declared like this:

<Style x:Key="GridStyle1" TargetType="Grid">
<Setter Property="Background" Value="#4CC8C8C8"/>
<Setter Property="VerticalAlignment" Value="Top"/>

The x:Key attribute defines a name that’s used when applying the style and the TargetType is the type of control that the style will be applied to.
Then, inside the <Style> tags, the individual properties can be set.

The style can then be applied to a Grid and all the properties set in the style will be applied to the control when your program is run.

<Grid Style="{StaticResource GridStyle1}">

The style can also be declared inside your applications App.xaml file, in the Application.Resources section. If you do that then your style can be accessed globally in your application and not just the page you declared it in.

Posted in wp7Dev | Comments closed

Moving from XNA to XNA/Silverlight hybrid on WP7

With the Mango update for WP7 you can now create “Windows Phone Silverlight and XNA Applications.” I’ve decided to make a game to make use of this Silverlight/XNA hybrid technology, with the main advantages I see being able to use the Silverlight web browser control in game for things like social network integration. However, as I don’t know any XAML, getting used to using it has been a bit challenging, so I’ve decided that I will post any things that I’ve had trouble with. What I post will probably be incredibly obvious to people who know any XAML whatsoever, but hopefully someone will find it useful.

So, the first thing I problem I enchountered when creating a Silverlight/XNA hybrid game is making it full screen.

Where there used to be this:

graphics = new GraphicsDeviceManager(this);
graphics.IsFullScreen = true;

there is now this at the top of you XAML:

SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"

The important bit is the last line. The system tray is the little bar that pops down if you tap near the top of your screen. If SystemTray.IsVisible is set to ‘True’, the bar is visible and your page will be slighlt shrunken as can be seen below. To get a propper full screen game it needs to be set to ‘False’, or since ‘False’ is the default, you can just delete that line. As you can see theres quite a difference.

XNA/Silverlight hybrid page rendered with SystemTray.IsVisible set to True

XNA/Silverlight hybrid page rendered with SystemTray.IsVisible set to False







Posted in wp7Dev | Tagged , , , , | Comments closed

New Game: Sort It!

I’ve just released a new game for WP7 called Sort It!. It’s a simple game, all you have to do is sort the shapes into the correct box. The challenge comes when the colours are removed so you need to look at the shapes, or when the colours of the shapes don’t match the colours of the boxes. Then you really need to concentrate.

Best of all its free!

Download it now, or click here for more information

Posted in News | Tagged , , | Comments closed

ERBY eReader v1.3 Released

ERBY eReader version 1.3 has been released. Updates in this version include:

  • Text-to-speech capabilities (Only availiable for some languages)
  • A translation history has been added
  • Significant speed improvements

You can get it from the WP7 Marketplace

Posted in News | Tagged , | Comments closed

ERBY Updates

ERBY version 1.2 has been submitted and should be available in a few days. It only includes a few minor fixes, the main being the problems with reading and translating Chinese text. Another fix regarding downloading books from Project Gutenberg has been implemented. Books with Chinese or other non-latin characters should now display correctly when downloaded. If you downloaded a book and it displayed incorrectly, please try downloading it again.

Posted in News | Tagged , , , | Comments closed

New App: ERBY eReader!

I have just release a new app to the WP7 marketplace. ERBY eReader is an ebook reader for Windows Phone 7. However it is made for those who are learning a foreign language. When reading a book, you can just tap on a word and get a tranlation. It is powered by Microsoft® Translator, so supports translating between 35 languages.

Here’s a video that shows you what it does. The song in the background is “Like the seasons” by Soundwryter

Posted in News | Tagged , , | Comments closed

Level Editor for Maze Escape

I have just submitted an update to Maze Escape with a new level editor. It should be availiable for download in a couple of days. With it you can now create your own mazes to play. I have also fixed a bug that sometimes resulted in duplicate high scores appearing in the high score table.

Posted in News | Tagged , , , , | Comments closed