<?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>Damian Schenkelman &#187; C#</title>
	<atom:link href="http://blogs.southworks.net/dschenkelman/category/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.southworks.net/dschenkelman</link>
	<description></description>
	<lastBuildDate>Fri, 08 Feb 2013 03:40:35 +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>How to: Add a View to a Region in a particular index with Prism-v2</title>
		<link>http://blogs.southworks.net/dschenkelman/2009/03/14/how-to-add-a-view-to-a-region-in-a-particular-index-with-prism-v2/</link>
		<comments>http://blogs.southworks.net/dschenkelman/2009/03/14/how-to-add-a-view-to-a-region-in-a-particular-index-with-prism-v2/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 01:04:00 +0000</pubDate>
		<dc:creator>Damian Schenkelman</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Composite Application Guidance for WPF & SL]]></category>
		<category><![CDATA[Extension methods]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[Prism-v2]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Windows Presentation Foundation]]></category>
		<category><![CDATA[p&p]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/dschenkelman/?p=69</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/dschenkelman/2009/03/14/how-to-add-a-view-to-a-region-in-a-particular-index-with-prism-v2/" class="more-link">read more<img src="http://blogs.southworks.net/dschenkelman/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday a <a href="http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=50138">question</a> in the <a href="http://compositewpf.codeplex.com/Thread/List.aspx">Prism codeplex forum</a> made me realize that there is no out-of-the-box way to specify the order in which a view will be added to a Region with the Composite Application Library&#8217;s code shipped with the <a href="http://msdn.microsoft.com/en-us/library/dd458809.aspx">Composite Application Guidance for WPF &amp; Silverlight</a>.</p>
<p>After discussing with <a href="http://blogs.southworks.net/matiasb/">Matias Bonaventura</a> what the best way to get this done was, we decided to use an <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx">extension method</a> for the <strong>RegionManager</strong> class.</p>
<h5>RegisterViewWithRegionInIndex method</h5>
<ol>
<li>Create a new <strong>public static</strong> class named <strong>RegionManagerCustomExtensions </strong>in any place accessible to where you want to be able to use it.</li>
<li>Add a reference to the Assembly Microsoft.Practices.ServiceLocation(located in the <strong>~DecompressionPath\LIB\Desktop\CommonServiceLocation</strong> folder)</li>
<li>Add the following using statements to the  <strong>RegionManagerCustomExtensions </strong>class:<br />
<blockquote>
<pre><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.Linq;
<span style="color: blue">using </span>System.Text;
<span style="color: blue">using </span>Microsoft.Practices.Composite.Regions;
<span style="color: blue">using </span>Microsoft.Practices.ServiceLocation;</pre>
<p><a href="http://11011.net/software/vspaste"></a></p></blockquote>
</li>
<li>Add a method named <strong>RegisterViewWithRegionInIndex</strong> with that has the following code:</li>
</ol>
<blockquote>
<pre><span style="color: blue">public static </span><span style="color: #2b91af">IRegionManager </span>RegisterViewWithRegionInIndex(<span style="color: blue">this </span><span style="color: #2b91af">IRegionManager </span>regionManager, <span style="color: blue">string </span>regionName, <span style="color: #2b91af">Type </span>viewType, <span style="color: blue">int </span>index)
       {
           <span style="color: #2b91af">IRegion </span>mainRegion = regionManager.Regions[regionName];
           <span style="color: blue">int </span>viewsAmount = mainRegion.Views.Count();
           <span style="color: blue">if </span>(index &gt; viewsAmount)
           {
               <span style="color: blue">throw new </span><span style="color: #2b91af">IndexOutOfRangeException</span>(<span style="color: #a31515">"Tried to add a view to a region that does not have enough views."</span>);
           }

           <span style="color: blue">if </span>(index &lt; 0)
           {
               <span style="color: blue">throw new </span><span style="color: #2b91af">IndexOutOfRangeException</span>(<span style="color: #a31515">"Tried to add a view in a negative index."</span>);
           }

           <span style="color: blue">object </span>activeView = <span style="color: blue">null</span>;

           <span style="color: blue">if </span>(mainRegion.ActiveViews.Count() == 1)
           {
               activeView = mainRegion.ActiveViews.First();
           }

           <span style="color: blue">var </span>regionViewRegistry = <span style="color: #2b91af">ServiceLocator</span>.Current.GetInstance&lt;<span style="color: #2b91af">IRegionViewRegistry</span>&gt;();

           <span style="color: green">// Save reference to each view existing in the RegionManager after the index to insert.
           </span><span style="color: #2b91af">List</span>&lt;<span style="color: blue">object</span>&gt; views = mainRegion.Views.SkipWhile((view, removeFrom) =&gt; removeFrom &lt; index).ToList();

           <span style="color: green">//Remove elements from region that are after index to insert.
           </span><span style="color: blue">for </span>(<span style="color: blue">int </span>i = 0; i &lt; views.Count; i++)
           {
               mainRegion.Remove(mainRegion.Views.ElementAt(index));
           }

           <span style="color: green">//Register view in index to insert.
           </span>regionViewRegistry.RegisterViewWithRegion(regionName, viewType);

           <span style="color: green">// Adding previously removed views
           </span>views.ForEach(view =&gt; mainRegion.Add(view));

           <span style="color: blue">if </span>(activeView != <span style="color: blue">null</span>)
           {
               mainRegion.Activate(activeView);
           }

           <span style="color: blue">return </span>regionManager;
       }</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><a href="http://11011.net/software/vspaste"></a></p></blockquote>
<blockquote><p><a href="http://11011.net/software/vspaste"></a></p></blockquote>
<h5>Putting the method to use</h5>
<p>You should be able to use the method now. To test it, I created a couple of extra views in the HelloWorld Quickstart and wrote the following code in the HelloWorldModule class:</p>
<pre>manager.RegisterViewWithRegionInIndex(<span style="color: #a31515">"MainRegion"</span>, <span style="color: blue">typeof</span>(Views.<span style="color: #2b91af">HelloWorldView</span>), 0);
manager.RegisterViewWithRegionInIndex(<span style="color: #a31515">"MainRegion"</span>, <span style="color: blue">typeof</span>(Views.<span style="color: #2b91af">View1</span>), 1);
manager.RegisterViewWithRegionInIndex(<span style="color: #a31515">"MainRegion"</span>, <span style="color: blue">typeof</span>(Views.<span style="color: #2b91af">View2</span>), 1);</pre>
<p>The outcome was the following. As you can see, View2 was placed where View1 was located:</p>
<pre><a href="http://blogs.southworks.net/dschenkelman/files/2009/03/image.png"><span style="font-family: georgia;color: #555555"><img style="float: none;margin-left: auto;margin-right: auto" src="http://blogs.southworks.net/dschenkelman/files/2009/03/image-thumb.png" border="0" alt="image" width="244" height="212" /></span></a></pre>
<p>The method could also be customized to add views to the latest index possible if the index to insert the view into was higher than the amount of views previously existing in the region.</p>
<p>Let me know if you find a good use to this method.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to: Show large amounts of data in WPF using UI Virtualization</title>
		<link>http://blogs.southworks.net/dschenkelman/2009/01/29/how-to-show-large-amounts-of-data-in-wpf-using-ui-virtualization/</link>
		<comments>http://blogs.southworks.net/dschenkelman/2009/01/29/how-to-show-large-amounts-of-data-in-wpf-using-ui-virtualization/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 13:47:13 +0000</pubDate>
		<dc:creator>Damian Schenkelman</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Composite Application Guidance for WPF & SL]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[Prism-v2]]></category>
		<category><![CDATA[UI Virtualization]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Windows Presentation Foundation]]></category>
		<category><![CDATA[p&p]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/dschenkelman/?p=61</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/dschenkelman/2009/01/29/how-to-show-large-amounts-of-data-in-wpf-using-ui-virtualization/" class="more-link">read more<img src="http://blogs.southworks.net/dschenkelman/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>Today I saw a <a href="http://www.codeplex.com/CompositeWPF/Thread/View.aspx?ThreadId=45581">question</a> in the <a href="http://www.codeplex.com/CompositeWPF/Thread/List.aspx">Composite WPF forum</a> that was asking for a way to show 40000 entries in a WPF ListView, with Databinding, in a fast manner since the user&#8217;s application was taking to long to load all the employees.</p>
<p>Therefore, I started doing some digging and found out that <strong>UI Virtualization</strong> could do the trick. This basically means that the process of showing a specific item in an ItemsControl is postponed until the item is within visibility range.</p>
<p>The ListView and ListBox controls have <strong>UI Virtualization</strong> enabled by default when their items are bound to data. In other ItemsControls, like TreeViews, it can be enabled using the <strong>VirtualizingStackPanel.IsVirtualizing</strong> attached property.</p>
<p>In the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=ab99342f-5d1a-413d-8319-81da479ab0d7&amp;displaylang=en">.NET Framework 3.5 SP1</a> an addition was made to improve UI Virtualization which is <strong>Container Recycling</strong>. You can read more about UI Virtualization <strong> </strong>and Container Recycling in this article:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/cc716879.aspx">Optimizing Performance: Controls</a></li>
</ul>
<h3>Applying Theory to Practice</h3>
<p>I opened the ViewDiscoveryComposition Quickstart from the <a href="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=21912">latest Prism-v2 Drop</a> and modified the Employee Service class&#8217; (located in the Employees Module) implementation for the following one and ran the application:</p>
<pre><span style="color: blue">public class </span><span style="color: #2b91af">EmployeeService </span>: <span style="color: #2b91af">IEmployeeService
    </span>{
        <span style="color: blue">public </span><span style="color: #2b91af">ObservableCollection</span>&lt;BusinessEntities.<span style="color: #2b91af">Employee</span>&gt; RetrieveEmployees()
        {
            <span style="color: #2b91af">ObservableCollection</span>&lt;BusinessEntities.<span style="color: #2b91af">Employee</span>&gt; employees =
                <span style="color: blue">new </span><span style="color: #2b91af">ObservableCollection</span>&lt;BusinessEntities.<span style="color: #2b91af">Employee</span>&gt;();
            <span style="color: blue">for </span>(<span style="color: blue">int </span>i = 1; i &lt; 40001; i++)
            {
                employees.Add(<span style="color: blue">new </span>BusinessEntities.<span style="color: #2b91af">Employee</span>(i)
                { FirstName = <span style="color: #a31515">"John" </span>+ i,
                    LastName = <span style="color: #a31515">"Smith"</span>, Phone = <span style="color: #a31515">"+1 (425) 555-0101"</span>,
                    Email = <span style="color: #a31515">"john.smith@example.com"</span>, Address = <span style="color: #a31515">"One Microsoft Way"</span>,
                    City = <span style="color: #a31515">"Redmond"</span>, State = <span style="color: #a31515">"WA" </span>});
            }

            <span style="color: blue">return </span>employees;
        }
    }</pre>
<p>In fact, the list of employees took ages to load. I got a little deeper and found in the article mentioned above that even if the ListView performs UI Virtualization by default there are some possible reasons why <strong>UI Virtualization</strong><em> </em>could be <em>accidentally</em> disabled. One of them was that the list was unable to scroll through its content.</p>
<p>Once I checked the EmployeeListView.xaml file,  I realized that it had no specified height nor implicitly showed a vertical scroll bar. The following modification in the ListView declaration was the one that made the trick:</p>
<pre><span style="color: blue">&lt;</span><span style="color: maroon">ListView </span><span style="color: red">x:Name</span><span style="color: blue">="EmployeesList" </span><span style="color: red">ItemsSource</span><span style="color: blue">="{</span><span style="color: maroon">Binding</span><span style="color: blue">}"
</span><span style="color: red">SelectionChanged</span><span style="color: blue">="EmployeesListView_SelectionChanged"
</span><span style="color: red">Height</span><span style="color: blue">="250" </span><span style="color: red">ScrollViewer.VerticalScrollBarVisibility</span><span style="color: blue">="Visible"&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>I run the application again and it took no more than one second to load the list view.</p>
<p>I hope you can find some good use for this. Let me know if you do.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CAB QuickStarts BankTeller</title>
		<link>http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/</link>
		<comments>http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 14:22:54 +0000</pubDate>
		<dc:creator>Damian Schenkelman</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[CAB]]></category>
		<category><![CDATA[Composite UI Application Block]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[p&p]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/dschenkelman/?p=33</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" class="more-link">read more<img src="http://blogs.southworks.net/dschenkelman/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>This is the last post of a series that covers the basic ground of CAB QuickStarts from a simple point of view.</p>
<h4>Other posts in this series</h4>
<ul>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/" href="http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/" target="_blank">Event Broker QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/" href="http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/" target="_blank">Module Loader QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" href="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" target="_blank">Smartpart QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" href="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" target="_blank">Command QS</a></li>
</ul>
<h3>BankTeller QS</h3>
<p><a href="http://blogs.southworks.net/dschenkelman/files/2008/06/bankqs.png"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/bankqs-thumb.png" border="0" alt="BankQS" width="343" height="257" /></a></p>
<h4>This is a list of the procedures in this post</h4>
<ul>
<li><a href="#_Startup">Startup</a></li>
<li><a href="#_BankTellerModuleInit">BankTellerModuleInit</a></li>
<li><a href="#_BankTellerWorkItem_Show">BankTellerWorkItem Show</a></li>
<li><a href="#_Accept_Customer">Accept Customer</a></li>
<li><a href="#_Customer_List_SelectedIndexChanged">Customer List SelectedIndexChanged</a>
<ul>
<li><a href="#_Customer_WorkItem_Show">Customer WorkItem Show</a></li>
<li><a href="#_CustomerSummaryView">CustomerSummaryView</a>
<ul>
<li><a href="#_Customer_Header_View">Customer Header View</a></li>
<li><a href="#_CustomerDetailView">CustomerDetailView</a></li>
<li><a href="#_CustomerAccountsView">CustomerAccountsView</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#_Customer_Map">Customer Map</a></li>
<li><a href="#_Customer_Summary_Controller">Customer Summary Controller</a></li>
<li><a href="#_CustomerWorkItem">CustomerWorkItem</a></li>
<li><a href="#_BankShellForm">BankShellForm</a></li>
<li><a href="#_ShowCommentButton_Click">ShowCommentButton Click</a></li>
<li><a href="#_SaveButton_Click">SaveButton Click</a></li>
</ul>
<h4><a name="_Startup"></a>Startup</h4>
<ol>
<li>The <strong>shell</strong> defines the root <strong>WorkItem</strong> as the default <strong>WorkItem</strong> provided by <strong>CAB</strong>, and the starting <strong>view</strong> as <strong>BankShellForm</strong>.</li>
<li>The shell executes the <strong>Run</strong>() method. This method calls the <strong>LoadModules</strong>() method in the <strong>CabApplication</strong> class.</li>
<li>The <strong>LoadModules()</strong> method obtains the <strong>modules (</strong>.dll<strong>)</strong> by using the <strong>FileCatalogModuleEnumerator</strong>.<strong>EnumerateModules() </strong>method. What it does is search for <strong>Assembly</strong> file names in the ProfileCatalog.xml.</li>
<li>The <strong>shell</strong> then overrides the <strong>AfterShellCreated()</strong> method registering <strong>ExtensionSites </strong>by using the hardcoded strings in the <strong>UIExtensionConstants</strong> class.
<ol>
<li><strong>mainMenuStrip</strong></li>
<li><strong>mainStatusStrip</strong></li>
<li>file<strong> menu item</strong></li>
<li>file <strong>menu drop-down section</strong></li>
</ol>
</li>
</ol>
<p><a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image001.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image001-thumb.jpg" border="0" alt="clip_image001" width="240" height="70" /></a><strong></strong></p>
<p><strong><span style="font-size: xx-small">UIExtensionSiteCollection Class</span></strong></p>
<p>5.  Then the <strong>LoadFromConfig</strong>() method from the <strong>UIElementBuilder</strong> class is called.</p>
<ol>
<li>
<ol>
<li>Gets the “shellitems” section from App.config file.</li>
<li>Exeutes a <strong>foreach</strong> (statement) <strong>MenuItemElement</strong> in the section, convert it to a <strong>ToolStripMenuItem </strong>(uiMenuItem).</li>
<li>Adds the <strong>ToolStripMenuItem </strong>to the <strong>ExtensionSite</strong> collection in the <strong>WorkItem</strong>.                                                    <a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image002.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image002-thumb.jpg" border="0" alt="clip_image002" width="244" height="25" /></a></li>
<li>If the menuItem has a CommandName, add a Command to the WorkItem registering the click event.</li>
</ol>
</li>
</ol>
<p><a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image003.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image003-thumb.jpg" border="0" alt="clip_image003" width="244" height="25" /></a></p>
<p>6.   The BankTellerModuleInit (ModuleInitializer) is executed.</p>
<h4><a name="_BankTellerModuleInit"></a>BankTellerModuleInit</h4>
<ol>
<li>Uses the [<strong>Injection Constructor</strong>] which makes it the constructor to be used for <strong>Dependency Injection</strong>. It gets the <strong>WorkItem</strong> by using [<strong>Service Dependency</strong>].</li>
<li>The <strong>Load</strong>() method adds the “Customer” <strong>ToolStripMenuItem</strong> by adding it to the <strong>UIExtensionSites</strong> Collection in the <strong>WorkItem</strong>.</li>
<li>Then retrieves the Content and Sidebar <strong>WorkSpaces</strong> (with names harcoded in <strong>WorkSpacesConstants</strong> class).</li>
<li>Adds a CHILD <strong>WorkItem</strong> named <strong>BankTellerWorkItem</strong> and calls its <strong>Show</strong>() method.</li>
</ol>
<p><a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image004.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image004-thumb.jpg" border="0" alt="clip_image004" width="244" height="20" /></a></p>
<h4><a name="_BankTellerWorkItem_Show"></a>BankTellerWorkItem Show</h4>
<ol>
<li>Creates a new object <strong>UserInfoView </strong>and adds it to the <strong>WorkItem</strong>.<strong>Items</strong> collection, giving it an ID (“UserInfo”) because it will be used in a place holder. (<span style="text-decoration: underline">Remember that</span>: The <strong>SmartPartPlaceHolder</strong> placeholder control has the <strong>SmartPartName</strong> property that automatically displays a <strong>SmartPart</strong> with that name if it is found within the current <strong>WorkItem</strong>.)</li>
<li>The Constructor gets the CurrentPrincipal property of the current <strong>Thread</strong> and displays the name of the user.</li>
<li>Creates a <strong>SideBarView</strong> and adds it to the <strong>WorkItem</strong>.<strong>Items</strong> collection. Then assigns it to a <strong>SideBarView</strong> instance named <strong>sideBarView</strong>.</li>
<li>Then calls the AddMenuItems() method.
<ol>
<li>Creates a <strong>new</strong> <strong>ToolStripMenuItem</strong> (<strong>“Queue”</strong>)==&gt; queueItem</li>
<li>Adds the <strong>queueItem</strong> to the <strong>WorkItem</strong>.<strong>ExtensionSites[“File”]</strong> collection.</li>
<li>Then registers a new site [<strong>“Queue”</strong>] in the <strong>queueItem</strong>.<strong>DropDownItems</strong> collection.</li>
<li>Creates a new <strong>ToolStripMenuItem</strong> (<strong>“AcceptCustomer”</strong>) ==&gt; <strong>acceptCustomer</strong>.</li>
<li>Sets shortcut keys for <strong>acceptCustomer</strong>.</li>
<li>Adds the <strong>acceptCustomer</strong> <strong>ToolStripMenuItem</strong> to the [<strong>“Queue”</strong>] extension site.</li>
<li>Adds a new <strong>CommandInvoker</strong> to the <strong>Command</strong>[<strong>“QueueAcceptCustomer”</strong>] using <strong>acceptCustomer</strong> as the <strong>Invoker</strong> and <strong>“Click”</strong> as the <strong>EventName</strong>.   <a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image006.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image006-thumb.jpg" border="0" alt="clip_image006" width="244" height="59" /></a> <strong>Father WorkItem</strong></li>
</ol>
</li>
<li>Calls <strong>sideBar</strong>(<strong>IWorkSpace</strong>).<strong>Show</strong> method, passing <strong>sideBarView</strong> as a <strong>SmartPart</strong> parameter.</li>
<li>Activates the <strong>WorkItem</strong> (<strong>this</strong>.<strong>Activate</strong>()).</li>
<li>The BankTellerWorkItem overrides the OnActivated method, setting the bool ShowQueueMenu = true; which uses set{} to make the <strong>ToolStripMenuItem</strong> queueItem.Visible = true;</li>
<li>The <strong>SideBarView</strong> <strong>DESIGNER</strong> has a design time (redundant) addition of the <strong>CustomerQueueView</strong> <strong>SmartPart</strong>.      <a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image007.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image007-thumb.jpg" border="0" alt="clip_image007" width="240" height="13" /></a></li>
<li>The <strong>CustomerQueueView</strong> uses <strong><span style="text-decoration: underline">dependency</span></strong> <strong><span style="text-decoration: underline">injection</span></strong> [<strong>CreateNew</strong>] to initialize the <strong>CustomerQueueController</strong>.</li>
<li>Also registers the <strong>CommandHandler</strong> for the [<strong>“QueueAcceptCustomer”</strong>] <strong>command</strong>.</li>
</ol>
<h4><a name="_Accept_Customer"></a>Accept Customer</h4>
<p>(Event Handler)</p>
<ol>
<li>Registers the (<strong>“QueueAcceptCustomer”</strong>) [<strong>CommandHandler</strong>], which is referenced by acceptCustomer <strong>ToolStripMenuItem</strong>. The <strong>Event Handler</strong> is also subscribed to by the <strong>btnNextCustomer</strong> <strong>Click</strong> <strong>Event</strong>.<a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image009.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image009-thumb.jpg" border="0" alt="clip_image009" width="240" height="14" /></a><a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image010.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image010-thumb.jpg" border="0" alt="clip_image010" width="240" height="25" /></a></li>
<li>Calls the <strong>GetNextCustomerInQueue</strong>() method from the <strong>CustomerQueueController</strong>.</li>
<li>The <strong>GetNextCustomerInQueue</strong>() method calls the <strong>CustomerQueueService</strong>(which was initiated with [<strong>ServiceDependency</strong>] attribute)  <strong>GetNext</strong>() method.</li>
<li>The <strong>GetNext</strong>() method returns a <strong>new</strong> <strong>Customer</strong>.</li>
<li>The <strong>view</strong> adds the <strong>Customer</strong> to the ListItem.Item Collection.</li>
</ol>
<h4><a name="_Customer_List_SelectedIndexChanged"></a>Customer List SelectedIndexChanged</h4>
<ol>
<li>Retrieves the selected <strong>Customer</strong> from the list.</li>
<li>Calls the <strong>CustomerQueueController</strong>.<strong>WorkWithCustomer(</strong>customer<strong>)</strong> method.</li>
<li>This method calls the <strong>BankTellerWorkItem</strong>.<strong>WorkWithCustomer</strong> (customer) method.</li>
<li>Creates a <strong>string</strong> keyè <strong>“Customer#”</strong> &amp; {customer.ID}</li>
<li>If the CustomerWorkItem for that customer has been created it gets it. Else it adds a new one.
<ol>
<li>Assigns the <strong>CustomerWorkItem</strong> with the KEY to <strong>workItem</strong> object and adds it to father <strong>WorkItems</strong> collection.</li>
<li>Sets the <strong>CustomerWorkItem</strong> <strong>ID</strong>, and .<strong>State</strong>[<strong>“Customer2”</strong>] = customer.</li>
<li>If the BankTeller PersistanceService ! null &amp; contains the WorkItem.ID, load() the workItem.</li>
<li>This method uses the <strong>Services</strong>&lt;Collection&gt;.<strong>Get</strong>() method, to get the <strong>FileStatePersistance</strong> service, in order to be able to get a previously saved customer <strong>state</strong>.</li>
</ol>
</li>
<li>Calls the <strong>CustomerWorkItem</strong>.<strong>Show</strong>() method.</li>
</ol>
<h4><a name="_Customer_WorkItem_Show"></a>Customer WorkItem Show</h4>
<ol>
<li>Assigns to <strong>CustomerSummaryView</strong> object the previously existing one if !<strong>null</strong> (<strong>??</strong> operator), or adds a new <strong>view</strong> to the <strong>CustomerWorkItem</strong>.<strong>Items</strong> (Collection).</li>
<li>The calls the <strong>WorkSpace</strong>(father).<strong>Show</strong>() method using <strong>CustomerSummaryView</strong> object as a parameter.</li>
<li>Calls the <strong>AddMenuItems</strong>() method.
<ol>
<li>Creates a <strong>new</strong> instance <strong>ToolStripMenuItem</strong> named <em>editCustomerMenuItem</em>.</li>
<li>Adds the <strong>ToolStripMenuItem</strong> to the <strong>CustomerWorkItem</strong> <strong>UIExtenstionSites</strong>[<strong>“BankTellerModule.CustomerMenu”</strong>] Collection.</li>
<li>In the <strong>WorkItem</strong>’s <strong>Commands</strong>[<strong>“EditCustomer”</strong>] adds an <strong>invoker</strong> from the <em>editCustomerMenuItem</em> Click <strong>Event</strong> handler.</li>
<li>In the <strong>WorkItem</strong>’s <strong>Commands</strong>[<strong>“CustomerMouseOver”</strong>] adds an <strong>invoker</strong> from the <em>customerSummaryView</em> (<strong>CustomerSummaryView</strong> instance) MouseHover <strong>Event</strong> handler.</li>
</ol>
</li>
<li>Gets the <em>customer</em> from the <strong>WorkItem</strong>’s <strong>state</strong>.</li>
<li>Calls <strong>OnStatusTextUpdate</strong>() method, passing as parameter the first and last name of the <em>customer</em> in a string.
<ol>
<li>Raises the <strong>UpdateStatusTextEvent</strong> which is published [<strong>EventPublication</strong>] in the begginnig of the <strong>WorkItem</strong>.<a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image011.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image011-thumb.jpg" border="0" alt="clip_image011" width="240" height="17" /></a></li>
<li>The <strong>BankShellForm</strong> has an <strong>EventSubscription</strong>, <strong>OnStatusUpdate</strong>().</li>
<li>Changes the label.Text to (<strong>“Editing {FirstName} {LastName}”</strong>)</li>
</ol>
</li>
<li>Calls the <strong>UpdateUserAddressLabel</strong>() method.
<ol>
<li>Instances a <strong>new</strong> <strong>ToolStripStatusLabel</strong> named <em>addressLabel</em>.</li>
<li>Adds to the <strong>UIExtensionSites</strong> (collection)[<strong>“MainStatus”</strong>] the <em>addressLabel</em>.</li>
<li>Sets the text property of the label to the <em>customer</em>.Address1.</li>
</ol>
</li>
<li>Activates the <strong>WorkItem</strong>.</li>
<li>Calls the <strong>SmartPart</strong> <strong>CustomerSummaryView</strong>.<strong>FocusFirstTab</strong>(), which sets the SelectedTab to [0].</li>
</ol>
<p><a name="_CustomerSummaryView"></a>CustomerSummaryView</p>
<ol>
<li>The <strong>CustomerSummaryView</strong> has a <strong>TabWorkSpace</strong> which inside has:</li>
</ol>
<ul>
<li><a href="#_Customer_Header_View">CustomerHeaderView</a></li>
<li><a href="#_CustomerDetailView">CustomerDetailView</a></li>
<li><a href="#_CustomerAccountsView">CustomerAccountsView</a></li>
</ul>
<p><a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image013.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image013-thumb.jpg" border="0" alt="clip_image013" width="240" height="34" /></a> <strong>CustomerSummaryView.Designer.Cs</strong></p>
<h4>Customer Header View</h4>
<ol>
<li>The <strong>CustomerHeaderView</strong> uses the [<strong>State</strong>] attribute to get the current <em>customer</em> from the Parent <strong>WorkItem</strong>.</li>
<li>The load <strong>event</strong> binds the <em>customer</em> to the <strong>CustomerHeaderView</strong>.<strong>BindingSource</strong>.</li>
</ol>
<h4>CustomerDetailView</h4>
<ol>
<li>The <strong>CustomerDetailView</strong> uses [<strong>ServiceDependency</strong>] to get a reference to the parent <strong>WorkItem</strong>.</li>
<li>It also uses the [<strong>State</strong>] attribute to get the current <em>customer</em> from the Parent <strong>WorkItem</strong>.</li>
<li>Then uses the [<strong>CreateNew</strong>] attribute to instantiate the <strong>CustomerDetailController</strong>.</li>
<li>The overridden <strong>OnLoad</strong>() method sets the <em>customer<strong> </strong></em>to the <strong>CustomerDetailView</strong>.BindingSource.</li>
</ol>
<h4>CustomerAccountsView</h4>
<ol>
<li>The <strong>CustomerAccountsView</strong> uses the [<strong>State</strong>] attribute to get the current <em>customer</em> from the Parent <strong>WorkItem</strong>.</li>
<li>Uses [<strong>ServiceDependency</strong>] to get a reference to <strong>CustomerAccountService</strong>.</li>
<li>Overrides the <strong>OnLoad</strong>() method to call the <em>accountService</em>.GetByCustomerID (<strong><em>Customer</em></strong>.ID), which gets a <strong>ListDictionary</strong>&lt;&gt; of accounts and sets it as the datasource for the <strong>DataGrid</strong>.</li>
</ol>
<h4><a name="_Customer_Map"></a>Customer Map</h4>
<ol>
<li>The Customer Map (third tab) is loaded from the <strong>CustomerMapExtensionModule.dll </strong>when the application starts because it is in the <strong>ProfileCatalog.xml. </strong>It contains a <strong>[SmartPart] (CustomerMap)</strong> and a <strong>CustomerWorkItemExtension.</strong></li>
<li>The <strong>CustomerWorkItemExtension </strong>overrides the <strong>OnActivated</strong>() method.
<ol>
<li>Adds a <strong>CustomerMap</strong> <strong>smartpart</strong> to the <strong>WorkItemExtension</strong>.<strong>Items</strong> collection, and assigns the <strong>smartpart</strong> to <em>mapView </em>(<strong>CustomerMap</strong> instance).</li>
<li>Creates a TabSmartPartInfo (A SmartPartInfo that shows how a specific SmartPart will be shown in a tab Workspace) named <em>info.</em></li>
<li>Assigns valus to title and description properties:<a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image014.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image014-thumb.jpg" border="0" alt="clip_image014" width="240" height="34" /></a></li>
<li>Calls the <strong>WorkItem</strong>.<strong>WorkSpaces</strong>[<strong>“tabbedWorkSpace1”</strong>].<strong>Show</strong>() method, passing as parameters the <strong>CustomerMap</strong> <strong>Smartpart</strong> and the <strong>SmartPartInfo</strong>.</li>
</ol>
</li>
<li>The <strong>CustomerMap</strong> <strong>SmartPart</strong> gets a <strong>Customer</strong> instance using  [<strong>State</strong>(<strong>“Customer 2”</strong>)]</li>
</ol>
<h4><a name="_Customer_Summary_Controller"></a>Customer Summary Controller</h4>
<p>The <strong>OnCustomerEdit</strong> <strong>event</strong> handler is declared as a [<strong>CommandHandler</strong>(<strong>“EditCustomer”</strong>)]</p>
<ol>
<li>Assigns to a <strong>tabWorkSpace</strong> <em>tabWS</em> the <strong>WorkItem</strong>.<strong>WorkSpaces</strong>[<strong>“tabbedWorkSpace1”</strong>] using <strong>as</strong> cast (if it is not able to do it <strong>return</strong> <strong>null</strong>)</li>
<li>Sets the <strong>tabWorkSpace</strong>.<strong>SelectedIndex</strong> to 0, allowing customer Editing.</li>
</ol>
<h4><a name="_CustomerWorkItem"></a>CustomerWorkItem</h4>
<ol>
<li>The <strong>OnCustomerEdit</strong> <strong>event</strong> handler is declared as a [<strong>CommandHandler</strong>(<strong>“CustomerMouseOver”</strong>)] and executes when the user moves the mouse over the <strong>CustomerSummaryView</strong> <strong>SmartPart.</strong></li>
<li>If the <strong>WorkItem</strong>.<strong>Status</strong> is active, displays a ToolTipText indicating the ID of the customer being edited.</li>
</ol>
<h4><a name="_BankShellForm"></a>BankShellForm</h4>
<ol>
<li>Registers the <strong>OnStatusUpdate</strong> event handler [<strong>EventSubscription</strong>] using the topic (<strong>“topic://BankShell/statusupdate”</strong>). This <strong>event</strong> is published in the <strong>CustomerWorkItem</strong>.                        <a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image015.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image015-thumb.jpg" border="0" alt="clip_image015" width="240" height="25" /></a></li>
<li>Updates the <strong>toolStripStatusLabel1</strong>.<strong>Text</strong> with the data from the customer.</li>
</ol>
<h4><a name="_ShowCommentButton_Click"></a>ShowCommentButton Click</h4>
<ol>
<li>Calls the <strong>OnShowCustomers</strong> event handler.</li>
<li>Calls the <strong>Controller</strong>.<strong>ShowCustomerComments</strong>() method.</li>
<li>The <strong>Controller</strong>.<strong>ShowCustomerComments</strong>() method calls the <strong>WorkItem</strong>.<strong>ShowCustomerComments</strong>() method.</li>
<li>Calls the <strong>CreateCommentsView</strong>() method.
<ol>
<li>Assigns to <em>commentsView </em>(<strong>CustomerCommentsView</strong> instance) the previously existing one if !<strong>null </strong>(<strong>?? </strong>operator), or adds a new <strong>view</strong> to the <strong>CustomerWorkItem</strong>.<strong>Items</strong> collection.</li>
<li>Declares <em>info </em>as a <strong>new</strong> <strong>tabSmartPartInfo</strong>. Assigns <em>info.</em><strong>Title</strong> = “Comments”.</li>
<li>Calls the <strong>WorkItem</strong>.<strong>RegisterSmartPartInfo</strong>() method passing as parameters (<em>commentsView, info</em>)</li>
</ol>
</li>
<li>Assigns to <em>ws</em> (which implements <strong>IWorkSpace</strong> <strong>Interface</strong>) <strong>WorkItem</strong>.<strong>WorkSpaces</strong>[<strong>“tabbedWorkSpace1”</strong>].</li>
<li><em>ws</em>.<strong>Show</strong>(<em>commentsView</em>);</li>
</ol>
<h4><a name="_SaveButton_Click"></a>SaveButton Click</h4>
<ol>
<li>Calls the <strong>Controller</strong>.<strong>Save</strong>() method</li>
<li>The <strong>Controller</strong>.<strong>Save</strong>() method calls <strong>WorkItem</strong>.<strong>Save</strong>() method.</li>
<li>Declares an <strong>IStatePersistanceService</strong> <em>service</em> and gets the <strong>Services</strong>.<strong>Get</strong> &lt;<strong>IStatePersistanceService</strong>&gt;</li>
<li>Saves the changes using the <em>service</em> and calls the state.<strong>AcceptChanges</strong>() method to reset the HasChanges “flag”.</li>
</ol>
<p><a href="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image016.jpg"><img src="http://blogs.southworks.net/dschenkelman/files/2008/06/clip-image016-thumb.jpg" border="0" alt="clip_image016" width="240" height="91" /></a></p>
<p><a href="http://technorati.com/claim/xzbecd7yn2" rel="me">Technorati Profile</a></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CAB Quickstarts: Commands</title>
		<link>http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/</link>
		<comments>http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/#comments</comments>
		<pubDate>Wed, 28 May 2008 13:29:00 +0000</pubDate>
		<dc:creator>Damian Schenkelman</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[CAB]]></category>
		<category><![CDATA[Composite UI Application Block]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[p&p]]></category>

		<guid isPermaLink="false">/blogs/dschenkelman/archive/2008/05/28/CAB-Quickstarts_3A00_-Commands.aspx</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" class="more-link">read more<img src="http://blogs.southworks.net/dschenkelman/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>This is the forth post of a <a title="http://blogs.southworks.net/dschenkelman/category/cab/" href="http://blogs.southworks.net/dschenkelman/category/cab/" target="_blank">series</a> that covers the basic ground of CAB QuickStarts from a simple point of view.</p>
<h4>Other posts in this series</h4>
<ul>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/" href="http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/" target="_blank">Event Broker QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/" href="http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/" target="_blank">Module Loader QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" href="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" target="_blank">Smartpart QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" href="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" target="_blank">BankTeller QS</a></li>
</ul>
<p>For more information about CAB see:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa480450.aspx">http://msdn.microsoft.com/en-us/library/aa480450.aspx</a></li>
<li><a href="/blogs/mconverti/archive/tags/CAB/default.aspx">CAB introduction posts </a>(Spanish) by <a href="/blogs/mconverti/">Mariano</a></li>
<li><a href="/blogs/jcisneros/archive/2008/02/13/Yet-Another-Post-about-CAB.aspx">Composite UI Application Block</a>(Spanish) by <a href="/blogs/jcisneros/">Jonathan</a></li>
</ul>
<h3>Commands QS</h3>
<p>This is a list of the procedures in this post</p>
<ul>
<li><a href="#_Startup">Startup</a></li>
<li><a href="#_Menu_Item_Clicking"> Menu Item Clicking</a></li>
</ul>
<h4><a title="_Startup" name="_Startup"></a>Startup</h4>
<ol>
<li>The <strong>shell</strong> defines the <strong>MainWorkItem</strong> as the root <strong>WorkItem</strong> and the <strong>ShellForm</strong> as the first <strong>view</strong>.</li>
<li> The overridden <strong>AfterShellCreated</strong>() method assigns to <em>fileitem </em>= <strong>ToolStripMenuItem</strong> [“File”].</li>
<li>An <strong>ExtensionSite</strong> is registered in the <strong>MainWorkItem</strong>, named “File” and is a <strong>DropDownItem</strong>.</li>
<li> The <strong>MainWorkItem</strong> overridden <strong>OnRunStarted</strong>() creates a <strong>new</strong> instace of the <strong>MainController</strong> and adds it to the <strong>Workitem</strong>’s <strong>Item</strong> Collection.</li>
<li>The <strong>ProcessCommandMap</strong>() method is called, which:
<ul>
<li>Loads Command Configuration File.</li>
<li>Executes a <strong>foreach</strong> statement in the CommandMap.Mapping [array]
<ul>
<li>Creates a <strong>ToolStripMenuItem</strong> (MenuItem.Text = mapping.Label)</li>
<li> Adds to the [“File”] Extension Site (using mapping.Site as the parameter) the <strong>ToolStripMenuItem</strong>.</li>
<li>Adds to the <strong>Commands</strong> (Collection) the invoker for the “Click” event using the <strong>AddInvoker()</strong> method.</li>
</ul>
</li>
</ul>
</li>
<li>Activates the <strong>WorkItem</strong>.</li>
</ol>
<h4><a title="_Menu_Item_Clicking" name="_Menu_Item_Clicking"></a>Menu Item Clicking</h4>
<ol>
<li>The <strong>CommandHandler</strong> related to the click <strong>event</strong> raised by the item is called.</li>
<li>There are two kind of <strong>CommandHandlers</strong> now.
<ol>
<li>The <strong>ShowCustomerHandler</strong> that MessageBox.Show(“”);</li>
<li>The status kind. These 3 change the <strong>CommandStatus</strong> according to the <strong>ToolStripMenuItem</strong> pressed. (Enabled|Disabled|Unavailable(not visible in this case))</li>
<li> The <strong>ToolStripItemCommandAdapter</strong> “listens” to the <strong>CommandChanged</strong> <strong>event</strong>, and based on it changes the Enabled/Visible property of the <strong>ShowCustomerHandler ToolStripMenuItem</strong>.</li>
</ol>
</li>
</ol>
<p>The <a title="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" href="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" target="_blank">next and final post</a> in the series will cover the BankTeller QS.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CAB Quickstarts: SmartPart</title>
		<link>http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/</link>
		<comments>http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/#comments</comments>
		<pubDate>Wed, 21 May 2008 14:08:00 +0000</pubDate>
		<dc:creator>Damian Schenkelman</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[CAB]]></category>
		<category><![CDATA[Composite UI Application Block]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[p&p]]></category>

		<guid isPermaLink="false">/blogs/dschenkelman/archive/2008/05/21/Quickstart-3-SmartPart.aspx</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" class="more-link">read more<img src="http://blogs.southworks.net/dschenkelman/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>This is the third post of a <a title="http://blogs.southworks.net/dschenkelman/category/cab/" href="http://blogs.southworks.net/dschenkelman/category/cab/" target="_blank">series</a> that covers the basic ground of CAB QuickStarts from a simple point of view.</p>
<h4>Other posts in this series</h4>
<ul>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/" href="http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/" target="_blank">Event Broker QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" href="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" target="_blank">Module Loader QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" href="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" target="_blank">Commands QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" href="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" target="_blank">BankTeller QS</a></li>
</ul>
<p>For more information about CAB see:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa480450.aspx">http://msdn.microsoft.com/en-us/library/aa480450.aspx</a></li>
<li><a href="/blogs/mconverti/archive/tags/CAB/default.aspx">CAB introduction posts </a>(Spanish) by <a href="/blogs/mconverti/">Mariano</a></li>
<li><a href="/blogs/jcisneros/archive/2008/02/13/Yet-Another-Post-about-CAB.aspx">Composite UI Application Block</a>(Spanish) by <a href="/blogs/jcisneros/">Jonathan</a></li>
</ul>
<h3>SmartPart QS</h3>
<p>This is a list of the procedures in this post:</p>
<ul>
<li><a href="#_Startup">Startup</a></li>
<li><a href="#_SelectedIndexChanged_Event_(ListVie">SelectedIndexChanged Event (ListView)</a></li>
<li><a href="/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;sectionid=92&amp;postid=114379#_Comments_Button">Comments Button</a></li>
</ul>
<h4><a title="_Startup" name="_Startup"></a>Startup</h4>
<ol>
<li>The <strong>shell </strong>defines <strong>BrowseCustomerWorkItem</strong> as the default <strong>WorkItem </strong>and MainForm as the starting <strong>view</strong>.</li>
<li>The List is set in the OVERLOADED <strong>BeforeShellCreated()</strong> method.</li>
<li>The <strong>Run() </strong>method is called in the root <strong>WorkItem </strong>(<strong>BrowseCustomerWorkItem</strong>).</li>
<li>The <strong>OnRunStarted()</strong> method at <strong>BrowseCustomerWorkItem </strong>starts the <strong>CustomerView</strong> <strong>SmartPart </strong>in the <strong>MainForm</strong>’s <strong>Workspace.</strong></li>
<li>The customer view is split (<strong>SplitContainer</strong>) between a <strong>CustomerListView</strong> <strong>SmartPart </strong>and a <strong>DeckWorkspace</strong>.</li>
<li>Using Dependency Injection [<strong>CreateNew</strong>] initializes a new instance of <strong>CustomerControllers</strong>.</li>
<li>The <strong>CustomerControllers </strong>gets the list of Customers (<strong>[State("</strong>Customers<strong>"</strong><strong>)])</strong></li>
<li>The <strong>OnLoad() </strong>event handler fills the customers at the <strong>Controller</strong> and by using the <strong>State</strong> updates <strong>List</strong>&lt;<strong>Customers</strong>&gt; in the <strong>view</strong> to fill the ListBox.</li>
<li>Then it  registers the <strong>SelectedIndexChanged</strong> <strong>event</strong> from the ListBox.</li>
</ol>
<h4><a title="_SelectedIndexChanged_Event_(ListVie" name="_SelectedIndexChanged_Event_(ListVie"></a>SelectedIndexChanged Event (ListView)</h4>
<ol>
<li>The SelectedIndexChanged <strong>event</strong> fires and calls the <strong>controller’s</strong> <strong>ShowCustomerDetails</strong>() Method, passing the customer as a parameter.</li>
<li>The <strong>controller</strong> then calls the <strong>ShowCustomerDetails() </strong>method<strong> </strong>of the <strong>BrowseCustomersWorkItem</strong>.</li>
<li>The <strong>ShowCustomerDetails() </strong>method injects the “Customer” <strong>State</strong> into Child <strong>Workitems</strong>.</li>
<li>It then adds a new <strong>ViewCustomerWorkItem (</strong>as a child WorkItem<strong>)</strong> and assigns the customerWorkItem.Customer property to the current “Customer” <strong>State</strong>.</li>
<li>The <strong>customerWorkItem</strong>.<strong>Run()</strong> Method is called passing the <strong>CustomersDeckedWorkspace</strong> as a parameter.</li>
<li>The <strong>Run </strong>method creates the <strong>views</strong> to be used by the <strong>WorkItem</strong> (<strong>CustomerTabView</strong>, which has the <strong>DetailsView</strong> in the <strong>CustomerTabView</strong> designer <strong>(this.</strong>customerDetailView1<strong> = new </strong>SmartPartQuickStart<strong>.</strong>ViewCustomerWorkItem<strong>.CustomerDetailView</strong>();<strong>)</strong>,  and the <strong>CustomerSummaryView</strong>)</li>
<li>Then calls the <strong>workspace.Show() </strong>method, with the <strong>CustomerTabView </strong>as a parameter, to show the <strong>view</strong> in the <strong>workspace</strong>.</li>
<li>The <strong>CustomerDetailView</strong> uses <strong>dependency</strong> <strong>injection</strong> to [CreateNew]<strong>CustomerController</strong> (no “s”).</li>
<li>The OnLoadMethod adds the customer to the controls.</li>
</ol>
<h4><a title="_Comments_Button" name="_Comments_Button"></a>Comments Button</h4>
<ol>
<li>Gets the [<strong>State</strong> (“Customer”)] from the <strong>ViewCustomerWorkItem</strong>.</li>
<li>The <strong>OnLoad</strong>() <strong>event</strong> handler adds the Customer (provided by the <strong>State</strong>) to the BindingSource<strong>.</strong></li>
<li>Fires the Click <strong>event</strong> handler.</li>
<li>Calls the <strong>CutomerController</strong> <strong>ShowCustomerComments()</strong> method.</li>
<li>By using [Service Dependency], the <strong>Controller</strong> gets a reference to <strong>ViewCustomerWorkItem</strong>.</li>
<li>Then the <strong>ShowCustomerComments()</strong> method calls the <strong>ViewCustomerWorkItem</strong><strong>ShowCustomerComments()</strong> method.</li>
<li>Creates a <strong>Workspace</strong> called <strong>tabbedspace</strong>.</li>
<li>Adds a <strong>CustomerCommentsView</strong> <strong>SmartPart</strong> to the <strong>ViewCustomerWorkItem.</strong></li>
<li>The <strong>CustomerCommentsView</strong>:
<ol>
<li>Creates a <strong>new</strong> <strong>SmartPartInfo</strong> and assigns (“Comments”) to the <strong>SmartPartInfo</strong> title.</li>
<li>Registers the <strong>SmartPartInfo</strong> to the <strong>CustomerCommentsView</strong>.</li>
<li>Shows the <strong>tabbedspace</strong> (<strong>WorkSpace</strong>).</li>
</ol>
</li>
</ol>
<p>The <a title="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" href="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" target="_blank">next post</a> will be about the Commands QS, be sure to read it.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CAB QuickStarts: Module Loader</title>
		<link>http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/</link>
		<comments>http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/#comments</comments>
		<pubDate>Thu, 15 May 2008 02:10:00 +0000</pubDate>
		<dc:creator>Damian Schenkelman</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[CAB]]></category>
		<category><![CDATA[Composite UI Application Block]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[p&p]]></category>

		<guid isPermaLink="false">/blogs/dschenkelman/archive/2008/05/14/CAB-QuickStarts_3A00_-Module-Loader.aspx</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/" class="more-link">read more<img src="http://blogs.southworks.net/dschenkelman/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>This is the second post of a <a title="http://blogs.southworks.net/dschenkelman/category/cab/" href="http://blogs.southworks.net/dschenkelman/category/cab/" target="_blank">series</a> that covers the basic ground of CAB QuickStarts from a simple point of view.</p>
<h3>Other posts in this series</h3>
<ul>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/" href="http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/" target="_blank">Event Broker QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" href="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" target="_blank">SmartPart QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" href="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" target="_blank">Commands QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" href="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" target="_blank">BankTeller QS</a></li>
</ul>
<p>For more information about CAB see:</p>
<ul>
<li> <a title="http://msdn.microsoft.com/en-us/library/aa480450.aspx" href="http://msdn.microsoft.com/en-us/library/aa480450.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/aa480450.aspx</a></li>
<li><a title="http://staff.southworks.net/blogs/mconverti/archive/tags/CAB/default.aspx" href="/blogs/mconverti/archive/tags/CAB/default.aspx" target="_blank">CAB introduction posts </a>(Spanish) by <a title="http://staff.southworks.net/blogs/mconverti/" href="/blogs/mconverti/" target="_blank">Mariano</a></li>
<li><a title="http://staff.southworks.net/blogs/jcisneros/archive/2008/02/13/Yet-Another-Post-about-CAB.aspx" href="/blogs/jcisneros/archive/2008/02/13/Yet-Another-Post-about-CAB.aspx" target="_blank"> Composite UI Application Block</a> (Spanish) by <a title="http://staff.southworks.net/blogs/jcisneros/" href="/blogs/jcisneros/" target="_blank">Jonathan</a></li>
</ul>
<h4>Module Loader QS</h4>
<p>This is a list of the procedures in this post:</p>
<ul>
<li><a href="#_Run">Run</a></li>
<li><a href="#_Get_Latitude_Button">Get Latitude Button</a></li>
<li><a href="#_Get_Distance_Button">Get Distance Button</a></li>
</ul>
<h4><a title="_Run" name="_Run"></a>Run</h4>
<ol>
<li>The <strong>shell</strong> loads the GPSModule.dll <strong>MODULE</strong> specified in <strong>ProfileCatalog</strong>.<strong>xml</strong>, and gets there by using default implementations from the CAB.</li>
<li>Gets the <strong>ROOTWORKITEM</strong> by using <strong>ServiceDependency</strong> (is a dependency in a service and will be dependency injected when added to a work item)</li>
<li>The Load Method, adds a <strong>SampleWorkItem</strong> <span style="text-decoration: underline">from the GPS module</span> (DOES NOT EXIST IN CAB STRUCTURE).</li>
<li>The <strong>SampleWorkItem </strong>overloads the OnRunStarted Method.</li>
<li>The <strong>OnRunStarted</strong> Method:
<ol>
<li>Calls base.<strong>OnRunStarted.</strong></li>
<li>References to the Deck Workspace ["MainWorkSpace"] on the MainForm.</li>
<li>Shows the workspace by previously adding <strong>GPSview</strong> as a <em>SmartPart.</em></li>
</ol>
</li>
<li>The <strong>GPSview</strong> gets the values from <strong>GPSService</strong>, because it has a <strong>Service Dependency.</strong></li>
<li>The <strong>GPSService</strong> has a <strong>service attribute</strong> (means that it is automatically loaded into the <strong>WorkItem</strong>).</li>
<li>The reason a message box appears the first time the <strong>GetDistance</strong> <strong>Event</strong> is triggered is because the <strong>DistanceCalculatorService</strong> <strong><span style="text-decoration: underline">has a service attribute containing the property (AddOnDemand = true) </span>([Service(typeof(IDistanceCalculatorService), AddOnDemand = true)]).</strong></li>
</ol>
<h4><a title="_Get_Latitude_Button" name="_Get_Latitude_Button"></a>Get Latitude Button</h4>
<ol>
<li>The button event is fired.<strong></strong></li>
<li>The event handler calls the <strong>IGPSService</strong>.GetLatitude() Method.<strong></strong></li>
<p><strong>GPSService</strong> has the [Service(<strong>typeof(IGPSService</strong>))] meaning that when the methods described in the <strong>service</strong> are executed the ones called are in <strong>GPSService NOT IGPSService</strong> (the <strong>class</strong>, not the <strong>interface</strong>)<strong>.</strong></ol>
<h4>Get Distance Button</h4>
<ol>
<li> The <strong>IDistanceCalculatorService</strong>.ComputeDistance() Method is called by the event handler passing as values the Latitude and Longitud from the <strong>GPSService</strong>.</li>
<li>The results return because the <strong>DistanceCalculatorService </strong>has the [Service(<strong>typeof(</strong> <strong>IDistanceCalculatorService</strong>))] meaning that when the methods described in the service are executed the ones called are in <strong>DistanceCalculatorService </strong>has <strong>NOT IDistanceCalculatorService </strong>(the <strong>class</strong>, not the <strong>interface</strong>)<strong>.</strong></li>
</ol>
<p>The <a title="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" href="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/">next post</a> will be about SmartPart QS, so don&#8217;t go anywhere.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>CAB QuickStarts: Event Broker</title>
		<link>http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/</link>
		<comments>http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/#comments</comments>
		<pubDate>Tue, 13 May 2008 20:39:00 +0000</pubDate>
		<dc:creator>Damian Schenkelman</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[CAB]]></category>
		<category><![CDATA[Composite UI Application Block]]></category>
		<category><![CDATA[Patterns & Practices]]></category>
		<category><![CDATA[p&p]]></category>

		<guid isPermaLink="false">/blogs/dschenkelman/archive/2008/05/13/CAB-QuickStarts_3A00_-Event-Broker.aspx</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/dschenkelman/2008/05/13/cab-quickstarts-event-broker/" class="more-link">read more<img src="http://blogs.southworks.net/dschenkelman/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>This is the first post of a <a title="http://blogs.southworks.net/dschenkelman/category/cab/" href="http://blogs.southworks.net/dschenkelman/category/cab/" target="_blank">series</a> that will cover the basic ground of <strong>CAB QuickStarts</strong> from a simple point of view.</p>
<h3>Other posts in this series</h3>
<ul>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/" href="http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/" target="_blank">Module Loader QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" href="http://blogs.southworks.net/dschenkelman/2008/05/21/quickstart-3-smartpart/" target="_blank">SmartPart QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" href="http://blogs.southworks.net/dschenkelman/2008/05/28/cab-quickstarts-commands/" target="_blank">Commands QS</a></li>
<li><a title="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" href="http://blogs.southworks.net/dschenkelman/2008/06/12/quickstart-5-bankteller/" target="_blank">BankTeller QS</a></li>
</ul>
<p>For more information about CAB see:</p>
<ul>
<li> <a title="http://msdn.microsoft.com/en-us/library/aa480450.aspx" href="http://msdn.microsoft.com/en-us/library/aa480450.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/aa480450.aspx</a></li>
<li><a title="http://staff.southworks.net/blogs/mconverti/archive/tags/CAB/default.aspx" href="/blogs/mconverti/archive/tags/CAB/default.aspx" target="_blank">CAB introduction posts </a>(Spanish) by <a title="http://staff.southworks.net/blogs/mconverti/" href="/blogs/mconverti/" target="_blank">Mariano</a></li>
<li><a title="http://staff.southworks.net/blogs/jcisneros/archive/2008/02/13/Yet-Another-Post-about-CAB.aspx" href="/blogs/jcisneros/archive/2008/02/13/Yet-Another-Post-about-CAB.aspx" target="_blank"> Composite UI Application Block</a>(Spanish) by <a title="http://staff.southworks.net/blogs/jcisneros/" href="/blogs/jcisneros/" target="_blank">Jonathan</a></li>
</ul>
<h3>Event Broker QS</h3>
<p><span style="text-decoration: underline">This is a list of the procedures in this post:</p>
<ul>
<li><a href="#_Add_Customer_Button">Add Customer Button</a></li>
<li><a href="/#_Show_List_Button">Show List Button</a></li>
<li><a href="#_Add_Local_Button">Add Local Button</a></li>
<li><a href="#_Add_Local_Button">Add Local Button</a></li>
<li><a href="#_Add_Global_Button">Add Global Button</a></li>
<li><a href="#_Proccess_Local_Button">Process Local Button (Makes Local be Global)</a></li>
</ul>
<h3>Add Customer Button</h3>
<ol>
<li><strong>View</strong> uses button <strong>event</strong> to communicate with <strong>controller</strong>.</li>
<li>Controller adds customer in controller logic, and raises State Changed <strong>Event</strong>.</li>
<li>The <strong>view</strong> which is suscribed to this <strong>event</strong> updates the list data source.</li>
</ol>
<h3>Show List Button</h3>
<ol>
<li><strong>View </strong>uses button <strong>Event</strong> to call method.</li>
<li>Calls <strong>Controller</strong> method: ShowCustomerList.</li>
<li>Creates a new <strong>workitem</strong> and adds it as a <strong>child</strong> for the one being used.</li>
<li>Passes the current <strong>workitem’s State </strong>to the child workitem (Using a List, Empty)</li>
<li>Adds a form as a <strong>View </strong>(to the Item Collection) to the child <strong>workitem.</strong></li>
<li>The <strong>view’s </strong>constructor creates a new list <strong>[Create New] </strong>&amp; gets the <strong>state</strong> using the <strong>State </strong>attribute.</li>
<li>The OnLoad <strong>Event Handler</strong> suscribes to both the <strong>State</strong> change <strong>event</strong> in the <strong>workitem</strong>, as well as a <strong>event</strong> raised by a change of <strong>State</strong> in the parent <strong>workitem</strong>.</li>
<li>Displays the new <strong>View.</strong></li>
</ol>
<h3>Add Local Button</h3>
<ol>
<li>Calls <strong>Event</strong> for the button.</li>
<li>If there’s something in the text box it calls the <strong>controller’s</strong> add local customer method passing id.</li>
<li>Adds customer to list</li>
<li>Raises <strong>event StateChanged.</strong></li>
<li>The event handler referred to the State Changed in the view is executed.</li>
<li>The data source for the list is re-assigned.</li>
</ol>
<h3>Add Global Button</h3>
<ol>
<li>Calls <strong>event</strong> for the button.</li>
<li>If there is text calls <strong>Controller’s</strong> addGlobal Method passing id.</li>
<li>Raises the GlobalCustomerAdded <strong>Event, </strong>passing customer ID as event args.</li>
<li>The [<strong>EventPublication</strong>("<strong>topic</strong>://EventBrokerQuickStart/CustomerAdded")] in the <strong>controller “publicates” </strong>the<strong> event</strong></li>
<li>This calls the method OnCustomerAdded in the LaunchPad<strong>Controller</strong>, because it is <strong>suscribed </strong>to the <strong>topic</strong>.</li>
<li>The OnCustomerAdded calls the AddCustomer Method from the LaunchPad<strong>Controller</strong>.</li>
<li>The method adds the customer to the customer List</li>
<li>The <strong>State</strong> <strong>Changed</strong> <strong>Event</strong> is raised.</li>
<li>Both <strong>Views</strong> (CustomerListView &amp; LaunchPadForm) update their list’s datasources because they are <strong>suscribed</strong> to the <strong>event</strong>.</li>
</ol>
<h3>Proccess Local Button  (Makes Local customers be Global)</h3>
<ol>
<li>Calls the <strong>event</strong> for the button.</li>
<li>Calls <strong>CustomerListController</strong> ProcessLocalCustomer Method.</li>
<li>If nothing is being processed assign the local customer list to <strong>DictionaryEventArgs.</strong></li>
<li>Fire the &#8220;topic://EventBrokerQuickStart/StartProcess&#8221; topic.</li>
<li><strong>CustomerListController </strong>has an EventSubscription to that topic, calling the <strong>StartProcessHandler </strong>(<span style="text-decoration: underline">Thread = Background, runs on a separate thread).</li>
<li>Gets the list of customers to process from the dictionary.</li>
<li>Calls the OnProgressChanged Method that raises the <strong>ProgressChanged</strong> <strong>event</strong>.</li>
<li>The &#8220;topic://EventBrokerQuickStart/ProgressChanged&#8221; <strong>topic</strong> is suscribed to by the <strong>ProgressChangeHandler</strong>. The ProgressView updates its value by suscribing to this event.</li>
<li>Calls the AddGlobalCustomer Method that fires the GlobalCustomerAdded <strong>event</strong>.</li>
<li>The <strong>LaunchPadController</strong> suscribes to the GlobalCustomerAdded <strong>event</strong>, calling the add customer method, thus adding a customer to the customer list.</li>
<li>Raising the StateChangedEvent so the list updates its data source (The CustomerListController Clears the customers list, then raises the State Changed and Creates a progress view ).</li>
<li>The on process completed method is called in the <strong>StartProcessHandler</strong>, firing the <strong>ProcessCompleted</strong> <strong>event</strong>.</li>
<li>The <strong>ProcessCompleted</strong> <strong>eventhandler</strong> updates the processing status to false.</li>
</ol>
<p>The <a title="http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/" href="http://blogs.southworks.net/dschenkelman/2008/05/15/cab-quickstarts-module-loader/" target="_blank">next post</a> will be about the Module Loader Quickstart, stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Differencies: Delegates vs Events</title>
		<link>http://blogs.southworks.net/dschenkelman/2008/03/28/differencies-delegates-vs-events/</link>
		<comments>http://blogs.southworks.net/dschenkelman/2008/03/28/differencies-delegates-vs-events/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 22:34:00 +0000</pubDate>
		<dc:creator>Damian Schenkelman</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">/blogs/dschenkelman/archive/2008/03/28/Differencies_3A00_-Delegates-vs-Events.aspx</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/dschenkelman/2008/03/28/differencies-delegates-vs-events/" class="more-link">read more<img src="http://blogs.southworks.net/dschenkelman/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>While reading C# step by step I found a bit of a dilemma. I couldn’t get the difference between a <em>delegate</em> and an <em>event </em>asides from one needing to be called explicitly (delegate) and the other one doesn’t(event).</p>
<p>To my understanding the delegate was a way of grouping methods with similar characteristics. i.e.:<br />
<code><br />
void createdata(); &amp; void destroydata(); void methodname (no parameters);<br />
</code><br />
<code><br />
int add (int a, int b); &amp; int  substract(int a, int b); int methodname (int, int);<br />
</code><br />
Once grouped into a single delegate they could be called at once. This was really similar to what the event did. It could group either methods or delegates (who at the same time group methods, otherwise they would be pointless to have).</p>
<p>The only difference I could find was that while the delegate is declared i.e.:</p>
<p><code><em>delegate</em> void Accelerate();</code></p>
<p>the event containing the TakeOff() delegate would be declared some sort of:</p>
<p><code><em>event</em> Accelerate PushLever;<br />
</code><br />
being <em>event</em> only a modifier.</p>
<p>Some research (<a href="http://blog.monstuff.com/archives/000040.html">http://blog.monstuff.com/archives/000040.html</a> is the web page where I got the information to help me understand some of this) showed me the some differences between the two of them:</p>
<ul>
<li>Events can be included in an interface, delegates cannot.</li>
<li>Events’ scope for invocation only includes the class that declares it, delegates depend on their modifier (public | private| protected)</li>
<li>Events come with their own custom “get and set” accessors for getting or removing other methods (add, remove)</li>
<li>The signature of any delegate that is used as an event should be: “<em>The signature should be foo(object source, EventArgs e), where source is the object that fired the event and e contains any additional information about the event.”</em>(<a href="http://blog.monstuff.com/archives/000040.html">http://blog.monstuff.com/archives/000040.html</a>)</li>
</ul>
<p>From my point of view without thinking about programming semantics, an <em>event</em>, as the word states is easier to imagine representing something that happens in real life as a result of an action. This thing that happens triggers a set of actions (the <em>delegate</em>). Each small action of this set would be the methods assigned to this delegate.</p>
<p>Back to the plane example, the event is pushing the lever. The objective of doing this is getting the plane to take off. In order to do this, the plane must accelerate thus making the engines work harder (method) and set the wings straight(method). (Maybe the plane wasn’t the best example since I clearly don’t know how it works, but I hope you can get the point).</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C#</title>
		<link>http://blogs.southworks.net/dschenkelman/2008/03/17/c/</link>
		<comments>http://blogs.southworks.net/dschenkelman/2008/03/17/c/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 19:27:00 +0000</pubDate>
		<dc:creator>Damian Schenkelman</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">/blogs/dschenkelman/archive/2008/03/17/C_2300_.aspx</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/dschenkelman/2008/03/17/c/" class="more-link">read more<img src="http://blogs.southworks.net/dschenkelman/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Read chapters 1 to 4 from Microsoft Visual C# 2005.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Here&rsquo;s a summary of what I read:</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><strong><u><span style="font-size: 14pt"><font face="Calibri">Variables:</font></span></u></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><strong><u><span style="font-size: 14pt"><span style="text-decoration: none"><font face="Calibri"></font></span></span></u></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">A variable is a memory location that holds a value. You name it, so its name makes reference to what it holds.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Naming conventions:</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Symbol"><span><font size="3">·</font><span style="font: 7pt 'Times New Roman'">         </span></span></span><font size="3"><font face="Calibri">You must not use underscores.</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Symbol"><span><font size="3">·</font><span style="font: 7pt 'Times New Roman'">         </span></span></span><font size="3"><font face="Calibri">Don&rsquo;t difference them by case only. (Variable, variable).</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Symbol"><span><font size="3">·</font><span style="font: 7pt 'Times New Roman'">         </span></span></span><font size="3"><font face="Calibri">Use camelCase notation (multiword only, first word start with lower case in the first letter, then for other words use upper case for first letter and continue in lower).</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Declaration of variables is done by writing the type of it and its name. i.e.: int number;</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><strong><u><span style="font-size: 14pt"><font face="Calibri">Methods:</font></span></u></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><strong><u><span style="font-size: 14pt"><span style="text-decoration: none"><font face="Calibri"></font></span></span></u></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Methods are &#8220;<em>sequences of statements</em>&#8220;(Microsoft Visual C# 2005 Step by Step, John Sharp). They have a name (refers to what the method does) and the body (step by step of what the method will do). </font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Declaring a method:</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">returntype methodName (parameterList)</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">{</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri"><span>                </span>body statements</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">}</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">The return type represents the type of information the method will return (or void if it returns nothing). The parameter list are the different things the method needs to do what it&rsquo;s supposed to (i.e.: numbers, words, lists, etc.). When you want your method to return information you use the <em>return</em> keyword. The return statement must return the same type specified by the functions return type.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Method calling is done as following: methodName (parameterList);.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri"><strong><span style="font-size: 12pt">Scopes:</span></strong><font size="3"> The scope is the location of the program where a variable can be used. A method&rsquo;s scope is defined by &ldquo;{}&rdquo;. Everything inside them is within the method&rsquo;s scope, meaning that variables in the scope can be used by the method.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri"><strong><span style="font-size: 12pt">Overloads:</span></strong><font size="3"> Overloaded methods are those that have the same name inside the same scope. The difference between them is their parameterList.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">i.e.:<span>        </span>CalculateArea (int base, int height){}</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri"><span>                </span>CalculateArea (int base, int height,<span>  </span>string type){}</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">When the CalculateArea method is called, the compiler will define which one it is depending on its parameterList. The same method can&rsquo;t have an overload with the same types and amounts. i.e.: <span>                </span>WriteText(string title){}</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri"><span>                </span>WriteText(string body){}</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><strong><u><span style="font-size: 14pt"><font face="Calibri">Decision Statements:</font></span></u></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><strong><u><span style="font-size: 14pt"><span style="text-decoration: none"><font face="Calibri"></font></span></span></u></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Boolean operators are those that return true/false. The most common are:</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">ü</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri">== equal to</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">ü</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri">!= not equal to</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">ü</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri">&lt; less than</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">ü</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri">&lt;= less or equal than</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">ü</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri">&gt; more than</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">ü</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri">&gt;= more or equal than</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">ü</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri">&amp;&amp; (AND). The outcome of it is true only if BOTH expressions are true.</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">ü</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri">|| (OR). The outcome of it is true if either one of the expressions is true.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri"><strong><em><u><span style="font-size: 14pt">If</span></u></em></strong><strong><u><span style="font-size: 14pt"> Statements:</span></u></strong></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><strong><u><span style="font-size: 14pt"><span style="text-decoration: none"><font face="Calibri"></font></span></span></u></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">If you want to choose between executing different block of codes, depending on the result of a Boolean expression, you can use an if statement.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Syntax:</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri"><span> </span>if (Boolean expression){</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">block 1</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">}else{</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">block 2</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">}.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">If statements can also be used in a cascade manner:</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">if (i==1){</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">block 1</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">}else if (i==2){</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">block 2</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">}</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">else if (i==3){</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">block 3</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">}</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Else{nothing}.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">By doing this you say: if the first statement isn&rsquo;t true, then do the second one. If that one isn&rsquo;t true do the third one. The last one is in case none of the statements are true.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri"><strong><em><u><span style="font-size: 14pt">Switch</span></u></em></strong><strong><u><span style="font-size: 14pt"> Statements:</span></u></strong></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><strong><u><span style="font-size: 14pt"><span style="text-decoration: none"><font face="Calibri"></font></span></span></u></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">An easier way of cascading if the statements are similar is a switch statement. You&rsquo;re simply telling, if the expression is this one come here, if it&rsquo;s this other one go there. i.e.:</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">Switch (intDay)</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">{case 1: do this</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri"><span> </span>break;</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">case 2: do this</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri"><span> </span>break;</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">case 3: do this</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri"><span> </span>break;</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">default: do this</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri"><span>                </span>break;</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri">}</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font size="3"><font face="Calibri"><span> </span>This way you only go to one of the blocks. If none of them are equal then the default block is executed. The <em>break</em> keyword finishes the switch statement.</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3"></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in"><font size="3"><font face="Calibri">Rules for switch: </font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">Ø</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri">You can only use them on primitive data types (such as int, string).</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">Ø</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri"><em>&#8220;The case labels must be constant expressions&#8221;</em>(Microsoft Visual C# 2005 Step by Step, John Sharp) (1, &ldquo;1&rdquo;). If they&rsquo;re not use an IF statement.</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">Ø</font><span style="font: 7pt 'Times New Roman'"> <em> </em></span></span></span><font size="3"><font face="Calibri"><em>&#8220;Two case labels cannot have the same value.&#8221;</em>(Microsoft Visual C# 2005 Step by Step, John Sharp)</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><span style="font-family: Wingdings"><span><font size="3">Ø</font><span style="font: 7pt 'Times New Roman'">  </span></span></span><font size="3"><font face="Calibri">You can use the same statements for more than one label. But you can&rsquo;t use different statements for the same label. </font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><font size="3"><font face="Calibri">(i.e.: <span>      </span><span> </span>case Monday:</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><font size="3"><font face="Calibri"><span>                </span>case Tuesday: do this (this is correct)</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><font size="3"><font face="Calibri">Break;<span>                                   </span></font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><font face="Calibri" size="3"></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><font size="3"><font face="Calibri">case thursday:</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><font size="3"><font face="Calibri">do this</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><font size="3"><font face="Calibri"><span>            </span>case friday: do this (this is NOT correct, )</font></font></p>
<p class="MsoListParagraph" style="margin: 0in 0in 0pt 0.5in"><font size="3"><font face="Calibri">Break;<span>                   </span><span>                                                </span>)</font></font></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in"><font size="3"><font face="Calibri">You need to stop the cascading, this is generally done by using BREAK.</font></font></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
