<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jonathan C Dickinson &#187; Programming</title>
	<atom:link href="http://jonathan.dickinsons.co.za/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathan.dickinsons.co.za/blog</link>
	<description>&#34;Jonathan Chayce Dickinson&#34;.ToString()</description>
	<lastBuildDate>Sun, 06 Jun 2010 11:07:31 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Android: Emulator Can&#8217;t Find Images</title>
		<link>http://jonathan.dickinsons.co.za/blog/2010/06/android-emulator-cant-find-images/</link>
		<comments>http://jonathan.dickinsons.co.za/blog/2010/06/android-emulator-cant-find-images/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 11:07:31 +0000</pubDate>
		<dc:creator>Jonathan Dickinson</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Top Hacks]]></category>

		<guid isPermaLink="false">http://jonathan.dickinsons.co.za/blog/?p=201</guid>
		<description><![CDATA[Fix the 'could not find virtual device named' error with Android Emulator.]]></description>
			<content:encoded><![CDATA[<p>If you are getting an error message from the Android emulator similar to:</p>
<pre class="brush: plain;">
emulator: ERROR: unknown virtual device name: 'xxx'
emulator: could not find virtual device named 'xxx'
</pre>
<p>It&#8217;s because the Android emulator works a little differently from the rest of the SDK (the rest of the SDK is Java, emulator.exe is C/++). The rest of the SDK behaves correctly in terms of user home folder (I move mine to a different hard disk) and emulator.exe has it hardcoded (depending on your OS). In Windows 7 and Vista that means it ALWAYS looks in &#8220;C:\Users\&lt;username&gt;\.android&#8221;. The fix for this is simple (in a command prompt under Vista/Win7):</p>
<pre class="brush: plain;">
C:
cd C:\Users\&lt;user name&gt;
mklink /j .android &lt;new home directory&gt;\.android
</pre>
<p>Worked for me. Source: <a href="http://forum.xda-developers.com/showpost.php?p=5612951&#038;postcount=12">XDA Developers</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonathan.dickinsons.co.za/blog/2010/06/android-emulator-cant-find-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Contracts</title>
		<link>http://jonathan.dickinsons.co.za/blog/2010/01/code-contracts/</link>
		<comments>http://jonathan.dickinsons.co.za/blog/2010/01/code-contracts/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 20:38:34 +0000</pubDate>
		<dc:creator>Jonathan Dickinson</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Short]]></category>
		<category><![CDATA[XMPP Server 2010]]></category>

		<guid isPermaLink="false">http://jonathan.dickinsons.co.za/blog/?p=179</guid>
		<description><![CDATA[I recently started using CodeContracts and have a few tips.]]></description>
			<content:encoded><![CDATA[<p>I have recently started using the <a href="http://research.microsoft.com/en-us/projects/contracts/">Microsoft CodeContracts</a> on a large scale. These have been a fantastic addition to my toolset; because when I get the green flag on my code I know that I am <em>pretty</em> safe (it is beta, after all). I had to migrate quite a bit of code into the contracts and found that it can be quite a daunting task. A few things that I have picked up are:</p>
<ul>
<li>If you are migrating existing code and worrying only about contracts, switch off background checking. Firstly, this means that the results you get are comprehensive and secondly because of the build time you will think twice about hitting that build key again. Long builds == fewer builds == more time thinking == better code.</li>
<li>Use code snippets. The ones provided by Microsoft are great! Think about creating your own or changing them. For example cren and cresn no longer throw ArgumentExceptions for me; they are both ArgumentNullExceptions. I also have snippets like create contract class for (cc &#8211; scaffolding for ContractClassFor) and contract class implementation (cci &#8211; ContractClass attributation).</li>
<li>Invariants are your friend. Figure out what state a class should really be in and depend on that rather than Contract.Requires everywhere.</li>
<li>A well placed Contract.Ensures will save you a lot of grief.</li>
<li>Don&#8217;t loose hope. It may seem like it&#8217;s daunting at first &#8211; but as you start thinking in terms of contracts things become a lot faster. A single well-thought out Contract call will often clear off 5 warnings (for the bigger projects).</li>
<li>Some classes can be skipped ([ContractVerification(false)]) &#8211; especially if they are internal. Don&#8217;t gung-ho and try and get everything in contracts; because sometimes they may be ill-suited for the task (and you would by &#8216;lying&#8217; just to get the stuff to pass). These situations are few and far between; but they are there.</li>
<li>New development = contracts. Full stop.</li>
</ul>
<p>Overall I am finding fewer and fewer Contract failures during each build. This is mainly because CodeContracts is getting me into a better and more disciplined mindset. It&#8217;s a great tool and I highly recommend it.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonathan.dickinsons.co.za/blog/2010/01/code-contracts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Code Block Toggler</title>
		<link>http://jonathan.dickinsons.co.za/blog/2009/12/code-block-toggler/</link>
		<comments>http://jonathan.dickinsons.co.za/blog/2009/12/code-block-toggler/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 22:42:34 +0000</pubDate>
		<dc:creator>Jonathan Dickinson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Top Hacks]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://jonathan.dickinsons.co.za/blog/?p=171</guid>
		<description><![CDATA[Handy snippet to switch between two code blocks.]]></description>
			<content:encoded><![CDATA[<p>I came across one of the most awesome meta-language features for C-style languages (specifically any language that has /* */ and // comment support). The nitty-gritties are up at <a href="http://theycallmemrjames.blogspot.com/2009/06/toggle-between-code-blocks.html">a rather good blog</a>. I whipped up a snippet to handle this automatically.</p>
<p>It has a few notable features &#8211; it gives a reason for the flip, it wraps it in a region, it has a auto-task FLIP: prefix and it explains how it&#8217;s used.</p>
<pre class="brush: csharp;">
            #region Flip - This new behaviour is experimental. -
            // FLIP: This new behaviour is experimental.
            //*/// Two proceding slashes will activate the first block, one will activate the second.
            Console.ReadLine();
            /*/
            Console.ReadLine();
            //*/
            #endregion Flip - This new behaviour is experimental. -
</pre>
<p>Drop it in your My Code Snippets folder. In VS select the code you want to flip-comment, Hold CTRL, Press K, Press S, Release CTRL, Press M, Press Enter, Press F, Press Enter (I wish you could assign hot keys to snippets!).</p>
<p><a href='http://jonathan.dickinsons.co.za/blog/wp-content/uploads/2009/12/flipper.txt'>Code Block Flipper</a> (WordPress won&#8217;t let me upload .snippet &#8211; so you will need to rename it)</p>
]]></content:encoded>
			<wfw:commentRss>http://jonathan.dickinsons.co.za/blog/2009/12/code-block-toggler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically Wrap BeginInvoke (dispatch)</title>
		<link>http://jonathan.dickinsons.co.za/blog/2009/12/automatically-wrap-begininvoke-dispatch/</link>
		<comments>http://jonathan.dickinsons.co.za/blog/2009/12/automatically-wrap-begininvoke-dispatch/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 07:24:46 +0000</pubDate>
		<dc:creator>Jonathan Dickinson</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://jonathan.dickinsons.co.za/blog/?p=165</guid>
		<description><![CDATA[Easily handle multi-threaded events in .Net WinForms.]]></description>
			<content:encoded><![CDATA[<p><em>C# supports implicit/explicit conversions to Delegates.</em></p>
<p>Yes, big news. I was very surprised when I gave this a shot. It&#8217;s really just one of those things you really don&#8217;t expect to work. So how does this help us? I am sure you are quite sick of writing the following code (the same stuff applies to WPF, you just need to access it via the Dispatch member):</p>
<pre class="brush: csharp;">
void _items_CollectionChanged(object sender, CollectionChangedEventArgs&lt;ConnectionListItem&gt; e)
{
    if (InvokeRequired)
    {
        Invoke(new EventHandler&lt;CollectionChangedEventArgs&lt;ConnectionListItem&gt;&gt;( _items_CollectionChanged ), sender, e);
        return;
    }

}
</pre>
<p>The &#8216;big news&#8217; allows us to do all the heavy lifting for the dispatch BeginInvoke in one simple class (this is a first try &#8211; I&#8217;ll get round to reviewing it later on).</p>
<pre class="brush: csharp;">
    /// &lt;summary&gt;
    /// Represent a wrapper for a delegate.
    /// &lt;/summary&gt;
    /// &lt;typeparam name="T"&gt;The type of event args.&lt;/typeparam&gt;
    public class InvokeEventWrapper&lt;T&gt;
        where T : EventArgs
    {
        private EventHandler&lt;T&gt; _apparantHandler;
        private EventHandler&lt;T&gt; _rawHandler;
        private Control _parent;

        /// &lt;summary&gt;
        /// Initializes a new instance of the &lt;see cref="InvokeDelegateWrapper&lt;T&gt;"/&gt; class.
        /// &lt;/summary&gt;
        /// &lt;param name="parent"&gt;The parent.&lt;/param&gt;
        /// &lt;param name="handler"&gt;The handler.&lt;/param&gt;
        public InvokeEventWrapper(EventHandler&lt;T&gt; handler)
            : this(null, handler)
        {

        }

        /// &lt;summary&gt;
        /// Initializes a new instance of the &lt;see cref="InvokeDelegateWrapper&lt;T&gt;"/&gt; class.
        /// &lt;/summary&gt;
        /// &lt;param name="parent"&gt;The parent.&lt;/param&gt;
        /// &lt;param name="handler"&gt;The handler.&lt;/param&gt;
        public InvokeEventWrapper(Control parent, EventHandler&lt;T&gt; handler)
        {
            if (handler == null)
                throw new ArgumentNullException("handler");
            if (parent == null)
                parent = (Control)handler.Target;

            _parent = parent;
            _rawHandler = handler;
            _apparantHandler = new EventHandler&lt;T&gt;(Raise);
        }

        /// &lt;summary&gt;
        /// Performs an implicit conversion from &lt;see cref="SharedTerminals.InvokeDelegateWrapper&lt;T&gt;"/&gt; to &lt;see cref="System.EventHandler&lt;T&gt;"/&gt;.
        /// &lt;/summary&gt;
        /// &lt;param name="wrapper"&gt;The wrapper.&lt;/param&gt;
        /// &lt;returns&gt;The result of the conversion.&lt;/returns&gt;
        public static implicit operator EventHandler&lt;T&gt;(InvokeEventWrapper&lt;T&gt; wrapper)
        {
            return wrapper._apparantHandler;
        }

        /// &lt;summary&gt;
        /// Raises the event.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The sender.&lt;/param&gt;
        /// &lt;param name="e"&gt;The e.&lt;/param&gt;
        private void Raise(object sender, T e)
        {
            if (_parent.InvokeRequired)
                _parent.BeginInvoke(_rawHandler, sender, e);
            else
                _rawHandler(sender, e);
        }
    }
</pre>
<p>Using it is pretty simple:</p>
<ol>
<li>Navigate to the event in Intellisense.</li>
<li>Type <em>+=</em>.</li>
<li>Press Tab.</li>
<li>Replace EventHandler with InvokeEventWrapper.</li>
</ol>
<p>So in the end all of that ugly code becomes:</p>
<pre class="brush: csharp;">
_items.CollectionChanged += new InvokeEventWrapper&lt;CollectionChangedEventArgs&lt;ConnectionListItem&gt;&gt;( _items_CollectionChanged );
</pre>
<p>You will need to hold onto a reference for that wrapper if you wish to unsubscribe from the event (one of the things I need to look at).</p>
]]></content:encoded>
			<wfw:commentRss>http://jonathan.dickinsons.co.za/blog/2009/12/automatically-wrap-begininvoke-dispatch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSRS Timeout on SSL 443 &#8211; Resolved</title>
		<link>http://jonathan.dickinsons.co.za/blog/2009/10/ssrs-timeout-on-ssl-443-resolved/</link>
		<comments>http://jonathan.dickinsons.co.za/blog/2009/10/ssrs-timeout-on-ssl-443-resolved/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 16:32:45 +0000</pubDate>
		<dc:creator>Jonathan Dickinson</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://jonathan.dickinsons.co.za/blog/?p=161</guid>
		<description><![CDATA[If you are getting either a 'The underlying connection was closed' or 'The operation has timed-out' error when deploying reports manually (add reference to web service) to SSRS via SSL on port 443 this fix may work for you.]]></description>
			<content:encoded><![CDATA[<h2>Manifestation of the Error</h2>
<p>If you attempt to connect to SSRS via the deployment webservice; when SSRS is running in SSL mode (specifically on port 443), you may get one of the following exceptions (which <strong>do not</strong> occur intermittently):</p>
<ul>
<li>The underlying connection was closed: An unexpected error occurred on a send.</li>
<li>The operation has timed-out.</li>
</ul>
<p>You might get it for other &#8220;The underlying connection was closed&#8221; errors, but I have not confirmed that. The issue occurs mainly when you try to upload report definitions that are over approximately 100kb.</p>
<h2>The Solution</h2>
<p>Let me tell you straight up &#8211; there is no reason to disable SSL or alter timeouts. The first thing you want to do is to add a new class to your project; I called mine SslReportService. Implement ReportingService2005 from your WebService reference. You can then override GetWebRequest(Uri) without worrying about your changes being lost of you update your web reference.</p>
<p>Then, in a nutshell:</p>
<pre class="brush: csharp;">class SslReportService : ReportService.ReportingService2005
{
  protected override System.Net.WebRequest GetWebRequest(Uri uri)
  {
    var res = (HttpWebRequest)base.GetWebRequest(uri);
    res.SendChunked = true;
    return res;
  }
}</pre>
<p>Your mileage may vary; so if this turns up nothing <a href="http://blogs.msdn.com/engelsr/articles/497902.aspx">Engels Rajangam</a> has another helpful post on this issue. You might want to read up on this property on <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.sendchunked.aspx">MSDN</a> and <a href="http://www.wintellect.com/CS/blogs/jeffreyr/archive/2009/02/08/httpwebrequest-its-request-stream-and-sending-data-in-chunks.aspx">a pretty good blog post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonathan.dickinsons.co.za/blog/2009/10/ssrs-timeout-on-ssl-443-resolved/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Direct to MSDN Chrome Search Tag</title>
		<link>http://jonathan.dickinsons.co.za/blog/2009/08/direct-to-msdn-chrome-search-tag/</link>
		<comments>http://jonathan.dickinsons.co.za/blog/2009/08/direct-to-msdn-chrome-search-tag/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 09:27:21 +0000</pubDate>
		<dc:creator>Jonathan Dickinson</dc:creator>
				<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Short]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://jonathan.dickinsons.co.za/blog/2009/08/direct-to-msdn-chrome-search-tag/</guid>
		<description><![CDATA[lo-band and high-band views easy in chrome.]]></description>
			<content:encoded><![CDATA[<p>If you ever need to get directly to the documentation for a specific type in MSDN (which Bing routinely fails to give me) here is a search provider for Chrome that will do the trick:</p>
<pre class="brush: plain;">http://msdn.microsoft.com/en-us/library/%s.aspx</pre>
<p>You can obviously also do something like:</p>
<pre class="brush: plain;">http://msdn.microsoft.com/en-us/library/%s(loband).aspx</pre>
<p>In case you need a refresher, here is how you add it:</p>
<ol>
<li>Click the wrench (top right).</li>
<li>Options</li>
<li>Basics (top)</li>
<li>Manage (alongside “Default Search”)</li>
<li>Add</li>
<li>Give it a name and keyword (the keyword is important).</li>
<li>Paste in my URL.</li>
</ol>
<p>To use it go to your address bar and type the keyword, tab and then the full type name. So for example (my keyword was msdnd):</p>
<pre class="brush: plain;">msdnd : [TAB] : system.xml.serialization.xmlelementattribute : [RETURN]</pre>
]]></content:encoded>
			<wfw:commentRss>http://jonathan.dickinsons.co.za/blog/2009/08/direct-to-msdn-chrome-search-tag/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>XLinQ Serialization</title>
		<link>http://jonathan.dickinsons.co.za/blog/2009/08/xlinq-serialization/</link>
		<comments>http://jonathan.dickinsons.co.za/blog/2009/08/xlinq-serialization/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 09:19:29 +0000</pubDate>
		<dc:creator>Jonathan Dickinson</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Short]]></category>

		<guid isPermaLink="false">http://jonathan.dickinsons.co.za/blog/2009/08/xlinq-serialization/</guid>
		<description><![CDATA[XmlSerializer suprisingly supports List<xelement>.</xelement>]]></description>
			<content:encoded><![CDATA[<p>Just found out that Microsoft actually had the foresight to support the following scenario:</p>
<pre class="brush: csharp;">/// &lt;summary&gt;
/// Gets the unknown elements as a &lt;see cref="List{XElement}"/&gt;.
/// &lt;/summary&gt;
[XmlAnyElement]
public List&lt;XElement&gt; UnknownElements
{
    get;
    set;
}</pre>
<p>Fantastic (undocumented) news.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonathan.dickinsons.co.za/blog/2009/08/xlinq-serialization/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TFS Server 2008 &#8211; Fail</title>
		<link>http://jonathan.dickinsons.co.za/blog/2009/07/tfs-server-2008-fail/</link>
		<comments>http://jonathan.dickinsons.co.za/blog/2009/07/tfs-server-2008-fail/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 06:26:51 +0000</pubDate>
		<dc:creator>Jonathan Dickinson</dc:creator>
				<category><![CDATA[Fail]]></category>
		<category><![CDATA[K2]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[TFS Server]]></category>

		<guid isPermaLink="false">http://jonathan.dickinsons.co.za/blog/?p=139</guid>
		<description><![CDATA[Installing TFS Server 2008 is far more difficult than it should be. What a waste.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s an amazing server. The installer needs A LOT of work. Here is what happened to me:</p>
<ol>
<li>Followed the pre-setup instructions to the T.</li>
<li>Run the installer; health check fails. SQL Server is the wrong version (2008 RTM); can&#8217;t find analysis services, NOTHING.</li>
<li>Hmm&#8230; must need SQL 2008 SP1. Install it via Windows Update.</li>
<li>Try again; health check fails. Wrong version of SQL Server, again.</li>
<li>Google &#8211; get a <a title="TFS 2008 and SQL 2008 SP1 solution" href="http://support.microsoft.com/kb/969985" target="_blank">solution</a>.</li>
<li>Follow those instructions to the T.</li>
<li>Installer <strong><em>CRASHES</em><span style="font-weight: normal;">. Each time it does this I need to </span><em>reboot</em><span style="font-weight: normal;">.</span></strong></li>
<li>Eventually just delete the SQL Server version check from hcpackages.xml</li>
<li>It looks like it&#8217;s installing now.</li>
</ol>
<p>16 hours later. TFS Server 2005 took me merely 4-5 hours (did it twice). Considering it&#8217;s a test-bed server where I am going to <em>continue</em> working on integrating K2 with TFS Server (we are going to be using K2 to automate our builds) this was just plain ridiculous.</p>
<p>It&#8217;s clever, and that&#8217;s about it, to use Sharepoint. It seems as though TFS might have started off as a Sharepoint extensibility test. Things would be far easier were it not for the whole Sharepoint dependency (and analysis and reporting &#8211; <em>I don&#8217;t need this</em>).</p>
<p>These guys need to take a hint from the ASP.net team.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonathan.dickinsons.co.za/blog/2009/07/tfs-server-2008-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Websites for IDIOTS</title>
		<link>http://jonathan.dickinsons.co.za/blog/2009/07/websites-for-idiots/</link>
		<comments>http://jonathan.dickinsons.co.za/blog/2009/07/websites-for-idiots/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 18:57:05 +0000</pubDate>
		<dc:creator>Jonathan Dickinson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://jonathan.dickinsons.co.za/blog/2009/07/websites-for-idiots/</guid>
		<description><![CDATA[A website builder that anyone can use.]]></description>
			<content:encoded><![CDATA[<p>People want to make websites – they just don’t know how (honestly, it’s not that hard). The last time anyone made an attempt at website development for the masses was FrontPage. It was a disaster, we had thousands of cookie-cutter websites springing up all over the place. I will bring such calamity to the web again; although it will be more artful cookies this time round.</p>
<p>I like to think I am pretty familiar with website development; and I have used a <em>wide</em> variety of platforms (from ASP.Net to PHP to RoR). That’s what it comes down to – I know what works and what doesn’t.</p>
<h2>Data</h2>
<p>Ah yes, the nuts and bolts of any website (even your Wordpress blog uses it). Unfortunately you qualify as a DBA alone (and nothing else) for a reason – databases are as hard as hell to get right. If you think for one minute that you know <em>exactly </em>what you are doing – <em>you are doing it wrong</em>. How do we present this to users in an easy fashion? Something that they are familiar with? Spreadsheets! Everyone knows (or at least should know) Excel. Instead of confusing users with data relationships and so forth give it to them in the following format (more or less):</p>
<table width="100%">
<caption>Blog Posts</caption>
<thead>
<tr>
<td valign="top">Title</td>
<td valign="top">Date</td>
<td valign="top">Content</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top">My first post</td>
<td valign="top">18 January 2009</td>
<td valign="top">This is my first post, I am really excited about blogging. YOU ALL SUCK!!!1!!ONE</td>
</tr>
<tr>
<td valign="top">Fish</td>
<td valign="top">18 January 2009</td>
<td valign="top">I like fish – do you.</td>
</tr>
</tbody>
</table>
<p>Granted, those are pretty short and are probably a poor example. It would work like an RDBMS (think Excel but more constrained) with the following exceptions:</p>
<ul>
<li>We don’t call them tables, we call them sheets. </li>
<li>Types are more user friendly. For example: short text, long text, formatted text, date, image etc. </li>
<li>Columns can have formulas; but they apply to the entire column (aggregated columns or excel formulas).</li>
<li>Users can willy-nilly alter the schema as they see fit. No constraints like RDBMS (read no-RDBMS). </li>
</ul>
<p>Now that we have given the user data we need to give them a way to shoot themselves in the foot with it.</p>
<h2>Design</h2>
<p>ASP.Net has one of these fantastic features: master pages. That’s a confusing term – Word terminology will save the day ‘Templates’. Essentially you design a web page but leave bits of it as ‘todos’. If you really wanted to use tables it might look a bit like the following:</p>
<table width="100%">
<tbody>
<tr>
<td colspan="2"><strong>My Cool Websites</strong></td>
</tr>
<tr>
<td width="80%">(Body placeholder)</td>
<td>(Repeating widget)</td>
</tr>
</tbody>
</table>
<p>The placeholder is where you would put the body content. For example, the body post out of the ‘Content’ column. These are fully nest-able; so you could define a template for your entire website – and then have child templates for the blog area, the product area, the home page and so forth.</p>
<p>Widgets? ASP.Net controls in a nutshell. The repeating widget would allow you to create something that repeats (the obvious one here would be posts). Everything would be driven by widgets – there would be no HTML (unless within the HTML widget) editing available.</p>
<p>Let me re-iterate that, NO HTML.</p>
<p>Next, any good website would use CSS. The idea here is to kindly steer users toward using (Word again) ‘Styles’. These define how things look (as CSS is supposed to), obviously the true noobies could just ignore them.</p>
<h2></h2>
<h2></h2>
<h2>Wizards</h2>
<p>My friend recently bought himself a printer that could print onto CDs or DVDs. It has one unique feature: down to earth wizards. The main wizard actually has an option called “I’m in a rush – just make me a label.” That’s the kind of stuff I am going to head for.</p>
<ul>
<li>What type of website do you want? [Blog] [Products] [Brochure]</li>
<li>Blog</li>
<li>[Just make me a blog, I will finish it up later] [Answer some questions about how it want it to work]</li>
</ul>
<p>I’m sure you get the idea. After working at K2 for so long I am partially poisoned – wizards will be rife.</p>
<h2>Doing Something with Data</h2>
<p>Once you have a design and data you need to render that. The obvious choice here would be to have special folders, for instance we could allow the user to construct an address by defining a simple format, for example:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:b2aa71e7-419f-4d27-a2b3-e960b42b66d0" class="wlWriterEditableSmartContent">
<pre class="brush: plain; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; ">&lt;Date&gt;/&lt;Title&gt;</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Any field used in that would obviously be made ‘web safe’ by the engine. These folders would then have a single webpage that would allow the user to define how to use that data. The obvious thing here would be to drag the content into the <em>Body placeholder</em>.</p>
<h2>Publish It</h2>
<p>Why is every website today ASP/PHP/RoR/etc. based? They don’t need to be, for crying out loud. The publishing wizard will compile the entire website down to static web pages (html) and blast them to the server (or to a folder); no fuss, no expensive hosting.</p>
<h2>Widgets</h2>
<p>Are the most important feature. They will probably take me the longest – I would obviously need a good coverage of them. The obvious thing to do would also allow third parties to author widgets.</p>
<p>Well that about sums it up. Oh yes, it will have all that Office 2007 look goodness.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonathan.dickinsons.co.za/blog/2009/07/websites-for-idiots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove System Menu Icon in WPF</title>
		<link>http://jonathan.dickinsons.co.za/blog/2009/07/remove-system-menu-icon-in-wpf/</link>
		<comments>http://jonathan.dickinsons.co.za/blog/2009/07/remove-system-menu-icon-in-wpf/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 13:40:47 +0000</pubDate>
		<dc:creator>Jonathan Dickinson</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Code 7 Contest]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Top Hacks]]></category>

		<guid isPermaLink="false">http://jonathan.dickinsons.co.za/blog/2009/07/remove-system-menu-icon-in-wpf/</guid>
		<description><![CDATA[Howto remove the caption bar in WPF.]]></description>
			<content:encoded><![CDATA[<p>I am entering the <a href="http://code7contest.com" target="_blank">Code7 Contest</a> and part of my project is to mimic the network notification icon.</p>
<div id="attachment_61" class="wp-caption aligncenter" style="width: 312px"><a href="http://jonathan.dickinsons.co.za/blog/wp-content/uploads/2009/07/Windows7Network.png"><img class="size-full wp-image-61" title="Windows 7 Network Menu" src="http://jonathan.dickinsons.co.za/blog/wp-content/uploads/2009/07/Windows7Network.png" alt="Windows 7 Network Menu" width="302" height="454" /></a><p class="wp-caption-text">Windows 7 Network Menu</p></div>
<p>The trick to this is to set the caption of the window to null (not empty string) and remove the system menu – at least as far as Windows Forms goes. WPF doesn’t let you do this. I had a few options:</p>
<ul>
<li>Implement a template to mimic the real window template. Not too sure how glass would work here.</li>
<li>Use API calls to do it instead.</li>
</ul>
<p>The second option seemed to be more sensible. As it turns out Windows Forms is doing quite a bit of heavy lifting under the covers – you don’t set the title to null; you actually need to remove the caption (Windows Forms does this for you). In the end it’s as simple as clearing two style flags for the Window.</p>
<div class="code-header">Remove Caption in WPF</div>
<div id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:63529eaa-0ca6-4208-853f-10b57d792814" class="wlWriterEditableSmartContent" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px">
<pre class="brush: csharp; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; ">private class NativeMethods
{
  [DllImport("user32.dll", EntryPoint = "SetWindowLong")]
  static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
  [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")]
  static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
  public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
  {
      if (IntPtr.Size == 8)
          return SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
      else
          return SetWindowLongPtr32(hWnd, nIndex, dwNewLong);
  }

  [DllImport("user32.dll", EntryPoint = "GetWindowLong")]
  private static extern IntPtr GetWindowLongPtr32(IntPtr hWnd, int nIndex);
  [DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
  private static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
  public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
  {
      if (IntPtr.Size == 8)
          return GetWindowLongPtr64(hWnd, nIndex);
      else
          return GetWindowLongPtr32(hWnd, nIndex);
  }

  const int GWL_STYLE = (-16);
  const int WS_SYSMENU = 0x00080000;
  const int WS_CAPTION = 0x00C00000;

  public static void RemoveMenu(IntPtr hwnd)
  {
      int currentStyle = GetWindowLong(hwnd, GWL_STYLE).ToInt32();
      currentStyle &amp;= ~WS_SYSMENU;
      currentStyle &amp;= ~WS_CAPTION;
      int ret = SetWindowLong(hwnd, GWL_STYLE, new IntPtr(currentStyle)).ToInt32();
  }

}</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>You simply call that from OnSourceInitialized.</p>
<div class="code-header">How to use the method</div>
<div id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:bac81a08-a2b0-4291-9490-ade63e6320ea" class="wlWriterEditableSmartContent" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px">
<pre class="brush: csharp; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; ">protected override void OnSourceInitialized(EventArgs e)
{
  base.OnSourceInitialized(e);
  WindowInteropHelper wih = new WindowInteropHelper(this);
  NativeMethods.RemoveMenu(wih.Handle);
}</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>And you will get the following result:</p>
<div id="attachment_63" class="wp-caption aligncenter" style="width: 309px"><a href="http://jonathan.dickinsons.co.za/blog/wp-content/uploads/2009/07/Windows7Mimic.png"><img class="size-full wp-image-63" title="Windows 7 Mimic'ed Menu" src="http://jonathan.dickinsons.co.za/blog/wp-content/uploads/2009/07/Windows7Mimic.png" alt="Windows 7 Mimic'ed Menu" width="299" height="364" /></a><p class="wp-caption-text">Windows 7 Mimic&#39;ed Menu</p></div>
]]></content:encoded>
			<wfw:commentRss>http://jonathan.dickinsons.co.za/blog/2009/07/remove-system-menu-icon-in-wpf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
