With all the buzz this week about the Windows Phone 8 SDK leak, I couldn’t resist installing it.
The title of the SDK is Windows Phone 8 Developer Preview. There are so many cool new features that initially, I didn’t know where to start. I decided to start with one of the new features of the live tiles, since this is the Windows Phone’s biggest strength.
I don’t know the exact feature name, but it’s about cycling images in a live tile. Here is a little video that will help to describe the feature.
Cycling images in a Live Tile
Have you spotted the difference between the Windows Phone 7 badge count and the new OS? It is now in a square instead of a circle!
What I love about Microsoft is that they make it easy for developers to use their APIs.
Follow these two steps to accomplish what you see in the video: 1- Add up to 9 images to the project and set the Build Action to Content. The images need to be local only. 2- Append the following code
ShellTile appTile = ShellTile.ActiveTiles.First();
if (appTile != null)
{
Uri uri1 = new Uri("/Assets/UltimatePokerManager.png", UriKind.Relative);
Uri uri2 = new Uri("/Assets/YourShape.png", UriKind.Relative);
CycleTileData cycleTileData = new CycleTileData
{
Count = 3,
CycleImages = new[] {uri1, uri2}
};
appTile.Update(cycleTileData);
}
The UtimatePokerManger.png and YourShape.png have the size 173×173. When you watched the video, the images were expanded.
Please note that the SDK is in preview and there is no guarantee that the APIs will be the same in the released version, but I bet this feature will stay as it is.
This was my first Windows Phone 8 blog post and is surely not the last!
Here is a complete step-by-step guide to create a WCF backup service for your Windows Phone applications.
You can implement your own hosting service with a cheap hosting server like GoDaddy. You can find deal at $5/month. Personally, I find it more professional saving your application data to a private server or in a cloud solution instead of relaying on SkyDrive.
To accomplish this, two things are required: A- Implementing the service on your server. B- Implementing the client code to send your data.
Alternatively, you can download the complete solution at the end of the article.
A) Server side
1- Let’s start with the hardest part. After you find a hosting server that supports the framework .NET 4.0, you create the WCF Service Application:
2- Rename the file IService1.cs to IFileUploader.cs
3- Replace the content of the IFileUploader.cs with:
using System.Runtime.Serialization;
using System.ServiceModel;
namespace FileUploadService
{
[ServiceContract]
public interface IFileUploader
{
// Returns null when there is no error, otherwise it is the exception message.
[OperationContract]
string Upload(UploadFile uploadFile);
}
[DataContract]
public class UploadFile
{
// Don't forget to set the variable FileUploadDirectoryWithReadWritePermission in your Web.config and set read/write permission in your web hosting.
// RelativeDirectory should be in the form as /Path1/Path2/ or null for the root directory.
[DataMember]
public string RelativeDirectory { get; set; }
[DataMember]
public string FileName { get; set; }
[DataMember]
public byte[] Content { get; set; }
}
}
This interface contains only the Upload method. The Upload needs a UploadFile which contains only 3 properties: RelativeDirectory, FileName and Content.
4- Rename the file Service1.svc to FileUploader.svc.
5- Replace the content of FileUploader.svc with:
using System;
using System.Configuration;
using System.IO;
using System.Web.Hosting;
namespace FileUploadService
{
public class FileUploader : IFileUploader
{
#region IFileUploader Members
public string Upload(UploadFile uploadFile)
{
string message = null;
try
{
string path = HostingEnvironment.MapPath(string.Format("~/{0}",ConfigurationManager.AppSettings["FileUploadDirectoryWithReadWritePermission"]));
if (path != null)
{
if (uploadFile.RelativeDirectory != null && uploadFile.RelativeDirectory.StartsWith("/"))
{
path = string.Concat(path, uploadFile.RelativeDirectory);
}
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
if (!string.IsNullOrEmpty(uploadFile.FileName))
{
using (FileStream fileStream = File.Open(Path.Combine(path, uploadFile.FileName), FileMode.Create))
{
using (var binaryWriter = new BinaryWriter(fileStream))
{
binaryWriter.Write(uploadFile.Content);
}
}
}
}
}
catch (Exception exception)
{
message = exception.Message;
}
return message;
}
#endregion
}
}
– The section about the length of the service parameters: You don’t need to understand everything here. It just works as is. If you are curious, I invite you to read the documentation on MSDN.
7- The service is ready to be published. Right-click on the FileUploadService project and choose Publish. Depending on your web hosting service, you need to set the info.
For GoDaddy:
– Use the FTP method.
– Set the target location. For me, I used ftp://ftp.ultimatepokermanager.com/upm/ServerTest
– Set the credentials
8- The trickiest part is to configure the application settings for the WCF service in the hosting service. In GoDaddy, it’s in the IIS Management in the Tools section. You need to check Anonymous Access and Set Application Root.
The upmservertest points to http://www.ultimatepokermanager.com/upm/servertest
8- To check if your service is running, open your browser and put the address of the web service. With my web service, the address is:
In the sample, I generated a GUID for the directory name. Also, the uploaded files are public as long as the user (or the application) knows about the directory name and the file name. If you want to add a layer of privacy, you just have to implement a DownloadFile method into your service. It should not be difficult if you read the code of the Upload method.
I guarantee you that you’ll be happy to see when your web service is working!
In the past year and a half, I have read a lot of Windows Phone books. The first book I read was the excellent 101 Windows Phone 7 apps. At that time, I was recommended that book, but ever since Microsoft released the Mango update, 101 is a bit out of date.
At the end of 2011, I read Essential Windows Phone 7.5 by Shawn Wildermuth. I recommend this book for someone who has never owned a Windows Phone and who wants to start programming for the Windows Phone. It is an excellent book for beginners, as the author spends time about on basic Windows Phone concepts.
Now to my review of the latest Windows Phone book I have read: Windows Phone 7.5 Unleashed by Daniel Vaughan.
This book is huge with 1120 pages, and all of them are worth it. Here are some of the things that I like about the book:
Most of the code samples are done with the MVVM pattern. Nowadays, this pattern is the most popular one used when creating Windows Phone applications. The author even shares his known Calcium SDK that includes the MVVM philosophy. For a beginner who wants to start Windows Phone programming, starting off with the best pattern is a great idea, and this book will help you do that.
There is a lot of free code given. There are a lot of utility classes that can be used in many types of Windows Phone applications. Honestly, the book is worth buying for the free code alone, and it will save you a lot of time.
If you are new to use the SQL Compact Server database, this book will help you to learn the technology; the author has a large helpful section on this topic.
The author introduced the usage of Reactive Extensions. This technology is not for beginners, but I’m pretty sure it will intrigue you, as it did me. The author presents the benefits of Reactive Extensions. The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. You can find the rest of the definition at the official website.
The author knows the platform well and describes many useful hints and caveats in Windows Phone programming.
In conclusion, this excellent book is one that I recommend right now if you want to dive into Windows Phone programming or to learn more about the recent features added with Mango.