<?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>Mindscape Blog &#187; WPF Diagramming</title> <atom:link href="http://www.mindscape.co.nz/blog/index.php/category/wpf-diagramming/feed/" rel="self" type="application/rss+xml" /><link>http://www.mindscape.co.nz/blog</link> <description>The official blog of Mindscape</description> <lastBuildDate>Tue, 07 Sep 2010 21:57:46 +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>Nightly news, 27 August 2010</title><link>http://www.mindscape.co.nz/blog/index.php/2010/08/26/nightly-news-27-august-2010/</link> <comments>http://www.mindscape.co.nz/blog/index.php/2010/08/26/nightly-news-27-august-2010/#comments</comments> <pubDate>Thu, 26 Aug 2010 23:45:48 +0000</pubDate> <dc:creator>Ivan Towlson</dc:creator> <category><![CDATA[LightSpeed]]></category> <category><![CDATA[WPF Diagramming]]></category><guid
isPermaLink="false">http://www.mindscape.co.nz/blog/?p=1966</guid> <description><![CDATA[Well, that was August. Four releases in four weeks. Mindscape HQ has been a non-stop riot of launch parties and last-minute brow-furrowing attempts to think of amusing discount codes. Despite all that we still have few updates in the nightlies. LightSpeed Fixed an issue where auto through entity tables were not created during database sync [...]]]></description> <content:encoded><![CDATA[<p>Well, that was August.  Four releases in four weeks.  Mindscape HQ has been a non-stop riot of launch parties and last-minute brow-furrowing attempts to think of amusing discount codes.  Despite all that we still have few updates in the nightlies.</p><p><a
href="http://www.totalizm.nazwa.pl/wyglad/rak.jpg"><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2010/08/DeveloperNotes22.png" alt="" title="That&#039;s not how you spice up an ASP.NET MVC talk.  This is how you spice up an ASP.NET MVC talk." width="344" height="64" class="alignleft size-full wp-image-1967" /></a></p><p><strong>LightSpeed</strong></p><ul><li>Fixed an issue where auto through entity tables were not created during database sync if the source was a STI derived entity</li><li>Added a check for the Client Profile when creating a new LightSpeed model</li></ul><p><strong>WPF Diagramming</strong></p><ul><li>Fixed DiagramPrinter printing nodes whose elements had been set to invisible</li></ul><p>We&#8217;d like to remind customers that most of the Mindscape crew will be at TechEd New Zealand for the first three days of next week and this is likely to impact forums support.  Please be patient &#8212; we&#8217;ll respond to posts when we can.</p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"><a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F08%2F26%2Fnightly-news-27-august-2010%2F"><img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F08%2F26%2Fnightly-news-27-august-2010%2F" height="61" width="51" /></a></div>]]></content:encoded> <wfw:commentRss>http://www.mindscape.co.nz/blog/index.php/2010/08/26/nightly-news-27-august-2010/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Nightly news, 20 August 2010</title><link>http://www.mindscape.co.nz/blog/index.php/2010/08/19/nightly-news-20-august-2010/</link> <comments>http://www.mindscape.co.nz/blog/index.php/2010/08/19/nightly-news-20-august-2010/#comments</comments> <pubDate>Thu, 19 Aug 2010 21:55:40 +0000</pubDate> <dc:creator>Ivan Towlson</dc:creator> <category><![CDATA[LightSpeed]]></category> <category><![CDATA[WPF Diagramming]]></category> <category><![CDATA[WPF Elements]]></category><guid
isPermaLink="false">http://www.mindscape.co.nz/blog/?p=1886</guid> <description><![CDATA[It&#8217;s been an enterprisy kind of a week: started out with a meeting, then our Dauntless Leaders went to an industry seminar and to cap it all off we&#8217;ve entered the SharePoint market. We&#8217;ve even got a pretty thin change log for this week. It doesn&#8217;t get much enterprisier than that. LightSpeed Improved DTO guidance [...]]]></description> <content:encoded><![CDATA[<p>It&#8217;s been an enterprisy kind of a week: started out with a meeting, then our Dauntless Leaders went to an industry seminar and to cap it all off we&#8217;ve entered the SharePoint market.  We&#8217;ve even got a pretty thin change log for this week.  It doesn&#8217;t get much enterprisier than that.</p><p><a
href="http://assets.mindscape.co.nz/IMG_0003.JPG"><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2010/08/DeveloperNotes21.png" alt="" title="Unless JD decides to impose a dress code..." width="344" height="64" class="alignnone size-full wp-image-1887" /></a></p><p><strong>LightSpeed</strong></p><ul><li>Improved DTO guidance sample</li><li>Added batch insert support for Amazon SimpleDB</li><li>Fixed a couple of cases that could cause &#8220;unresolved identifier&#8221; alias errors in generated SQL</li></ul><p><strong>WPF Elements</strong></p><ul><li>Added controls for single-day display &#8212; see the <a
href="http://www.mindscape.co.nz/blog/index.php/2010/08/18/wpf-elements-how-to-build-a-multi-scheduler/">multiple schedule sample here</a></li><li>Fixed an issue where TimePicker wasn&#8217;t showing the current value</li></ul><p><strong>WPF Diagramming</strong></p><ul><li>Fixed an issue where printing wasn&#8217;t respecting node elements being hidden</li></ul><p>As always, these fixes and enhancements are in the current nightlies &#8212; <a
href="http://www.mindscape.co.nz/downloads.aspx">free and trial editions from the downloads page</a>, <a
href="http://www.mindscape.co.nz/store/myaccount.aspx">retail editions from the store</a>.</p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"><a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F08%2F19%2Fnightly-news-20-august-2010%2F"><img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F08%2F19%2Fnightly-news-20-august-2010%2F" height="61" width="51" /></a></div>]]></content:encoded> <wfw:commentRss>http://www.mindscape.co.nz/blog/index.php/2010/08/19/nightly-news-20-august-2010/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Nightly news, 30 July 2010</title><link>http://www.mindscape.co.nz/blog/index.php/2010/07/29/nightly-news-30-july-2010/</link> <comments>http://www.mindscape.co.nz/blog/index.php/2010/07/29/nightly-news-30-july-2010/#comments</comments> <pubDate>Thu, 29 Jul 2010 21:48:39 +0000</pubDate> <dc:creator>Ivan Towlson</dc:creator> <category><![CDATA[LightSpeed]]></category> <category><![CDATA[WPF Diagramming]]></category> <category><![CDATA[WPF Property Grid]]></category><guid
isPermaLink="false">http://www.mindscape.co.nz/blog/?p=1683</guid> <description><![CDATA[We&#8217;ve been busy this week nailing down the hatches on WPF Elements 3.0, but we&#8217;ve also got a bunch of stuff into the latest nightly builds. Here&#8217;s what&#8217;s new. LightSpeed Now you don&#8217;t even need to leave the designer to get your database created. If the designer can&#8217;t find the database when you try to [...]]]></description> <content:encoded><![CDATA[<p>We&#8217;ve been busy this week nailing down the hatches on WPF Elements 3.0, but we&#8217;ve also got a bunch of stuff into the latest nightly builds.  Here&#8217;s what&#8217;s new.</p><p><a
href="http://www.youtube.com/watch?v=wGobJ-whLvI"><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2010/07/DeveloperNotes4.png" alt="" title="Well it&#039;s not what *I* call a plug-in architecture" width="344" height="64" class="alignnone size-full wp-image-1685" /></a></p><p><strong>LightSpeed</strong></p><ul><li>Now you don&#8217;t even need to leave the designer to get your database created.  If the designer can&#8217;t find the database when you try to do an Update Database, it will now offer to create it for you &#8212; if you&#8217;re on SQL Server, MySQL or PostgreSQL, anyway.  Let us know if you want this feature for other databases too.  (Except Oracle.  If you want it for Oracle&#8230; please <em>don&#8217;t</em> let us know.)  Rumours that the next version of the designer will download and install the database software for you are greatly exaggerated.</li><li>Fixed an error with client-side boolean literals.</li><li>Fix for an error when projecting a property declared in a derived class when using class table inheritance.</li><li>Fixed an issue where discriminators were not respected when joining to a derived class.</li><li>Beta support for the SQL Server Compact 4 CTP.  This requires an additional assembly reference: see <a
href="http://www.mindscape.co.nz/forums/Post.aspx?ThreadID=3401&#038;PostID=11431">here</a> for instructions.  At the moment, this is only runtime support: there&#8217;s no designer integration.  Of course you can still use designer-built models with the LightSpeed runtime, you just won&#8217;t be able to do database sync or migrations.</li><li>Ninja association support, or &#8216;cross-cutting composite keys&#8217; as they are more prosaically known.  We&#8217;ll post more about this later, but if you can&#8217;t wait, <a
href="http://www.mindscape.co.nz/forums/Post.aspx?ThreadID=2653&#038;PostID=11412">see here</a> for the details.</li></ul><p><strong>WPF Property Grid</strong></p><ul><li>Fix for an exception when editing a subnode in a collection when the collection contains expandable structs.</li></ul><p>Don&#8217;t forget the <a
href="http://www.mindscape.co.nz/blog/index.php/2010/07/26/wpf-elements-3-0-beta/">WPF Elements 3.0 beta is now available to existing property grid customers</a>.  This contains some changes to the property grid so check it out sooner rather than later!</p><p><strong>WPF Flow Diagrams</strong></p><ul><li>We&#8217;ve added some hooks to make it easier to serialise custom connections. <a
href="http://www.mindscape.co.nz/forums/Post.aspx?ThreadID=3393&#038;PostID=11363">Here&#8217;s a sample.</a></li></ul><p>All these features and fixes are available in current nightly builds &#8212; get <a
href="http://www.mindscape.co.nz/downloads.aspx">free and trial editions from the downloads page</a>, or <a
href="https://www.mindscape.co.nz/store/myaccount.aspx">retail versions from the store</a>.</p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"><a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F07%2F29%2Fnightly-news-30-july-2010%2F"><img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F07%2F29%2Fnightly-news-30-july-2010%2F" height="61" width="51" /></a></div>]]></content:encoded> <wfw:commentRss>http://www.mindscape.co.nz/blog/index.php/2010/07/29/nightly-news-30-july-2010/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>WPF Diagramming 2.0 Planning</title><link>http://www.mindscape.co.nz/blog/index.php/2010/06/01/wpf-diagramming-2-0-planning/</link> <comments>http://www.mindscape.co.nz/blog/index.php/2010/06/01/wpf-diagramming-2-0-planning/#comments</comments> <pubDate>Tue, 01 Jun 2010 23:06:52 +0000</pubDate> <dc:creator>John-Daniel Trask</dc:creator> <category><![CDATA[WPF]]></category> <category><![CDATA[WPF Diagramming]]></category><guid
isPermaLink="false">http://www.mindscape.co.nz/blog/?p=1532</guid> <description><![CDATA[We have started work on the next generation of our popular diagramming products and wanted to get some feedback from current users. Let your minds run wild with the possibilities of what would help you build some truly stunning applications with WPF diagramming. Some of our plans are&#8230; When your powers combine&#8230; Currently we&#8217;re retailing [...]]]></description> <content:encoded><![CDATA[<p><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2010/05/header1.png" alt="WPF Diagramming 2.0 - it&#039;s time to kick ass and chew bubble gum.... and we&#039;re all out of gum." title="WPF Diagramming 2.0 - it&#039;s time to kick ass and chew bubble gum.... and we&#039;re all out of gum." width="620" height="216" class="alignnone size-full wp-image-1533" /></p><p>We have started work on the next generation of our popular diagramming products and wanted to get some feedback from current users. Let your minds run wild with the possibilities of what would help you build some truly stunning applications with WPF diagramming.</p><p>Some of our plans are&#8230;</p><p><strong>When your powers combine&#8230;</strong><br
/> Currently we&#8217;re retailing two diagramming products &#8211; WPF Flow Diagrams and WPF Star Diagrams. We&#8217;ll be merging these two into a single &#8220;WPF Diagramming&#8221; product. Developers have always been able to build far more than just Flow Diagrams and Star Diagrams with the foundation classes so we decided to simplify things and just have one tidy package for all customers. All customers who have active subscriptions to one of the diagramming products will be upgraded automatically to the joint offering of course :-) As an aside, that also means now is the best value time to purchase licenses!</p><p><strong>Additional layout options</strong><br
/> We&#8217;ve always included a force directed layout algorithm and a tree layout algorithm in the Star Diagrams product. We&#8217;re now working on making these work seamlessly with other diagram types as well as including several new layout algorithms to create even more attractive diagrams easily. Part of this work includes new path finding algorithms as well, so once the nodes are laid out nicely, you can control what routing algorithm is used to draw the connections between nodes.</p><p><strong>More samples</strong><br
/> Diagramming is a large domain to be working in and that means creating custom diagrams is not always as easy as you might hope. To help improve the situation for users, we&#8217;re planning to ship more samples that provide additional detail on how to achieve certain diagram types, work with custom nodes, configure layouts and path finding etc.</p><p><strong>A whole bunch more</strong><br
/> Obviously we&#8217;re including a slew of smaller feature enhancements and improvements, but what&#8217;s most important to us is that we get your feedback on what you would like to see. We&#8217;ve had solid feedback since we launched these products which has helped in the incremental improvements, and as we&#8217;re actively investing in 2.0 it&#8217;s important to hear your latest requests :-)</p><p>Never used our diagramming products? Check out <a
href="http://www.mindscape.co.nz/products/wpfflowdiagrams/default.aspx">WPF Flow Diagrams</a> or <a
href="http://www.mindscape.co.nz/products/wpfstardiagrams/default.aspx">WPF Star Diagrams</a>.</p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"><a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F06%2F01%2Fwpf-diagramming-2-0-planning%2F"><img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F06%2F01%2Fwpf-diagramming-2-0-planning%2F" height="61" width="51" /></a></div>]]></content:encoded> <wfw:commentRss>http://www.mindscape.co.nz/blog/index.php/2010/06/01/wpf-diagramming-2-0-planning/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Nightly news, 28 May 2010</title><link>http://www.mindscape.co.nz/blog/index.php/2010/05/27/nightly-news-28-may-2010/</link> <comments>http://www.mindscape.co.nz/blog/index.php/2010/05/27/nightly-news-28-may-2010/#comments</comments> <pubDate>Fri, 28 May 2010 01:28:35 +0000</pubDate> <dc:creator>Ivan Towlson</dc:creator> <category><![CDATA[LightSpeed]]></category> <category><![CDATA[News]]></category> <category><![CDATA[Silverlight Elements]]></category> <category><![CDATA[WPF Diagramming]]></category><guid
isPermaLink="false">http://www.mindscape.co.nz/blog/?p=1509</guid> <description><![CDATA[We&#8217;ve not posted a Nightly News for a couple of weeks because we&#8217;ve been shipping releases rather than nightlies &#8212; see the Silverlight Elements 1.1 and LightSpeed 3.1 announcements. Still, here&#8217;s what&#8217;s new and not in those releases. LightSpeed We&#8217;ve fixed a bug with ordering on group keys that were obtained by traversals. We&#8217;ve fixed [...]]]></description> <content:encoded><![CDATA[<p>We&#8217;ve not posted a Nightly News for a couple of weeks because we&#8217;ve been shipping releases rather than nightlies &#8212; see the <a
href="http://www.mindscape.co.nz/blog/index.php/2010/05/19/introducing-silverlight-elements-1-1/">Silverlight Elements 1.1</a> and <a
href="http://www.mindscape.co.nz/blog/index.php/2010/05/24/lightspeed-3-1-released/">LightSpeed 3.1</a> announcements.  Still, here&#8217;s what&#8217;s new and not in those releases.</p><p><a
href="http://www.mindscape.co.nz/blog/wp-content/uploads/2010/05/DeveloperNotes2.png"><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2010/05/DeveloperNotes2.png" alt="" title="Think of it as an awesome picture of CLIPBOARD MAN and his sidekick the Green Tickmark" width="344" height="64" class="alignnone size-full wp-image-1510" /></a></p><p><strong>LightSpeed</strong></p><ul><li>We&#8217;ve fixed a bug with ordering on group keys that were obtained by traversals.</li><li>We&#8217;ve fixed an error that occurred in certain join-and-project scenarios if your entity had a property name that was the same as a property name that could be translated to SQL.</li><li>Fixed a spurious warning relating to a designer option</li></ul><p><strong>WPF Diagramming</strong></p><ul><li>Extensibility improvements to the connection remover and relocator</li><li>Fixed a couple of cropping issues in image export</li></ul><p><strong>Silverlight Elements</strong></p><ul><li>Resolved an issue relating to the order that properties were set in the Slider and DualSlider when using XAML</li></ul><p>We&#8217;ve also got work in progress on our WPF Diagramming products and on porting some of the cool new Silverlight Elements controls to WPF.  We&#8217;ll bring you an update on those as soon as they&#8217;re available.</p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"><a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F05%2F27%2Fnightly-news-28-may-2010%2F"><img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F05%2F27%2Fnightly-news-28-may-2010%2F" height="61" width="51" /></a></div>]]></content:encoded> <wfw:commentRss>http://www.mindscape.co.nz/blog/index.php/2010/05/27/nightly-news-28-may-2010/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>WPF Diagramming: Connection validation and an API change</title><link>http://www.mindscape.co.nz/blog/index.php/2010/04/13/wpf-diagramming-connection-and-an-api-change-validation/</link> <comments>http://www.mindscape.co.nz/blog/index.php/2010/04/13/wpf-diagramming-connection-and-an-api-change-validation/#comments</comments> <pubDate>Tue, 13 Apr 2010 21:50:00 +0000</pubDate> <dc:creator>Jason</dc:creator> <category><![CDATA[Products]]></category> <category><![CDATA[WPF]]></category> <category><![CDATA[WPF Diagramming]]></category> <category><![CDATA[WPF Flow Diagrams]]></category><guid
isPermaLink="false">http://www.mindscape.co.nz/blog/?p=1363</guid> <description><![CDATA[One important feature that some diagrams need is connection validation. That is, the ability to control which diagram nodes are allowed to be connected together. For example, you might want node A to be connectable only to node B. Or you may want to prevent start nodes being connected to end nodes. Many different diagrams [...]]]></description> <content:encoded><![CDATA[<p>One important feature that some diagrams need is connection validation. That is, the ability to control which diagram nodes are allowed to be connected together. For example, you might want node A to be connectable only to node B. Or you may want to prevent start nodes being connected to end nodes. Many different diagrams will require their own unique connection validation which is why <a
href="http://www.mindscape.co.nz/products/wpfflowdiagrams/default.aspx">WPF Diagramming</a> provides a way for you to customize this logic. The two interfaces that you need to consider when providing your own logic is the IDiagramConnectionBuilder and the IDiagramConnectionRelocator. The connection builder contains a method for building a connection and adding it to the diagram, and the relocator has a method for performing the connection relocation. Originally, custom connection validation would be taken place in your own implementations of these methods. A disadvantage of doing it this way is that the user interface is oblivious to this validation. Because of this, the user would only know if a connection can not be made between particular nodes after they let go of the mouse button and find that no connection is created. However, a recent modification to these two interfaces solves this issue. In this blog post we look at this modification that has been made, as well as how to provide your own connection validation logic to your applications.</p><h2>Connection builder and connection relocator API change.</h2><p>Both the IDiagramConnectionBuilder and the IDiagramConnectionRelocator now has an additional method that returns whether or not they are allowed to perform their respective actions. The new connection builder method is called CanCreateConnection which has the following parameters:</p><ul><li>IDiagramModel. This is simply the diagram that the new connection is going to be added to.</li><li>IDiagramConnectionPoint. This is the connection point where the new connection is going to originate. Using the Connectable property on this connection point gives us access to the diagram node that the connection will be attached to.</li><li>ConnectionDropTarget. This is a new type of object that contains information about where the user is dragging the end of the connection to.</li></ul><p>This method is also called in the situation where the user has just pressed the mouse button on a connection point thumb in preperation to create a connection. This allows you to provide connection validation logic that prevents certain types of connections being made on certain types of nodes. One thing to be aware of is that the ConnectionDropTarget parameter will be null to represent this situation.</p><p>The new connection relocator method is called CanRelocateConnection and contains all the parameters as previously mentioned as well as the IDiagramConnection that is being relocated. One thing to note is that the IDiagramConnectionPoint parameter is the connection point that the connection is still attached to, and the ConnectionDropTarget holds information about the end of the connection that the user is dragging.</p><h2>Custom connection validation logic</h2><p>Now that we know the basics, lets implement our own connection validation logic for a flow diagram to follow. Our logic will simply prevent any StartNode elements from being directly connected to an EndNode element. We want both our IDiagramConnectionBuilder and IDiagramConnectionRelocator implementations to share the same connection validation logic, so we can write it in a static method as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="csharp"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">class</span> ConnectionValidationLogic
<span style="color: #000000;">&#123;</span>
  <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">bool</span> ValidateConnection<span style="color: #000000;">&#40;</span>IDiagramConnectionPoint connectionPoint, ConnectionDropTarget dropTarget<span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">bool</span> canCreateConnection <span style="color: #000000;">=</span> <span style="color: #0600FF;">true</span>;
    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>dropTarget <span style="color: #000000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      IDiagramConnectable source <span style="color: #000000;">=</span> connectionPoint.<span style="color: #000000;">Connectable</span>;
      IDiagramConnectable destination <span style="color: #000000;">=</span> dropTarget.<span style="color: #000000;">Connectable</span>;
      <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>source <span style="color: #008000;">is</span> StartNode <span style="color: #000000;">&amp;&amp;</span> destination <span style="color: #008000;">is</span> EndNode<span style="color: #000000;">&#41;</span>
      <span style="color: #000000;">&#123;</span>
        canCreateConnection <span style="color: #000000;">=</span> <span style="color: #0600FF;">false</span>;
      <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">return</span> canCreateConnection;
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div><p>For our validation logic we will only be interested in the source and destination of the connection. So the only parameters we need for this method is the IDiagramConnectionPoint and the ConnectionDropTarget object. As previously mentioned, the drop target object will be null in a special situation so we include a null check around the rest of our logic. We can aquire the source item of the connection by using the Connectable property on the connection point, and the destination item can be obtained with dropTarget.Connectable. Then all our logic needs to do is return false if the source is a StartNode and the destination is an EndNode. Later when we give this logic to the diagram, we will get the following results:</p><p><a
href="http://www.mindscape.co.nz/blog/wp-content/uploads/2010/04/CantConnectStartToEnd.png"><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2010/04/CantConnectStartToEnd-600x183.png" title="Can not connect StartNode to EndNode" width="600" height="183" class="alignnone size-medium wp-image-1366" /></a></p><p>Here on the left we can see the user is creating a connection from the start node and hovering the mouse over the process node. Our validation logic allows this and so the connection points on the process node are shown. However, when hovering the mouse over the end node, the validation logic notices that this is illegal and so the connection points stay hidden.</p><p>Now that we have set up the validation logic, we need to make a connection builder and connection relocator implementation that uses it. We can do this easily by extending the FlowDiagramConnectionBuilder and DefaultDiagramConnectionRelocator classes and overiding the appropriate methods. In the implementation of these methods, we simply make a call to our static validation logic method, and return the result as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="csharp"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">class</span> ValidatingConnectionBuilder <span style="color: #000000;">:</span> FlowDiagramConnectionBuilder
<span style="color: #000000;">&#123;</span>
  <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">bool</span> CanCreateConnection<span style="color: #000000;">&#40;</span>IDiagramModel diagram
                                                          IDiagramConnectionPoint fromConnectionPoint,
                                                          ConnectionDropTarget dropTarget<span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">return</span> ConnectionValidationLogic.<span style="color: #000000;">ValidateConnection</span><span style="color: #000000;">&#40;</span>fromConnectionPoint, dropTarget<span style="color: #000000;">&#41;</span>;
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div><h2>Providing the diagram with the validation logic.</h2><p>Now all thats left to do is give our custom logic to the diagram. This is easily done by setting the appropriate diagram properties to be instances of our connection builder and relocator classes.</p><div
class="wp_syntax"><div
class="code"><pre class="csharp">FlowDiagramModel diagram <span style="color: #000000;">=</span> <span style="color: #008000;">new</span> FlowDiagramModel<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
diagram.<span style="color: #000000;">DefaultConnectionBuilder</span> <span style="color: #000000;">=</span> <span style="color: #008000;">new</span> ValidatingConnectionBuilder<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
diagram.<span style="color: #000000;">ConnectionRelocator</span> <span style="color: #000000;">=</span> <span style="color: #008000;">new</span> ValidatingConnectionRelocator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div><h2>And thats it!</h2><p>There are many connection validation scenarios that can be handled in this way. You could prevent certain types of nodes being directly connected to themselves, only allow specific types of connections to be made between certain node types, or even prevent particular diagram node instances from being connected together. If you download the latest nightly build you will find a new project in the flow diagram samples solution called ConnectionValidationSample. The sample prevent StartNodes being connected to EndNodes, DecisionNodes can only be accessed by a StartNode, and data-ProcessNodes can not connect to themselves. Use this to see how it all works and give you ideas to implement your own validation logic.</p><p>Try this out if you are in need of custom connection validation. If you are having trouble getting it to work or can&#8217;t seem to get the logic right for a certain scenario, then <a
href="http://www.mindscape.co.nz/forums/Forum.aspx?ForumID=19">let us know in our forum</a>, or put a comment on this blog post.</p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"><a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F04%2F13%2Fwpf-diagramming-connection-and-an-api-change-validation%2F"><img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F04%2F13%2Fwpf-diagramming-connection-and-an-api-change-validation%2F" height="61" width="51" /></a></div>]]></content:encoded> <wfw:commentRss>http://www.mindscape.co.nz/blog/index.php/2010/04/13/wpf-diagramming-connection-and-an-api-change-validation/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>WPF Diagrams: Custom Diagram Node Data</title><link>http://www.mindscape.co.nz/blog/index.php/2010/01/07/wpf-diagrams-custom-diagram-node-data/</link> <comments>http://www.mindscape.co.nz/blog/index.php/2010/01/07/wpf-diagrams-custom-diagram-node-data/#comments</comments> <pubDate>Fri, 08 Jan 2010 00:26:08 +0000</pubDate> <dc:creator>Jason</dc:creator> <category><![CDATA[WPF]]></category> <category><![CDATA[WPF Diagramming]]></category><guid
isPermaLink="false">http://www.mindscape.co.nz/blog/?p=1155</guid> <description><![CDATA[You may know that in WPF Flow Diagrams you can create your own custom node types to hold any additional data that they need. These nodes can be styled however you want, and also can be integrated into the serialization and undo features. This is useful when you want to create your own kind of [...]]]></description> <content:encoded><![CDATA[<p>You may know that in <a
href="http://www.mindscape.co.nz/products/wpfflowdiagrams/default.aspx">WPF Flow Diagrams</a> you can create your own custom node types to hold any additional data that they need. These nodes can be styled however you want, and also can be integrated into the serialization and undo features. This is useful when you want to create your own kind of node to represent a specific process that has its own attributes.</p><p>But what if you have various kinds of data objects that you want to be held by any type of diagram node? Or maybe you&#8217;re happy with the standard node types that we provide, but want them to hold more data without creating your own node types? Say for example you are creating a diagram where each node represents a task involved in completing a project. You may want each node including start and end nodes to contain text, as well as a list of people responsible for completing the task. Sure, you could create some custom node types that contain this additional data, but it would be nice if we could simply use the node&#8217;s Data property to hold any data we need</p><p>This has always been possible, but in the past it&#8217;s been slightly problematic due to the standard styles and serializer assuming that nodes only hold string content. However, if you <a
href="http://www.mindscape.co.nz/downloads.aspx">download the latest update of WPF Flow Diagrams</a>, you will find it is now easier to allow any kind of node to hold any kind of custom data that you need.</p><p>So you have some custom data objects that you want to be held by any node in a diagram. There are 2 main things you need to do: tell the diagram surface how to display the data content of a node, and tell the serializer how to serialize and deserialize your data objects.</p><h3>Custom node content templates</h3><p>The IDiagramFormatter interface now contains a property called NodeContentTemplateSelector. This can be set up to select a DataTemplate based on both the type of a diagram node, and the type of data that it holds. So you can have all nodes displaying each type of custom data the same way, or start nodes could display data differently to end nodes. So for each of the different types of node content that you want to display, you need to create a DataTemplate. These data templates will be templating your custom data, so you can have bindings to properties in your data objects to make them look however you want. Set these data templates into whatever data template selector you need, and set the selector into the NodeContentTemplateSelector of the IDiagramFormatter your using.</p><p>Here is an example of the effects you can achieve with templating custom node content.<br
/> (You can <a
href='http://www.mindscape.co.nz/blog/wp-content/uploads/2010/01/CustomDataSample.zip'>download this sample here</a> to see how it works. Make sure you&#8217;ve also downloaded the latest update of WPF Flow Diagrams)</p><p><a
href="http://www.mindscape.co.nz/blog/wp-content/uploads/2010/01/CustomNodeContent.png"><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2010/01/CustomNodeContent.png" alt="" title="Custom Node Content" width="434" height="311" class="alignnone size-full wp-image-1159" /></a></p><p>The start node simply contains a string. It gets a default template containing a TextBox where the text is a binding to the Data property of the node.</p><p>The next node contains custom data that has a string and an arbitrary object. The template selected for this type of node content displays the string but nothing else. This is useful when you want nodes to store custom data, but don&#8217;t want to change the appearance of the node.</p><p>The next node contains custom data that has a string and some data that represents a square. The template selected for this type of data displays the string, and also a coloured square. The template could also use attributes from the data to change the apperance of the square. For example its size and colour.</p><p>The last 2 nodes are different, but contain the same type of data. I have set up the template selector to use a different DataTemplate depending on the type of node ignoring the fact that the type of data is the same.</p><h3>Custom node content serialization</h3><p>Serializing your own custom data objects is fairly straight forward. IFlowDiagramSerializer now has a NodeContentSerializer property. All you need to do is make your own implementation of the new INodeContentSerializer interface. In the serialize method, you are given the data object that needs to be serialized. If you are serializing to XML, you just need to use the given XmlWriter to write any attributes your data objects have. If you have more than one type of custom data object, then you should also write some kind of attribute to the XmlWriter that indicates what type of data you are writing.</p><p>Now in the deserialize method, you get an XmlReader, and need to return an object. If you have multiple types of data objects, then you will first want to find out what type of object you are deserializing. This can be done by checking the value of the previously mentioned attribute. When you know what you are deserializing, you can read the values of the attributes that you wrote to XML, and create an instance of your data object based on these values.</p><p>If you haven&#8217;t tried the <a
href="http://www.mindscape.co.nz/products/wpfflowdiagrams/default.aspx">WPF Flow Diagrams</a> yet and want to create some very slick looking diagrams then <a
href="http://www.mindscape.co.nz/products/wpfflowdiagrams/default.aspx">download the trial version</a> now and let us know what you think!</p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"><a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F01%2F07%2Fwpf-diagrams-custom-diagram-node-data%2F"><img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2010%2F01%2F07%2Fwpf-diagrams-custom-diagram-node-data%2F" height="61" width="51" /></a></div>]]></content:encoded> <wfw:commentRss>http://www.mindscape.co.nz/blog/index.php/2010/01/07/wpf-diagrams-custom-diagram-node-data/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Improved support options for customers</title><link>http://www.mindscape.co.nz/blog/index.php/2009/12/15/improved-support-options-for-customers/</link> <comments>http://www.mindscape.co.nz/blog/index.php/2009/12/15/improved-support-options-for-customers/#comments</comments> <pubDate>Wed, 16 Dec 2009 03:52:38 +0000</pubDate> <dc:creator>John-Daniel Trask</dc:creator> <category><![CDATA[LightSpeed]]></category> <category><![CDATA[MegaPack]]></category> <category><![CDATA[Products]]></category> <category><![CDATA[SimpleDB Management Tools]]></category> <category><![CDATA[VS File Explorer]]></category> <category><![CDATA[WPF Diagramming]]></category> <category><![CDATA[WPF Elements]]></category> <category><![CDATA[WPF Property Grid]]></category> <category><![CDATA[Support]]></category><guid
isPermaLink="false">http://www.mindscape.co.nz/blog/?p=1127</guid> <description><![CDATA[Hand in hand with our recent volume discounts and LightSpeed 3.0 release we have started to put in place an improved support capability for customers who need priority support options or may occasionally want to escalate support beyond what we normally offer. Tooting our own horn a little, we have had very positive feedback from [...]]]></description> <content:encoded><![CDATA[<p>Hand in hand with our recent <a
href="http://www.mindscape.co.nz/blog/index.php/2009/12/14/lightspeed-3-licensing-changes/">volume discounts</a> and <a
href="http://www.mindscape.co.nz/blog/index.php/2009/12/14/lightspeed-3-0-released/">LightSpeed 3.0</a> release we have started to put in place an improved support capability for customers who need priority support options or may occasionally want to escalate support beyond what we normally offer.</p><p>Tooting our own horn a little, we have had very positive feedback from many customers who have said our support is fantastic. We hope this addition helps us maintain end user happiness as we continue to grow and our support load scales up.</p><p><strong>What is priority support?</strong></p><p>Priority support is the option to ensure that your request is dealt with promptly, and is reviewed before and prioritised over normal forum posts. It is also useful for folks who wish to not use the forum which is quite open and may not be viable for talking about sensitive parts of a software system.</p><p><strong>Can I use it for feature requests?</strong></p><p>No, we still urge that feature requests be posted in the forums so that others may discuss them (and because we don&#8217;t think it&#8217;s fair to charge you for suggesting cool features!). Features are still only added to products at our discretion.</p><p><strong>How much does priority support cost?</strong></p><p>We have priced support at $199 USD per priority support issue OR at $499 for a 5 pack of support issues, a 50% saving. You will be able to see if you have support tickets in your store account page. We have been issuing 1 priority support ticket per customer to LightSpeed 3.0 customers and upgrading Enterprise Edition customers.  For other products, we&#8217;re in the process of migrating Enterprise customers to have a priority ticket added to their account.</p><p>The pricing is designed to be very cost effective and is inexpensive compared to the support options offered for other software (for example, <a
href="http://nhprof.com/commercialsupport">one commercial NHibernate support vendor</a> quotes 600 Euro, approximately $870 USD, per incident for ad hoc support).</p><p><a
href="http://www.mindscape.co.nz/store/?p=Support%20and%20consulting">You can purchase Priority support tickets in our online store</a>.</p><p><strong>Do I need it? Should I put all my requests through priority support?</strong></p><p>If you need a guaranteed response, or a quick response is crucial to you, or you don&#8217;t want to discuss your issue on the public forum, then you should put a request through priority support. The forum will still get monitored actively by Mindscape staff and questions will be answered, but there are no guarantees around response times (our response times have usually been pretty good, but never guaranteed!).</p><p>Priority support is for those times when you need additional help and you don&#8217;t want to rely on the forums. You are welcome to simply <a
href="http://www.mindscape.co.nz/store/?p=Support%20and%20consulting">buy a support ticket as you need them for $199 USD</a> however it may be wiser to simply <a
href="http://www.mindscape.co.nz/store/?p=Support%20and%20consulting">purchase a 5 pack</a> in order to save 50%.</p><p>If I&#8217;ve missed any questions you have then please post a comment &#8211; I&#8217;m happy to answer them :-)</p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"><a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2009%2F12%2F15%2Fimproved-support-options-for-customers%2F"><img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2009%2F12%2F15%2Fimproved-support-options-for-customers%2F" height="61" width="51" /></a></div>]]></content:encoded> <wfw:commentRss>http://www.mindscape.co.nz/blog/index.php/2009/12/15/improved-support-options-for-customers/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>WPF Diagrams: Styling a Node Element</title><link>http://www.mindscape.co.nz/blog/index.php/2009/09/29/wpf-diagrams-styling-a-node-element/</link> <comments>http://www.mindscape.co.nz/blog/index.php/2009/09/29/wpf-diagrams-styling-a-node-element/#comments</comments> <pubDate>Tue, 29 Sep 2009 11:39:41 +0000</pubDate> <dc:creator>Jason</dc:creator> <category><![CDATA[WPF Diagramming]]></category> <category><![CDATA[WPF Diagrams]]></category> <category><![CDATA[WPF Flow Diagrams]]></category> <category><![CDATA[WPF Star Diagrams]]></category><guid
isPermaLink="false">http://www.mindscape.co.nz/blog/?p=959</guid> <description><![CDATA[One of the most powerful and useful features of WPF Diagrams is the ability to style any part of a diagram any way you want it to look and feel.Â  One of the mostÂ common parts of a diagram that you&#8217;ll likely want to style are the node elements. When it comes to customizing the look [...]]]></description> <content:encoded><![CDATA[<p>One of the most powerful and useful features of WPF Diagrams is the ability to style any part of a diagram any way you want it to look and feel.Â  One of the mostÂ common parts of a diagram that you&#8217;ll likely want to style are the node elements. When it comes to customizing the look of a node element there are 2Â main things to think of first. First there is the style to be applied to the nodes, and secondly the data template that each node type should have. The <em>data template</em> is what seperates the look of one type of node to some other type of node. The <em>style</em> of all the nodes is generally the same, this is what provides a node with its MoveThumb, Resizer, and ConnectionPointThumbs. In this post we look at how to provide your own node style in your applications.</p><p>The standard DiagramNodeElement style uses a simple black colored Resizer, and blue gradient filled connection points as seen in below.</p><p><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2009/09/StandardStyle.png" alt="Standard WPF Diagram Node Style" title="Standard WPF Diagram Node Style" width="350" height="211" class="alignnone size-full wp-image-972" /></p><p>The best place to start is by copying the standard DiagramNodeElement style. Below I have provided the style used in the <a
href="http://www.mindscape.co.nz/products/wpfflowdiagrams/default.aspx">WPF Flow Diagrams</a> product.</p><div
class="wp_syntax"><div
class="code"><pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Style</span> <span style="color: #000066;">x:Key</span>=<span style="color: #ff0000;">&quot;NodeStyle&quot;</span> <span style="color: #000066;">TargetType</span>=<span style="color: #ff0000;">&quot;{x:Type ms:DiagramNodeElement}&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;FocusVisualStyle&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;{x:Null}&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Template&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span>.Value<span style="font-weight: bold; color: black;">&gt;</span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ControlTemplate</span> <span style="color: #000066;">TargetType</span>=<span style="color: #ff0000;">&quot;ms:DiagramNodeElement&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
          <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Grid</span> Canvas.<span style="color: #000066;">Left</span>=<span style="color: #ff0000;">&quot;{TemplateBinding Left}&quot;</span> Canvas.<span style="color: #000066;">Top</span>=<span style="color: #ff0000;">&quot;{TemplateBinding Top}&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ms:MoveThumb</span> <span style="color: #000066;">Element</span>=<span style="color: #ff0000;">&quot;{Binding RelativeSource={RelativeSource TemplatedParent}}&quot;</span> 
                             <span style="color: #000066;">Focusable</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">Clip</span>=<span style="color: #ff0000;">&quot;{TemplateBinding Geometry}&quot;</span>
                             <span style="color: #000066;">Style</span>=<span style="color: #ff0000;">&quot;{StaticResource {x:Static ms:MoveThumb.InvisibleStyleKey}}&quot;</span> <span style="color: #000066;">Cursor</span>=<span style="color: #ff0000;">&quot;SizeAll&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Mover&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ms:Resizer</span> <span style="color: #000066;">Element</span>=<span style="color: #ff0000;">&quot;{Binding RelativeSource={RelativeSource TemplatedParent}}&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Resizer&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ContentPresenter</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;ContentPresenter&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ms:ConnectionPointThumb</span> <span style="color: #000066;">ConnectionPoint</span>=<span style="color: #ff0000;">&quot;{Binding Content.DefaultConnectionPoint, RelativeSource={RelativeSource TemplatedParent}}&quot;</span>
                                        <span style="color: #000066;">Width</span>=<span style="color: #ff0000;">&quot;{Binding ActualWidth, RelativeSource={RelativeSource TemplatedParent}}&quot;</span>
                                        <span style="color: #000066;">Height</span>=<span style="color: #ff0000;">&quot;{Binding ActualHeight, RelativeSource={RelativeSource TemplatedParent}}&quot;</span>
                                        <span style="color: #000066;">IsHitTestVisible</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #000066;">Focusable</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">Visibility</span>=<span style="color: #ff0000;">&quot;Collapsed&quot;</span>
                                        <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Connector&quot;</span> <span style="color: #000066;">Style</span>=<span style="color: #ff0000;">&quot;{StaticResource {x:Static ms:MoveThumb.InvisibleStyleKey}}&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ItemsControl</span> <span style="color: #000066;">ItemsSource</span>=<span style="color: #ff0000;">&quot;{Binding Content.ConnectionPoints, RelativeSource={RelativeSource TemplatedParent}}&quot;</span> 
                          <span style="color: #000066;">ItemTemplate</span>=<span style="color: #ff0000;">&quot;{StaticResource ConnectionPointTemplate}&quot;</span>
                          <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Connectors&quot;</span>
                          <span style="color: #000066;">Visibility</span>=<span style="color: #ff0000;">&quot;{TemplateBinding ShowConnectionPoints, Converter={StaticResource bvc}}&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ItemsControl</span>.RenderTransform<span style="font-weight: bold; color: black;">&gt;</span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;TranslateTransform</span> <span style="color: #000066;">X</span>=<span style="color: #ff0000;">&quot;{Binding (Canvas.Left), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource Negative}}&quot;</span>
                                    <span style="color: #000066;">Y</span>=<span style="color: #ff0000;">&quot;{Binding (Canvas.Top), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource Negative}}&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ItemsControl</span>.RenderTransform<span style="font-weight: bold; color: black;">&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ItemsControl</span>.ItemsPanel<span style="font-weight: bold; color: black;">&gt;</span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ItemsPanelTemplate<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Canvas</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ItemsPanelTemplate<span style="font-weight: bold; color: black;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ItemsControl</span>.ItemsPanel<span style="font-weight: bold; color: black;">&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ItemsControl</span>.ItemContainerStyle<span style="font-weight: bold; color: black;">&gt;</span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Style<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Canvas.Left&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
                    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span>.Value<span style="font-weight: bold; color: black;">&gt;</span></span>
                      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;MultiBinding</span> <span style="color: #000066;">Converter</span>=<span style="color: #ff0000;">&quot;{StaticResource CPX}&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
                        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Binding</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Binding</span> <span style="color: #000066;">Path</span>=<span style="color: #ff0000;">&quot;Formatter.Layout&quot;</span> <span style="color: #000066;">RelativeSource</span>=<span style="color: #ff0000;">&quot;{RelativeSource AncestorType={x:Type ms:DiagramSurface}}&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Binding</span> <span style="color: #000066;">Path</span>=<span style="color: #ff0000;">&quot;Position&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
                      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/MultiBinding<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Setter</span>.Value<span style="font-weight: bold; color: black;">&gt;</span></span>
                  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Setter<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Canvas.Top&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
                    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span>.Value<span style="font-weight: bold; color: black;">&gt;</span></span>
                      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;MultiBinding</span> <span style="color: #000066;">Converter</span>=<span style="color: #ff0000;">&quot;{StaticResource CPY}&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
                        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Binding</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Binding</span> <span style="color: #000066;">Path</span>=<span style="color: #ff0000;">&quot;Formatter.Layout&quot;</span> <span style="color: #000066;">RelativeSource</span>=<span style="color: #ff0000;">&quot;{RelativeSource AncestorType={x:Type ms:DiagramSurface}}&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Binding</span> <span style="color: #000066;">Path</span>=<span style="color: #ff0000;">&quot;Position&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
                      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/MultiBinding<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Setter</span>.Value<span style="font-weight: bold; color: black;">&gt;</span></span>
                  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Setter<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Style<span style="font-weight: bold; color: black;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ItemsControl</span>.ItemContainerStyle<span style="font-weight: bold; color: black;">&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ItemsControl<span style="font-weight: bold; color: black;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Grid<span style="font-weight: bold; color: black;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ControlTemplate</span>.Triggers<span style="font-weight: bold; color: black;">&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Trigger</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;IsSelected&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;False&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Resizer&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Visibility&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;Collapsed&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Trigger<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Trigger</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;IsResizable&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;False&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Resizer&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Visibility&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;Collapsed&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Trigger<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;DataTrigger</span> <span style="color: #000066;">Binding</span>=<span style="color: #ff0000;">&quot;{Binding IsReadOnly, RelativeSource={RelativeSource AncestorType={x:Type ms:DiagramSurface}}}&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;True&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Resizer&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Visibility&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;Collapsed&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Mover&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Visibility&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;Collapsed&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Connector&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Visibility&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;Collapsed&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Connectors&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Visibility&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;Collapsed&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/DataTrigger<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;DataTrigger</span> <span style="color: #000066;">Binding</span>=<span style="color: #ff0000;">&quot;{Binding CanModifyConnectivity, RelativeSource={RelativeSource AncestorType={x:Type ms:DiagramSurface}}}&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;False&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Connector&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Visibility&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;Collapsed&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Connectors&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Visibility&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;Collapsed&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/DataTrigger<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;MultiDataTrigger<span style="font-weight: bold; color: black;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;MultiDataTrigger</span>.Conditions<span style="font-weight: bold; color: black;">&gt;</span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Condition</span> <span style="color: #000066;">Binding</span>=<span style="color: #ff0000;">&quot;{Binding Path=(ms:CursorAction.Current), Converter={StaticResource CursorActionTypeConverter}, RelativeSource={RelativeSource AncestorType={x:Type ms:DiagramSurface}}}&quot;</span> 
                           <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;{x:Static ms:CursorActionType.CreateConnection}&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Condition</span> <span style="color: #000066;">Binding</span>=<span style="color: #ff0000;">&quot;{Binding IsReadOnly, RelativeSource={RelativeSource AncestorType={x:Type ms:DiagramSurface}}}&quot;</span>
                           <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/MultiDataTrigger</span>.Conditions<span style="font-weight: bold; color: black;">&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Mover&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;IsHitTestVisible&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;False&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Connector&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;IsHitTestVisible&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
              <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Setter</span> <span style="color: #000066;">TargetName</span>=<span style="color: #ff0000;">&quot;Connector&quot;</span> <span style="color: #000066;">Property</span>=<span style="color: #ff0000;">&quot;Visibility&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;Visible&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/MultiDataTrigger<span style="font-weight: bold; color: black;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ControlTemplate</span>.Triggers<span style="font-weight: bold; color: black;">&gt;</span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ControlTemplate<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Setter</span>.Value<span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Setter<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Style<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre></div></div><p>Â<br
/> Phew! That&#8217;s a lot of XAML! Good news though &#8211; you only need to tweak parts of it to start styling your own nodes.</p><p>After modifying the parts of the style that you need to customize, you then need to tell the DiagramSurface that this is the style you want to use. This is easily done by setting the NodeStyleSelector property of the IDiagramFormatter that you give to the DiagramSurface. If you wanted to use your style on all the different types of nodes in a diagram, then you would use the following code.</p><div
class="wp_syntax"><div
class="code"><pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ms:FixedStyleSelector</span> <span style="color: #000066;">x:Key</span>=<span style="color: #ff0000;">&quot;{x:Static styles:GradientStyle.NodeStyleSelectorKey}&quot;</span> <span style="color: #000066;">Style</span>=<span style="color: #ff0000;">&quot;{StaticResource NodeStyle}&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></pre></div></div><h2>So why make your own node element style?</h2><p>The node element style is the best way to incorporate your own SizeThumb and ConnectionPointThumb styles on your nodes. This is done simply by making your own style for these thumbs, and then setting them onÂ the appropriate controls found within the node element style. This allows you to achieve the effects in the following images.</p><p><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2009/09/ChangedSizeThumbStyle.png" alt="Changed WPF Diagrams node size thumb style" title="Changed WPF Diagrams node size thumb style" width="350" height="218" class="alignnone size-full wp-image-973" /></p><p>Changing the color of the Resizer, and only including the corner thumbs.</p><p><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2009/09/ChangedConnectionPointThumb.png" alt="Changed WPF Diagram connection thumb style" title="Changed WPF Diagram connection thumb style" width="350" height="200" class="alignnone size-full wp-image-974" /></p><p>Changing the look of the outbound connection point thumbs to have a transparent green fill.</p><p>Another useful tip with creating your own node styles is to add MouseDoubleClick or MouseRightButtonDown event handlers to the MoveThumb within the style. This willÂ allow you to define appropriate actions to occur when the user double clicks or right click on a node.Â And since the MoveThumb in the standard node style is the most exposed control, it is the best place to attach such event handlers.</p><p>Node element styles are not limited to being applied to all the nodes in a single diagram. By using a TypeStyleSelector instead of a FixedStyleSelector, you can have some typesÂ nodes with different colored connection points compared to other nodes. Or some nodes could have the standard Resizer, while other nodes use a Resizer that only allows nodes to be square shaped.</p><p>Need any help with making your own node element styles? Drop a comment on this blog or put a <a
href="http://www.mindscape.co.nz/forums/">post up on the forum</a>. We&#8217;d love to hear from you!</p><p>Want to play with <a
href="http://www.mindscape.co.nz/products/wpfflowdiagrams/default.aspx">WPF Diagrams</a>? Download the free trials of <a
href="http://www.mindscape.co.nz/products/wpfflowdiagrams/default.aspx">WPF Flow Diagrams</a> or <a
href="http://www.mindscape.co.nz/products/wpfstardiagrams/default.aspx">WPF Star Diagrams</a>.</p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"><a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2009%2F09%2F29%2Fwpf-diagrams-styling-a-node-element%2F"><img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2009%2F09%2F29%2Fwpf-diagrams-styling-a-node-element%2F" height="61" width="51" /></a></div>]]></content:encoded> <wfw:commentRss>http://www.mindscape.co.nz/blog/index.php/2009/09/29/wpf-diagrams-styling-a-node-element/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>WPF Diagrams: Dynamic connection point creation</title><link>http://www.mindscape.co.nz/blog/index.php/2009/09/27/wpf-diagrams-dynamic-connection-point-creation/</link> <comments>http://www.mindscape.co.nz/blog/index.php/2009/09/27/wpf-diagrams-dynamic-connection-point-creation/#comments</comments> <pubDate>Sun, 27 Sep 2009 23:38:03 +0000</pubDate> <dc:creator>Jason</dc:creator> <category><![CDATA[WPF Diagramming]]></category> <category><![CDATA[WPF Flow Diagrams]]></category> <category><![CDATA[WPF Star Diagrams]]></category><guid
isPermaLink="false">http://www.mindscape.co.nz/blog/?p=947</guid> <description><![CDATA[In this blog post we take a look at one of our latest additions to the WPF Diagramming product, the ability to dynamicallyÂ add connection points to a node. Say we want to design a node representing some kind of intersection in a network. The intersection has input flows and output flows. EachÂ input and outputÂ connection should [...]]]></description> <content:encoded><![CDATA[<p>In this blog post we take a look at one of our latest additions to the WPF Diagramming product, the ability to dynamicallyÂ add connection points to a node.</p><p>Say we want to design a node representing some kind of intersection in a network. The intersection has input flows and output flows. EachÂ input and outputÂ connection should have its own connection point to make it easier to follow the diagram, rather than having all the connections bunched up on one point.Â To make it flexible for the user, we want to be able to have a variable number of connection points on the node. Hence we want to be able to dynamically add and remove connection points from instances of this node.</p><p>Here is how we go about implementing such a node:</p><p><strong>1.</strong> We start by creating a new class that extends from FlowDiagramNode.</p><p><strong>2.</strong> Include an ObservableCollection&lt;IDiagramConnectionPoint&gt; field to hold all the connection points. I&#8217;m calling this _connectionPoints.</p><p><strong>3.</strong> In the constructor, we setup all the initial connection points on this node, and add them all to the observable collection as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="csharp"><span style="color: #0600FF;">public</span> SampleNode1<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    _connectionPoints <span style="color: #000000;">=</span> <span style="color: #008000;">new</span> ObservableCollection<span style="color: #000000;">&lt;</span>IDiagramConnectionPoint<span style="color: #000000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
    _connectionPoints.<span style="color: #000000;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> InboundConnectionPoint<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>, Edge.<span style="color: #000000;">Top</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
    _connectionPoints.<span style="color: #000000;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> OutboundConnectionPoint<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>, Edge.<span style="color: #000000;">Bottom</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div><p><strong>4.</strong> Now we want to override the FlowDiagramNode.ConnectionPoints property to return the observable collection.</p><p><strong>5.</strong> As both outbound and inbound connection points are stored in the same collection, we need to implement the InboundConnectionPointsCore and OutboundConnectionPointsCore properties in a way that looks through our observable collection and picks out the appropriate points to return. One way to do this is as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="csharp"><span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> IList<span style="color: #000000;">&lt;</span>InboundConnectionPoint<span style="color: #000000;">&gt;</span> InboundConnectionPointsCore
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">get</span>
    <span style="color: #000000;">&#123;</span>
        List<span style="color: #000000;">&lt;</span>InboundConnectionPoint<span style="color: #000000;">&gt;</span> result <span style="color: #000000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #000000;">&lt;</span>InboundConnectionPoint<span style="color: #000000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>IDiagramConnectionPoint point <span style="color: #0600FF;">in</span> _connectionPoints<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            InboundConnectionPoint p <span style="color: #000000;">=</span> point <span style="color: #0600FF;">as</span> InboundConnectionPoint;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>p <span style="color: #000000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> result.<span style="color: #000000;">Add</span><span style="color: #000000;">&#40;</span>p<span style="color: #000000;">&#41;</span>; <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">return</span> result;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div><p><strong>6.</strong> Done!</p><p>Connection points can now be freely added or removed from the observable collection which results in dynamic connection point creation and deletion at the graphical layer. Note that the above code simply illustrates how to get dynamic connection point creation and deletion working, some more logic is required to specify when exactly the connection point collection is modified.Â How you add and remove connection points is up to you as it&#8217;s likely application specific. You could allow there to always be 1 unused connection point available on a node by adding or deleting connection points when connections are made or removed from the node. Or you could have a control somewhere in your application or on the node itself which the user can use toÂ specify the number of input and output points.</p><p>Here are a couple of screenshots of one possible way dynamic connection point creation could be implemented. First we have network intersection node with one input point on the top, and one input point on the bottom as its initial state.</p><p><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2009/09/NetworkIntersection.gif" alt="WPF Diagram node with two connection points" title="WPF Diagram node with two connection points" width="572" height="236" class="alignnone size-full wp-image-952" /></p><p>When the user introduces an input flow to the connection point on the top, a newÂ  input point can be added to the node as seen in the next screenshot.Â This will allow additional inbound connections being introduced by the userÂ if necessary.</p><p><img
src="http://www.mindscape.co.nz/blog/wp-content/uploads/2009/09/NetworkIntersection_AnotherPoint.gif" alt="WPF Diagram node with three connection points" title="WPF Diagram node with three connection points" width="572" height="236" class="alignnone size-full wp-image-953" /></p><p>The WPF Diagramming products support this type of customisation because we know that nearly every application will require something different. Need to have a minimum or maximum number of connections? No problem &#8211; do whatever you require!</p><p>If you want to create some amazing diagrammatic visualizations with WPF then check out our <a
href="http://www.mindscape.co.nz/products/wpfflowdiagrams/default.aspx">WPF Flow Diagrams</a> or <a
href="http://www.mindscape.co.nz/products/wpfstardiagrams/default.aspx">WPF Star Diagrams</a> products.</p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"><a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2009%2F09%2F27%2Fwpf-diagrams-dynamic-connection-point-creation%2F"><img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.mindscape.co.nz%2Fblog%2Findex.php%2F2009%2F09%2F27%2Fwpf-diagrams-dynamic-connection-point-creation%2F" height="61" width="51" /></a></div>]]></content:encoded> <wfw:commentRss>http://www.mindscape.co.nz/blog/index.php/2009/09/27/wpf-diagrams-dynamic-connection-point-creation/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (request URI is rejected)

Served from: www.mindscape.co.nz @ 2010-09-08 01:48:34 -->