<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0"><channel><title>Tales from the Evil Empire</title><link>http://weblogs.asp.net/bleroy/default.aspx</link><description>Bertrand Le Roy's blog</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TalesFromTheEvilEmpire" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="talesfromtheevilempire" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Etching sketches with a Netduino Go</title><link>http://weblogs.asp.net/bleroy/archive/2012/05/01/etching-sketches-with-a-netduino-go.aspx</link><pubDate>Wed, 02 May 2012 01:40:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8428664</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8428664</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/05/01/etching-sketches-with-a-netduino-go.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.etch-a-sketchartist.com/etchasketches/?e=starry_night"&gt;&lt;img style="background-image: none; z-index: -10; border-right-width: 0px; margin: -12px 6px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Starry Night - amazing etch-a-sketch art (c) 2012 Jeff Gagliardi" border="0" alt="Starry Night - amazing etch-a-sketch art (c) 2012 Jeff Gagliardi" align="left" src="http://www.etch-a-sketchartist.com/images/largePictures/etchasketch/starry-night.jpg" width="240" height="240" /&gt;&lt;/a&gt;&lt;a href="http://nwazet.com/netduinogo"&gt;Netduino Go&lt;/a&gt; is designed for much more than toy projects, but one has to recognize that toy projects are fun and also great learning experiences. Today, I want to take you through the process of reproducing the behavior of a famous toy that you will surely recognize. That toy, that has helped many of us realize what poor motor skills we possess, has two knobs that control the horizontal and vertical coordinates of a pen that draws into the dust on the back of a simple screen. It’s a great mechanical device that is part of western culture.&lt;/p&gt;  &lt;p&gt;Our version will use two &lt;a href="http://nwazet.com/potentiometer"&gt;potentiometers&lt;/a&gt;, a &lt;a href="http://nwazet.com/touch-display-module"&gt;320x240 LCD display&lt;/a&gt;, a &lt;a href="http://nwazet.com/gobutton"&gt;button&lt;/a&gt; to erase the screen, and of course a &lt;a href="http://nwazet.com/netduinogo"&gt;Netduino Go&lt;/a&gt;. The hardware setup looks like the following:&lt;img style="background-image: none; border-right-width: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="The hardware setup" border="0" alt="The hardware setup" src="http://weblogs.asp.net/blogs/bleroy/IMG_2546_668A65B6.jpg" width="502" height="336" /&gt;&lt;/p&gt;  &lt;p&gt;We connected the button to port 2 (but it doesn’t matter as there’s only one), the two potentiometers to ports 3 and 4, and the display to port 5.&lt;/p&gt;  &lt;p&gt;We can initialize this setup with the following code: &lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; Potentiometer Vertical = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Potentiometer(GoSockets.Socket3);&lt;br /&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; Potentiometer Horizontal = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Potentiometer(GoSockets.Socket4);&lt;br /&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; Button Button = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Button();&lt;br /&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; VirtualCanvas Canvas = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; VirtualCanvas();&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;To initialize the display, I wrote this method, which initializes a VirtualCanvas object on socket 5, sets the orientation of the display to landscape, fills the screen with white and flushes the command buffer:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; InitCanvas() {&lt;br /&gt;    Canvas.Initialize(GoSockets.Socket5);&lt;br /&gt;    Canvas.SetOrientation(Orientation.Landscape);&lt;br /&gt;    Canvas.DrawFill(white);&lt;br /&gt;    Canvas.Execute();&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The VirtualCanvas object can be seen as the driver for the display. It’s a simple vector API, but a crucial point is that these vector drawing primitives are not executed on the Netduino. Instead, they are serialized, sent to the display and executed there. This keeps communication between the microcontroller and the screen to a minimum, and frees the Netduino main board computing power. Essentially, you have a graphics coprocessor bundled with that screen. This is also why you need to call Execute when you want a command batch to be sent to the display and drawn.&lt;/p&gt;

&lt;p&gt;To do the actual drawing, all we need is to read the values from both potentiometers and convert them into screen coordinates:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; ReadY() {&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)(Vertical.GetValue() * Canvas.Height);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; ReadX() {&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)(Horizontal.GetValue() * Canvas.Width);&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;And then render that on the screen:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;Canvas.DrawLine(currentX, currentY, x, y, black);&lt;br /&gt;Canvas.Execute();&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;I’m using DrawLine here and not DrawPixel so that the drawing looks continuous even if the potentiometers are rotated very fast. This requires remembering the previous coordinates, which is fairly simple to do.&lt;/p&gt;

&lt;p&gt;All this is pretty easy really. You can see it in action in the following video. To keep things exciting, I threw in some debugging and live command drawing…&lt;/p&gt;
&lt;iframe height="284" src="http://www.youtube.com/embed/6UM0SKuvSYw" frameborder="0" width="500" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;

&lt;p&gt;The source code for this can be downloaded here: 
  &lt;br /&gt;&lt;a title="http://weblogs.asp.net/blogs/bleroy/Telecran.zip" href="http://weblogs.asp.net/blogs/bleroy/Telecran.zip"&gt;http://weblogs.asp.net/blogs/bleroy/Telecran.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;All parts used in this demo can be purchased from &lt;a href="http://nwazet.com/products"&gt;Nwazet&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8428664" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/ExI5QDz8EQs" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Netduino/default.aspx">Netduino</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Electronics/default.aspx">Electronics</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Nwazet/default.aspx">Nwazet</category></item><item><title>Electronics for developers with Netduino Go</title><link>http://weblogs.asp.net/bleroy/archive/2012/04/20/electronics-for-developers-with-netduino-go.aspx</link><pubDate>Fri, 20 Apr 2012 22:59:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8399438</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8399438</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/04/20/electronics-for-developers-with-netduino-go.aspx#comments</comments><description>&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 8px 6px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="Nwazet" border="0" alt="Nwazet" align="right" src="http://weblogs.asp.net/blogs/bleroy/NwazetIcon_0A9FF64F.png" width="182" height="182" /&gt;Wouldn’t it be great if you could build your own stuff? Microcontrollers let you do that, but they usually require dealing with a lot of complexity and unknowns. If you’re a software developer, chances are you don’t really know how to use a capacitor, or how a transistor works, even though it is at the heart of all computers.&lt;/p&gt;  &lt;p&gt;Well there is a way now to develop awesome hardware projects without knowledge of electronics, just by connecting modules together. &lt;a href="http://netduino.com/netduinogo"&gt;Netduino Go&lt;/a&gt; is a platform that allows for that without constraining the types of projects you can build. Today the number of available modules is still limited (the platform was released only this month), but it is expected to grow fast.&lt;/p&gt;  &lt;p&gt;In this post, I’ll introduce you to the platform, with the assumption that you know programming but not electronics.&lt;/p&gt;  &lt;p&gt;So let’s get started. What you need to follow along this post is the following:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;A &lt;a href="http://nwazet.com/netduinogo"&gt;Netduino Go&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;A &lt;a href="http://nwazet.com/potentiometer"&gt;potentiometer module&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;A &lt;a href="http://nwazet.com/rgb-led-module"&gt;RGB LED module&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;A version of Visual Studio (&lt;a href="http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express#2010-Visual-CS"&gt;C# Express&lt;/a&gt; is enough)&lt;!--EndFragment--&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://netmf.codeplex.com/releases/view/82448#DownloadId=343358"&gt;The .NET Micro Framework 4.2&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;The Netduino SDK for &lt;a href="http://www.netduino.com/downloads/netduinosdk_64bit_NETMF42.exe"&gt;64-bit&lt;/a&gt; or &lt;a href="http://www.netduino.com/downloads/netduinosdk_32bit_NETMF42.exe"&gt;32-bit&lt;/a&gt; depending on your version of Windows &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;First we’ll create a new project, selecting the Netduino Go Application project type:&lt;img style="background-image: none; border-right-width: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="New Project -&amp;gt; Netduino Go" border="0" alt="New Project -&amp;gt; Netduino Go" src="http://weblogs.asp.net/blogs/bleroy/image_1799D660.png" width="502" height="286" /&gt;&lt;/p&gt;  &lt;p&gt;This creates a new project with references to assemblies managing the .NET Micro Framework, the Go Bus and the Netduino’s ports:&lt;img style="background-image: none; border-right-width: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Assemblies included" border="0" alt="Assemblies included" src="http://weblogs.asp.net/blogs/bleroy/image_62FC0AD5.png" width="287" height="332" /&gt;&lt;/p&gt;  &lt;p&gt;We still need to add specific support for the two modules we’re going to use, the RGB LED and the Potentiometer. For that, let’s right-click on References and add the two assemblies we need:&lt;img style="background-image: none; border-right-width: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Adding reference to module assemblies" border="0" alt="Adding reference to module assemblies" src="http://weblogs.asp.net/blogs/bleroy/image_451D86D4.png" width="506" height="410" /&gt;&lt;/p&gt;  &lt;p&gt;Once that is done, we can start creating objects representing our modules:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; NetduinoGo;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; FirstStepsWithNetduinoGo {&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Program {&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Main() {&lt;br /&gt;            var led = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RgbLed();&lt;br /&gt;            var pot = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Potentiometer();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This code works without specifying a port because Netduino Go knows to take the first module it finds that identifies as the right module type. Each constructor has an overload that takes a GoSockets enumeration so we could have written:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; SecretLabs.NETMF.Hardware.NetduinoGo;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; NetduinoGo;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; FirstStepsWithNetduinoGo {&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Program {&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Main() {&lt;br /&gt;            var led = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RgbLed(GoSockets.Socket2);&lt;br /&gt;            var pot = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Potentiometer(GoSockets.Socket1);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;

  &lt;p&gt;We now have objects representing our module, but we still need to do something with them. Let’s start by turning on that LED. But before we do, let’s review our hardware setup:&lt;img style="background-image: none; border-right-width: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Our hardware setup" border="0" alt="Our hardware setup" src="http://weblogs.asp.net/blogs/bleroy/image_723273A2.png" width="402" height="488" /&gt;&lt;/p&gt;

  &lt;p&gt;The potentiometer is connected to socket #1 on the Netduino, and the RGB LED is on socket #2. Now we need to connect a micro-USB cable between the computer and the Go. This will both power the whole thing and give us the channel we need to deploy and debug our code. The first time you do that, it will also install the driver for the Go on your computer.&lt;/p&gt;

  &lt;p&gt;Let’s code:&lt;/p&gt;

  &lt;div id="codeSnippetWrapper"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;led.SetColor(255, 212, 42);&lt;/pre&gt;
  &lt;/div&gt;

  &lt;p&gt;In order to deploy that code, we need first to make sure that the project properties are set to deploy on USB:&lt;img style="background-image: none; border-right-width: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Make sure Transport is USB in project properties" border="0" alt="Make sure Transport is USB in project properties" src="http://weblogs.asp.net/blogs/bleroy/image_715F2F1A.png" width="502" height="307" /&gt;&lt;/p&gt;

  &lt;p&gt;Once this is done, we can hit F5 and see that LED turn on…&lt;/p&gt;

  &lt;p&gt;And… You should have gone blind by now. That LED is incredibly bright. Our next step is going to add some code so that the potentiometer can control the intensity of that light:&lt;/p&gt;

  &lt;div id="codeSnippetWrapper"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;var led = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RgbLed();&lt;br /&gt;var pot = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Potentiometer();&lt;br /&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; red = 255, green = 212, blue = 42;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;while&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;) {&lt;br /&gt;    var intensity = pot.GetValue();&lt;br /&gt;    led.SetColor(&lt;br /&gt;        (&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;)(red * intensity),&lt;br /&gt;        (&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;)(green * intensity),&lt;br /&gt;        (&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;)(blue * intensity));&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
  &lt;/div&gt;

  &lt;p&gt;Deploying this code gives the following result:
    &lt;iframe width="448" height="258" src="http://www.youtube.com/embed/67D-MVzaj7A" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/p&gt;

  &lt;p&gt;And of course, this is visual Studio, so we have full debugging support, as can be seen in the video.&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;And that’s it for today. This should get you started with Netduino Go. And we didn’t have to solder anything… Next time, we’ll play with a touch screen.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8399438" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/IUK5wSL5QJQ" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Screencast/default.aspx">Screencast</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Netduino/default.aspx">Netduino</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Electronics/default.aspx">Electronics</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Nwazet/default.aspx">Nwazet</category></item><item><title>Overriding the Pager rendering in Orchard</title><link>http://weblogs.asp.net/bleroy/archive/2012/03/30/overriding-the-pager-rendering-in-orchard.aspx</link><pubDate>Sat, 31 Mar 2012 04:41:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8371144</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8371144</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/03/30/overriding-the-pager-rendering-in-orchard.aspx#comments</comments><description>&lt;p&gt;The Pager shape that is used in Orchard to render pagination is one of those shapes that are built in code rather than in a Razor template. This can make it a little more confusing to override, but nothing is impossible.&lt;/p&gt;  &lt;p&gt;If we look at the Pager method in CoreShapes, here is what we see:   &lt;pre class="csharpcode"&gt;[Shape]
&lt;span class="kwrd"&gt;public&lt;/span&gt; IHtmlString Pager(dynamic Shape, dynamic Display) {
    Shape.Metadata.Alternates.Clear(); 
    Shape.Metadata.Type = &lt;span class="str"&gt;&amp;quot;Pager_Links&amp;quot;&lt;/span&gt;;
    &lt;span class="kwrd"&gt;return&lt;/span&gt; Display(Shape);
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;The Shape attribute signals a shape method. All it does is remove all alternates that may exist and replace the type of the shape with “Pager_Links”. In turn, this shape method is rather large and complicated, but it renders as a set of smaller shapes: a List with a “pager” class, and under that Pager_First, Pager_Previous, Pager_Gap, for each page a Pager_Link or a Pager_Current, then Pager_Gap, Pager_Next and Pager_Last.&lt;/p&gt;

&lt;p&gt;Each of these shapes can be displayed or not depending on the properties of the pager. Each can also be overridden with a Razor template. This can be done by dropping a file into the Views folder of your theme. For example, if you want the current page to appear between square braces, you could drop this Pager-CurrentPage.cshtml into your views folder:
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;span&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;[@Model.Value]&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;span&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;This overrides the original shape method, which was this:
  &lt;pre class="csharpcode"&gt;[Shape]
&lt;span class="kwrd"&gt;public&lt;/span&gt; IHtmlString Pager_CurrentPage(HtmlHelper Html, dynamic Display,
    &lt;span class="kwrd"&gt;object&lt;/span&gt; Value) {
    var tagBuilder = &lt;span class="kwrd"&gt;new&lt;/span&gt; TagBuilder(&lt;span class="str"&gt;&amp;quot;span&amp;quot;&lt;/span&gt;);
    tagBuilder.InnerHtml = Html.Encode(Value &lt;span class="kwrd"&gt;is&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ?
        (&lt;span class="kwrd"&gt;string&lt;/span&gt;)Value : Display(Value));
            
    &lt;span class="kwrd"&gt;return&lt;/span&gt; MvcHtmlString.Create(tagBuilder.ToString());
}&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;And here is what it would look like:&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="An overridden current page template" border="0" alt="An overridden current page template" src="http://weblogs.asp.net/blogs/bleroy/image_0177CBBE.png" width="131" height="22" /&gt;&lt;/p&gt;

&lt;p&gt;Now what if we want to completely hide the pager if there is only one page? Well, the easiest way to do that is to override the Pager shape by dropping the following into the Views folder of your theme:
  &lt;pre class="csharpcode"&gt;@{
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (Model.TotalItemCount &amp;gt; Model.PageSize) {
        Model.Metadata.Alternates.Clear();
        Model.Metadata.Type = &lt;span class="str"&gt;&amp;quot;Pager_Links&amp;quot;&lt;/span&gt;;
        @Display(Model)
    }
}&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;And that’s it. The code in this template just adds a check for the number of items to display (in a template, Model is the shape) and only displays the Pager_Links shape if it knows that there’s going to be more than one page.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8371144" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/iBNnr01tg-s" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>ZenGallery: a minimalist image gallery for Orchard</title><link>http://weblogs.asp.net/bleroy/archive/2012/03/30/zengallery-a-minimalist-image-gallery-for-orchard.aspx</link><pubDate>Sat, 31 Mar 2012 04:13:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8371112</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8371112</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/03/30/zengallery-a-minimalist-image-gallery-for-orchard.aspx#comments</comments><description>&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px 8px 8px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="The gallery, added to a commerce site" border="0" alt="The gallery, added to a commerce site" align="left" src="http://weblogs.asp.net/blogs/bleroy/image_2CDE4C8E.png" width="244" height="171" /&gt;There are &lt;a href="http://gallery.orchardproject.net/List/Modules/Orchard.Module.FlickrGallery"&gt;quite&lt;/a&gt; &lt;a href="http://gallery.orchardproject.net/List/Modules/Orchard.Module.PrettyGallery"&gt;a&lt;/a&gt; &lt;a href="http://gallery.orchardproject.net/List/Modules/Orchard.Module.Mello.ImageGallery"&gt;few&lt;/a&gt; &lt;a href="http://gallery.orchardproject.net/List/Modules/Orchard.Module.Alexan.PhotoAlbums"&gt;image&lt;/a&gt; &lt;a href="http://gallery.orchardproject.net/List/Search?packageType=Modules&amp;amp;searchCategory=All+Categories&amp;amp;searchTerm=gallery&amp;amp;sortOrder=package-title&amp;amp;pageSize=10"&gt;gallery modules&lt;/a&gt; for Orchard but &lt;strike&gt;they were not invented here&lt;/strike&gt; I wanted something a lot less sophisticated that would be as barebones and minimalist as possible out of the box, to make customization extremely easy. So I made this, in less than two days (during which I got distracted a lot).&lt;/p&gt;  &lt;p&gt;&lt;a href="https://gallery.orchardproject.net/List/Modules/Orchard.Module.Nwazet.ZenGallery/"&gt;Nwazet.ZenGallery&lt;/a&gt; uses existing Orchard features as much as it can:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Galleries are just a content part that can be added to any type&lt;/li&gt;    &lt;li&gt;The set of photos in a gallery is simply defined by a folder in Media&lt;/li&gt;    &lt;li&gt;Managing the images in a gallery is done using the standard media management from Orchard&lt;/li&gt;    &lt;li&gt;Ordering of photos is simply alphabetical order of the filenames (use 1_, 2_, etc. prefixes if you have to)&lt;/li&gt;    &lt;li&gt;The path to the gallery folder is mapped from the content item using a token-based pattern&lt;/li&gt;    &lt;li&gt;The pattern can be set per content type&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Setting the pattern" border="0" alt="Setting the pattern" src="http://weblogs.asp.net/blogs/bleroy/Gallery5_36C33DF9.png" width="302" height="171" /&gt;&lt;/li&gt;    &lt;li&gt;You can edit the generated gallery path for each item&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Editing the path" border="0" alt="Editing the path" src="http://weblogs.asp.net/blogs/bleroy/Gallery4_7BFB9522.png" width="382" height="228" /&gt;&lt;/li&gt;    &lt;li&gt;The default template is just a list of links over images, that get open in a new tab&lt;/li&gt;    &lt;li&gt;No lightbox script comes with the module, just customize the template to use your favorite script.&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Using a lightbox script" border="0" alt="Using a lightbox script" src="http://weblogs.asp.net/blogs/bleroy/Gallery1_7403F2C0.png" width="382" height="281" /&gt;&lt;/li&gt;    &lt;li&gt;Light, light, light.&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="The gallery displays thumbnails in admin summary view" border="0" alt="The gallery displays thumbnails in admin summary view" src="http://weblogs.asp.net/blogs/bleroy/Gallery3_6BA01D69.png" width="402" height="287" /&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Rather than explaining in more details this very simple module, here is a video that shows how I used the module to add photo galleries to a product catalog:   &lt;div style="padding-bottom: 8px; margin: 0px auto; padding-left: 0px; width: 448px; padding-right: 0px; display: block; float: none; padding-top: 8px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:6b67b1b5-1428-4603-98c1-ebd65190dd96" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;object width="448" height="252"&gt;&lt;param name="movie" value="http://www.youtube.com/v/06_OI8QnBZg?hl=en&amp;amp;hd=1"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/06_OI8QnBZg?hl=en&amp;amp;hd=1" type="application/x-shockwave-flash" width="448" height="252"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;div style="width:448px;clear:both;font-size:.8em"&gt;Adding a gallery to a product catalog&lt;/div&gt;&lt;/div&gt; &lt;/p&gt;  &lt;p&gt;You can find the module on the Orchard Gallery:   &lt;br /&gt;&lt;a title="https://gallery.orchardproject.net/List/Modules/Orchard.Module.Nwazet.ZenGallery/" href="https://gallery.orchardproject.net/List/Modules/Orchard.Module.Nwazet.ZenGallery/"&gt;https://gallery.orchardproject.net/List/Modules/Orchard.Module.Nwazet.ZenGallery/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The source code is available from BitBucket:   &lt;br /&gt;&lt;a title="https://bitbucket.org/bleroy/nwazet.zengallery" href="https://bitbucket.org/bleroy/nwazet.zengallery"&gt;https://bitbucket.org/bleroy/nwazet.zengallery&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8371112" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/gNM4ri39kUk" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/HTML/default.aspx">HTML</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>Drawing transparent glyphs on the HTML canvas</title><link>http://weblogs.asp.net/bleroy/archive/2012/03/16/drawing-transparent-glyphs-on-the-html-canvas.aspx</link><pubDate>Sat, 17 Mar 2012 06:38:59 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8352020</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8352020</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/03/16/drawing-transparent-glyphs-on-the-html-canvas.aspx#comments</comments><description>&lt;p&gt;The HTML canvas has a set of methods, createImageData and putImageData, that look like they will enable you to draw transparent shapes pixel by pixel. The data structures that you manipulate with these methods are pseudo-arrays of pixels, with four bytes per pixel. One byte for red, one for green, one for blue and one for alpha. This alpha byte makes one believe that you are going to be able to manage transparency, but that’s a lie.&lt;/p&gt;  &lt;p&gt;Here is a little script that attempts to overlay a simple generated pattern on top of a uniform background:   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;var&lt;/span&gt; wrong = document.getElementById(&lt;span class="str"&gt;&amp;quot;wrong&amp;quot;&lt;/span&gt;).getContext(&lt;span class="str"&gt;&amp;quot;2d&amp;quot;&lt;/span&gt;);
wrong.fillStyle = &lt;span class="str"&gt;&amp;quot;#ffd42a&amp;quot;&lt;/span&gt;;
wrong.fillRect(0, 0, 64, 64);
&lt;span class="kwrd"&gt;var&lt;/span&gt; overlay = wrong.createImageData(32, 32),
    data = overlay.data;
fill(data);
wrong.putImageData(overlay, 16, 16);&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;where the fill method is setting the pixels in the lower-left half of the overlay to opaque red, and the rest to transparent black.&lt;/p&gt;

&lt;p&gt;And here’s how it renders:&lt;a href="http://weblogs.asp.net/blogs/bleroy/image_63B90709.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="putImageData replaces existing pixels" border="0" alt="putImageData replaces existing pixels" src="http://weblogs.asp.net/blogs/bleroy/image_thumb_70B2E71A.png" width="66" height="66" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the transparency byte was completely ignored. Or was it? in fact, what happens is more subtle. What happens is that the pixels from the image data, including their alpha byte, replaced the existing pixels of the canvas. So the alpha byte is not lost, it’s just that it wasn’t used by putImageData to combine the new pixels with the existing ones.&lt;/p&gt;

&lt;p&gt;This is in fact a clue to how to write a putImageData that works: we can first dump that image data into an intermediary canvas, and then compose that temporary canvas onto our main canvas. The method that we can use for this composition is drawImage, which works not only with image objects, but also with canvas objects.
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;var&lt;/span&gt; right = document.getElementById(&lt;span class="str"&gt;&amp;quot;right&amp;quot;&lt;/span&gt;).getContext(&lt;span class="str"&gt;&amp;quot;2d&amp;quot;&lt;/span&gt;);
right.fillStyle = &lt;span class="str"&gt;&amp;quot;#ffd42a&amp;quot;&lt;/span&gt;;
right.fillRect(0, 0, 64, 64);
&lt;span class="kwrd"&gt;var&lt;/span&gt; overlay = wrong.createImageData(32, 32),
    data = overlay.data;
fill(data);
&lt;span class="kwrd"&gt;var&lt;/span&gt; overlayCanvas = document.createElement(&lt;span class="str"&gt;&amp;quot;canvas&amp;quot;&lt;/span&gt;);
overlayCanvas.width = overlayCanvas.height = 32;
overlayCanvas.getContext(&lt;span class="str"&gt;&amp;quot;2d&amp;quot;&lt;/span&gt;).putImageData(overlay, 0, 0);
right.drawImage(overlayCanvas, 16, 16);&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;And there is is, a version of putImageData that works like it should always have:&lt;a href="http://weblogs.asp.net/blogs/bleroy/image_684F11C3.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 8px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Using an intermediary canvas gets the transparency right" border="0" alt="Using an intermediary canvas gets the transparency right" src="http://weblogs.asp.net/blogs/bleroy/image_thumb_636C5E07.png" width="66" height="66" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8352020" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/Wgy1w-0kyHQ" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/HTML/default.aspx">HTML</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/canvas/default.aspx">canvas</category></item><item><title>My Orchard comment notification rule</title><link>http://weblogs.asp.net/bleroy/archive/2012/03/01/my-orchard-comment-notification-rule.aspx</link><pubDate>Fri, 02 Mar 2012 06:02:53 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8321516</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>7</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8321516</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/03/01/my-orchard-comment-notification-rule.aspx#comments</comments><description>&lt;p&gt;The Rules module in Orchard enable you to set-up “if this then that” types of rules. The system is fully extensible in terms of what “this” and “that” are of course, but Orchard comes with everything you need out of the box to set-up comment notifications. Let’s create this rule:&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 10px auto 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Comment notification rule" border="0" alt="Comment notification rule" src="http://weblogs.asp.net/blogs/bleroy/image_3B207D94.png" width="311" height="370" /&gt;&lt;/p&gt;  &lt;p&gt;Before you begin, you need to make sure you have the rules features installed and enabled.&lt;/p&gt;  &lt;p&gt;For comment notifications, “this” is: “when content with type comment is published”, and “that is: “send an e-mail”.&lt;/p&gt;  &lt;p&gt;In order to reproduce this, create a new rule named “Content Notification”. Add an event, choose “Content Published” and select “Comment” as the published type:&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 10px auto 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Choose the Comment type" border="0" alt="Choose the Comment type" src="http://weblogs.asp.net/blogs/bleroy/image_0C5AC4F2.png" width="232" height="262" /&gt;&lt;/p&gt;  &lt;p&gt;Now we will add a “Send e-mail action”. As the recipient of the e-mail, I usually set “Site Admin”, but many people will want the mail to be sent to the owner of the blog. To get that result, you can select “Other” with the following pattern:   &lt;pre class="csharpcode"&gt;{Content.CommentedOn.Container.Author}&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;As the subject of the e-mail, I use this pattern:
  &lt;pre class="csharpcode"&gt;nwazet.com: A new comment has been posted by {Content.CommentAuthor}&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;Finally, as the body, I use the following:
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;New comment by {Content.CommentAuthor} on {Content.CommentedOn.DisplayText}&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;{Content.CommentMessage}&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;a&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://nwazet.com/admin/comments&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Moderate&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;a&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;Once you’ve saved all that, don’t forget to enable the new rule, and you should now get an e-mail every time someone posts a comment. Oh, one last thig: you need e-mail settings to be correctly set-up for this to work, naturally.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8321516" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/Bu_DWnO9ZAw" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>Leaving the Evil Empire</title><link>http://weblogs.asp.net/bleroy/archive/2012/02/29/leaving-the-evil-empire.aspx</link><pubDate>Thu, 01 Mar 2012 06:14:40 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8320535</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>29</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8320535</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/02/29/leaving-the-evil-empire.aspx#comments</comments><description>&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px 10px 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="Crossing a bridge" border="0" alt="Crossing a bridge" align="left" src="http://weblogs.asp.net/blogs/bleroy/image_7D715978.png" width="244" height="164" /&gt;TL;DR: I’m leaving Microsoft to found &lt;a href="http://nwazet.com/"&gt;my own company&lt;/a&gt;. My involvement in Orchard continues unchanged.&lt;/p&gt;  &lt;p&gt;It’s been almost nine years. Nine years at Microsoft, first as a developer, and then as a program manager. I’ve worked on ASP.NET versions 2.0 to 4.0, ASP.NET Ajax, Ajax Control Toolkit, then on integrating jQuery into the Microsoft developer’s toolbox, and of course, on Orchard. I’ve made mistakes, errors of judgment, but I like to think I’ve learned a lot along the way, that my blog has helped many who were learning or struggling with the technology, and that I’ve built a few really cool things.&lt;/p&gt;  &lt;p&gt;Most of all, I’ve changed.&lt;/p&gt;  &lt;p&gt;When I got hired by Scott Guthrie &lt;em&gt;et al.&lt;/em&gt;, Microsoft was for me the Mecca of software development, the place where the amazing, superbly integrated software that I loved was made. I thought ASP.NET was the best group at Microsoft, and the most innovative. It was the zenith of my career. So I thought. During those nine years, I saw how the sausage was made, and I understood that innovation was and should be less centralized, and that open-source and community-driven software was a lot more exciting and promising than anything that a single actor could come up with, no matter how big it was. Maybe &lt;em&gt;because&lt;/em&gt; it was so big.&lt;/p&gt;  &lt;p&gt;At the same time, the world changed.&lt;/p&gt;  &lt;p&gt;Almost all sectors of human activity have started to move away from a hierarchical, top-down model, to a distributed one. It takes the form of open source, of peer-to-peer, or of social networks.&lt;/p&gt;  &lt;p&gt;I have a conviction that this is only the beginning of a profound change in our societies, that innovation is considerably more likely to occur in cooperative networks of small structures than in large competing corporations.&lt;/p&gt;  &lt;p&gt;All this, plus a number of ideas that I can’t possibly develop at Microsoft, led me to the decision to quit my job and to found &lt;a href="http://nwazet.com"&gt;my own company&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;So what does this mean for Orchard?&lt;/p&gt;  &lt;p&gt;Not much. Let me explain what Orchard means to me. Before Microsoft hired me, I had spent two years building a CMS on ASP.NET, that was very targeted at rationalizing our web site development business. I knew at the time that most web sites are first and foremost content-driven. In the ASP.NET team, the focus was very different: the technology was built for business applications, not really web sites. From the start, I advocated for an approach that gave contents a more prominent place, ideally through a new content-centric framework. Eventually, others came to similar conclusions from different starting points, and the time became right for Orchard to begin. I jumped in enthusiastically.&lt;/p&gt;  &lt;p&gt;In other words, Orchard is something I’ve wanted to do for a very long time, and I care about it very much. We still have a lot of work to do on the platform, and I’m going to be a part of that.&lt;/p&gt;  &lt;p&gt;Orchard is also one of the first projects started by Microsoft to make such a full transition to a community-driven project. From our beginnings where 100% of the code was produced by a team of a dozen Microsoft employees, we are now able to produce amazing releases such as &lt;a href="http://orchard.codeplex.com/releases/view/74491"&gt;Orchard 1.4&lt;/a&gt; with only two full-time employees, because the community has stepped in to produce the new features. Governance of the project has been transferred to an elected steering committee.&lt;/p&gt;  &lt;p&gt;For me to leave Microsoft and become a part of this community only makes sense.&lt;/p&gt;  &lt;p&gt;My new company, &lt;a href="http://nwazet.com/"&gt;Nwazet&lt;/a&gt;, is focused on Open Source software and hardware. The hardware part won’t surprise you much if you’re a regular reader of this blog. With my business partner and friend &lt;a href="http://fabienroyer.wordpress.com/"&gt;Fabien Royer&lt;/a&gt;, we’re in the process of building amazing new products around &lt;a href="http://netduino.com/"&gt;Netduino&lt;/a&gt; microcontrollers.&lt;/p&gt;  &lt;p&gt;And… That’s about it. I’m very excited about this change. If you or your company need help on Orchard projects, custom electronics or both, &lt;a href="http://nwazet.com/contact"&gt;hire us&lt;/a&gt;!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8320535" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/ajhFbsy-ERM" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Open+Source/default.aspx">Open Source</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Nwazet/default.aspx">Nwazet</category></item><item><title>More than one driver for a single Orchard part</title><link>http://weblogs.asp.net/bleroy/archive/2012/02/23/more-than-one-driver-for-a-single-orchard-part.aspx</link><pubDate>Fri, 24 Feb 2012 07:01:10 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8310393</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8310393</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/02/23/more-than-one-driver-for-a-single-orchard-part.aspx#comments</comments><description>&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 6px 10px 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="This picture has nothing to do with the post. Haack won&amp;#39;t like it, so be it." border="0" alt="This picture has nothing to do with the post. Haack won&amp;#39;t like it, so be it." align="left" src="http://weblogs.asp.net/blogs/bleroy/image_79FF8D68.png" width="244" height="163" /&gt;Drivers in Orchard are responsible for taking content parts and using them to generate shapes for the rendering engine to transform into HTML. A little known fact is that there can be more than one driver for any given part. You might be wondering what this can be used for: one shape per part seems like a reasonable assumption.&lt;/p&gt;  &lt;p&gt;I’ll show one case where this ability to add a driver to the one that already exists came in really handy.&lt;/p&gt;  &lt;p&gt;One of the sites I’m working on is making heavy use of taxonomies. The customer wanted to add management screens for the order of terms in any given taxonomy, that had some interesting specific features. We wanted a couple of links to that additional screen right inside the existing UI for a taxonomy field. I could have created a new part, but it would have never made sense unless a TermPart was already present. Orchard is so extensible in fact that extensions are extensible, so in a completely separate module from the original taxonomies, I created a new ContentPartDriver&amp;lt;TermPart&amp;gt;:&lt;/p&gt;  &lt;p&gt;   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; DriverResult Editor(TermPart part, dynamic shapeHelper) {
    &lt;span class="kwrd"&gt;return&lt;/span&gt; ContentShape(&lt;span class="str"&gt;&amp;quot;Parts_Taxonomies_Term_OrderLink&amp;quot;&lt;/span&gt;,
            () =&amp;gt; shapeHelper.EditorTemplate(
                TemplateName: &lt;span class="str"&gt;&amp;quot;Parts/Taxonomies.Term.OrderLink&amp;quot;&lt;/span&gt;,
                Model: part,
                Prefix: Prefix));
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;Both drivers will run, and they will both emit their own shape. Each of those shapes can in turn be moved around using placement.info. This driver and the template to render the new shape is all I had to write. Here is the end result:&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="The new links inside the term editor" border="0" alt="The new links inside the term editor" src="http://weblogs.asp.net/blogs/bleroy/image_4A616EDC.png" width="280" height="85" /&gt;&lt;/p&gt;

&lt;p&gt;This is a pretty nifty way to enrich existing admin UI for any content type, don’t you think?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8310393" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/Kh6e4WtR6fI" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>About Orchard Governance and Microsoft</title><link>http://weblogs.asp.net/bleroy/archive/2012/01/30/about-orchard-governance-and-microsoft.aspx</link><pubDate>Mon, 30 Jan 2012 08:29:03 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8271858</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>26</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8271858</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/01/30/about-orchard-governance-and-microsoft.aspx#comments</comments><description>&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px 10px 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="Sunrise on a volcano" border="0" alt="Sunrise on a volcano" align="left" src="http://weblogs.asp.net/blogs/bleroy/image_78FD3DF4.png" width="244" height="163" /&gt;Back in September, we did something with Orchard that is kind of a big deal: we transferred control over the Orchard project to the community.&lt;/p&gt;  &lt;p&gt;Most Open Source projects that were initiated by corporations such as Microsoft are nowadays still governed by that corporation. They may have an open license, they may take patches and contributions, they may have given the copyright to some non-profit foundation, but for all practical purposes, it’s still that corporation that controls the project and makes the big decisions.&lt;/p&gt;  &lt;p&gt;That wasn’t what we wanted for Orchard. We wanted to trust the community completely to do what’s best for the project. This is why we organized elections for our new Steering Committee and had five members elected. Anyone who had ever posted anything on our forums that wasn’t spam could be a candidate, and had five votes to cast.&lt;/p&gt;  &lt;p&gt;We got 9 candidates, and after a week of vote casting, we had our committee elected (see &lt;a href="http://orchard.codeplex.com/discussions/271355"&gt;http://orchard.codeplex.com/discussions/271355&lt;/a&gt; for the details of the vote). Our five members are elected for a year and they each get a vote in any major decision. Two out of those five are Microsoft employees, which means the company doesn’t even have a majority (even though I have a veto right that I never used, as the elected “benevolent dictator” of the group). We &lt;a href="http://groups.google.com/group/orchard-gov/msg/de5de4b164bb5cd3?hl=en"&gt;have public online meetings every week&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The committee’s role is to give the project’s strategic direction, and to decide what feature areas are going to be in the next releases. It is not to make technical decisions or build the product (more on that in a moment). The weekly meetings are used to give status on current development, do bug triage and make decisions as needed.&lt;/p&gt;  &lt;p&gt;This was not just the right thing to do. It did have a very visible impact on the involvement of non-Microsoft developers. Shortly after the election, we started calling for teams to form around our 1.4 release’s features. Feature teams are being given a feature scope by the committee, and they are then free to make their own decisions on technical design. They regularly interact with the committee, which gets to decide when the features make it into the main branch.&lt;/p&gt;  &lt;p&gt;This was quite successful as we are preparing to launch what will be the first release of Orchard where entire features have been written by the community. In fact, 3 out of 4 of the new feature areas of 1.4 have been written mostly by non-Microsoft developers.&lt;/p&gt;  &lt;p&gt;To my knowledge, this makes Orchard the most open of all Microsoft-initiated Open Source projects. It now belongs entirely to the community, and absolutely everything is not only done publicly but also in a way where community participation is actively sought after and encouraged.&lt;/p&gt;  &lt;p&gt;My hope is that as the project becomes more and more successful, our model gets copied by other corporate-initiated projects, at Microsoft and elsewhere. I would love to hear your thoughts, dear readers, on this.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8271858" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/sfM3qUwpMdQ" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Open+Source/default.aspx">Open Source</category></item><item><title>What’s the deal with Orchard and NuGet? Does Orchard suck?</title><link>http://weblogs.asp.net/bleroy/archive/2011/12/06/what-s-the-deal-with-orchard-and-nuget-does-orchard-suck.aspx</link><pubDate>Wed, 07 Dec 2011 02:34:02 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8096759</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>16</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8096759</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2011/12/06/what-s-the-deal-with-orchard-and-nuget-does-orchard-suck.aspx#comments</comments><description>&lt;p&gt;Damn, &lt;a href="http://wekeroad.com"&gt;Rob&lt;/a&gt; saw right through &lt;a href="http://haacked.com/archive/2011/12/05/nuget_org_update.aspx"&gt;the PR lies of Phil Haack&lt;/a&gt; about &lt;a href="http://nuget.org/"&gt;the new NuGet gallery&lt;/a&gt; and figured it all out. Kidding, kidding. For your enjoyment and context, here is Rob’s post:    &lt;br /&gt;&lt;a href="http://wekeroad.com/2011/12/06/nuget-and-orchard/"&gt;http://wekeroad.com/2011/12/06/nuget-and-orchard/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Phil made a thoughtful answer to the post where he gives the rationale behind the decision:   &lt;br /&gt;&lt;a title="http://wekeroad.com/2011/12/06/nuget-and-orchard/#comment-380571113" href="http://wekeroad.com/2011/12/06/nuget-and-orchard/#comment-380571113"&gt;http://wekeroad.com/2011/12/06/nuget-and-orchard/#comment-380571113&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;What I want to address here is what that means (or not) about Orchard.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;“Why wasn’t it fast before?”&lt;/strong&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Because by default, back when the NuGet gallery was first built, Orchard was grossly under optimized. We made a lot of progress, but it still is under optimized out of the box --in a number of ways-- which is why we’re having this discussion for the 1.4 release:   &lt;br /&gt;&lt;a href="http://orchard.codeplex.com/discussions/274921"&gt;http://orchard.codeplex.com/discussions/274921&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;One thing you cannot accuse the Orchard team of is premature optimization… But seriously, there are options available today: installing &lt;a href="http://gallery.orchardproject.net/List/Modules/Orchard.Module.Contrib.Cache"&gt;the cache module&lt;/a&gt;, or &lt;a href="http://gallery.orchardproject.net/List/Modules/Orchard.Module.Piedone.Combinator"&gt;the combinator module&lt;/a&gt;. Or custom, in-site optimizations.&lt;/p&gt;  &lt;p&gt;So could the NuGet team have optimized its gallery instead of mobilizing several engineers over a few months to rewrite it? Sure they could have, but it so happened that they didn’t, for &lt;a href="http://wekeroad.com/2011/12/06/nuget-and-orchard/#comment-380571113"&gt;reasons Phil explained better than I could&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;As a matter of facts, &lt;a href="http://gallery.orchardproject.net/"&gt;our own gallery site&lt;/a&gt;, which just passed the million-download mark, still uses that same codebase that NuGet was using before. The new NuGet gallery doesn’t display total download stats (because the home page is now static html) but I believe it’s around 3 million so we’re looking at a similar scale here. Just visit &lt;a href="http://gallery.orchardproject.net/"&gt;http://gallery.orchardproject.net/&lt;/a&gt; and you’ll see that it’s performing quite well. So what’s the deal here?&lt;/p&gt;  &lt;p&gt;Well, we did spend the time to apply a few optimizations:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;We &lt;strong&gt;profiled the code&lt;/strong&gt; and &lt;strong&gt;fixed&lt;/strong&gt; the biggest &lt;strong&gt;bottlenecks&lt;/strong&gt;. Those fixes, of course, now benefit all Orchard users.&lt;/li&gt;    &lt;li&gt;We &lt;strong&gt;profiled the database&lt;/strong&gt; queries (using &lt;a href="http://ayende.com/blog/"&gt;Ayende&lt;/a&gt;’s excellent &lt;a href="http://www.nhprof.com/"&gt;NHProf&lt;/a&gt;) and optimized the biggest offenders.&lt;/li&gt;    &lt;li&gt;We activated &lt;strong&gt;output caching&lt;/strong&gt;.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;All optimizations that NuGet never saw applied. And well, see for yourself, it’s not too bad. We’re not quite done, there is a whole lot more we can and will do, with what limited resources we have (hint: a lot less than NuGet).&lt;/p&gt;  &lt;p&gt;We’re not the only ones: more and more big sites are going online with Orchard, with good performance.&lt;/p&gt;  &lt;p&gt;But Rob also says something interesting and expresses a perception that I’ve seen many times:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;“I’ve deployed Big CMS’s before as a solution for clients and every single time we decided to move away. They’re great for getting off the ground – but after a while there’s just too much friction.”&lt;/strong&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;That is true of some CMS, but not all. In the case of Drupal or Orchard (not what Rob used, I checked), my own experience and that of many others is that because the content model is factored at precisely the right level of abstraction, it’s actually sometimes harder to get off the ground, but &lt;strong&gt;the friction diminishes over time&lt;/strong&gt;. Where a more traditional application requires you to pile functionality on a relatively monolithic data model, modern CMS allow you to add functionality in a completely decoupled and unobtrusive way that puts the composition exactly where it needs to happen, somewhere between individual properties and full types.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8096759" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/G_U5ig5xt6U" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/NuGet/default.aspx">NuGet</category></item><item><title>Source-controlled database backups</title><link>http://weblogs.asp.net/bleroy/archive/2011/12/04/source-controlled-database-backups.aspx</link><pubDate>Mon, 05 Dec 2011 01:31:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8091856</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>8</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8091856</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2011/12/04/source-controlled-database-backups.aspx#comments</comments><description>&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 6px 0px 10px 10px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="This is in beautiful Kauai in case you were wondering" border="0" alt="This is in beautiful Kauai in case you were wondering" align="right" src="http://weblogs.asp.net/blogs/bleroy/image_6B574C9E.png" width="244" height="164" /&gt;I’m not very satisfied with traditional database backup solutions. It seems like almost no progress was made since SQL Server 6.5 (at least for the built-in tools). They are still outputting monolithic binary backup files that only do the job if the only thing you expect from backups is the ability to recover from catastrophic failures. I expect more, but before I explain, we need a disclaimer:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;I am no expert of database backup and may very well miss some crucial points or some aspects of the current state of the art. The solution exposed in this post is the result of my own experiments and has no pretense at exhaustiveness or even reliability. It’s something I use on my own simple projects, and no more. Database backups are serious business and your data is valuable. Use this at your own risk.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;What I wanted from my database backup solution can be summarized as follows:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Works on Azure databases (can you believe that as I’m writing this there is no valid built-in backup solution on Azure?) &lt;/li&gt;    &lt;li&gt;Backups are not stored in the same place as the database &lt;/li&gt;    &lt;li&gt;Has more than one state to rollback to &lt;/li&gt;    &lt;li&gt;Can be automated &lt;/li&gt;    &lt;li&gt;Easy to restore &lt;/li&gt;    &lt;li&gt;Can make diffs between backup states &lt;/li&gt;    &lt;li&gt;Can merge backup states &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The last two, diffs and backups, can seem a little peculiar and require some explanation. I work on several Orchard projects, where a team of developers collaborate. The team is virtual, with people in the US, and in various places in Europe. Because Orchard is a CMS, the database contains more than just data: it also stores the configuration of the site, something that developers modify as part of their routine job. Since it is impractical to work off a central database because of latency, and also because one developer can break everyone’s instance with a bad change, we need multiple copies of the database, and a way to reconcile them.&lt;/p&gt;  &lt;p&gt;What works in a distributed fashion, resolves conflicts, and stores history? Why, a Distributed Version Control System of course! This is what gave me the idea of storing my database backups in a private repository on BitBucket, using Mercurial as the DVCS.&lt;/p&gt;  &lt;p&gt;In order to be able to do diffs and merges, we need a text-based persistence format. I chose to use &lt;a href="http://msdn.microsoft.com/en-us/library/ms162802.aspx"&gt;the bcp command-line utility&lt;/a&gt; to emit that format because my past experience of it has been that it’s fast and reliable. The code could in principle use &lt;a href="http://msdn.microsoft.com/en-us/library/1y8tb169.aspx"&gt;the bulk copy SQL commands&lt;/a&gt;, but having never worked with them I went for bcp. If someone wants to modify the code and make a pull request using bulk copy that’s fine by me. Bcp produces flat text files for each table that are very easy to diff and merge.&lt;/p&gt;  &lt;p&gt;My solution, HgDBackup, comes with two command-lines that automate bcp, one for backup and one for restore. HgDBackup.exe enumerates the tables in the database and spits out one text file per table. HgDRestore.exe enumerates the tables, tries to find a text file with the same name, and if found, drops all rows in the table before importing the contents of the file into the table.&lt;/p&gt;  &lt;p&gt;The schema of the database is not backed up, so you need to do that as a separate operation every time it changes, or as a separate automated task.&lt;/p&gt;  &lt;p&gt;In the distributed development environment I described above, the process to take a new version of the database will be as follows:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;execute HgDBackup &lt;/li&gt;    &lt;li&gt;commit local changes &lt;/li&gt;    &lt;li&gt;pull and update from the repository &lt;/li&gt;    &lt;li&gt;execute HgDRestore &lt;/li&gt;    &lt;li&gt;run tests &lt;/li&gt;    &lt;li&gt;commit if a merge was necessary &lt;/li&gt;    &lt;li&gt;push to repository &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Both commands have built-in help that you can bring up with hgdbackup /? or hgdrestore /?.&lt;/p&gt;  &lt;p&gt;The backup command responds to the following flags:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;/Server or /S: the address of the server to backup (e.g. tcp:myazuredb.database.windows.net or .\SQLExpress) &lt;/li&gt;    &lt;li&gt;/Database or /D: the name of the database to backup (e.g. Orchard) &lt;/li&gt;    &lt;li&gt;/User or /U: user name to use on the database &lt;/li&gt;    &lt;li&gt;/Password or /P: password to use on the database &lt;/li&gt;    &lt;li&gt;/Output or /O: output directory where the tables will be dumped (e.g. C:\backup) &lt;/li&gt;    &lt;li&gt;/Template or /T: connection string template &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The restore command responds to the same flags, except that Output is replaced with Input.&lt;/p&gt;  &lt;p&gt;The default connection string pattern is SQLExpress with integrated security (so no password has to be on the command-line).&lt;/p&gt;  &lt;p&gt;For example, here is what I use to backup one of my Azure databases: &lt;/p&gt;  &lt;pre class="csharpcode"&gt;HgDBackup.exe&lt;br /&gt;  /S:tcp:something.database.windows.net /D:Orchard&lt;br /&gt;  /U:mysubscription@weirdstuff /P:**********&lt;br /&gt;  /O:C:\Projects\nwazet.Backup\Tables&lt;br /&gt;  /T:Server={0},1433;Database={1};User={2};Password={3};&lt;br /&gt;     Trusted_Connection=False;Encrypt=True;&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;And here is what I use to import that backup into my local SQLExpress instance: &lt;/p&gt;

&lt;pre class="csharpcode"&gt;HgDRestore.exe&lt;br /&gt;  /S:.\SQLExpress /D:Orchard&lt;br /&gt;  /I:C:\Projects\nwazet.backup\Tables&lt;/pre&gt;

&lt;p&gt;That nwazet.backup directory is a clone of a private repository on BitBucket. It’s of course important that the repository is private because databases contain secrets.&lt;/p&gt;

&lt;p&gt;The code is available on BitBucket: 
  &lt;br /&gt;&lt;a href="https://bitbucket.org/bleroy/hgdbackup"&gt;https://bitbucket.org/bleroy/hgdbackup&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may also download the already compiled commands: 
  &lt;br /&gt;&lt;a title="http://weblogs.asp.net/blogs/bleroy/HgDBackup.zip" href="http://weblogs.asp.net/blogs/bleroy/HgDBackup.zip"&gt;http://weblogs.asp.net/blogs/bleroy/HgDBackup.zip&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And remember, use at your own risk…&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8091856" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/0uYwyyEJ9pA" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/SQL/default.aspx">SQL</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Mercurial/default.aspx">Mercurial</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Backup/default.aspx">Backup</category></item><item><title>From ScrewTurn Wiki to Markdown</title><link>http://weblogs.asp.net/bleroy/archive/2011/10/25/from-screwturn-wiki-to-markdown.aspx</link><pubDate>Wed, 26 Oct 2011 05:56:03 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8011834</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>8</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8011834</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2011/10/25/from-screwturn-wiki-to-markdown.aspx#comments</comments><description>&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px 0px 6px 10px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://weblogs.asp.net/blogs/bleroy/image_02863050.png" width="244" height="176" /&gt;I'm in the process of moving the Orchard documentation site from ScrewTurn Wiki to a Mercurial + Markdown system, where revisions are managed through source control tools instead of a fully online wiki. We see quite a few advantages in doing that, but that's a story for another post.&lt;/p&gt;  &lt;p&gt;Today, I just want to post on that quick and dirty tool that I've built to translate the ScrewTurn Wiki markup into Markdown. It's not a masterpiece in any way, it's not exhaustive, but I thought it may be useful to others, so here it is…&lt;/p&gt;  &lt;p&gt;&lt;a href="https://bitbucket.org/bleroy/screwturn2markdown/src"&gt;https://bitbucket.org/bleroy/screwturn2markdown/src&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8011834" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/UKGwEHz4avM" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Mercurial/default.aspx">Mercurial</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Markdown/default.aspx">Markdown</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Wiki/default.aspx">Wiki</category></item><item><title>State of .NET Image Resizing: how does imageresizer do?</title><link>http://weblogs.asp.net/bleroy/archive/2011/10/22/state-of-net-image-resizing-how-does-imageresizer-do.aspx</link><pubDate>Sat, 22 Oct 2011 22:18:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8004326</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>28</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8004326</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2011/10/22/state-of-net-image-resizing-how-does-imageresizer-do.aspx#comments</comments><description>&lt;p&gt;&lt;img style="margin: 3px 0px 10px 6px; border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="Thumb" border="0" alt="Thumb" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_0744_178B0514.jpg" width="240" height="160" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_0744_178B0514.jpg"&gt;I've written several times before about image resizing in .NET and how the various built-in solutions (GDI, WPF and WIC) compare in terms of quality, speed and size. I'll put the links to my previous articles at the end of this post for reference.&lt;/p&gt;
  
&lt;p&gt;&lt;img style="margin: 0px 3px 10px 0px; float: left; display: inline;" align="left" src="http://weblogs.asp.net/blogs/bleroy/WorksInMediumTrust_41AE9248.gif" mce_src="http://weblogs.asp.net/blogs/bleroy/WorksInMediumTrust_41AE9248.gif"&gt;Several readers have since pointed me to the &lt;a href="http://imageresizing.net/" mce_href="http://imageresizing.net/"&gt;imageresizer&lt;/a&gt; library, which is pure .NET and thus has no problems running in medium trust. Medium trust is an issue that has plagued existing options, preventing many people from using the best available approach. I was doubtful though that a purely managed library could come anywhere near the native Windows libraries in terms of performance. The best way to find out, of course, is to run a benchmark. Fortunately, I still had the code for my previous benchmarks so I just had to add imageresizer code to it.&lt;/p&gt;
  
&lt;p&gt;I excluded IO from this test by measuring the processing time for each library working on binary streams. This also levels the playing field as some of them start processing while they are reading a file, making it harder to separate file reading overhead from image processing. By working with streams, the comparison is more meaningful. The timing code is wrapped around only the meaningful code.&lt;/p&gt;
  
&lt;p&gt;The first problem that I hit with imageresizer is that it has a strong dependency on System.Web. This is really unfortunate and very probably unjustified. The library should be split between the pure image processing bits, which should have no System.Web dependency, and the request handling and caching bits, which can depend on System.Web all they want.&lt;/p&gt;
  
&lt;p&gt;Since I'm mostly interested in web applications, I changed my command-line code into an ASP.NET Pages application, which probably saved me some configuration headache. The code is linked to at the end of this post. One thing I have to say is that the API feels good, natural and reasonably concise, a nice change when compared with the noisy Interop-like code we had to write before. It's nice to have something that is native .NET rather than a thin layer on top of Windows APIs that stink of C.   
&lt;pre class="csharpcode"&gt;var settings = &lt;span class="kwrd"&gt;new&lt;/span&gt; ResizeSettings {
    MaxWidth = thumbnailSize,
    MaxHeight = thumbnailSize,
    Format = &lt;span class="str"&gt;"jpg"&lt;/span&gt;
};
settings.Add(&lt;span class="str"&gt;"quality"&lt;/span&gt;, quality.ToString());
ImageBuilder.Current.Build(inStream, outStream, settings);
resized = outStream.ToArray();&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;I really liked that I don't have to do size calculations myself, and I can just give it a square or rectangle inside of which it has to fit. You have many options to customize that. It's unfortunate that the quality setting has to be set this way instead of being promoted to a 1st class property like other settings but I can live with it. Notice how the library can work with streams, which is very important for web apps. One thing I really didn't like though was that some APIs, such as Build, take untyped object parameters and then decide internally at runtime what to do with them. Why the author didn't use strongly-typed overloads here is a mystery to me.&lt;/p&gt;

&lt;p&gt;So how does imageresizer do then? Well, mostly as expected. In terms of size, I found it to be a little greedier than its peers, but really nothing dramatic:&lt;img style="margin: 10px auto; border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: none; display: block; background-image: none;" title="Size of resized images against jpg quality" border="0" alt="Size of resized images against jpg quality" src="http://weblogs.asp.net/blogs/bleroy/image_16B29F2A.png" width="481" height="289" mce_src="http://weblogs.asp.net/blogs/bleroy/image_16B29F2A.png"&gt;&lt;/p&gt;

&lt;p&gt;The quality of the images is where imageresizer shines. See for yourself (quality 85% for those images):&lt;/p&gt;

&lt;p&gt;
  
&lt;table border="0" cellSpacing="10" cellPadding="2" width="144"&gt;&lt;tbody&gt;
      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;
          
&lt;p align="center"&gt;&lt;strong&gt;imageresizer&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;
          
&lt;p align="center"&gt;&lt;strong&gt;WIC&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="Copenhagen_85" border="0" alt="Copenhagen_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/Copenhagen_85_19E48712.jpg" width="150" height="112" mce_src="http://weblogs.asp.net/blogs/bleroy/Copenhagen_85_19E48712.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="Copenhagen_85" border="0" alt="Copenhagen_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/Copenhagen_85_0E4EC9D3.jpg" width="150" height="112" mce_src="http://weblogs.asp.net/blogs/bleroy/Copenhagen_85_0E4EC9D3.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2300_85" border="0" alt="IMG_2300_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2300_85_58D607AD.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2300_85_58D607AD.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2300_85" border="0" alt="IMG_2300_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2300_85_740E60AE.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2300_85_740E60AE.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2305_85" border="0" alt="IMG_2305_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2305_85_4C67E484.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2305_85_4C67E484.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2305_85" border="0" alt="IMG_2305_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2305_85_24C1685A.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2305_85_24C1685A.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2317_85" border="0" alt="IMG_2317_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2317_85_7D1AEC2F.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2317_85_7D1AEC2F.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2317_85" border="0" alt="IMG_2317_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2317_85_6A65F278.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2317_85_6A65F278.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2325_85" border="0" alt="IMG_2325_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2325_85_14D22396.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2325_85_14D22396.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2325_85" border="0" alt="IMG_2325_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2325_85_021D29DF.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2325_85_021D29DF.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2351_85" border="0" alt="IMG_2351_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2351_85_6F683027.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2351_85_6F683027.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2351_85" border="0" alt="IMG_2351_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2351_85_19D46145.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2351_85_19D46145.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2443_85" border="0" alt="IMG_2443_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2443_85_201B37D3.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2443_85_201B37D3.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2443_85" border="0" alt="IMG_2443_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2443_85_0D663E1C.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2443_85_0D663E1C.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2445_85" border="0" alt="IMG_2445_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2445_85_65BFC1F1.jpg" width="150" height="103" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2445_85_65BFC1F1.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2445_85" border="0" alt="IMG_2445_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2445_85_5715160C.jpg" width="150" height="103" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2445_85_5715160C.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2446_85" border="0" alt="IMG_2446_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2446_85_44601C55.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2446_85_44601C55.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2446_85" border="0" alt="IMG_2446_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2446_85_1CB9A02B.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2446_85_1CB9A02B.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2525_85" border="0" alt="IMG_2525_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2525_85_0A04A674.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2525_85_0A04A674.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2525_85" border="0" alt="IMG_2525_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2525_85_4D6CA7D6.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2525_85_4D6CA7D6.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="IMG_2565_85" border="0" alt="IMG_2565_85" src="http://weblogs.asp.net/blogs/bleroy/IMG_2565_85_01A0D11D.jpg" width="100" height="150" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2565_85_01A0D11D.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: none; display: block; background-image: none;" title="IMG_2565_85" border="0" alt="IMG_2565_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2565_85_2C0D023A.jpg" width="100" height="150" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2565_85_2C0D023A.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;

      
&lt;tr&gt;
        
&lt;td vAlign="top" width="81"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: none; display: block; background-image: none;" title="IMG_2734_85" border="0" alt="IMG_2734_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2734_85_3253D8C8.jpg" width="150" height="100" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2734_85_3253D8C8.jpg"&gt;&lt;/td&gt;

        
&lt;td vAlign="top" width="31"&gt;&lt;img style="border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;" title="IMG_2734_85" border="0" alt="IMG_2734_85" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2734_85_187FA299.jpg" width="150" height="99" mce_src="http://weblogs.asp.net/blogs/bleroy/IMG_2734_85_187FA299.jpg"&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;


&lt;p&gt;The images look sharper (in particular the hummingbird one), and a little bit more saturated. Because of that, some moiré effects seem more visible (the shot before last makes that the most obvious. Still, the resizing is overall the best I've seen so far.&lt;/p&gt;

&lt;p&gt;Now of course, while managed code is usually quite fast, image processing is heavy in the sort of operation where native code has a definitive advantage. That is reflected in the results I got in terms of processing speed:&lt;img style="margin: 10px auto; border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: none; display: block; background-image: none;" title="Time to resize against quality" border="0" alt="Time to resize against quality" src="http://weblogs.asp.net/blogs/bleroy/image_1EC67927.png" width="545" height="289" mce_src="http://weblogs.asp.net/blogs/bleroy/image_1EC67927.png"&gt;&lt;/p&gt;














&lt;p&gt;Imageresizer is clearly the slowest. That was expected, but now we know by how much. It is &lt;strong&gt;31% slower than GDI&lt;/strong&gt; (I excluded the 50 quality point here), and almost &lt;strong&gt;4 times slower than WIC&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Of course, unless your application is doing lots and lots of resizing operations, speed may not be that important, in particular if you are doing appropriate disk caching. Imageresizer shines in that department by making disk caching super-easy. The library, after all, is very web centric and tries hard to do everything right for the web scenarios. We should not underestimate &lt;a href="http://nathanaeljones.com/163/20-image-resizing-pitfalls/" mce_href="http://nathanaeljones.com/163/20-image-resizing-pitfalls/"&gt;how hard it is to get web image resizing right&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That leaves us with the unfortunate conclusion that we still don't have an image resizing silver bullet. I'll try to summarize all that we know in a table that will hopefully help you make a decision in the context of your specific application:&lt;/p&gt;

&lt;table border="1" cellSpacing="0" cellPadding="2" width="500"&gt;&lt;tbody&gt;
    
&lt;tr&gt;
      
&lt;td vAlign="top" width="100"&gt;&amp;nbsp;&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;&lt;strong&gt;Imageresizer&lt;/strong&gt;&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;&lt;strong&gt;WIC&lt;/strong&gt;&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;&lt;strong&gt;WPF&lt;/strong&gt;&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;&lt;strong&gt;GDI&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;

    
&lt;tr&gt;
      
&lt;td vAlign="top" width="100"&gt;Speed&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;*&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;****&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;****&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;**&lt;/td&gt;
    &lt;/tr&gt;

    
&lt;tr&gt;
      
&lt;td vAlign="top" width="100"&gt;Quality&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;*****&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;****&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;****&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;***&lt;/td&gt;
    &lt;/tr&gt;

    
&lt;tr&gt;
      
&lt;td vAlign="top" width="100"&gt;Medium trust&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;Yes&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;No&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;No&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;Yes&lt;/td&gt;
    &lt;/tr&gt;

    
&lt;tr&gt;
      
&lt;td vAlign="top" width="100"&gt;Supported&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;By author&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;By MS&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;No&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;No&lt;/td&gt;
    &lt;/tr&gt;

    
&lt;tr&gt;
      
&lt;td vAlign="top" width="100"&gt;.NET friendly&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;****&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;*&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;****&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;***&lt;/td&gt;
    &lt;/tr&gt;

    
&lt;tr&gt;
      
&lt;td vAlign="top" width="100"&gt;Web centric&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;Yes&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;No&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;No&lt;/td&gt;

      
&lt;td vAlign="top" width="100"&gt;No&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;Benchmark code:
    &lt;br&gt;&lt;/strong&gt;&lt;a title="http://weblogs.asp.net/blogs/bleroy/ImageResizeBenchmark.zip" href="http://weblogs.asp.net/blogs/bleroy/ImageResizeBenchmark.zip" mce_href="http://weblogs.asp.net/blogs/bleroy/ImageResizeBenchmark.zip"&gt;http://weblogs.asp.net/blogs/bleroy/ImageResizeBenchmark.zip&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Results&lt;/strong&gt;:
  &lt;br&gt;&lt;a title="http://weblogs.asp.net/blogs/bleroy/ImageResizerBenchResults.zip" href="http://weblogs.asp.net/blogs/bleroy/ImageResizerBenchResults.zip" mce_href="http://weblogs.asp.net/blogs/bleroy/ImageResizerBenchResults.zip"&gt;http://weblogs.asp.net/blogs/bleroy/ImageResizerBenchResults.zip&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Previous articles:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  
&lt;li&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2010/05/03/the-fastest-way-to-resize-images-from-asp-net-and-it-s-more-supported-ish.aspx" mce_href="http://weblogs.asp.net/bleroy/archive/2010/05/03/the-fastest-way-to-resize-images-from-asp-net-and-it-s-more-supported-ish.aspx"&gt;The fastest way to resize images from ASP.NET. And it’s (more) supported-ish&lt;/a&gt;&lt;/li&gt;

  
&lt;li&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2010/01/21/server-side-resizing-with-wpf-now-with-jpg.aspx" mce_href="http://weblogs.asp.net/bleroy/archive/2010/01/21/server-side-resizing-with-wpf-now-with-jpg.aspx"&gt;Server-side resizing with WPF: now with JPG&lt;/a&gt;&lt;/li&gt;

  
&lt;li&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2009/12/10/resizing-images-from-the-server-using-wpf-wic-instead-of-gdi.aspx" mce_href="http://weblogs.asp.net/bleroy/archive/2009/12/10/resizing-images-from-the-server-using-wpf-wic-instead-of-gdi.aspx"&gt;Resizing images from the server using WPF/WIC instead of GDI+&lt;/a&gt;&lt;/li&gt;

  
&lt;li&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2007/12/05/what-interpolationmode-and-compositingquality-to-use-when-generating-thumbnails-via-system-drawing.aspx" mce_href="http://weblogs.asp.net/bleroy/archive/2007/12/05/what-interpolationmode-and-compositingquality-to-use-when-generating-thumbnails-via-system-drawing.aspx"&gt;What InterpolationMode and CompositingQuality to use when generating thumbnails via System.Drawing&lt;/a&gt;&lt;/li&gt;

  
&lt;li&gt;&lt;a href="http://dotnetslackers.com/articles/aspnet/Generating-Image-Thumbnails-in-ASP-NET.aspx" mce_href="http://dotnetslackers.com/articles/aspnet/Generating-Image-Thumbnails-in-ASP-NET.aspx"&gt;Generating image thumbnails in ASP.NET&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The imageresizer library:&lt;/strong&gt;
  &lt;br&gt;&lt;a href="http://imageresizing.net/" mce_href="http://imageresizing.net/"&gt;http://imageresizing.net/&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8004326" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/tlvKQldHA6w" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Windows+Imaging+Components/default.aspx">Windows Imaging Components</category></item><item><title>So what's new in Orchard 1.3?</title><link>http://weblogs.asp.net/bleroy/archive/2011/10/04/so-what-s-new-in-orchard-1-3.aspx</link><pubDate>Wed, 05 Oct 2011 00:52:22 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7979598</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>14</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=7979598</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2011/10/04/so-what-s-new-in-orchard-1-3.aspx#comments</comments><description>&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px 0px 10px 10px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="A reptile" border="0" alt="A reptile" align="right" src="http://weblogs.asp.net/blogs/bleroy/image_160F1F80.png" width="164" height="244" /&gt;Orchard 1.3 was released yesterday night with some really neat features that I will outline in this post. I will come back in depth on some of those with full-length posts. Let's start with the simple but super-useful ones…&lt;/p&gt;  &lt;h4&gt;1. Draft Preview&lt;/h4&gt;  &lt;p&gt;Once you've created and saved a content item, there will now be a &amp;quot;Preview&amp;quot; link next to its summary:&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px auto 10px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="The new preview link" border="0" alt="The new preview link" src="http://weblogs.asp.net/blogs/bleroy/image_3183FBB6.png" width="502" height="50" /&gt;&lt;/p&gt;  &lt;p&gt;Previously, it was impossible to view unpublished contents. This was one of the most requested missing features, and there it is.&lt;/p&gt;  &lt;h4&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px 0px 10px 10px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="You can now delete content types and parts" border="0" alt="You can now delete content types and parts" align="right" src="http://weblogs.asp.net/blogs/bleroy/image_1090890F.png" width="152" height="134" /&gt;2. Delete Content Types and Parts&lt;/h4&gt;  &lt;p&gt;Speaking about features high on the wish list, you can now delete the custom content types and parts that you built.&lt;/p&gt;  &lt;h4&gt;3. Markdown&lt;/h4&gt;  &lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px 10px 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="The Body part can now use Markdown" border="0" alt="The Body part can now use Markdown" align="left" src="http://weblogs.asp.net/blogs/bleroy/image_2FD32FE2.png" width="201" height="115" /&gt;Not everyone likes editing contents in Wysywyg editors, for various reasons. There has always been the possibility in Orchard of switching the flavor of the Body part, but the only available alternative to the default &amp;quot;html&amp;quot; so far has been &amp;quot;text&amp;quot;, which was only giving you a plain text box. Now there is a new option, &amp;quot;markdown&amp;quot;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Markdown"&gt;Markdown&lt;/a&gt; is a neat text syntax that has the advantage of being simple, rich and human-readable.&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px auto 10px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="The Markdown editor" border="0" alt="The Markdown editor" src="http://weblogs.asp.net/blogs/bleroy/image_0898E6AD.png" width="502" height="304" /&gt;&lt;/p&gt;  &lt;p&gt;I especially like the code sample convention of starting a line with four spaces. Very handy for writing documentation. Oh, about that, did I mention that we are planning on switching the Orchard documentation from the current wiki to Markdown?&lt;/p&gt;        &lt;h4&gt;4. Title Part&lt;/h4&gt;  &lt;p&gt;Until now, the title of Orchard content items has been kept in the Route part. That was an inconvenience when you wanted to give a title to a content type that did not have a vocation to have its own URL, for example widgets.&lt;/p&gt;  &lt;p&gt;Title is still there in the Route part, but what we did is introduce a new interface, ITitleAspect, that the Route part implements.   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; ITitleAspect : IContent {
    &lt;span class="kwrd"&gt;string&lt;/span&gt; Title { get; }
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;In all the places where we were using the old title, we are now using the interface instead. If you need to add a title, but not a URL to your own content types, you can either make one of your parts implements ITitleAspect, or you can add the new Title part, that already implements the interface in a ready to use form.&lt;/p&gt;

&lt;h4&gt;5. Rules&lt;/h4&gt;

&lt;p&gt;Rules are a truly wonderful feature that enables you to add event-driven behavior to your site from the admin UI. Let's create for example a new &amp;quot;Comment Notification&amp;quot; rule and add a &amp;quot;content created&amp;quot; event that we'll configure to be triggered on the Comment content type:&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/bleroy/image_478A6748.png" width="152" height="205" /&gt;&lt;/p&gt;

&lt;p&gt;Once this is done, we can add an action to be triggered when that event fires. We'll choose &amp;quot;Send e-mail&amp;quot;, which will raise the following form, where we can specify who will receive the e-mail, and what will be the subject and body:&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Sending e-mail on comment submission" border="0" alt="Sending e-mail on comment submission" src="http://weblogs.asp.net/blogs/bleroy/image_64B00F52.png" width="252" height="158" /&gt;&lt;/p&gt;

&lt;p&gt;The subject and body of the e-mail can use tokens, which are another new feature that I'll get to in a minute.&lt;/p&gt;

&lt;p&gt;Here is how the content creation event was wired in a handler:
  &lt;pre class="csharpcode"&gt;OnCreated&amp;lt;ContentPart&amp;gt;(
  (context, part) =&amp;gt;
    rulesManager.TriggerEvent(&lt;span class="str"&gt;&amp;quot;Content&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Created&amp;quot;&lt;/span&gt;,
    () =&amp;gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt; { { &lt;span class="str"&gt;&amp;quot;Content&amp;quot;&lt;/span&gt;, context.ContentItem } }));&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;When a piece of content is created, an event is triggered on the rules manager, giving it the content item being created as the context. The event itself is implemented in a class that implements IEventProvider. I'll write more on creating your own events in a future post.&lt;/p&gt;

&lt;p&gt;Actions are classes that implement IActionProvider. Both event and action providers can expose their own UI forms for their configuration, which brings us to the next feature…&lt;/p&gt;

&lt;h4&gt;6. Forms&lt;/h4&gt;

&lt;p&gt;So far, to expose admin UI, a module writer had to create controllers or drivers, view models and views. Starting with this release, they can use a much easier forms API. This is what rule events and actions are using to expose their UI. The forms API makes it possible to describe a form in a nice, compact and extensible form that is using, you guessed it, dynamic shapes.
  &lt;pre class="csharpcode"&gt;Shape.Form(
    Id: &lt;span class="str"&gt;&amp;quot;ActionEmail&amp;quot;&lt;/span&gt;,
    _Type: Shape.SelectList(
        Id: &lt;span class="str"&gt;&amp;quot;Recipient&amp;quot;&lt;/span&gt;, Name: &lt;span class="str"&gt;&amp;quot;Recipient&amp;quot;&lt;/span&gt;,
        Title: T(&lt;span class="str"&gt;&amp;quot;Send to&amp;quot;&lt;/span&gt;),
        Description: T(&lt;span class="str"&gt;&amp;quot;Select who should be the recipient of this e-mail.&amp;quot;&lt;/span&gt;))
        .Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; SelectListItem { Value = &lt;span class="str"&gt;&amp;quot;owner&amp;quot;&lt;/span&gt;, Text = T(&lt;span class="str"&gt;&amp;quot;Owner&amp;quot;&lt;/span&gt;).Text })
        .Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; SelectListItem { Value = &lt;span class="str"&gt;&amp;quot;author&amp;quot;&lt;/span&gt;, Text = T(&lt;span class="str"&gt;&amp;quot;Author&amp;quot;&lt;/span&gt;).Text })
        .Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; SelectListItem { Value = &lt;span class="str"&gt;&amp;quot;admin&amp;quot;&lt;/span&gt;, Text = T(&lt;span class="str"&gt;&amp;quot;Site Admin&amp;quot;&lt;/span&gt;).Text }),
    _Subject: Shape.Textbox(
        Id: &lt;span class="str"&gt;&amp;quot;Subject&amp;quot;&lt;/span&gt;, Name: &lt;span class="str"&gt;&amp;quot;Subject&amp;quot;&lt;/span&gt;,
        Title: T(&lt;span class="str"&gt;&amp;quot;Subject&amp;quot;&lt;/span&gt;),
        Description: T(&lt;span class="str"&gt;&amp;quot;The subject of the e-mail.&amp;quot;&lt;/span&gt;),
        Classes: &lt;span class="kwrd"&gt;new&lt;/span&gt;[] { &lt;span class="str"&gt;&amp;quot;large&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;text&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;tokenized&amp;quot;&lt;/span&gt; }),
    _Message: Shape.Textarea(
        Id: &lt;span class="str"&gt;&amp;quot;Body&amp;quot;&lt;/span&gt;, Name: &lt;span class="str"&gt;&amp;quot;Body&amp;quot;&lt;/span&gt;,
        Title: T(&lt;span class="str"&gt;&amp;quot;Body&amp;quot;&lt;/span&gt;),
        Description: T(&lt;span class="str"&gt;&amp;quot;The body of the e-mail.&amp;quot;&lt;/span&gt;),
        Classes: &lt;span class="kwrd"&gt;new&lt;/span&gt;[] { &lt;span class="str"&gt;&amp;quot;tokenized&amp;quot;&lt;/span&gt; }
        )
    );&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;What you see here is the form that is in the e-mail action picture above. Of course, each of the shapes in there will be rendered by a template that can be overridden (as usual). The advantage of such a description is that it can be enriched dynamically. A comments form for example could have a captcha inserted dynamically by another module, just by injecting a new shape in the form. I encourage you to dive into existing implementations to understand how you can use this new API, until we get the chance to write some good documentation.&lt;/p&gt;

&lt;h4&gt;7. Tokens&lt;/h4&gt;

&lt;p&gt;Tokens are system-wide variables whose values can vary depending on the context. They can be used in a variety of places, one of which is rules, as you can see from the example above (the subject of the e-mail that is sent when new comments are added uses a token to describe the name of the commenter). I've blogged about tokens before, so I encourage you to read these posts to know more:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2011/07/22/future-orchard-part-1-introducing-tokens.aspx"&gt;http://weblogs.asp.net/bleroy/archive/2011/07/22/future-orchard-part-1-introducing-tokens.aspx&lt;/a&gt;

  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2011/07/27/future-orchard-part-2-more-tokens.aspx"&gt;http://weblogs.asp.net/bleroy/archive/2011/07/27/future-orchard-part-2-more-tokens.aspx&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;8. New Content Manager Methods&lt;/h4&gt;

&lt;p&gt;Building contents by composing small parts is an extremely flexible approach, but it makes it more difficult to build efficient database queries. There is always caching, but we also needed to optimize things a bit. We did that by adding some new methods to the content manager, such as GetMany, which is taking multiple content ids in one query. We also added the Aggregate attribute that can be used to specify records that should be eagerly loaded. For example, the Tags property of the TagsPartRecord and the TagRecord property of ContentTagRecord are marked with the attribute, because when the tags are included with a content item, you don't want the act of actually getting the tags associated with the content item to be lazily executed (that is a SELECT N+1 condition). If you want the tag part, there is a very high chance that you'll want to actually access the tags themselves: the part in itself has nothing else of interest. With the attribute, the tags will be fetched at the same time and from the same query as the item itself.&lt;/p&gt;

&lt;h4&gt;9. The rest&lt;/h4&gt;

&lt;p&gt;There is a lot more in this release, such as RSS for lists (it's just there, not much to say about it), some localization improvements, the task lease API that enables better synchronization across web farms, and many, many bug fixes and performance improvements (in particular, if you use multi-tenancy, you should feel the difference). If you want to see everything that was fixed, take a look at the list on CodePlex:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://orchard.codeplex.com/workitem/list/advanced?keyword=&amp;amp;status=Closed&amp;amp;type=All&amp;amp;priority=All&amp;amp;release=Orchard%201.3&amp;amp;assignedTo=All&amp;amp;component=All&amp;amp;sortField=Votes&amp;amp;sortDirection=Descending&amp;amp;page=0"&gt;http://orchard.codeplex.com/workitem/list/advanced?keyword=&amp;amp;status=Closed&amp;amp;type=All&amp;amp;priority=All&amp;amp;release=Orchard%201.3&amp;amp;assignedTo=All&amp;amp;component=All&amp;amp;sortField=Votes&amp;amp;sortDirection=Descending&amp;amp;page=0&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;What's next?&lt;/h4&gt;

&lt;p&gt;The current plan for the near future is to quickly release a 1.4 version with the focus on the new Projector feature that will enable you to query your contents in any way you want directly from the admin UI. This, I can assure you, is going to be a killer feature.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7979598" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/Kjt0k-Nx6wk" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>PIX-6T4, the DIY console, has an Orchard site</title><link>http://weblogs.asp.net/bleroy/archive/2011/09/17/pix-6t4-the-diy-console-has-an-orchard-site.aspx</link><pubDate>Sun, 18 Sep 2011 05:54:29 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7956740</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=7956740</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2011/09/17/pix-6t4-the-diy-console-has-an-orchard-site.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.pix6T4.com"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 6px 10px 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="PIX-6T4" border="0" alt="PIX-6T4" align="left" src="http://fabienroyer.files.wordpress.com/2011/09/pix-6t4-logo.gif?w=205&amp;amp;h=185" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you're a regular reader of this blog, you may have noticed the electronics posts lately. With my friend &lt;a href="http://fabienroyer.wordpress.com/"&gt;Fabien&lt;/a&gt;, we've been building a little handheld console from readily available parts. It's also programmable in C#, using &lt;a href="http://netduinohelpers.codeplex.com/"&gt;a library that we built&lt;/a&gt;. It's great fun really. Our plan is to build a kit and a book out of it, to help people learn the basics of digital electronics and C# programming.&lt;/p&gt;  &lt;p&gt;We've built a site for the project over a few nights last week, using &lt;a href="http://orchardproject.net/"&gt;Orchard&lt;/a&gt; and hosting on &lt;a href="https://windows.azure.com/"&gt;Azure&lt;/a&gt;. I thought I'd throw in a little return on experience and talk about the modules we used.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.pix6t4.com"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px 0px 10px 10px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="The PIX-6T4 site" border="0" alt="The PIX-6T4 site" align="right" src="http://weblogs.asp.net/blogs/bleroy/Theme_0500F75A.png" width="250" height="358" /&gt;&lt;/a&gt;The site can be found here: &lt;a href="http://www.pix6t4.com"&gt;http://www.pix6t4.com&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The first thing I did to build the site was to build the theme. I started from the built in Theme Machine, and just added the markup and styles for the header. I then changed the fonts from the stylesheet and layout files, added a few custom styles such as the atomic bullet lists or the round corner menus, some transparency for the body and that was pretty much it. The Theme Machine is extremely flexible and let me get exactly what I wanted without changing much markup at all. Most of the changes are CSS.&lt;/p&gt;  &lt;p&gt;I then packaged and deployed my Azure image onto our Azure instance. We are using multi-tenancy in order to host multiple small sites on a single Azure instance, so I just created a new tenant for our new domain name. After the second or so it took me, I was able to go through setup for the tenant, and pointed the site to the same SQL Azure connection string I'm using for the main tenant, but using a difference table prefix.&lt;/p&gt;  &lt;p&gt;Here are the modules we're currently using (I installed those on my dev machine and added them to the Azure solution so that they get uploaded with the image, as you can't install modules directly on Azure):&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://orchardproject.net/gallery/List/Modules/Orchard.Module.Contrib.GoogleAnalytics"&gt;Google Analytics&lt;/a&gt;: very simple to use, just register the new site on Analytics and copy the provided script into the module's admin page. You are done, Google starts accumulating stats on your site from this moment.&lt;/li&gt;    &lt;li&gt;Content Types: as you add modules to your Orchard site, you will often want to extend existing types with new parts. You need the content types feature for that.&lt;/li&gt;    &lt;li&gt;&lt;a href="http://orchardproject.net/gallery/List/Modules/Orchard.Module.Orchard.ImportExport"&gt;Import Export&lt;/a&gt;: the Azure story for backups is, well, lacking at this point in time. We'll use export to work around this and download the contents of the site on a regular basis. It's not the same as proper automated backups but it's way better than nothing.&lt;/li&gt;    &lt;li&gt;&lt;a href="http://orchardproject.net/gallery/List/Modules/Orchard.Module.Vandelay.Industries"&gt;Vandelay Industries&lt;/a&gt;: well, I built this one. I has several useful features, such as favicon settings, Feedburner, tag clouds, etc.&lt;/li&gt;    &lt;li&gt;&lt;a href="http://orchardproject.net/gallery/List/Modules/Orchard.Module.Contrib.YoutubeField"&gt;YouTube Field&lt;/a&gt;: We added a Youtube field to the page content type, to make it super-easy to add video to our pages. I had to make a couple of modifications to the module (nice that all modules come with source code): I overrode the template so that it uses the iframe YouTube markup rather than object and embed. As a side note, the default markup has a Lady Gaga video hard-coded into the archaic &amp;lt;object&amp;gt; tag. Nobody noticed I suppose because no recent browser uses that nowadays. I also modified the driver so that it only returns a shape if a video has been configured and null otherwise. I will contribute back those changes of course.&lt;/li&gt;    &lt;li&gt;&lt;a href="http://orchardproject.net/gallery/List/Modules/Orchard.Module.CyberStride.Contacts"&gt;Contact Form&lt;/a&gt;: works as advertised. You can create a contact form page, and every time someone fills the form, we'll get an e-mail notification. The module also has a report page where you can see all the contact requests. I did have to fix a bug in the driver to prevent double entries in the database. I will also contribute that change back.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;And well, that is it really. It's a simple site, and it was a simple job to set it up, as it should be. :)&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7956740" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/TalesFromTheEvilEmpire/~4/HGjgQsRQQOo" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Electronics/default.aspx">Electronics</category></item></channel></rss>

