Wrote another Windows Mobile app tonight – this time I even tried it out on my phone and not just the emulator!
The idea of this one is an alternative to the built-in Windows Mobile “Notes” application. Instead of single ‘post-it-style’ notes, the idea is to use a wiki approach – a personal wiki, entirely hosted on the PDA. (Partly because it is quicker to use local files, but mainly because I’m too skint to pay the mobile data fees to access an online wiki :-))
I prefer the wiki approach to note-taking – mainly for the quick and easy formatting and the hyperlinks between pages. I’ve used something similar before on Palm OS for a couple of years now – ‘NoteStudio‘ by DogMelon. This is a brilliant app, which I really miss since moving to Windows Mobile as my main PDA. (There has been some talk of a Windows Mobile for a while now, but this is looking a little like vaporware).
When I saw that the .NET compact framework included a web browser widget, I thought I’d see how hard it would be to knock together a wiki tool tonight.
After fighting with native C++ GUI code yesterday, this was really easy. I’ve got two controls – a text box and a web browser box – both configured to fill the available screenspace (so it works in portrait or landscape modes). One is visible, while the other is invisible – and I use one of the soft-keys to toggle between the two. The web-browser shows the wiki page as a web page, the text box lets you edit the HTML code. I’ve added a bit more functionality to make it vaguely usable…
Creating pages automatically – a typical wiki behaviour is that clicking on a link to a page that doesn’t exist should create that page. I’ve done that by listening for when a link is clicked on in the browser (registering for
WebBrowserNavigatingEventHandler events), and checking to see if the target file exists. If it doesn’t, I create it – before the web browser has had a chance to look for it. (I also set up a little dialog to let the user define a template which I use for newly created pages – so all new pages start with my standard menu header by default.)
My first attempt was just a straight text editor to edit the HTML directly. I want to move towards a simpler wiki-markup, so I did a bit of work towards that. Instead of storing the pages as HTML files, I store them as text files. When the user clicks on a link (e.g. “home”), I append “.txt” to find the relevant text file (“home.txt”). If in edit mode, I just load this into the text box. If in view mode, I turn this into HTML on-the-fly for viewing. At the moment, all I’m doing is adding a
<head> section at the start of the file contents, and closing up the
<body> tags after. But this separation between the HTML displayed and the text stored, and the fact that I now have links to topic names (like ‘Home’, rather than to HTML files, like ‘Home.htm’) is the start of making this more wiki-like.
This is enough for tonight’s hacking, but this is an app that I can see myself using a lot. I really like Visual Studio 2005 and the Windows Mobile emulators – this was easy. After only a hour or so, I’ve already got a very usable app. I’ll have to come back to this again soon.