A quick update: Mango on my HD7

IMAG0001

This is going to be a quick post. Just over 2 weeks ago I got the Windows Phone Mango invite I was waiting for; my HD7 has been running mango in full glory since then. The installation took a long time but went pretty smoothly, backing the data up takes most of the time. I am really liking the Mango update, this is what windows phone should have been when it launched. Multitasking, IE9, better facebook integration in people’s hub and a plethora of other features. The voice command integration in mango is exceptional, and I find myself using it quite often. Being able to listen to an incoming message, compose a reply and send it, all using only your voice, is really amazing (or magical, as some might call it) and works really well.

Strangely, I am not using the multitasking feature all that much. Somehow I have an obsessive compulsion to keep the backstack clean all the time. Whenever I am done using the phone, I keep pressing the back button just to make sure there is nothing on the stack. I have a feeling I’m not alone.

In other news, AppHub gets some new features and Windows Phone is expanding to new markets. More importantly, Microsoft’s pubCenter, finally, will be available to developers outside of US of A. According to Todd Brix’s post, pubCenter should launch to new markets (including India!) before the end of 2011. I can’t wait to try out adCenter. You can read Todd’s post here,

http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/07/20/windows-phone-developers-get-new-app-hub-features-mango-app-submission-just-one-month-away.aspx

Windows Phone Mango 7.1 SDK Beta 2

The developer tools for Windows Phone Mango were updated to Beta 2 a few days ago. You can find the bits here,

Web Installer – http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=26648

ISO file – http://go.microsoft.com/fwlink/?LinkID=220415

You can read this WindowsPhoneGeek article on installation instructions.

On June 29th, Microsoft also released Mango for developers,

http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/06/29/developers-get-goody-basket-full-of-mangos.aspx

I am still waiting for my invite. Looks like they are sending out invites starting from the list of supported countries, which unfortunately, India is not a part of. I’ll write when I get the invite and let you know how the installation goes on my HD7.

Windows Phone Mango Developer Tools

The consumer side of Windows Phone Mango was unveiled yesterday by Microsoft. It brings in some great new features like multitasking, IE9, fast application switching, maps, web marketplace etc to name a few. I was also impressed with enhancements to bing like local scout, bing vision and bing voice. With the NoDo update fiasco now behind us, I think the expectations are set just right for the ‘mango’ update which will be coming this fall ;) One thing that annoys me is the feature-market fragmentation that’s happening with Windows Phone. What’s the deal with making some features available only to a few markets! Just look at the way zune services and their features are split region-wise. It’s horrible and needs fixing.

Nothing was mentioned about Microsoft’s ad framework, PubCenter, and its expansion plans. It’s been close to 8 months since windows phone came out and PubCenter has expanded its market by zero, zilch, nada! There were talks a while back that it will be made available in europe, I don’t know how that’s working out. Hey you, make it global already! And show us some pay-per-impression love.

Tools

You can download the Windows Phone Developer Tools 7.1 Beta from here, (web installer) http://www.microsoft.com/downloads/en/details.aspx?FamilyID=77586864-ab15-40e1-bc38-713a95a56a05&displaylang=en

And if you don’t believe in web installers, here’s the link for downloading the ISO file, http://download.microsoft.com/download/0/0/D/00D22BA8-E716-4272-93D8-C4D98F0567AE/WPDT_v2_Beta_en1.iso

Aaron Stebner’s post contains some more links and other useful information, do take a look, http://blogs.msdn.com/b/astebner/archive/2011/05/24/10168008.aspx

And remember to install Visual Studio 2010 SP1 first.

You have a good day while I watch the ISO getting sucked from the interwebs at mind-numbing speeds.  /s

Until next time…

MIX’11 : Windows Phone Sessions

Here is a list of all windows phone sessions from MIX this year, (list taken from AppHub)

Day 2 Keynote
Joe Belfiore

Application Design for Windows Phone
Megan Donahue

XNA Game Studio for Fun, Profit, Danger, Excitement and Windows Phone 7 Games
Rob Miles

Expert Lessons: Top Tips to Building a Successful Windows Phone Application
Stefan Wick

Who Would Pay For That Feature? Adding Analytics to Your Windows Phone 7 Applications
David Poeschl

Rx: A Library for Managing Asynchronous Data and Events in Your Windows Phone 7 Application
Jim Wooley

What’s Coming Next to the Windows Phone Application Platform
Andrew Clinick

Building Windows Phone 7 Applications with the Windows Azure Platform
Wade Wegner

Going Mobile with Your Site on Internet Explorer 9 and Windows Phone 7
Joe Marini

Get Ready for Fast Application Switching in Windows Phone
Adina Trufinescu

What’s New in the Windows Phone Developer Tools?
Vibhor Agarwal

Multitasking in the Next Version of Windows Phone, Part I
Darin Miller

Multitasking in the Next Version of Windows Phone, Part II: Using Background Agents
Peter Torr

Flickr API: Tap Into Billions of Photos for Windows Phone 7
Markus Spiering

Sensor and Camera Access in the Next Version of Windows Phone
Mark Paley

What’s New for Windows Phone Development with Silverlight?
Shawn Oster

Windows Phone Architecture – Deep Dive
Istvan Cseri

Analyzing and Improving Windows Phone Application Performance
Jeff Wilcox

What’s New for Windows Phone Development with the XNA Framework?
Brian Hudson

Making Money with Your Application on Windows Phone
Todd Brix

Enhanced Push Notifications & Live Tiles for Windows Phone
Thomas Fenne

Creating Windows Phone Applications Using Expression Blend
Unni Ravindranathan

New Data Access Features Coming to Windows Phone
Sean McKenna

All Thumbs: Redesigning an Existing UI to Suit Windows Phone 7
Ward Bell

The Tale of Two Apps: Making a Splash in the Windows Phone Marketplace
András Velvárt, Bálint Orosz

Over 1500 new API’s have been added to the next version of Windows Phone, called Mango. And yes, all existing devices will be updated to Mango, the update can’t come soon enough :)

Windows Phone 7: Freeing up space after installing the pre-NoDo update

Like I mentioned in this post, if you installed the pre-NoDo update, the process would have required a fair amount of storage space on your primary drive depending on how much content you have on your phone. The Zune software takes a backup of your phone’s content before updating the OS on the device. This backed up data stays on your machine, here’s how to move the data to another location so you can free up some space on your primary drive.

On your machine navigate to the following location,

C:\Users\<user-name>\AppData\Local\Microsoft\Windows Phone Update\

the folder AppData is hidden, so you’ll need to enable the option to show hidden folders. And depending on your configuration you may also need admin privileges to move stuff around. The Windows Phone Update folder contains the data backed up from your device,

WP7-pre-nodo-free-space

All the data is present inside the RestorePoint folder. Move this folder to another location to free up space. Make sure you keep this backup of the backup safe, just in case something horribly bad happens to your windows phone 7 device.

Windows Phone 7: Translation, rotation, scaling and the effect of ‘BitmapCache’ on performance

One thing that was pending on my “todo” list from a long time was implementing the ‘Game Of Life’ on Windows Phone 7. I got the basic version running in a couple of hours and I’ve been thinking about improving it since and adding new features to it. Maybe I’ll submit it to the marketplace someday, who knows. I have also been reading about gestures, multi-touch, pinch-to-zoom and related topics and most importantly trying to understand the math behind each of those gestures, and the math is so elegant that it fascinates me!

Game Of Life
Game Of Life is a simple cellular automaton in which you create a pattern in a world made of rectangular grids, start the evolution process and then watch the pattern change as the world evolves. The world is made up of dead cells initially, you create a pattern by selecting a few cells and giving them “life”. The world then evolves according to a set of rules (source: Wikipedia):

  1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies, as if by overcrowding.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

It’s a fascinating concept and some very interesting patterns emerge out of it, read more about Game Of Life on Wikipedia here.

Gestures
Gestures like translation, scaling and rotation seemed complex to me at first, but they’re pretty simple once you understand the math that makes the magic happen. I came across two great articles that really dig deep into these concepts. Both articles use the Silverlight Toolkit for Windows Phone 7 and the gesture support that it provides. I was a little surprised to know that the silverlight toolkit actually uses XNA’s touch api’s to detect gestures. These are the articles that you must read:

MSDN Magazine : Touch Gestures on Windows Phone by Charles Petzold. This is the implementation I chose to use in my app Game Of Life. The code is available for download in the article.

Windows Phone 7: Correct pinch zoom in silverlight by Francesco De Vittori. I was using this before I stumbled on Charles’ article :) Also, Charles’ implementation seemed more intuitive to me.

Charles Petzolds’ implementation makes use of Matrix transforms. It took me some time to understand matrix transforms and realize their importance in 2D/3D graphics. The only time I used matrix multiplication was to solve silly linear equations in college. You’ll find many a articles on the internet about matrix transforms but the best resource I found again comes from Charles Petzold. Chapter 22 – From Gestures to Transforms in his free book Programming Windows Phone 7. Download it now if you haven’t already, it’s a great resource.

The two paths had to meet. Using gestures in Game Of Life was the best way to learn them.

In my first implementation of Game Of Life, I used the Manipulation Delta events to support pinch-to-zoom. In this I used the DeltaManipulation.Scale.X and DeltaManipulation.Scale.Y values in the ManipulationDeltaEventArgs class (passed to the ManipulationDelta event handler) to modify the ScaleX and ScaleY values of a Scale transform on the object to be scaled. If that sentence didn’t make sense, don’t worry, this is the easiest and the worst implementation of pinch-to-zoom. The scaling was not smooth or accurate. To understand what a perfect pinch-to-zoom should be read this – Pinch Zooming using XNA on WP7: Getting it right. The article explains this with reference to XNA but the concept remains the same everywhere.

In my second attempt I used the Silverlight Toolkit for Windows Phone and Francesco’s implementation of pinch-to-zoom. It was working pretty nicely with a few quirks here and there. Though the implementation is easy to understand, I felt there were too many variables used for storing state information and the code looked a bit messy, but it worked.

It is while tuning this implementation that the MSDN Magazine article was published. Charles Petzold’s implementation felt intuitive and was much cleaner. The only part I had to figure out was the matrix transforms he used. And that I’ll explain a bit here.

This is what the app looks like,

game-of-life

The rectangular grids are added programmatically to a canvas. Here is the XAML for the canvas,



    
        
            

            
                
                
                
            

        
    


So during the Drag Delta and Pinch Delta events the transforms under currentTransform are manipulated to achieve the desired effect and once the drag or pinch gestures are completed a function, TransferTransforms(), is called:

void TransferTransforms()
{
    previousTransform.Matrix = Multiply(previousTransform.Matrix, currentTransform.Value);

    //Set current transforms to default values
    scaleTransform.ScaleX = scaleTransform.ScaleY = 1;
    scaleTransform.CenterX = scaleTransform.CenterY = 0;

    rotateTransform.Angle = 0;
    rotateTransform.CenterX = rotateTransform.CenterY = 0;

    translateTransform.X = translateTransform.Y = 0;
}

Matrix Multiply(Matrix A, Matrix B)
{
    return new Matrix(A.M11 * B.M11 + A.M12 * B.M21,
            A.M11 * B.M12 + A.M12 * B.M22,
            A.M21 * B.M11 + A.M22 * B.M21,
            A.M21 * B.M12 + A.M22 * B.M22,
            A.OffsetX * B.M11 + A.OffsetY * B.M21 + B.OffsetX,
            A.OffsetX * B.M12 + A.OffsetY * B.M22 + B.OffsetY);
}

To understand what is happening here we need to look at the XAML first. The RenderTransform on the MainCanvas is a double-barrelled (term used by Charles in his article) transform. Basically, a transform group within a transform group. So the effective transform on MainCanvas is equal to the effect of previousTransform plus the effect of currentTransform. Well, it’s not exactly “plus”. First, previousTransform is applied on MainCanvas to change its state, and then currentTransform is applied on that state to change it further. If you download and look into Charles’ code, you’ll see that during drag delta and pinch delta events, only currentTransform values are modified. Once the drag or pinch gesture is complete, TransferTransform() is called to “transfer” the values of currentTransform to previousTransform. And this transfer happens by the way of matrix multiplication, which is what the function Mulitply() does. It’s not over yet. After the multiplication the values of currentTransform (i.e scaleTransform, rotateTransform and translateTransform) are reset. This is important because, as we discussed before, the effective transform on MainCanvas is effect of previousTransform “plus” the effect of currentTransform. Transferring the values of currentTransform to previousTransform and then resetting currentTransform keeps the effect same.

CacheMode and BitmapCache
Now I got the translation, scaling and rotation to work correctly, but the performance was not very great. There was a huge lag in pinching and dragging, and this is where BitmapCache comes in. Every UIElement has a property called CacheMode, which can be set to BitmapCache.

In XAML, CacheMode=”BitmapCache”

In code, uiElem.CacheMode = new BitmapCache();

When the CacheMode of a UIElement is set to BitmapCache, a snapshot of the UIElement is taken and is stored in the video memory. So the element is not redrawn every time, instead all the operations are performed on the cached bitmap. This is super fast and is particularly useful when working with transforms on controls. Change the MainCanvas element in the XAML to include CacheMode,

 

and this will have a dramatic effect on the performance as you will see in the video below.

Please leave a comment if you have anything else to add.

Until next time..

Windows Phone 7 – The pre-NoDo update

A quick post, about two days back I got a notification on my HD7 saying that there is a update available to be installed. Yes, it was the pre-nodo update that you might have read about on the windows phone blog. Just installed it, and it completed without any hitch. Reading several reports about some devices having trouble installing the update (particularly the Samsung ones) and some even getting bricked, I was wary at first. I waited two days and there were no reports of issues with any of the HTC devices. I went ahead and installed it today.

The only downside is that you might need a lot of space on your primary drive, close to 8GB for me, depending on how much data your phone contains. The update process backs up all the data in your phone, just in case something goes horribly wrong. The whole process took about 45 minutes, majority of the time for data backup. The OS version was updated from 7.0.7004.0 to 7.0.7008.0.

Now if we could just get the NoDo update.

Windows Phone 7 Developer Tools – January 2011 Update

WP7EmuCopyPaste

If you haven’t heard already, the Jan 2011 update of the windows phone 7 developer tools is out, er, in Feb. You can download the installation files from here,

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=49b9d0c5-6597-4313-912a-f0cca9c7d277

The performance increase with the new emulator is clearly noticeable and the first time deploy is real quick! The emulator image should also be a precursor to the windows phone 7 OS update that we’ve been waiting for ever. The emulator image includes copy-paste functionality which is enabled by default on all textboxes, password boxes and edit controls within web browser control, so existing apps get this feature for free. Go ahead and give the new tools a try. If you want to experiment more you might be interested in a unlocked emulator image, follow the link for more information.

http://windowsphonehacker.com/latest_windows_phone_7_emulator_unlocked-02-05-11.php

A tale of two dev accounts

You probably remember my rant from a while back about my windows mobile developer account having problems with the new AppHub, well, there have been few developments and I thought I should share it with you.

First up, the issue isn’t fixed yet. I still cannot login to AppHub using my windows mobile 6.x developer account and can’t view details of my Minesweeper app. Who knows how many copies its sold. I had numerous exchanges with Microsoft’s support team on the AppHub forums and via email as well (support ticket), but somehow we never managed to get to the root of it. In fact, the support team itself grew so tired of the problem that they suggested I create a new dev account.

I grew impatient, and it was really frustrating to have an app ready for submission but not being able to do anything with it. Eventually, the frustration had to show somewhere, and it was on this forum thread

Prabhu Kumar in reply to Nick

Nick, I feel for you and totally understand the frustration. Since day one I have been getting the XBOX profile linking error,

We encountered an issue connecting your App Hub account with your Xbox Live Profile.
Please visit Xbox.com and update your contact information.
After you have updated your contact information, please return to the App Hub (https://users.create.msdn.com/Register) to continue.

I have an app published on the Windows Mobile 6.x marketplace since Aug, now I can’t view the details of this app.
I completed work on my WP7 application 1.5 months ago and the first version is ready for submission to marketplace, only if I can login. You can imagine how frustrating all this can be, the issue has taken far too long to be fixed, this has drained all my motivation.

I have exchanged numerous mails with Microsoft support team on this issue, and from the looks of it they really are trying their best, unfortunately, their best is not good enough for some of us. During the first week of December I was told that there would be an update happening to AppHub around mid of December. I was hoping that the issue would be fixed but it wasn’t. After the update the only change I notice is that the xbox.com link on the error page now takes me to the correct link. Previously, this link used to take me to the 404 page you mentioned above.

Out of desperation, I am now considering creating another developer account on AppHub with a new live id, even this I am not 100% sure will work.

I asked the support team when the next update to AppHub was planned and got this reply,
We do not have  release date to announce for the next App Hub update at this time. In regards to the login issue you are experiencing at this point the only solution would be to create a new account with a different live ID but make sure to go to xbox.com before hand to get all the information in order on that side.

I know it’s an extra $99, and not that I can’t afford it but it doesn’t feel right and I shouldn’t have to be doing it in the first place. I have lost all hope of this issue being resolved.

I went ahead and created a new dev account, the id verification was in progress when Shaun Taulbee of Microsoft, who has been really helpful in the forums, replied saying,

If you find it necessary to pay again to create a new account due to a Microsoft problem, send in a support request asking for a refund and we’ll review it (and likely approve it given the circumstances).

The thought of refund made me happy, but I had my doubts. So once my second account was verified by Geotrust I applied for a refund through the developer dashboard, by creating a support ticket. Couple of days later I got an email from Microsoft saying that the refund had been approved! yay! Few days and the refund showed up on my bill,

ms_refund

Well, thank you Microsoft, it means a lot. I am glad it’s over now. The new account works flawlessly. I would still like to get my first account working again and look at my app numbers for Win Mo 6.x, and probably transfer the credits to the new account somehow, but I’ll save it for another day. If you’ve had similar problems with the AppHub, and had to create a new account to submit your app, I suggest you contact the support team and get your dollars refunded!