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:

1 comment:

Anonymous said...

Thanks this is exactly what I needed to speed up the development of a recent application