<?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 &#187; C#</title>
	<atom:link href="http://jsedlak.org/category/coding/net/c-net-coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://jsedlak.org</link>
	<description></description>
	<lastBuildDate>Wed, 01 Sep 2010 00:44:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Korkboard 1.0.0.4</title>
		<link>http://jsedlak.org/2010/07/08/korkboard-1-0-0-4/</link>
		<comments>http://jsedlak.org/2010/07/08/korkboard-1-0-0-4/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 11:20:55 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Applications]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[Korkboard]]></category>

		<guid isPermaLink="false">http://jsedlak.org/?p=655</guid>
		<description><![CDATA[Korkboard is a little tool I have been developing that enables a uniform method of storing multiple items on the clipboard. When Korkboard runs, it hooks into the clipboard chain and attempts to intercept messages as you use the Copy and Cut commands. It then stores the items on its own list so that they [...]]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin-left:20px;"><a href="/apps#korkboard"><img src="http://jsedlak.org/images/screenshots/cb/cb4_small.jpg" alt="Korkboard Screenshot"></a></div>
<p><a href="/apps#korkboard">Korkboard</a> is a little tool I have been developing that enables a uniform method of storing multiple items on the clipboard. When Korkboard runs, it hooks into the clipboard chain and attempts to intercept messages as you use the Copy and Cut commands. It then stores the items on its own list so that they may be retrieved at a later time. It is important to note that Korkboard does <b>not</b> mess with the functionality of the clipboard. If you copy an item, the clipboard works as expected without any interruption or user required interception. Check it out, and let me know what you think!</p>
<ul>
<li><a href="http://jsedlak.org/wp-content/plugins/download-monitor/download.php?id=25" title="Downloaded 177 times.">Korkboard v1.1.0.0 (177)</a></li>
<li><a href="http://jsedlak.org/wp-content/plugins/download-monitor/download.php?id=26" title="Downloaded 22 times.">Korkboard (Zip) v1.0.0.4 (22)</a></li>
</ul>
<p>Korkboard is written in WPF/.NET4 and uses ClickOnce to manage the installation and update processes.</p>
<p>Update: Added the Zip file for those having trouble using the ClickOnce method.</p>
<div style="clear:both;"><!--clear--></div>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2010/07/08/korkboard-1-0-0-4/feed/</wfw:commentRss>
		<slash:comments>4</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('p593code3'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5933"><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="p593code3"><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('p593code4'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5934"><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="p593code4"><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>FGF: It&#8217;s All About Abstraction</title>
		<link>http://jsedlak.org/2009/11/16/fgf-its-all-about-abstraction/</link>
		<comments>http://jsedlak.org/2009/11/16/fgf-its-all-about-abstraction/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 15:41:58 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[FGF]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://jsedlak.com/?p=256</guid>
		<description><![CDATA[One of the major themes present in the design of FGF is abstraction of functionality from its implementation. The major reason for this is because one of the major goals of FGF is to provide functionality without forcing developers into a corner. The idea is if the base of the framework is modular and open, [...]]]></description>
			<content:encoded><![CDATA[<p>One of the major themes present in the design of FGF is abstraction of functionality from its implementation. The major reason for this is because one of the major goals of FGF is to provide functionality without forcing developers into a corner. The idea is if the base of the framework is modular and open, the rest of the framework will fall into place very easily. So I begin the implementation of FGF by <span style="text-decoration:line-through;">fixing</span>improving the XNA Framework&#8217;s Game class with an abstraction of its functionality. The reason for which will become apparent when the component classes are improved at a later time.</p>
<p>The important question to ask here is what can a game do? We can run a game, and exit a game but also add and remove components and services. Thus the IGame interface is born (within the FocusedGames.Xna project):</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('p256code19'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25619"><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
</pre></td><td class="code" id="p256code19"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Xna.Framework</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> FocusedGames<span style="color: #008000;">.</span><span style="color: #0000FF;">Xna</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> IGame
    <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">void</span> Run<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">void</span> Exit<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        Vector2 ObjectToScreen<span style="color: #008000;">&#40;</span>Vector2 objectVector<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        Vector2 ScreenToObject<span style="color: #008000;">&#40;</span>Vector2 screenVector<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        GraphicsDeviceManager DeviceManager <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
        DisplayOrientation DisplayOrientation <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        Vector2 DisplaySize <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: #6666cc; font-weight: bold;">bool</span> IsLoaded <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;">float</span> TargetFrameRate <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;
        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>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><span id="more-256"></span></p>
<p>It should be immediately obvious that there are elements to this code that do not compile. I have added extra functionality due to the foresight of working with the Zune HD device and its re-orientating capabilities. Mainly the IGame interface (and any class that implements it) needs to provide a mechanism for dealing with how the screen and the objects within that screen are presented to the user. As for the last element, <i>Modules</i>, don&#8217;t worry about that for now as it will be covered in the next section.</p>
<p>Before implementing the IGame interface, the DisplayOrientation enumeration needs to be defined. You may have better terminology for all the options, I went with what came to my head initially and admit they aren&#8217;t the most descriptive choices. Remember that they have to describe the orientation on all the platforms and that the Zune HD&#8217;s landscape mode is much like the PC&#8217;s standard mode in terms of aspect ratio.</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('p256code20'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25620"><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
</pre></td><td class="code" id="p256code20"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">namespace</span> FocusedGames<span style="color: #008000;">.</span><span style="color: #0000FF;">Xna</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Represents the orientation of the display.</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">enum</span> DisplayOrientation <span style="color: #008000;">:</span> <span style="color: #6666cc; font-weight: bold;">byte</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Represents the standard orientation of the display. For Zune and Zune HD this is portrait mode.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        Standard <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>,
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Represents a 180 degree flip of the standard orientation.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        Flipped <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>,
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Represents a 90 degree rotation of the standard orientation. For the Zune and Zune HD this is landscape mode.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        Rotated <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>,
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Represents a -90 degree rotation of the standard orientation.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        ReverseRotated <span style="color: #008000;">=</span> <span style="color: #FF0000;">3</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>For now a dummy ModuleCollection class will do:</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('p256code21'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25621"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p256code21"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">namespace</span> FocusedGames<span style="color: #008000;">.</span><span style="color: #0000FF;">Xna</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ModuleCollection
    <span style="color: #008000;">&#123;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Finally we are ready to start implementing the IGame interface in a base class called Application so as not to confuse it with the XNA Framework&#8217;s Game 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('p256code22'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25622"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p256code22"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Xna.Framework</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Xna.Framework.Graphics</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> FocusedGames<span style="color: #008000;">.</span><span style="color: #0000FF;">Xna</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> Application <span style="color: #008000;">:</span> Game, IGame
    <span style="color: #008000;">&#123;</span></pre></td></tr></table></div>

<p>The implementation will need a certain number of members to deal with the orientation of the screen. Specifically, a render target will be used to draw everything and then rotated it rather than rotating everything as they are drawn. I have found this makes for simpler code for end developers because rotations can get complicated fast.</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('p256code23'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25623"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p256code23"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF; font-weight: bold;">private</span> DisplayOrientation displayOrientation<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">float</span> displayRotation <span style="color: #008000;">=</span> 0f<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> SpriteEffects displaySpriteEffects <span style="color: #008000;">=</span> SpriteEffects<span style="color: #008000;">.</span><span style="color: #0000FF;">None</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> Vector2 orientedDisplaySize <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Vector2<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">800</span>, <span style="color: #FF0000;">600</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> Vector2 displaySize <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Vector2<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">800</span>, <span style="color: #FF0000;">600</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> SpriteBatch spriteBatch<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> RenderTarget2D renderTarget<span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Next comes the default constructor for the class which simply initializes several of the members for use later on. Here is where the basic defaults of any game are defined and you&#8217;ll note the Zune specific code for &quot;saving&quot; battery life.</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('p256code24'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25624"><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="p256code24"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF; font-weight: bold;">public</span> Application<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;
            DeviceManager <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> GraphicsDeviceManager<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            ClearColor <span style="color: #008000;">=</span> Color<span style="color: #008000;">.</span><span style="color: #0000FF;">Black</span><span style="color: #008000;">;</span>
            DisplayOrientation <span style="color: #008000;">=</span> DisplayOrientation<span style="color: #008000;">.</span><span style="color: #0000FF;">Standard</span><span style="color: #008000;">;</span>
&nbsp;
            Content<span style="color: #008000;">.</span><span style="color: #0000FF;">RootDirectory</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Content&quot;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080;">#if ZUNE</span>
            <span style="color: #008080; font-style: italic;">// Frame rate is 30 fps by default for Zune.</span>
            TargetElapsedTime <span style="color: #008000;">=</span> TimeSpan<span style="color: #008000;">.</span><span style="color: #0000FF;">FromSeconds</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1</span> <span style="color: #008000;">/</span> <span style="color: #FF0000;">30.0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008080;">#endif</span>
        <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>The implementation needs to load some content, set the display size up and then handle when the content needs to be unloaded. To do this the virtual methods provided by the XNA Framework work wonders. Just remember that when inheriting this class in the XNA game template to include calls to the base methods both in LoadContent and UnloadContent (they aren&#8217;t included by default &#8211; ugh!).</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('p256code25'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25625"><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="p256code25"><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> LoadContent<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            spriteBatch <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SpriteBatch<span style="color: #008000;">&#40;</span>GraphicsDevice<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            SetDisplaySize<span style="color: #008000;">&#40;</span>displaySize<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            ResetRenderTarget<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;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">LoadContent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            IsLoaded <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;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> UnloadContent<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;">if</span><span style="color: #008000;">&#40;</span>spriteBatch <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> <span style="color: #008000;">!</span>spriteBatch<span style="color: #008000;">.</span><span style="color: #0000FF;">IsDisposed</span><span style="color: #008000;">&#41;</span>
                spriteBatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Dispose</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;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UnloadContent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            IsLoaded <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And now for the creation of the workhorse functions that maintain the orientation and display size and render target all in perfect harmony! The first one up is a function that is called to change the orientation of the display at any time. There are a couple ways of going about this; I have found using the sprite effects to be simple and effective. It is important to note that at the end of the function the render target is reset if the game has been loaded. If you fail to do this, things will get funky!</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('p256code26'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25626"><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
</pre></td><td class="code" id="p256code26"><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> SetDisplayOrientation<span style="color: #008000;">&#40;</span>DisplayOrientation newOrientation<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// Removed so this method can act as a reset as well</span>
            <span style="color: #008080; font-style: italic;">// if (newOrientation == displayOrientation) return;</span>
&nbsp;
            displayOrientation <span style="color: #008000;">=</span> newOrientation<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// TODO: Handle orientations</span>
            <span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span>displayOrientation<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> DisplayOrientation<span style="color: #008000;">.</span><span style="color: #0000FF;">Standard</span><span style="color: #008000;">:</span>
                    orientedDisplaySize <span style="color: #008000;">=</span> displaySize<span style="color: #008000;">;</span>
                    displayRotation <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
                    displaySpriteEffects <span style="color: #008000;">=</span> SpriteEffects<span style="color: #008000;">.</span><span style="color: #0000FF;">None</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> DisplayOrientation<span style="color: #008000;">.</span><span style="color: #0000FF;">Flipped</span><span style="color: #008000;">:</span>
                    orientedDisplaySize <span style="color: #008000;">=</span> displaySize<span style="color: #008000;">;</span>
                    displayRotation <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
                    displaySpriteEffects <span style="color: #008000;">=</span> SpriteEffects<span style="color: #008000;">.</span><span style="color: #0000FF;">FlipVertically</span> <span style="color: #008000;">|</span> SpriteEffects<span style="color: #008000;">.</span><span style="color: #0000FF;">FlipHorizontally</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> DisplayOrientation<span style="color: #008000;">.</span><span style="color: #0000FF;">Rotated</span><span style="color: #008000;">:</span>
                    orientedDisplaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span> <span style="color: #008000;">=</span> displaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span><span style="color: #008000;">;</span>
                    orientedDisplaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span> <span style="color: #008000;">=</span> displaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span><span style="color: #008000;">;</span>
                    displayRotation <span style="color: #008000;">=</span> MathHelper<span style="color: #008000;">.</span><span style="color: #0000FF;">PiOver2</span><span style="color: #008000;">;</span>
                    displaySpriteEffects <span style="color: #008000;">=</span> SpriteEffects<span style="color: #008000;">.</span><span style="color: #0000FF;">None</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> DisplayOrientation<span style="color: #008000;">.</span><span style="color: #0000FF;">ReverseRotated</span><span style="color: #008000;">:</span>
                    orientedDisplaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span> <span style="color: #008000;">=</span> displaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span><span style="color: #008000;">;</span>
                    orientedDisplaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span> <span style="color: #008000;">=</span> displaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span><span style="color: #008000;">;</span>
                    displayRotation <span style="color: #008000;">=</span> MathHelper<span style="color: #008000;">.</span><span style="color: #0000FF;">PiOver2</span><span style="color: #008000;">;</span>
                    displaySpriteEffects <span style="color: #008000;">=</span> SpriteEffects<span style="color: #008000;">.</span><span style="color: #0000FF;">FlipVertically</span> <span style="color: #008000;">|</span> SpriteEffects<span style="color: #008000;">.</span><span style="color: #0000FF;">FlipHorizontally</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//SpriteEffects.FlipHorizontally;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>IsLoaded<span style="color: #008000;">&#41;</span>
                ResetRenderTarget<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>The following method changes the display size of the screen and calls the previous method, SetDisplayOrientation, because as the screen size is changed, everything else is affected.</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('p256code27'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25627"><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="p256code27"><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> SetDisplaySize<span style="color: #008000;">&#40;</span>Vector2 newSize<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// Removed so this method can act as a reset as well</span>
            <span style="color: #008080; font-style: italic;">// if (newSize == displaySize) return;</span>
&nbsp;
            displaySize <span style="color: #008000;">=</span> newSize<span style="color: #008000;">;</span>
            orientedDisplaySize <span style="color: #008000;">=</span> newSize<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// Reset the backbuffer</span>
            DeviceManager<span style="color: #008000;">.</span><span style="color: #0000FF;">PreferredBackBufferWidth</span> <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span>displaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span><span style="color: #008000;">;</span>
            DeviceManager<span style="color: #008000;">.</span><span style="color: #0000FF;">PreferredBackBufferHeight</span> <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span>displaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// If we already loaded, apply the changed</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsLoaded<span style="color: #008000;">&#41;</span>
                DeviceManager<span style="color: #008000;">.</span><span style="color: #0000FF;">ApplyChanges</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// Reset the orientation details</span>
            SetDisplayOrientation<span style="color: #008000;">&#40;</span>displayOrientation<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 a method that resets the render target. In the future, the stub for Windows / Xbox 360 must be filled in with a robust RT creation method.</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('p256code28'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25628"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p256code28"><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> ResetRenderTarget<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
<span style="color: #008080;">#if ZUNE</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>renderTarget <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> <span style="color: #008000;">!</span>renderTarget<span style="color: #008000;">.</span><span style="color: #0000FF;">IsDisposed</span><span style="color: #008000;">&#41;</span>
                renderTarget<span style="color: #008000;">.</span><span style="color: #0000FF;">Dispose</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            renderTarget <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> RenderTarget2D<span style="color: #008000;">&#40;</span>GraphicsDevice, <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span>orientedDisplaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span>, <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span>orientedDisplaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span>, <span style="color: #FF0000;">1</span>, SurfaceFormat<span style="color: #008000;">.</span><span style="color: #0000FF;">Color</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008080;">#else</span>
            <span style="color: #008080; font-style: italic;">// TODO: Do some RT work here for Windows / Xbox 360</span>
<span style="color: #008080;">#endif</span>
        <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>But really that is only half of the implementation! Now that we have the members setup for drawing an orientated screen, the drawing actually has to happen. This code comes your way from Nick Gravelyn with some minor modifications. The first method, ClearGraphicsDevice, is provided as a virtual member because it should be changed by end-developers when complex clears need to occur. This is done in lieu of many more options and fields on the IGame interface.</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('p256code29'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25629"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p256code29"><pre class="csharp" style="font-family:monospace;">        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Clears the GraphicsDevice.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <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> ClearGraphicsDevice<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            GraphicsDevice<span style="color: #008000;">.</span><span style="color: #0000FF;">Clear</span><span style="color: #008000;">&#40;</span>ClearColor<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>In the BeginDraw method, the device needs to be cleared and the render target needs to be setup in some cases. In other cases, clearing the device is enough and the function is short circuited.</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('p256code30'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25630"><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
</pre></td><td class="code" id="p256code30"><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;">bool</span> BeginDraw<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;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">BeginDraw</span><span style="color: #008000;">&#40;</span><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;">if</span> <span style="color: #008000;">&#40;</span>DisplayOrientation <span style="color: #008000;">==</span> DisplayOrientation<span style="color: #008000;">.</span><span style="color: #0000FF;">Standard</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    ClearGraphicsDevice<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</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: #008000;">&#125;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>renderTarget <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">||</span> renderTarget<span style="color: #008000;">.</span><span style="color: #0000FF;">IsDisposed</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    ClearGraphicsDevice<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</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;
                GraphicsDevice<span style="color: #008000;">.</span><span style="color: #0000FF;">SetRenderTarget</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, renderTarget<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                ClearGraphicsDevice<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                GraphicsDevice<span style="color: #008000;">.</span><span style="color: #0000FF;">Viewport</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Viewport
                <span style="color: #008000;">&#123;</span>
                    X <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>,
                    Y <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>,
                    Width <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span>orientedDisplaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span>,
                    Height <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span>orientedDisplaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span>,
                    MinDepth <span style="color: #008000;">=</span> GraphicsDevice<span style="color: #008000;">.</span><span style="color: #0000FF;">Viewport</span><span style="color: #008000;">.</span><span style="color: #0000FF;">MinDepth</span>,
                    MaxDepth <span style="color: #008000;">=</span> GraphicsDevice<span style="color: #008000;">.</span><span style="color: #0000FF;">Viewport</span><span style="color: #008000;">.</span><span style="color: #0000FF;">MaxDepth</span>
                <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
                <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: #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></pre></td></tr></table></div>

<p>And last but certainly not least, the EndDraw and supporting methods need to clean up, present the render target and then draw any overlays before presenting to the screen. Here is where the real rotation magic occurs.</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('p256code31'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25631"><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
</pre></td><td class="code" id="p256code31"><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> EndDraw<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;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>IsLoaded<span style="color: #008000;">&#41;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>DisplayOrientation <span style="color: #008000;">==</span> DisplayOrientation<span style="color: #008000;">.</span><span style="color: #0000FF;">Standard</span> <span style="color: #008000;">||</span>
                <span style="color: #008000;">&#40;</span>renderTarget <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">||</span> renderTarget<span style="color: #008000;">.</span><span style="color: #0000FF;">IsDisposed</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #008080; font-style: italic;">//base.EndDraw();</span>
                FinalizeDraw<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;">return</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            GraphicsDevice<span style="color: #008000;">.</span><span style="color: #0000FF;">SetRenderTarget</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            GraphicsDevice<span style="color: #008000;">.</span><span style="color: #0000FF;">Viewport</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Viewport
            <span style="color: #008000;">&#123;</span>
                X <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>,
                Y <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>,
                Width <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span>displaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span>,
                Height <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span>displaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span>,
                MinDepth <span style="color: #008000;">=</span> GraphicsDevice<span style="color: #008000;">.</span><span style="color: #0000FF;">Viewport</span><span style="color: #008000;">.</span><span style="color: #0000FF;">MinDepth</span>,
                MaxDepth <span style="color: #008000;">=</span> GraphicsDevice<span style="color: #008000;">.</span><span style="color: #0000FF;">Viewport</span><span style="color: #008000;">.</span><span style="color: #0000FF;">MaxDepth</span>
            <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
            spriteBatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Begin</span><span style="color: #008000;">&#40;</span>SpriteBlendMode<span style="color: #008000;">.</span><span style="color: #0000FF;">None</span>, SpriteSortMode<span style="color: #008000;">.</span><span style="color: #0000FF;">Immediate</span>, SaveStateMode<span style="color: #008000;">.</span><span style="color: #0000FF;">SaveState</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            spriteBatch<span style="color: #008000;">.</span><span style="color: #0000FF;">Draw</span><span style="color: #008000;">&#40;</span>
                renderTarget<span style="color: #008000;">.</span><span style="color: #0000FF;">GetTexture</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>,
                displaySize <span style="color: #008000;">/</span> <span style="color: #FF0000;">2</span>,
                <span style="color: #0600FF; font-weight: bold;">null</span>,
                Color<span style="color: #008000;">.</span><span style="color: #0000FF;">White</span>,
                DisplayRotation,
                orientedDisplaySize <span style="color: #008000;">/</span> <span style="color: #FF0000;">2</span>,
                1f,
                DisplaySpriteEffects,
                <span style="color: #FF0000;">0</span>
            <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            spriteBatch<span style="color: #008000;">.</span><span style="color: #0000FF;">End</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">//base.EndDraw();</span>
            FinalizeDraw<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;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> FinalizeDraw<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            DrawOverlay<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;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">EndDraw</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: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Draw's unrotated graphics.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <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> DrawOverlay<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
        <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And before we can really call this implementation done (for now anyways), the various properties used need to be defined. These are given to you a la shotgun because they are straight forward and self explanatory.</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('p256code32'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25632"><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
</pre></td><td class="code" id="p256code32"><pre class="csharp" style="font-family:monospace;">        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets screen coordinates from object coordinates.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;objectVector&quot;&gt;The object's coordinates.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;Coordinates in screen space.&lt;/returns&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> Vector2 ObjectToScreen<span style="color: #008000;">&#40;</span>Vector2 objectVector<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;">new</span> Vector2<span style="color: #008000;">&#40;</span>displaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span> <span style="color: #008000;">-</span> objectVector<span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span>, objectVector<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets object coordinates from screen coordinates.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;screenVector&quot;&gt;The coordinates in screen space.&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;Coordinates in object space.&lt;/returns&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> Vector2 ScreenToObject<span style="color: #008000;">&#40;</span>Vector2 screenVector<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;">new</span> Vector2<span style="color: #008000;">&#40;</span>screenVector<span style="color: #008000;">.</span><span style="color: #0000FF;">Y</span>, displaySize<span style="color: #008000;">.</span><span style="color: #0000FF;">X</span> <span style="color: #008000;">-</span> screenVector<span style="color: #008000;">.</span><span style="color: #0000FF;">X</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> GraphicsDeviceManager DeviceManager <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: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets or Sets the orientation of the display.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> DisplayOrientation DisplayOrientation
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> displayOrientation<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetDisplayOrientation<span style="color: #008000;">&#40;</span>value<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: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets or Sets the size of the display.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> Vector2 DisplaySize
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> displaySize<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetDisplaySize<span style="color: #008000;">&#40;</span>value<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: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets the rotation of the display.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;seealso cref=&quot;DisplaySpriteEffects&quot;/&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">float</span> DisplayRotation <span style="color: #008000;">&#123;</span> get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> displayRotation<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets the SpriteEffects for the display's render target.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;seealso cref=&quot;DisplayRotation&quot;/&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> SpriteEffects DisplaySpriteEffects <span style="color: #008000;">&#123;</span> get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> displaySpriteEffects<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets whether or not the application has been loaded.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsLoaded <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: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets or Sets the clear color of the graphics device.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">protected</span> Color ClearColor <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: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets the SpriteBatch used to draw the main render target.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">protected</span> SpriteBatch SpriteBatch <span style="color: #008000;">&#123;</span> get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> spriteBatch<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Gets or Sets the target frame rate for the underlying loop code.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">float</span> TargetFrameRate
        <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: #FF0000;">1</span> <span style="color: #008000;">/</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">float</span><span style="color: #008000;">&#41;</span>TargetElapsedTime<span style="color: #008000;">.</span><span style="color: #0000FF;">TotalSeconds</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set
            <span style="color: #008000;">&#123;</span>
                TargetElapsedTime <span style="color: #008000;">=</span> TimeSpan<span style="color: #008000;">.</span><span style="color: #0000FF;">FromSeconds</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1</span> <span style="color: #008000;">/</span> value<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> 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>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2009/11/16/fgf-its-all-about-abstraction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FGF: Getting Started</title>
		<link>http://jsedlak.org/2009/11/05/fgf-getting-started/</link>
		<comments>http://jsedlak.org/2009/11/05/fgf-getting-started/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 15:08:52 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[FGF]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>

		<guid isPermaLink="false">http://jsedlak.com/?p=246</guid>
		<description><![CDATA[This series is devoted to the design and development of my framework, FGF (Focused Games Framework), and aims to cover topics like async content management, WCF services, and many more. In this first article, I cover how to setup Visual Studio 2008 for coding the framework. It is important to understand that I will be [...]]]></description>
			<content:encoded><![CDATA[<p>This series is devoted to the design and development of my framework, FGF (Focused Games Framework), and aims to cover topics like async content management, WCF services, and many more. In this first article, I cover how to setup Visual Studio 2008 for coding the framework. It is important to understand that I will be using Visual Studio Team System 2008 and thus may have features that are not available in the Express edition. It is possible to get around many of these or ignore them completely, however, so not having Team System does not mean developing FGF is impossible.</p>
<p>The first step is to open up the IDE and create our solution. When starting a large solution such as the one for FGF, I find it useful to create a <i>Blank Solution</i> so that the solution&#8217;s name can be different than that of the first project. Again, this can be worked around in Express as well as other versions of the editor.</p>
<div class="Center"><img class="Bordered" src="/wp-content/uploads/2009/11/screenshot_9-300x222.jpg" alt="Blank FGF Solution" title="Blank FGF Solution" width="300" height="222" class="size-medium wp-image-247" /></div>
<p><span id="more-246"></span></p>
<p>The next step is an obvious one: add the first project. The design of FGF is based on a hierarchy of libraries much like the .NET Framework. Whereas libraries depend on the System DLL and mscorlib, FGF libraries can all depend on the core project, FocusedGames. To enable some cross-platform awesomeness down the road, we make this project an XNA library and then remove the references to the XNA Framework. Remember that FGF is not just an XNA framework and should support situations where XNA is not installed. You can see the cleaned project in the below screenshot.</p>
<div class="Center"><img class="Bordered" src="/wp-content/uploads/2009/11/screenshot_11-279x300.jpg" alt="First project in FGF" title="First project in FGF" width="279" height="300" class="size-medium wp-image-248" /></div>
<p>After creating some copy projects for the Zune and the Xbox 360, repeat the process for a new project, FocusedGames.Xna. At this point you may find it nice to move the platform specific projects into platform specific Solution Folders. This is one of the features of Visual Studio I wish was present in the Express Edition, but unfortunately it was left out. The really nice part of Solution Folders is that it does not physically move the project files. Rather it simply organizes them in a virtual fashion.</p>
<p>Regardless, the last step is to setup the output directory. Personally, I like having the projects all push to the same bin folder so I can copy them with a Powershell script very easily. To do this, go into each project&#8217;s properties and change the output directory to something like &#8220;..\Bin\whatever was here>&#8221; and remember to change it for both Debug and Release.</p>
<div class="Center"><a href="/wp-content/uploads/2009/11/screenshot_12.jpg"><img src="http://jsedlak.com/wp-content/uploads/2009/11/screenshot_12-300x222.jpg" alt="Changing the output directory..." title="Changing the output directory..." width="300" height="222" class="Bordered" /></a></div>
<p>Finally we are ready to start coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2009/11/05/fgf-getting-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utilizing XSLT with FGF</title>
		<link>http://jsedlak.org/2009/09/21/utilizing-xslt-with-fgf/</link>
		<comments>http://jsedlak.org/2009/09/21/utilizing-xslt-with-fgf/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 21:24:59 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://jsedlak.com/2009/09/21/utilizing-xslt-with-fgf/</guid>
		<description><![CDATA[After developing with the Sitecore CMS for a couple of months I have seen what XSLT can offer in terms of a powerful web technology. I decided early on, before using Sitecore, that Vodka 2.0 would have to support XSL transforms since the content is stored as XML. The following is a sample of how [...]]]></description>
			<content:encoded><![CDATA[<p>After developing with the Sitecore CMS for a couple of months I have seen what XSLT can offer in terms of a powerful web technology. I decided early on, before using Sitecore, that Vodka 2.0 would have to support XSL transforms since the content is stored as XML. The following is a sample of how to work with XML and XSLT in the second version of the Focused Games Framework (FGF 2.0).</p>
<p>While the XSLT code can go pretty much anywhere in the ASP.NET pipeline, for now I have put it in my main Controller. Note that this code is not final, I will be looking into a better way to streamline the content retrieval process.</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('p201code40'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20140"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p201code40"><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> ContentController <span style="color: #008000;">:</span> Controller
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> ActionResult Get<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> uri<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Content content <span style="color: #008000;">=</span> GetContent<span style="color: #008000;">&#40;</span>uri, <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        Content template <span style="color: #008000;">=</span> GetContent<span style="color: #008000;">&#40;</span>content<span style="color: #008000;">.</span><span style="color: #0000FF;">TemplateId</span>, <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Next the XslTransformer class is instantiated and a test extension is added. Extensions can be simple or complext .NET classes. Again I plan to streamline this process and support loading from the web.config file.</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('p201code41'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20141"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p201code41"><pre class="csharp" style="font-family:monospace;">        XslTransformer transformer <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XslTransformer<span style="color: #008000;">&#40;</span>GetDocument<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        transformer<span style="color: #008000;">.</span><span style="color: #0000FF;">AddExtension</span><span style="color: #008000;">&#40;</span>
            <span style="color: #008000;">new</span> XsltExtension
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">Namespace</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://focusedgames.com/vodka&quot;</span>,
                Provider <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> VodkaXslExtensions<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        ViewData<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Content&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> transformer<span style="color: #008000;">.</span><span style="color: #0000FF;">Transform</span><span style="color: #008000;">&#40;</span>uri, template<span style="color: #008000;">.</span><span style="color: #0000FF;">Meta</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Uri</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> View<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Get&quot;</span>, <span style="color: #666666;">&quot;~/Themes/FGDN/Theme.master&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>When the Transform method is invoked, the transformer attempts to load documents through a callback. This process will definitely be streamlined so that the re-implementation of the following method isn&#8217;t required. The callback method loads the content straight from the database through an SqlContentProvider object. Not much has really changed here since Vodka 1.0 except for the addition of support for both languages and versioning.</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('p201code42'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20142"><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
</pre></td><td class="code" id="p201code42"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF; font-weight: bold;">public</span> Content GetContent<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> uri, <span style="color: #6666cc; font-weight: bold;">int</span> parent<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        SqlContentProvider scp <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SqlContentProvider<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        NameValueCollection parameters <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> NameValueCollection<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        parameters<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>SqlContentProvider<span style="color: #008000;">.</span><span style="color: #0000FF;">ConnectionStringParameterName</span>, connectionString<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        scp<span style="color: #008000;">.</span><span style="color: #0000FF;">Initialize</span><span style="color: #008000;">&#40;</span>parameters<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        Content content <span style="color: #008000;">=</span> scp<span style="color: #008000;">.</span><span style="color: #0000FF;">GetContent</span><span style="color: #008000;">&#40;</span>uri<span style="color: #008000;">.</span><span style="color: #0000FF;">ToLower</span><span style="color: #008000;">&#40;</span><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> content<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> XPathDocument GetDocument<span style="color: #008000;">&#40;</span>Uri uri<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Content content <span style="color: #008000;">=</span> GetContent<span style="color: #008000;">&#40;</span>uri<span style="color: #008000;">.</span><span style="color: #0000FF;">OriginalString</span>, <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        XPathDocument document <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XPathDocument<span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> StringReader<span style="color: #008000;">&#40;</span>content<span style="color: #008000;">.</span><span style="color: #0000FF;">Xml</span><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> document<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And finally the simple extension object:</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('p201code43'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20143"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p201code43"><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> VodkaXslExtensions
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> GetDate<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> DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><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;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>So what does this produce exactly? Well it takes the following XML&#8230;</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('p201code44'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20144"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p201code44"><pre class="html" style="font-family:monospace;">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;content&gt;
    &lt;title&gt;Home&lt;/title&gt;
    &lt;description&gt;
        &lt;p&gt;This website is still under construction, please check back soon.&lt;/p&gt;
        &lt;p&gt;Thank you,&lt;/p&gt;
        &lt;p&gt;&lt;a href=&quot;http://jsedlak.com&quot;&gt;John Sedlak&lt;/a&gt;&lt;/p&gt;
    &lt;/description&gt;
&lt;/content&gt;</pre></td></tr></table></div>

<p>And uses the following XSLT file (stored in the Vodka Database)&#8230;</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('p201code45'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20145"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p201code45"><pre class="html" style="font-family:monospace;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:test=&quot;http://focusedgames.com/vodka&quot; xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot; exclude-result-prefixes=&quot;msxsl test&quot;
&gt;
    &lt;xsl:output method=&quot;xml&quot; indent=&quot;yes&quot;/&gt;
&nbsp;
    &lt;xsl:template match=&quot;@* | node()&quot;&gt;
      &lt;h2&gt;
        &lt;xsl:value-of select=&quot;title&quot;/&gt;
      &lt;/h2&gt;
        &lt;div class=&quot;Description&quot;&gt;
            &lt;xsl:value-of select=&quot;description&quot;/&gt;
        &lt;/div&gt;
        &lt;p&gt;&lt;xsl:value-of select=&quot;test:GetDate()&quot;/&gt;&lt;/p&gt;
    &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;</pre></td></tr></table></div>

<p>And produces the following HTML&#8230;</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('p201code46'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20146"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p201code46"><pre class="html" style="font-family:monospace;">&lt;h2&gt;Home&lt;/h2&gt; 
&lt;div class=&quot;Description&quot;&gt;This website is still under construction, please check back soon.Thank you,John Sedlak&lt;/div&gt; 
&lt;p&gt;9/21/2009 5:23:04 PM&lt;/p&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2009/09/21/utilizing-xslt-with-fgf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sitecore Tip: Stripping HTML Tags</title>
		<link>http://jsedlak.org/2009/08/14/sitecore-tip-stripping-html-tags/</link>
		<comments>http://jsedlak.org/2009/08/14/sitecore-tip-stripping-html-tags/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 13:22:29 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://jsedlak.com/?p=194</guid>
		<description><![CDATA[Here is a quick and incredibly useful tip for using the Sitecore API. Recently I was looking for an easy way to strip HTML tags from a string (in C# code) and Alex de Groot responded to the call. Turns out that the process is insanely painless. ?View Code CSHARP1 Sitecore.StringUtil.RemoveTags&#40;string&#41; : string]]></description>
			<content:encoded><![CDATA[<p>Here is a quick and incredibly useful tip for using the <a href="http://sitecore.net">Sitecore</a> API. Recently I was looking for an easy way to strip HTML tags from a string (in C# code) and <a href="http://sitecore.alexiasoft.nl/">Alex de Groot</a> responded to the call. Turns out that the process is insanely painless.</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('p194code48'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p19448"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p194code48"><pre class="csharp" style="font-family:monospace;">Sitecore<span style="color: #008000;">.</span><span style="color: #0000FF;">StringUtil</span><span style="color: #008000;">.</span><span style="color: #0000FF;">RemoveTags</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">:</span> <span style="color: #6666cc; font-weight: bold;">string</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2009/08/14/sitecore-tip-stripping-html-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Spark of Genius?</title>
		<link>http://jsedlak.org/2008/12/09/a-spark-of-genius/</link>
		<comments>http://jsedlak.org/2008/12/09/a-spark-of-genius/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 01:44:26 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Versionator]]></category>

		<guid isPermaLink="false">http://jsedlak.com/?p=150</guid>
		<description><![CDATA[Knowing how frameworks are designed and developed definately has its benefits. Awhile ago I spent some time looking into how DependencyObject and DependencyProperty work in WPF. Essentially, many of the properties are not simple properties but rather facades for method invocations. Fast forward to today when I was working on Versionator, an application I am [...]]]></description>
			<content:encoded><![CDATA[<p>Knowing how frameworks are designed and developed definately has its benefits. Awhile ago I spent some time looking into how DependencyObject and DependencyProperty work in WPF. Essentially, many of the properties are not simple properties but rather facades for method invocations.</p>
<p>Fast forward to today when I was working on Versionator, an application I am writing to help me manage my many projects&#8217; versions. The problem is that project information files (AssemblyInfo.cs) are not straight forward in terms of parsing. They are merely text files, awkward and malformed code files in fact. To be able to support many properties so easily, I came up with a scheme to parse, manage and save the projects&#8217; properties in the file.</p>
<p>What I do is parse the properties, extracting the data and storing it in a dictionary as &#8220;old values.&#8221; At the same time I create a copy of the values in a &#8220;current values&#8221; dictionary. As new values come in, I channel them through properties, then Get and Set methods which access the &#8220;current values&#8221; dictionary. When it comes time to save I have to do some management of the data based on whether or not the property was empty, non-existant or is being changed to empty. It is simple to say that it would have taken me a lot longer if I had not taken a look at WPF. So was it a spark of genius? Or just plain old learnedness?</p>
<p>The Code (Beware of its massive length):</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('p150code50'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p15050"><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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
</pre></td><td class="code" id="p150code50"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections.Generic</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.IO</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> FocusedGames<span style="color: #008000;">.</span><span style="color: #0000FF;">Versionator</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Data</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ProjectInfo
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">enum</span> Properties <span style="color: #008000;">:</span> <span style="color: #6666cc; font-weight: bold;">ushort</span>
        <span style="color: #008000;">&#123;</span>
            Title <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>,
            Description <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>,
            Company <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>,
            Product <span style="color: #008000;">=</span> <span style="color: #FF0000;">3</span>,
            Copyright <span style="color: #008000;">=</span> <span style="color: #FF0000;">4</span>,
            Trademark <span style="color: #008000;">=</span> <span style="color: #FF0000;">5</span>,
            AssemblyVersion <span style="color: #008000;">=</span> <span style="color: #FF0000;">6</span>,
            FileVersion <span style="color: #008000;">=</span> <span style="color: #FF0000;">7</span>,
            Guid <span style="color: #008000;">=</span> <span style="color: #FF0000;">8</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">readonly</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> lookups <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">&quot;AssemblyTitle&quot;</span>, <span style="color: #666666;">&quot;AssemblyDescription&quot;</span>, <span style="color: #666666;">&quot;AssemblyCompany&quot;</span>, <span style="color: #666666;">&quot;AssemblyProduct&quot;</span>, <span style="color: #666666;">&quot;AssemblyCopyright&quot;</span>, <span style="color: #666666;">&quot;AssemblyTrademark&quot;</span>, <span style="color: #666666;">&quot;AssemblyVersion&quot;</span>, <span style="color: #666666;">&quot;AssemblyFileVersion&quot;</span>, <span style="color: #666666;">&quot;Guid&quot;</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">readonly</span> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">ushort</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> propertyValues <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">ushort</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">readonly</span> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">ushort</span>, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> oldValues <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">ushort</span>, <span style="color: #6666cc; font-weight: bold;">string</span><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;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> ProjectInfo FromFile<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> filename<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;">new</span> ProjectInfo<span style="color: #008000;">&#40;</span>filename<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> ProjectInfo<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Array enumValues <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">Enum</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetValues</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span> <span style="color: #008000;">&#40;</span>Properties<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;">foreach</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">ushort</span> prop <span style="color: #0600FF; font-weight: bold;">in</span> enumValues<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                propertyValues<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>prop, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                oldValues<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>prop, <span style="color: #6666cc; font-weight: bold;">string</span><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> ProjectInfo<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> filename<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><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Load<span style="color: #008000;">&#40;</span>filename<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008080;">#region Getting and Setting Project Properties</span>
        <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">void</span> SetProperty<span style="color: #008000;">&#40;</span>Properties prop, <span style="color: #6666cc; font-weight: bold;">string</span> value<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            propertyValues<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">ushort</span><span style="color: #008000;">&#41;</span> prop<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">string</span> GetProperty<span style="color: #008000;">&#40;</span>Properties prop<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #6666cc; font-weight: bold;">string</span> newValue <span style="color: #008000;">=</span> propertyValues<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">ushort</span><span style="color: #008000;">&#41;</span> prop<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>newValue<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span> oldValues<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">ushort</span><span style="color: #008000;">&#41;</span> prop<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> newValue<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #008080;">#endregion</span>
&nbsp;
        <span style="color: #008080;">#region Loading and Saving</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Load<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> filename<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Filename <span style="color: #008000;">=</span> filename<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> lines <span style="color: #008000;">=</span> File<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadAllLines</span><span style="color: #008000;">&#40;</span>Filename<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Array enumValues <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">Enum</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetValues</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span> <span style="color: #008000;">&#40;</span>Properties<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;">foreach</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">ushort</span> prop <span style="color: #0600FF; font-weight: bold;">in</span> enumValues<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                Load<span style="color: #008000;">&#40;</span>lines, prop<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;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> Load<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> lines, <span style="color: #6666cc; font-weight: bold;">ushort</span> lookup<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> lines<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #6666cc; font-weight: bold;">string</span> currentLine <span style="color: #008000;">=</span> lines<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
                <span style="color: #6666cc; font-weight: bold;">string</span> searchTerm <span style="color: #008000;">=</span> lookups<span style="color: #008000;">&#91;</span>lookup<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// Get the first index of the search term</span>
                <span style="color: #6666cc; font-weight: bold;">int</span> firstIndex <span style="color: #008000;">=</span> currentLine<span style="color: #008000;">.</span><span style="color: #0000FF;">IndexOf</span><span style="color: #008000;">&#40;</span>searchTerm<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// The property wasn't found, continue</span>
                <span style="color: #008080; font-style: italic;">// through the file.</span>
                <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>firstIndex <span style="color: #008000;">==</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;">continue</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// Now we need to extract the data out of the string!</span>
                <span style="color: #6666cc; font-weight: bold;">string</span> data <span style="color: #008000;">=</span> currentLine<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span>firstIndex <span style="color: #008000;">+</span> searchTerm<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TrimFront</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TrimBack</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                oldValues<span style="color: #008000;">&#91;</span>lookup<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> data<span style="color: #008000;">;</span>
                propertyValues<span style="color: #008000;">&#91;</span>lookup<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> data<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;">void</span> Save<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> lines <span style="color: #008000;">=</span> File<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadAllLines</span><span style="color: #008000;">&#40;</span>Filename<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            Array enumValues <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">Enum</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetValues</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>Properties<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;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">ushort</span> prop <span style="color: #0600FF; font-weight: bold;">in</span> enumValues<span style="color: #008000;">&#41;</span>
                Save<span style="color: #008000;">&#40;</span>lines, prop<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            StreamWriter sw <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StreamWriter<span style="color: #008000;">&#40;</span>Filename, <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><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> lines<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
                sw<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span>lines<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            sw<span style="color: #008000;">.</span><span style="color: #0000FF;">Close</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;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> Save<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> lines, <span style="color: #6666cc; font-weight: bold;">ushort</span> prop<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> lines<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #6666cc; font-weight: bold;">string</span> currentLine <span style="color: #008000;">=</span> lines<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
                <span style="color: #6666cc; font-weight: bold;">string</span> searchTerm <span style="color: #008000;">=</span> lookups<span style="color: #008000;">&#91;</span>prop<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// Get the first index of the search term</span>
                <span style="color: #6666cc; font-weight: bold;">int</span> firstIndex <span style="color: #008000;">=</span> currentLine<span style="color: #008000;">.</span><span style="color: #0000FF;">IndexOf</span><span style="color: #008000;">&#40;</span>searchTerm<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// The property wasn't found, continue</span>
                <span style="color: #008080; font-style: italic;">// through the file.</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>firstIndex <span style="color: #008000;">==</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;">continue</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #6666cc; font-weight: bold;">string</span> oldValueLocal <span style="color: #008000;">=</span> oldValues<span style="color: #008000;">&#91;</span>prop<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
                <span style="color: #6666cc; font-weight: bold;">string</span> newValueLocal <span style="color: #008000;">=</span> propertyValues<span style="color: #008000;">&#91;</span>prop<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// If the old value didn't exist, we can adjust the </span>
                <span style="color: #008080; font-style: italic;">// replacement mechanism to remove the &quot;&quot; and add</span>
                <span style="color: #008080; font-style: italic;">// them back in.</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>oldValueLocal<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    oldValueLocal <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span><span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #008000;">;</span>
                    newValueLocal <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span>{0}<span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span>, newValueLocal<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// We also need to catch people emptying strings out.</span>
                <span style="color: #008080; font-style: italic;">// To do this we adjust the saving mechanism the same way.</span>
                <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>newValueLocal<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    oldValueLocal <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span>{0}<span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span>, oldValueLocal<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    newValueLocal <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span><span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// Replace the old value with the new value</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>newValueLocal<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                        lines<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> lines<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span>oldValueLocal, newValueLocal<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: #008080;">#endregion</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Filename <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;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> AssemblyVersion
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> GetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">AssemblyVersion</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">AssemblyVersion</span>, value<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;">string</span> FileVersion
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> GetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">FileVersion</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">FileVersion</span>, value<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;">string</span> Title 
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> GetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span>, value<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;">string</span> Description
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> GetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Description</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Description</span>, value<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;">string</span> Company
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> GetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Company</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Company</span>, value<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;">string</span> Product 
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> GetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Product</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Product</span>, value<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;">string</span> Copyright
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> GetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Copyright</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Copyright</span>, value<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;">string</span> Trademark
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> GetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Trademark</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Trademark</span>, value<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;">string</span> Guid
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> GetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Guid</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> SetProperty<span style="color: #008000;">&#40;</span>Properties<span style="color: #008000;">.</span><span style="color: #0000FF;">Guid</span>, value<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>

<p>P.S. The code is not done, is not even close to being efficient or functionally complete. But it works!</p>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2008/12/09/a-spark-of-genius/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tackling The Problem</title>
		<link>http://jsedlak.org/2008/12/03/tackling-the-problem/</link>
		<comments>http://jsedlak.org/2008/12/03/tackling-the-problem/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 13:08:31 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[FGF]]></category>
		<category><![CDATA[Web CMS]]></category>

		<guid isPermaLink="false">http://jsedlak.com/?p=146</guid>
		<description><![CDATA[Tackling the problem in the previous post I have decided to rely on providing more options than necessary. I have to remember that because Vodka is not client software, I have to write it as if the client software will be as simple as possible. The goal of Vodka is to give developers a way [...]]]></description>
			<content:encoded><![CDATA[<p>Tackling the problem in the <a href="http://jsedlak.com/2008/12/01/problems-with-vodka/">previous post</a> I have decided to rely on providing more options than necessary. I have to remember that because Vodka is not client software, I have to write it as if the client software will be as simple as possible. The goal of Vodka is to give developers a way of setting up a software based CMS with great ease.</p>
<p>To do this, I have built in services that can be implemented and exposed via WCF as well as built in implementations of these services. If you had the binaries for Vodka, you could reference FocusedGames.Vodka.Services, create a class in a Service project and inherit from ContentService or MembershipService. After deploying the project, you can treat it like any other WCF service reference.</p>
<p>The original question dealt with translation services however, is it a client or server responsibility? You would generally make it client side because you may wish to get a different template for the content or change how translation is done. This is on par with most CMS software installs out there but there is a problem. Templates in the Vodka backend are treated as standard items of content. It then would require two calls to the service: one for the template and one for the content. You would also have to know how the template is extracted from the content item. This is a bad idea as it increases server load unecessarily.</p>
<p>The answer is simple: abstract it and keep it server side. The idea here is that the developers can plugin their own template provider into the service when setting it up. This will allow them to point to another service, a local directory or hardcoded templates. If no plugin is used, the service will continue on its standard course, grabbing the template from the standard content data store.</p>
<p>You may be asking why you would ever want to use a custom provider to point to a second service. Let&#8217;s say you have a ton of websites that you all want to look the same. For instance Microsoft may have microsoft.com, msdn.microsoft.com, creators.xna.com, xbox.com, et cetera and may want them to all use the same templates for items. They could use a provider to point to a single template service removing the need to change 5+ templates on 5+ servers.</p>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2008/12/03/tackling-the-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problems With Vodka</title>
		<link>http://jsedlak.org/2008/12/01/problems-with-vodka/</link>
		<comments>http://jsedlak.org/2008/12/01/problems-with-vodka/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 13:08:37 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[FGF]]></category>
		<category><![CDATA[Web CMS]]></category>

		<guid isPermaLink="false">http://jsedlak.com/?p=145</guid>
		<description><![CDATA[The Vodka Content Management System is a service based, multitier setup with the clients getting access to all content and member information via services. In turn, the services communicate with each other as well as their respective data stores. One of the goals of designing Vodka is to implement objects in a way that is [...]]]></description>
			<content:encoded><![CDATA[<p>The Vodka Content Management System is a service based, multitier setup with the clients getting access to all content and member information via services. In turn, the services communicate with each other as well as their respective data stores. One of the goals of designing Vodka is to implement objects in a way that is easily extendable. To accomplish this, all content is managed in terms of the text data (XML) and its meta data (title, author, date stamps, et al).</p>
<p>The problem is how this data is transformed into its two main uses: HTML and .NET Objects. The question is where these transformations take place. In order to transform an XML file into HTML, the code needs access to an XSL file. The problem with this is that it too, is treated as a piece of content. It is regulated in exactly the same way with the same level of security. Thus it can be seen that this service should remain on the server. This is where it currently sits, so what is the problem? </p>
<p>The problem remains that it shouldn&#8217;t be a server side operation! That is slow! It requires more implementations than necessary and furthermore it builds a bad dependency on the server for specific implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2008/12/01/problems-with-vodka/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Screenshot of the Day</title>
		<link>http://jsedlak.org/2008/11/05/screenshot-of-the-day/</link>
		<comments>http://jsedlak.org/2008/11/05/screenshot-of-the-day/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 17:02:25 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Aero]]></category>
		<category><![CDATA[FGF]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Thrust]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://jsedlak.com/?p=134</guid>
		<description><![CDATA[This is from the most recent build of FGF: Yes, it is my own implementation of the Aero style of windows done in XNA. What does this mean? Well I have decided that although the simple way of doing a menu system in games is fine for simple situations, I want something more powerful and [...]]]></description>
			<content:encoded><![CDATA[<p>This is from the most recent build of FGF:</p>
<div style="text-align:center;"><a href='http://jsedlak.com/wp-content/uploads/2008/11/fgf_001.jpg'><img src="http://jsedlak.com/wp-content/uploads/2008/11/fgf_001-300x233.jpg" alt="Aero In Xna" title="Aero In Xna" width="300" height="233" class="alignnone size-medium wp-image-135" /></a></div>
<p>Yes, it is my own implementation of the Aero style of windows done in XNA. What does this mean? Well I have decided that although the simple way of doing a menu system in games is fine for simple situations, I want something more powerful and prettier to look at. Thus I have started working on a new UI library for <a href="http://focusedgames.com/fg-framework">Thrust</a> that is based on Aero and similar interfaces. I am doing it in a fully customizable but lightweight manner and working on Xbox 360 compatibility.</p>
]]></content:encoded>
			<wfw:commentRss>http://jsedlak.org/2008/11/05/screenshot-of-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
