Month: January 2013

Free Windows 8 Design Templates are coming back soon

Windows 8
Two weeks ago, Microsoft Malaysia published a list of 50 templates to help developers creating applications for Windows 8. The links to the SkyDrive account that was hosting the 500 MB file is down and even all the MSDN blog posts that were talking about it have been deleted by Microsoft or their respective authors. I think the reason of this “black out” is the success of the operation, imagine a lot of people downloading the 500 MB file on only one SkyDrive account.

But as you can see on the web site of Microsoft Malaysia, the templates should come back soon. Microsoft will probably host the file on another platform.

Microsoft Malaysia

Windows Phone SDK Update for 7.8 available

SDK Windows Phone 7.8

Windows Phone 7.8 begins to be shipped with new phones and the update for 7.5 devices should start been deployed “over the air” very soon. That is the consumer part. For the developer, the good news was published today by Microsoft, the Windows Phone SDK Update for 7.8 was released this morning. You will be able to use some of the new features of Windows Phone 8 in your application that target Windows Phone 7.5.

You can install this SDK on Windows 7 and Windows 8 and it will add two new Emulators: Windows Phone 7.8 512 MB emulator and Windows Phone 7.8 256MB emulator. You’ll still be able to test your apps on Windows Phone 7.1 (or 8.0) because this new SDK is installed on top of the previous installs. There is no new API provided with this SDK, only the two new emulators.

New capability

The main (if not only) new capability that you can take advantage of in your app is the new live tile option:

  • The primary tile supports now 3 different sizes (like for Windows Phone 8), small, medium and large.
  • The secondary tile can now use the 3 tile templates introduced for Windows Phone 8: Flip, Iconic and Cycle templates.

Download the Windows Phone SDKs

Windows Phone 7.8 Emulator

Windows Azure Mobile Services – Update with REST APIs

Windows Azure Mobile Services

After the introduction to Windows Azure Mobile Services, I hope you had the chance to try this service. Di you know you can try Windows Azure for free for 90 days?

Today I would like to add a very short code snippet to help you updating an item in your Mobile Service. We have to use the HTTP method PATCH, send the id of the item to update and send the new item in the body of your request (serialized as a JSON message). You can use the following method in the class I gave to you in my introduction to Windows Azure Mobile Services.

public void Update<T>(string tableName, int idToUpdate, T item)
    where T : class
{
    Uri address = new Uri(string.Format("https://{0}.azure-mobile.net/tables/{1}/{2}", ServiceName, tableName, idToUpdate));

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);

    request.Method = "PATCH";
    request.Headers = new WebHeaderCollection
                            {
                                {"X-ZUMO-APPLICATION", ApplicationId},
                                {"X-ZUMO-MASTER", MasterKey},
                            };

    string serialization = item.Serialize();
    byte[] byteData = Encoding.UTF8.GetBytes(serialization);
    request.ContentLength = byteData.Length;

    using (Stream postStream = request.GetRequestStream())
    {
        postStream.Write(byteData, 0, byteData.Length);
    }

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    response.Close();
}

Introduction to Windows Azure Mobile Services

MobileServices

Today I would like to write about one of the feature on Windows Azure that was created by the team of Scott Guthrie. This new service, still tagged as a preview in the Azure management console, allows you to make easier your developments for Windows Phone, Windows 8 and even iPhone and Android devices with:

  • Structured storage. You can send and retrieve structured data between your client device and Azure using JSON messages or with the Windows Azure Mobile Services SDK. The backend of this storage is a SQL Server database but you don’t have to take care of it. Windows Store C#, Windows Phone 8, iOS.
  • User authentication. You will be able using a very simple line of code to get your mobile users to authenticate using for example their Microsoft Account or Facebook to access some restricted data or just to be identify by your system. Windows Store C#, Windows Phone 8, iOS.
  • Push notifications. Send a push notification to display a toast or change the tile on the client device has never been easier. With one line of JavaScript embedded on Azure, you can send push notification to all of your users. Windows Store C#, Windows Phone 8, iOS.

Microsoft did an amazing job by creating a lot of content to help developers creating applications using Windows Azure and I’ve linked, for each feature mentioned above, the corresponding tutorial for Windows 8 and Windows Phone 8 apps or even iOS.

Ok, now that we have the big picture of what is Windows Azure Mobile Services, let’s code a little bit. For one of my project I’m working on, I needed to connect Mobile Services, not from a mobile device but from a Worker Role also hosted on Azure. The main problem is that the Mobile Service SDK is not working for other projects than Windows 8, Windows Phone 8 (in the .NET world). Remember what I said about the Structured storage? You can exchange data using JSON messages. So I’ll use the REST APIs to communicate with my backend.

Continue reading

50 free Windows 8 Design Templates

windows8_logo

Microsoft Malaysia has recently published 50 application templates for Windows 8 to help developers to shape their apps for the Windows Store. These templates are ready to publish, in other words, you (almost) just have to open them in Visual Studio, change the name of the application and publish it in the store, that’s as easy. Each package is available in C# and JS/HTML. It’s about 500MB you can download on this SkyDrive.

Here are some samples of what you’ll get in the package:

You don’t have anymore excuse for not trying making applications for Windows 8.

[Update 1/26/2013] It seems the links are down, please look at Free Windows 8 Design Templates are coming back soon.

JSON Serialization–Deserialization

JSON is the new “trending” format used to transfer data between server and client. Today I’m going to start a series of post about Windows Azure Mobile Services, but I want to start very easy with something I’ll need for the next parts.

Here is the code of a helper to serialize and deserialize any object. Start with this using:

using System.Runtime.Serialization.Json;

Here is the static class you can use to serialize and deserialize your objects:

public static class JsonHelper
{
  public static string Serialize<T>(this T value)
     where T : class
  {
     var serializer = new DataContractJsonSerializer(typeof(T));

     using (MemoryStream stream = new MemoryStream())
     {
          serializer.WriteObject(stream, value);
          return Encoding.Default.GetString(stream.ToArray());
     }
  }

  public static T Deserialize<T>(this Stream stream)
     where T : class
  {
     var serializer = new DataContractJsonSerializer(typeof(T));
     return (T)serializer.ReadObject(stream);
  }
}