Click here to Skip to main content
Licence CPOL
First Posted 19 Feb 2012
Views 3,608
Bookmarked 1 time

Hidden Pics: My first App on Windows Phone marketplace

By | 19 Feb 2012 | Technical Blog
My first app on Windows Phone marketplace
A Technical Blog article. View original blog here.[^]

Just days ago, I finished and published my first app to Microsoft Windows Phone Marketplace. As part of the "#30tolaunch" program, I must admit that waiting for the app to be certified was a little scaring, but the app was approved without any trouble and is already up, you can grab it here.

Now the idea of the app is simple, it uses the Isolated Storage to hide pictures you want to keep out of curious people looking at your phone. And it involves two common elements that might be useful for you in future apps.

  1. Isolated Storage
  2. Photo Chooser Task

Isolated Storage

The Isolated Storage is a virtualized file system so your app can't really access the device storage like it used to be. If you are a Windows Mobile developer, you might remember those times where you could write/read files all across the filesystem of a Windows device. Thankfully, that's not like that anymore. And you get a isolated space just for your application. Reading bytes from a file on that storage looks like this:

public static byte[] GetFullImageBytes(string f)
        {
            byte[] data;
            using (IsolatedStorageFile isf = 
        IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream isfs = isf.OpenFile
        (Path.Combine(PHOTO_ROOT, f), FileMode.Open, FileAccess.Read))
                {
                    data = new byte[isfs.Length];
                    isfs.Read(data, 0, data.Length);
                    isfs.Close();
                }
            }
            return data;
        }

In a nutshell, it is pretty much what you do using the regular File, Directory and Stream classes in System.IO Namespace. Just that now you are reduced to work over a private space for your application and not the whole storage device.

Photo Chooser Task

Letting the user select a photo from either the media library or the camera is a very straight forward action. Paraphrasing Chris Koenig, this is an "anti-climatic" kind of stuff, because it is so easy, that you have nothing to ask, and hence, you might get bored. If you remember battling with a camera in Windows Mobile 5.0, you will love this.

public void ShowPhotoChooser()
        {
            PhotoChooserTask photoChooserTask = new PhotoChooserTask {ShowCamera = true};
            photoChooserTask.Completed += photoChooserTask_Completed;
            photoChooserTask.Show();
        }

        void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                Helper.AddPhoto(e);
                LoadElements();
            }
        }

Just opening the photo chooser task will let the user select a picture from the media library or take one from the camera. No work with the camera is involved at all, not even with the Media Library. All you get is a file at the end of the process, no matter if the file is new from the camera or it was selected from a user's photo album.

The Overall Experience

Being a developer from the times of eVB and eVC, then .NET Compact Framework with C# (which did rock, but wasn't enough), I must say the experience is great. I do miss some low-level power control with p/invoke (which is forbidden in the marketplace). Also miss control on how I could connect external devices to the phone and develop for that using COM ports. But with more sensors everyday on the phones, that might not be missed.

The UI being developed with Silverlight instead of Windows Forms is a huge step forward especially on screens that auto-rotate and re-layout. This could not get easier to develop using Visual Studio. And finally the process of submitting an app to the marketplace is easy and simple.

So... just submit your app.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Leonardo Paneque

Team Leader

United States United States

Member

Follow on Twitter Follow on Twitter
Leonardo loves to code with C# and thinks .NET platforms rocks.
He has a Master degree in Computer Sciences and likes to share code and ideas.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 PinmemberMember 847520811:34 9 Apr '12  
GeneralMy vote of 1 Pinmembernick_journals20:56 19 Feb '12  
GeneralRe: My vote of 1 PinmemberLeonardo Paneque22:00 19 Feb '12  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Beta | 2.5.120516.1 | Last Updated 19 Feb 2012
Article Copyright 2012 by Leonardo Paneque
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid