<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>An Original Idea</title>
	<atom:link href="http://anoriginalidea.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://anoriginalidea.wordpress.com</link>
	<description>because all great software begins with an original idea</description>
	<lastBuildDate>Fri, 06 Jan 2012 08:26:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='anoriginalidea.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>An Original Idea</title>
		<link>http://anoriginalidea.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://anoriginalidea.wordpress.com/osd.xml" title="An Original Idea" />
	<atom:link rel='hub' href='http://anoriginalidea.wordpress.com/?pushpress=hub'/>
		<item>
		<title>What every phonegap developer on windows phone 7 needs</title>
		<link>http://anoriginalidea.wordpress.com/2012/01/06/what-every-phonegap-developer-on-windows-phone-7-needs/</link>
		<comments>http://anoriginalidea.wordpress.com/2012/01/06/what-every-phonegap-developer-on-windows-phone-7-needs/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 08:26:19 +0000</pubDate>
		<dc:creator>anoriginalidea</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anoriginalidea.wordpress.com/2012/01/06/what-every-phonegap-developer-on-windows-phone-7-needs/</guid>
		<description><![CDATA[  Error logging!  An unfortunate side effect of developing apps in Javascript in mobile IE9 is that there doesn&#8217;t appear to be any error dialogs. Try the following Javascript:   // provide our own console if it does not exist, huge dev aid!if (typeof window.console == &#8220;undefined&#8221;) { window.console = { log: function (str) { [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=389&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>Error logging!  An unfortunate side effect of developing apps in Javascript in mobile IE9 is that there doesn&#8217;t appear to be any error dialogs.</p>
<p>Try the following Javascript:</p>
<p> </p>
<p><em>// provide our own console if it does not exist, huge dev aid!</em><br /><em>if (typeof window.console == &#8220;undefined&#8221;) {</em><br /><em> window.console = { log: function (str) { window.external.Notify(str); } };</em><br /><em>}</em></p>
<p><em>// output any errors to console log, created above.</em><br /><em>window.onerror = function (msg,url,linenumber) {</em><br /><em> console.log(&#8220;Error ::&#8221; + msg + &#8221; in &#8221; + url + &#8221; at line &#8221; + linenumber); </em><br /><em>};</em></p>
<p><em>console.log(&#8220;Installed console ! &#8220;);</em></p>
<p>This also gives you a &#8220;console.log&#8221; for free.</p>
<p> </p>
<p>Enjoy!</p>
<p> </p>
<p> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/anoriginalidea.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/anoriginalidea.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/anoriginalidea.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/anoriginalidea.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/anoriginalidea.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/anoriginalidea.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/anoriginalidea.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/anoriginalidea.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/anoriginalidea.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/anoriginalidea.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/anoriginalidea.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/anoriginalidea.wordpress.com/389/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/anoriginalidea.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/anoriginalidea.wordpress.com/389/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=389&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://anoriginalidea.wordpress.com/2012/01/06/what-every-phonegap-developer-on-windows-phone-7-needs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a70f6e33c95b7744068ecffceac0aa31?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">anoriginalidea</media:title>
		</media:content>
	</item>
		<item>
		<title>Aspect Oriented Programming in Javascript</title>
		<link>http://anoriginalidea.wordpress.com/2012/01/01/aspect-oriented-programming-in-javascript/</link>
		<comments>http://anoriginalidea.wordpress.com/2012/01/01/aspect-oriented-programming-in-javascript/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 00:07:33 +0000</pubDate>
		<dc:creator>anoriginalidea</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anoriginalidea.wordpress.com/?p=372</guid>
		<description><![CDATA[&#160; In designing javascript for modularity and &#8220;separation of concerns&#8221;, I was pleasantly surprised to discover a way of implementing AOP (Aspect Oriented Programming) in Javascript. &#160; AOP can be useful for automatically &#8220;wrapping&#8221; methods to provide tracing, error logging or caching. In this example, we are &#8220;wrapping&#8221; a method to show an alert when a method starts [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=372&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>In designing javascript for modularity and &#8220;separation of concerns&#8221;, I was pleasantly surprised to discover a way of implementing <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">AOP </a>(Aspect Oriented Programming) in Javascript.</p>
<p>&nbsp;</p>
<p>AOP can be useful for automatically &#8220;wrapping&#8221; methods to provide tracing, error logging or caching.</p>
<p>In this example, we are &#8220;wrapping&#8221; a method to show an alert when a method starts and finishes:</p>
<pre>$.aop.around({ target: homelinksModel, method: 'get' }
 , function (invocation) {</pre>
<pre style="padding-left:30px;">alert("Method Call");

var ret = return invocation.proceed(); // This line calls the original method</pre>
<pre style="padding-left:30px;">alert("After Call");
return ret;
});</pre>
<p>I used it for caching using <a href="http://westcoastlogic.com/lawnchair/">Lawnchair </a> (an abstraction around local storage on client browsers).  It is designed to cache the result of data calls to the server.</p>
<pre>$.aop.around({ target: homelinksModel, method: 'get' }
 , function (invocation) {</pre>
<pre style="padding-left:30px;">var lc = new Lawnchair(function () { });</pre>
<pre style="padding-left:30px;">var keyName = 'homelinksModel' + invocation.method;</pre>
<pre style="padding-left:30px;">
var rec;</pre>
<pre style="padding-left:30px;">lc.get(keyName, function (ret) {</pre>
<pre style="padding-left:30px;">if (ret == null) {
    res = invocation.proceed()
    lc.save({ key: keyName, value: res });
    rec = res;</pre>
<pre style="padding-left:30px;"> }
 else {
 rec = ret.value;
 }</pre>
<pre style="padding-left:30px;">});</pre>
<pre style="padding-left:30px;">return rec;
}); // &lt;/aop&gt;</pre>
<p>I&#8217;m still learning Lawnchair, so there&#8217;s probably better ways of implementing this, but I thought a &#8220;useful&#8221; example might be helpful.</p>
<p>Peter Chung has an <a href="http://unitstep.net/blog/2009/03/31/aspect-oriented-programming/">excellent article</a> about Jquery AOP if you&#8217;d like to learn more.</p>
<p>There&#8217;s not alot of recent &#8220;action&#8221; around AOP in the Javascript space (Google Search).   I suspect that either some of it&#8217;s functionality is automatically part of jQuery or that the Javascript world isn&#8217;t mature enough yet to care much.    Perhaps it&#8217;s the former.</p>
<p>Over the past few days I&#8217;ve had a marvelous time implementing the MVVM pattern in Javascript.  I&#8217;m discovering all my favourite technologies are there, such as object databases (Lawnchair), binding (Knockout) and much more.  I hope to be blogging more about some of these soon.</p>
<p><strong>Links</strong></p>
<ul>
<li>JQuery AOP Plugin - <a href="http://code.google.com/p/jquery-aop/">http://code.google.com/p/jquery-aop/</a></li>
<li><a href="http://unitstep.net/blog/2009/03/31/aspect-oriented-programming/">http://unitstep.net/blog/2009/03/31/aspect-oriented-programming/</a></li>
<li>Using JQuery AOP Plugin to stop WordPress Tracking on DOM objects - <a href="http://blog.futtta.be/2011/11/16/applying-javascript-aop-magic-to-stop-3rd-party-tracking-in-wordpress/">http://blog.futtta.be/2011/11/16/applying-javascript-aop-magic-to-stop-3rd-party-tracking-in-wordpress/</a></li>
<li>List of Javascript AOP Frameworks - <a href="http://stackoverflow.com/questions/1005486/javascript-aop-libraries">http://stackoverflow.com/questions/1005486/javascript-aop-libraries</a></li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/anoriginalidea.wordpress.com/372/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/anoriginalidea.wordpress.com/372/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/anoriginalidea.wordpress.com/372/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/anoriginalidea.wordpress.com/372/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/anoriginalidea.wordpress.com/372/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/anoriginalidea.wordpress.com/372/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/anoriginalidea.wordpress.com/372/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/anoriginalidea.wordpress.com/372/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/anoriginalidea.wordpress.com/372/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/anoriginalidea.wordpress.com/372/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/anoriginalidea.wordpress.com/372/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/anoriginalidea.wordpress.com/372/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/anoriginalidea.wordpress.com/372/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/anoriginalidea.wordpress.com/372/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=372&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://anoriginalidea.wordpress.com/2012/01/01/aspect-oriented-programming-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a70f6e33c95b7744068ecffceac0aa31?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">anoriginalidea</media:title>
		</media:content>
	</item>
		<item>
		<title>Returning data from an MVC method with a small cute ActionResult</title>
		<link>http://anoriginalidea.wordpress.com/2011/06/17/returning-data-from-an-mvc-method-with-a-small-cute-actionresult/</link>
		<comments>http://anoriginalidea.wordpress.com/2011/06/17/returning-data-from-an-mvc-method-with-a-small-cute-actionresult/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 13:11:45 +0000</pubDate>
		<dc:creator>anoriginalidea</dc:creator>
				<category><![CDATA[.net Framework]]></category>
		<category><![CDATA[ccsharp]]></category>
		<category><![CDATA[xmlresult]]></category>
		<category><![CDATA[xmlserialization]]></category>

		<guid isPermaLink="false">https://anoriginalidea.wordpress.com/2011/06/17/returning-data-from-an-mvc-method-with-a-small-cute-actionresult/</guid>
		<description><![CDATA[In order return data from an MVC method, Microsoft provide a useful ActionResult object called JSONResult.&#160; JSONResult exposes a convenient Data property that you can use to serialize an object to JSON. Here’s how it can be used: var res = new JsonResult(); res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; res.Data = someObject; return res; Pretty easy to use.&#160;&#160; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=369&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://anoriginalidea.files.wordpress.com/2011/06/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="image" border="0" alt="image" src="http://anoriginalidea.files.wordpress.com/2011/06/image_thumb.png?w=244&#038;h=193" width="244" height="193" /></a></p>
<p>In order return data from an MVC method, Microsoft provide a useful ActionResult object called JSONResult.&#160; JSONResult exposes a convenient Data property that you can use to serialize an object to JSON.</p>
<p>Here’s how it can be used:</p>
<p><em>var res = new JsonResult();     <br />res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;      <br />res.Data = someObject;      <br />return res;</em></p>
<p>Pretty easy to use.&#160;&#160; Unfortunately there’s no matching XMLResult class if you want to return a scrap of XML instead.&#160; In the MVCContrib project on codeplex there’s an XMLResult, but it’s event signature is slightly different.</p>
<p>I’ve modified this class to provide the same signature.&#160; </p>
<p>Here’s the usage:</p>
<p><em>var res = new XmlResult();     <br />res.Data = someObject;      <br />return res;      <br /></em></p>
<p>Here’s the class:</p>
<p><em>using System.Web.Mvc;     <br />using System.Xml.Serialization;</em></p>
<p><em>namespace Sample     <br />{      <br />&#160;&#160;&#160; /// &lt;summary&gt;      <br />&#160;&#160;&#160; /// Action result that serializes the specified object into XML and outputs it to the response stream.      <br />&#160;&#160;&#160; /// &lt;/summary&gt;      <br />&#160;&#160;&#160; public class XmlResult : ActionResult      <br />&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; private object _objectToSerialize;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; private XmlAttributeOverrides _xmlAttribueOverrides;</em></p>
<p><em>&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;summary&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// Creates a new instance of the XmlResult class.      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;/summary&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;param name=&quot;objectToSerialize&quot;&gt;The object to serialize to XML.&lt;/param&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; public XmlResult()      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</em></p>
<p><em>&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;summary&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// Creates a new instance of the XmlResult class.      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;/summary&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;param name=&quot;objectToSerialize&quot;&gt;The object to serialize to XML.&lt;/param&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; public XmlResult(object objectToSerialize)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _objectToSerialize = objectToSerialize;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</em></p>
<p><em>&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;summary&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// Creates a new instance of the XMLResult class.      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;/summary&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;param name=&quot;objectToSerialize&quot;&gt;The object to serialize to XML.&lt;/param&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;param name=&quot;xmlAttributeOverrides&quot;&gt;&lt;/param&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; public XmlResult(object objectToSerialize, XmlAttributeOverrides xmlAttributeOverrides)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _objectToSerialize = objectToSerialize;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _xmlAttribueOverrides = xmlAttributeOverrides;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</em></p>
<p><em>&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;summary&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// The object to be serialized to XML.      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;/summary&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; public object Data      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; get       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { return _objectToSerialize; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; set       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _objectToSerialize = value;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</em></p>
<p><em>&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;summary&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// Serialises the object that was passed into the constructor to XML and writes the corresponding XML to the result stream.      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;/summary&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; /// &lt;param name=&quot;context&quot;&gt;The controller context for the current request.&lt;/param&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; public override void ExecuteResult(ControllerContext context)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (_objectToSerialize != null)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var xs = (_xmlAttribueOverrides == null) ?      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; new XmlSerializer(_objectToSerialize.GetType()) :      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; new XmlSerializer(_objectToSerialize.GetType(), _xmlAttribueOverrides);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; context.HttpContext.Response.ContentType = &quot;text/xml&quot;;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; xs.Serialize(context.HttpContext.Response.Output, _objectToSerialize);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160; }      <br />}      </em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/anoriginalidea.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/anoriginalidea.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/anoriginalidea.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/anoriginalidea.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/anoriginalidea.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/anoriginalidea.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/anoriginalidea.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/anoriginalidea.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/anoriginalidea.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/anoriginalidea.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/anoriginalidea.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/anoriginalidea.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/anoriginalidea.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/anoriginalidea.wordpress.com/369/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=369&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://anoriginalidea.wordpress.com/2011/06/17/returning-data-from-an-mvc-method-with-a-small-cute-actionresult/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a70f6e33c95b7744068ecffceac0aa31?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">anoriginalidea</media:title>
		</media:content>

		<media:content url="http://anoriginalidea.files.wordpress.com/2011/06/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Data Uris&#8211;A way of embedding images in your html page or UIWebView</title>
		<link>http://anoriginalidea.wordpress.com/2011/05/24/data-urisa-way-of-embedding-images-in-your-html-page-or-uiwebview/</link>
		<comments>http://anoriginalidea.wordpress.com/2011/05/24/data-urisa-way-of-embedding-images-in-your-html-page-or-uiwebview/#comments</comments>
		<pubDate>Mon, 23 May 2011 22:41:14 +0000</pubDate>
		<dc:creator>anoriginalidea</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[datauri]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objectivec]]></category>

		<guid isPermaLink="false">https://anoriginalidea.wordpress.com/2011/05/24/data-urisa-way-of-embedding-images-in-your-html-page-or-uiwebview/</guid>
		<description><![CDATA[Currently I’m investigating ways of using&#160; UIWebView to render a user interface.&#160;&#160; I’d like to re-purpose some server side html form rendering logic so that it can be resused on the iPhone, Android and Windows Phone.&#160; Modern forms incorporate more than simple form elements however.&#160; They may include data, such as images. By default, the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=361&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://anoriginalidea.files.wordpress.com/2011/05/image1.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" border="0" alt="image" src="http://anoriginalidea.files.wordpress.com/2011/05/image_thumb1.png?w=209&#038;h=244" width="209" height="244" /></a></p>
<p>Currently I’m investigating ways of using&#160; UIWebView to render a user interface.&#160;&#160; </p>
<p>I’d like to re-purpose some server side html form rendering logic so that it can be resused on the iPhone, Android and Windows Phone.&#160; </p>
<p>Modern forms incorporate more than simple form elements however.&#160; They may include data, such as images.</p>
<p>By default, the UIWebview supports images in the “bundle” and images in the documents area.&#160; </p>
<p>What if I want to create images in memory, then display these in the HTML?</p>
<p>An little known feature of many modern web browsers (including Webkit) is datauris.&#160; A <a href="http://en.wikipedia.org/wiki/Data_URI_scheme">datauri</a> allows data to be embedded in a webpage where a url would usually be.</p>
<p>Here’s an example:</p>
<pre>&lt;img src=&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==&quot; alt=&quot;Red dot&quot; /&gt;</pre>
<pre><font face="Verdana">There are disadvantages however, which are the obvious effect this will have on caching and pagesize.</font></pre>
<pre><font face="Verdana">The Stackflow article <a href="http://stackoverflow.com/questions/5329648/display-local-uiimage-on-uiwebview">Display Local UI Image On a UIWebView</a> shows how to this, replicated here for your convenience.</font></pre>
<pre><font face="Verdana">This code demonstrates reading a file from the local bundle, then embedding into the background image, in the html dom of a UIWebView:</font></pre>
<p><code><code></p>
<p>#import &quot;NSString+DataURI.h&quot;</p>
<p>#import &quot;NSData+Base64.h&quot;</p>
<p>...</p>
<p>-(void)webViewDidFinishLoad:(UIWebView *)webView</p>
<p>{</p>
<p>&#160;&#160;&#160; NSString *imgPath = [[NSBundle mainBundle] pathForResource:@&quot;image&quot; ofType:@&quot;png&quot;];</p>
<p>&#160;&#160;&#160; NSData *imgData = [NSData dataWithContentsOfFile:imgPath];</p>
<p>&#160;&#160;&#160; NSString *imgB64 = [[imgData base64Encoding] pngDataURIWithContent];</p>
<p>&#160;&#160;&#160; NSString *javascript = [NSString stringWithFormat:@&quot;document.body.style.backgroundImage='url(%@)';&quot;, imgB64];</p>
<p>&#160;&#160;&#160; [webView stringByEvaluatingJavaScriptFromString:javascript];</p>
<p>}</code></p>
<p><font face="Verdana">This code uses the following utility functions that provide the base 64 encoding support:</font></p>
<p>NSData+Base64.h</p>
<p><code>@interface NSData (Base64) </code></p>
<p>    <code></p>
<p>+ (NSData *)dataWithBase64EncodedString:(NSString *)string;</p>
<p>- (id)initWithBase64EncodedString:(NSString *)string;</p>
<p>- (NSString *)base64Encoding;</p>
<p>- (NSString *)base64EncodingWithLineLength:(unsigned int) lineLength;</p>
<p>@end</p>
<p>    </code></p>
<p>NSData.Base64.m</p>
<p><code>#import &quot;NSData+Base64.h&quot;</code></p>
<p>    <code></p>
<p>static char encodingTable[64] = {</p>
<p>'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',</p>
<p>'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',</p>
<p>'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',</p>
<p>'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' };</p>
<p>@implementation NSData (VQBase64)</p>
<p>- (id)initWithString:(NSString *)string {</p>
<p>&#160;&#160;&#160; if ((self = [super init])) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; [self initWithBase64EncodedString:string];</p>
<p>&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; return self;</p>
<p>}</p>
<p>+ (NSData *) dataWithBase64EncodedString:(NSString *) string {</p>
<p>&#160;&#160;&#160; return [[[NSData allocWithZone:nil] initWithBase64EncodedString:string] autorelease];</p>
<p>}</p>
<p>- (id) initWithBase64EncodedString:(NSString *) string {</p>
<p>&#160;&#160;&#160; NSMutableData *mutableData = nil;</p>
<p>&#160;&#160;&#160; if( string ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; unsigned long ixtext = 0;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; unsigned long lentext = 0;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; unsigned char ch = 0;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; unsigned char inbuf[4], outbuf[3];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; short i = 0, ixinbuf = 0;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; BOOL flignore = NO;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; BOOL flendtext = NO;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; NSData *base64Data = nil;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; const unsigned char *base64Bytes = nil;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Convert the string to ASCII data.</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; base64Data = [string dataUsingEncoding:NSASCIIStringEncoding];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; base64Bytes = [base64Data bytes];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; mutableData = [NSMutableData dataWithCapacity:[base64Data length]];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; lentext = [base64Data length];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; while( YES ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( ixtext &gt;= lentext ) break;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ch = base64Bytes[ixtext++];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; flignore = NO;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( ( ch &gt;= 'A' ) &amp;&amp; ( ch &lt;= 'Z' ) ) ch = ch - 'A';</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else if( ( ch &gt;= 'a' ) &amp;&amp; ( ch &lt;= 'z' ) ) ch = ch - 'a' + 26;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else if( ( ch &gt;= '0' ) &amp;&amp; ( ch &lt;= '9' ) ) ch = ch - '0' + 52;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else if( ch == '+' ) ch = 62;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else if( ch == '=' ) flendtext = YES;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else if( ch == '/' ) ch = 63;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else flignore = YES;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( ! flignore ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; short ctcharsinbuf = 3;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BOOL flbreak = NO;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( flendtext ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( ! ixinbuf ) break;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( ( ixinbuf == 1 ) || ( ixinbuf == 2 ) ) ctcharsinbuf = 1;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else ctcharsinbuf = 2;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ixinbuf = 3;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; flbreak = YES;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; inbuf [ixinbuf++] = ch;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( ixinbuf == 4 ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ixinbuf = 0;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; outbuf [0] = ( inbuf[0] &lt;&lt; 2 ) | ( ( inbuf[1] &amp; 0x30) &gt;&gt; 4 );</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; outbuf [1] = ( ( inbuf[1] &amp; 0x0F ) &lt;&lt; 4 ) | ( ( inbuf[2] &amp; 0x3C ) &gt;&gt; 2 );</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; outbuf [2] = ( ( inbuf[2] &amp; 0x03 ) &lt;&lt; 6 ) | ( inbuf[3] &amp; 0x3F );</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; for( i = 0; i &lt; ctcharsinbuf; i++ )</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [mutableData appendBytes:&amp;outbuf[i] length:1];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( flbreak )&#160; break;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; self = [self initWithData:mutableData];</p>
<p>&#160;&#160;&#160; return self;</p>
<p>}</p>
<p>#pragma mark -</p>
<p>- (NSString *) base64Encoding {</p>
<p>&#160;&#160;&#160; return [self base64EncodingWithLineLength:0];</p>
<p>}</p>
<p>- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength {</p>
<p>&#160;&#160;&#160; const unsigned char&#160;&#160;&#160;&#160; *bytes = [self bytes];</p>
<p>&#160;&#160;&#160; NSMutableString *result = [NSMutableString stringWithCapacity:[self length]];</p>
<p>&#160;&#160;&#160; unsigned long ixtext = 0;</p>
<p>&#160;&#160;&#160; unsigned long lentext = [self length];</p>
<p>&#160;&#160;&#160; long ctremaining = 0;</p>
<p>&#160;&#160;&#160; unsigned char inbuf[3], outbuf[4];</p>
<p>&#160;&#160;&#160; unsigned short i = 0;</p>
<p>&#160;&#160;&#160; unsigned short charsonline = 0, ctcopy = 0;</p>
<p>&#160;&#160;&#160; unsigned long ix = 0;</p>
<p>&#160;&#160;&#160; while( YES ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ctremaining = lentext - ixtext;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( ctremaining &lt;= 0 ) break;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; for( i = 0; i &lt; 3; i++ ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ix = ixtext + i;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( ix &lt; lentext ) inbuf[i] = bytes[ix];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else inbuf [i] = 0;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; outbuf [0] = (inbuf [0] &amp; 0xFC) &gt;&gt; 2;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; outbuf [1] = ((inbuf [0] &amp; 0x03) &lt;&lt; 4) | ((inbuf [1] &amp; 0xF0) &gt;&gt; 4);</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; outbuf [2] = ((inbuf [1] &amp; 0x0F) &lt;&lt; 2) | ((inbuf [2] &amp; 0xC0) &gt;&gt; 6);</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; outbuf [3] = inbuf [2] &amp; 0x3F;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ctcopy = 4;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; switch( ctremaining ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case 1:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ctcopy = 2;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case 2:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ctcopy = 3;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; for( i = 0; i &lt; ctcopy; i++ )</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [result appendFormat:@&quot;%c&quot;, encodingTable[outbuf[i]]];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; for( i = ctcopy; i &lt; 4; i++ )</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [result appendString:@&quot;=&quot;];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ixtext += 3;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; charsonline += 4;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( lineLength &gt; 0 ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( charsonline &gt;= lineLength ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; charsonline = 0;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [result appendString:@&quot;\n&quot;];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; return [NSString stringWithString:result];</p>
<p>}</p>
<p>@end </p>
<p>&#160;&#160;
<p>NSString+DataURI.h</p>
<p>#import &lt;Foundation/Foundation.h&gt;</p>
<p>@interface NSString(DataURI)</p>
<p>- (NSString *) pngDataURIWithContent;</p>
<p>- (NSString *) jpgDataURIWithContent;</p>
<p>@end</p>
<p>    </code></p>
<p>NSString+DataURI.m</p>
<p><code>#import &quot;NSString+DataURI.h&quot;</code></p>
<p>    <code></p>
<p>@implementation NSString(DataURI)</p>
<p>- (NSString *) pngDataURIWithContent;</p>
<p>{</p>
<p>&#160;&#160;&#160; NSString * result = [NSString stringWithFormat: @&quot;data:image/png;base64,%@&quot;, self];</p>
<p>&#160;&#160;&#160; return result;</p>
<p>}</p>
<p>- (NSString *) jpgDataURIWithContent;</p>
<p>{</p>
<p>&#160;&#160;&#160; NSString * result = [NSString stringWithFormat: @&quot;data:image/jpg;base64,%@&quot;, self];</p>
<p>&#160;&#160;&#160; return result;</p>
<p>}</p>
<p>@end </p>
<p>      <font face="Verdana"></font>&#160;<font face="Verdana"></font>&#160;</code></code></p>
<pre><font face="Verdana"></font>&#160;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/anoriginalidea.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/anoriginalidea.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/anoriginalidea.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/anoriginalidea.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/anoriginalidea.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/anoriginalidea.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/anoriginalidea.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/anoriginalidea.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/anoriginalidea.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/anoriginalidea.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/anoriginalidea.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/anoriginalidea.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/anoriginalidea.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/anoriginalidea.wordpress.com/361/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=361&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://anoriginalidea.wordpress.com/2011/05/24/data-urisa-way-of-embedding-images-in-your-html-page-or-uiwebview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a70f6e33c95b7744068ecffceac0aa31?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">anoriginalidea</media:title>
		</media:content>

		<media:content url="http://anoriginalidea.files.wordpress.com/2011/05/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting the default browser in Visual Studio 2010 in an MVC Application</title>
		<link>http://anoriginalidea.wordpress.com/2011/05/12/setting-the-default-browser-in-visual-studio-2010-in-an-mvc-application/</link>
		<comments>http://anoriginalidea.wordpress.com/2011/05/12/setting-the-default-browser-in-visual-studio-2010-in-an-mvc-application/#comments</comments>
		<pubDate>Thu, 12 May 2011 10:39:55 +0000</pubDate>
		<dc:creator>anoriginalidea</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://anoriginalidea.wordpress.com/2011/05/12/setting-the-default-browser-in-visual-studio-2010-in-an-mvc-application/</guid>
		<description><![CDATA[To set the default browser used for debugging in an ASP.Net web application you need to bring up the “Browse With…” option on an aspx web page.&#160; In a default MVC application you won’t have this option. To do this temporarily add a “default.aspx” form to the root of your project, then the “Browse With…” [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=358&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://anoriginalidea.files.wordpress.com/2011/05/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="image" border="0" alt="image" src="http://anoriginalidea.files.wordpress.com/2011/05/image_thumb.png?w=244&#038;h=223" width="244" height="223" /></a></p>
<p>To set the default browser used for debugging in an ASP.Net web application you need to bring up the “Browse With…” option on an aspx web page.&#160; In a default MVC application you won’t have this option.</p>
<p>To do this temporarily add a “default.aspx” form to the root of your project, then the “Browse With…” context menu option will appear.&#160; Choose your favourite browser, then remove the “default.aspx”.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/anoriginalidea.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/anoriginalidea.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/anoriginalidea.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/anoriginalidea.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/anoriginalidea.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/anoriginalidea.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/anoriginalidea.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/anoriginalidea.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/anoriginalidea.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/anoriginalidea.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/anoriginalidea.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/anoriginalidea.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/anoriginalidea.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/anoriginalidea.wordpress.com/358/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=358&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://anoriginalidea.wordpress.com/2011/05/12/setting-the-default-browser-in-visual-studio-2010-in-an-mvc-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a70f6e33c95b7744068ecffceac0aa31?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">anoriginalidea</media:title>
		</media:content>

		<media:content url="http://anoriginalidea.files.wordpress.com/2011/05/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Updating Twitter via SuperTweet using VBA</title>
		<link>http://anoriginalidea.wordpress.com/2011/04/28/updating-twitter-via-supertweet-using-vba/</link>
		<comments>http://anoriginalidea.wordpress.com/2011/04/28/updating-twitter-via-supertweet-using-vba/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 12:54:19 +0000</pubDate>
		<dc:creator>anoriginalidea</dc:creator>
				<category><![CDATA[Outlook]]></category>
		<category><![CDATA[supertweet]]></category>
		<category><![CDATA[twitter api]]></category>
		<category><![CDATA[vb6]]></category>
		<category><![CDATA[vba]]></category>

		<guid isPermaLink="false">https://anoriginalidea.wordpress.com/2011/04/28/updating-twitter-via-supertweet-using-vba/</guid>
		<description><![CDATA[In my previous article I showed how to update a twitter status, prior to the twitter decision to remove the basic authentication api.&#160; This article shows a way of getting around this.&#160; The SuperTweet service allows you to continue to use basic authentication.&#160; This is particularly useful for non-visual processes that use VBA. I am [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=354&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img style="margin:5px;" alt="image" src="http://anoriginalidea.files.wordpress.com/2007/10/image-thumb.png?w=231&amp;h=68" /></p>
<p>In my <a href="http://anoriginalidea.wordpress.com/2007/10/12/twittering-from-outlook-using-vba/">previous article</a> I showed how to update a twitter status, prior to the twitter decision to remove the basic authentication api.&#160; This article shows a way of getting around this.&#160; The <a href="http://supertweet.net">SuperTweet</a> service allows you to continue to use basic authentication.&#160; This is particularly useful for non-visual processes that use VBA.</p>
<p>I am currently using Twitter to update a private tweet-stream of my activities (such as sending email) from an Outlook 2010 macro.&#160; This stream is then fed into the iPhone application Momento, which provides me with an “autodiary” based on my various twitter feeds and online services.</p>
<p>To use the SuperTweet, there are just three steps:</p>
<ol>
<li>Sign In with OAuth to the SuperTweet.net&#160; (<a href="http://www.supertweet.net/login">Sign-Up/Sign-In Now</a>)</li>
<li>Create a password for your applications to use with the SuperTweet.net API when they want to Tweet: <a href="http://www.supertweet.net/about/documentation#step2">Learn more</a>. </li>
<li>Change your application to use <tt>http://api.supertweet.net</tt> instead of Twitter.com.&#160; See the sample below on how to do this using WinHttp in VBA. ( <a href="http://www.supertweet.net/about/api">Learn more</a>.)</li>
</ol>
<p>The VBA code below will allow you to do an update to Twitter.&#160; The UrlEncode implementation came from <a href="http://stackoverflow.com/questions/218181/how-can-i-url-encode-a-string-in-excel-vba">this StackOverflow post</a>.</p>
<p> <code>
<p>Function PostToTwitter(statusUpdate As String, username As String, password As String) As Boolean      <br />&#160;&#160;&#160; Const HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0&#160; <br />&#160;&#160;&#160; On Error GoTo error_handler       <br />&#160;&#160;&#160; <br />&#160;&#160;&#160; Dim WinHttpReq As New WinHttpRequest       <br />&#160; <br />&#160;&#160;&#160;&#160; ' Assemble an HTTP Request.       <br />&#160;&#160;&#160; WinHttpReq.Open &quot;POST&quot;, _       <br />&#160;&#160;&#160;&#160;&#160; &quot;<a href="http://api.supertweet.net/1/statuses/update.xml&quot;">http://api.supertweet.net/1/statuses/update.xml&quot;</a>, False       <br />&#160;&#160;&#160; WinHttpReq.SetCredentials username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER       <br />&#160;&#160;&#160; ' Send the HTTP Request.       <br />&#160;&#160;&#160; WinHttpReq.SetRequestHeader &quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;       <br />&#160;&#160;&#160; WinHttpReq.Send &quot;status=&quot; &amp; URLEncode(statusUpdate)       <br />&#160;&#160;&#160; If WinHttpReq.Status &lt;&gt; 200 Then       <br />&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160; GoTo error_handler       <br />&#160;&#160;&#160; End If       <br />&#160;&#160;&#160; DoEvents       <br />&#160;&#160;&#160; Debug.Print &quot;Posted - &quot; &amp; statusUpdate       <br />&#160;&#160;&#160; <br />&#160;&#160;&#160; PostToTwitter = True       <br />&#160;&#160;&#160; <br />&#160;&#160;&#160; Exit Function</p>
<p>error_handler:</p>
<p>&#160;&#160;&#160; PostToTwitter = False      <br />&#160;&#160;&#160; <br />&#160;&#160;&#160; Exit Function       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />End Function</p>
<p>Public Function URLEncode( _     <br />&#160;&#160; StringToEncode As String, _      <br />&#160;&#160; Optional UsePlusRatherThanHexForSpace As Boolean = False _      <br />) As String</p>
<p>&#160; Dim TempAns As String     <br />&#160; Dim CurChr As Integer      <br />&#160; CurChr = 1</p>
<p>&#160; Do Until CurChr - 1 = Len(StringToEncode)     <br />&#160;&#160;&#160; Select Case Asc(Mid(StringToEncode, CurChr, 1))      <br />&#160;&#160;&#160;&#160;&#160; Case 48 To 57, 65 To 90, 97 To 122      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; TempAns = TempAns &amp; Mid(StringToEncode, CurChr, 1)      <br />&#160;&#160;&#160;&#160;&#160; Case 32      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; If UsePlusRatherThanHexForSpace = True Then      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TempAns = TempAns &amp; &quot;+&quot;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Else      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TempAns = TempAns &amp; &quot;%&quot; &amp; Hex(32)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If      <br />&#160;&#160;&#160;&#160;&#160; Case Else      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; TempAns = TempAns &amp; &quot;%&quot; &amp; _      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Right(&quot;0&quot; &amp; Hex(Asc(Mid(StringToEncode, _      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CurChr, 1))), 2)      <br />&#160;&#160;&#160; End Select</p>
<p>&#160;&#160;&#160; CurChr = CurChr + 1     <br />&#160; Loop</p>
<p>&#160; URLEncode = TempAns     <br />End Function</p>
<p></code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/anoriginalidea.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/anoriginalidea.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/anoriginalidea.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/anoriginalidea.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/anoriginalidea.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/anoriginalidea.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/anoriginalidea.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/anoriginalidea.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/anoriginalidea.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/anoriginalidea.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/anoriginalidea.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/anoriginalidea.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/anoriginalidea.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/anoriginalidea.wordpress.com/354/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=354&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://anoriginalidea.wordpress.com/2011/04/28/updating-twitter-via-supertweet-using-vba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a70f6e33c95b7744068ecffceac0aa31?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">anoriginalidea</media:title>
		</media:content>

		<media:content url="http://anoriginalidea.files.wordpress.com/2007/10/image-thumb.png?w=231&#38;h=68" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Bringing a Windows Application to the Foreground using .net</title>
		<link>http://anoriginalidea.wordpress.com/2011/04/01/bringing-a-windows-application-to-the-foreground-using-net/</link>
		<comments>http://anoriginalidea.wordpress.com/2011/04/01/bringing-a-windows-application-to-the-foreground-using-net/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 10:46:10 +0000</pubDate>
		<dc:creator>anoriginalidea</dc:creator>
				<category><![CDATA[.net Framework]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[SetForegroundWindow]]></category>

		<guid isPermaLink="false">https://anoriginalidea.wordpress.com/2011/04/01/bringing-a-windows-application-to-the-foreground-using-net/</guid>
		<description><![CDATA[It’s surprising that there’s very little information available about bringing another windows application to the foreground. The SetForegroundWindow api call can be useful in this regard, but it can’t be used unless you know the windows handle of the main window of the application you’re activating.&#160; If the application you’re activating has many child windows, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=353&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://anoriginalidea.files.wordpress.com/2011/04/image.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://anoriginalidea.files.wordpress.com/2011/04/image_thumb.png?w=244&#038;h=95" width="244" height="95" /></a></p>
<p>It’s surprising that there’s very little information available about bringing another windows application to the foreground.</p>
<p>The SetForegroundWindow api call can be useful in this regard, but it can’t be used unless you know the windows handle of the main window of the application you’re activating.&#160; If the application you’re activating has many child windows, simply using the “MainWindowHandle” property on the Process object is not enough.</p>
<p>The code fragment and sample will show how to find a process, enumerate it’s child windows, then send these the foreground.</p>
<p>&#160;</p>
<pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">BringAppToForeground(“notepad”)
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">………
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"><span style="color:#0000ff;">using</span> System.Diagnostics;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"><span style="color:#0000ff;">using</span> System.Runtime.InteropServices;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">……….
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">[DllImport(&quot;<span style="color:#8b0000;">user32.dll</span>&quot;)] <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">extern</span> <span style="color:#0000ff;">bool</span> SetForegroundWindow(IntPtr hWnd);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">[DllImport(&quot;<span style="color:#8b0000;">user32.dll</span>&quot;)]
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">

<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">extern</span> IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter,

 <span style="color:#0000ff;">string</span> windowClass, <span style="color:#0000ff;">string</span> windowTitle);

</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> BringAppToForeground(<span style="color:#0000ff;">string</span> appName)
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">{
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#008000;">// Find Parent </span>
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           IntPtr parenthWnd = GetProcessWindowHandle(appName);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#0000ff;">if</span> (parenthWnd == IntPtr.Zero) <span style="color:#0000ff;">return</span>;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#008000;">// Get list of child windows </span>
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           List&lt;IntPtr&gt; loChildWindows = GetChildWindowHandles(parenthWnd);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#008000;">// Bring Windows to Front </span>
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           BringWindowsToFront(loChildWindows.Reverse&lt;IntPtr&gt;());
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">}
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> IntPtr GetProcessWindowHandle(<span style="color:#0000ff;">string</span> processName)
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">{
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           IntPtr parenthWnd = IntPtr.Zero;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#0000ff;">foreach</span> (Process loProcess <span style="color:#0000ff;">in</span> Process.GetProcessesByName(processName))
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           {
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">               parenthWnd = loProcess.MainWindowHandle;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">               <span style="color:#0000ff;">if</span> (parenthWnd != IntPtr.Zero) <span style="color:#0000ff;">break</span>;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           }
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#0000ff;">return</span> parenthWnd;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">}
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> BringWindowsToFront(IEnumerable&lt;IntPtr&gt; windows)
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">{
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#008000;">// Go through each and bring to front </span>
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#0000ff;">foreach</span> (IntPtr fronthWnd <span style="color:#0000ff;">in</span> windows)
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           {
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">               SetForegroundWindow(fronthWnd);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           }
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">}
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> List&lt;IntPtr&gt; GetChildWindowHandles(IntPtr parenthWnd)
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">{
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           IntPtr hWnd = IntPtr.Zero;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           List&lt;IntPtr&gt; loChildWindows = <span style="color:#0000ff;">new</span> List&lt;IntPtr&gt;();
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#0000ff;">do</span>
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           {
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">               hWnd = FindWindowEx(parenthWnd, hWnd, <span style="color:#0000ff;">null</span>, <span style="color:#0000ff;">null</span>);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">               <span style="color:#0000ff;">if</span> (hWnd == IntPtr.Zero) <span style="color:#0000ff;">break</span>;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">               loChildWindows.Add(hWnd);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           }
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#0000ff;">while</span> (hWnd != IntPtr.Zero);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">           <span style="color:#0000ff;">return</span> loChildWindows;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;">}
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#039;font-size:12px;margin:0;"></pre>
</pre>
<p>To understand how to use this in a winforms project, take a look at the sample project.</p>
<p><a href="http://cid-5f1708eb705d1c65.office.live.com/self.aspx/Public/BringWindowsAppToFront.zip">Download Sample Project</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/anoriginalidea.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/anoriginalidea.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/anoriginalidea.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/anoriginalidea.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/anoriginalidea.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/anoriginalidea.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/anoriginalidea.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/anoriginalidea.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/anoriginalidea.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/anoriginalidea.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/anoriginalidea.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/anoriginalidea.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/anoriginalidea.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/anoriginalidea.wordpress.com/353/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=353&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://anoriginalidea.wordpress.com/2011/04/01/bringing-a-windows-application-to-the-foreground-using-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a70f6e33c95b7744068ecffceac0aa31?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">anoriginalidea</media:title>
		</media:content>

		<media:content url="http://anoriginalidea.files.wordpress.com/2011/04/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Optimising Winforms Dropdown list combos for touch</title>
		<link>http://anoriginalidea.wordpress.com/2011/02/27/optimising-winforms-dropdown-list-combos-for-touch/</link>
		<comments>http://anoriginalidea.wordpress.com/2011/02/27/optimising-winforms-dropdown-list-combos-for-touch/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 08:57:16 +0000</pubDate>
		<dc:creator>anoriginalidea</dc:creator>
				<category><![CDATA[.net Framework]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[touch combo]]></category>
		<category><![CDATA[windows tablet]]></category>
		<category><![CDATA[winforms]]></category>

		<guid isPermaLink="false">https://anoriginalidea.wordpress.com/2011/02/27/optimising-winforms-dropdown-list-combos-for-touch/</guid>
		<description><![CDATA[The optimisation of the iPhone and the iPad for touch has contributed to it’s success.&#160; One example of this kind of optimisation is “drop down combos”.&#160; Rather than sticking with the traditional touch UI of a big combo with a fat scrollbar (that would mess up web pages), they do something completely different.&#160; As shown [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=350&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://anoriginalidea.files.wordpress.com/2011/02/image.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" border="0" alt="image" src="http://anoriginalidea.files.wordpress.com/2011/02/image_thumb.png?w=134&#038;h=244" width="134" height="244" /></a></p>
<p>The optimisation of the iPhone and the iPad for touch has contributed to it’s success.&#160; </p>
<p>One example of this kind of optimisation is “drop down combos”.&#160; Rather than sticking with the traditional touch UI of a big combo with a fat scrollbar (that would mess up web pages), they do something completely different.&#160; As shown above a neat “roller” control is shown which makes combos a pleasure to use.</p>
<p>On the iPad the experience is more like a traditional combo, but it is not the same.</p>
<p>In the creation of Windows 7 Tablet user interfaces I am sure our users would prefer this kind of experience.</p>
<p>In Winforms it turns out that it’s possible to improve the touch experience markedly using the “OwnerDrawVariable” style on comboboxes. </p>
<p>As you can see, when the combo box looks relatively normal, not taking up much screen real estate….</p>
<p><a href="http://anoriginalidea.files.wordpress.com/2011/02/image1.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:5px;" title="image" border="0" alt="image" src="http://anoriginalidea.files.wordpress.com/2011/02/image_thumb1.png?w=240&#038;h=153" width="240" height="153" /></a></p>
<p>Yet when it’s clicked, the control becomes bigger, so the normal flick scrolling features of Windows 7 tablet can work better.</p>
<p><a href="http://anoriginalidea.files.wordpress.com/2011/02/image2.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:5px;" title="image" border="0" alt="image" src="http://anoriginalidea.files.wordpress.com/2011/02/image_thumb2.png?w=240&#038;h=183" width="240" height="183" /></a></p>
<p>The following code sample is a class called TouchCombo that can be used to cause combos to take on the new style.&#160; Here’s the code for the sample form:</p>
<p> <code>
<p>Public Class Form1      <br />&#160;&#160;&#160; Private Sub mPopulate(ByVal combo As ComboBox)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; combo.Items.Add(&quot;Alpha&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; combo.Items.Add(&quot;Beta&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; combo.Items.Add(&quot;Gamma&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; combo.Items.Add(&quot;Delta&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; combo.Items.Add(&quot;Epsilon&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; combo.SelectedIndex = 0</p>
<p>&#160;&#160;&#160; End Sub</p>
<p>&#160;&#160;&#160; Private moTouchCombo As New TouchCombo      <br />&#160;&#160;&#160; Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; mPopulate(ComboBox1)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; mPopulate(ComboBox2)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; moTouchCombo.Connect(ComboBox2)       <br />&#160;&#160;&#160; End Sub       <br />End Class</p>
<p>&#160;</p>
<p> </code>
<p>Here’s the code for the TouchCombo class:</p>
<p>&#160;</p>
<p> <code>
<p>Public Class TouchCombo</p>
<p>&#160;&#160;&#160; Public Sub Connect(ByVal combo As ComboBox)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; combo.DrawMode = DrawMode.OwnerDrawVariable       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; combo.DropDownHeight = 200       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; combo.DropDownWidth = combo.Width * 1.5       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; AddHandler combo.MeasureItem, AddressOf mMeasureItem       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; AddHandler combo.DrawItem, AddressOf mDrawItem       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; AddHandler combo.DropDown, AddressOf mDropDown       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; AddHandler combo.DropDownClosed, AddressOf mDropDownClosed       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; AddHandler combo.Disposed, AddressOf mDisposed       <br />&#160;&#160;&#160; End Sub</p>
<p>&#160;&#160;&#160; Private Sub mDrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs)</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim loCombo As ComboBox = sender</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Using loBrush = New System.Drawing.SolidBrush(e.ForeColor)</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' Draw the normal Background      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.DrawBackground()</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' If it's not dropped down, make it look normal      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If Not loCombo.DroppedDown OrElse e.State = DrawItemState.ComboBoxEdit OrElse e.State = DrawItemState.Default Then       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.Graphics.DrawString(loCombo.Items(e.Index), loCombo.Font, loBrush, e.Bounds.X, e.Bounds.Y)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' Otherwise draw it big       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Using loFont As New System.Drawing.Font(&quot;Arial&quot;, 15, FontStyle.Bold)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.Graphics.DrawString(loCombo.Items(e.Index), loFont, loBrush, e.Bounds.X, e.Bounds.Y)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End Using       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.DrawFocusRectangle()</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; End Using</p>
<p>&#160;&#160;&#160; End Sub      <br />&#160;&#160;&#160; Private Sub mMeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.ItemHeight = 35       <br />&#160;&#160;&#160; End Sub       <br />&#160;&#160;&#160; Private Sub mDropDown(ByVal sender As Object, ByVal e As System.EventArgs)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim loCombo As ComboBox = sender       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; loCombo.ItemHeight = 35       <br />&#160;&#160;&#160; End Sub</p>
<p>&#160;&#160;&#160; Private Sub mDropDownClosed(ByVal sender As Object, ByVal e As System.EventArgs)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim loCombo As ComboBox = sender       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; loCombo.ItemHeight = 15       <br />&#160;&#160;&#160; End Sub</p>
<p>&#160;&#160;&#160; Private Sub mDisposed(ByVal sender As Object, ByVal e As System.EventArgs)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim loCombo As ComboBox = sender       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; RemoveHandler loCombo.MeasureItem, AddressOf mMeasureItem       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; RemoveHandler loCombo.DrawItem, AddressOf mDrawItem       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; RemoveHandler loCombo.DropDown, AddressOf mDropDown       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; RemoveHandler loCombo.DropDownClosed, AddressOf mDropDownClosed       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; RemoveHandler loCombo.Disposed, AddressOf mDisposed       <br />&#160;&#160;&#160; End Sub       <br />End Class       </p>
<p> </code>
<p>&#160;</p>
<p><a href="http://cid-5f1708eb705d1c65.office.live.com/self.aspx/Public/TouchComboFun.zip">Download</a> the project.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/anoriginalidea.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/anoriginalidea.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/anoriginalidea.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/anoriginalidea.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/anoriginalidea.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/anoriginalidea.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/anoriginalidea.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/anoriginalidea.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/anoriginalidea.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/anoriginalidea.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/anoriginalidea.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/anoriginalidea.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/anoriginalidea.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/anoriginalidea.wordpress.com/350/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=350&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://anoriginalidea.wordpress.com/2011/02/27/optimising-winforms-dropdown-list-combos-for-touch/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a70f6e33c95b7744068ecffceac0aa31?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">anoriginalidea</media:title>
		</media:content>

		<media:content url="http://anoriginalidea.files.wordpress.com/2011/02/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://anoriginalidea.files.wordpress.com/2011/02/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://anoriginalidea.files.wordpress.com/2011/02/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>PowerPoint Inception Deck template for the Agile Samurai</title>
		<link>http://anoriginalidea.wordpress.com/2011/01/27/powerpoint-inception-deck-template-for-the-agile-samurai/</link>
		<comments>http://anoriginalidea.wordpress.com/2011/01/27/powerpoint-inception-deck-template-for-the-agile-samurai/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 05:11:46 +0000</pubDate>
		<dc:creator>anoriginalidea</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[agile samurai]]></category>

		<guid isPermaLink="false">https://anoriginalidea.wordpress.com/2011/01/27/powerpoint-inception-deck-template-for-the-agile-samurai/</guid>
		<description><![CDATA[&#160; Recently I read the “Agile Samurai” a great introduction to Agile software development. The first part of the book talks about an artefact called the “Inception Deck”, a number of cards or powerpoint presentation that is used to help understand and scope a software project. The inception deck elaborates on: Why are we here? [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=343&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p><a href="http://anoriginalidea.files.wordpress.com/2011/01/image.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://anoriginalidea.files.wordpress.com/2011/01/image_thumb.png?w=244&#038;h=169" width="244" height="169" /></a></p>
<p>Recently I read the “Agile Samurai” a great introduction to Agile software development.</p>
<p>The first part of the book talks about an artefact called the “Inception Deck”, a number of cards or powerpoint presentation that is used to help understand and scope a software project.</p>
<p>The inception deck elaborates on:</p>
<ol>
<li>Why are we here?</li>
<li>Create an elevator pitch</li>
<li>Product Box</li>
<li>Create a NOT list</li>
<li>Meet your neighbours</li>
<li>Show the solution</li>
<li>What keeps us up at night</li>
<li>Size it up</li>
<li>Be clear on what’s going to give</li>
<li>Show what it’s going to take</li>
</ol>
<p>I couldn’t find a powerpoint template to start me off, so I created one for anyone who is interested.&#160; It’s pretty basic, but it’s nice to start somewhere.</p>
<p><a href="http://cid-5f1708eb705d1c65.office.live.com/self.aspx/Public/Inception%20Deck.pptx">Download here</a>.</p>
<h4>Links</h4>
<p>Learn more from the Agile Warrior himself here:</p>
<p><a href="http://agilewarrior.wordpress.com/2010/11/06/the-agile-inception-deck/">http://agilewarrior.wordpress.com/2010/11/06/the-agile-inception-deck/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/anoriginalidea.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/anoriginalidea.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/anoriginalidea.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/anoriginalidea.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/anoriginalidea.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/anoriginalidea.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/anoriginalidea.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/anoriginalidea.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/anoriginalidea.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/anoriginalidea.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/anoriginalidea.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/anoriginalidea.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/anoriginalidea.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/anoriginalidea.wordpress.com/343/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=343&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://anoriginalidea.wordpress.com/2011/01/27/powerpoint-inception-deck-template-for-the-agile-samurai/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a70f6e33c95b7744068ecffceac0aa31?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">anoriginalidea</media:title>
		</media:content>

		<media:content url="http://anoriginalidea.files.wordpress.com/2011/01/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Capturing a still image from a Webcam in .net</title>
		<link>http://anoriginalidea.wordpress.com/2010/10/04/capturing-a-still-image-from-a-webcam-in-net/</link>
		<comments>http://anoriginalidea.wordpress.com/2010/10/04/capturing-a-still-image-from-a-webcam-in-net/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 13:55:15 +0000</pubDate>
		<dc:creator>anoriginalidea</dc:creator>
				<category><![CDATA[.net Framework]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[avicap32]]></category>
		<category><![CDATA[image capture]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">https://anoriginalidea.wordpress.com/2010/10/04/capturing-a-still-image-from-a-webcam-in-net/</guid>
		<description><![CDATA[&#160; What if you want to capture a single image from a webcam?&#160; It turns out that this is quite straight forward to do using a couple of Win32 api calls to the avicap32.dll library. I encapsulated these api calls in a simple class. To write a file called “snapshot.jpg” out to the desktop from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=340&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://anoriginalidea.files.wordpress.com/2010/10/image3.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://anoriginalidea.files.wordpress.com/2010/10/image_thumb3.png?w=244&#038;h=180" width="244" height="180" /></a>&#160; </p>
<p>What if you want to capture a single image from a webcam?&#160; It turns out that this is quite straight forward to do using a couple of Win32 api calls to the avicap32.dll library.</p>
<p>I encapsulated these api calls in a simple class.</p>
<p>To write a file called “snapshot.jpg” out to the desktop from a single webcam, simply declare the class and call a the TakePicture method.</p>
<p> <code>
<p>Dim loSnap As New WebcamSnap     <br />loSnap.TakePicture(0)</p>
<p> </code>
<p>The devices collection shows a list of all webcam devices on your machine so you can populate a combo with them.</p>
<p>Note: This example has no decent error handling, which I suspect will be needed in the “real world” of multiple devices.</p>
<p>Here’s the WebcamSnap class:</p>
<p> <code>
<p>Option Explicit On      <br />Imports System.IO       <br />Imports System.Runtime.InteropServices       <br />''' &lt;summary&gt;       <br />''' This class takes a snapshot from any or all attached webcams       <br />''' &lt;/summary&gt;       <br />''' &lt;remarks&gt;&lt;/remarks&gt;       <br />Public Class WebcamSnap       <br />&#160;&#160;&#160; Const WM_CAP As Short = &amp;H400S </p>
<p>&#160;&#160;&#160; Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10      <br />&#160;&#160;&#160; Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11       <br />&#160;&#160;&#160; Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30       <br />&#160;&#160;&#160; Const WS_CHILD As Integer = &amp;H40000000       <br />&#160;&#160;&#160; Const WS_VISIBLE As Integer = &amp;H10000000       <br />&#160;&#160;&#160; Declare Function SendMessage Lib &quot;user32&quot; Alias &quot;SendMessageA&quot; _       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;MarshalAs(UnmanagedType.AsAny)&gt; ByVal lParam As Object) As Integer </p>
<p>&#160;&#160;&#160; Declare Function capCreateCaptureWindowA Lib &quot;avicap32.dll&quot; _      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; (ByVal lpszWindowName As String, ByVal dwStyle As Integer, _       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, _       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; ByVal nHeight As Short, ByVal hWndParent As Integer, _       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; ByVal nID As Integer) As Integer </p>
<p>&#160;&#160;&#160; Declare Function capGetDriverDescriptionA Lib &quot;avicap32.dll&quot; (ByVal wDriver As Short, _      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, _       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; ByVal cbVer As Integer) As Boolean </p>
<p>&#160;&#160;&#160; Public Devices As New List(Of String)      <br />&#160;&#160;&#160; Public Height As Integer = 480       <br />&#160;&#160;&#160; Public Width As Integer = 640       <br />&#160;&#160;&#160; Public OutputPath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)       <br />&#160;&#160;&#160; Public FilenamePrefix As String = &quot;snapshot&quot;       <br />&#160;&#160;&#160; Public Sub New()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; mLoadDeviceList()       <br />&#160;&#160;&#160; End Sub       <br />&#160;&#160;&#160; Private Sub mLoadDeviceList()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim lsName As String = Space(100)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim lsVers As String = Space(100)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim lbReturn As Boolean       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim x As Integer = 0 </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Do      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; '&#160;&#160; Get Driver name and version       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lbReturn = capGetDriverDescriptionA(x, lsName, 100, lsVers, 100) </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' If there was a device add device name to the list      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If lbReturn Then Devices.Add(lsName.Trim)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; x += 1       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Loop Until lbReturn = False       <br />&#160;&#160;&#160; End Sub       <br />&#160;&#160;&#160; Public Sub TakePicture()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; For i = 0 To Me.Devices.Count - 1       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim lsFilename As String = Path.Combine(OutputPath, Me.FilenamePrefix &amp; i &amp; &quot;.jpg&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TakePicture(i, lsFilename)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Next       <br />&#160;&#160;&#160; End Sub       <br />&#160;&#160;&#160; Public Sub TakePicture(ByVal iDevice As Integer)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Me.TakePicture(iDevice, Path.Combine(OutputPath, Me.FilenamePrefix &amp; &quot;.jpg&quot;))       <br />&#160;&#160;&#160; End Sub       <br />&#160;&#160;&#160; Public Sub TakePicture(ByVal iDevice As Integer, ByVal filename As String) </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim lhHwnd As Integer ' Handle to preview window </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' Create a form to play with      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Using loWindow As New System.Windows.Forms.Form </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' Create capture window      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lhHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, Me.Width, _       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Me.Height, loWindow.Handle.ToInt32, 0) </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' Hook up the device      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SendMessage(lhHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' Allow the webcam apeture to let enough light in       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; For i = 1 To 10       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Application.DoEvents()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Next </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' Copy image to clipboard      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SendMessage(lhHwnd, WM_CAP_EDIT_COPY, 0, 0) </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' Get image from clipboard and convert it to a bitmap      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim loData As IDataObject = Clipboard.GetDataObject()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If loData.GetDataPresent(GetType(System.Drawing.Bitmap)) Then       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Using loBitmap As Image = CType(loData.GetData(GetType(System.Drawing.Bitmap)), Image)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; loBitmap.Save(filename, Imaging.ImageFormat.Jpeg)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End Using       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SendMessage(lhHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0) </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; End Using </p>
<p>&#160;&#160;&#160; End Sub </p>
<p>End Class </p>
<p> </code><br />
<h5>Links</h5>
<p>I found the original code sample here:</p>
<p><a href="http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22482234.html">http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22482234.html</a></p>
<p>(Although I’ve seen it all over the web in various guises)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/anoriginalidea.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/anoriginalidea.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/anoriginalidea.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/anoriginalidea.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/anoriginalidea.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/anoriginalidea.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/anoriginalidea.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/anoriginalidea.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/anoriginalidea.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/anoriginalidea.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/anoriginalidea.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/anoriginalidea.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/anoriginalidea.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/anoriginalidea.wordpress.com/340/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=anoriginalidea.wordpress.com&amp;blog=1093530&amp;post=340&amp;subd=anoriginalidea&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://anoriginalidea.wordpress.com/2010/10/04/capturing-a-still-image-from-a-webcam-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a70f6e33c95b7744068ecffceac0aa31?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">anoriginalidea</media:title>
		</media:content>

		<media:content url="http://anoriginalidea.files.wordpress.com/2010/10/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
	</channel>
</rss>
