<?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>Head.SmackOnTable(); &#187; visual studio</title>
	<atom:link href="http://www.unauthorised-access.com/tag/visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.unauthorised-access.com</link>
	<description>Contains Nuts.</description>
	<lastBuildDate>Fri, 02 Jul 2010 17:46:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using NAnt 0.85 with .net 4.0</title>
		<link>http://www.unauthorised-access.com/2009/12/using-nant-0-85-with-net-4-0/</link>
		<comments>http://www.unauthorised-access.com/2009/12/using-nant-0-85-with-net-4-0/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 11:02:14 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[CycleMania]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=354</guid>
		<description><![CDATA[Im guessing because the .net 4.0 framework is still in the beta stages, that&#8217;s why NAnt (and TeamCity) arnt supporting it, but from what I can tell, mstcthe method to build it hasnt changed since .net 2.0&#8242;s msbuild way of compiling a solution.  Basically, all you need to do is call msbuild from the command [...]]]></description>
			<content:encoded><![CDATA[<p>Im guessing because the .net 4.0 framework is still in the beta stages, that&#8217;s why NAnt (and TeamCity) arnt supporting it, but from what I can tell, mstcthe method to build it hasnt changed since .net 2.0&#8242;s msbuild way of compiling a solution.  Basically, all you need to do is call msbuild from the command line, give it the path of the solution, and off it goes to build it. You can specify additional information such as the build target etc, but its not essential.</p>
<p>Whereas normally, within NAnt, you would run the following:</p>
<pre class="brush: xml;">

&lt;solution configuration=&quot;release&quot; solutionfile=&quot;test.sln&quot; /&gt;
</pre>
<p>This aparently dosent work with the .net 4.0 framework, it seems to not detect it. From what I can tell, the quickest way around this is to do the following:</p>
<pre class="brush: xml;">

&lt;exec program=&quot;c:\Windows\Microsoft.NET\Framework64\v4.0.21006\MSBuild.exe&quot; basedir=&quot;C:\SVN\CycleMania\&quot;  verbose=&quot;true&quot; &gt;
 &lt;arg value=&quot;C:\SVN\CycleMania\CycleMania.sln&quot; /&gt;
 &lt;/exec&gt;
</pre>
<p>Obviously, change the path in the <em>program</em> attribute to suit where Windows is located, and change the <em>Framework64</em> to simply <em>Framework</em> if you are not running on a 64bit platform. One quirk that I fonud is that you have to have the <em>BaseDir</em> as where the solution is based, otherwise it throws errors about it cannot build properly.</p>
<p>And that should be it! If you are still struggling to compile on the .net 4.0 framework from within Nant, give me a shout.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/12/using-nant-0-85-with-net-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CycleMania&#8217;s Continuous Integration</title>
		<link>http://www.unauthorised-access.com/2009/12/cyclemanias-continuous-integration/</link>
		<comments>http://www.unauthorised-access.com/2009/12/cyclemanias-continuous-integration/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 14:37:48 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[CycleMania]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=349</guid>
		<description><![CDATA[Its now public knowledge that I have been working on getting a decent CI integration for the CycleMania project working on a publicly accessable server. For the record, we are using the following tech for the CI integration. Yes, I WILL write a very detailed how-to on how I set things up, but as I [...]]]></description>
			<content:encoded><![CDATA[<p>Its now <a href="http://twitter.com/LeeDumond/status/6767942229">public knowledge</a> that I have been working on getting a decent CI integration for the <a href="http://cyclemania.codeplex.com/">CycleMania project</a> working on a publicly accessable server.</p>
<p>For the record, we are using the following tech for the CI integration. Yes, I WILL write a very detailed how-to on how I set things up, but as I am on my lunchbreak here at work, heres a very quick overview of what we are using:</p>
<ul>
<li>TeamCity 5.0 Professional, a free download from JetBrains (Limit of 20 Projects and 20 Users)</li>
<li>.Net framework 4.0 Beta 2 (obviously)</li>
<li>Nant 0.85, not as a proper build script, but purely as a glorified as a batch script</li>
<li>APPCMD command to control IIS7&#8242;s App recycling (From inside Nant)</li>
<li>.Net 4.0&#8242;s MSBuild</li>
</ul>
<p>All this running ontop of Windows 2008 R2 Web Edition, and SQL Server 2008 Express.</p>
<p>Things I have learned is:</p>
<ul>
<li>TeamCity 5.0 isnt geared up for .net 4.0 YET, which is fair enough, they said support will be included in 5.1</li>
<li>TeamCity also seems to be simply geared for building projects and running unit tests, less so for copying files over to another directory with specific paths etc.</li>
<li>Nant&#8217;s contrib project is crap. Fair enough last time it was updated was 3 years ago, but it dosent work.</li>
<li>You cannot simply recycle an app pool to kill a user instance of SQL Server 2008, to update the .mdf file.</li>
<li>You really shouldnt run a site from the same directory as SVN, if you plan to update it (re above)</li>
<li>Nant is all good and well, but also dosent support .net 4.0.</li>
</ul>
<p>I promise I will expand on most of these points when I have time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/12/cyclemanias-continuous-integration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LAB: Image Detection, Part 3</title>
		<link>http://www.unauthorised-access.com/2009/05/lab-image-detection-part-3/</link>
		<comments>http://www.unauthorised-access.com/2009/05/lab-image-detection-part-3/#comments</comments>
		<pubDate>Fri, 08 May 2009 00:19:47 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[R&D Lab]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[R&D]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=263</guid>
		<description><![CDATA[After writing some comparison code, we have the following output, thanks to log4net (I love log4net): Source Target . X:79 Y:156 W:17 H:23 X:73 Y:149 W:17 H:23 . X:337 Y:176 W:27 H:50 X:331 Y:169 W:27 H:49 . X:158 Y:249 W:32 H:31 X:152 Y:242 W:32 H:32 . X:446 Y:286 W:28 H:32 X:440 Y:279 W:27 H:32 . [...]]]></description>
			<content:encoded><![CDATA[<p>After writing some comparison code, we have the following output, thanks to log4net (I love log4net):</p>
<p><a href="http://www.unauthorised-access.com/wp-content/uploads/2009/05/output-3.jpg"><img class="alignnone size-thumbnail wp-image-265" title="output-3" src="http://www.unauthorised-access.com/wp-content/uploads/2009/05/output-3-150x150.jpg" alt="output-3" width="150" height="150" /></a></p>
<table id="tblMain_0" class="tblGenFixed" style="height: 220px;" border="0" cellspacing="0" cellpadding="0" width="493">
<tbody>
<tr>
<td class="s0"><cite><strong>Source</strong></cite></td>
<td class="s1"><cite><br />
</cite></td>
<td class="s1"><cite><br />
</cite></td>
<td class="s1"><cite><br />
</cite></td>
<td class="s2"><cite></cite></td>
<td class="s1"><cite><strong>Target</strong></cite></td>
<td class="s1"><cite><br />
</cite></td>
<td class="s1"><cite><br />
</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:79</cite></td>
<td class="s4"><cite>Y:156</cite></td>
<td class="s4"><cite>W:17</cite></td>
<td class="s4"><cite>H:23</cite></td>
<td class="s4"><cite>X:73</cite></td>
<td class="s4"><cite>Y:149</cite></td>
<td class="s4"><cite>W:17</cite></td>
<td class="s4"><cite>H:23</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:337</cite></td>
<td class="s4"><cite>Y:176</cite></td>
<td class="s4"><cite>W:27</cite></td>
<td class="s4"><cite>H:50</cite></td>
<td class="s4"><cite>X:331</cite></td>
<td class="s4"><cite>Y:169</cite></td>
<td class="s4"><cite>W:27</cite></td>
<td class="s4"><cite>H:49</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:158</cite></td>
<td class="s4"><cite>Y:249</cite></td>
<td class="s4"><cite>W:32</cite></td>
<td class="s4"><cite>H:31</cite></td>
<td class="s4"><cite>X:152</cite></td>
<td class="s4"><cite>Y:242</cite></td>
<td class="s4"><cite>W:32</cite></td>
<td class="s4"><cite>H:32</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:446</cite></td>
<td class="s4"><cite>Y:286</cite></td>
<td class="s4"><cite>W:28</cite></td>
<td class="s4"><cite>H:32</cite></td>
<td class="s4"><cite>X:440</cite></td>
<td class="s4"><cite>Y:279</cite></td>
<td class="s4"><cite>W:27</cite></td>
<td class="s4"><cite>H:32</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:398</cite></td>
<td class="s4"><cite>Y:339</cite></td>
<td class="s4"><cite>W:18</cite></td>
<td class="s4"><cite>H:26</cite></td>
<td class="s4"><cite>X:392</cite></td>
<td class="s4"><cite>Y:334</cite></td>
<td class="s4"><cite>W:16</cite></td>
<td class="s4"><cite>H:24</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:244</cite></td>
<td class="s4"><cite>Y:349</cite></td>
<td class="s4"><cite>W:47</cite></td>
<td class="s4"><cite>H:52</cite></td>
<td class="s4"><cite>X:238</cite></td>
<td class="s4"><cite>Y:342</cite></td>
<td class="s4"><cite>W:47</cite></td>
<td class="s4"><cite>H:52</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:38</cite></td>
<td class="s4"><cite>Y:374</cite></td>
<td class="s4"><cite>W:16</cite></td>
<td class="s4"><cite>H:15</cite></td>
<td class="s4"><cite>X:31</cite></td>
<td class="s4"><cite>Y:366</cite></td>
<td class="s4"><cite>W:17</cite></td>
<td class="s4"><cite>H:16</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:34</cite></td>
<td class="s4"><cite>Y:388</cite></td>
<td class="s4"><cite>W:16</cite></td>
<td class="s4"><cite>H:17</cite></td>
<td class="s4"><cite>X:148</cite></td>
<td class="s4"><cite>Y:423</cite></td>
<td class="s4"><cite>W:27</cite></td>
<td class="s4"><cite>H:24</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:154</cite></td>
<td class="s4"><cite>Y:430</cite></td>
<td class="s4"><cite>W:27</cite></td>
<td class="s4"><cite>H:24</cite></td>
<td class="s4"><cite>X:459</cite></td>
<td class="s4"><cite>Y:435</cite></td>
<td class="s4"><cite>W:24</cite></td>
<td class="s4"><cite>H:22</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:465</cite></td>
<td class="s4"><cite>Y:442</cite></td>
<td class="s4"><cite>W:25</cite></td>
<td class="s4"><cite>H:22</cite></td>
<td class="s4"><cite>X:119</cite></td>
<td class="s4"><cite>Y:450</cite></td>
<td class="s4"><cite>W:30</cite></td>
<td class="s4"><cite>H:46</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:126</cite></td>
<td class="s4"><cite>Y:457</cite></td>
<td class="s4"><cite>W:29</cite></td>
<td class="s4"><cite>H:46</cite></td>
<td class="s4"><cite>X:221</cite></td>
<td class="s4"><cite>Y:465</cite></td>
<td class="s4"><cite>W:17</cite></td>
<td class="s4"><cite>H:19</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:227</cite></td>
<td class="s4"><cite>Y:472</cite></td>
<td class="s4"><cite>W:17</cite></td>
<td class="s4"><cite>H:19</cite></td>
<td class="s4"><cite>X:250</cite></td>
<td class="s4"><cite>Y:594</cite></td>
<td class="s4"><cite>W:17</cite></td>
<td class="s4"><cite>H:18</cite></td>
</tr>
<tr>
<td class="hd">
<p style="height: 16px;"><cite>.</cite></p>
</td>
<td class="s3"><cite>X:256</cite></td>
<td class="s4"><cite>Y:601</cite></td>
<td class="s4"><cite>W:17</cite></td>
<td class="s4"><cite>H:18</cite></td>
<td><cite><br />
</cite></td>
<td><cite><br />
</cite></td>
<td><cite><br />
</cite></td>
</tr>
</tbody>
</table>
<p><cite><br />
Comparison<br />
S[X: 79, Y: 156, Width: 17, Height: 23] matched to T[X: 73, Y: 149, Width: 17, Height: 23]<br />
S[X: 158, Y: 249, Width: 32, Height: 31] matched to T[X: 152, Y: 242, Width: 32, Height: 32]<br />
S[X: 398, Y: 339, Width: 18, Height: 26] matched to T[X: 392, Y: 334, Width: 16, Height: 24]<br />
S[X: 38, Y: 374, Width: 16, Height: 15] matched to T[X: 31, Y: 366, Width: 17, Height: 16]<br />
S[X: 154, Y: 430, Width: 27, Height: 24] matched to T[X: 392, Y: 334, Width: 16, Height: 24]<br />
S[X: 126, Y: 457, Width: 29, Height: 46] matched to T[X: 31, Y: 366, Width: 17, Height: 16]<br />
S[X: 256, Y: 601, Width: 17, Height: 18] matched to T[X: 31, Y: 366, Width: 17, Height: 16]<br />
Non matched<br />
S[X: 34, Y: 388, Width: 16, Height: 17]<br />
S[X: 154, Y: 430, Width: 27, Height: 24]<br />
S[X: 465, Y: 442, Width: 25, Height: 22]<br />
S[X: 126, Y: 457, Width: 29, Height: 46]<br />
S[X: 227, Y: 472, Width: 17, Height: 19]<br />
S[X: 256, Y: 601, Width: 17, Height: 18]<br />
T[X: 148, Y: 423, Width: 27, Height: 24]<br />
T[X: 459, Y: 435, Width: 24, Height: 22]<br />
T[X: 119, Y: 450, Width: 30, Height: 46]<br />
T[X: 221, Y: 465, Width: 17, Height: 19]<br />
T[X: 250, Y: 594, Width: 17, Height: 18]<br />
</cite></p>
<p>I know its not perfect, I know its only matching about 50% of the blobs, but im working on it. I have a plan up my sleeve for this <img src='http://www.unauthorised-access.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/05/lab-image-detection-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Snippets &#8211; Text on images</title>
		<link>http://www.unauthorised-access.com/2009/05/code-snippets-text-on-images/</link>
		<comments>http://www.unauthorised-access.com/2009/05/code-snippets-text-on-images/#comments</comments>
		<pubDate>Mon, 04 May 2009 12:13:02 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[R&D Lab]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=237</guid>
		<description><![CDATA[Two code snippets for you: private void drawTextWithBackground (string Text, Font font, Graphics grpaphics, Brush backgroundBrush, Brush foregroundBrush, int x, int y) { SizeF size = grpaphics.MeasureString(Text, font); grpaphics.FillRectangle(backgroundBrush, x,y,size.Width, size.Height); grpaphics.DrawString(Text,font,foregroundBrush,x+1,y+1); } private void drawTextAtBottom (String Text, Font font, Graphics graphics, Image sourceImage, Brush backgroundBrush, Brush foregroundBrush) { SizeF size = graphics.MeasureString(Text, font); int [...]]]></description>
			<content:encoded><![CDATA[<p>Two code snippets for you:</p>
<div style="background: #242424 none repeat scroll 0% 0%; font-family: ProFontWindows; font-size: 9pt; color: #e8f3f6;">
<p style="margin: 0px;"><span style="color: #8ac6f2;">private</span> <span style="color: #8ac6f2;">void</span> drawTextWithBackground (<span style="color: #8ac6f2;">string</span> Text, <span style="color: #cae682;">Font</span> font, <span style="color: #cae682;">Graphics</span> grpaphics, <span style="color: #cae682;">Brush</span> backgroundBrush, <span style="color: #cae682;">Brush</span> foregroundBrush, <span style="color: #8ac6f2;">int</span> x, <span style="color: #8ac6f2;">int</span> y)</p>
<p style="margin: 0px;">{</p>
<p style="margin: 0px;"><span style="color: #e5786d;">SizeF</span> size = grpaphics.MeasureString(Text, font);</p>
<p style="margin: 0px;">grpaphics.FillRectangle(backgroundBrush, x,y,size.Width, size.Height);</p>
<p style="margin: 0px;">grpaphics.DrawString(Text,font,foregroundBrush,x+<span style="color: #e5786d;">1</span>,y+<span style="color: #e5786d;">1</span>);</p>
<p style="margin: 0px;">}</p>
<p style="margin: 0px;">
<p style="margin: 0px;"><span style="color: #8ac6f2;">private</span> <span style="color: #8ac6f2;">void</span> drawTextAtBottom (<span style="color: #cae682;">String</span> Text, <span style="color: #cae682;">Font</span> font, <span style="color: #cae682;">Graphics</span> graphics, <span style="color: #cae682;">Image</span> sourceImage, <span style="color: #cae682;">Brush</span> backgroundBrush, <span style="color: #cae682;">Brush</span> foregroundBrush)</p>
<p style="margin: 0px;">{</p>
<p style="margin: 0px;"><span style="color: #e5786d;">SizeF</span> size = graphics.MeasureString(Text, font);</p>
<p style="margin: 0px;">
<p style="margin: 0px;"><span style="color: #8ac6f2;">int</span> y = (<span style="color: #8ac6f2;">int</span>) (sourceImage.Height &#8211; size.Height);</p>
<p style="margin: 0px;">
<p style="margin: 0px;">drawTextWithBackground(Text,font,graphics,backgroundBrush,foregroundBrush,<span style="color: #e5786d;">1</span>,y);</p>
<p style="margin: 0px;">}</p>
</div>
<p>Does exactly what it says on the tin!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/05/code-snippets-text-on-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LAB: Image Detection, Part 1</title>
		<link>http://www.unauthorised-access.com/2009/05/lab-image-detection-part-1/</link>
		<comments>http://www.unauthorised-access.com/2009/05/lab-image-detection-part-1/#comments</comments>
		<pubDate>Sun, 03 May 2009 23:30:09 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[R&D Lab]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[R&D]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=228</guid>
		<description><![CDATA[Every now and then, I get a crazy idea, to try something rather hard in .net – maybe hard isnt the right word for it, but something that hasn&#8217;t really been attempted before, or if it has, nothing public about it. So the idea I have is for some form of image detection, to say [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Every now and then, I get a crazy idea, to try something rather hard in .net – maybe hard isnt the right word for it, but something that hasn&#8217;t really been attempted before, or if it has, nothing public about it. So the idea I have is for some form of image detection, to say that Image X is x % similar to Image Y. I prefer to use the terms Source and Target, but it doesn&#8217;t really matter.</p>
<p style="text-align: justify;">The <a href="http://www.unauthorised-access.com/wp-content/uploads/2009/05/source.jpg">source</a> and the <a href="http://www.unauthorised-access.com/wp-content/uploads/2009/05/comparetarget.jpg">target</a> images are here. That&#8217;s a photo I took a few weeks ago, if you do decide to steal it, please put a message on there that points back to me <img src='http://www.unauthorised-access.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Anyway, the target image is 14&#215;15 pixels smaller – that&#8217;s a whopping 210 pixels different! It shouldn&#8217;t be too hard to match up the two images, or should it?</p>
<h2>Histograms</h2>
<p style="text-align: justify;">My first attempt was with Histograms. I grabbed some open source (unsafe!) code that generates an array of int[] and lists the histogram values, so I shoved both images through that, and got it to output the Source’s histogram value, the Target’s histogram value, the difference between them both, and the percentage of how similar it is, like so: (The first number is the key# of the int in the array, just because)</p>
<p><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="image" src="http://www.unauthorised-access.com/wp-content/uploads/2009/05/image-thumb.png" border="0" alt="image" width="320" height="264" /></p>
<p style="text-align: justify;">Right at the bottom, I had an average of all the percentages, to see how “similar” the image is. I was expecting the percentage to be fairly high, since there is only a few hundred pixels difference, and I didn&#8217;t change any of the levels or colours when I cut the images out of each other, but it told me there was a <strong>87.7% similarity</strong>! That was very shockingly low. If you see something wrong with my maths from the code below, please let me know:</p>
<div style="font-size: 9pt; background: #242424; color: #e8f3f6; font-family: profontwindows">
<p style="margin: 0px"><span style="color: #8ac6f2">public</span> HistogramCompareResults(<span style="color: #8ac6f2">int</span> key, <span style="color: #8ac6f2">int</span> source, <span style="color: #8ac6f2">int</span> target)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: #8ac6f2">this</span>.key = key;</p>
<p style="margin: 0px"><span style="color: #8ac6f2">this</span>.source = source;</p>
<p style="margin: 0px"><span style="color: #8ac6f2">this</span>.target = target;</p>
<p style="margin: 0px">difference = source &#8211; target;</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: #8ac6f2">if</span> (difference &lt; <span style="color: #e5786d">0</span>)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">difference = difference*-<span style="color: #e5786d">1</span>;</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: #8ac6f2">if</span> (source != <span style="color: #e5786d">0</span> &amp;&amp; target !=<span style="color: #e5786d">0</span>)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: #8ac6f2">if</span> (source &gt; target)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">percentage = (<span style="color: #8ac6f2">double</span>)target / (<span style="color: #8ac6f2">double</span>)source;</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px"><span style="color: #8ac6f2">else</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">percentage = (<span style="color: #8ac6f2">double</span>)source / (<span style="color: #8ac6f2">double</span>)target;</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">
<p style="margin: 0px">percentage = percentage*<span style="color: #e5786d">100</span>;</p>
<p style="margin: 0px">
<p style="margin: 0px">}</p>
<p style="margin: 0px">}</p>
</div>
<h2>Image Processing</h2>
<p style="text-align: justify;">My next port of call was basically image processing, like what I did with my <a href="http://www.unauthorised-access.com/2008/09/pet-project-personal-anpr/" target="_blank">ANPR</a> project that I created – basically filtering stuff out and building a “thumbprint” of the image, that hopefully will withstand being resized and stuff like that. Using image filters, flattening images and looking for large “blobs” of images, sofar I have come up with this:</p>
<p><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="image" src="http://www.unauthorised-access.com/wp-content/uploads/2009/05/image-thumb1.png" border="0" alt="image" width="500" height="751" /></p>
<p>That is the current “thumbprint” for the red channel, on the source image.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/05/lab-image-detection-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An introduction to Pex</title>
		<link>http://www.unauthorised-access.com/2009/04/an-introduction-to-pex/</link>
		<comments>http://www.unauthorised-access.com/2009/04/an-introduction-to-pex/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 02:07:37 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[pex]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=198</guid>
		<description><![CDATA[Pex generates Unit Tests from Parameterized Unit Tests through Automated White box Testing based on Input Generation Ill be the first to admit, I have never been a big fan of unit testing. To me, it seems like a big waste of time. I&#8217;m not sure why, but I just don&#8217;t like it – I [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Pex generates Unit Tests from Parameterized Unit Tests through Automated White box Testing based on Input Generation</p></blockquote>
<p>Ill be the first to admit, I have never been a big fan of unit testing. To me, it seems like a big waste of time. I&#8217;m not sure why, but I just don&#8217;t like it – I suppose it has something to-do with spending time writing tests instead of actually doing proper, paid work. Yes, yes, I know that tests “prove” that your code works, as long as you have coded your tests right. But what if you haven&#8217;t?</p>
<p>Anyway, I thought id give Pex a test since it generates unit tests for me. I love things that generate things for me, because I like to do things as quickly as possible, and the computer is millions of times faster than me at generating stuff.</p>
<p>For starters – head over to the <a href="http://research.microsoft.com/en-us/projects/Pex/" target="_blank">Pex website</a>, and download it – I downloaded the academic version, since im running VS.NET 2008 pro. Installing it after downloading it also might help matters.</p>
<p>Once you have installed it, you should be able to just open up a project and when right clicking inside a .cs file, you should see a few menu items:</p>
<p><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="WindowClipping (192)" src="http://www.unauthorised-access.com/wp-content/uploads/2009/04/windowclipping192.png" border="0" alt="WindowClipping (192)" width="204" height="101" /></p>
<p>Once you click on that little baby, Pex should start whizzing into action. Be warned, Pex will only test Public classes and methods – it dosent like testing anything else that isnt public, and I believe it will give you a warning.</p>
<p>In VS.NET’s status bar, you will get a bunch of messages, along the lines of “Pex: listening to monitored process (cold start)” and then “Pex: Finished”. It should also pop up a window, something vaguely like the following:</p>
<p><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="Pex Exploration Results - stopped - 1 failed, 2 runs" src="http://www.unauthorised-access.com/wp-content/uploads/2009/04/pexexplorationresultsstopped1failed2runs1.png" border="0" alt="Pex Exploration Results - stopped - 1 failed, 2 runs" width="500" height="115" /></p>
<p>I know this looks confusing at first, but it really isn&#8217;t. Its quite simple really. You have various options, but what&#8217;s interesting (I think) is the grid view in the middle. The first icon says if the test passed or failed – green = pass, red = ? (Take a guess, gwan, take a guess!) The number denotes the number of the test (its incremental), and the name is the value it has tried If the test fails and throws an exception, that will be listed under the Summary and Error message bits.</p>
<p>If you click on the test, you can see the following to the side :</p>
<p><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="WindowClipping (194)" src="http://www.unauthorised-access.com/wp-content/uploads/2009/04/windowclipping194.png" border="0" alt="WindowClipping (194)" width="453" height="358" /></p>
<p>The details is the actual code for the unit test that it has executed. I know, it says “this.” instead of the class name, and that&#8217;s because Pex creates a copy of the code to run tests on, in a partial class. Under the stack trace subtab, it well, gives you the stack trace (Please tell me you knew what that would do. Please.)</p>
<p>This is where Pex becomes rather … brilliant &#8211; it allows you to save all of these generated tests into its own project, simply by selecting the tests you want to save, and hitting the fancy &#8220;Save Test…&#8221; button &#8211; it will go off, and generate its own project (It will ask you for the name of the project, where it should live etc, I will provide a screenshot later) &#8211; and it will save the tests to that project! Tests that you can run later, and you don&#8217;t have to use vs.net&#8217;s test suite &#8211; you can decide to plug in different testing libraries such as MBUnit (my current fav) by downloading extensions that are available on CodePlex, or I believe you can create your own.</p>
<p>More on Pex later!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/04/an-introduction-to-pex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nesting Repeaters without OnItemDataBound</title>
		<link>http://www.unauthorised-access.com/2009/02/nesting-repeaters-without-onitemdatabound/</link>
		<comments>http://www.unauthorised-access.com/2009/02/nesting-repeaters-without-onitemdatabound/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 19:12:53 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[OnItemDataBound]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[WebControls]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=110</guid>
		<description><![CDATA[And the page result is: abc 12345 def 67890]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-112" title="windowclipping-106" src="http://www.unauthorised-access.com/wp-content/uploads/2009/02/windowclipping-106.png" alt="windowclipping-106" width="397" height="172" /></p>
<p><img class="alignnone size-full wp-image-111" title="windowclipping-107" src="http://www.unauthorised-access.com/wp-content/uploads/2009/02/windowclipping-107.png" alt="windowclipping-107" width="462" height="118" /></p>
<p>And the page result is:</p>
<p><cite>abc                          12345<br />
def                          67890 </cite></p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/02/nesting-repeaters-without-onitemdatabound/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft.WebApplication.targets</title>
		<link>http://www.unauthorised-access.com/2009/01/microsoft-webapplication-targets/</link>
		<comments>http://www.unauthorised-access.com/2009/01/microsoft-webapplication-targets/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 16:34:13 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=72</guid>
		<description><![CDATA[I seem to be getting quite a few hits regarding Microsoft.WebApplication.targets file, and im guessing its because people&#8217;s copies are missing, so I have decided to attach the file to this post. Enjoy! Linky]]></description>
			<content:encoded><![CDATA[<p>I seem to be getting quite a few hits regarding Microsoft.WebApplication.targets file, and im guessing its because people&#8217;s copies are missing, so I have decided to attach the file to this post. Enjoy!</p>
<p><a href="http://www.unauthorised-access.com/wp-content/uploads/2009/01/microsoftwebapplication.targets">Linky</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/01/microsoft-webapplication-targets/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Extending Nettiers Part 2 &#8211; Adding an OnItemCommand</title>
		<link>http://www.unauthorised-access.com/2008/11/extending-nettiers-part-2/</link>
		<comments>http://www.unauthorised-access.com/2008/11/extending-nettiers-part-2/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 19:10:20 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[NetTiers]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[w00tles]]></category>
		<category><![CDATA[WebControls]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=57</guid>
		<description><![CDATA[A few days ago, I decided to try to extend the Repeater Control, by adding an OnItemCommand, like the System.Web.UI.WebControl. Simple I thought. Shouldnt be that hard I thought. I couldnt have been more wrong. I have learned alot with the whole experience. I have learned about event bubbling, the way that events get passed [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago, I decided to try to extend the Repeater Control, by adding an OnItemCommand, like the System.Web.UI.WebControl. Simple I thought. Shouldnt be that hard I thought.</p>
<p>I couldnt have been more wrong.</p>
<p>I have learned alot with the whole experience. I have learned about event bubbling, the way that events get passed up the control tree till they are handled by their parents. Iv learned about the way that items that are nested will need to be databound for the event to be fired, even if the data is being shown on the page, you still have to explicitly call DataBind(); And I got some help from a random guy (who works for telerik!) on StackOverflow, thanks!</p>
<p>Basically, this is the way it works. When a user hits a button (Like a &lt;asp:button) on the page, it will bubble up (OnBubbleEvent) on the ITemplate (In this case, the actual type of the ItemRepeater). That will do its magic, work out if its a CommandEventArgs, if it is, then bubble it up:</p>
<pre class="brush: csharp;">

protected override bool OnBubbleEvent(object source, EventArgs e)
{
if (e is CommandEventArgs)
{
RepeaterCommandEventArgs args = new RepeaterCommandEventArgs(this, source, (CommandEventArgs) e);
base.RaiseBubbleEvent(this, args);
return true;
}
return false;
}
</pre>
<p>Taken from System.Web.UI.WebControls.RepeaterItem.OnBubbleEvent(object source, EventArgs e);</p>
<p>From there, the Repeater will intercept that, then process it:</p>
<pre class="brush: csharp;">
private static readonly object EventItemCommand = new object();

protected override bool OnBubbleEvent(object sender, EventArgs e)
{
bool flag = false;
if (e is RepeaterCommandEventArgs)
{
this.OnItemCommand((RepeaterCommandEventArgs)e);
flag = true;
}
return flag;
}

protected virtual void OnItemCommand(RepeaterCommandEventArgs e)
{
RepeaterCommandEventHandler handler = (RepeaterCommandEventHandler)base.Events[EventItemCommand];
if (handler != null)
{
handler(this, e);
}
}

public event RepeaterCommandEventHandler ItemCommand
{
add
{
base.Events.AddHandler(EventItemCommand, value);
}
remove
{
base.Events.RemoveHandler(EventItemCommand, value);
}
}
</pre>
<p>This is where the fun starts. First off, in the RepeaterItem source code, you cannot call:</p>
<pre class="brush: csharp;">
RepeaterCommandEventArgs args = new RepeaterCommandEventArgs(&lt;strong&gt;this&lt;/strong&gt;, source, (CommandEventArgs) e);
base.RaiseBubbleEvent(this, args);
</pre>
<p>because <strong>this</strong> refers to a RepeaterItem, which, in my case, it is not because its a Nettiers generated RepeaterItem. So you have to go off and create your own CommandEventArgs. If you create your own EventArgs, the event handler <strong>RepeaterCommandEventHandler </strong>wont work, because its not of the type <strong>RepeaterCommandEventArgs</strong>. Which is a pain in the arse!</p>
<p>Once you have created the EventArgs and the event handler though, its fairly simple from there &#8211; you just modify the Reflector&#8217;ed code (From the RepeaterControl), to get it to handle your custom Repeater Item&#8217;s event, and not the RepeateItem default event which you cant even call!</p>
<p>But your not done! I found out that the command wont get called when someone clicky&#8217;s on it, because you havnt called DataBind(); on the control, which explains some &#8230; oddities I spotted in the code when I was digging around inside the Repeater &#8211; I kept finding calls to &#8220;EnsureDataBound()&#8221; &#8211; which is called OnPreRender:</p>
<p><img class="alignnone size-full wp-image-58" title="windowclipping-75" src="http://www.unauthorised-access.com/wp-content/uploads/2008/11/windowclipping-75.png" alt="" width="445" height="73" /></p>
<p>Note: I will provide code samples and Nettiers templates very soon, as soon as I have integrated my changes into Nettiers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2008/11/extending-nettiers-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to CSS Adapters &#8211; Label Control</title>
		<link>http://www.unauthorised-access.com/2008/11/introduction-to-css-adapters/</link>
		<comments>http://www.unauthorised-access.com/2008/11/introduction-to-css-adapters/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 12:53:00 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[CSSAdapter]]></category>
		<category><![CDATA[HtmlTextWriterTag]]></category>
		<category><![CDATA[RenderEndTag]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[WebControls]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=52</guid>
		<description><![CDATA[CSS Adapters in .net are rarely used, even though they are really powerful and can fix things like xhtml validation errors. This very quick sample will show you how to replace the &#60;span&#62; tags with a &#60;div&#62; Create a class file, something like &#8220;LabelOverride.cs&#8221;, and put in the following: using System.Web.UI; namespace CSSAdapterTest { public [...]]]></description>
			<content:encoded><![CDATA[<p>CSS Adapters in .net are rarely used, even though they are really powerful and can fix things like xhtml validation errors. This very quick sample will show you how to replace the &lt;span&gt; tags with a &lt;div&gt;</p>
<p>Create a class file, something like &#8220;LabelOverride.cs&#8221;, and put in the following:</p>
<pre class="brush: csharp;">

using System.Web.UI;

namespace CSSAdapterTest
{
public class LabelOverride : System.Web.UI.WebControls.Adapters.WebControlAdapter
{
protected override void RenderBeginTag(HtmlTextWriter writer)
{
writer.RenderBeginTag(HtmlTextWriterTag.Div);
}
protected override void RenderEndTag(HtmlTextWriter writer)
{
writer.RenderEndTag();
}
}
}
</pre>
<p>Create a folder in the web application called &#8220;App_Browsers&#8221;, and create a .browsers file called &#8220;CSSAdapter.browser&#8221;, and enter in the following:</p>
<pre class="brush: xml;">

&lt;browsers&gt;
&lt;browser refID=&quot;Default&quot;&gt;
&lt;controlAdapters&gt;
&lt;adapter controlType=&quot;System.Web.UI.WebControls.Label&quot;
adapterType=&quot;CSSAdapterTest.LabelOverride&quot; /&gt;
&lt;/controlAdapters&gt;
&lt;/browser&gt;
&lt;/browsers&gt;
</pre>
<p>This basically tells asp.net to override the controlType&#8217;s renderer with the one you have specified.</p>
<p>Once you have done this, and when you build your application, all &lt;span&gt;&#8217;s will disappear and be replaced with &lt;div&gt;&#8217;s!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2008/11/introduction-to-css-adapters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
