<?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>JSEDLAK</title>
	<atom:link href="http://jsedlak.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://jsedlak.org</link>
	<description></description>
	<lastBuildDate>Sun, 21 Feb 2010 20:40:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>FGF 0.1.2.0 Released with Gesture Recognition</title>
		<link>http://jsedlak.org/2010/02/21/fgf-0-1-2-0-released-with-gesture-recognition/</link>
		<comments>http://jsedlak.org/2010/02/21/fgf-0-1-2-0-released-with-gesture-recognition/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 20:27:41 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[FGF]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Gesture Recognition]]></category>

		<guid isPermaLink="false">http://jsedlak.org/?p=603</guid>
		<description><![CDATA[New to the input engine within the Focused Games Framework is the gesture recognition capabilities, housed in the GestureTracker class. The gesture recognition class currently supports a small subset of the gestures I plan on supporting, but all are useful none-the-less. The included gestures are press, two fingered press, swipe, two fingered swipe, zoom and [...]]]></description>
			<content:encoded><![CDATA[<p>New to the input engine within the Focused Games Framework is the gesture recognition capabilities, housed in the GestureTracker class. The gesture recognition class currently supports a small subset of the gestures I plan on supporting, but all are useful none-the-less. The included gestures are press, two fingered press, swipe, two fingered swipe, zoom and pinch. To use the gesture recognition, instantiate a GestureTracker object, add it to the IGame.Modules list and then listen to its GestureTracked even. You will also need an instance of the InputManager class added to the list of modules.</p>
<p>The following is a small sample taken from one of my games that handles some simple menu swiping (a full sample is on the way).</p>
<p><i>If you do happen to use FGF, I would love to hear what you think! Drop me a line via the <a href="/contact">Contact</a> form or leave a comment here.</i></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p603code2'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6032"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code" id="p603code2"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnGestureTracked<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, GestureArgs args<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// If it wasn't a swipe, we don't care!</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>args<span style="color: #008000;">.</span><span style="color: #0000FF;">Gesture</span> <span style="color: #008000;">!=</span> Gesture<span style="color: #008000;">.</span><span style="color: #0000FF;">Swipe</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">// Get the direction of the swipe to determine what way</span>
    <span style="color: #008080; font-style: italic;">// the menus should move</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>args<span style="color: #008000;">.</span><span style="color: #0000FF;">Direction</span><span style="color: #008000;">.</span><span style="color: #0000FF;">X</span> <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// If we are capped at the right side of the menus, return</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>current <span style="color: #008000;">==</span> menus<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// Transition the menus</span>
        menus<span style="color: #008000;">&#91;</span>current<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Transition</span><span style="color: #008000;">&#40;</span>Menu<span style="color: #008000;">.</span><span style="color: #0000FF;">MoveDir</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OffToLeft</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        current<span style="color: #008000;">++;</span>
&nbsp;
        menus<span style="color: #008000;">&#91;</span>current<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Transition</span><span style="color: #008000;">&#40;</span>Menu<span style="color: #008000;">.</span><span style="color: #0000FF;">MoveDir</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnFromRight</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">else</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>current <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
&nbsp;
        menus<span style="color: #008000;">&#91;</span>current<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Transition</span><span style="color: #008000;">&#40;</span>Menu<span style="color: #008000;">.</span><span style="color: #0000FF;">MoveDir</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OffToRight</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        current<span style="color: #008000;">--;</span>
&nbsp;
        menus<span style="color: #008000;">&#91;</span>current<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Transition</span><span style="color: #008000;">&#40;</span>Menu<span style="color: #008000;">.</span><span style="color: #0000FF;">MoveDir</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnFromLeft</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><a href="/wp-content/plugins/download-monitor/download.php?id=23" class="more-link" style="margin-right:5px;float:left;"><img style="padding-top:3px;" src="/images/icons/box.png"/>&nbsp;Download FGF 0.1.2.0 Bin</a>
<div class="Clear"><!--clear--></div>
<p><span id="more-603"></span></p>
<h4>Change Log</h4>
<ul>
<li>Added gesture recognition</li>
<li>Added support for Moved state of Tracs</li>
<li>Changed Collection&lt;T&gt; class to implement interfaces directly rather than inherit from List&lt;T&gt;</li>
<li>Added angle extensions for Vector2 and Vector3</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/02/21/fgf-0-1-2-0-released-with-gesture-recognition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is DMS?</title>
		<link>http://jsedlak.org/2010/02/12/what-is-dms/</link>
		<comments>http://jsedlak.org/2010/02/12/what-is-dms/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 22:12:53 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[FGF]]></category>

		<guid isPermaLink="false">http://jsedlak.org/?p=593</guid>
		<description><![CDATA[During the last semester I was taking a class on ASP.NET where we formed teams to write a website from scratch. The website was a &#8220;project manager&#8221; that would help users maintain projects, employees and customers. Given my experience with ASP.NET prior to the class, my team hit the ground in a full on sprint. [...]]]></description>
			<content:encoded><![CDATA[<p>During the last semester I was taking a class on ASP.NET where we formed teams to write a website from scratch. The website was a &#8220;project manager&#8221; that would help users maintain projects, employees and customers. Given my experience with ASP.NET prior to the class, my team hit the ground in a full on sprint. We hit a wall when it came time to bind the site&#8217;s controls to the data behind it, in this case a Microsoft SQL database. The problems weren&#8217;t associated with a lack of knowledge but rather the gross disconnect between interfaces and the data with which they associate. It is easy to think that a textbox on a page can represent a name, but how that name is actually filled in can be the most complicated process.</p>
<p>This is just one instance of running into issues with data. How many times have you used a converter of some sort to scrub data or used a validator to make sure it can be stored? How many times have you written the same try-catch block for the SqlConnection class? How many times have you written a statement with &#8220;XmlDocument&#8221; or an instance somewhere in the middle? I have come to realize that there within the .NET Framework, there are many classes to get all the work done, but they aren&#8217;t really put together in a unified way. When you look at all the data-oriented classes (e.g. System.Xml.*, System.Data.*) you will find that there is no grand picture. For some reason the framework architects didn&#8217;t take a step back and see a possibility to unify the approach to reaching, converting, validating and consuming data.</p>
<p>So <i>what is DMS</i>? In short, the Data Management System prototype is a look into how possible it is to unify the approach to using data and whether or not it can make a developer&#8217;s life easier. The first step is to consider open architectures that are highly extensible and configurable. The <a href="http://jsedlak.org/wp-content/plugins/download-monitor/download.php?id=21">current version</a> of the DMS Prototype is focusing on just that by experimenting with converting runtime objects to and from XML. The important part isn&#8217;t the conversion; XML serialization has been done to death before. The important part to take away is that the serialization is being done in an abstracted manner. It is trying to gain as much information as possible from as little information as possible. <em>The fewer attributes a developer has to use and the more generic they are, the easier life will be</em>.</p>
<p><span id="more-593"></span></p>
<p>So what does a sample input object look like when using DMS? Something like the following class is perfectly suitable. Note that the only attribute being used here is the &#8220;NonSerialized&#8221; attribute. The others are sample attributes that may or may not be used at a later time.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p593code5'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5935"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p593code5"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> SampleObject
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> PublicInteger <span style="color: #008000;">=</span> <span style="color: #FF0000;">6</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008000;">&#91;</span>NotNullable<span style="color: #008000;">&#40;</span><span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
    <span style="color: #008000;">&#91;</span>UniqueIdentifier<span style="color: #008000;">&#93;</span>
    <span style="color: #008000;">&#91;</span>NumberConstraint<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #6666cc; font-weight: bold;">double</span><span style="color: #008000;">.</span><span style="color: #0000FF;">MaxValue</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Id <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008000;">&#91;</span>LengthConstraint<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">50</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Title <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008000;">&#91;</span>NonSerialized<span style="color: #008000;">&#93;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Secret <span style="color: #008000;">=</span> <span style="color: #FF0000;">3</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> List<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&gt;</span> RawData <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> Data <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> <span style="color: #FF0000;">5</span>, <span style="color: #FF0000;">6</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">8</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> SampleObject<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        RawData <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        RawData<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">32</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        RawData<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">64</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>I can hear you asking about how the output looks like. XML is a weird format because it can be very simple and incredibly useless (a la the built-in XML Serializer), very powerful and very messy, or somewhere in between. If you haven&#8217;t already guessed, I am shooting for somewhere in between. One of the reasons behind creating DMS is to replace the built-in serializer. For now I will save that discussion for another post, but know that it is an important issue that needs to be addressed. The following is the previous class run through the current version of DMS.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p593code6'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5936"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p593code6"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-16&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ns1:SampleObject</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">xmlns:ns2</span>=<span style="color: #ff0000;">&quot;clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">xmlns:ns3</span>=<span style="color: #ff0000;">&quot;clr-namespace:System.Collections.Generic;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">xmlns:ns1</span>=<span style="color: #ff0000;">&quot;clr-namespace:DMS.Driver;Assembly=DMS.Driver&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ns2:Int32</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Id&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ns2:String</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Title&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Hello!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ns2:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Generic</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;">&quot;System.Collections.Generic.List`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;RawData&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>32<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>64<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Generic<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ns2:Int32</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;PublicInteger&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Array</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;">&quot;System.Int32[]&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Data&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>7<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ns2:Int32<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ns1:SampleObject<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Overall, a little verbose but extremely powerful. So that is DMS in a nutshell. Would be happy to hear what you think of the idea and how the execution is going so far. You can comment here or use the <a href="/contact">Contact</a> form.</p>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/02/12/what-is-dms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing The XNA/Creators Forums</title>
		<link>http://jsedlak.org/2010/02/11/fixing-the-xna-creators-forums/</link>
		<comments>http://jsedlak.org/2010/02/11/fixing-the-xna-creators-forums/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 21:18:32 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://jsedlak.org/?p=587</guid>
		<description><![CDATA[If you hate reading the XNA Forums because of the low contrast and overly wide style, there is good news. I have managed to rewrite a bit of the CSS to drastically increase the readability of threads. As an added bonus, your overall experience on the forum will be better. The modifications were done using [...]]]></description>
			<content:encoded><![CDATA[<p>If you hate reading the <a href="http://forums.xna.com/forums">XNA Forums</a> because of the low contrast and overly wide style, there is good news. I have managed to rewrite a bit of the CSS to drastically increase the readability of threads. As an added bonus, your overall experience on the forum will be better. The modifications were done using the <a href="https://chrome.google.com/extensions/detail/plcnnpdmhobdfbponjpedobekiogmbco">Personalized Web</a> plugin for Chrome, but it works just as well in similar plugins for Firefox (I was testing in the Web Developer plugin).</p>
<p>After installing the plugin, open the Options page (through the Extensions menu item in Chrome) and add a rule for the forums that matches the url, http://forums.xna.com/forums/. Add the following CSS into the appropriate textbox and click the Save button.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p587code8'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5878"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p587code8"><pre class="css" style="font-family:monospace;">body<span style="color: #00AA00;">,</span> <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#3d3d3d</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.CommonPagingArea</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#2d2d2d</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ForumPostHeader</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.CommonDescription</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.XnaCgp_small_CreatorRollUp_Container</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.XnaCgp_small_CreatorRollUp_Forums</span> a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul<span style="color: #6666ff;">.ForumPostUserPropertyList</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul<span style="color: #6666ff;">.ForumPostUserPropertyList</span> li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
a<span style="color: #00AA00;">,</span> a<span style="color: #3333ff;">:link</span><span style="color: #00AA00;">,</span> a<span style="color: #3333ff;">:visited</span><span style="color: #00AA00;">,</span> a<span style="color: #3333ff;">:active  </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#0A67A3</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.XnaCgp_CSCommonTitle</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#efefef</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
div<span style="color: #6666ff;">.XnaCgp_shell_wide_body</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">960px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
div<span style="color: #6666ff;">.ForumPostArea</span><span style="color: #00AA00;">,</span> div<span style="color: #6666ff;">.ForumPostArea</span> table tr<span style="color: #00AA00;">,</span> div<span style="color: #6666ff;">.ForumPostArea</span> table tr td <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#efefef</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ForumPostUserArea</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ForumPostUserContent</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
td<span style="color: #6666ff;">.ForumPostContentArea</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fefefe</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
td.ForumPostContentArea<span style="color: #00AA00;">&gt;</span>table<span style="color: #00AA00;">&gt;</span>tr<span style="color: #00AA00;">&gt;</span>td <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fefefe</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
div<span style="color: #6666ff;">.ForumPostBodyArea</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fefefe</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
div<span style="color: #6666ff;">.ForumPostContentText</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#3d3d3d</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">justify</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fefefe</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.2em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
div<span style="color: #6666ff;">.ForumPostTitleArea</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fefefe</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">dashed</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#8d8d8d</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
div.ForumPostTitleArea<span style="color: #00AA00;">&gt;</span>h4 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.2em</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#2d2d2d</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Now just browse to a post and check out the changes. There are many more changes you can make, and some optimizations in the CSS so have at it.</p>
<div style="text-align:center;margin-bottom:10px;"><a href="http://jsedlak.org/images/screenshots/xna_forums/before.jpg"><img src="http://jsedlak.org/images/screenshots/xna_forums/before_small.jpg"></a></div>
<div style="text-align:center;"><a href="http://jsedlak.org/images/screenshots/xna_forums/after.jpg"><img src="http://jsedlak.org/images/screenshots/xna_forums/after_small.jpg"></a></div>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/02/11/fixing-the-xna-creators-forums/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>That&#8217;s Twitterific!</title>
		<link>http://jsedlak.org/2010/02/11/thats-twitterific/</link>
		<comments>http://jsedlak.org/2010/02/11/thats-twitterific/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 13:29:00 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://jsedlak.org/?p=581</guid>
		<description><![CDATA[Are you new to Twitter? Are you looking for some interesting people to follow? What follows is an introduction to who you should be following on Twitter. It is by no means a complete compilation of who I think is important but rather the beginning.

XNA MVP List
This is a compiled list of the XNA MVPs [...]]]></description>
			<content:encoded><![CDATA[<p>Are you new to <a href="http://twitter.com">Twitter</a>? Are you looking for some interesting people to follow? What follows is an introduction to who you should be following on Twitter. It is by no means a complete compilation of who I think is important but rather the beginning.</p>
<ul>
<li><a href="http://twitter.com/mklucher/xna-mvp">XNA MVP List</a>
<p>This is a compiled list of the XNA MVPs known to be twittering. If you are interested in XNA, you should be following these guys!</p>
</li>
<li><a href="http://twitter.com/mklucher">Michael Klucher</a>
<p>Speaking of Klucher, he is the Lead Program Manager of the XNA Development Platform at Microsoft. Follow him for an interesting view of the daily life of a Microsoftie.
</li>
<li><a href="http://twitter.com/thurrott">Paul Thurrott</a>
<p>Best known for his <a href="http://winsupersite.com">website</a>, Paul offers a fantastic viewpoint on the industry and is constantly on top of the latest products coming out of Redmond.</p>
</li>
<li><a href="http://twitter.com/billgates">Bill Gates</a>
<p>Gates is finally twittering! Follow him to stay up to date on his work and travels related to the <a href="http://www.gatesfoundation.org">Bill &amp; Melinda Gates Foundation</a>.</p>
</li>
<li><a href="http://twitter.com/shawnhargreaves">Shawn Hargreaves</a>
<p>Shawn, famous for his cat based tutorials has one of the best XNA blogs out there. If you are an XNA developer and don&#8217;t know him, you&#8217;re living under a rock.</p>
</li>
<li><a href="http://twitter.com/sgtconker">Sgt. Conker</a>
<p>Keeping up to date on all things XNA can be a daunting task some times. Thankfully <a href="http://sgtconker.com">Sgt. Conker</a> has got you covered! Follow these guys for the latest news, articles, videos and releases.</p>
</li>
<li><a href="http://twitter.com/skastudios">Ska Studios</a>
<p>Dishwasher. Charlie Murder. GAME WITH ZOMBIES. What else needs to be said? The leader in XNA game development. Follow for news not just about their latest creation but gatos as well.</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/02/11/thats-twitterific/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FGF: Modules, Not Components</title>
		<link>http://jsedlak.org/2010/01/31/fgf-modules-not-components/</link>
		<comments>http://jsedlak.org/2010/01/31/fgf-modules-not-components/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 15:13:42 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[FGF]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://jsedlak.org/?p=577</guid>
		<description><![CDATA[As you no doubt saw in the writing of the Application class, FGF implements its own version of the XNA Framework’s component classes. The first major reason for doing so is that the builtin component classes require you to pass in a (Framework) Game object through the constructor. While this dependency can be circumvented by [...]]]></description>
			<content:encoded><![CDATA[<p>As you no doubt saw in the writing of the Application class, FGF implements its own version of the XNA Framework’s component classes. The first major reason for doing so is that the builtin component classes require you to pass in a (Framework) Game object through the constructor. While this dependency can be circumvented by implementing the interfaces directly and supplying a manual workaround, the attempt is exactly that: a workaround. The second major reason for my implementation is that by controlling the interfaces and base classes, I can easily support more advanced situations such as the separation between initialization and content loading/unloading. You will see more of this later on when I modify the classes to support asynchronous content loading.</p>
<p>For now, the focus is being put on building a robust base for developers to start working with my framework. Because the goal is to fix the XNA Framework’s implementation, we begin with a simplification of the IGameComponent, IUpdateable and IDrawable interfaces. We combine these three into a single, multi-purpose interface, IModule.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code21'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57721"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p577code21"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> IModule
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">event</span> EventHandler DrawOrderChanged<span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">event</span> EventHandler UpdateOrderChanged<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">void</span> Initialize<span style="color: #008000;">&#40;</span>IGame game<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">void</span> Draw<span style="color: #008000;">&#40;</span>GameTime gameTime<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">void</span> Update<span style="color: #008000;">&#40;</span>GameTime gameTime<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">int</span> DrawOrder <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #6666cc; font-weight: bold;">int</span> UpdateOrder <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">bool</span> IsVisible <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #6666cc; font-weight: bold;">bool</span> IsEnabled <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #6666cc; font-weight: bold;">bool</span> IsInitialized <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    IModule Parent <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    ModuleCollection Modules <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><span id="more-577"></span></p>
<p>Although we have carried over many of the properties, methods and events, you should spot some key differences. Specifically the Initialize method now takes a single parameter, IGame, to remove the dependency on the Game class in the framework. Also added are the Parent and Modules properties that allow us to build a tree structure with the modules. This will become crucial to building advanced systems later on.</p>
<p>Before we can build the base class for the IModule interface, we need to build the ModuleCollection class. This class acts as a list of modules but adds added support for calling the specific methods of the IModule interface on each item in the list. This makes management of a large number of modules incredibly simple.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code22'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57722"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p577code22"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ModuleCollection <span style="color: #008000;">:</span> Collection<span style="color: #008000;">&lt;</span>IModule<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> List<span style="color: #008000;">&lt;</span>IModule<span style="color: #008000;">&gt;</span> drawList <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>IModule<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>The class inherits the custom Collection<T> class we wrote earlier to gain access to the events which we will see shortly. Note that an internal list is kept so that we can sort modules for drawing differently. The main collection will keep the modules sorted based on their update order and this way we don’t have to sort each time the modules need to be updated and drawn.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code23'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57723"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p577code23"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">public</span> T GetModule<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">where</span> T <span style="color: #008000;">:</span> <span style="color: #6666cc; font-weight: bold;">class</span>, IModule
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> Count<span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #008000;">is</span> T<span style="color: #008000;">&#41;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #0600FF; font-weight: bold;">as</span> T<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>A generic method is supplied here to make the searching and casting of modules easier on the end developer. Next we provide Initialize, Draw and Update methods that do exactly as their names imply.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code24'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57724"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p577code24"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Initialize<span style="color: #008000;">&#40;</span>IGame game<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsInitialized<span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
&nbsp;
        Game <span style="color: #008000;">=</span> game<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> Count<span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsInitialized</span><span style="color: #008000;">&#41;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Initialize</span><span style="color: #008000;">&#40;</span>game<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        IsInitialized <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Draw<span style="color: #008000;">&#40;</span>GameTime gameTime<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> drawList<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>drawList<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsVisible</span><span style="color: #008000;">&#41;</span>
                drawList<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Draw</span><span style="color: #008000;">&#40;</span>gameTime<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Update<span style="color: #008000;">&#40;</span>GameTime gameTime<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> Count<span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsEnabled</span><span style="color: #008000;">&#41;</span>
                <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span>gameTime<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>When an item is added to the list, we have to do a few things. First we have to make sure it is a module. We have to add some event handlers to its events and then we have to add it to the lists and sort each one. If the main list has been initialized, we have to initialize the module itself.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code25'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57725"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code" id="p577code25"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnItemAdded<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, CollectionChangedEventArgs args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        IModule module <span style="color: #008000;">=</span> args<span style="color: #008000;">.</span><span style="color: #0000FF;">Item</span> <span style="color: #0600FF; font-weight: bold;">as</span> IModule<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>module <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
&nbsp;
        module<span style="color: #008000;">.</span><span style="color: #0000FF;">DrawOrderChanged</span> <span style="color: #008000;">+=</span> OnModuleDrawOrderChanged<span style="color: #008000;">;</span>
        module<span style="color: #008000;">.</span><span style="color: #0000FF;">UpdateOrderChanged</span> <span style="color: #008000;">+=</span> OnModuleUpdateOrderChanged<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsInitialized <span style="color: #008000;">&amp;&amp;</span> <span style="color: #008000;">!</span>module<span style="color: #008000;">.</span><span style="color: #0000FF;">IsInitialized</span><span style="color: #008000;">&#41;</span>
            module<span style="color: #008000;">.</span><span style="color: #0000FF;">Initialize</span><span style="color: #008000;">&#40;</span>Game<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        drawList<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>module<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        drawList<span style="color: #008000;">.</span><span style="color: #0000FF;">Sort</span><span style="color: #008000;">&#40;</span>DrawOrderComparer<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Default</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        Sort<span style="color: #008000;">&#40;</span>UpdateOrderComparer<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Default</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnItemAdded</span><span style="color: #008000;">&#40;</span>sender, args<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnModuleUpdateOrderChanged<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Sort<span style="color: #008000;">&#40;</span>UpdateOrderComparer<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Default</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnModuleDrawOrderChanged<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        drawList<span style="color: #008000;">.</span><span style="color: #0000FF;">Sort</span><span style="color: #008000;">&#40;</span>DrawOrderComparer<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Default</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Later, when a module is removed, we have to remove those event handlers and remove it from any internal list. Essentially this is the reverse process of adding, except that we do not have to resort the lists.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code26'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57726"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p577code26"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnItemRemoved<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, CollectionChangedEventArgs args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        IModule module <span style="color: #008000;">=</span> args<span style="color: #008000;">.</span><span style="color: #0000FF;">Item</span> <span style="color: #0600FF; font-weight: bold;">as</span> IModule<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>module <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
&nbsp;
        module<span style="color: #008000;">.</span><span style="color: #0000FF;">DrawOrderChanged</span> <span style="color: #008000;">-=</span> OnModuleDrawOrderChanged<span style="color: #008000;">;</span>
        module<span style="color: #008000;">.</span><span style="color: #0000FF;">UpdateOrderChanged</span> <span style="color: #008000;">-=</span> OnModuleUpdateOrderChanged<span style="color: #008000;">;</span>
&nbsp;
        drawList<span style="color: #008000;">.</span><span style="color: #0000FF;">Remove</span><span style="color: #008000;">&#40;</span>module<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnItemRemoved</span><span style="color: #008000;">&#40;</span>sender, args<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And finally some properties to close off the class.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code27'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57727"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p577code27"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">protected</span> IGame Game <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsInitialized <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Now that we have the ModuleCollection class, we can write the Module (base) class itself. The class is a basic implementation of the IModule interface and inherits the NotifyPropertyChangedBase class to support some advanced data &#038; binding situations.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code28'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57728"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p577code28"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> Module <span style="color: #008000;">:</span> NotifyPropertyChangedBase, IModule
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">int</span> drawOrder <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">int</span> updateOrder <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> isVisible <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> isEnabled <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> IModule parent <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> EventHandler DrawOrderChanged<span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> EventHandler UpdateOrderChanged<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> Module<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Modules <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ModuleCollection<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        Modules<span style="color: #008000;">.</span><span style="color: #0000FF;">ItemAdded</span> <span style="color: #008000;">+=</span> OnModuleAdded<span style="color: #008000;">;</span>
        Modules<span style="color: #008000;">.</span><span style="color: #0000FF;">ItemRemoved</span> <span style="color: #008000;">+=</span> OnModuleRemoved<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>When the DrawOrder or UpdateOrder properties are changed, we need to invoke their respective events.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code29'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57729"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p577code29"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnDrawOrderChanged<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>DrawOrderChanged <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> DrawOrderChanged<span style="color: #008000;">.</span><span style="color: #0000FF;">Invoke</span><span style="color: #008000;">&#40;</span>sender, args<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnUpdateOrderChanged<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>UpdateOrderChanged <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> UpdateOrderChanged<span style="color: #008000;">.</span><span style="color: #0000FF;">Invoke</span><span style="color: #008000;">&#40;</span>sender, args<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>When a child module is added, we have to set its parent. Similarly when a module is removed, we have to unset the parent (if it hasn’t been manually changed).</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code30'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57730"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p577code30"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnModuleAdded<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, CollectionChangedEventArgs args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        IModule module <span style="color: #008000;">=</span> args<span style="color: #008000;">.</span><span style="color: #0000FF;">Item</span> <span style="color: #0600FF; font-weight: bold;">as</span> IModule<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>module <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
&nbsp;
        module<span style="color: #008000;">.</span><span style="color: #0000FF;">Parent</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnModuleRemoved<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, CollectionChangedEventArgs args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        IModule module <span style="color: #008000;">=</span> args<span style="color: #008000;">.</span><span style="color: #0000FF;">Item</span> <span style="color: #0600FF; font-weight: bold;">as</span> IModule<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>module <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// First we check to ensure that the developer</span>
        <span style="color: #008080; font-style: italic;">// hasn't set the parent manually to some other</span>
        <span style="color: #008080; font-style: italic;">// object before we remove ourselves as parent.</span>
        <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>module<span style="color: #008000;">.</span><span style="color: #0000FF;">Parent</span> <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#41;</span>
            module<span style="color: #008000;">.</span><span style="color: #0000FF;">Parent</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>The Initialize, Draw and Update methods are incredibly straight forward. For the most part the respective method is called on the list of child modules.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code31'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57731"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p577code31"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> Initialize<span style="color: #008000;">&#40;</span>IGame game<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Game <span style="color: #008000;">=</span> game<span style="color: #008000;">;</span>
&nbsp;
        Modules<span style="color: #008000;">.</span><span style="color: #0000FF;">Initialize</span><span style="color: #008000;">&#40;</span>game<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        IsInitialized <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> Draw<span style="color: #008000;">&#40;</span>GameTime gameTime<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Modules<span style="color: #008000;">.</span><span style="color: #0000FF;">Draw</span><span style="color: #008000;">&#40;</span>gameTime<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> Update<span style="color: #008000;">&#40;</span>GameTime gameTime<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Modules<span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span>gameTime<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And last but not least the properties.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p577code32'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57732"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
</pre></td><td class="code" id="p577code32"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> DrawOrder
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> drawOrder<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            drawOrder <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
&nbsp;
            OnDrawOrderChanged<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, EventArgs<span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> UpdateOrder
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> updateOrder<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            updateOrder <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
&nbsp;
            OnUpdateOrderChanged<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, EventArgs<span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsVisible
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> isVisible<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        set <span style="color: #008000;">&#123;</span> isVisible <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsEnabled
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> isEnabled<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        set <span style="color: #008000;">&#123;</span> isEnabled <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> IModule Parent
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> parent<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        set <span style="color: #008000;">&#123;</span> parent <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsInitialized <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">protected</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> ModuleCollection Modules <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> IGame Game <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Now that we have our base module class, we can start creating games without using the builtin component classes!</p>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/01/31/fgf-modules-not-components/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FGF: A Collection Class with Events</title>
		<link>http://jsedlak.org/2010/01/31/fgf-a-collection-class-with-events/</link>
		<comments>http://jsedlak.org/2010/01/31/fgf-a-collection-class-with-events/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 15:06:04 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[FGF]]></category>

		<guid isPermaLink="false">http://jsedlak.org/?p=573</guid>
		<description><![CDATA[For most purposes, the builtin collection classes supplied by the .NET Framework are terrific. They are simple and straight forward implementations that do exactly as you expect. But for our purposes, a collection class that fires events when the collection is changed is simply better and in some cases, necessary. For this class, we make [...]]]></description>
			<content:encoded><![CDATA[<p>For most purposes, the builtin collection classes supplied by the .NET Framework are terrific. They are simple and straight forward implementations that do exactly as you expect. But for our purposes, a collection class that fires events when the collection is changed is simply better and in some cases, necessary. For this class, we make the jump over to the FocusedGames.Collections namespace, maintained in the FocusedGames library.</p>
<p>Before writing the collection class itself, we need a delegate that can define how our events will work. Enter the CollectionChangedHandler delegate.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p573code38'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57338"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p573code38"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">delegate</span> <span style="color: #6666cc; font-weight: bold;">void</span> CollectionChangedHandler<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, CollectionChangedEventArgs args<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>As you can see, we need to define the CollectionChangedEventArgs class itself. This is a simple class that has two properties. The two properties help listeners of the events to understand how the collection was changed.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p573code39'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57339"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p573code39"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> CollectionChangedEventArgs <span style="color: #008000;">:</span> EventArgs
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> CollectionChangedEventArgs<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> CollectionChangedEventArgs<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Item <span style="color: #008000;">=</span> item<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> CollectionChangedEventArgs<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> item, <span style="color: #6666cc; font-weight: bold;">int</span> index<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Index <span style="color: #008000;">=</span> index<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">object</span> Item <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Index <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><span id="more-573"></span></p>
<p>In the future, I hope that I can implement the INotifyCollectionChanged interface from the .NET Framework. Unfortunately I refuse to do so because the interface is placed in a DLL that is not supported on some frameworks that I need to support with the FG Framework. Instead, I have written my own ICollection interface that basically takes the place of the .NET Framework’s interface.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p573code40'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57340"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p573code40"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> ICollection
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">event</span> CollectionChangedHandler ItemAdded<span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">event</span> CollectionChangedHandler ItemRemoved<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>When combined with the .NET Framework’s List<T> class, a powerful collection class is created.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p573code41'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57341"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p573code41"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> Collection<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> <span style="color: #008000;">:</span> ICollection, IList<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span>, ICollection<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span>, IEnumerable<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span>, IList, <span style="color: #000000;">System.<span style="color: #0000FF;">Collections</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">ICollection</span>, IEnumerable
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> CollectionChangedHandler ItemAdded<span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> CollectionChangedHandler ItemRemoved<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> List<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> internalList <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsViableType<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>item <span style="color: #008000;">is</span> T <span style="color: #008000;">&amp;&amp;</span> item <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnItemAdded<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, CollectionChangedEventArgs args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>ItemAdded <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> ItemAdded<span style="color: #008000;">.</span><span style="color: #0000FF;">Invoke</span><span style="color: #008000;">&#40;</span>sender, args<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnItemRemoved<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, CollectionChangedEventArgs args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>ItemRemoved <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> ItemRemoved<span style="color: #008000;">.</span><span style="color: #0000FF;">Invoke</span><span style="color: #008000;">&#40;</span>sender, args<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>But it is more complicated than that. We have to implement every single interface. I am not going to bother explaining each one because they are all simple pass through methods.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p573code42'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57342"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
</pre></td><td class="code" id="p573code42"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080;">#region Sorting</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Sort<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">Sort</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Sort<span style="color: #008000;">&#40;</span>IComparer<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> comparer<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">Sort</span><span style="color: #008000;">&#40;</span>comparer<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> AddRange<span style="color: #008000;">&#40;</span>IEnumerable<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> items<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>T item <span style="color: #0600FF; font-weight: bold;">in</span> items<span style="color: #008000;">&#41;</span>
            Add<span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080;">#region IList&lt;T&gt; Members</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> IndexOf<span style="color: #008000;">&#40;</span>T item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">IndexOf</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Insert<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> index, T item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">Insert</span><span style="color: #008000;">&#40;</span>index, item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        OnItemAdded<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, <span style="color: #008000;">new</span> CollectionChangedEventArgs<span style="color: #008000;">&#40;</span>item, index<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> RemoveAt<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> index<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        T item <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
        internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">RemoveAt</span><span style="color: #008000;">&#40;</span>index<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        OnItemRemoved<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, <span style="color: #008000;">new</span> CollectionChangedEventArgs<span style="color: #008000;">&#40;</span>item, index<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> T <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span><span style="color: #6666cc; font-weight: bold;">int</span> index<span style="color: #008000;">&#93;</span>
    <span style="color: #008000;">&#123;</span>
        get
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> internalList<span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            internalList<span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080;">#region ICollection&lt;T&gt; Members</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Add<span style="color: #008000;">&#40;</span>T item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        OnItemAdded<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, <span style="color: #008000;">new</span> CollectionChangedEventArgs<span style="color: #008000;">&#40;</span>item, Count <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Clear<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// TODO: How do throw the event here?</span>
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> Count <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i<span style="color: #008000;">--</span><span style="color: #008000;">&#41;</span>
            RemoveAt<span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">Clear</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> Contains<span style="color: #008000;">&#40;</span>T item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> CopyTo<span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> array, <span style="color: #6666cc; font-weight: bold;">int</span> arrayIndex<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">CopyTo</span><span style="color: #008000;">&#40;</span>array, arrayIndex<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Count
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">bool</span> ICollection<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;.</span><span style="color: #0000FF;">IsReadOnly</span>
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> Remove<span style="color: #008000;">&#40;</span>T item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">int</span> index <span style="color: #008000;">=</span> internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">IndexOf</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #6666cc; font-weight: bold;">bool</span> returnValue <span style="color: #008000;">=</span> internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">Remove</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        OnItemRemoved<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, <span style="color: #008000;">new</span> CollectionChangedEventArgs<span style="color: #008000;">&#40;</span>item, index<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> returnValue<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080;">#region IEnumerable&lt;T&gt; Members</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> IEnumerator<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> GetEnumerator<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetEnumerator</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080;">#region IEnumerable Members</span>
    IEnumerator IEnumerable<span style="color: #008000;">.</span><span style="color: #0000FF;">GetEnumerator</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetEnumerator</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080;">#region IList Members</span>
    <span style="color: #6666cc; font-weight: bold;">int</span> IList<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> value<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsViableType<span style="color: #008000;">&#40;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Add<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">IndexOf</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">bool</span> IList<span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> value<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsViableType<span style="color: #008000;">&#40;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> Contains<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">int</span> IList<span style="color: #008000;">.</span><span style="color: #0000FF;">IndexOf</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> value<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>IsViableType<span style="color: #008000;">&#40;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> internalList<span style="color: #008000;">.</span><span style="color: #0000FF;">IndexOf</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">void</span> IList<span style="color: #008000;">.</span><span style="color: #0000FF;">Insert</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> index, <span style="color: #6666cc; font-weight: bold;">object</span> value<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsViableType<span style="color: #008000;">&#40;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            Insert<span style="color: #008000;">&#40;</span>index, <span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">bool</span> IList<span style="color: #008000;">.</span><span style="color: #0000FF;">IsFixedSize</span>
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">void</span> IList<span style="color: #008000;">.</span><span style="color: #0000FF;">Remove</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> value<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsViableType<span style="color: #008000;">&#40;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            Remove<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">object</span> IList<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span><span style="color: #6666cc; font-weight: bold;">int</span> index<span style="color: #008000;">&#93;</span>
    <span style="color: #008000;">&#123;</span>
        get
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> internalList<span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>value <span style="color: #008000;">is</span> T <span style="color: #008000;">&amp;&amp;</span> value <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
                internalList<span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>value<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">bool</span> IList<span style="color: #008000;">.</span><span style="color: #0000FF;">IsReadOnly</span>
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080;">#region ICollection Members</span>
    <span style="color: #6666cc; font-weight: bold;">void</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Collections</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">ICollection</span><span style="color: #008000;">.</span><span style="color: #0000FF;">CopyTo</span><span style="color: #008000;">&#40;</span>Array array, <span style="color: #6666cc; font-weight: bold;">int</span> index<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">throw</span> <span style="color: #008000;">new</span> NotImplementedException<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">bool</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Collections</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">ICollection</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsSynchronized</span>
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">object</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Collections</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">ICollection</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SyncRoot</span>
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And there you have it, a collection that fires events when an item is added or removed. In the future, I plan to clean this class up. I decided to include the non-generic interfaces only because the .NET Framework’s List<T> class has implemented them.</p>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/01/31/fgf-a-collection-class-with-events/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FGF: A Base Class For INotifyPropertyChanged</title>
		<link>http://jsedlak.org/2010/01/31/fgf-a-base-class-for-inotifypropertychanged/</link>
		<comments>http://jsedlak.org/2010/01/31/fgf-a-base-class-for-inotifypropertychanged/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 13:06:17 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[FGF]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://jsedlak.org/?p=569</guid>
		<description><![CDATA[One piece of functionality I consistently find myself writing and rewriting is the implementation of the INotifyPropertyChanged interface. This class, located in the main FGF library, makes that rewriting unnecessary by implementing it in an open way.

?View Code CSHARP1
2
3
4
5
public class NotifyPropertyChangedBase : INotifyPropertyChanged
&#123;
    private bool isDirty = false;
&#160;
    public [...]]]></description>
			<content:encoded><![CDATA[<p>One piece of functionality I consistently find myself writing and rewriting is the implementation of the INotifyPropertyChanged interface. This class, located in the main FGF library, makes that rewriting unnecessary by implementing it in an open way.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p569code47'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p56947"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p569code47"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> NotifyPropertyChangedBase <span style="color: #008000;">:</span> INotifyPropertyChanged
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> isDirty <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> PropertyChangedEventHandler PropertyChanged<span style="color: #008000;">;</span></pre></td></tr></table></div>

<p><span id="more-569"></span></p>
<p>A virtual method is then added to allow end developers to change how the class reacts to when properties are changed.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p569code48'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p56948"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p569code48"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">bool</span> CanSetDirty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">!</span>DisableDirtyFlag<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>To fire the event, a simple method is written that can be used by end developers. This method makes a call to a virtual method that actually fires the event and sets the IsDirty property.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p569code49'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p56949"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p569code49"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnPropertyChanged<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> propertyName<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        OnPropertyChanged<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, <span style="color: #008000;">new</span> PropertyChangedEventArgs<span style="color: #008000;">&#40;</span>propertyName<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnPropertyChanged<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, PropertyChangedEventArgs args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>args<span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyName</span> <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;IsDirty&quot;</span><span style="color: #008000;">&#41;</span>
            IsDirty <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>PropertyChanged <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> PropertyChanged<span style="color: #008000;">.</span><span style="color: #0000FF;">Invoke</span><span style="color: #008000;">&#40;</span>sender, args<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And finally the properties:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p569code50'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p56950"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p569code50"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> DisableDirtyFlag <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsDirty
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> isDirty<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>CanSetDirty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                isDirty <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
&nbsp;
                OnPropertyChanged<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;IsDirty&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/01/31/fgf-a-base-class-for-inotifypropertychanged/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linking To CSS Files In MasterPages</title>
		<link>http://jsedlak.org/2010/01/22/linking-to-css-files-in-masterpages/</link>
		<comments>http://jsedlak.org/2010/01/22/linking-to-css-files-in-masterpages/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 18:45:44 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://jsedlak.org/?p=562</guid>
		<description><![CDATA[A common problem for beginning ASP.NET developers is relative linking to CSS files in a MasterPage file. As it turns out, this is incredibly easy as shown below. Even better is that it works in ASP.NET MVC!

?View Code HTML1
&#60;link rel=&#34;Stylesheet&#34; href=&#34;&#60;%= ResolveUrl(&#34;css/Master.css&#34;) %&#62;&#34; type=&#34;text/css&#34; media=&#34;screen&#34; /&#62;

]]></description>
			<content:encoded><![CDATA[<p>A common problem for beginning ASP.NET developers is relative linking to CSS files in a MasterPage file. As it turns out, this is incredibly easy as shown below. Even better is that it works in ASP.NET MVC!</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p562code52'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p56252"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p562code52"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;Stylesheet&quot; href=&quot;&lt;%= ResolveUrl(&quot;css/Master.css&quot;) %&gt;&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/01/22/linking-to-css-files-in-masterpages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two Thousand And Ten</title>
		<link>http://jsedlak.org/2010/01/14/two-thousand-and-ten/</link>
		<comments>http://jsedlak.org/2010/01/14/two-thousand-and-ten/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 18:15:58 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://jso.fg.com/?p=554</guid>
		<description><![CDATA[It&#8217;s a new year and that means it is a time for changes, upgrades, resolutions, and new ideas! Last year was an awesome year for me. I completed my undergraduate career and am now waiting for confirmation from my university. I also completed my first major, professional project (nymagic.com) and learned a lot in doing [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a new year and that means it is a time for changes, upgrades, resolutions, and new ideas! Last year was an awesome year for me. I completed my undergraduate career and am now waiting for confirmation from my university. I also completed my first major, professional project (<a href="http://nymagic.com">nymagic.com</a>) and learned a lot in doing so. In the spirit of resolutions and renewals I have decided to consolidate my sites and really give them a complete revamping. Here is just some of what I am planning to accomplish this year.</p>
<h4>jsedlak.org / jsedlak.com Revamp</h4>
<p>I have decided to combine jsedlak.com and jsedlak.org into one site, bringing over content from jsedlak.com from previous years. I have also given it a complete redesign and brought over articles from the Focused Games site. Over the course of 2010 I plan to write more articles and blog posts related to XNA and ASP.NET as well as the usual topics. I have added a few pages, cleaned up others and removed the unnecessary ones in an attempt to make the site more useful to visitors.</p>
<h4>focusedgames.com</h4>
<p>I plan to move the site for Focused Games to an ASP.NET CMS (to be named) and use it primarily as a house for all content related to the Focused Games Framework. One primary feature of which will be a bug/suggestion database for the framework and any other projects I have published.</p>
<h4>Cycling</h4>
<p>Last year was my first year getting into the sport and I managed three centuries and a total of over 4200 miles. Unfortunately I do not believe I can top that this year but I am sure going to try. I have already been out once and plan to get out a lot more in January. The other cycling thing I did last year was enter some races. I definitely plan to do this again and beat my previous times, but work may get in the way.</p>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/01/14/two-thousand-and-ten/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FGF: Oriented Drawing</title>
		<link>http://jsedlak.org/2010/01/12/fgf-oriented-drawing/</link>
		<comments>http://jsedlak.org/2010/01/12/fgf-oriented-drawing/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 11:40:57 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[FGF]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Zune HD]]></category>

		<guid isPermaLink="false">http://jso.fg.com/?p=532</guid>
		<description><![CDATA[After you&#8217;ve read about the Display Orientation features of FGF, a natural question to ask is &#8220;How do I draw and take input with a rotated display?&#8221; Fortunately FGF has some methods to help in this department that sit alongside the rotation methods and properties in the Application class.
Application.OrientedDisplaySize
If you need to draw something relative [...]]]></description>
			<content:encoded><![CDATA[<p>After you&#8217;ve read about the <a href="/2010/01/11/fgf-display-orientation-on-the-zune-hd/">Display Orientation</a> features of FGF, a natural question to ask is &#8220;How do I draw and take input with a rotated display?&#8221; Fortunately FGF has some methods to help in this department that sit alongside the rotation methods and properties in the Application class.</p>
<h4>Application.OrientedDisplaySize</h4>
<p>If you need to draw something relative to the size of the screen, use the <i>OrientedDisplaySize</i> property of the Application class. This property differs from <i>DisplaySize</i>, which is used to change the actual size of the display, in that <i>OrientatedDisplaySize</i> reacts to the selected rotation of the display, set with the <i>DisplayOrientation</i> property.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p532code54'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p53254"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p532code54"><pre class="csharp" style="font-family:monospace;">DisplaySize <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Vector2<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">272</span>, <span style="color: #FF0000;">480</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
DisplayOrientation <span style="color: #008000;">=</span> DisplayOrientation<span style="color: #008000;">.</span><span style="color: #0000FF;">Rotated</span><span style="color: #008000;">;</span>
&nbsp;
Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span>OrientedDisplaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Because the display is set to be rotated (landscape on the Zune HD), the above code will actually print out a display size of (480, 272) rather than the standard (272, 480) size.</p>
<p><span id="more-532"></span></p>
<h4>Application.DisplayOrientation</h4>
<p>Get or set the orientation of the display. Setting this value to standard will set landscape mode on the PC and portrait mode on the Zune HD. At the time of writing this article, the PC/Xbox360 version of FGF does not support rotating the display but setting the orientation to Rotated on the Zune HD will enable landscape mode.</p>
<h4>Application.DisplayRotation</h4>
<p>You can view the rotation value being used to render the global render target through this property. Note that this property is used in conjunction with the <i>DisplaySpriteEffects</i> and <i>DisplayOrientation</i> properties and cannot be set manually.</p>
<h4>DisplaySpriteEffects</h4>
<p>You can view the sprite effectsbeing used to render the global render target through this property. Note that this property is used in conjunction with the <i>DisplayRotation</i> and <i>DisplayOrientation</i> properties and cannot be set manually.</p>
<h4>Application.DisplaySize</h4>
<p>The standard size of the display is given by the <i>DisplaySize</i> property. Set this property to change the size of the display at any time.</p>
<h4>Application.ScreenToObject(Vector2)</h4>
<p>The <i>ScreenToObject</i> method is used to translate screen space coordinates into object space coordinates. The major use of this method is to translate touch panel positions into object space where they can be used for object selection.</p>
<h4>Application.ObjectToScreen(Vector2)</h4>
<p>Opposite of the <i>ScreenToObject</i> method, <i>ObjectToScreen</i> converts object space coordinates to screen space coordinates. Note that the resulting coordinates are <b>not</b> to be used for drawing in an oriented application; objects will automatically be rotated and positioned correctly via the global render target.</p>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/01/12/fgf-oriented-drawing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
