Thursday, October 27, 2011

Nokia LUMIA 800 windows phone emulator skin

 

LUMIA800_sampleOk.. Nokia just announced the first “real” windows phones Lumia 800 and Lumia 710.

These both models looks great, but my favourite one is the Lumia 800, too bad I cannot buy it from Romania’s phone stores (I hope anyway to get it with some friend out there in UK).

Seeing that Telerik has already launched some Lumia 710 skins for windows phone emulator, that inspired me into creating my own Lumia 800 emulator skin (blue theme) which I will share with you for use.

DOWNLOAD IT FROM HERE

Install steps:

- Backup the existing files from the emulator folder.(on a 64-bit machine, this is “C:\Program Files (x86)\Microsoft XDE\1.0\”)
- Extract the Zip into emulator folder overwriting old files.
- Re-launch windows phone emulator

Please enjoy it as much I do!

Wednesday, October 19, 2011

Windows Phone Mango SQL CE tips and tricks


   Hi windows phone developers,
   I’m currently working on a windows phone project where I use as storage medium the local database feature of new Windows Phone Mango.
   After playing with some configurations I come to recommend you some nice shortcuts to take in your projects:

1. Tables(Entities) and DataContext automatic code generation.

   Instead of writing all that code by hand, why not take advantage of existing designers in Visual Studio + some very interesting tools.
   Let’s add to the project an SQL Compact 4.0 Local Database file (.sdf) with the name you wish. When you confirm the file addition you will get this error:
“The assembly reference "System.Data" could not be added to the project. This wizard will continue to run, but the resulting project may not build properly.
trick_02
   Don’t worry, we will use this file as a blueprint for next phase and it should never be included into the project (in this scenario), so pay attention to change file property “Build Action” to “None”.
   Next create a data connection to this new created local database and design it on your will:
trick_01
   Now, we are going to need a nifty tool to generate all the plumbing and code that will handle the data storage into windows phone (mango) local database.
   This tool is named "SQL Compact Code Generator” and you can install it from Extension Manger (not for Visual Studio Express) (http://visualstudiogallery.msdn.microsoft.com/119234ae-bd87-415f-af87-098b72b90e9a?SRC=VSIDE). Luckily, it has also an independent tool for same purpose that can be used by those with Visual Studio Express(http://sqlcecodegen.codeplex.com/).
   Thank you Christian for this nice addition, we really appreciate it.
   Once the tool is installed  from ExtensionManager all you have to do is to set the database file property “Custom Tool” to value “SQLCEMangoCodeGenerator” and to add System.Data.Linq reference to your project.
screen_02     screen_01
   Immediately we should see beneath our database file a “.cs” file that contains all the generated code.
  Done!
  You can write your code for accessing datacontext and table entities the ordinary way.

2. Performing backup and restore for a SQL CE windows phone mango database

   Ok, we should know already that in Windows Phone Mango, the local database isn't but just another file into the isolated storage (or application folder). For isolated storage case, a simple connection string should look like this:
public static string ConnectionString = "Data Source=isostore:/SampleDB.sdf";

   Now that we know this fact, we can make a backup of this file into a new “*.bak” isolated storage file and consider this one as the database backup.

trick_03

   Of course we should pay attention on some aspects:
- during the backup/restore operation make sure that all the DataContext(s) that are using this database file are properly disposed and closed (also apply some sync mechanism for concurrent access); otherwise you will encounter a nice error message: “Operation not permitted on IsolatedStorageFileStream.”
- after a restore operation repopulate the interface and/or modelview with fresh data.

trick_04   A sample project to demonstrate backup/restore of local database can be found on the this link.



I hope these tricks will help you spare some time.
See you soon!