Shove HalfPenny

 

Got myself a real live Shove HalfPenny board from eBay today – figured that it would be a great family activity over the Summer break, the kids are off school for 6 weeks so we are holding our own ‘Shove HalfPenny championship’!

On a dev note its Perhaps just as well that  I got a ‘real board’ as I now realise that the boundaries between the beds (the scoring area) is not raised as I had remembered  (I guess there is just no substitute for real hardware!)

Still waiting to hear back from MS on the turn by turn support (is there anybody there?).

Currently in the middle of adding multiple language support to all six of my existing phone apps & praying that I will get a device to help with multi touch input ‘real soon’.

http://apps.webservicesuk.com/shove

Press Summary

  • 25/08/2010 – PocketPC live – Short review of Metro Drummer.

http://pocketpc-live.com/utilities/-drummer-app-for-windows-phone-7.html

  • 23/08/2010 – PocketNow.com – Short review of Metro Drummer.

http://pocketnow.com/windows-phone/metro-drummer-percussion-app-for-windows-phone-7

  • 6/08/2010 – Computer Weekly (asked to comment on W7/Silverlight/WP7/tablet development.

http://www.computerweekly.com/Articles/2010/08/06/242283/Windows-7-proves-a-hit-with-developers.htm 

  • 23/07/2010 – The Silverlight Show (Reference to this blog & “Nuke Your Office” WP7 App).

Silverlight & XNA together on WP7

  • 23/07/2010 – Mobile Tech World (Shove Ha’penny Review)

http://www.mobiletechworld.com/2010/07/23/windows-phone-7-shuffleboard-game/

  • 23/07/2010 – Buzz Games (Silverlight & XNA together)

http://buzzgamesnews.blogspot.com/2010/07/silverlight-xna-together-on-wp7.html

  • 09/07/2010 – Silverlight.Net Community Sample (Shove)

http://www.silverlight.net/community/samples/silverlight-samples/shove-halfpenny-35732/

  • 09/07/2010 – Silverlight.Net News Article (reference to above post)

http://www.silverlight.net/news/

  • 30/06/2010 – YouTube (Promo re MS call for developer devices)

You Tube Video

  • 24/06/2010 – WMExperts.com (article on ‘Social Networking’ mentions Nuke Your Office)

http://www.wmexperts.com/wp7-social-networking-buttons-nuke-your-office

  • 24/06/2010 – Mobility Digest (pick up on WMExperts article)

http://windowsphone.mobilitydigest.com/wp7-social-networking-addons-and-some-games/

  • 24/04/2010 – Expression Web Site (Puzzlegram sample published)

http://gallery.expression.microsoft.com/en-us/Puzzlegram 

  • 06/04/2010 Silverlight.Net  (‘Spot The Difference’ WP7 prototype)

http://www.silverlight.net/community/samples/silverlight-4/spot-the-difference-34714/

  • 10/03/2010 – Expression Web Site (Spot The Difference sample published)

http://gallery.expression.microsoft.com/en-us/SpotTheDifference

Silverlight Sites on Symbian S60 (Tested on Nokia N97)

 

BING Toolbar Functionality

BINGBING 2BING 3BING 4

NB The development team has a blog post here:

http://blogs.msdn.com/b/slsymbian/archive/2010/04/05/silverlight-for-symbian-development-experience.aspx


I will add to this list as I come across sites that work on the N97.  Please leave a comment if you would like to suggest a site that you know works well on Symbian S60.


UPDATE: I note from the dev team post here that there is an issue with the HTML hosting of Silverlight on N97 devices.

NB I have asked the team who look after the Community Samples at Silverlight.Net if they would update the hosting code for Sl1 & 2 based samples.

Update: My Bad, they are only pointing to the contributions, not hosting them as I had originally thought.

Silverlight & XNA together on WP7

 

I am developing most of my WP7 apps in Silverlight 3, then doing whatever porting is necessary to get them running on WP7 (the final stage is then optimising for WP7, but that’s another story).   ‘Nuke Your Office’ (http://apps.webservicesuk.com/NukeYourOffice) has a lot going on sound-wise (multiple WMA files fired at random and in parallel).  All was fine in SL3 but when I moved to WP7 I realised that I had an issue with performance.  I recalled reading something about being able to use XNA functionality for playing sounds within Silverlight/WP7 –  A little searching  later and I came across the “Physics helper Library” that already contained just the functionality I was looking for.  Within the downloadable source code there is a file called SOUNDMAIN.CS.  All that is required is to include this file in your Silverlight Desktop and/or WP7 Silverlight project and provide a reference to the following XNA libraries:

using Microsoft.Xna.Framework.Audio;
using System.IO;
using Microsoft.Xna.Framework;

Then, after setting up your sound files:

#if WINDOWS_PHONE
           Whistle = new SoundMain(this.LayoutRoot, "sounds/bomb.wav", 2, 0);
           Whistle2 = new SoundMain(this.LayoutRoot, "sounds/bomb2.wav", 2, 0);
           Explosion1 = new SoundMain(this.LayoutRoot, "sounds/Explosion1.wav", 2, 0);
           Explosion2 = new SoundMain(this.LayoutRoot, "sounds/Explosion2.wav", 2, 0);
           Explosion3 = new SoundMain(this.LayoutRoot, "sounds/Explosion3.wav", 2, 0);
           Siren = new SoundMain(this.LayoutRoot, "sounds/AirRaid.wav", 2, 0);
           CrackGlass = new SoundMain(this.LayoutRoot, "sounds/GlassCracking.wav", 2, 0);
#else
            Whistle = new SoundMain(this.LayoutRoot, "sounds/bomb.wma", 2, 0);
            Whistle2 = new SoundMain(this.LayoutRoot, "sounds/bomb2.wma", 2, 0);
            Explosion1 = new SoundMain(this.LayoutRoot, "sounds/Explosion1.wma", 2, 0);
            Explosion2 = new SoundMain(this.LayoutRoot, "sounds/Explosion2.wma", 2, 0);
            Explosion3 = new SoundMain(this.LayoutRoot, "sounds/Explosion3.wma", 2, 0);
            Siren = new SoundMain(this.LayoutRoot, "sounds/AirRaid.wma", 2, 0);
            CrackGlass = new SoundMain(this.LayoutRoot, "sounds/GlassCracking.wma", 2, 0);
#endif

You can play them within your code as follows:

Whistle.Play();

NB the only limitation is that the sound files for WP7 and XNA must be in WAV format (WMA is not supported under XNA on WP7).


My thanks to Andy Beaulieu and the other developers on the CodePlex site http://physicshelper.codeplex.com/

Please ensure that you are familiar with the licensing conditions if you plan on using this code in your own app.

WP7 Launchers

Launchers are a set of APIs that Windows Phone applications can use to enable common tasks such as making a phone call or sending an email. Unlike Choosers, Launchers do not return a value back to the calling application.

Using Launchers in Your Application.


The Launcher APIs are belong to the Microsoft.Phone.Tasks namespace. You need to add a using directive for this namespace to the PhoneApplicationPage class file. All of the Launcher APIs function in a similar manner. First, you create an instance of the Launcher class you wish to use. Next, you set properties of the Launcher object that will determine the behavior of the task application when it is invoked. For example, you can specify a phone number that will be displayed when the Phone application launches. Finally, you call the Launcher’s Show method to launch the task application.It is important to note that when you use a Launcher, a separate application is launched to complete the task. For example, the EmailComposeTask invokes the Messaging application. When the separate application is launched, your application is deactivated and is no longer running. After completing the task, the user can return to your application, at which point it is reactivated.

Classes


Public class
CameraCaptureTask
Allows an application to launch the Camera application. Use this to allow users to take a photo from your application.Public class
ChooserBase<TTaskEventArgs>
The base class from which all choosers are derived. This class exposes a common function for showing the choosers and an event for handling the chooser result.Public class
EmailAddressChooserTask
Allows an application to launch the Contacts application. Use this to obtain the email address of a contact selected by the user.Public class
EmailComposeTask
Allows an application to launch the email application with a new message displayed. Use this to allow users to send email from your application.Public class
EmailResult
Represents an email address returned from a call to the Show method of a EmailAddressChooserTask object.Public class
MarketplaceDetailTask
Allows an application to launch the Windows Phone Marketplace client application and display the details page for the specified product.Public class
MarketplaceHubTask
Allows an application to launch the Windows Phone Marketplace client application.Public class
MarketplaceLauncher
This Windows Phone Marketplace Launcher API is deprecated. It will not be supported in future releases. Please use the new Windows Phone Marketplace APIs, MarketplaceDetailTask, MarketplaceHubTask, MarketplaceReviewTask, and MarketplaceSearchTask.Public class
MarketplaceReviewTask
Allows an application to launch the Windows Phone Marketplace client application and display the review page for the specified product.Public class
MarketplaceSearchTask
Allows an application to launch the Windows Phone Marketplace client application and display the search results from the specified search terms.Public class
MediaPlayerLauncher
Allows an application to launch the media player.Public class
PhoneCallTask
Allows an application to launch the Phone application. Use this to allow users to make a phone call from your application.Public class
PhoneNumberChooserTask
Allows an application to launch the Contacts application. Use this to obtain the phone number of a contact selected by the user.Public class
PhoneNumberResult
Represents a phone number returned from a call to the Show method of a PhoneNumberChooserTask object.Public class
PhotoChooserTask
Allows an application to launch the Photo Chooser application. Use this to allow users to select a photo.Public class
PhotoResult
Represents a photo returned from a call to the Show method of a PhotoChooserTask object or a CameraCaptureTask object.Public class
SaveEmailAddressTask
Allows an application to launch the contacts application. Use this to allow users to save an email address from your application to a new or existing contact.Public class
SavePhoneNumberTask
Allows an application to launch the contacts application. Use this to allow users to save a phone number from your application to a new or existing contact.Public class
SearchTask
Allows an application to launch the Web Search application.Public class
SmsComposeTask
Launches the Messaging application with a new SMS message displayed.Public class
TaskEventArgs
The EventArgs used by the Completed event for all Choosers.Public class
WebBrowserTask
Allows an application to launch the Web browser application.


Public class

 

EmailComposeTask

EmailComposeTask launches the Email application which displays a new email message. You can optionally specify recipients, a message subject, and a message body that are prepopulated in the new message. The message is not sent until it is initiated by the user.

EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.To = "user@example.com";
emailComposeTask.Body = "Email message body";
emailComposeTask.Cc = "user2@example.com";
emailComposeTask.Subject = "Email subject";
emailComposeTask.Show();

MarketplaceDetailTask

MarketplaceDetailTask launches the Windows Phone Marketplace client application which then shows the details page for a product specified by the unique identifier you provide.

MarketplaceDetailTask marketplaceDetailTask = new MarketplaceDetailTask();
marketplaceDetailTask.ContentIdentifier = "<ID>";
marketplaceDetailTask.Show();

MarketplaceHubTask

MarketplaceHubTask launches the Windows Phone Marketplace client application. Set the ContentType property to a value from the MarketplaceContentType enumeration to launch the hub to a particular type of content.

MarketplaceHubTask marketplaceHubTask = new MarketplaceHubTask();
marketplaceHubTask.ContentType = MarketplaceContentType.Music;
marketplaceHubTask.Show();

MarketplaceReviewTask

MarketplaceDetailTask launches the Windows Phone Marketplace client application which then displays the review page for your application.

MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();

MarketplaceSearchTask

MarketplaceSearchTask launches the Windows Phone Marketplace client application which then shows the search results based on search terms you provide.

MarketplaceSearchTask marketplaceSearchTask = new MarketplaceSearchTask();
marketplaceSearchTask.SearchTerms = "accelerometer xna";
marketplaceSearchTask.Show();

MediaPlayerLauncher

MediaPlayerLauncher launches the Media Player application and plays the media file you specify. Media files are stored in isolated storage when saved to disk by the application and are stored in the application’s installation directory if they are bundled into the applications .xap file. You must specify one of these locations using the MediaLocationType enumeration. You can optionally specify that one or more controls should be shown by the Media Player using bitwise OR combinations of the MediaPlaybackControls values.

MediaPlayerLauncher mediaPlayerLauncher = new MediaPlayerLauncher();
mediaPlayerLauncher.Media = new Uri("MyVideo.wmv", UriKind.Relative);
mediaPlayerLauncher.Location = MediaLocationType.Data;
mediaPlayerLauncher.Controls = MediaPlaybackControls.Pause | MediaPlaybackControls.Stop;
mediaPlayerLauncher.Show();

PhoneCallTask

PhoneCallTask launches the Phone application and displays the specified phone number and display name. The phone call is not placed until it is initiated by the user.

PhoneCallTask phoneCallTask = new PhoneCallTask();
phoneCallTask.PhoneNumber = "55555555555";
phoneCallTask.DisplayName = "Gage";
phoneCallTask.Show();

SearchTask

SearchTask launches the Search application and performs search query you provide.

SearchTask searchTask = new SearchTask();
searchTask.SearchQuery = "NukeYourOffice";
searchTask.Show();

SMSComposeTask

SmsComposeTask launches the Messaging application which displays a new SMS message. You can optionally specify recipients and a message body that are prepopulated in the new message. The message is not sent until it is initiated by the user.

SmsComposeTask smsComposeTask = new SmsComposeTask();
smsComposeTask.To = "5555555555";
smsComposeTask.Body = "Check out this new app.";
WebBrowserTask

WebBrowserTask launches the Web browser and displays the URL you provide.

WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.URL = http://webservicesuk.com;

WP7 TOMBSTONING – State – Launching, Closing, Deactivated and Closing Events

 

Paused App

 

As you probably aware, WP7 only allows one application to run in the foreground at any given time  and no 3rd party applications are allowed to run in the background. Therefore when a user navigates away from your application, either to a chooser like picture chooser, or to a launcher like phone call, Windows Phone operating system terminates your application!

This process is known as “Tombstoning” and is the procedure in which the operating system terminates an application’s process when the user navigates away from the application. The operating system maintains state information about the application. If the user navigates back to the application, the operating system restarts the application process and passes the state data back to the application.

TIP: When you return from a tombstoned state the screen on the device/emulator goes black for a short while. At this point hit F5 in the debugger – the device is waiting for the debugger to attach. (Set the breakpoints beforehand, you have 10 seconds in which to reactivate the debugger).

There are 4 events related to Tombstoning- It is recommended that they are handled appropriately by developers within their own code (by default, the following stubs are created in App.XAML.cs code behind file:

// Code to execute when the application is launching (eg, from Start)
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Application Launching");
}

// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Application Activated");
}

// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Application Deactivated");
}

// Code to execute when the application is closing (eg, user hit Back)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Application Closing");
}

 

LAUNCHING()

public event System.EventHandler<Microsoft.Phone.Shell.LaunchingEventArgs> Launching
    Member of Microsoft.Phone.Shell.PhoneApplicationService

Summary:

Occurs when the application is being launched. This happens when the user taps the icon for your application from the Start screen. Handle this event by loading persistent state from isolated storage and showing the first launch experience for the application. The application should not imply that it is resuming from a previous session.

CLOSING()

public event System.EventHandler<Microsoft.Phone.Shell.ClosingEventArgs> Closing
    Member of Microsoft.Phone.Shell.PhoneApplicationService

Summary:

 

Occurs when the application is exiting. This happens when the user uses the back key to navigate backwards past the first page of the application. Handle this event by saving persistent state, such as settings and user data.

 

DEACTIVATED()

public event System.EventHandler<Microsoft.Phone.Shell.DeactivatedEventArgs> Deactivated
    Member of Microsoft.Phone.Shell.PhoneApplicationService

Summary:

Occurs when the application is being suspended. This happens when the user navigates away from the application, either by starting another application or by invoking a launcher or chooser. Handle this event to preserve the application’s transient application state which you can restore in the handler for the Microsoft.Phone.Shell.PhoneApplicationService.Activated event if the application is reactivated. It is not guaranteed that the application will be reactivated. Therefore, it is a good practice to also save persistent state, such as settings and user data, in the handler for this event.

 

ACTIVATED()

public event System.EventHandler<Microsoft.Phone.Shell.ActivatedEventArgs> Activated
    Member of Microsoft.Phone.Shell.PhoneApplicationService

Summary:

Occurs when the application is being made active after previously being suspended. This can happen when the user navigates away from your application, either by starting another application or by invoking a launcher or chooser, and then returns to the application either by completing the chooser interaction or by using the back key to until the application is active again. Handle this event by loading persistent state from isolated storage and transient state from the State property. The application should present the user with an experience as if they are continuing a previous application session.

 

More:

http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2010/07/14/silverlight-for-windows-phone-7-tombstoning.aspx

http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/07/16/understanding-the-windows-phone-application-execution-model-tombstoning-launcher-and-choosers-and-few-more-things-that-are-on-the-way-part-2.aspx

Microsoft PDC10

2003  Redmond 12003  Redmond 2

One of my workmates summed up my first visit to Redmond when he informed everyone I was going on holiday to my “spiritual home”.

Since then I’ve been out to visit Microsoft’s Redmond campus a couple of times.  It’s a great experience, it’s a large centre, but in no way on the same scale as the Orlando or LA Convention Centers.  Think more MIX size (actually a little smaller I would guess).  So its going to be a ‘mini PDC’ in more ways than one.  That’s not to say that the campus isn’t large, in fact it is like a sprawling mini town in its own right with lots of interesting things to find and plenty of techie history along the way.  2005  Redmond 3

I was very lucky and got a tour of the campus from Jeremy Kelly after chatting on Channel 9 (http://Channel9.msdn.com).  He also arranged an informal meet with other “Niners” at one of the many Canteens on Campus.  Before I left he showed me around the ‘nerve center for Visual Studio and as we walked, we stumbled upon some history in the shape of plaques in the pavement commemorating significant releases  (I later returned intending to take some more photos of this spot but couldn’t find it!).

2005  Redmond 42005  Redmond 52005  Redmond 62005  Redmond 7

 

 

 

 

http://www.microsoftpdc.com/

WP7 Dev Labs

A rewarding day at Microsoft’s’ WP7 Developer labs in London in the Company of Technical Evangelist Paul Foster. 

  I started the day with the mandatory Starbucks and straight into an opportunity to play with one of the few WP7 devices in the UK  (a pre-release phone from LG).  Paul had linked his Facebook account to the phone which made the experience more rewarding / true to life.  Of course as a developer I might be biased but I have to say the interface is both ‘Next Gen and very intuitive in operation’.  I look forward to owning a device as a user as well as a developer. 

London,Victoria,Westminster Cathedral 1920s small  On to business and a few tweaks later my first app (http://apps.webservicesuk.com/Shove) was up and running on the device. ( It was a relief to see that it  performed well (It had shown some issues on the emulator running on my ‘PDC laptop’).  FYI  a high spec (core i7) device is the recommended option in order for the emulator to get close to the performance of the initial hardware   I found this last fact quite comforting! 

  Next up was PuzzleGram (http://apps.webservicesuk.com/Puzzlegram) , the same few tweaks to the project files and it sprang in to life on the device – sweet!  I still have a little work to do on both these apps – running ‘shove halfpenny’ on the device confirmed concerns that keeping things to scale left the coins a little on the small side –  should be an easy fix though  (stand by!). 

  The ’bad day at the office ‘ / stress relief app “Nuke Your Office” (http://apps.webservicesuk.com/NukeYourOffice) proved a little more troublesome but I was relieved to find that performance was great on the device (Multiple simultaneous explosions and sound effects / particle based smoke effects were no problem for the devices’ processor).

Apart from the opportunity to put a device through its paces for a day it was also a great opportunity to enhance my understanding of the platform through discussion with Paul, who I must thank for his constant attention  (Paul’s own specialty is XNA but he was kind enough to contact Mike Taulty and others to assist with some of the Silverlight specific questions).

As a bonus (for getting up at 4am?) I also had the opportunity to develop a fLondon,Hyde Park,Piccadily 1900s Same Smallew more locations for my hobbyist historical site at http://apps.webservicesuk.com/FromTheMalverns.  The offices in Victoria are directly opposite Westminster Cathedral and only a stones throw from Hyde Park Corner and Piccadilly, all of which feature on the site.  (Note to self: must think how I can best bring this to WP7).

 

Many thanks again to Paul and to Bindi Karia (BizSpark UK – without which I would not have got this far)

Using WP7 Controls in Silverlight Desktop

toggleIn building my WP7 apps I have taken the approach of dual coding wherever possible, that is to say that each solution has both a standard Silverlight project and a Windows Phone 7 project, with shared code (using shortcuts within the project) wherever possible.  My objective is to have the Silverlight Desktop version mimic the UI and behavior of the WP7 project.

Windows Phone 7 has a few new controls but a little digging (and I mean just a little) reveals that they are in fact standard controls with a style applied within the APP.XAML of the WP7 project.  SO it is simple a case of cutting and pasting the styles from the WP7 to the Desktop project!

For an example of the new toggle switch applied to a silverlight desktop project click on the options button in the top left corner of the following link:

http://apps.webservicesuk.com/shove

So the code for the checkbox within the options panel simply has the following style applied to it:

Style="{StaticResource PhoneToggleSwitch}"

 

This is also  useful when doing multi-touch desktop applications as the styles for all the WP7 controls provide a better staring point than the default desktop equivalents.