Saturday, December 3, 2011

WP7 Accelerometer infographic

 

wp7_accelerometer_cheatsheet

Source .. WP7 training kit, XNA part

I use it as a quick reminder ;)

I hope you can use it too.

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!

Thursday, June 30, 2011

WP7 WebBrowser caching and Facebook login/logout

So you want to developed your next social media integrated Windows Phone application;
And you’re making heavy use of Facebook C# SDK.

But you’ll find out that all the authentication/authorization/delegation process is done entirely in a WebBrowser component and developer is just intercepting Navigated event of this component to process the server responses and capture the Access Tokens.

It comes a bit more trickier when you try to log-out in order to log-in with another credentials.
Not so much info over the internet, so here it was my solution that works just fine:

- when we wish to log-out we pass to the browser log-out URL:

wb.Navigate(new Uri("http://m.facebook.com/logout.php?confirm=1"));

- then on the navigated event of WebBrowser component we look for logout button, extract the logout Url and we force a navigation to this real logout Url:

private void wb_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
string fbLogoutDoc = wb.SaveToString();
Regex regex = new Regex("\\<A href=\\\"(.*)\\\".*data-sigil=\\\"logout\\\"");
MatchCollection matches = regex.Matches(fbLogoutDoc);
if (matches.Count > 0)
{
string finalLogout = string.Format("http://m.facebook.com{0}", matches[0].Groups[1].ToString());
wb.Navigate(new Uri(finalLogout));
}
}

This way the browser will not cache Facebook login cookies and next time when we intent to authenticate a new user/credentials the login screen will appear nicely. And of course, if we logout the user from a different screen as the login one, the webbrowser component can be made “invisible”


Just my simple solution for a clean windows phone facebook logout.

Wednesday, June 8, 2011

5 easy steps for a Windows Phone 7.1(Mango) to 7.0 application downgrade

 

I like to play a lot with latest beta version of Windows Phone named Mango.
I like mostly the new Windows Phone Performance Analysis tool available in Debug menu.

image

But after I tested my app, when in comes to come back to current version in market (7.0) the application platform cannot be changed back.

image

Let’s do some tricks to get it back in just five easy steps.

1. Unload the wp7 application

image

image

2. Edit the project (.csproject) files

image

change the line

    ...
<
TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile>
...

into

    ...
<
TargetFrameworkProfile>WindowsPhone</TargetFrameworkProfile>
...
3. Reload the project
image
4. Edit Properties\WMAppManifest.xml file
image
5. Change AppPlatformVersion of Deployment node
from 7.1 to 7.0
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.1">

to

<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">

That’s all folks!

Saturday, June 4, 2011

“en-ro dic” windows phone app approved

Hi folks!

Just as I promised, since “en-ro dic” application was approved (quite fast I must admit), I came back with download link for those of you who wish to use it right away.
Of course you can search it also in Windows Phone Marketplace from your WP7 phone, based on keywords: “en-ro”, “romania” etc.

Have a nice time translating Romanian - English, back and forth!

en-ro dic wp7 app downloaden-ro dic

Wednesday, June 1, 2011

"EN-RO DIC" - My first WP7 app published in Marketplace to be approved

   A few days ago I proposed myself (and not only) a nice challenge. To create some small but useful applications in the languages and technologies we know the best, with a single goal.. to provide in maximum 2 days, a full featured product.
   This exercise will help me (us) in getting knowing better and efficiently the newest technologies, but also it could constitute a good base ground for a potential business start-up.
So I started first by myself with a simple application: “EN-RO DIC” – an English – Romanian Translation Dictionary, that could work offline but also online with the help of well known available online translators: Google and Bing(Microsoft).
   Unfortunately this first experience was cost me more that proposed time, and instead of 2 days I ended with 3 days (50% more with ~7-9 hours/day for research and coding). But all was for a great cause!. It was a nice experience where I learn a lot about how to improve a windows phone application overall  performance. I also had the chance to learn new tools and libraries (for example Telerik windows phone controls – because I have won a free license from them within a webinar session, I think), to work with Google and Bing translation API and various other libraries.
   Putting all together, I’m very satisfied with performance gain I succeed to obtain (~40k EN to RO words and ~70k RO to EN words), almost instant loading on the first launch or restore from tombstoning, and very fast search of the words into offline dictionary. Here are some screenshots of the final application which you will find later onto Windows Phone Market after approval process with the name “en-ro dic” (I will provide a Zune link later after approval):
dic_enro (1)dic_enro (2)dic_enro (3)dic_enro (5)dic_enro (4)
   Of course, not everything is pixel perfectly, so there will be room for improvement, but for the issues I know about, I can only blame Microsoft  :) .
   As for the future roadmap, perhaps some TextToSpeach(TTS) feature, favourite words, user proposed words, etc. There are some ideas, we only lack some time to invest. If any of you is feeling courageous to continue this project improvement, please feel free to contact me as for me this project is already doing all I have expected from it.

Feedback is always welcome!
Thank you!