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

<channel>
	<title>Cory Plotts' Blog &#187; WPF</title>
	<atom:link href="http://www.cplotts.com/category/wpf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cplotts.com</link>
	<description>Yet another UX guy, working in WPF/Silverlight.</description>
	<lastBuildDate>Fri, 25 Jun 2010 23:59:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Snoop: There can be only one!</title>
		<link>http://www.cplotts.com/2010/06/25/snoop-there-can-be-only-one/</link>
		<comments>http://www.cplotts.com/2010/06/25/snoop-there-can-be-only-one/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 23:57:23 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Snoop]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/2010/06/25/snoop-there-can-be-only-one/</guid>
		<description><![CDATA[Haven’t I already said that the community has just been awesome in regards to Snoop? Well, here is another piece of evidence! The other day, a developer, Bruno Martinez, from Uruguay contacted me and wanted to contribute to Snoop by making it so that there was only 1 version, instead of the 4 currently required [...]]]></description>
			<content:encoded><![CDATA[<p>Haven’t I already <a href="http://channel9.msdn.com/posts/Psychlist1972/Pete-at-MIX10-Cory-Plotts-on-Snoop-for-WPF/">said</a> that the community has just been awesome in regards to Snoop?</p>
<p>Well, here is another piece of evidence!</p>
<p>The other day, a developer, <a href="http://www.bigmostacho.com/">Bruno Martinez</a>, from Uruguay contacted me and wanted to contribute to Snoop by making it so that there was only 1 version, instead of the 4 currently required at that point.</p>
<p>If you recall …</p>
<ol>
<li>You needed a version for WPF 3.5 and 32-bit.</li>
<li>You needed a version for WPF 3.5 and 64-bit.</li>
<li>You needed a version for WPF 4.0 and 32-bit.</li>
<li>You needed a version for WPF 4.0 and 64-bit.</li>
</ol>
<p>Yuck! <em>Of course, it was better than not being able to Snoop in those situations.</em> <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Well, after integrating Bruno’s changes … you just need:</p>
<ol>
<li>Snoop</li>
</ol>
<p><a href="http://www.cplotts.com/wp-content/uploads/2010/06/SnoopAppChooserNoLabels.png"><img style="display: inline; border: 0px;" title="SnoopAppChooserNoLabels" src="http://www.cplotts.com/wp-content/uploads/2010/06/SnoopAppChooserNoLabels_thumb.png" border="0" alt="SnoopAppChooserNoLabels" width="521" height="29" /></a></p>
<p>Yeah, that’s right. There are no labels! <strong>Thank you, Bruno!</strong></p>
<p>I’m obviously tickled by this … since it was a usability nightmare trying to figure out what version you needed to run … but there are host of other fixes/improvements as well. In particular, the Snoop start-up process is much more robust than it used to be and it can handle some fringe cases that it wasn’t able to before.</p>
<p>Please go to <a href="http://snoopwpf.codeplex.com">http://snoopwpf.codeplex.com</a> for more info, and of course, the download/release area for <a href="http://snoopwpf.codeplex.com/releases/view/47822">version 2.6.0.</a></p>
<p>Happy Snooping!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share/Save</a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2010/06/25/snoop-there-can-be-only-one/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Weird Visual Studio 2008 SP1 IntelliSense Issue Figured Out!</title>
		<link>http://www.cplotts.com/2010/04/23/weird-visual-studio-2008-sp1-intellisense-issue-figured-out/</link>
		<comments>http://www.cplotts.com/2010/04/23/weird-visual-studio-2008-sp1-intellisense-issue-figured-out/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 14:16:31 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[IntelliSense]]></category>
		<category><![CDATA[Issue]]></category>
		<category><![CDATA[VisualStudio2008]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/2010/04/23/weird-visual-studio-2008-sp1-intellisense-issue-figured-out/</guid>
		<description><![CDATA[Ok, I just have to blog about this, because I just figured out an issue that’s been driving me nuts, nuts, nuts. In some xaml files, I had no folding editor … and no IntelliSense! What I discovered was that if I delete the local namespace declaration (and then add it back again), the folding [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, I just have to blog about this, because I just figured out an issue that’s been driving me nuts, nuts, nuts.</p>
<p>In some xaml files, I had no folding editor … and no IntelliSense!</p>
<p>What I discovered was that if I delete the local namespace declaration (and then add it back again), the folding editor starts working again.</p>
<p>Then, I discovered that if I just leave out the local namespace declaration … instead of adding it back, IntelliSense starts working again. Annoying … since I have to remember to put the namespace declaration back before checking it in.</p>
<p>So, I decided to do a search and see if anyone (besides me) had run into this problem. Well, as you all know, the trick to searching for anything on the internet is getting the right search string. Well, I got lucky. This <a href="http://www.google.com/search?sourceid=chrome&amp;ie=UTF-8&amp;q=intellisense+xaml+not+working+local+namespace">search</a> brought me to this blog <a href="http://blog.lab49.com/archives/3384">post</a>.</p>
<p>It wasn’t exactly my problem, but what I found was that if I added an ‘;assembly=’ to my local namespace declaration … everything started working again … and would continue working even if I closed and reopened the file! Woot! <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So, the following xaml doesn’t work:</p>
<pre class="brush: xml;">&lt;my:Inspector
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:my=&quot;clr-namespace:Snoop&quot;
    x:Class=&quot;Snoop.PropertyGrid2&quot;
    x:Name=&quot;PropertyGrid&quot;
    MinHeight=&quot;0&quot;
    MinWidth=&quot;0&quot;
&gt;</pre>
<p>But, the following xaml DOES work:</p>
<pre class="brush: xml;; highlight: [4]">&lt;my:Inspector
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:my=&quot;clr-namespace:Snoop;assembly=&quot;
    x:Class=&quot;Snoop.PropertyGrid2&quot;
    x:Name=&quot;PropertyGrid&quot;
    MinHeight=&quot;0&quot;
    MinWidth=&quot;0&quot;
&gt;</pre>
<p>Hope this helps someone! It has bothered me for some time!</p>
<p>p.s.<br />
Just to clarify: this does not affect Visual Studio 2010. That is, you do not need the &#8216;assembly=&#8217; there &#8230; so this was likely an issue with the xaml editor in Visual Studio 2008.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share/Save</a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2010/04/23/weird-visual-studio-2008-sp1-intellisense-issue-figured-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snoop: Now Supports WPF 4.0</title>
		<link>http://www.cplotts.com/2010/02/14/snoop-now-supports-wpf-4-0/</link>
		<comments>http://www.cplotts.com/2010/02/14/snoop-now-supports-wpf-4-0/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 19:18:59 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Snoop]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/2010/02/14/snoop-now-supports-wpf-4-0/</guid>
		<description><![CDATA[This is just a quick post to point people to the fact that I have updated Snoop on CodePlex (http://snoopwpf.codeplex.com/) such that it now supports WPF 4.0. If you try to Snoop a WPF 4.0 application with the WPF 3.5 version, you will get the following error message: I speculate that this is because there is [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a quick post to point people to the fact that I have updated Snoop on CodePlex (<a title="http://snoopwpf.codeplex.com/" href="http://snoopwpf.codeplex.com/">http://snoopwpf.codeplex.com/</a>) such that it now supports WPF 4.0.</p>
<p>If you try to Snoop a WPF 4.0 application with the WPF 3.5 version, you will get the following error message:</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2010/02/SnoopError.png"><img style="display: inline; border: 0px;" title="SnoopError" src="http://www.cplotts.com/wp-content/uploads/2010/02/SnoopError_thumb.png" border="0" alt="SnoopError" width="435" height="175" /></a></p>
<p>I speculate that this is because there is a brand new CLR with .NET 4.0 (WPF 4.0) applications. Yes, that’s right, a brand new CLR. We haven’t had one of those for a while.</p>
<p>If someone can confirm this or provide a better understanding of why I can’t Snoop WPF 4.0 applications without retargeting Snoop to .NET 4.0 … please shed some light for me.</p>
<p>So, there are now 4, count them, 4 versions of Snoop:</p>
<ol>
<li>Snoop 32-bit for WPF 3.5</li>
<li>Snoop 64-bit for WPF 3.5</li>
<li>Snoop 32-bit for WPF 4.0</li>
<li>Snoop 64-bit for WPF 4.0</li>
</ol>
<ol>You need to use the right version of Snoop in each particular situation … otherwise … thar will be problems, matey!</ol>
<p>I have also added another label to the app chooser so that you know which version you currently have up. Take a look … this is what it looks like for the 64-bit/WPF 4.0 version:</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2010/02/image.png"><img style="display: inline; border: 0px;" title="image" src="http://www.cplotts.com/wp-content/uploads/2010/02/image_thumb.png" border="0" alt="image" width="468" height="30" /></a></p>
<p>Let me know if you have any problems by creating a discussion (or participating in a current one) on the <a href="http://snoopwpf.codeplex.com">http://snoopwpf.codeplex.com</a> site.</p>
<p>Enjoy and happy Snooping! <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share/Save</a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2010/02/14/snoop-now-supports-wpf-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snoop: Now on CodePlex</title>
		<link>http://www.cplotts.com/2010/02/11/snoop-now-on-codeplex/</link>
		<comments>http://www.cplotts.com/2010/02/11/snoop-now-on-codeplex/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 18:25:15 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Snoop]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/2010/02/11/snoop-now-on-codeplex/</guid>
		<description><![CDATA[  Snoop is now on CodePlex at snoopwpf.codeplex.com The community reception to my efforts (blog posts: 1, 2, 3) on Snoop have been wonderful. Some like Anvaka have offered additional feature suggestions; others have just encouraged me. In my last post, a fellow commented asking why it wasn’t up on CodePlex. Well, this was a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cplotts.com/wp-content/uploads/2010/02/CP_banner_111x111_gen.jpg"><img style="display: inline; border: 0px;" title="CP_banner_111x111_gen" src="http://www.cplotts.com/wp-content/uploads/2010/02/CP_banner_111x111_gen_thumb.jpg" border="0" alt="CP_banner_111x111_gen" width="115" height="115" /></a> </p>
<h2>Snoop is now on CodePlex at <a href="http://snoopwpf.codeplex.com">snoopwpf.codeplex.com</a></h2>
<p>The community reception to my <a href="http://www.cplotts.com/2009/12/08/snoop-now-with-64-bit-support-and-more/">efforts</a> (blog posts: <a href="http://www.cplotts.com/2009/04/04/snoop-20-now-works-in-wpf-interop-scenarios/">1</a>, <a href="http://www.cplotts.com/2009/04/13/snoop-now-works-in-wpf-interop-scenarios-part-ii/">2</a>, <a href="http://www.cplotts.com/2009/12/08/snoop-now-with-64-bit-support-and-more/">3</a>) on Snoop have been wonderful. Some like <a href="http://vivalution.blogspot.com/">Anvaka</a> have offered additional feature suggestions; <a href="http://blogs.msdn.com/peterlau/archive/2010/02/10/connected-show-23-addicted-to-spring-net.aspx">others</a> have just encouraged me.</p>
<p>In my last post, a fellow commented asking why it wasn’t up on CodePlex. Well, this was a great suggestion and one that I had actually already considered. That prompted me to email <a href="http://blois.us/blog/">Pete Blois</a> (the original author) for his permission. He graciously gave it and so I then proceeded to put it up there.</p>
<p>It took me a little while, but I now have the initial bits uploaded … that is, the same stuff that is available here at my blog.</p>
<p>Now, there are a <strong>bunch</strong> of things on the todo list. Most notably, <strong>I’ve already modified Snoop so that it works for WPF 4.0</strong> … and definitely want to share that with the world.</p>
<p>So, please be patient, I’ll get to it. Those silly day jobs! <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h2>Some Info</h2>
<p>If you are going to download the source code and build it, some comments are in order (I’ll put this out at the CodePlex site too).</p>
<p>There are (go to Build-&gt;Configuration Manager) 3 solution platforms (x86, x64, Any CPU) and 2 solution configurations (Debug, Release). The x86 platform is for 32-bit, the x64 platform is obviously for 64-bit, but … what is Any CPU?</p>
<p>Well, Any CPU is only around for Blendability. That is, for some odd reason, I couldn’t bring up the Blend designer Snoop’s window unless it was in this configuration.<strong> I have intentionally marked the ManagedInjector project to not be built under the Any CPU configuration. </strong>Since Any CPU will run as 32-bit on 32-bit operating systems and as 64-bit on 64-bit operating systems, using Any CPU will likely cause a mismatch (and a headache <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) with the ManagedInjector dll.  The project which builds the ManagedInjector.dll is a C++ project and there isn’t an Any CPU setting for those (they can only be specifically built to Win32 or x64).</p>
<p>Or, in other words, <strong>make sure you switch into another platform, before you build or the build will fail.</strong></p>
<p>Here’s a chart for quick reference:</p>
<table border="1" cellspacing="0" cellpadding="2" width="595">
<tbody>
<tr>
<td width="96" valign="top"><strong>Platform</strong></td>
<td width="130" valign="top"><strong>Configuration</strong></td>
<td width="368" valign="top"><strong>Notes</strong></td>
</tr>
<tr>
<td width="96" valign="top">x86</td>
<td width="130" valign="top">Debug</td>
<td width="368" valign="top">For 32-bit.</td>
</tr>
<tr>
<td width="96" valign="top">x86</td>
<td width="130" valign="top">Release</td>
<td width="368" valign="top">For 32-bit, builds the installer.</td>
</tr>
<tr>
<td width="96" valign="top">x64</td>
<td width="130" valign="top">Debug</td>
<td width="368" valign="top">For 64-bit.</td>
</tr>
<tr>
<td width="96" valign="top">x64</td>
<td width="130" valign="top">Release</td>
<td width="368" valign="top">For 64-bit, builds the installer.</td>
</tr>
<tr>
<td width="96" valign="top">Any CPU</td>
<td width="130" valign="top">Debug, Release</td>
<td width="368" valign="top"><strong>Only for Blendability. Do not use.</strong></td>
</tr>
</tbody>
</table>
<p> </p>
<h2>Call to Action</h2>
<p>If you have a feature request or want to be involved somehow (maybe as a contributor), please don’t hesitate to <a href="http://www.cplotts.com/contact/">contact</a> me.</p>
<p>For near future though, I’m going to keep the project closed until I can change the copyright info to Ms-PL and clean up the code a bit.</p>
<h2>Thanks</h2>
<p>Finally, I want to publicly thank Pete Blois for first creating this awesome <a href="http://blois.us/Snoop/">tool</a> and for giving us the permission to get it going on CodePlex. A big thanks Pete!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share/Save</a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2010/02/11/snoop-now-on-codeplex/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Snoop: Now with 64-bit Support and More</title>
		<link>http://www.cplotts.com/2009/12/08/snoop-now-with-64-bit-support-and-more/</link>
		<comments>http://www.cplotts.com/2009/12/08/snoop-now-with-64-bit-support-and-more/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 18:01:37 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Snoop]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/2009/12/08/snoop-now-with-64-bit-support-and-more/</guid>
		<description><![CDATA[The other day I was rebuilding an application such that it would specifically target the x86 platform … solely because I wanted to Snoop it. I’ve done this many, many times because it is the only way I’ve been able to Snoop applications on my Windows 7 64-bit operating system. And, I thought, “Boy, this [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was rebuilding an application such that it would specifically target the x86 platform … solely because I wanted to Snoop it.</p>
<p>I’ve done this many, many times because it is the only way I’ve been able to Snoop applications on my Windows 7 64-bit operating system. And, I thought, “Boy, this is stupid. I should be able to build a 64-bit version of Snoop such that I don’t have to do this anymore.”</p>
<p>And that is exactly what I did.</p>
<p>Now … presenting Snoop 32-bit!</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/12/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.cplotts.com/wp-content/uploads/2009/12/image_thumb.png" width="428" height="30" /></a></p>
<p>And Snoop 64-bit!</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/12/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.cplotts.com/wp-content/uploads/2009/12/image_thumb1.png" width="428" height="30" /></a></p>
<p><strike>Here are the binaries for the </strike><strike>32-bit</strike><strike> version and here are the binaries for the </strike><strike>64-bit</strike><strike> version.</strike></p>
<p><em>(The binaries are now (see posts: </em><a href="http://www.cplotts.com/2010/02/11/snoop-now-on-codeplex/"><em>1</em></a><em>, </em><a href="http://www.cplotts.com/2010/02/14/snoop-now-supports-wpf-4-0/"><em>2</em></a><em>) up on </em><a href="http://snoopwpf.codeplex.com/"><em>CodePlex</em></a><em>. Please go download it from there as those binaries will contain the latest and greatest bits.)</em></p>
<p>It was rather a simple matter really. I just needed to change all the project configurations so that they targeted the x64 platform … for the x64 version of Snoop … and all the project configurations so that they targeted the x86 platform … for the x86 version of Snoop.</p>
<p>This was so easy and worked so nicely … that I searched the internet to see if anyone had done this already … and I found <a href="http://team.interknowlogy.com/blogs/danhanan/">Dan Hanan’s</a> nice <a href="http://team.interknowlogy.com/blogs/danhanan/archive/2009/07/15/64-bit-snoop-for-wpf-development.aspx">post</a> on the matter.</p>
<p>The problem, though, was that he did it for original version of Snoop … and not the nicely styled and improved version that <a href="http://blois.us/blog/">Pete Blois</a> currently is making <a href="http://blois.us/Snoop/">available</a> since property editing was originally (still?) broken in that version. However, he also had several nice usability features that I was drooling over and wanted for my very own. <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  And I, of course, have already fixed the property editing issue in my version (see previous posts: <a href="http://www.cplotts.com/2009/04/04/snoop-20-now-works-in-wpf-interop-scenarios/">1</a>, <a href="http://www.cplotts.com/2009/04/13/snoop-now-works-in-wpf-interop-scenarios-part-ii/">2</a>) with a little help from <a href="http://www.shunra.com/shunrablog/index.php/2009/07/21/a-fix-to-the-awesome-wpf-snoop-utility/">Mark Kharitonov</a> (see this forum <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b99f3db7-540c-43f4-8051-69d2d51a78bc">post</a> for more info on that).</p>
<p>So, I emailed him, got his permission to integrate those changes, and promptly did so. I also added a few improvements myself.</p>
<h2>The Improvements</h2>
<p>Here is what has been improved (over and above Pete Blois’ current version):</p>
<table border="1" cellspacing="0" cellpadding="2" width="595">
<tbody>
<tr>
<td valign="top" width="435"><strong>Improvement</strong></td>
<td valign="top" width="158"><strong>Originator</strong></td>
</tr>
<tr>
<td valign="top" width="435">Handles WPF interop scenarios (both Windows Forms hosting WPF and WPF hosting Windows Forms).</td>
<td valign="top" width="158">Cory Plotts</td>
</tr>
<tr>
<td valign="top" width="435">Fixed the ability to edit properties.</td>
<td valign="top" width="158">Mark Kharitonov</td>
</tr>
<tr>
<td valign="top" width="435">Modified Snoop so that it can handle visual trees that have nesting greater than 255 levels deep.</td>
<td valign="top" width="158">Mark Kharitonov</td>
</tr>
<tr>
<td valign="top" width="435">Modified the project configurations so that you can build a 32-bit version and a 64-bit version. <em>This is what the blog post is all about! Ha!</em></td>
<td valign="top" width="158">Cory Plotts         <br />Dan Hanan</td>
</tr>
<tr>
<td valign="top" width="435">Turned off the showing of properties at their default value (by untoggling the Show Defaults toggle button).</td>
<td valign="top" width="158">Dan Hanan</td>
</tr>
<tr>
<td valign="top" width="435">Turned auto refresh off in the AppChooser. Snoop was previously polling every 20 seconds for new applications.</td>
<td valign="top" width="158">Dan Hanan</td>
</tr>
<tr>
<td valign="top" width="435">Added a checkbox to turn auto refresh back on (if you so desire).</td>
<td valign="top" width="158">Dan Hanan</td>
</tr>
<tr>
<td valign="top" width="435">Added a label to the AppChooser to indicate 32-bit versus 64-bit.</td>
<td valign="top" width="158">Dan Hanan</td>
</tr>
<tr>
<td valign="top" width="435">Added a wait cursor when the AppChooser is busy iterating over the applications to possibly Snoop.</td>
<td valign="top" width="158">Dan Hanan</td>
</tr>
<tr>
<td valign="top" width="435">Added the capability to bring the selected tree view item into view.</td>
<td valign="top" width="158">Dan Hanan</td>
</tr>
<tr>
<td valign="top" width="435">Added the capability to filter properties based on predefined sets of properties.</td>
<td valign="top" width="158">Dan Hanan</td>
</tr>
<tr>
<td valign="top" width="435">Added the ability to pop the target (after a delve) with the back button on the mouse.</td>
<td valign="top" width="158">Dan Hanan</td>
</tr>
<tr>
<td valign="top" width="435">Modified the selected item in the tree view to be a light blue even when it doesn’t have focus.</td>
<td valign="top" width="158">Dan Hanan</td>
</tr>
<tr>
<td valign="top" width="435">Added the ability to pop the target (after a delve) with the alt-left arrow keyboard sequence.</td>
<td valign="top" width="158">Cory Plotts</td>
</tr>
<tr>
<td valign="top" width="435">Added the ability to remember window position, size, and the maximized/minimized/normal state for all three Snoop windows.</td>
<td valign="top" width="158">Cory Plotts</td>
</tr>
<tr>
<td valign="top" width="435">Removed the filtering of ‘devenv’ out from the list of applications that you can Snoop.</td>
<td valign="top" width="158">Cory Plotts</td>
</tr>
<tr>
<td valign="top" width="435"><span style="text-decoration: line-through">Modified the project configurations so that it never builds the installer. I just copy the Snoop executable and the ManagedInjector dll from place to place. <em>Don’t know if this an improvement. <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></span></td>
<td valign="top" width="158">Cory Plotts</td>
</tr>
<tr>
<td valign="top" width="435">Fixed the x86 installer and created an installer for x64. Snoop is no longer being added to the GAC and the assemblies are thus no longer strong named. The installers for both platforms should now work.</td>
<td valign="top" width="158">Cory Plotts</td>
</tr>
<tr>
<td valign="top" width="435">Integrated <a href="http://vivalution.blogspot.com/">Anvaka</a>’s great suggestion below (see the comments). That is, I moved the long label that tells a user how to ctrl-shift click on the application being Snoop(ed) (to a tool tip on the tree view) … and replaced it with a label that tells the user what the immediate following hyperlink is … that is, the Keyboard.FocusedElement. Also added another label and hyperlink for the current selection’s focus scope.</td>
<td valign="top" width="158">Andrei Kashcha (Anvaka)</td>
</tr>
</tbody>
</table>
<p>I chose not to integrate a couple of Dan Hanan’s changes. First, I did not integrate the ‘indexer delve’. Well, actually I did, but then noticed that Pete Blois’ new version already allowed you to delve into items in a collection … and so I backed it out.</p>
<p>Second, I did not integrate the ‘use 2nd monitor if present’ feature. I liked that feature but thought that I would try to improve upon it by remembering the position and size of all the windows … regardless of the number of monitors. So, with a little help from this StackOverflow <a href="http://stackoverflow.com/questions/847752/net-wpf-remember-window-size-between-sessions">question</a> and this MSDN <a href="http://msdn.microsoft.com/en-us/library/aa972163.aspx">sample</a> … that is what I did. It seems to work nicely. Let me know if you have any problems with it.</p>
<h2>Snoop(ing) Visual Studio 2010</h2>
<p>Finally, ever since I’ve installed Visual Studio 2010, I’ve wanted to take a peek under the covers with Snoop (remember … Microsoft used WPF in this latest version of Visual Studio). I originally thought I couldn’t Snoop it … because it was running as a 64-bit application and I only had a 32-bit version of Snoop.</p>
<p>So, when I got the 64-bit version of Snoop going, I quickly tried Snooping Visual Studio 2010. No luck! Bringing up task manager, I quickly remembered that Visual Studio runs as a 32-bit application on 64-bit operating systems. See this <a href="http://blogs.msdn.com/ricom/archive/2009/06/10/visual-studio-why-is-there-no-64-bit-version.aspx">post</a> by <a href="http://blogs.msdn.com/ricom/default.aspx">Rico Mariani</a> for more info.</p>
<p>As I have recently been invited into the <a href="http://groups.google.com/group/wpf-disciples?hl=en">WPF Disciples</a> group, I posed the question <a href="http://groups.google.com/group/wpf-disciples/browse_frm/thread/70b94cf0fc67a086?hl=en">there</a>. Imagine my surprise to find out that devenv.exe was manually being filtered out (since Visual Studio 2008 would load WPF assemblies … but Snoop would fail since Visual Studio 2008 wasn’t built with WPF).</p>
<p>That gave me quite the chuckle. Or, more like, duh! So, promptly removed that and Snoop(ed) Visual Studio 2010 to my delight (check out the red Snoop adorner):</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/12/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.cplotts.com/wp-content/uploads/2009/12/image_thumb2.png" width="599" height="484" /></a></p>
<p>And, of course, the Snoop AppChooser:</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/12/image3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.cplotts.com/wp-content/uploads/2009/12/image_thumb3.png" width="568" height="30" /></a></p>
<p>And, finally, the main Snoop user interface:</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/12/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.cplotts.com/wp-content/uploads/2009/12/image_thumb4.png" width="599" height="484" /></a></p>
<p>I think that is <strong>so cool</strong>. Ok, I know … I need mental help. <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h2>The Source Code</h2>
<p><strike>In the past, I have not released the source code since I have wanted to get Pete’s permission before I do so. I actually met him at PDC 2009 this year. I brought up the fact that I had modified Snoop to handle interop scenarios … but I forgot to ask him about the source code!</strike></p>
<p><strike>There are so many changes now … that I think it would be counter-productive to not release it … in case someone else wants to take Snoop even further than I (and Dan and Mark) have. <em>If you do modify it … and take it further … please let me know! I would love the chance to determine whether to integrate the changes into this version.</em></strike></p>
<p><strike>So, here it is: the </strike><strike>source code</strike><strike>.</strike></p>
<p><em>(The source code is now (see posts: </em><a href="http://www.cplotts.com/2010/02/11/snoop-now-on-codeplex/"><em>1</em></a><em>, </em><a href="http://www.cplotts.com/2010/02/14/snoop-now-supports-wpf-4-0/"><em>2</em></a><em>) up on </em><a href="http://snoopwpf.codeplex.com/"><em>CodePlex</em></a><em>. Please go download it from there as that code will contain the latest and greatest bits.)</em></p>
<p>Enjoy!</p>
<p>p.s. If you were one of the few who pulled down the binaries immediately after I posted it, then you may not have gotten the Snoop.exe.config file. Unfortunately, in this case, Snoop does not seem to close down all the way (i.e. I had to manually kill it through task manager). You’ll want to get the latest binaries that do include the Snoop.exe.config file … or manually rebuild them yourself with the source code.</p>
<h2>An Update</h2>
<p>See above (in the table of improvements), but I fixed the installers and integrated a nice idea by Anvaka. All the attached binaries (which should be installers now) and source code have been updated.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share/Save</a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2009/12/08/snoop-now-with-64-bit-support-and-more/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Blend Modes: Hue, Saturation, Color, and Luminosity with WPF 4.0</title>
		<link>http://www.cplotts.com/2009/11/29/blend-modes-hue-saturation-color-and-luminosity-with-wpf-4-0/</link>
		<comments>http://www.cplotts.com/2009/11/29/blend-modes-hue-saturation-color-and-luminosity-with-wpf-4-0/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 18:22:37 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[Blend Modes]]></category>
		<category><![CDATA[Pixel Shader Effects]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/?p=437</guid>
		<description><![CDATA[I’ve been toying with and working on this blend mode library of mine for some time now (see posts 1, 2, 3, 4, 5). However, it is now only with WPF 4.0 (currently Beta 2) … that I can actually implement all the blend modes. Hue, Saturation, Color, and Luminosity: Where Are You? If you [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been toying with and working on this blend mode library of mine for some time now (see posts <a href="http://www.cplotts.com/2009/06/16/blend-modes-part-i/">1</a>, <a href="http://www.cplotts.com/2009/06/16/blend-modes-part-ii/">2</a>, <a href="http://www.cplotts.com/2009/06/17/blend-modes-for-silverlight/">3</a>, <a href="http://www.cplotts.com/2009/06/30/blend-modes-part-iii/">4</a>, <a href="http://www.cplotts.com/2009/11/06/blend-modes-now-opacity-aware/">5</a>). However, it is now only with WPF 4.0 (currently Beta 2) … that I can actually implement <strong>all </strong>the blend modes.</p>
<h2>Hue, Saturation, Color, and Luminosity: Where Are You?</h2>
<p>If you were watching closely, you will have noticed that I have not (to date) implemented the Hue, Saturation, Color, and Luminosity blend mode effects.</p>
<p>Why is that? Whenever fxc.exe would compile the .fx file (through the <a href="http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=14962">Shader Effects BuildTask and Templates</a>), it would give me the following two errors:</p>
<ul>
<li>error X5608: Compiled shader code uses too many arithmetic instruction slots (100). Max. allowed by target (ps_2_0) is 64. </li>
<li>error X5609: Compiled shader code uses too many instruction slots (102). Max. allowed by the target (ps_2_0) is 96. </li>
</ul>
<p>Those errors mean that you’ve exceeded the limitations of Pixel Shader 2.0 … which is what WPF 3.5 SP1 targets for pixel shader effects.</p>
<p>So, what can you do about this? You could optimize the HLSL so that your effect code goes under the limits … but if you notice in the errors above (these particular errors are for the Saturation effect) … you will see that I am significantly above the number of allowed arithmetic instruction slots (100 versus 64). I would have to optimize significantly.</p>
<h2>WPF 4.0 to the Rescue</h2>
<p>Another option is to utilize WPF 4.0!</p>
<p>WPF 4.0 increases what you can do with effects because it now allows you to target Pixel Shader 3.0. <a href="http://en.wikipedia.org/wiki/High_Level_Shader_Language">This</a> wikipedia article has a great chart on the differences between the different shader models. With PS 3.0, we shouldn’t hit any limits.</p>
<p>Realizing this, as soon as Visual Studio 2010 and .NET 4 Beta 2 came out (PS 3.0 is only available in Beta 2), I installed it and gave it a whirl. There was really only one gotcha in getting this to work. The <a href="http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=14962">Shader Effects BuildTask</a> only compiles to PS 2.0 … and there is no option to toggle between PS 2.0 and PS 3.0.</p>
<p>This means that, for now, probably until release, you will have to manually run fxc.exe (targeting ps_3_0) and add the compiled shader output file (the .ps file) to the project as a Resource.</p>
<h2>Caveats</h2>
<p>There are some caveats to using PS 3.0 in WPF 4.0. Most notably, there is no software fallback if your hardware or situation (remote desktop, forced software rendering) don’t support it. This means that your effect code will simply not run and not appear.</p>
<p>Some good news is that Microsoft has extended the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.rendercapability(VS.100).aspx">RenderCapability</a> API so that you can determine what level of pixel shader support is currently available. They’ve updated the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.rendercapability.ispixelshaderversionsupported(VS.100).aspx">RenderCapability.IsPixelShaderVersionSupported</a> method and have added two additional methods: <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.rendercapability.ispixelshaderversionsupportedinsoftware(VS.100).aspx">RenderCapability.IsPixelShaderVersionSupportedInSoftware</a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.rendercapability.maxpixelshaderinstructionslots(VS.100).aspx">RenderCapability.MaxPixelShaderInstructionSlots</a>.</p>
<p>(The above information and more is available in David Teitlebaum’s PDC09 session titled <a href="http://microsoftpdc.com/Sessions/CL31">Mastering WPF Graphics and Beyond</a>. Jamie Rodriguez also has some great posts covering what’s new in WPF 4.0 (<a href="http://blogs.msdn.com/jaimer/archive/2009/05/27/wpf-4-and-net-framework-4-beta-1-list-of-features-totrack.aspx">Beta 1</a>, <a href="http://blogs.msdn.com/jaimer/archive/2009/10/23/what-is-new-in-wpf-and-cider-on-the-net-framework-4-and-vs2010-beta-2-release.aspx">Beta 2</a>).)</p>
<p>Another caveat that bears mentioning is that Silverlight (both 3.0 and 4.0) only support PS 2.0. So, if you are creating and using effects across both technologies, you will not be able to use PS 3.0. <strong>This also means that the Hue, Saturation, Color, and Luminosity blend modes (and the attached code) are WPF only blend modes.</strong> Sorry Silverlight! I love you, but that’s how the chips fall.</p>
<h2>Hue, Saturation, Color, and Luminosity: Here They Are!</h2>
<p>Alright … enough with the caveats! Let’s see the effects!</p>
<p>First, let me refer you back to Angie Bowen’s <a href="http://www.myinkblog.com/2009/07/14/an-explanation-of-photoshop-blend-modes/">post</a> where she covers what each blend mode does … including the Hue, Saturation, Color and Luminosity effects.</p>
<p>To show off what each effect does, I’m going to go ahead and use her reference images … first showing how they blend out of Photoshop … and then showing how they blend with my library … for comparison purposes. Why? Well, it seems as if my blend mode library does not always match what is coming out of Photoshop … sometimes it&#8217;s pretty darn close and at other times it’s more than just a little bit off.</p>
<p>I have been through and through the math (and HLSL) for these effects and I honestly can’t find anything wrong there. If I could speculate what is going on, I would say that I’m bumping up against some float versus double precision issues (where Photoshop is using doubles for greater precision) during the conversion from RGB to HSL and back. <em>If you can figure out what I’ve done wrong (if anything) please let me know.</em></p>
<p>However, for the most part, they work great!</p>
<h2>Hue Blend Mode</h2>
<p>The result is the hue of the blend layer and the saturation and luminance of the base layer.</p>
<table border="1" cellspacing="0" cellpadding="2" width="595">
<tbody>
<tr>
<td valign="top" width="146">
<p align="right">Photoshop</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/HuePhotoshop.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="HuePhotoshop" border="0" alt="HuePhotoshop" src="http://www.cplotts.com/wp-content/uploads/2009/12/HuePhotoshop_thumb.png" width="329" height="248" /></a></td>
</tr>
<tr>
<td valign="top" width="146">
<p align="right">My Blend Mode Library</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Hue.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Hue" border="0" alt="Hue" src="http://www.cplotts.com/wp-content/uploads/2009/12/Hue_thumb.png" width="329" height="248" /></a></td>
</tr>
</tbody>
</table>
<table border="1" cellspacing="0" cellpadding="2" width="596">
<tbody>
<tr>
<td valign="top" width="146">
<p align="right">Photoshop</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Hue2Photoshop.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Hue2Photoshop" border="0" alt="Hue2Photoshop" src="http://www.cplotts.com/wp-content/uploads/2009/12/Hue2Photoshop_thumb.png" width="329" height="248" /></a></td>
</tr>
<tr>
<td valign="top" width="146">
<p align="right">My Blend Mode Library</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Hue2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Hue2" border="0" alt="Hue2" src="http://www.cplotts.com/wp-content/uploads/2009/12/Hue2_thumb.png" width="329" height="248" /></a></td>
</tr>
</tbody>
</table>
<h2>Saturation Blend Mode</h2>
<p>The result is the saturation of the blend layer and the hue and luminance of the base layer.</p>
<table border="1" cellspacing="0" cellpadding="2" width="596">
<tbody>
<tr>
<td valign="top" width="146">
<p align="right">Photoshop</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/SaturationPhotoshop.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="SaturationPhotoshop" border="0" alt="SaturationPhotoshop" src="http://www.cplotts.com/wp-content/uploads/2009/12/SaturationPhotoshop_thumb.png" width="329" height="248" /></a></td>
</tr>
<tr>
<td valign="top" width="146">
<p align="right">My Blend Mode Library</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Saturation.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Saturation" border="0" alt="Saturation" src="http://www.cplotts.com/wp-content/uploads/2009/12/Saturation_thumb.png" width="329" height="248" /></a></td>
</tr>
</tbody>
</table>
<table border="1" cellspacing="0" cellpadding="2" width="596">
<tbody>
<tr>
<td valign="top" width="146">
<p align="right">Photoshop</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Saturation2Photoshop.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Saturation2Photoshop" border="0" alt="Saturation2Photoshop" src="http://www.cplotts.com/wp-content/uploads/2009/12/Saturation2Photoshop_thumb.png" width="329" height="248" /></a></td>
</tr>
<tr>
<td valign="top" width="146">
<p align="right">My Blend Mode Library</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Saturation2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Saturation2" border="0" alt="Saturation2" src="http://www.cplotts.com/wp-content/uploads/2009/12/Saturation2_thumb.png" width="329" height="248" /></a></td>
</tr>
</tbody>
</table>
<h2>Color Blend Mode</h2>
<p>The result is luminance of the base layer and the hue and the saturation of the blend layer.</p>
<table border="1" cellspacing="0" cellpadding="2" width="596">
<tbody>
<tr>
<td valign="top" width="146">
<p align="right">Photoshop</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/ColorPhotoshop.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ColorPhotoshop" border="0" alt="ColorPhotoshop" src="http://www.cplotts.com/wp-content/uploads/2009/12/ColorPhotoshop_thumb.png" width="329" height="248" /></a></td>
</tr>
<tr>
<td valign="top" width="146">
<p align="right">My Blend Mode Library</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Color.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Color" border="0" alt="Color" src="http://www.cplotts.com/wp-content/uploads/2009/12/Color_thumb.png" width="329" height="248" /></a></td>
</tr>
</tbody>
</table>
<table border="1" cellspacing="0" cellpadding="2" width="596">
<tbody>
<tr>
<td valign="top" width="146">
<p align="right">Photoshop</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Color2Photoshop.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Color2Photoshop" border="0" alt="Color2Photoshop" src="http://www.cplotts.com/wp-content/uploads/2009/12/Color2Photoshop_thumb.png" width="329" height="248" /></a></td>
</tr>
<tr>
<td valign="top" width="146">
<p align="right">My Blend Mode Library</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Color2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Color2" border="0" alt="Color2" src="http://www.cplotts.com/wp-content/uploads/2009/12/Color2_thumb.png" width="329" height="248" /></a></td>
</tr>
</tbody>
</table>
<h2>Luminosity Blend Mode</h2>
<p>The result is hue and the saturation of the base layer and the luminosity of the blend layer.</p>
<table border="1" cellspacing="0" cellpadding="2" width="596">
<tbody>
<tr>
<td valign="top" width="146">
<p align="right">Photoshop</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/LuminosityPhotoshop.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="LuminosityPhotoshop" border="0" alt="LuminosityPhotoshop" src="http://www.cplotts.com/wp-content/uploads/2009/12/LuminosityPhotoshop_thumb.png" width="329" height="248" /></a></td>
</tr>
<tr>
<td valign="top" width="146">
<p align="right">My Blend Mode Library</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Luminosity.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Luminosity" border="0" alt="Luminosity" src="http://www.cplotts.com/wp-content/uploads/2009/12/Luminosity_thumb.png" width="329" height="248" /></a></td>
</tr>
</tbody>
</table>
<table border="1" cellspacing="0" cellpadding="2" width="596">
<tbody>
<tr>
<td valign="top" width="146">
<p align="right">Photoshop</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Luminosity2Photoshop.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Luminosity2Photoshop" border="0" alt="Luminosity2Photoshop" src="http://www.cplotts.com/wp-content/uploads/2009/12/Luminosity2Photoshop_thumb.png" width="329" height="248" /></a></td>
</tr>
<tr>
<td valign="top" width="146">
<p align="right">My Blend Mode Library</p>
</td>
<td valign="top" width="448"><a href="http://www.cplotts.com/wp-content/uploads/2009/12/Luminosity2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Luminosity2" border="0" alt="Luminosity2" src="http://www.cplotts.com/wp-content/uploads/2009/12/Luminosity2_thumb.png" width="329" height="248" /></a></td>
</tr>
</tbody>
</table>
<h2>The Binaries and the Source Code</h2>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/12/WPFSLBlendModeFx.zip">Here</a> is the source code for the library and <a href="http://www.cplotts.com/wp-content/uploads/2009/12/BlendModeEffectLibrary.zip">here</a> is the assembly.</p>
<p>Again, remember that this is a WPF-only release as Silverlight does not <strong>yet</strong> have support for Pixel Shader 3.0.</p>
<p>Also, all of these new blend modes are opacity aware … meaning that you can pull the opacity out of the upper layer to lessen the effect of the blend mode (see my last <a href="http://www.cplotts.com/2009/11/06/blend-modes-now-opacity-aware/">post</a> on the matter).</p>
<p>Enjoy!</p>
<p>p.s.</p>
<p>At one point, I thought that the <a href="http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=14962">Shader Effects BuildTask and Templates</a> was built into Visual Studio 2010. It appears I was mistaken about that. I have updated this post to indicate that.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share/Save</a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2009/11/29/blend-modes-hue-saturation-color-and-luminosity-with-wpf-4-0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Blend Modes: Now Opacity Aware</title>
		<link>http://www.cplotts.com/2009/11/06/blend-modes-now-opacity-aware/</link>
		<comments>http://www.cplotts.com/2009/11/06/blend-modes-now-opacity-aware/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 23:29:30 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[Blend Modes]]></category>
		<category><![CDATA[Pixel Shader Effects]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/?p=392</guid>
		<description><![CDATA[After I wrote my trio of blog posts (1, 2, 3) about blend modes using pixel shader effects, I was toying around with it …   The Problem … and noticed that it didn’t handle an opacity changes on the upper layer (B). In fact, this was brought to my attention by a great blog [...]]]></description>
			<content:encoded><![CDATA[<p>After I wrote my trio of blog posts (<a href="http://www.cplotts.com/2009/06/16/blend-modes-part-i/">1</a>, <a href="http://www.cplotts.com/2009/06/16/blend-modes-part-ii/">2</a>, <a href="http://www.cplotts.com/2009/06/30/blend-modes-part-iii/">3</a>) about blend modes using pixel shader effects, I was toying around with it …</p>
<p> </p>
<h2>The Problem</h2>
<p>… and noticed that it didn’t handle an opacity changes on the upper layer (B).</p>
<p>In fact, this was brought to my attention by a great blog <a href="http://www.myinkblog.com/2009/07/14/an-explanation-of-photoshop-blend-modes/">post</a> by Angie Bowen. In it she explains how the blend modes work and, she says:</p>
<blockquote><p>Remember that to get better results you can also adjust the opacity of the upper layer.</p></blockquote>
<p>Trying it out, revealed that some of the blend modes were okay, but most were not. Most of the blend modes would simply result in a black square if you pulled all the opacity out of the upper layer (B). This was obviously wrong, for if you pull all the opacity out of the upper layer (B), you should get the lower layer (A).</p>
<p>Argh!</p>
<p> </p>
<h2>The Solution</h2>
<p>So, I dove back in on the blend mode math, trying to figure out what I needed to do to make these blend modes … opacity aware. <em>That’s got a nice ring to it, doesn’t it!?</em></p>
<p>I started at the top of the list and got the NormalEffect working:</p>
<pre class="brush: cpp;">float4 main(float2 uv : TEXCOORD) : COLOR
{
    float4 inputColor;
    inputColor = tex2D(input, uv);

    float4 blendColor;
    blendColor = tex2D(blend, uv);

    inputColor.rgb = (1 - blendColor.a) * inputColor.rgb + blendColor.rgb;

    return inputColor;
}</pre>
<p>Ok, the above math made sense. When the opacity of the upper layer (blendColor.a) was 1 (opaque), the result was just blendColor. Otherwise when the opacity of the upper layer was 0 (transparent), the result was inputColor.</p>
<p>So, I then started to tackle the darken blend modes (Darken, Multiply, …) and quickly ran into problems. It was at that point, that I ran into this <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2940eec8-6689-4ed7-b276-38e637640dd6">post</a> in the WPF Forum. My blend modes were rendering full black (not white), but it provided a crucial piece of knowledge.</p>
<p><strong>Namely, WPF uses pre-multiplied alpha everywhere for performance reasons.</strong></p>
<p>What does that mean? Well, it means that the RGB values for inputColor are already multiplied by the alpha value for inputColor and that the RGB values for blendColor are already multiplied by the alpha value for blendColor.</p>
<p>Ah! Do you see it? This explains why the blend modes were going to a black square when pulling the opacity out. Take the Multiply blend mode. In the above HLSL, it would be:</p>
<pre class="brush: cpp;">// R = Base * Blend
resultColor.rgb = inputColor.rgb * blendColor.rgb</pre>
<p>So, if the alphas were pre-multiplied in and you were pulling opacity out of the blend (upper) layer … then blendColor.rgb would go to zero … which would cause resultColor to go to zero … which would cause the gradient square to go to black!</p>
<p>Thinking about this … brought about the general solution for making these blend modes opacity aware. I needed to simply:</p>
<ol>
<li>Un-pre-multiply the blend layer alpha value out.</li>
<li>Apply the blend mode math.</li>
<li>Then re-multiply the blend layer alpha value in again.</li>
</ol>
<ol>Here is the HLSL for the opacity aware Multiply blend mode:</ol>
<ol>
<pre class="brush: cpp;">float4 main(float2 uv : TEXCOORD) : COLOR
{
    float4 inputColor;
    inputColor = tex2D(input, uv);

    float4 blendColor;
    blendColor = tex2D(blend, uv);

    float4 resultColor;
    resultColor.a = inputColor.a;
    // un-premultiply the blendColor alpha out from blendColor
    blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1);

    // apply the blend mode math
    // R = Base * Blend
    resultColor.rgb = inputColor.rgb * blendColor.rgb;

    // re-multiply the blendColor alpha in to blendColor
    // weight inputColor according to blendColor.a
    resultColor.rgb =
        (1 - blendColor.a) * inputColor.rgb +
        resultColor.rgb * blendColor.a;

    return resultColor;
}</pre>
<p>A few comments about the above code. Notice that I am clamp(ing) when I un-premultiply (i.e. divide) the alpha out. This assures that the RGB values will be between 0 and 1 (where 0 is black and 1 is white … HLSL operates in ScRGB color space). This is necessary since dividing by values close to 0 (blendColor.a) can yield large numbers or even positive infinity … which throws off the math.</ol>
<p>Secondly, when I re-multiply the blend layer alpha value back in … I need to also properly weight the inputColor … just like I did in the NormalEffect above.</p>
<p>Finally, notice that I really don’t have worry about the opacity on the lower layer (A). I just pass its value off to the result by setting resultColor.a equal to inputColor.a.</p>
<p>Applying this general formula worked in all cases!</p>
<p> </p>
<h2>The Gradient Contour Test Harness</h2>
<p>In order to verify that I was doing math correctly, and to see the effect of pulling the opacity out of the blend modes … I have built a new gradient test harness. I have called it the gradient contour test harness since it not only shows the A + B = R gradient squares but it also shows the R gradient square with contours … just like Paul Dunn’s <a href="http://dunnbypaul.net/blends/">post</a> does when you mouse over the R squares.</p>
<p>It is extremely interesting (to me at least) watching the contours as you pull out the opacities.</p>
<p>For example, Here are three gradient contour squares for the Pin Light blend mode at opacity values of 1.0, 0.5, and 0.0:</p>
<div>
<table border="1" cellspacing="0" cellpadding="2" width="595" align="center">
<tbody>
<tr>
<td width="249" valign="top">
<p align="center">Gradient Squares</p>
</td>
<td width="251" valign="top">
<p align="center">Gradient Contour Squares</p>
</td>
<td width="93" valign="top">
<p align="center">Opacity</p>
</td>
</tr>
<tr>
<td width="249" valign="top"><a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight1.00nc.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PinLight1.00nc" src="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight1.00nc_thumb.png" border="0" alt="PinLight1.00nc" width="204" height="204" /></a> <a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight1.00.png"></a></td>
<td width="251" valign="top"><a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight1.00.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PinLight1.00" src="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight1.00_thumb.png" border="0" alt="PinLight1.00" width="204" height="204" /></a><a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.50.png"></a></td>
<td width="93" valign="top">
<p align="center">1.0</p>
</td>
</tr>
<tr>
<td width="249" valign="top"><a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.50nc.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PinLight0.50nc" src="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.50nc_thumb.png" border="0" alt="PinLight0.50nc" width="204" height="204" /></a> <a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.50.png"></a></td>
<td width="251" valign="top"><a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.50.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PinLight0.50" src="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.50_thumb.png" border="0" alt="PinLight0.50" width="204" height="204" /></a></td>
<td width="93" valign="top">
<p align="center">0.5</p>
</td>
</tr>
<tr>
<td width="249" valign="top"><a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.00nc.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PinLight0.00nc" src="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.00nc_thumb.png" border="0" alt="PinLight0.00nc" width="204" height="204" /></a> <a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.00.png"></a></td>
<td width="251" valign="top"><a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.00.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PinLight0.00" src="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight0.00_thumb.png" border="0" alt="PinLight0.00" width="203" height="204" /></a></td>
<td width="93" valign="top">
<p align="center">0.0</p>
</td>
</tr>
</tbody>
</table>
</div>
<p align="center"><a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLight1.00.png"></a></p>
<p align="left">I have also included a button labeled ‘Swap’ which swaps the A and B layers … since not all blend mode effects are commutative.</p>
<p align="left">The gradient contours were made possible via Dwayne Need’s <a href="http://www.codeplex.com/MicrosoftDwayneNeed">library</a>. Check out the code (the class Grayscale4Bitmap) and see this <a href="http://blogs.msdn.com/dwayneneed/archive/2008/06/20/implementing-a-custom-bitmapsource.aspx">post</a> for more info.</p>
<h2>The Image Test Harness</h2>
<p>I’ve also put opacity sliders in the image test harnesses. Let’s take a look at the Pin Light effect at opacity values of 1.0, 0.5, and 0.3.</p>
<table border="1" cellspacing="0" cellpadding="2" width="595">
<tbody>
<tr>
<td width="297" valign="top">
<p align="center">Images</p>
</td>
<td width="297" valign="top">Opacity</td>
</tr>
<tr>
<td width="297" valign="top"><a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLightImage1.0.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="PinLightImage1.0" src="http://www.cplotts.com/wp-content/uploads/2009/11/PinLightImage1.0_thumb.png" border="0" alt="PinLightImage1.0" width="329" height="248" /></a></td>
<td width="297" valign="top">1.0</td>
</tr>
<tr>
<td width="297" valign="top"><a href="http://www.cplotts.com/wp-content/uploads/2009/11/PinLightImage0.75.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="PinLightImage0.75" src="http://www.cplotts.com/wp-content/uploads/2009/11/PinLightImage0.75_thumb.png" border="0" alt="PinLightImage0.75" width="329" height="248" /></a></td>
<td width="297" valign="top">0.50</td>
</tr>
<tr>
<td width="297" valign="top"><a href="http://www.cplotts.com/wp-content/uploads/2009/11/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.cplotts.com/wp-content/uploads/2009/11/image_thumb.png" border="0" alt="image" width="329" height="248" /></a></td>
<td width="297" valign="top">0.3</td>
</tr>
</tbody>
</table>
<p>As you can see … pulling out the opacity … lessens the effect that the upper layer/texture has on the lower layer … and proves the truth of what <a href="http://www.myinkblog.com/">Angie Bowen</a> was saying earlier about using the opacity of the upper layer to achieve better results.</p>
<p> </p>
<h2>The Binaries and the Source Code (aka The Goods)</h2>
<p>So, as I’m fond of saying … without further adieu … <a href="http://www.cplotts.com/wp-content/uploads/2009/11/WPFSLBlendModeFx.zip">here</a> is source code for the Blend Mode library and <a href="http://www.cplotts.com/wp-content/uploads/2009/11/BlendModeLibraryBinaries.zip">here</a> are the library binaries … now opacity aware!</p>
<p>I also have updated the Silverlight <a href="http://www.cplotts.com/BlendModeEffectTestHarness/Default.html">test harness</a> (as always you will need the Silverlight 3.0 runtime).</p>
<p><strong>p.s.</strong></p>
<p>The gradient contour test harness is WPF only &#8230; you won&#8217;t find that on the Silverlight side. Maybe someday I&#8217;ll get my Silverlight test harnesses up to parity with what&#8217;s in the WPF test harnesses &#8230; but I can&#8217;t see when. Any one want to do it for me? Bueller? Bueller?</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share/Save</a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2009/11/06/blend-modes-now-opacity-aware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF &amp; Silverlight Charting: A Logarithmic Axis</title>
		<link>http://www.cplotts.com/2009/10/09/wpf-silverlight-charting-a-logarithmic-axis/</link>
		<comments>http://www.cplotts.com/2009/10/09/wpf-silverlight-charting-a-logarithmic-axis/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 00:02:58 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Charting]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/?p=329</guid>
		<description><![CDATA[I love controls. Even more … I love graph controls. In fact, graph controls have been one of the main things I have worked on during my tenure at my current place of employment. A small aside: I think it is what I was meant to do (i.e. work on graph controls). For, my name [...]]]></description>
			<content:encoded><![CDATA[<p>I love controls. Even more … I love graph controls. In fact, graph controls have been one of the main things I have worked on during my tenure at my current place of employment.</p>
<p><em>A small aside: I think it is what I was meant to do (i.e. work on graph controls). For, my name is … Cory <strong>Plotts. </strong>Plotts, you know, as in plots. Ok, never mind, that was lame. </em> <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So, it was quite natural, and actually part of my job, to take a look at what Microsoft is offering in the WPF and Silverlight toolkits. I have to hand it to <a href="http://blogs.msdn.com/delay/default.aspx">David Anson</a> and the other fellows at Microsoft. They have taken a very nice approach.</p>
<p>First, almost everything is a <span style="font-family: courier new; font-size: small;">System.Windows.Controls.Control</span> that you can restyle and re-template to your heart’s content. So, that makes it very designable.</p>
<p><strong>Second</strong>, I love the data binding model. They have decided to follow an <span style="font-family: courier new; font-size: small;">ItemsControl</span> like approach where you have an <span style="font-family: courier new; font-size: small;">ItemsSource</span> property that you just plunk your data into. Very nice. It literally takes you seconds to get something up and running.</p>
<p><strong>Third</strong>, they are developing it … with Blend in mind. That is, they are trying to provide a positive Blend experience and have gone to pains to make it so. So, not only is it designable … but designers can actually use Blend to do their designing … instead of hacking through xaml in a code editor. Woot! Woot!</p>
<p>Now, this post is not going to be an introduction on how to start using the charting component. Many others have done that already. If that is what you are looking for … I would suggest that you go to this blog <a href="http://blogs.msdn.com/delay/archive/2009/07/19/my-new-home-page-enhanced-updated-collection-of-great-silverlight-wpf-data-visualization-resources.aspx">post</a> by David Anson where he lists out lots and lots of links to other blog posts and articles. In fact, he is so nice … that he has even separated them out by difficulty level.</p>
<p>No, in this blog post, I am going to show you the <strong>fourth thing</strong> I love about this charting component: how extensible it is! And, I am going to do that by showing how I created a logarithmic axis by simply deriving from <span style="font-family: courier new; font-size: small;">NumericAxis</span>.</p>
<p>So, here’s the code (sorry for just dumping it all in one place … but it gives you a nice place to copy out the <em>entire </em>implementation at once):</p>
<pre class="brush: csharp; highlight: [20, 37, 67, 104, 114, 125]">using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes;

namespace System.Windows.Controls.DataVisualization.Charting
{
    /// &lt;summary&gt;
    /// An axis that displays numeric values along a logarithmic range.
    /// &lt;/summary&gt;
    [StyleTypedProperty(Property = "GridLineStyle", StyleTargetType = typeof(Line))]
    [StyleTypedProperty(Property = "MajorTickMarkStyle", StyleTargetType = typeof(Line))]
    [StyleTypedProperty(Property = "MinorTickMarkStyle", StyleTargetType = typeof(Line))]
    [StyleTypedProperty(Property = "AxisLabelStyle", StyleTargetType = typeof(NumericAxisLabel))]
    [StyleTypedProperty(Property = "TitleStyle", StyleTargetType = typeof(Title))]
    [TemplatePart(Name = AxisGridName, Type = typeof(Grid))]
    [TemplatePart(Name = AxisTitleName, Type = typeof(Title))]
    public class LogarithmicAxis : NumericAxis
    {
        /// &lt;summary&gt;
        /// Instantiates a new instance of the LogarithmicAxis
        /// &lt;/summary&gt;
        public LogarithmicAxis()
        {
            ActualRange = new Range&lt;IComparable&gt;(1.0, 2.0);
        }

        /// &lt;summary&gt;
        /// Returns the plot area coordinate of a value.
        /// &lt;/summary&gt;
        /// &lt;param name="value"&gt;The value to plot.&lt;/param&gt;
        /// &lt;param name="range"&gt;The range of values.&lt;/param&gt;
        /// &lt;param name="length"&gt;The length of the axis.&lt;/param&gt;
        /// &lt;returns&gt;The plot area coordinate of the value.&lt;/returns&gt;
        protected override UnitValue? GetPlotAreaCoordinate(object value, Range&lt;IComparable&gt; range, double length)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (range.HasData)
            {
                double doubleValue = ValueHelper.ToDouble(value);
                Range&lt;double&gt; actualDoubleRange = range.ToDoubleRange();

                return
                    new UnitValue
                    (
                        length /
                        Math.Log10(actualDoubleRange.Maximum / actualDoubleRange.Minimum) *
                        Math.Log10(doubleValue / actualDoubleRange.Minimum),
                        Unit.Pixels
                    );
            }

            return new UnitValue?();
        }

        /// &lt;summary&gt;
        /// Returns the value range given a plot area coordinate.
        /// &lt;/summary&gt;
        /// &lt;param name="value"&gt;The plot area position.&lt;/param&gt;
        /// &lt;returns&gt;The value at that plot area coordinate.&lt;/returns&gt;
        protected override IComparable GetValueAtPosition(UnitValue value)
        {
            if (ActualRange.HasData &amp;&amp; ActualLength != 0.0)
            {
                if (value.Unit == Unit.Pixels)
                {
                    double coordinate = value.Value;
                    Range&lt;double&gt; actualDoubleRange = ActualRange.ToDoubleRange();

                    double output =
                        Math.Pow
                        (
                            10,
                            coordinate *
                            Math.Log10(actualDoubleRange.Maximum / actualDoubleRange.Minimum) /
                            ActualLength
                        )
                        *
                        actualDoubleRange.Minimum;

                    return output;
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            return null;
        }

        /// &lt;summary&gt;
        /// Returns a sequence of values to create major tick marks for.
        /// &lt;/summary&gt;
        /// &lt;param name="availableSize"&gt;The available size.&lt;/param&gt;
        /// &lt;returns&gt;A sequence of values to create major tick marks for.
        /// &lt;/returns&gt;
        protected override IEnumerable&lt;IComparable&gt; GetMajorTickMarkValues(Size availableSize)
        {
            return GetMajorValues(availableSize).Cast&lt;IComparable&gt;();
        }

        /// &lt;summary&gt;
        /// Returns a sequence of values to plot on the axis.
        /// &lt;/summary&gt;
        /// &lt;param name="availableSize"&gt;The available size.&lt;/param&gt;
        /// &lt;returns&gt;A sequence of values to plot on the axis.&lt;/returns&gt;
        protected override IEnumerable&lt;IComparable&gt; GetLabelValues(Size availableSize)
        {
            return GetMajorValues(availableSize).Cast&lt;IComparable&gt;();
        }

        /// &lt;summary&gt;
        /// Returns a sequence of major axis values.
        /// &lt;/summary&gt;
        /// &lt;param name="availableSize"&gt;The available size.&lt;/param&gt;
        /// &lt;returns&gt;A sequence of major axis values.
        /// &lt;/returns&gt;
        private IEnumerable&lt;double&gt; GetMajorValues(Size availableSize)
        {
            if (!ActualRange.HasData || ValueHelper.Compare(ActualRange.Minimum, ActualRange.Maximum) == 0 || GetLength(availableSize) == 0.0)
            {
                yield break;
            }

            yield return 125;
            yield return 250;
            yield return 500;
            yield return 1000;
            yield return 2000;
            yield return 4000;
            yield return 8000;
        }
    }
}</pre>
<p>To explain the above code a little bit, I would first direct your attention to two methods. The first is called <strong><span style="font-family: courier new; font-size: small;">GetPlotAreaCoordinate</span></strong>. This method is the method responsible for converting from world coordinates into device coordinates. That is, it converts all the data point values in your Series into pixel coordinates … so that your data point is placed where you expect it should be.</p>
<p>The second method is called <strong><span style="font-family: courier new; font-size: small;">GetValueAtPosition</span></strong>. This method does the exact opposite as <span style="font-family: courier new; font-size: small;">GetPlotAreaCoordinate</span>. It converts from device coordinates into world coordinates. In other words, it takes the mouse position (for example) and it tells you where your mouse is at on the respective axis.</p>
<p>So, the above two methods contain the math behind the axis … and if you look closely, you’ll see the <span style="font-family: courier new; font-size: small;">Math.Log10</span> function getting called. Yep. That’s right. This is a logarithmic axis.</p>
<p>After those two methods, you will see <strong><span style="font-family: courier new; font-size: small;">GetMajorTickValues</span></strong> and <strong><span style="font-family: courier new; font-size: small;">GetLabelValues</span></strong>. They both delegate to a third method called <span style="font-family: courier new; font-size: small;">GetMajorValues</span>. <span style="font-family: courier new; font-size: small;">GetMajorTickValues</span> returns the values at which we want major tick marks and <span style="font-family: courier new; font-size: small;">GetLabelValues</span> returns the values at which we want grid line labels. Pretty straightforward.</p>
<p>Now, a word about my implementation of <span style="font-family: courier new; font-size: small;">GetMajorValues</span>. In it, I have chosen to hardcode very specific values for this axis’ grid lines (i.e. 125, 250, 500, 1000, 2000, 4000, 8000). I did that because I was lazy. For inside of <span style="font-family: courier new; font-size: small;">LinearAxis</span>, there is an <span style="font-family: courier new; font-size: small;">Interval</span> property which you can use to generate the grid lines in a dynamic fashion … and I didn’t feel like figuring out how to make the <span style="font-family: courier new; font-size: small;">Interval</span> property work for the logarithmic axis. (If anyone out there does take the time to do so … please share!)</p>
<p>So, more than likely, you will be wanting to replace those specific values with some of your own … or will be wanting to generate the major values in a much more dynamic way.</p>
<p>Ok, now let me show you how you would use this axis. Check out this xaml (this is just a snippet … I am leaving out all the styling xaml and more):</p>
<pre class="brush: xml; highlight: [11, 12, 13, 14, 15, 16, 17]">&lt;charting:Chart
    x:Name="chart"
    Width="480"
    Height="480"
    Margin="10"
    Title="Response"
    BorderBrush="{x:Null}"
    Style="{StaticResource chartStyle}"
&gt;
    &lt;charting:Chart.Axes&gt;
        &lt;charting:LogarithmicAxis
            Orientation="X"
            ShowGridLines="True"
            Title="Frequency (Hz)"
            Minimum="100"
            Maximum="10000"
        /&gt;
        &lt;charting:LinearAxis
            Orientation="Y"
            ShowGridLines="True"
            Title="Response (dB SPL)"
            Minimum="20"
            Maximum="120"
            Interval="10"
        /&gt;
    &lt;/charting:Chart.Axes&gt;
    &lt;charting:LineSeries
        ItemsSource="{StaticResource responseCurve}"
        IndependentValueBinding="{Binding Frequency}"
        DependentValueBinding="{Binding Response}"
        DataPointStyle="{StaticResource lineDataPointStyle}"
        AnimationSequence="Simultaneous"
        TransitionDuration="0:0:0"
        IsSelectionEnabled="True"
    /&gt;
&lt;/charting:Chart&gt;</pre>
<p>In the above, you can see my new <strong>and proud</strong> <span style="font-family: courier new; font-size: small;">LogarithmicAxis</span> with a Minimum value of 100 and a Maximum value of 10000. Here is a snapshot of the chart that the above xaml creates:</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/10/image.png"><img style="display: inline; border-width: 0px;" title="image" src="http://www.cplotts.com/wp-content/uploads/2009/10/image_thumb.png" border="0" alt="image" width="504" height="504" /></a></p>
<p>Woot! Doesn’t it look sweet!</p>
<p>Now, go out and create some logarithmic charts!</p>
<p><strong>p.s.</strong></p>
<p>I have had to make these changes in a <em>local edit</em> of the toolkits. However, as David Anson points out in this <a href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx">post</a> … they are unsealing everything! So, in a little while … you will no longer need to do this. You will be free to simply derive a new axis at your leisure. <strong>In my mind, that is another point for extensibility!</strong></p>
<p><strong>p.s.s.</strong></p>
<p>Here is the <a href="http://www.cplotts.com/wp-content/uploads/2009/10/WPFSLDataVisualization.zip">source code</a> for this article &#8230; note that it contains <a href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx">David Anson&#8217;s development release version 1</a> &#8230; and it contains his DataVisualizationDemos applications. Finally, and most importantly for this article, it contains the sample code for the above &#8230; under the title <strong>Visibility</strong> (I was working on some DataPoint visibility functionality at the time I drafted up that test harness).</p>
<p><strong>p.s.s.s.</strong></p>
<p>David Anson and the fellows at Microsoft have finally released the version of the Silverlight Toolkit that unseals everything. Check out this blog <a href="http://blogs.msdn.com/delay/archive/2009/10/19/silverlight-and-wpf-data-visualization-classes-unsealed-silverlight-toolkit-october-2009-release-now-available.aspx">post</a> for more info. When David publishes another development release, I’ll update the source code for this article so that the above is not a local edit.</p>
<p><strong>p.s.s.s.s.</strong></p>
<p>I have finally gotten around to getting the source code together where the above logarithmic axis is just an extension of toolkit … versus the local edit as before. So, here is that <a href="http://www.cplotts.com/wp-content/uploads/2010/01/DataVisualizationDemos.zip">source code</a>. It is actually from David Anson’s <a href="http://blogs.msdn.com/delay/archive/2009/11/30/two-birds-squared-silverlight-wpf-data-visualization-development-release-3-and-a-datavisualizationdemos-update.aspx">development release 3</a> (although I have stripped out the WPF 4 and Silverlight 4 projects). I won’t remove the above <a href="http://www.cplotts.com/wp-content/uploads/2009/10/WPFSLDataVisualization.zip">source code</a> … as some people might want to see both ways of doing it.</p>
<p>One additional comment. In David’s <a href="http://blogs.msdn.com/delay/archive/2009/10/21/two-birds-one-stone-silverlight-wpf-data-visualization-development-release-2-and-datavisualizationdemos-update.aspx">development release 2</a>, there was an internal NumericAxis constructor. So, even though he <a href="http://blogs.msdn.com/delay/archive/2009/10/19/silverlight-and-wpf-data-visualization-classes-unsealed-silverlight-toolkit-october-2009-release-now-available.aspx">unsealed</a> everything, that internal constructor was inhibiting me from inheriting a new numeric axis type via an extension. That meant I had to wait till <a href="http://blogs.msdn.com/delay/archive/2009/11/30/two-birds-squared-silverlight-wpf-data-visualization-development-release-3-and-a-datavisualizationdemos-update.aspx">development release 3</a> in order to provide this code. (I also had to find some time too. <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> )</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share/Save</a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2009/10/09/wpf-silverlight-charting-a-logarithmic-axis/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>WPF Control Development Unleashed</title>
		<link>http://www.cplotts.com/2009/09/25/wpf-control-development-unleashed/</link>
		<comments>http://www.cplotts.com/2009/09/25/wpf-control-development-unleashed/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 01:36:06 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/2009/09/25/wpf-control-development-unleashed/</guid>
		<description><![CDATA[I just received my copy of the masterpiece WPF Control Development Unleashed in the mail. Woohoo! Written by the veritable master Pavan Podila with a little help from Kevin Hoffman, it is sure to be an instant classic. Why is that? Well, WPF is known for its learning curve. In particular, the amount of concepts [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cplotts.com/wp-content/uploads/2009/09/book.jpg"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="book" src="http://www.cplotts.com/wp-content/uploads/2009/09/book_thumb.jpg" border="0" alt="book" width="380" height="492" align="left" /></a></p>
<p>I just received my copy of the masterpiece <em><a href="http://www.amazon.com/WPF-Control-Development-Unleashed-Experiences/dp/0672330334/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1253927604&amp;sr=8-1">WPF Control Development Unleashed</a></em> in the mail. <strong>Woohoo!</strong></p>
<p>Written by the veritable master <a href="http://blog.pixelingene.com/">Pavan Podila</a> with a little help from <a href="http://dotnetaddict.dotnetdevelopersjournal.com/read/poster/87984.htm">Kevin Hoffman</a>, it is sure to be an instant classic.</p>
<p>Why is that?</p>
<p>Well, WPF is known for its learning curve. In particular, the amount of concepts that you have to digest in order to create custom elements and controls … is rather daunting.</p>
<p>This book will ease your journey. Even more, this book will give you the insight and the tricks to deliver compelling user experiences.</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>You know me, the presentation layer is my passion, and in particular, building controls is what I love to do. This book was meant for me. In fact, I was honored to help review a few of the chapters and now that I have it in front of me … I’m going to devour the rest of it. Who knows, maybe I will start up a series of blog posts as I go along.</p>
<p><em>Muhawhahaha! World domination! With this in my hands, the world is mine! All mine!</em></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share/Save</a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2009/09/25/wpf-control-development-unleashed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blend Modes, Part III</title>
		<link>http://www.cplotts.com/2009/06/30/blend-modes-part-iii/</link>
		<comments>http://www.cplotts.com/2009/06/30/blend-modes-part-iii/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 23:57:29 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[Blend Modes]]></category>
		<category><![CDATA[Pixel Shader Effects]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/?p=286</guid>
		<description><![CDATA[After I gave you the blend mode library for both WPF and Silverlight, you thought, “Finally! I can do some really cool stuff … and what’s even better … it will run on the GPU!” Then, you started playing with it a little and you ran into some limitations. In this third blog post in [...]]]></description>
			<content:encoded><![CDATA[<p>After I gave you the blend mode library for both <a href="http://www.cplotts.com/2009/06/17/blend-modes-for-silverlight/">WPF and Silverlight</a>, you thought, “Finally! I can do some really cool stuff … and what’s even better … it will run on the GPU!” Then, you started playing with it a little and you ran into some limitations.</p>
<p>In this third blog post in the series (<a href="http://www.cplotts.com/2009/06/16/blend-modes-part-i/">Part 1</a> and <a href="http://www.cplotts.com/2009/06/16/blend-modes-part-ii/">Part 2</a>), I will explore these limitations and show you how you can use <a href="http://jmorrill.hjtcentral.com/">Jeremiah Morrill’s</a> <strong><a href="http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/403/Glass-Behavior-for-WPF.aspx">GlassBehavior</a></strong> (which with his permission I have renamed to <strong>BackgroundEffectBehavior</strong>) to get around some of them.</p>
<p>Let’s jump in.</p>
<p>Sometimes you’ll have two images of the exact same size that you want to blend together using one of the blend modes in my library. That is:</p>
<pre class="brush: xml;">&lt;!-- Blending Two Images Together --&gt;
&lt;Image
    Grid.Column="2"
    Width="325"
    Height="244"
    Source="Resources/summer_325x244.jpg"
&gt;
    &lt;Image.Effect&gt;
        &lt;bme:PhoenixEffect&gt;
            &lt;bme:PhoenixEffect.BInput&gt;
                &lt;ImageBrush ImageSource="Resources/fall_325x244.jpg"/&gt;
            &lt;/bme:PhoenixEffect.BInput&gt;
        &lt;/bme:PhoenixEffect&gt;
    &lt;/Image.Effect&gt;
&lt;/Image&gt;</pre>
<p>The above is easy. As you can see, you just choose one of the images and set the blend mode effect on it. This actually causes that image to become the ‘A’ input (remember: A + B = R). Then, you simply set the ‘B’ input of the blend mode effect to the second image.</p>
<p>But it isn’t always that easy, is it?!</p>
<p>Many times when a designer is thinking of blend modes they aren’t thinking “Ok, I have two images and I want to blend those together.” They often are thinking, “I have this shape and I want to blend it into its background using a cool blend mode.”</p>
<p>Take a look at the following. Here I have a shape, a gray (#FF808080) ‘H’, on top of an image:</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/07/HOnImage600.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="HOnImage600" src="http://www.cplotts.com/wp-content/uploads/2009/07/HOnImage600_thumb.png" border="0" alt="HOnImage600" width="604" height="379" /></a></p>
<p>And, here I have the gray ‘H’, blended into its background image using the Color Burn blend mode:</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/07/HOnImageColorBurn600.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="HOnImageColorBurn600" src="http://www.cplotts.com/wp-content/uploads/2009/07/HOnImageColorBurn600_thumb.png" border="0" alt="HOnImageColorBurn600" width="604" height="379" /></a></p>
<p>Now, anywhere I move that ‘H’ … it is going to look different because it is being blended into its background, similar, of course, to making a shape transparent (although with different math).</p>
<p>So, how would I do this with the blend mode library that I’ve provided? Well, it would seem easy … and here is a valiant try:</p>
<pre class="brush: xml;">&lt;Grid Width="240" Height="150"&gt;
    &lt;Grid.Resources&gt;
        &lt;SolidColorBrush x:Key="solidColorBrush" Color="#FF808080"/&gt;
        &lt;Path
            x:Key="path"
            Width="168.367"
            Height="152.44"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Stretch="Uniform"
            Data="(removed for clarity)"
            Fill="{DynamicResource solidColorBrush}"
        /&gt;
    &lt;/Grid.Resources&gt;

    &lt;Image
        Source="Resources/MSwanson - Wide - Water 06.jpg"
        Stretch="Uniform"
    &gt;
        &lt;Image.Effect&gt;
            &lt;bme:ColorBurnEffect&gt;
                &lt;bme:ColorBurnEffect.BInput&gt;
                    &lt;VisualBrush Visual="{StaticResource path}"/&gt;
                &lt;/bme:ColorBurnEffect.BInput&gt;
            &lt;/bme:ColorBurnEffect&gt;
        &lt;/Image.Effect&gt;
    &lt;/Image&gt;
&lt;/Grid&gt;</pre>
<p>In the above, I am using the Image as the ‘A’ input and then passing the shape (Path) in as a VisualBrush for the ‘B’ input on the color burn blend mode effect. Here is what happens, though:</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/07/HOnImageColorBurn600NoCigar.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="HOnImageColorBurn600NoCigar" src="http://www.cplotts.com/wp-content/uploads/2009/07/HOnImageColorBurn600NoCigar_thumb.png" border="0" alt="HOnImageColorBurn600NoCigar" width="604" height="379" /></a></p>
<p>What is going on? Well, if you recall from <a href="http://blogs.msdn.com/greg_schechter/default.aspx">Greg Schlecter’s</a> series (<a href="http://blogs.msdn.com/greg_schechter/archive/2008/09/16/introducing-multi-input-shader-effects.aspx">1</a> and <a href="http://blogs.msdn.com/greg_schechter/archive/2008/09/27/a-more-useful-multi-input-effect.aspx">2</a>) on multi-input pixel shader effects (which is how the blend modes are implemented), the inputs have to be either a VisualBrush or an ImageBrush and the inputs have to be the same size. If they are not, the second input is resized to match the first input.</p>
<p>So, our ‘H’ path is getting sized bigger to match the image’s size and the parts outside of the path are taking part in the blending that is occurring (i.e. the dark areas outside the ‘H’) as well.</p>
<p>Greg Schlecter suggests (in the aforementioned articles) how you can solve the ‘resizing’ issue … by using the Viewbox property on the brush.</p>
<p>But, let’s take a step back here. Do we really want to apply the blend mode effect to the background? No, we don’t, as that would limit us to having only one effect per background. For that matter, it is also not very intuitive as you typically think of blending the shape into the background which suggests that it makes more sense to apply effect to the shape.</p>
<p>While thinking about how to solve this problem, I ran into this WPF forum <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2502892a-eab9-4731-8af5-55dcdbd85850">post</a>. I first thought, “Oh, no! I’m up a creek without a paddle.” But, then I dove in on Jeremiah Morrill’s GlassBehavior … and got it too work (at least for certain situations)!</p>
<p>(I’m not going to cover behaviors in this blog post, but they are basically something new with Expression Blend 3.x. They are an implementation of the attached property behavior pattern and allow the designer inside of Blend to drag and drop behaviors onto elements in the element tree. See <a href="http://blogs.msdn.com/expression/archive/2009/03/23/an-introduction-to-behaviors-triggers-and-actions.aspx">here</a> and <a href="http://blogs.msdn.com/johngossman/archive/2008/05/07/the-attached-behavior-pattern.aspx">here</a> for more info.)</p>
<p>Jeremiah’s GlassBehavior is a behavior that let’s you apply an effect to the background underneath the element that you are attaching the behavior to. He uses it to apply a SmoothMagnifyEffect (to get a glass like appearance) … but you can really use it to apply <strong>any </strong>effect. And that is just what I did.</p>
<p>Take a look at this xaml:</p>
<pre class="brush: xml;">&lt;Grid&gt;
    &lt;Grid x:Name="grid"&gt;
        &lt;Image
            x:Name="image"
            Source="Resources/MSwanson - Wide - Water 06.jpg"
            Stretch="Uniform"
        /&gt;
    &lt;/Grid&gt;
    &lt;Canvas Width="168.367" Height="152.44"&gt;
        &lt;Path
            Width="168.367"
            Height="152.44"
            Stretch="Uniform"
            Data="(removed for clarity)"
            Fill="{StaticResource solidColorBrush}"
        &gt;
            &lt;i:Interaction.Behaviors&gt;
                &lt;local:BackgroundEffectBehavior
                    Visual="{Binding ElementName=grid, Mode=OneWay}"
                &gt;
                    &lt;local:BackgroundEffectBehavior.Effect&gt;
                        &lt;bme:ColorBurnEffect&gt;
                            &lt;bme:ColorBurnEffect.BInput&gt;
                                &lt;ImageBrush&gt;
                                &lt;ImageBrush.ImageSource&gt;
                                &lt;DrawingImage&gt;
                                &lt;DrawingImage.Drawing&gt;

                                &lt;GeometryDrawing
                                    Brush="{StaticResource solidColorBrush}"
                                &gt;
                                    &lt;GeometryDrawing.Geometry&gt;
                                        &lt;RectangleGeometry Rect="0,0,1,1"/&gt;
                                    &lt;/GeometryDrawing.Geometry&gt;
                                &lt;/GeometryDrawing&gt;

                                &lt;/DrawingImage.Drawing&gt;
                                &lt;/DrawingImage&gt;
                                &lt;/ImageBrush.ImageSource&gt;
                                &lt;/ImageBrush&gt;
                            &lt;/bme:ColorBurnEffect.BInput&gt;
                        &lt;/bme:ColorBurnEffect&gt;
                    &lt;/local:BackgroundEffectBehavior.Effect&gt;
                &lt;/local:BackgroundEffectBehavior&gt;
            &lt;/i:Interaction.Behaviors&gt;
        &lt;/Path&gt;
    &lt;/Canvas&gt;
&lt;/Grid&gt;</pre>
<p>First of all, notice how the BackgroundEffectBehavior attaches to the Path through the attached property collection i:Interaction.Behaviors. This is how the behavior hooks its functionality into Path.</p>
<p>The BackgroundEffectBehavior’s Visual is set to the background (the grid which is holding the image) … and the BackgroundEffectBehavior’s Effect is set to the ColorBurnEffect which has a SolidColorBrush as its ‘B’ input. I also have the same SolidColorBrush set as the Fill of the Path … but this is just so that I can see it in the designer … as at runtime … this behavior kicks in and that Fill is not used.</p>
<p>This is what we get from the xaml above … but basically … success! <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/07/HOnImageColorBurn600Success.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="HOnImageColorBurn600Success" src="http://www.cplotts.com/wp-content/uploads/2009/07/HOnImageColorBurn600Success_thumb.png" border="0" alt="HOnImageColorBurn600Success" width="604" height="379" /></a></p>
<p>Now, a few caveats. <img src='http://www.cplotts.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  This whole thing seems to be very fragile.</p>
<p>For example, in order to get this to work, I had to put the image inside the grid … as a sibling to the Canvas that contains the ‘H’ path. Certain other ways of doing it didn’t work. For example, if I set the BackgroundEffectBehavior’s Visual to the grid which contains both the grid/image and the ‘H’ path … it doesn’t work.</p>
<p>Also, if you change the StaticResource(s) to DynamicResource(s) … it doesn’t work.</p>
<p>Another issue is that using this behavior inside of Blend … does not result in what-you-see-is-what-you-get (WYSIWYG) blending. That is why I also set the Fill of the Path above to the same SolidColorBrush that I used as my ‘B’ input to the color burn blend mode effect. In that way, at least, I can see the &#8216;H’ inside of Blend.</p>
<p>Finally, I have not done any performance analysis (yet) of this, but the BackgroundEffectBehavior uses two VisualBrush(es) to get its job done. So, if you use a lot of these, I wouldn’t be surprised if it starts slowing stuff down.</p>
<p>The best solution here, is really for Microsoft to bake blend modes into the platform. Unfortunately, blend modes will not be in next release of WPF (.NET 4.x) … but the good news is that Brendan Clark from Microsoft <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2502892a-eab9-4731-8af5-55dcdbd85850">says</a> he’s pushing for it.</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/07/WPFSLBlendModeFx.zip">Here</a> is the code. Unfortunately, the BackgroundEffectBehavior is WPF-only right now (I hope to fix this), but I have updated the Silverlight test harness to have the gradient and image test harnesses. Enjoy!</p>
<p><a href="http://www.cplotts.com/BlendModeEffectTestHarness/Default.html">Here</a> is a live Silverlight 3 test harness (you will need the Silverlight 3.0 runtime, 3.0.40624).</p>
<p><a href="http://www.cplotts.com/wp-content/uploads/2009/07/HelloWorldColorBurn600.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="HelloWorldColorBurn600" src="http://www.cplotts.com/wp-content/uploads/2009/07/HelloWorldColorBurn600_thumb.png" border="0" alt="HelloWorldColorBurn600" width="604" height="379" /></a></p>
<p>p.s. I just want to give a shout-out to <a href="http://blogs.msdn.com/mswanson/">Mike Swanson</a> and his <a href="http://blogs.msdn.com/mswanson/articles/wallpaper.aspx">wallpaper images</a>. They rock. Period. The water droplet background I am using above is one of his.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share/Save</a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2009/06/30/blend-modes-part-iii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
