{"id":38,"date":"2006-10-29T21:21:17","date_gmt":"2006-10-29T20:21:17","guid":{"rendered":"http:\/\/dalelane.co.uk\/blog\/?p=38"},"modified":"2006-10-30T02:37:49","modified_gmt":"2006-10-30T01:37:49","slug":"using-nets-web-browser-to-create-a-mobile-wiki","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=38","title":{"rendered":"Using .NET WebBrowser to create a mobile wiki"},"content":{"rendered":"<p>Wrote another Windows Mobile app tonight &#8211; this time I even tried it out on <a href=\"http:\/\/www.europe.htc.com\/products\/qtek9000.html\" title=\"HTC Universal - my PDA phone\" target=\"_blank\">my phone<\/a> and not just the emulator!<\/p>\n<p>The idea of this one is an alternative to the built-in Windows Mobile &#8220;Notes&#8221; application. Instead of single &#8216;post-it-style&#8217; notes, the idea is to use a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Wiki\" title=\"Wikipedia reference: wiki\" target=\"_blank\">wiki<\/a> approach &#8211; a personal wiki, entirely hosted on the PDA. (Partly because it is quicker to use local files, but mainly because I&#8217;m too skint to pay the mobile data fees to access an online wiki :-))<\/p>\n<p>I prefer the wiki approach to note-taking &#8211; mainly for the quick and easy formatting and the hyperlinks between pages. I&#8217;ve used something similar before on Palm OS for a couple of years now &#8211; &#8216;<a href=\"http:\/\/www.dogmelon.com.au\/NoteStudio.shtml\" title=\"NoteStudio product site\" target=\"_blank\">NoteStudio<\/a>&#8216; by DogMelon. This is a brilliant app, which I really miss since moving to Windows Mobile as my main PDA. (There has been <a href=\"http:\/\/www.dogmelon.com.au\/nsforum\/viewtopic.php?t=813\" title=\"NoteStudio forums\" target=\"_blank\">some talk<\/a> of a Windows Mobile for a while now, but this is looking a little like <a href=\"http:\/\/en.wikipedia.org\/wiki\/Vaporware\" target=\"_blank\" title=\"Wikipedia reference: vaporware\">vaporware<\/a>). <\/p>\n<p>When I saw that the .NET compact framework included a <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/3s8ys666.aspx\" title=\"MSDN documentation\" target=\"_blank\">web browser widget<\/a>, I thought I&#8217;d see how hard it would be to knock together a wiki tool tonight.<\/p>\n<p><!--more--><img decoding=\"async\" hspace=\"5\" src=\"http:\/\/dalelane.co.uk\/blog\/post-images\/061029-wikiview.gif\" alt=\"my Wiki app in view mode\" align=\"left\"\/>After <a href=\"http:\/\/dalelane.co.uk\/blog\/?p=39\" title=\"yesterday's blog post\">fighting with native C++ GUI code yesterday<\/a>, this was really easy. I&#8217;ve got two controls &#8211; a text box and a web browser box &#8211; both configured to fill the available screenspace (so it works in portrait or landscape modes). One is visible, while the other is invisible &#8211; 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&#8217;ve added a bit more functionality to make it vaguely usable&#8230;<br \/>\n<img decoding=\"async\" hspace=\"5\" src=\"http:\/\/dalelane.co.uk\/blog\/post-images\/061029-wikiedit.gif\" alt=\"my Wiki app in edit mode\" align=\"right\"\/><\/p>\n<p><strong>Creating pages automatically<\/strong> &#8211; a typical wiki behaviour is that clicking on a link to a page that doesn&#8217;t exist should create that page. I&#8217;ve done that by listening for when a link is clicked on in the browser (registering for <code>WebBrowserNavigatingEventHandler<\/code> events), and checking to see if the target file exists. If it doesn&#8217;t, I create it &#8211; 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 &#8211; so all new pages start with my standard menu header by default.)<\/p>\n<p>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. &#8220;home&#8221;), I append &#8220;.txt&#8221; to find the relevant text file (&#8220;home.txt&#8221;). 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&#8217;m doing is adding a <code>&lt;head&gt;<\/code> section at the start of the file contents, and closing up the <code>&lt;body&gt;<\/code> 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 &#8216;Home&#8217;, rather than to HTML files, like &#8216;Home.htm&#8217;) is the start of making this more wiki-like. <\/p>\n<p>This is enough for tonight&#8217;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 &#8211; this was easy. After only a hour or so, I&#8217;ve already got a very usable app. I&#8217;ll have to come back to this again soon. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wrote another Windows Mobile app tonight &#8211; 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 &#8220;Notes&#8221; application. Instead of single &#8216;post-it-style&#8217; notes, the idea is to use a wiki approach &#8211; a personal wiki, entirely [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-code"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=38"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}