Nothing at all and Everything in general.

Remember the Permission

I had a bit of a late night last night. I had just downloaded the Windows Live SDK and wanted to try it out. I took the Voice Memo application tha tI put on CodeProject.com and tried to add a feature to upload recordings to Skydrive. In the SDK there is a SignInButton controll and setting some parameters on this control along with responding to an event the control has is all that is needed to to make use of it. When I ran my program it failed with an error about the WebBrowserControl neededing to be on the visual tree before it is used. 

You cannot call WebBrowser methods until it is in the visual tree."

This was a little confusing to me at first. I am not using a web browser control anywhere in my program. So I played with the parameters on the control trying to see if I could change the response I was getting. After continual failure I posted a question on the Windows Live Connect support forums.  One of the Microsoft employees asked me if I could make a simple project demonstrating the problem. When I made my simple project the error would not occur. I then realized what was causing the problem. The Voice Memo application has had its permissions appropriately reduced. But those reduced permissions did not include what was needed by the login control. I ran the Windows Phone Marketplace Test kit and it told me the other permissions that I needed; ID_CAP_WEBBROWSERCOMPONENT  and ID_CAP_NETWORKING. After adding those permissions it worked like a charm!

Rather than sweep my mistake under a rug I thought I would share it in the hopes that posting this will save some one from having made the simple yet time consuming oversight that I had


Windows Phone Camp is Coming!

What's a Windows Phone Camp? 
A free, full day event chock-full of everything you need to know to develop a Windows Phone application. Whether you're a seasoned veteran or just getting started with .NET development this full-day event is for you. Interested in profit? We'll also lead discussions on how to monetize your applications and generate profits with your apps.

Don't miss the new Windows Phone 7.5 (codename "Mango") features as well - with detailed sessions in the afternoon around Fast Application Switching, Multitasking, Live Tiles, Push Notifications, and more. 

The day will be capped with an 
open lab hands-on session and prizes for apps completed. This is the perfect opportunity to begin work on your dream application, or finish that app you've already started, with Windows Phone experts there to guide you every step of the way. Bring your own laptop to join in the fun and show off your killer app! 


9:00 AM


Description: Description: Description: C:\Users\Public\Documents\Webcamps Email - All\PHONE CAMPS\phonecamps_metro_er_allup_OFT_EVANG\spacer.gif


Welcome Campers

9:15 AM


Description: Description: Description: C:\Users\Public\Documents\Webcamps Email - All\PHONE CAMPS\phonecamps_metro_er_allup_OFT_EVANG\spacer.gif


How to make money with your Windows Phone app

10:00 AM


Description: Description: Description: C:\Users\Public\Documents\Webcamps Email - All\PHONE CAMPS\phonecamps_metro_er_allup_OFT_EVANG\spacer.gif


Frameworks for fun and profit > Silverlight and XNA



Description: Description: Description: C:\Users\Public\Documents\Webcamps Email - All\PHONE CAMPS\phonecamps_metro_er_allup_OFT_EVANG\spacer.gif



1:00 PM


Description: Description: Description: C:\Users\Public\Documents\Webcamps Email - All\PHONE CAMPS\phonecamps_metro_er_allup_OFT_EVANG\spacer.gif


Hands-on lab

3:00 PM


Description: Description: Description: C:\Users\Public\Documents\Webcamps Email - All\PHONE CAMPS\phonecamps_metro_er_allup_OFT_EVANG\spacer.gif


Cool stuff your app can do

4:00 PM


Description: Description: Description: C:\Users\Public\Documents\Webcamps Email - All\PHONE CAMPS\phonecamps_metro_er_allup_OFT_EVANG\spacer.gif


To the Cloud

4:45 PM


Description: Description: Description: C:\Users\Public\Documents\Webcamps Email - All\PHONE CAMPS\phonecamps_metro_er_allup_OFT_EVANG\spacer.gif


Be What's Next > People's Choice Awards


Bring a notebook computer and identification. Also check out the APP HUB where you can get developer toolslearn about application featuresunderstand common task for Apps and register and load your APP.

This event is brought to you by Microsoft and is free of charge. However, you are responsible for booking and paying for your own travel and accommodations.

Event Locations
9/20 - Charlotte, NC
9/22 - Alpharetta, GA
9/27 - Malvern, PA
9/29 - Reston, VA
10/18 - Chevy Chase, MD
10/19 - New York, NY
10/25 - Tampa, FL
10/27 - Burlington, VT
11/2 - Raleigh, NC
11/4 - Ft. Lauderdale, FL
11/8 - Orlando, FL
11/10 - New Paltz, NY
11/10 - Miami, FL
11/15 - Blacksburg, VA
11/17 - Washington, DC
11/29 - Pittsburgh, PA
11/29 - Atlanta, GA
12/1 - Long Island, NY

Passing thoughts, video effects on Windows Phone

Some years ago I saw the movie "A Scanner Darkly." There isn't much to talk about as much as the plot goes, but the visuals of the movie were unique. The movie was done with real actors but it the look of everything was as though it were drawn like a cartoon.

I thought about making an application that would allow some one to produce a similar effect in real time (or close to it) using a phone's camera. I thought I would be able to implement it with the K-means algorithm operating within color space (I will do another post on the details of this). Before diving into this task I needed to make sure that the phone was capable of doing this. I started by taking a look at Windows Phone and these were the main things that I needed to be able to satisfy:

  • Is real time access to the camera available
  • Can I render video frames to the screen at a rate
  • Can the phone provide the computational capability to quickly do the image processing

One of the new capabilities that comes with the Mango update to Windows phone is access to the camera. In addition to getting information from the camera through tasks (which was available with the initial release of Windows Phone) Microsoft has granted developers the ability to paint a surface with a live feed from the camera, capture a video from the camera, capture a frame from the preview buffer, and take a photograph (without user interaction) from the camera. Let's examine how each one of those features does or does not contribute towards my goal and the program design.

Because of the the nature of my goal (to work with video) the Windows Phone Tasks (Camera Capture and Photo Chooser) won't work for my program. They both require user interaction for each frame captured. That's no way to work with video.

What about taking pictures automatically? This doesn't quire work either. Picture taking is slow. In general you'll find that the CCDs used in many digital devices are now able to capture and transmit the information from a full resolution photograph as quickly as they do when sending lower resolution video.

The ability to display the video buffer on screen looks promising. With it you can display what ever the camera sees. However this capability is only for displaying the camera's "vision" on the screen and rendering over it (such as in augmented reality).

This leaves two methods left: using the preview buffer and using the phone's video capturing abilities. Using the phone for video capture gives the highest framerate but it ceases to be real time. I'd be fine with that. That would just mean that some one would need to film a video and then it would play back with the video affect applied. But that would also require that I decode the resulting MP4 video myself (there's no video codec available to do this). So the preview buffer seemed like the best option. So I did a quick test to see how many frames I could capture per second (before performing any processing).


public MainPage()
    _camera = new PhotoCamera();
    _camera.Initialized += new EventHandler<CameraOperationCompletedEventArgs>(_camera_Initialized);            

void _camera_Initialized(object sender, CameraOperationCompletedEventArgs e)
    var x = _camera.PreviewResolution;
    int pixelCount = (int) (x.Width*x.Height);
    buffer = new int[pixelCount];
    Dispatcher.BeginInvoke(() => { });

    Thread ts = new Thread(new ThreadStart(GrabFrames));

void GrabFrames()
    var startDate = DateTime.Now;
    for(int i=0;i<100;++i)
    var endTime = DateTime.Now;
    var delta = endTime.Subtract(startDate);

The results I got back on a Mango Beta HD7 worked out to 10 frames per second. Not quite real time video. So it looks like my best option is to go with the MP4 video recorder. I'll have to figure out how to read frames from an MP4 file.

I'm glad I was able to figure that out before writing a substantial amount of code or doing a substantial amount of design.

Displaying an Image from Isolated Storage

I was writing some code for someone and for the scenario I needed to display images that were stored in isolated storage. Unfortunately at present the Image element in Silverlight doesn't support displaying images from Isolated storage. You must load the image yourself and then give the loaded image to an Image element. At first glance this is annoying because I wanted to just give the image a URI to something stored in solated storage and let the element do it's magic. After a few minutes of thinking I realized I can still do this provided I create a converter to do some of the needed work.  I wanted to ensure the converter was both compatible with the URIs that point to isolated storage and those that refer to locations on the internet. 

public class FilePathToImageConverter: IValueConverter
    private static IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication();

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        string path = value as string;
        if (String.IsNullOrEmpty(path))
            return null;
            using (var sourceFile = ISF.OpenFile(path.Substring(9), FileMode.Open, FileAccess.Read))
                BitmapImage bm = new BitmapImage();
                return bm;
            BitmapImage bm = new BitmapImage(new Uri(path));
            return bm;

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        throw new NotImplementedException();

To use it bind a string value to the Source property of the Image element. The file path must be prefixed with "isostore:" for the converter to extract the image from isoated storage. if the "isostore:" prefix is not present the converter will attempt to load the image using a regular Uri.

bada 2.0 Released

bada is Samsun's operating system for lower priced phones (note: the lowercase 'b' is not a type, it is always spelled in lower case). I had interest in an earlier version of bada but there was one thing that kept me away; the SDK did not have support for 64-bit computers. You could run it on 64-bit computers but it would creash frequently and behave in odd ways. Version 2.0 of bada was recently release and one of the new features the SDK has is that it will work on 64-bit computers. I am downloading the SDK now and hope to get started with it soon. 

You can find more information and the SDK download from bada.com.

StartUp Camp

This weekend I went to an event known as "StartUp." Apparently these events are not uncommon, but it was new to me and was an interesting experience. In a Start-up weekend people present their ideas for an application to developers, artists, and people of other skills. After the presentation of the initial ideas people organize themselves into teams and try to make the application a reality.

The event ran from Friday to Sunday. Of those three days I was only present on Sunday to help some people out and ended up being dedicated to a single team helping them out with their Windows Phone coding. At the end of the event every one does their presentations on what they came up with to a panel of judges. There's also people there that are ready to fund projects. I wish I had known of events like this before. These are perfect opportunities for people that have application ideas but can't make the application by themselves. 

Slides from What's New in Windows Phone Mango

Last month I did a presentation at the Macon .Net user group on what's new in Windows Phone Mango. I also presented this at the Atlanta Windows Phone developer's group. The slides were uploaded to Skydrive a few days ago but I never did post the link. So here it is. You can download the slides and the example code from here.

Windows Phone NTP Client

Download Code (53 KB)

I've got plans for an application in which I need to know with certainty the current time. So I don't want to trust the time as reported by the user's device. Instead I need to retrieve the time from a server. I made a NTP (Network Time Protocol) client for retrieving this information. This is something that couldn't be done on Windows Phone 7 prior to Mango. But with the fall update (Mango) access to sockets is granted.

The use of the client is pretty simple. At minimum one can create the client with the default constructor, subscribe to the ReceivedTime event, and call the RequestTime method to initiate a request. The ReceivedTime event may be called on a thread other than the UI thread so remember to use a dispatcher when making UI updates.

NTP Client

This is an example of a client using the code to display both the system time and the network time.

public partial class MainPage : PhoneApplicationPage
    private NtpClient _ntpClient;
    public MainPage()
        _ntpClient = new NtpClient();
        _ntpClient.TimeReceived += new EventHandler<NtpClient.TimeReceivedEventArgs>(_ntpClient_TimeReceived);

    void _ntpClient_TimeReceived(object sender, NtpClient.TimeReceivedEventArgs e)
        this.Dispatcher.BeginInvoke(() =>
                                            txtCurrentTime.Text = e.CurrentTime.ToLongTimeString();
                                            txtSystemTime.Text = DateTime.Now.ToUniversalTime().ToLongTimeString();

    private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)

    private void UpdateTimeButton_Click(object sender, RoutedEventArgs e)

XNA Animated Sprite code uploaded to CodeProject.com

I've uploaded some code I was working on to animate sprites in XNA.

Animating a sprite isn't difficult, but I wanted some way to animate them but reduce the coupling between code and the animation. The Content Pipeline is perfect for this. So I created a component that will handle the animation scenarios that I need along with a content extension so that I could load these animations as content. Right now the animation information is in an XML file. This is a stepping point towards having a graphical tool for handling this.

You can read about the code here or see a brief description of it in the video below

Site Mirror

It seems that my hosting provider has gone through some changes for the worst; once a week for the past three weeks this site has gone offline because of some failure or data loss at my provider's location. Because of the decrease in reliability I'll be looking for a new provider. In the mean time I've started mirroring my content at http://j2inet.wordpress.com/. Any new content I write will also be published there (I may just use WordPress as the primary host for this site, still undecided). If this site ever goes down remember you can see the content there too.