Tuesday, March 18, 2008

How to allow minimize being in a modal dialog on Pocket PC using the .Net CF

An interesting question came up today at the Mobility Metro train the trainers workshop in London: How can we allow the Pocket PC user to minimize the application even when he is in a modal dialog?

This is a particular requirement received by an attendee, and it was a little bit challenging problem. I did a small spike on this, and this is my suggested approach.

First of all, we cannot use Form.ShowDialog(), because it shows the 'OK' button at the top right corner, and ideally we should keep the standard 'X' smart minimize button there.

The solution is to use Form.Show() and handle the Form.Closed event of the dialog. We also should take care of the dialog Owner property in order to show only one entry on the Running Programs List.

private void menuItem1_Click(object sender, EventArgs e)
{
Dialog dialog = new Dialog();

//Prepare the app to be 'Running Programs Aware'
this.Text = dialog.Text;
dialog.Owner = this;

//Subscribe to the dialog closed event
dialog.Closed += delegate(object s2, EventArgs e2)
{
//Do something when the dialog is closed
label1.Text = string.Format("DialogResult = {0}", dialog.DialogResult.ToString());
//Update the form text back
this.Text = "MainForm";
};
dialog.Show();
}

Here you can find the spike sourcecode:



 


 


Sunday, March 9, 2008

Going back to London for Microsoft Mobility Metro 2008 Train The Trainers (TTT)

Well, I'm glad to say that I've been invited to be instructor in the Microsoft Mobility Metro "Train the Trainers" in UK. It will be my second time in London and I'm sure it'll be as great as the previous one was.

This will be a three days mobility training targeting european instructors audience, that will start on March 18th. The agenda includes several topics, starting with Windows Mobile platform concepts, moving thru the tools, managed code for devices, SQL Compact Edition, Optimization and guidance, and an interesting review of what's coming on in mobile development. Hope to see some of you there.

These days are very busy for me, but I'll try to keep blogging. Stay tuned!

Saturday, March 1, 2008

Looking for an OpenFileDialog for Smartphone? Porting the MobilePractices.OpenFileDialogEx from PocketPC to Smartphone

This morning I've ported the MobilePractices.OpenFileDialogEx custom implementation of the OpenFileDialog to smartphone. Strictly, I've ported it to Windows Mobile 6 Standard Edition. And I want to remark that Smartphone doesn't even support the standard OpenFileDialog. If you try to use the standard version a NotSupportedException is raised. So I thought this port should be extremely useful, and it's additionally fully implemented using the .Net Compact Framework (.Net CF).

The port was pretty much straightforward, besides the expected design constrains. It took me exactly 75 minutes. What were the main issues I have during the process? First of all, the need to make it usable in the smartphone platform. It doesn't make sense to have the same structure with one combo box, the list, and the textbox at the bottom. So, my design decision was to leave the list. I know you may have a new smartphone device which has a qwerty keyboard, but I think it still being the simplest option just to browse the file system. Actually I used to do that even in my laptop. And if I keep the textbox, it'll leave less space for the list, and I think that's critical here. Anyway, if you prefer you can bring the textbox back from the pocket pc version.

The second main issue was how to provide the quick go back to any directory on the current path without the combo box. I've decided to implement this using the right menu, the same way File Explorer does.

It looks this way in the Windows Mobile 6 Standard Edition emulator:

image image

Not bad! But it still being just a starting point. There are many features missing which you probably will find critical in your app. As you can probably noticed, the file list is not sorted, there are no InitialDirectory property, and it doesn't cached any directory info to improve the performance during the browsing. Feel free to add any feature you want. The source code is here: