<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Pixel in Gene</title><link>http://blog.pixelingene.com</link><description>Exploring creativity with Design / Graphics / Technology</description><language>en</language><lastBuildDate>Wed, 24 Jun 2009 09:06:26 PDT</lastBuildDate><generator>http://wordpress.org/?v=2.8.1</generator><sy:updatePeriod xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">hourly</sy:updatePeriod><sy:updateFrequency xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">1</sy:updateFrequency><creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Pixel-In-Gene" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>A SilverLight TreeMap control</title><link>http://feedproxy.google.com/~r/Pixel-In-Gene/~3/bVgbD40BX8k/</link><category>SilverLight</category><category>custom-control</category><category>treemap</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pavan Podila</dc:creator><pubDate>Sat, 20 Jun 2009 13:50:11 PDT</pubDate><guid isPermaLink="false">http://blog.pixelingene.com/?p=432</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Treemapping">Treemaps</a> are space-filling visualizations of hierarchical data. Each node in the Treemap is represented as a rectangle, whose size depends on some attribute of the data. For example, if&#160; I am representing the high-volume trades in a day, I could have a Treemap that shows different sized rectangles based on the volume of each trade. Larger rectangles will represent the large trades and smaller rectangles, the not so large trades. The most popular of the treemap implementations use a squarified treemap algorithm that produces more squarish rectangles, resulting in better aspect ratios.</p>
<p>&#160;<img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/06/image2.png" width="400" height="286" /> </p>
<p>In my current SilverLight project we required a variety of features that were not present in any of the online implementations. Features like multi-level treemaps, zooming, progressive reveal of information, selection events, filtering, dynamic views, etc were something we found missing in existing implementations. We wanted a single control that had all of these features. Instead of starting from scratch we took inspiration from the following places:</p>
<ul>
<li><a href="http://treemap.codeplex.com/">SilverLight Treemap on CodePlex</a> </li>
<li><a href="http://visitmix.com/Lab/Descry#visuals">Descry</a> </li>
<li><a href="http://blogs.msdn.com/gpde/pages/silverlight-treemap-control.aspx">Treemap by the Microsoft GPDE team</a> </li>
</ul>
<p>&#160;<strong>A new custom control: TreeMapView</strong></p>
<p>TreeMapView is the custom control I built that has many of the features mentioned earlier. Its built in SilverLight 3 and as expected does a lot of stuff via data-binding. It uses Visual State Manager (VSM) extensively for showing state changes and animating transitions. Some of the common features include:</p>
<p><strong>Multi-level hierarchies: </strong>It can represent multiple levels of hierarchy, so you can visualize treemaps within treemaps! The figure below shows three levels of treemaps.&#160; </p>
<p>&#160; <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="multi-level" border="0" alt="multi-level" src="http://blog.pixelingene.com/wp-content/uploads/2009/06/multilevel.jpg" width="400" height="286" /> </p>
<p><strong>Fine grained styling: </strong>One can style the root nodes, internal nodes and leaf nodes separately. It is very common to use a different style for the root level nodes, since you want them to stand out when you first see the map. Similarly, the leaf nodes require special visual treatment which is supported. </p>
<p><strong>Drill downs: </strong>It is impossible to show every level legibly in one view but drill-downs make this easier. You can click and go deeper into the hierarchy and see more detail as you drill in. This is the notion of progressive reveal, which is taken care using special states. You can style the progressive reveal using VSM, giving you have complete power in choosing how and what to style and show (reveal). </p>
<p><strong>Breadcrumb trail: </strong>The breadcrumb trail is useful when you are doing drill downs. The TreeMapView publishes a list of items indicating the path along a subtree. This path changes as you drill in/out. You can style this path and provide navigation support for your drill downs. </p>
<p><strong>Filters: </strong>When viewing large datasets, filters make it easier to hone into the stuff you are interested. Again, the filtered state of the treemap can by stylized using VSM. The figure below shows one possible way of styling filtered items. Colored items are the ones that match the criteria.</p>
<p><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://blog.pixelingene.com/wp-content/uploads/2009/06/image.png" width="400" height="284" /> </p>
<p><strong>Dynamic views: </strong>A treemap sizes the boxes based on some attribute of the data. You can change this attribute on the fly (by bindings) and see different views of the data. Quickly switching between different views gives you a better perspective of the kind of the data you are visualizing. </p>
<p><strong>Coloring the tiles: </strong>This is a primary requirement of any treemap control. The color of a box indicates the weight of some attribute. You have complete control over this using bindings and converters. You can bind to the attribute you want to use for coloring the tile and use a converter to provide the different colors. </p>
<p><strong>Virtualization: </strong>As you start visualizing large datasets, you cannot afford to create controls for every item. Virtualization helps in reducing the number of controls and improves the performance for this scenario. Since custom virtualization is not supported natively in SilverLight, I had to write my own version based on my experience with WPF. In principle it is similar to Deep Zoom. </p>
<p><strong>Mouse hovers: </strong>Hovers can be styled using ToolTips </p>
<p><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://blog.pixelingene.com/wp-content/uploads/2009/06/image1.png" width="449" height="289" /> </p>
<p><strong>Selections: </strong>You can click a tile to select it, which automatically updates the SelectedItem property and also raises the SelectionChanged event. Selections can be styled via VSM. </p>
<p>&#160;</p>
<p><strong>Usage</strong></p>
<p>The programming model is fairly straightforward and using it is also simple. Here is a Xaml snippet that shows the usage:</p>
<pre class="code">        <span style="color: blue">&lt;</span><span style="color: #a31515">Controls1</span><span style="color: blue">:</span><span style="color: #a31515">TreeMapView </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;TM&quot;
                               </span><span style="color: red">Controls</span><span style="color: blue">:</span><span style="color: red">DockPanel.Dock</span><span style="color: blue">=&quot;Left&quot;
                               </span><span style="color: red">SizeBinding</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">Quantity</span><span style="color: blue">}&quot;
                               </span><span style="color: red">HeaderBinding</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">Name</span><span style="color: blue">}&quot;
                               </span><span style="color: red">ColorBinding</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">Status</span><span style="color: blue">, </span><span style="color: red">Converter</span><span style="color: blue">={</span><span style="color: #a31515">StaticResource </span><span style="color: red">Converter</span><span style="color: blue">}}&quot;
                               </span><span style="color: red">ItemsSource</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">Traders</span><span style="color: blue">}&quot;
                               </span><span style="color: red">ChildItemsSourceBinding</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">ChildTraders</span><span style="color: blue">}&quot;
                               </span><span style="color: red">ItemStyle</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">DefaultItemStyle</span><span style="color: blue">}&quot;
                               </span><span style="color: red">ContainerStyle</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">DefaultItemStyle</span><span style="color: blue">}&quot;
                               </span><span style="color: red">RootContainerStyle</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">DefaultItemStyle</span><span style="color: blue">}&quot;
                               /&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<p>The TreeMapView creates instances of <strong>TreeMapTile </strong>for each item in a level. TreeMapTiles can contain child tiles to give you the nested view. The <strong>ChildItemsSourceBinding </strong>property of the TreeMapView can be used to create nested levels. <strong>SizeBinding </strong>is used to size the tiles and <strong>ColorBinding </strong>determines the color of each tile. Typically you would use the ColorBinding with a converter to map the data to a brush. <strong>ItemStyle </strong>is the style used for leaf tiles. <strong>ContainerStyle </strong>is for internal nodes and <strong>RootContainerStyle </strong>is for the top level tiles.</p>
<p><strong>Video</strong>&#160;</p>
<p>Here is a quick video showing all of these features in action:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:d0984137-4e3c-4faa-bd14-fc4efe778b56" class="wlWriterEditableSmartContent">
<div><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/W-EOpJ9Jlc8&amp;hl=en"></param><embed src="http://www.youtube.com/v/W-EOpJ9Jlc8&amp;hl=en" type="application/x-shockwave-flash" width="425" height="355"></embed></object></div>
</div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=bVgbD40BX8k:MP7efMJ70g0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=bVgbD40BX8k:MP7efMJ70g0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=bVgbD40BX8k:MP7efMJ70g0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=bVgbD40BX8k:MP7efMJ70g0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=bVgbD40BX8k:MP7efMJ70g0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=bVgbD40BX8k:MP7efMJ70g0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=bVgbD40BX8k:MP7efMJ70g0:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Pixel-In-Gene/~4/bVgbD40BX8k" height="1" width="1"/>]]></content:encoded><description>Treemaps are space-filling visualizations of hierarchical data. Each node in the Treemap is represented as a rectangle, whose size depends on some attribute of the data. For example, if&amp;#160; I am representing the high-volume trades in a day, I could have a Treemap that shows different sized rectangles based on the volume of each trade. [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blog.pixelingene.com/?feed=rss2&amp;p=432</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">3</slash:comments><feedburner:origLink>http://blog.pixelingene.com/?p=432</feedburner:origLink></item><item><title>Using Attached Properties for view transitions, the ViewManager</title><link>http://feedproxy.google.com/~r/Pixel-In-Gene/~3/6QyC8_F2UhM/</link><category>WPF</category><category>Attached-Properties</category><category>Transitions</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pavan Podila</dc:creator><pubDate>Wed, 15 Apr 2009 08:52:03 PDT</pubDate><guid isPermaLink="false">http://blog.pixelingene.com/?p=422</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Attached Properties is a wonderful feature of WPF and I find myself using it in a variety of scenarios. The most recent one has to do with view-management and transitions. The app that I was building has many visual parts that can be swapped out and replaced with something else. Each part is actually a UserControl, also called the view. To make things interesting, the actual swap happens with a transition, using the <a href="http://blog.pixelingene.com/?p=330">TransitionPresenter</a> from the <a href="http://www.codeplex.com/fluidkit">FluidKit</a> library.</p>
<p>Since there are many such areas in the UI, which have changeable views, there are many TransitionPresenters that act as the containers for the views. Swapping of the views typically happens via user interaction and there is also an action that needs to get invoked whenever a view changes. In the first iteration of my solution, I had some code-behind which would do the view-swap and call an action when the transition completed. It looked something like the snippet below.</p>
<pre class="code"><span style="color: blue">private void </span>ExecuteFlip(<span style="color: blue">object </span>parameter)
{
    <span style="color: blue">string </span>prevFace = (<span style="color: blue">string</span>) parameter;
    <span style="color: blue">string </span>nextFace = <span style="color: blue">string</span>.Empty;

    <span style="color: blue">if </span>(prevFace == <span style="color: #a31515">&quot;Preferences&quot;</span>)
    {
        _flipTransition.Rotation = Direction.RightToLeft;
        nextFace = <span style="color: #a31515">&quot;Main&quot;</span>;
    }
    <span style="color: blue">else if </span>(prevFace == <span style="color: #a31515">&quot;Main&quot;</span>)
    {
        _flipTransition.Rotation = Direction.LeftToRight;
        nextFace = <span style="color: #a31515">&quot;Preferences&quot;</span>;
    }

    <span style="color: #2b91af">EventHandler </span>handler = <span style="color: blue">null</span>;
    handler = <span style="color: blue">delegate
                  </span>{
                      _transContainer.TransitionCompleted -= handler;
                      <span style="color: green">/* Do some action */
                  </span>};
    _transContainer.TransitionCompleted += handler;
    _transContainer.ApplyTransition(prevFace, nextFace);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>ExecuteFlip is called on some user-interaction, generally via a command invoked on a button-click. Depending on the parameter (which is the current view-name) I decide what should be the next view and also adjust the transition to use. Before invoking the transition, I attach an event-handler for the TransitionPresenter’s TransitionCompleted event. This is needed to invoke some actions after the transition completes.</p>
<p>As you can see, for a UI that has many such TransitionPresenters, the code-behind can get pretty repetitive and messy. It’s too much duplication and can easily overwhelm anyone maintaining this code. Fortunately, attached properties come to the rescue.</p>
<p><strong>The need for a ViewManager</strong></p>
<p>To simplify this process of invoking a transition, attaching to the TransitionCompleted event and doing some post-transition action, I have come up with the static ViewManager class that exposes a single attached property called ViewName (of type string). Within the property changed handler for this atttached property, I discover the parent TransitionPresenter and cache in a Dictionary. The Dictionary is just a map of view-name to TransitionPresenter. Here is the code that shows all of these pieces.</p>
<pre class="code"><span style="color: blue">private static </span><span style="color: #2b91af">Dictionary</span>&lt;<span style="color: blue">string</span>, <span style="color: #2b91af">TransitionPresenter</span>&gt; _mapper;

<span style="color: blue">public static readonly </span><span style="color: #2b91af">DependencyProperty </span>ViewNameProperty = <span style="color: #2b91af">DependencyProperty</span>.RegisterAttached(
    <span style="color: #a31515">&quot;ViewName&quot;</span>, <span style="color: blue">typeof </span>(<span style="color: blue">string</span>), <span style="color: blue">typeof </span>(<span style="color: #2b91af">ViewManager</span>), <span style="color: blue">new </span><span style="color: #2b91af">PropertyMetadata</span>(OnViewNameChanged));

<span style="color: blue">static </span>ViewManager()
{
    _mapper = <span style="color: blue">new </span><span style="color: #2b91af">Dictionary</span>&lt;<span style="color: blue">string</span>, <span style="color: #2b91af">TransitionPresenter</span>&gt;();
}

<span style="color: blue">public static void </span>SetViewName(<span style="color: #2b91af">DependencyObject </span>d, <span style="color: blue">string </span>name)
{
    d.SetValue(ViewNameProperty, name);
}

<span style="color: blue">private static void </span>OnViewNameChanged(<span style="color: #2b91af">DependencyObject </span>d, <span style="color: #2b91af">DependencyPropertyChangedEventArgs </span>e)
{
    <span style="color: #2b91af">UserControl </span>view = d <span style="color: blue">as </span><span style="color: #2b91af">UserControl</span>;
    <span style="color: blue">if </span>(view == <span style="color: blue">null</span>) <span style="color: blue">throw new </span><span style="color: #2b91af">ArgumentException</span>(<span style="color: #a31515">&quot;The ViewManager.ViewName attached can only be used on a UserControl&quot;</span>);

    <span style="color: blue">string </span>viewName = (<span style="color: blue">string</span>) e.NewValue;
    <span style="color: blue">if </span>(<span style="color: blue">string</span>.IsNullOrEmpty(viewName)) <span style="color: blue">throw new </span><span style="color: #2b91af">ArgumentException</span>(<span style="color: #a31515">&quot;ViewName cannot be null or empty&quot;</span>);

    view.Loaded += FindTransitionPresenter;
}

<span style="color: blue">private static void </span>FindTransitionPresenter(<span style="color: blue">object </span>sender, <span style="color: #2b91af">RoutedEventArgs </span>e)
{
    <span style="color: #2b91af">UserControl </span>view = (<span style="color: #2b91af">UserControl</span>) sender;
    view.Loaded -= FindTransitionPresenter;

    <span style="color: #2b91af">DependencyObject </span>parent = <span style="color: #2b91af">VisualTreeHelper</span>.GetParent(view);
    <span style="color: blue">while </span>(parent != <span style="color: blue">null </span>&amp;&amp; !(parent <span style="color: blue">is </span><span style="color: #2b91af">TransitionPresenter</span>))
    {
        parent = <span style="color: #2b91af">VisualTreeHelper</span>.GetParent(parent);
    }

    <span style="color: blue">if </span>(parent == <span style="color: blue">null</span>)
    {
        <span style="color: blue">throw new </span><span style="color: #2b91af">Exception</span>(<span style="color: #a31515">&quot;Could not find a TransitionPresenter in the parent chain of view&quot;</span>);
    }
    <span style="color: #2b91af">TransitionPresenter </span>presenter = (<span style="color: #2b91af">TransitionPresenter</span>) parent;
    <span style="color: blue">string </span>viewName = (<span style="color: blue">string</span>)view.GetValue(ViewNameProperty);
    _mapper.Add(viewName, presenter);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a><br />
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>The interesting part here is the fact that I hook into the view’s (UserControl) Loaded event to discover the TransitionPresenter. The Loaded event is fired when WPF has created the visual tree and run a first pass of layout and rendering. Hooking into this event gives us a safe way to navigate the visual tree. The actual discovery of the TransitionPresenter happens in the FindTransitionPresenter method. This method also adds the link between the view-name and the TransitionPresenter and stores it in the map. At the end of this, we have a way to know the TransitionPresenter, given the string view-name.</p>
<p>&#160;<strong>Time for transition</strong></p>
<p>Before we can invoke the transition, we need to associate the ViewName attached property to all of our views. Additionally these views need to be nested inside a TransitionPresenter, since we check for that in the FindTransitionPresenter method. Here is a snippet of adding this attached property:</p>
<pre class="code">        <span style="color: blue">&lt;</span><span style="color: #a31515">Controls</span><span style="color: blue">:</span><span style="color: #a31515">TransitionPresenter </span><span style="color: red">Transition</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">FlipTransition</span><span style="color: blue">}&quot;
                                      </span><span style="color: red">Focusable</span><span style="color: blue">=&quot;False&quot;
                                      </span><span style="color: red">KeyboardNavigation.IsTabStop</span><span style="color: blue">=&quot;False&quot;&gt;
            &lt;</span><span style="color: #a31515">Views</span><span style="color: blue">:</span><span style="color: #a31515">PreferencesView </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;Preferences&quot;
                                   </span><span style="color: red">Controls1</span><span style="color: blue">:</span><span style="color: red">ViewManager.ViewName</span><span style="color: blue">=&quot;Preferences&quot; /&gt;
            &lt;</span><span style="color: #a31515">Views</span><span style="color: blue">:</span><span style="color: #a31515">MainView </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;Main&quot;
                            </span><span style="color: red">Controls1</span><span style="color: blue">:</span><span style="color: red">ViewManager.ViewName</span><span style="color: blue">=&quot;Main&quot; /&gt;
        &lt;/</span><span style="color: #a31515">Controls</span><span style="color: blue">:</span><span style="color: #a31515">TransitionPresenter</span><span style="color: blue">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>With that done, we are now in a position to actually invoke the transitions and to do that we have the ViewManager.SwitchView method. Since for a transition you need two views, SwitchView takes the view-names as its parameters. We actually have three different overloads of this method:</p>
<pre class="code"><span style="color: blue">public static void </span>SwitchView(<span style="color: blue">string </span>fromView, <span style="color: blue">string </span>toView)

<span style="color: blue">public static void </span>SwitchView(<span style="color: blue">string </span>fromView, <span style="color: blue">string </span>toView, <span style="color: #2b91af">Action </span>onViewSwitchCompleted)

<span style="color: blue">public static void </span>SwitchView(<span style="color: blue">string </span>fromView, <span style="color: blue">string </span>toView, <span style="color: #2b91af">Action </span>onViewSwitchCompleted, <span style="color: #2b91af">Action</span>&lt;<span style="color: #2b91af">TransitionPresenter</span>&gt; configure)</pre>
<p><a href="http://11011.net/software/vspaste"></a><br />
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>The first overload should be obvious, it does a simple transition between the views and nothing more. The second overload gives you a callback method that will be invoked once the transition is complete. The last overload gives you the additional capability to configure your TransitionPresenter before the transition happens. I have used this overload to change the transition for some views. Now lets look at the SwitchView method. I am just showing the third overload, as the other two just call into it.</p>
<pre class="code"><span style="color: blue">public static void </span>SwitchView(<span style="color: blue">string </span>fromView, <span style="color: blue">string </span>toView, <span style="color: #2b91af">Action </span>onViewSwitchCompleted, <span style="color: #2b91af">Action</span>&lt;<span style="color: #2b91af">TransitionPresenter</span>&gt; configure)
{
    <span style="color: #2b91af">TransitionPresenter </span>fromTP = _mapper[fromView];
    <span style="color: #2b91af">TransitionPresenter </span>toTP = _mapper[toView];

    <span style="color: blue">if </span>(fromTP != toTP) <span style="color: blue">throw new </span><span style="color: #2b91af">Exception</span>(<span style="color: #a31515">&quot;TransitionPresenters of From and To views don't match&quot;</span>);

    <span style="color: #2b91af">EventHandler </span>handler = <span style="color: blue">null</span>;
    handler = <span style="color: blue">delegate
    </span>{
        fromTP.TransitionCompleted -= handler;

        <span style="color: blue">if </span>(onViewSwitchCompleted != <span style="color: blue">null</span>)
        {
            onViewSwitchCompleted();
        }
    };
    fromTP.TransitionCompleted += handler;

    <span style="color: blue">if </span>(configure != <span style="color: blue">null</span>)
    {
        configure(fromTP);
    }
    fromTP.ApplyTransition(fromView, toView);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>The code here checks if the two views share the same TransitionPresenter and throws an exception otherwise. It then hooks into the TransitionCompleted event and fires the callback when the transition completes. It also calls the configure callback to do any pre-transition configuration on the TransitionPresenter. You can see how the boilerplate code from the first implementation is nicely wrapped up over here.</p>
<p><strong>Using the ViewManager</strong></p>
<p>If you have already setup the ViewName attached properties, using the ViewManager is as simple as calling SwitchView with the correct view-names. If you have some action to be carried out at the end of the transition, you can also pass in an Action delegate. I use the Action delegate to set focus on some controls or set some UI properties. The ExecuteFlip method that I mentioned earlier now looks like so:</p>
<pre class="code"><span style="color: blue">private void </span>ExecuteFlip(<span style="color: blue">object </span>parameter)
{
    <span style="color: blue">string </span>prevFace = (<span style="color: blue">string</span>) parameter;
    <span style="color: blue">string </span>nextFace = prevFace == <span style="color: #a31515">&quot;Preferences&quot; </span>? <span style="color: #a31515">&quot;Main&quot; </span>: <span style="color: #a31515">&quot;Preferences&quot;</span>;

    <span style="color: #2b91af">Action </span>onSwitch = () =&gt; { <span style="color: green">/* Do some action */ </span>};
    <span style="color: #2b91af">Action</span>&lt;<span style="color: #2b91af">TransitionPresenter</span>&gt; configure = (tp) =&gt;
                                                {
                                                    <span style="color: #2b91af">FlipTransition </span>t = (<span style="color: #2b91af">FlipTransition</span>)tp.Transition;
                                                    t.Rotation = prevFace == <span style="color: #a31515">&quot;Preferences&quot; </span>? <span style="color: #2b91af">Direction</span>.RightToLeft : <span style="color: #2b91af">Direction</span>.LeftToRight;
                                                };
    <span style="color: #2b91af">ViewManager</span>.SwitchView(prevFace, nextFace, onSwitch, configure);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><br />
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><strong>Some Takeaways</strong></p>
<ul>
<li>One can argue that using strings for view-names is not type-safe and should instead be enums. But then you limit yourself to a particular enum-type and need to constantly update it as new views are added. One way to have type safety would be to expose static string constants on your App and use them instead. </li>
<li>You can also have some setup methods on the ViewManager to do any global configuration. You could call this once your main window is loaded. I use it to setup some default durations on all TransitionPresenters. </li>
<li>One big advantage of the ViewManager is that a transition on any part of the UI can be invoked from any other part of the UI. All I need to know are the view-names that are involved in the transition and just call ViewManager.SwitchView. Internally the correct TransitionPresenter is determined and used for the transition. This has been a great feature for me as there are some non-user-events that cause transitions on some views. </li>
</ul>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://blog.pixelingene.com/?p=12" rel="bookmark" title="August 30, 2007">TransitionContainer: Easy transitions between views</a></li>
<li><a href="http://blog.pixelingene.com/?p=396" rel="bookmark" title="April 9, 2009">A Design Pattern for communication between UI and ViewModel</a></li>
<li><a href="http://blog.pixelingene.com/?p=80" rel="bookmark" title="January 28, 2008">How to do Sort / Filter / Group in your custom control</a></li>
<li><a href="http://blog.pixelingene.com/?p=41" rel="bookmark" title="November 20, 2006">Drag &amp; Drop with attached properties &#8211; Part 2</a></li>
<li><a href="http://blog.pixelingene.com/?p=257" rel="bookmark" title="August 27, 2008">Techniques for UI Auditing on WPF apps</a></li>
</ul>
<p><!-- Similar Posts took 112.915 ms --></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=6QyC8_F2UhM:zAhVfkVmTPM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=6QyC8_F2UhM:zAhVfkVmTPM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=6QyC8_F2UhM:zAhVfkVmTPM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=6QyC8_F2UhM:zAhVfkVmTPM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=6QyC8_F2UhM:zAhVfkVmTPM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=6QyC8_F2UhM:zAhVfkVmTPM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=6QyC8_F2UhM:zAhVfkVmTPM:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Pixel-In-Gene/~4/6QyC8_F2UhM" height="1" width="1"/>]]></content:encoded><description>Attached Properties is a wonderful feature of WPF and I find myself using it in a variety of scenarios. The most recent one has to do with view-management and transitions. The app that I was building has many visual parts that can be swapped out and replaced with something else. Each part is actually a [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blog.pixelingene.com/?feed=rss2&amp;p=422</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">3</slash:comments><feedburner:origLink>http://blog.pixelingene.com/?p=422</feedburner:origLink></item><item><title>A Design Pattern for communication between UI and ViewModel</title><link>http://feedproxy.google.com/~r/Pixel-In-Gene/~3/n9Nujxazkj8/</link><category>WPF</category><category>DesignPattern</category><category>ViewModel</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pavan Podila</dc:creator><pubDate>Thu, 09 Apr 2009 10:50:29 PDT</pubDate><guid isPermaLink="false">http://blog.pixelingene.com/?p=396</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>In the app that I am working on right now, there is a particular design pattern that I am using to communicate back and forth with the server side data. The app itself is structured into three distinct pieces:</p>
<ul>
<li>A Service Model (SM), which is essentially a web-service with a bunch of data-contracts </li>
<li>A View Model (VM) which talks to the SM on a background thread and notifies the UI whenever an operation completes. The VM also stores a reference to the Dispatcher, which is used to communicate with the UI </li>
<li>…and finally the UI – the WPF powerhouse </li>
</ul>
<p><strong>A redesign</strong></p>
<p>The first time I designed the communication channel, there were events on the VM that mirrored the operations that were present on the SM. These VM-events were fired on the UI thread using <a href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.begininvoke.aspx">Dispatcher.BeginInvoke</a>. The UI subscribed to all of these events and did some visual changes. This model worked great for the initial set of operations that we had in the SM. As the number of operations grew (currently there are about 8 different ones), I realized that the event model is not scaling well.</p>
<p>Instead of the VM raising an event on the UI thread, I decided to use the power of delegates to automatically invoke them on the UI thread whenever an operation completed. Let me explain this more clearly.</p>
<p>As mentioned earlier, the VM already has a reference to the Dispatcher. Note that when I say the VM has reference to the Dispatcher, it is really the root of the ViewModel, a singleton, that stores the reference to the Dispatcher. Instead of mirrored Service Model events, the VM now exposes methods with an Action delegate as a parameter. Let me show you the most commonly used method, <em>EnqueueTask:</em></p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> EnqueueTask(ServerTaskType task, Action completedUIAction)
{
    <span class="kwrd">if</span> (task == ServerTaskType.Initialize)
    {
    EventHandler&lt;FeedDownloadedEventArgs&gt; handler = <span class="kwrd">null</span>;
    handler = (sender, args) =&gt;
    {
        _controller.HistoryDownloaded -= handler;
        OnHistoryAvailable(args, completedUIAction);
    };
    _controller.HistoryDownloaded += handler;
    _controller.Initialize();
    }
    <span class="kwrd">else</span> <span class="kwrd">if</span> (task == ServerTaskType.Reload)
    {
    EventHandler&lt;FeedDownloadedEventArgs&gt; handler = <span class="kwrd">null</span>;
    handler = (sender, args) =&gt;
    {
        _controller.HistoryDownloaded -= handler;
        OnHistoryAvailable(args, completedUIAction);
    };
    _controller.HistoryDownloaded += handler;

    _controller.ReloadHistory();
    _controller.GetPeerList();
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>The above method does the actual subscription to the Service Model event and also unsubscribes when the operation completes. It then raises the <em>completedUIAction</em> delegate. This action is invoked using Dispatcher.BeginInvoke so it always happens on the UI thread. Here is the <em>OnHistoryAvailable</em> method, which does the job of updating the ViewModel and then calling the action to update the UI (using a custom <em>InvokeOnDispatcher </em>convenience method). Note that we are passing the action delegate to this method.</p>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<pre class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">void</span> OnHistoryAvailable(FeedDownloadedEventArgs e, Action completedAction)
{
    InvokeOnDispatcher(
    <span class="kwrd">delegate</span>
    {
        <span class="rem">// Update the ViewModel </span>
        <span class="rem">// &lt;Code deleted for brevity&gt;</span>

        <span class="rem">// Finally call the completed action, which will update some UI </span>
        <span class="kwrd">if</span> (completedAction != <span class="kwrd">null</span>)
        {
            completedAction();
        }
    });

}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>
  <br /><strong>So what’s the advantage?</strong></p>
<p>Good question! As you can see, I no longer need to expose any further events from the VM, which the UI subscribes to. The event handler code on the UI is now passed in as an Action delegate which the VM nicely calls on the UI thread. Also this technique is scalable to a large number of Service Model events. All I change on my side is the switch case for the operations.</p>
<p>[Currently I am using this technique to show/hide progress bars and other animations. The animation starts before a call to <em>EnqueueTask </em>and stopped in the <em>completedUIAction</em>.]</p>
<p><strong>Possible improvements</strong></p>
<p>If we have a large number of SM-events, we can have a simple mapping table that maps the operation-type to a method on the VM. We can then simply lookup that method from the table and pass it the <em>completedUIAction </em>delegate. This can save us a long switch-case in <em>EnqueueTask</em>.</p>
<p>We can also use generic Action&lt;T&gt; delegates that could be used to pass some state information back to the UI.</p>
<p>Hopefully you will find this technique useful in your own apps !</p>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://blog.pixelingene.com/?p=41" rel="bookmark" title="November 20, 2006">Drag &amp; Drop with attached properties &#8211; Part 2</a></li>
<li><a href="http://blog.pixelingene.com/?p=422" rel="bookmark" title="April 15, 2009">Using Attached Properties for view transitions, the ViewManager</a></li>
<li><a href="http://blog.pixelingene.com/?p=348" rel="bookmark" title="December 30, 2008">Huge limitation of a MarkupExtension</a></li>
<li><a href="http://blog.pixelingene.com/?p=39" rel="bookmark" title="December 6, 2006">Drag &amp; Drop with attached properties &#8211; Part 3</a></li>
<li><a href="http://blog.pixelingene.com/?p=43" rel="bookmark" title="November 15, 2006">Drag &amp; Drop with attached properties</a></li>
</ul>
<p><!-- Similar Posts took 70.593 ms --></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=n9Nujxazkj8:ofHJqrR-_FQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=n9Nujxazkj8:ofHJqrR-_FQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=n9Nujxazkj8:ofHJqrR-_FQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=n9Nujxazkj8:ofHJqrR-_FQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=n9Nujxazkj8:ofHJqrR-_FQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=n9Nujxazkj8:ofHJqrR-_FQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=n9Nujxazkj8:ofHJqrR-_FQ:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Pixel-In-Gene/~4/n9Nujxazkj8" height="1" width="1"/>]]></content:encoded><description>In the app that I am working on right now, there is a particular design pattern that I am using to communicate back and forth with the server side data. The app itself is structured into three distinct pieces:

A Service Model (SM), which is essentially a web-service with a bunch of data-contracts 
A View Model [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blog.pixelingene.com/?feed=rss2&amp;p=396</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">7</slash:comments><feedburner:origLink>http://blog.pixelingene.com/?p=396</feedburner:origLink></item><item><title>Setting up XDebug on NetBeans 6.5 PHP IDE</title><link>http://feedproxy.google.com/~r/Pixel-In-Gene/~3/Djr9310GFw8/</link><category>WordPress</category><category>NetBeans</category><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pavan Podila</dc:creator><pubDate>Sun, 22 Mar 2009 13:35:27 PDT</pubDate><guid isPermaLink="false">http://blog.pixelingene.com/?p=388</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Recently I was doing a bit of PHP development for my blog and playing around with the <a href="http://codex.wordpress.org/Main_Page">WordPress APIs</a>. After spending some time deciding on the IDE to use, I hit upon <a href="http://www.netbeans.org/features/php/index.html">NetBeans 6.5</a>, which I think is an awesome tool for PHP development. It has fantastic auto-completion, syntax-highlighting, code-folding and refactoring support unlike no other PHP IDE. It also has nice debugger support (XDebug) but setting it up can be a pain!</p>
<p>&#160;<img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="363" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/03/image5.png" width="470" border="0" /> </p>
<p>I had lot of trouble making it work with issues like: XDebug not being recognized, Apache webserver crashes, etc. However I finally got it working and below are the steps I took on my Windows Vista machine:</p>
<ul>
<li>If you doing WordPress development, most probably you are using <a href="http://www.apachefriends.org/en/xampp-windows.html">XAMPPLite</a> to run a local webserver. If not, you should definitely get it. The rest of the steps assume that you have XAMPPLite on your machine. </li>
<li>To set up XDebug, first get hold of the latest DLL from the <a href="http://www.xdebug.org/download.php">XDebug website</a>.&#160; The site recommends version <strong>2.0.x for a PHP version of 5.2.x</strong>. At the time of writing this post, I used <strong>php_xdebug-2.0.4-5.2.8.dll</strong> </li>
<li>Edit your <strong>php.ini</strong> file in &lt;xampplite-install-folder&gt;/apache/bin/. Note that you should edit the <strong>php.ini </strong>file in <strong>apache/bin </strong>and <strong>NOT </strong>in &lt;xampplite-install-folder&gt;/php/. This is the biggest mistake most people make, including me. </li>
<li>Add these lines at the end of the .ini file:      <br /> 
<p>[xdebug]        <br />zend_extension_ts=&quot;&lt;xampplie-install-folder&gt;/php/ext/php_xdebug-&lt;version-number&gt;.dll&quot;         <br />xdebug.remote_enable=1         <br />xdebug.remote_host=localhost         <br />xdebug.remote_port=9000         <br />xdebug.remote_handler=dbgp</p>
</li>
<li>Next increase the memory limit of your PHP script to <strong>128M</strong>, by modifying the <strong>memory_limit</strong> variable in php.ini. It is usually around line 246 in that file.       <br /> 
<p>memory_limit = 128M&#160;&#160;&#160;&#160;&#160; ; Maximum amount of memory a script may consume (16MB)</p>
</li>
<li>Save the .ini file and restart the Apache server. I typically do this via the XAMPPLite control panel. </li>
</ul>
<p><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="361" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/03/image7.png" width="454" border="0" /> </p>
</p>
<ul>
<li>Now if you go to <a title="http://localhost/xampp/" href="http://localhost/xampp/">http://localhost/xampp/</a> and click on the phpinfo() link on the left-hand sidebar, you should see a spew of xdebug information. Here is how mine looks: </li>
</ul>
<p><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="405" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/03/image8.png" width="470" border="0" />&#160;&#160; </p>
<ul>
<li>If you see the above in your output, you are all set and XDebug should start working within NetBeans. You can now happily set breakpoints in your script and debug all your PHP worries <img src='http://blog.pixelingene.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </li>
</ul>
<p>&#160;</p>
<p>I hope in the future this process becomes a lot simpler, but until then this post will definitely remain useful!</p>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://blog.pixelingene.com/?p=82" rel="bookmark" title="January 29, 2008">Playing with Wordpress, PHP, Photoshop, CSS, XHTML</a></li>
</ul>
<p><!-- Similar Posts took 44.556 ms --></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=Djr9310GFw8:_jcUcU0bvMU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=Djr9310GFw8:_jcUcU0bvMU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=Djr9310GFw8:_jcUcU0bvMU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=Djr9310GFw8:_jcUcU0bvMU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=Djr9310GFw8:_jcUcU0bvMU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=Djr9310GFw8:_jcUcU0bvMU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=Djr9310GFw8:_jcUcU0bvMU:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Pixel-In-Gene/~4/Djr9310GFw8" height="1" width="1"/>]]></content:encoded><description>Recently I was doing a bit of PHP development for my blog and playing around with the WordPress APIs. After spending some time deciding on the IDE to use, I hit upon NetBeans 6.5, which I think is an awesome tool for PHP development. It has fantastic auto-completion, syntax-highlighting, code-folding and refactoring support unlike no [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blog.pixelingene.com/?feed=rss2&amp;p=388</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">1</slash:comments><feedburner:origLink>http://blog.pixelingene.com/?p=388</feedburner:origLink></item><item><title>Quick update on the WPF Control Development Unleashed book</title><link>http://feedproxy.google.com/~r/Pixel-In-Gene/~3/J8b3qw-46v0/</link><category>Book</category><category>WPF</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pavan Podila</dc:creator><pubDate>Wed, 18 Mar 2009 07:06:47 PDT</pubDate><guid isPermaLink="false">http://blog.pixelingene.com/?p=384</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>As many of you know my co-author <a href="http://dotnetaddict.dotnetdevelopersjournal.com/wpf_control_devunleashed.htm">Kevin Hoffman</a> and I have been quite busy finishing up a book on WPF control development. We have few more chapters to finish and then we will be content ready for tech review. The first half of the book is already done and we are going through the tech review as I write. The tech review phase will add a lot of polish to the book and make it an enjoyable read. I am glad to have a master-writer like Kevin working with me, who is doing the part of “<strong>making it enjoyable</strong>” ! </p>
<p>At the recent MVP Summit, I got a chance to catch up with other MVP buddies who also provided some valuable feedback on the content. Interestingly, my publisher was also at the Summit and it was the first time meeting him. He can be sure now that it is not a robot writing the book.</p>
<p>In the last few weeks, I got emails from many of you asking about the status of the book. I hope this post will tell you that things are moving towards completion. Some of you have offered to review the book, which was quite flattering for me. I will try to reach out to you once I incorporate the feedback from my current reviewers.</p>
<p>If you are curious to know more about the book, try <a href="http://www.amazon.com/WPF-Control-Development-Unleashed-Experiences/dp/0672330334">Amazon</a>. We already have a placeholder for the book! </p>
<p>BTW, this is going to be a full color book with rich set of examples, controls, figures and of course syntax-highlighted code!</p>
<p><a href="http://www.amazon.com/WPF-Control-Development-Unleashed-Experiences/dp/0672330334"><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://blog.pixelingene.com/wp-content/uploads/2009/03/image1.png" width="240" height="240" /></a></p>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://blog.pixelingene.com/?p=218" rel="bookmark" title="July 16, 2008">Working on a Book !</a></li>
<li><a href="http://blog.pixelingene.com/?p=251" rel="bookmark" title="August 2, 2008">Details of my upcoming Book</a></li>
<li><a href="http://blog.pixelingene.com/?p=237" rel="bookmark" title="July 29, 2008">[FluidKit Update] Fixed bugs, added stuff</a></li>
<li><a href="http://blog.pixelingene.com/?p=224" rel="bookmark" title="July 18, 2008">File encodings matter when writing Pixel Shaders</a></li>
<li><a href="http://blog.pixelingene.com/?p=39" rel="bookmark" title="December 6, 2006">Drag &amp; Drop with attached properties &#8211; Part 3</a></li>
</ul>
<p><!-- Similar Posts took 40.273 ms --></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=J8b3qw-46v0:tE-XULCfuRI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=J8b3qw-46v0:tE-XULCfuRI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=J8b3qw-46v0:tE-XULCfuRI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=J8b3qw-46v0:tE-XULCfuRI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=J8b3qw-46v0:tE-XULCfuRI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=J8b3qw-46v0:tE-XULCfuRI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=J8b3qw-46v0:tE-XULCfuRI:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Pixel-In-Gene/~4/J8b3qw-46v0" height="1" width="1"/>]]></content:encoded><description>As many of you know my co-author Kevin Hoffman and I have been quite busy finishing up a book on WPF control development. We have few more chapters to finish and then we will be content ready for tech review. The first half of the book is already done and we are going through the [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blog.pixelingene.com/?feed=rss2&amp;p=384</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">1</slash:comments><feedburner:origLink>http://blog.pixelingene.com/?p=384</feedburner:origLink></item><item><title>I have started tweeting</title><link>http://feedproxy.google.com/~r/Pixel-In-Gene/~3/qYDO78qWZ-A/</link><category>Twitter</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pavan Podila</dc:creator><pubDate>Thu, 05 Mar 2009 07:38:58 PST</pubDate><guid isPermaLink="false">http://blog.pixelingene.com/?p=372</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>I have finally jumped on to Twitter and making sounds (tweets) on <strong><a href="http://twitter.com/pavanpodila">@pavanpodila</a></strong>. So follow me and I’ll follow you <img src='http://blog.pixelingene.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>&#160;</p>
<p> <a href="http://twitter.com/pavanpodila"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="362" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/03/image.png" width="362" border="0" /></a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=qYDO78qWZ-A:e11Kl6E1vmk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=qYDO78qWZ-A:e11Kl6E1vmk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=qYDO78qWZ-A:e11Kl6E1vmk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=qYDO78qWZ-A:e11Kl6E1vmk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=qYDO78qWZ-A:e11Kl6E1vmk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=qYDO78qWZ-A:e11Kl6E1vmk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=qYDO78qWZ-A:e11Kl6E1vmk:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Pixel-In-Gene/~4/qYDO78qWZ-A" height="1" width="1"/>]]></content:encoded><description>I have finally jumped on to Twitter and making sounds (tweets) on @pavanpodila. So follow me and I’ll follow you  
&amp;#160;</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blog.pixelingene.com/?feed=rss2&amp;p=372</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://blog.pixelingene.com/?p=372</feedburner:origLink></item><item><title>Animating graphs in WPF using Clipping masks</title><link>http://feedproxy.google.com/~r/Pixel-In-Gene/~3/7jIZjLc0184/</link><category>Animation</category><category>WPF</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pavan Podila</dc:creator><pubDate>Thu, 26 Feb 2009 13:08:07 PST</pubDate><guid isPermaLink="false">http://blog.pixelingene.com/?p=368</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Over the past couple of weeks I have been working on an application that displays a variety of graphs. One of the standard features we have is the load animation for a graph when the user sees it for the first time. For a line graph, this would mean that the graph animates from the left to right and draws itself out.</p>
<p>&#160;<img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="335" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/02/image.png" width="412" border="0" /> </p>
</p>
<p>The technique I am using to do this animation is with Clipping Masks. The graph starts out with a Rectangular mask with zero-width and ends with the full-width of the graph after the animation completes. The height of the mask is the same as that of the graph. The following figure shows how my mask grows in size.</p>
<p><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="335" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/02/image1.png" width="412" border="0" /> </p>
<p>&#160;</p>
<p>In Xaml, this can look like so:</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">Grid</span> <span class="attr">x:Name</span><span class="kwrd">=&quot;GraphContainer&quot;</span><span class="kwrd">&gt;</span>
<span class="rem">    &lt;!—Line Graph --&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Grid.Clip</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">RectangleGeometry</span> <span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Grid.Clip</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">Grid</span><span class="kwrd">&gt;</span></pre>
<p>&#160;</p>
<p>The above snippet shows the container on which the Clip mask has been applied. The line graph is inside the GraphContainer. The Storyboard looks like:</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">Storyboard</span> <span class="attr">x:Key</span><span class="kwrd">=&quot;GraphClipAnimator&quot;</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">RectAnimation</span> <span class="attr">Duration</span><span class="kwrd">=&quot;0:0:1&quot;</span>
                   <span class="attr">Storyboard</span>.<span class="attr">TargetProperty</span><span class="kwrd">=&quot;Clip.(RectangleGeometry.Rect)&quot;</span>
                   <span class="attr">Storyboard</span>.<span class="attr">TargetName</span><span class="kwrd">=&quot;GraphContainer&quot;</span><span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">Storyboard</span><span class="kwrd">&gt;</span></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>Note the use of RectAnimation for expanding the size of the mask. It starts out with a <strong>Rect(0, 0, 0, GraphContainer.ActualHeight)</strong> and ends with a <strong>Rect(0, 0, GraphContainer.ActualWidth, GraphContainer.ActualHeight)</strong>. We set the From/To values of the RectAnimation inside the Loaded event for the containing Window/UserControl.</p>
<p>&#160;</p>
<p>The advantage of this technique is that you can choose a more elaborate clipping mask (think of arbitrary PathGeometry) to achieve more fluid graph animations. Also we are not affecting the actual graph in any way and all of the animations are happening on its container. This makes it easy to reuse the technique on multiple graphs.</p>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://blog.pixelingene.com/?p=91" rel="bookmark" title="February 8, 2008">Super Fast alternating row colors in a ListBox</a></li>
<li><a href="http://blog.pixelingene.com/?p=12" rel="bookmark" title="August 30, 2007">TransitionContainer: Easy transitions between views</a></li>
<li><a href="http://blog.pixelingene.com/?p=235" rel="bookmark" title="July 28, 2008">Don&rsquo;t forget to pass the Input brush to the Shader</a></li>
<li><a href="http://blog.pixelingene.com/?p=276" rel="bookmark" title="September 23, 2008">Quick tip to get a striped background</a></li>
<li><a href="http://blog.pixelingene.com/?p=172" rel="bookmark" title="April 2, 2008">Automatic form layouts with the TreeView</a></li>
</ul>
<p><!-- Similar Posts took 50.616 ms --></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=7jIZjLc0184:ijC_8R2hHHI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=7jIZjLc0184:ijC_8R2hHHI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=7jIZjLc0184:ijC_8R2hHHI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=7jIZjLc0184:ijC_8R2hHHI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=7jIZjLc0184:ijC_8R2hHHI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Pixel-In-Gene?a=7jIZjLc0184:ijC_8R2hHHI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Pixel-In-Gene?i=7jIZjLc0184:ijC_8R2hHHI:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Pixel-In-Gene/~4/7jIZjLc0184" height="1" width="1"/>]]></content:encoded><description>Over the past couple of weeks I have been working on an application that displays a variety of graphs. One of the standard features we have is the load animation for a graph when the user sees it for the first time. For a line graph, this would mean that the graph animates from the [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blog.pixelingene.com/?feed=rss2&amp;p=368</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">3</slash:comments><feedburner:origLink>http://blog.pixelingene.com/?p=368</feedburner:origLink></item><item><title>A fun After Effects CS4 composition</title><link>http://feedproxy.google.com/~r/Pixel-In-Gene/~3/9KeRQy6nEkM/</link><category>After Effects</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pavan Podila</dc:creator><pubDate>Sat, 24 Jan 2009 18:57:08 PST</pubDate><guid isPermaLink="false">http://blog.pixelingene.com/?p=363</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Last night I was playing around with After Effects CS4 and made this video just for fun. Its nothing fancy, just some 3D shake and some particle effects. Unfortunately I did not save my project so I cannot post the *.aep file. I do have the rendered video, which you can see below. In the future, I will post the project file as well.</p>
<p>&#160;</p>
<div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:3064cb76-fd96-4f06-86ee-9a60d3c09098" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/KwEXnaC6kSo&amp;hl=en"></param><embed src="http://www.youtube.com/v/KwEXnaC6kSo&amp;hl=en" type="application/x-shockwave-flash" width="425" height="355"></embed></object></div>
</div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=7pI9baZk"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?i=7pI9baZk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=gB7On8C3"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=kYCZGqnO"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?i=kYCZGqnO" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=JLvVc9Zu"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?i=JLvVc9Zu" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Pixel-In-Gene/~4/9KeRQy6nEkM" height="1" width="1"/>]]></content:encoded><description>Last night I was playing around with After Effects CS4 and made this video just for fun. Its nothing fancy, just some 3D shake and some particle effects. Unfortunately I did not save my project so I cannot post the *.aep file. I do have the rendered video, which you can see below. In the [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blog.pixelingene.com/?feed=rss2&amp;p=363</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">1</slash:comments><feedburner:origLink>http://blog.pixelingene.com/?p=363</feedburner:origLink></item><item><title>Making dashed lines in Photoshop</title><link>http://feedproxy.google.com/~r/Pixel-In-Gene/~3/J75KTafbopU/</link><category>PhotoShop</category><category>dashed</category><category>lines</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pavan Podila</dc:creator><pubDate>Fri, 23 Jan 2009 18:53:57 PST</pubDate><guid isPermaLink="false">http://blog.pixelingene.com/?p=362</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>This is just a quick post on how to make dashed lines in Photoshop. I am sure many of the designers who are reading this would find it useful. Photoshop by default does not give you any direct way to draw dashed lines. However it has the very powerful brush engine that can do the trick.</p>
<p><strong>Steps</strong></p>
<p>1. Lets start out by picking a <strong>Square brush </strong>shape. We need to reduce the <strong>Roundness </strong>to get the horizontal dash and also increase the <strong>Spacing </strong>to see the spacing between dashes.</p>
<p><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="460" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/01/image1.png" width="377" border="0" /> </p>
<p>2. Now if you notice in the preview area, you will see that the dashes are not oriented along the direction of the curve. This can be easily fixed by going into the <strong>Shape Dynamics </strong>section. Here we change the <strong>Angle Jitter’s</strong> Control to <strong>Direction</strong>. Notice how the preview has changed to align the dashes along the curve.</p>
<p><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="460" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/01/image2.png" width="377" border="0" /> </p>
<p>3. Now if I draw something on my layer with my newly created brush, I get some nice dashed outlines!</p>
<p><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="462" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/01/image3.png" width="379" border="0" /> </p>
<p>&#160;</p>
</p>
<p>I think the best use of such a brush is for shapes like Rectangle, Circle, etc</p>
<p><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="301" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/01/image4.png" width="300" border="0" /></p>
<p>&#160;</p>
<p>Hope you Photoshop-ers find this useful !</p>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://blog.pixelingene.com/?p=82" rel="bookmark" title="January 29, 2008">Playing with Wordpress, PHP, Photoshop, CSS, XHTML</a></li>
<li><a href="http://blog.pixelingene.com/?p=156" rel="bookmark" title="March 30, 2008">My first shot at Wordpress themes</a></li>
</ul>
<p><!-- Similar Posts took 26.675 ms --></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=YTz30YSw"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?i=YTz30YSw" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=R8fPtTNS"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=UHlWFIgc"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?i=UHlWFIgc" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=SMeWRP61"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?i=SMeWRP61" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Pixel-In-Gene/~4/J75KTafbopU" height="1" width="1"/>]]></content:encoded><description>This is just a quick post on how to make dashed lines in Photoshop. I am sure many of the designers who are reading this would find it useful. Photoshop by default does not give you any direct way to draw dashed lines. However it has the very powerful brush engine that can do the [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blog.pixelingene.com/?feed=rss2&amp;p=362</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">2</slash:comments><feedburner:origLink>http://blog.pixelingene.com/?p=362</feedburner:origLink></item><item><title>A tip for referencing Assets in your WPF application</title><link>http://feedproxy.google.com/~r/Pixel-In-Gene/~3/ZkZjaRAOY7k/</link><category>WPF</category><category>Assets</category><category>MarkupExtension</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pavan Podila</dc:creator><pubDate>Mon, 05 Jan 2009 09:12:51 PST</pubDate><guid isPermaLink="false">http://blog.pixelingene.com/?p=352</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Organizing and referencing assets (images, fonts, xaml) has always been an interesting topic of discussion. There is still no proper guidance and is wide open for experimentation.</p>
<p><strong>Organizing assets</strong></p>
<p>If you have few assets, you could just keep them under a folder in your main assembly. However if you have a variety of assets and in large numbers, you are better off keeping them in separate assemblies. Each assembly can now serve as a theme for your application. Within the assembly you could break up your assets into a folder structure. As a simple example, you could have a structure like so:</p>
<p><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="154" alt="image" src="http://blog.pixelingene.com/wp-content/uploads/2009/01/image.png" width="134" border="0" /></p>
<p>You can come up with a more elaborate structure depending on the variety and the number of assets that you have. Since this post is more about referencing assets than organizing them, I am going to jump to that now. I assume you already have a folder structure for your assets that is similar to the one I mentioned above.</p>
<p><strong>Referencing assets</strong></p>
<p>If you are to store your assets in a separate assembly, the referencing Uri can be rather long, something like:</p>
<p><em><span style="color: #804000">pack://application:,,,/Company.ThemeName;component/Images/Icons/Large/up.png</span></em></p>
<p>Try typing few of those Uri’s and I can guarantee the beginnings of a <a href="http://en.wikipedia.org/wiki/Carpal_tunnel_syndrome">Carpal tunnel</a> <img src='http://blog.pixelingene.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> . This is where a MarkupExtension can be very useful. It will abstract out those long paths and only keep the part that is essential. So you could be seeing something like:</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">ImageBrush</span> <span class="attr">x:Key</span><span class="kwrd">=&quot;SelfFill&quot;</span>
            <span class="attr">ImageSource</span><span class="kwrd">=&quot;{ln:Asset Icons/marker/self_fill.png}&quot;</span> <span class="kwrd">/&gt;</span></pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Surely this is more readable than the previous path. If you are a bit more adventurous, you can also add a prefix to the path that will further abstract the actual location of the resource. For example the above MarkupExtension usage could be: {ln:Asset MarkerIcons:self_fill.png}. Note the MarkerIcons: prefix, which will internally map to the <em>Images/Icons/marker</em> path. You can come up with your own prefixes that will simplify the paths, as you see fit for your project.</p>
<p>The AssetExtension class contains the logic to parse the paths and create the appropriate resources. <span class="kwrd">Just like every other MarkupExtension, the </span><span class="kwrd">ProvideValue() method is where the bulk of the logic is. In the case of AssetExtension, there is a Regex that parses the path and identifies the kind of resource we are dealing with.</span></p>
<p><span class="kwrd">Here is the Regex that I am using:</span></p>
<pre class="csharpcode">        <span class="kwrd">private</span> <span class="kwrd">static</span> Regex ResourceRegex = <span class="kwrd">new</span> Regex(
                <span class="str">@&quot;
                        (?&lt;Image&gt;(.png|.jpg|.bmp)$)
                        | (?&lt;Font&gt;#.+$)
                        | (?&lt;Xaml&gt;.xaml$)
                &quot;</span>,
                RegexOptions.Singleline | RegexOptions.Compiled |
        RegexOptions.IgnorePatternWhitespace |
                RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Once we know the resource-type, we create it inside of ProvideValue() and return that as the output. The core methods are below. ResourceType is an enum that I am using internally.</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> Uri GetResourceUri(<span class="kwrd">string</span> path)
{
    <span class="kwrd">string</span> asmName = Assembly.GetExecutingAssembly().GetName().Name;
    <span class="kwrd">string</span> uriString =
     <span class="kwrd">string</span>.Format(<span class="str">&quot;pack://application:,,,/{0};component/{1}&quot;</span>,
                           asmName, path);
    Uri uri = <span class="kwrd">new</span> Uri(uriString);

    <span class="kwrd">return</span> uri;
}

<span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">object</span> ProvideValue(IServiceProvider serviceProvider)
{
    IProvideValueTarget ipvt =
    serviceProvider.GetService(<span class="kwrd">typeof</span> (IProvideValueTarget))
                                           <span class="kwrd">as</span> IProvideValueTarget;
    <span class="kwrd">if</span> (ipvt == <span class="kwrd">null</span>) <span class="kwrd">return</span> <span class="kwrd">null</span>;

    ResourceType type = ParseResourceType(Path);
    <span class="kwrd">switch</span> (type)
    {
        <span class="kwrd">case</span> ResourceType.Image:
            BitmapImage image =
                        <span class="kwrd">new</span> BitmapImage(GetResourceUri(Path));
            <span class="kwrd">return</span> image;

        <span class="kwrd">case</span> ResourceType.Font:
            FontFamily family =
                       <span class="kwrd">new</span> FontFamily(GetResourceUri(<span class="str">&quot;&quot;</span>), Path);
            <span class="kwrd">return</span> family;

        <span class="kwrd">case</span> ResourceType.Xaml:
            <span class="kwrd">return</span> GetResourceUri(Path);
    }

    <span class="kwrd">return</span> <span class="kwrd">null</span>;
}

<span class="kwrd">private</span> ResourceType ParseResourceType(<span class="kwrd">string</span> path)
{
    ResourceType type = ResourceType.None;

    Match match = ResourceRegex.Match(path);
    <span class="kwrd">if</span> (match.Groups[<span class="str">&quot;Image&quot;</span>].Success) type = ResourceType.Image;
    <span class="kwrd">else</span> <span class="kwrd">if</span> (match.Groups[<span class="str">&quot;Font&quot;</span>].Success) type = ResourceType.Font;
    <span class="kwrd">else</span> <span class="kwrd">if</span> (match.Groups[<span class="str">&quot;Xaml&quot;</span>].Success) type = ResourceType.Xaml;

    <span class="kwrd">return</span> type;
}</pre>
<p><strong>Summary</strong></p>
<p>So if you have project that uses a ton of assets, it is probably easier to use a MarkupExtension to reference them instead of hard-coding paths. Besides simplifying the paths, it also helps you in refactoring. If you wish to relocate the assets to a different assembly or change the folder structure, it is much easier now, since you only change the AssetExtension.</p>
<p>The attached source file contains all the code. Note that it does not contain the code for parsing prefixes. I’ll leave that as an exercise for the readers!</p>
<p><a href="http://blog.pixelingene.com/wp-content/uploads/2009/01/assetextension.cs"><img title="down" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="32" alt="down" src="http://blog.pixelingene.com/wp-content/uploads/2009/01/down.png" width="32" border="0" />Download AssetExtension.cs</a></p>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://blog.pixelingene.com/?p=235" rel="bookmark" title="July 28, 2008">Don&rsquo;t forget to pass the Input brush to the Shader</a></li>
<li><a href="http://blog.pixelingene.com/?p=12" rel="bookmark" title="August 30, 2007">TransitionContainer: Easy transitions between views</a></li>
<li><a href="http://blog.pixelingene.com/?p=348" rel="bookmark" title="December 30, 2008">Huge limitation of a MarkupExtension</a></li>
<li><a href="http://blog.pixelingene.com/?p=276" rel="bookmark" title="September 23, 2008">Quick tip to get a striped background</a></li>
<li><a href="http://blog.pixelingene.com/?p=172" rel="bookmark" title="April 2, 2008">Automatic form layouts with the TreeView</a></li>
</ul>
<p><!-- Similar Posts took 95.925 ms --></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=ZMWSzUae"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?i=ZMWSzUae" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=lfN7d1eS"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=gVOb46cW"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?i=gVOb46cW" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Pixel-In-Gene?a=enZF3h8T"><img src="http://feeds.feedburner.com/~f/Pixel-In-Gene?i=enZF3h8T" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Pixel-In-Gene/~4/ZkZjaRAOY7k" height="1" width="1"/>]]></content:encoded><description>Organizing and referencing assets (images, fonts, xaml) has always been an interesting topic of discussion. There is still no proper guidance and is wide open for experimentation.
Organizing assets
If you have few assets, you could just keep them under a folder in your main assembly. However if you have a variety of assets and in large [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blog.pixelingene.com/?feed=rss2&amp;p=352</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">9</slash:comments><feedburner:origLink>http://blog.pixelingene.com/?p=352</feedburner:origLink></item></channel></rss>
