<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>David Fritz: Programming and Web Dev</title>
	<atom:link href="http://davidfritz.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidfritz.wordpress.com</link>
	<description>My sites and my code.</description>
	<lastBuildDate>Fri, 17 Jun 2011 03:36:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='davidfritz.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>David Fritz: Programming and Web Dev</title>
		<link>http://davidfritz.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://davidfritz.wordpress.com/osd.xml" title="David Fritz: Programming and Web Dev" />
	<atom:link rel='hub' href='http://davidfritz.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Screensaver Preventer</title>
		<link>http://davidfritz.wordpress.com/2010/08/18/screensaver-preventer/</link>
		<comments>http://davidfritz.wordpress.com/2010/08/18/screensaver-preventer/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 20:01:36 +0000</pubDate>
		<dc:creator>davidfritz</dc:creator>
				<category><![CDATA[Programs by me]]></category>
		<category><![CDATA[saver]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[screensaver]]></category>
		<category><![CDATA[time-out]]></category>
		<category><![CDATA[timeout]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://davidfritz.wordpress.com/?p=197</guid>
		<description><![CDATA[I know what you&#8217;re thinking already: &#8220;just disable the screensaver in Windows preferences!&#8221; But what if you&#8217;re working on a computer which doesn&#8217;t allow you to change this (perhaps a work computer that&#8217;s locked down by Windows group policies&#8230;) Well, here&#8217;s a small little program that checks the Windows Group Policy for the screen saver&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidfritz.wordpress.com&amp;blog=7457310&amp;post=197&amp;subd=davidfritz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I know what you&#8217;re thinking already: &#8220;just disable the screensaver in Windows preferences!&#8221; But what if you&#8217;re working on a computer which doesn&#8217;t allow you to change this (perhaps a work computer that&#8217;s locked down by Windows group policies&#8230;)</p>
<p><span style="font-size:13.3333px;">Well, here&#8217;s a small little program that checks the Windows Group Policy for the screen saver&#8217;s timeout which is usually ScreenSaverTimeOut in the registry:</span></p>
<blockquote>
<pre><span style="font-size:10.3333px;"> HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop</span></pre>
</blockquote>
<p>It defaults to a 10 minute time-out if it can&#8217;t find the value from the registry.</p>
<p>Then, when it&#8217;s t minus 30 seconds until your screen saver is supposed to kick-in, the program &#8220;presses&#8221; the up arrow which resets Window&#8217;s idle time counter.</p>
<p>This runs very quietly in the system tray, and allows you to enable/disable/quit it with a simple right click menu.</p>
<p>Nothing too fancy.</p>
<p>Here&#8217;s a link to the executable: <a href="https://sites.google.com/site/dfritter4/Home/ScreensaverPreventer.zip?attredirects=0&amp;d=1" target="_self">Download</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davidfritz.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davidfritz.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/davidfritz.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/davidfritz.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/davidfritz.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/davidfritz.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/davidfritz.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/davidfritz.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/davidfritz.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/davidfritz.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/davidfritz.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/davidfritz.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/davidfritz.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/davidfritz.wordpress.com/197/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidfritz.wordpress.com&amp;blog=7457310&amp;post=197&amp;subd=davidfritz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davidfritz.wordpress.com/2010/08/18/screensaver-preventer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a82a18042ca1ea7b962f104b6fbbfe9f?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">davidfritz</media:title>
		</media:content>
	</item>
		<item>
		<title>Fash – A Bash-like Unix shell</title>
		<link>http://davidfritz.wordpress.com/2010/06/10/fash-a-bash-like-unix-shell/</link>
		<comments>http://davidfritz.wordpress.com/2010/06/10/fash-a-bash-like-unix-shell/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 04:20:17 +0000</pubDate>
		<dc:creator>davidfritz</dc:creator>
				<category><![CDATA[Programs by me]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[c programs]]></category>
		<category><![CDATA[fash]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://davidfritz.wordpress.com/?p=188</guid>
		<description><![CDATA[For my Operating Systems course, our main course-long project was to implement a very light, simple Unix shell, written in C. I took it a step (well&#8230;multiple steps really) further and added many of the most useful features of Bash, the most popular Unix shell. I titled mine Fash &#8211; the Fritz Again Shell. I&#8217;m [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidfritz.wordpress.com&amp;blog=7457310&amp;post=188&amp;subd=davidfritz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For my Operating Systems course, our main course-long project was to implement a very light, simple Unix shell, written in C. I took it a step (well&#8230;multiple steps really) further and added many of the most useful features of Bash, the most popular Unix shell. I titled mine Fash &#8211; the Fritz Again Shell.</p>
<p>I&#8217;m going to add the source code to a Git repository so anyone can view the source (give me about day or so).</p>
<p><strong>Features of Fash:</strong></p>
<ol>
<li>Ability to import settings in a .fashrc file</li>
<li>Support for aliases</li>
<li>Bash-like command history management/navigation</li>
<li>Directory history management/navigation (similar to command history)</li>
<li>Simple redirection (input from file, output to file, append to file)</li>
<li>Supports piping (form of redirection really)</li>
<li>Very basic tab completion</li>
<li>Very basic &#8220;C interpreter&#8221; (allows you to quickly write a C program and run it from within the shell, but very limited</li>
</ol>
<p>It&#8217;s pretty stable despite the large feature set (when I say large, I mean large for one man to implement in the course of a few months). And depending on what features you use in Bash, the Fash shell could serve as a lightweight replacement. All the source files combined are only 50KB (unless you count the hash-table library which adds another 64KB) and the executable is only 37KB. This means that my Fash shell (although granted it&#8217;s feature set and stability is MUCH smaller than Bash&#8217;s) is <strong>420x smaller than Bash</strong> (Bash&#8217;s source code is ~21MB).</p>
<p>Anyway, feel free to check-out the code as soon as I add it to the Git repository!</p>
<p>UPDATE: Alright, here is the link to the Git Hub repo: <a href="http://github.com/dfritter4/Fash-Shell">http://github.com/dfritter4/Fash-Shell</a></p>
<p>Feel free to let me know how badly it sucks!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davidfritz.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davidfritz.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/davidfritz.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/davidfritz.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/davidfritz.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/davidfritz.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/davidfritz.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/davidfritz.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/davidfritz.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/davidfritz.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/davidfritz.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/davidfritz.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/davidfritz.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/davidfritz.wordpress.com/188/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidfritz.wordpress.com&amp;blog=7457310&amp;post=188&amp;subd=davidfritz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davidfritz.wordpress.com/2010/06/10/fash-a-bash-like-unix-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a82a18042ca1ea7b962f104b6fbbfe9f?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">davidfritz</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Chrome extension with Google JavaScript API</title>
		<link>http://davidfritz.wordpress.com/2009/08/20/google-chrome-extension-with-google-javascript-api/</link>
		<comments>http://davidfritz.wordpress.com/2009/08/20/google-chrome-extension-with-google-javascript-api/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 17:30:53 +0000</pubDate>
		<dc:creator>davidfritz</dc:creator>
				<category><![CDATA[Programs by me]]></category>
		<category><![CDATA[Websites by me]]></category>
		<category><![CDATA[browser extensions]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[chrome extensions]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google api]]></category>
		<category><![CDATA[google finance]]></category>
		<category><![CDATA[google javascript client api]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[stock market ticker]]></category>

		<guid isPermaLink="false">http://davidfritz.wordpress.com/?p=173</guid>
		<description><![CDATA[I&#8217;ve been in a huge rant about the awesomeness of Google Chrome over the past few days, and it got me wanting to become a little more involved with the project. I set out to create a Chrome extension (which is still very dev-stage) that would show me one of my Google Finance porfolios in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidfritz.wordpress.com&amp;blog=7457310&amp;post=173&amp;subd=davidfritz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been in a huge rant about the awesomeness of Google Chrome over the past few days, and it got me wanting to become a little more involved with the project. I set out to create a Chrome extension (which is still very dev-stage) that would show me one of my Google Finance porfolios in a scrolling ticker-like style.</p>
<p>Unfortunately, Google&#8217;s JavaScript client API for developing web applications is meant (as far as I know) precisely for web applications: ones that are run (hosted) on the web.</p>
<p>The problem is, since you have to be logged-in to Google Finance to grab portfolio data, you need to have Google allow your website to &#8220;access&#8221; your account (<a href="http://code.google.com/apis/gdata/client-js.html">http://code.google.com/apis/gdata/client-js.html</a>) and when you do, Google will redirect you to the originating site that was requesting access.</p>
<p>Well&#8230;thats fine and great if you can be redirected to. Chrome extensions can&#8217;t. They are simply HTML/JavaScript files on your computer.</p>
<p>Now I&#8217;ve managed to come up with a solution that unfortunately can&#8217;t really be used by everyone unless you have a Google Finance porfolio #3. The portfolio ID must be #3 for the time being, because that&#8217;s what&#8217;s hard coded in my extension. Despite this (hopefully temporary) drawback, it does still demonstrate my workaround to the API authentication problem.</p>
<p>First, I created an HTML site that uses the Google API to pull my stocks into a small little ticker.</p>
<p>You can view the website here:</p>
<p>http://motrclan.com/chrome_extensions/my_toolstrip_original.html</p>
<p>NOTE: When you go to this site you will only see the Finance icon. To connect your Google Account and retrieve your data, first click anywhere on the page. This will try to log you in to your Finance account (don&#8217;t worry, I&#8217;m not stealing any personal information) and redirect you back to the site. After this, click on the Finance icon to retrieve your #3 portfolio.</p>
<p>Now that&#8217;s the majority of the work. Now to make it an extension, I created another file on my comptuer called &#8220;my_toolstrip_client.html&#8221; (as well as the neccessary &#8220;manifest.json&#8221; file) and here is the code:</p>
<pre>&lt;div id="my_toolstrip"&gt;
	&lt;iframe scrolling="no" FRAMEBORDER="0" width="125px" style="margin-top: -3px;" height="40px" src="http://motrclan.com/chrome_extensions/my_toolstrip_original.html" /&gt;
&lt;/div&gt;</pre>
<p>You see, all the Chrome extension is, is an iframe to my site which serves as the extension, since my site can actually use the API. Now if you do all this and try to load the extension in Chrome. You&#8217;ll have to first go to the original site and click on the body to authorize access. Then you can click on the Finance icon in your Chrome extension and VIOLA! You have a scrolling ticker extension in Chrome.</p>
<p>I&#8217;ll be working on this for a while and adding some features. Hopefully soon I&#8217;ll be able to cycle through each of your portfolios and add all the different stocks from each one.</p>
<p>You&#8217;ll notice that right now, all the stocks are saying 0.0% I think there is something wrong with the Finance API because I&#8217;m just grabbing a field straight from the documentation for the Finance API. The only thing that seems to actual give any numbers is shares.</p>
<p>Here&#8217;s a screenshot:</p>
<p><a href="http://davidfritz.files.wordpress.com/2009/08/chromeextension.jpg"><img title="Chrome extension" src="http://davidfritz.files.wordpress.com/2009/08/chromeextension.jpg?w=614&#038;h=384" alt="Chrome extension" width="614" height="384" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davidfritz.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davidfritz.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/davidfritz.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/davidfritz.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/davidfritz.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/davidfritz.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/davidfritz.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/davidfritz.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/davidfritz.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/davidfritz.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/davidfritz.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/davidfritz.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/davidfritz.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/davidfritz.wordpress.com/173/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidfritz.wordpress.com&amp;blog=7457310&amp;post=173&amp;subd=davidfritz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davidfritz.wordpress.com/2009/08/20/google-chrome-extension-with-google-javascript-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a82a18042ca1ea7b962f104b6fbbfe9f?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">davidfritz</media:title>
		</media:content>

		<media:content url="http://davidfritz.files.wordpress.com/2009/08/chromeextension.jpg" medium="image">
			<media:title type="html">Chrome extension</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding XML element to existing XML document in C#</title>
		<link>http://davidfritz.wordpress.com/2009/07/10/adding-xml-element-to-existing-xml-document-in-c/</link>
		<comments>http://davidfritz.wordpress.com/2009/07/10/adding-xml-element-to-existing-xml-document-in-c/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 13:13:37 +0000</pubDate>
		<dc:creator>davidfritz</dc:creator>
				<category><![CDATA[Programs by me]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[editing xml c#]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xml node insert]]></category>

		<guid isPermaLink="false">http://davidfritz.wordpress.com/?p=143</guid>
		<description><![CDATA[I was looking around for a good tutorial/example on how to add an XML node to an exisitant XML document but never really found one that I needed. Here&#8217;s my version: Let&#8217;s say this is your existing XML Document: &#60;?xml version="1.0"?&#62; &#60;configuration&#62; &#60;appSettings&#62; &#60;add key="aKey1" value="http://www.google.com"/&#62; &#60;add key="aKey2" value="http://www.yahoo.com"/&#62; &#60;add key="aKey3" value="http://www.bing.com"/&#62; &#60;add key="aKey4" value="http://www.facebook.com"/&#62; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidfritz.wordpress.com&amp;blog=7457310&amp;post=143&amp;subd=davidfritz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was looking around for a good tutorial/example on how to add an XML node to an exisitant XML document but never really found one that I needed. Here&#8217;s my version:</p>
<p>Let&#8217;s say this is your existing XML Document:</p>
<pre><span style="color:#000000;font-size:12px;">&lt;?xml version="1.0"?&gt;</span>
<span style="color:#000000;font-size:12px;">&lt;configuration&gt;</span>
<span style="color:#000000;font-size:12px;">     &lt;appSettings&gt;</span>
<span style="color:#000000;font-size:12px;">          &lt;add key="aKey1" value="http://www.google.com"/&gt;</span>
<span style="color:#000000;font-size:12px;">          &lt;add key="aKey2" value="http://www.yahoo.com"/&gt;</span>
<span style="color:#000000;font-size:12px;">          &lt;add key="aKey3" value="http://www.bing.com"/&gt;</span>
<span style="color:#000000;font-size:12px;">          &lt;add key="aKey4" value="http://www.facebook.com"/&gt;</span>
<span style="color:#000000;font-size:12px;">     &lt;/appSettings&gt;</span>
<span style="color:#000000;font-size:12px;">     &lt;system.web&gt;</span>
<span style="color:#000000;font-size:12px;">          &lt;httpHandlers&gt;</span>
<span style="color:#000000;font-size:12px;">               &lt;add verb="*" path="*.vjsproj" type="System.Web.HttpForbiddenHandler"/&gt;</span>
<span style="color:#000000;font-size:12px;">          &lt;/httpHandlers&gt;</span>
<span style="color:#000000;font-size:12px;">     &lt;/system.web&gt;</span>
<span style="color:#000000;font-size:12px;">&lt;/configuration&gt;</span></pre>
<p>And you wanted to add the following element under the &lt;appSettings&gt; section:</p>
<pre><span style="color:#000000;font-size:12px;">&lt;add key="someKey" value="someValue" /&gt;</span><span style="color:#000000;">
</span></pre>
<p>Here&#8217;s the C# code you&#8217;d need:</p>
<pre><span style="color:#000000;font-size:12px;">XmlDocument xDoc = new XmlDocument();</span>
<span style="color:#000000;font-size:12px;">xDoc.Load("C:\yourXmlFile.xml");</span>
<span style="color:#000000;font-size:12px;">XmlNode xNode = xDoc.CreateNode(XmlNodeType.Element, "add", "");</span>
<span style="color:#000000;font-size:12px;">XmlAttribute xKey = xDoc.CreateAttribute("key");</span>
<span style="color:#000000;font-size:12px;">XmlAttribute xValue = xDoc.CreateAttribute("value");</span>
<span style="color:#000000;font-size:12px;">xKey.Value = "someKey";</span>
<span style="color:#000000;font-size:12px;">xValue.Value = "someValue";</span>
<span style="color:#000000;font-size:12px;">xNode.Attributes.Append(xKey);</span>
<span style="color:#000000;font-size:12px;">xNode.Attributes.Append(xValue);</span>
<span style="color:#000000;font-size:12px;">xDoc.GetElementsByTagName("appSettings")[0].InsertAfter(xNode,</span>
<span style="color:#000000;font-size:12px;">xDoc.GetElementsByTagName("appSettings")[o].LastChild);</span>
<span style="color:#000000;font-size:12px;">xDoc.Save("C:\yourXmlFile.xml");</span>
<span style="color:#000000;font-size:12px;">
</span></pre>
<p>And there you have it! Your XML file will now include your new node!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davidfritz.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davidfritz.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/davidfritz.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/davidfritz.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/davidfritz.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/davidfritz.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/davidfritz.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/davidfritz.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/davidfritz.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/davidfritz.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/davidfritz.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/davidfritz.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/davidfritz.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/davidfritz.wordpress.com/143/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidfritz.wordpress.com&amp;blog=7457310&amp;post=143&amp;subd=davidfritz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davidfritz.wordpress.com/2009/07/10/adding-xml-element-to-existing-xml-document-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a82a18042ca1ea7b962f104b6fbbfe9f?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">davidfritz</media:title>
		</media:content>
	</item>
		<item>
		<title>iPhone style checkbox in .NET</title>
		<link>http://davidfritz.wordpress.com/2009/07/02/iphone-style-checkbox-in-net/</link>
		<comments>http://davidfritz.wordpress.com/2009/07/02/iphone-style-checkbox-in-net/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 16:41:04 +0000</pubDate>
		<dc:creator>davidfritz</dc:creator>
				<category><![CDATA[Programs by me]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.net iphone checkbox]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[c# .net]]></category>
		<category><![CDATA[c# iphone checkbox]]></category>
		<category><![CDATA[c# iphone switcher]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone checkbox]]></category>
		<category><![CDATA[iphone on-off switch]]></category>
		<category><![CDATA[on off iphone]]></category>

		<guid isPermaLink="false">http://davidfritz.wordpress.com/?p=128</guid>
		<description><![CDATA[I really like Apple iPhone&#8217;s &#8220;sliding checkbox&#8221; that you see everywhere. It&#8217;s much easier on the eyes and has a big &#8220;cool factor&#8221;. Now I&#8217;m not saying that all applications need a &#8220;cool factor&#8221; (especially the program I&#8217;m using this for), but every once in a while, it&#8217;s fun to add some cool things to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidfritz.wordpress.com&amp;blog=7457310&amp;post=128&amp;subd=davidfritz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I really like Apple iPhone&#8217;s &#8220;sliding checkbox&#8221; that you see everywhere. It&#8217;s much easier on the eyes and has a big &#8220;cool factor&#8221;. Now I&#8217;m not saying that all applications need a &#8220;cool factor&#8221; (especially the program I&#8217;m using this for), but every once in a while, it&#8217;s fun to add some cool things to a .NET application that you don&#8217;t get from the general toolkit.</p>
<p>Unfortunately, there isn&#8217;t anything that I know of that can give .NET controls a nice rounded corners, so you&#8217;ll just have to deal with the very squareish boxes in my example.</p>
<p>First, you need a form (obviously) and you&#8217;ll need to add a SplitContainer. You&#8217;ll probably have to go into the properties and change the &#8220;Dock&#8221; property to &#8220;None&#8221; (otherwise it fills your form). Also, you&#8217;ll want to change the &#8220;BorderStyle&#8221; to &#8220;Fixed3D&#8221;, set the &#8220;SplitterWidth&#8221; to half the width of the container, and set both Panels&#8217; &#8220;MinSize&#8221; to &#8220;0&#8243;. Resize the whole container to the approximate size of the iPhone checkbox, and set the &#8216;BackColor&#8221; to white, or an offwhite. A good size would be around (65,22), but for my demonstration, I&#8217;m making mine larger.</p>
<p>Also, add a Label to each panel. The one in the first panel should have a blue color that is similar to the blue in the iPhone version, and the Text should be &#8220;ON&#8221;. You&#8217;ll also want to change the &#8220;Dock&#8221; for both Labels to &#8220;Fill&#8221;</p>
<p>The Label in the second panel should be the same color as the container backcolor, and should say &#8220;Off&#8221;. You&#8217;ll probably want to change the font in each Label, and set the &#8220;TextAlign&#8221; to &#8220;MiddleCenter&#8221;</p>
<p>Also, change both Labels to AutoSize = False</p>
<p>Here&#8217;s what it should look like so far (it looks like &#8220;O&#8221; is the only thing in the second Label, but its just being crunched because the splitter is in the middle of the container):</p>
<p>Now we need to add some action, so first double click on the form to bring up the &#8220;Form Load&#8221; event handler.</p>
<p>You&#8217;ll need to add the following (assuming you didn&#8217;t change the names of the controls):</p>
<pre>private void Form1_Load(object sender, EventArgs e)
{
	splitContainer1.SplitterDistance = 0;
	splitContainer1.SplitterMoved += new SplitterEventHandler(splitContainer1_SplitterMoved);
}</pre>
<p>This assures that when the form loads, the container will be set to &#8220;O00&#8243;. It will be giving you an error about the method not existing or something; just ignore it.</p>
<p>Now we need to add some click handlers for each Label. You&#8217;ll need to double click the first Label and add this code:</p>
<pre>private void label2_Click(object sender, EventArgs e){splitContainer1.SplitterMoved -= new SplitterEventHandler(splitContainer1_SplitterMoved);for (int x = 100; x &gt;= 0; x--){splitContainer1.SplitterDistance = x;splitContainer1.Refresh();//Thread.Sleep(1);}splitContainer1.SplitterMoved += new SplitterEventHandler(splitContainer1_SplitterMoved);}
private void label1_Click(object sender, EventArgs e)
{
	splitContainer1.SplitterMoved -= new SplitterEventHandler(splitContainer1_SplitterMoved);

	for (int x = 100; x &gt;= 0; x--)
	{
		 splitContainer1.SplitterDistance = x;
		 splitContainer1.Refresh();
	}

	splitContainer1.SplitterMoved += new SplitterEventHandler(splitContainer1_SplitterMoved);
}</pre>
<p>Now go ahead and double click the second Label (O00) and add this code:</p>
<pre>private void label2_Click(object sender, EventArgs e)
{
	splitContainer1.SplitterMoved -= new SplitterEventHandler(splitContainer1_SplitterMoved);

	for (int x = 0; x &lt;= 100; x++)
	{
		splitContainer1.SplitterDistance = x;
		splitContainer1.Refresh();
	}

	splitContainer1.SplitterMoved += new SplitterEventHandler(splitContainer1_SplitterMoved);
}</pre>
<p>Note that depending on your size, you will have to change that &#8220;100&#8243; in each of the loops to the width of your container divided by 2. (my container is 200 wide, so my loop has 100)</p>
<p>You may be wondering why I am removing and re-adding the SplitterEventHandler. It&#8217;s because if we didn&#8217;t do that, every time you try to update the splitter&#8217;s distance, it would raise the splitter moved event, which we don&#8217;t want, since we only want the user to be able to raise that event when they are dragging the splitter manually.</p>
<p>Now we are going to add the event handler for the splitter.  Here&#8217;s the code:</p>
<pre>private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
{
	if (e.SplitX &gt; 50)
	{
		splitContainer1.SplitterMoved -= new SplitterEventHandler(splitContainer1_SplitterMoved);
		for (int x = e.SplitX; x &lt;= 100; x++) 		{ 			splitContainer1.SplitterDistance = x; 			splitContainer1.Refresh(); 		} 		splitContainer1.SplitterMoved += new SplitterEventHandler(splitContainer1_SplitterMoved); 	} 	else 	{ 		splitContainer1.SplitterMoved -= new SplitterEventHandler(splitContainer1_SplitterMoved); 		for (int x = e.SplitX; x &gt;= 0; x--)
		{
			splitContainer1.SplitterDistance = x;
			splitContainer1.Refresh();
		}
		splitContainer1.SplitterMoved += new SplitterEventHandler(splitContainer1_SplitterMoved);
	}
}</pre>
<p>That should do it folks! Run your application and viola, a working iPhone style checkbox in .NET.  Now if you want to know what the value is (ON or O00) you&#8217;ll have to check whether the splitter is at 0 or 100. if it&#8217;s at 0, its o00, or if its at 100, its on.</p>
<p>In the download below, I added a Label that tells whether it is ON or O00.</p>
<p>If you wanted to be really fancy, you could create a custom .NET control called IPhoneCheckBox that extends the SplitContainer control and had an custom enumeration specifying whether the control is set to &#8220;ON&#8221; or &#8220;O00&#8243;. It would require a little more code, but it really wouldn&#8217;t be that hard. If anyone asked for it, I&#8217;d give a tutorial on that too.</p>
<p>Have fun!</p>
<p>Here&#8217;s a link to the compiled EXE. All it is, is a checkbox, so I don&#8217;t think you&#8217;ll have much fun with it, but it will allow you to see the final results.</p>
<p>Download ZIP containing the EXE</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davidfritz.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davidfritz.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/davidfritz.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/davidfritz.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/davidfritz.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/davidfritz.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/davidfritz.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/davidfritz.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/davidfritz.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/davidfritz.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/davidfritz.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/davidfritz.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/davidfritz.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/davidfritz.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidfritz.wordpress.com&amp;blog=7457310&amp;post=128&amp;subd=davidfritz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davidfritz.wordpress.com/2009/07/02/iphone-style-checkbox-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a82a18042ca1ea7b962f104b6fbbfe9f?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">davidfritz</media:title>
		</media:content>
	</item>
	</channel>
</rss>
