AvSol Chess Clock Application Windows Phone 7 Application 

Of course, I was very excited when my Chess Clock Windows Phone 7 application passed the Windows 7 Marketplace certification. It is there for the whole world to try and even buy and I would very much appreciate you trying it and leaving a comment if you have any remarks. In this post I want to share some of my experiences writing this Silverlight application for Windows Phone 7. By the way, Caliburn Micro was the framework and it greatly simplified development. Nothing beats an App class that looks like this:

    public partial class App : Application
    {
        public App()
        {
            // Standard Silverlight initialization
            InitializeComponent();
        }
    }

 

I will assume that you know the basics of MVVM Windows Phone 7 Silverlight development, so I will only highlight a few details you might find interesting or helpful.

What is a chess clock?

When I started out with this Chess Clock, there weren’t any in the Marketplace. Now that it has entered the Marketplace it turns out that there are several others. Some of them very close to my design even. Despite this I can be pleased that it Is the most versatile digital Chess Clock of them all. Also, my children are very pleased that we have a fully functional digital Chess Clock for some real chess competition training. Yes, it’s a boy and a girl and they both play chess.

First off, a Chess Clock is slightly more than a countdown timer. There are several variations or Game Clock modes and various aspects that relate to game of Chess and how its played in tournaments or competitions. In its very essence however it is a countdown timer and this leads to the question: how to write a countdown timer with Windows Phone 7?

Keeping time

There is no true multitasking for the standard Silverlight development tools you get from Microsoft. This means that a timer is not guaranteed to run. The user may press the start button and this will effectively kill your running code and put it under a tombstone. Someone can SMS or call you, which will “cover” your application. The phone may fall asleep after 2 minutes if there is no user interaction.

Chess Clock uses a simple strategy. When the timer starts or one user hits his or her stop button to change turns, the actual system time is recorded. Then the difference between the recorded time and the actual phone time determines the time passed between players turns. This will be true even when the whole application has been tombstoned and resurrected (The user presses start, runs other applications and eventually steps back using back). Then a simple DispatcherTimer suffices to make sure that the clock times are updated regularly to show the correct player times. The DispatcherTimer is ONLY used to refresh the display and NOT used to actually make the clock tick.

    [SurviveTombstone]
    public class MainPageViewModel : PropertyChangedBase
    {
     ...
        private DateTime chessClockTime;

        [SurviveTombstone]
        public DateTime ChessClockTime
        {
            get { return chessClockTime; }
            set { chessClockTime = value; }
        }
    ...

    }

Marking the main ViewModel with the Caliburn Micro [SurviveTombstone] attribute and members storing the recorded clock time, player turn and other status information suffices to make the app survive a switch by the user to another application.

If you combine this with setting the PhoneApplicationService.Current.UserIdleDetectionMode flag, the phone will not go to standby. While the Chess Clock is running I set it to Disabled. When the clock stops, this is also when the game ends, it is set to Enabled. Now all bases are covered.

  1. 1. The user can start another application and go back. The DispatcherTimer will kick in and play time will have passed.
  2. 2. The application can be covered, but the timer will still show the correct time when the application is uncovered.
  3. 3. The Chess Clock cannot inconveniently enter standby in the middle of a game.

 

Please note that the certification process of your application will now mark your application as ‘Runs under lock’.

Marketplace

The Marketplace certification process was easy enough. I uploaded it on a Thursday before the weekend and on Tuesday it already entered the Marketplace. Getting all the necessary images screenshots in place was the most difficult part. I think I need to have a look at all the flags and settings. I think it reports “uses data connection” even though a Chess Clock obviously does not need it. Also, I marked it in the “Games and Puzzles” category. To my surprise this means that it gets installed in the Game Hub. After giving it some thought I left it at that.

Giving away applications free in the Marketplace is limited, so I priced it on par with other Chess Clocks. So I hope you will at least try it. If you decide to buy it the revenues will be invested in more Windows Phone 7 development by Aviva Solutions. I know of XNA game plans in the making and I have two more in Silverlight myself, so watch this space for more Windows Phone 7 app releases.

Posted on 03-04-2011 by Wim The
0 Comments  |  Trackback Url  |  Link to this post
Tags:

Links to this post

Comments

Name:
URL:
Email:
Comments:

CAPTCHA Image Validation