<?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>Jeremy Boyd &#187; C#</title>
	<atom:link href="http://jeremy.infinicastonline.com/category/work/net/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeremy.infinicastonline.com</link>
	<description>Web Developer</description>
	<lastBuildDate>Sun, 15 Aug 2010 02:21:25 +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>New ASP.Net MVC GridView Extension</title>
		<link>http://jeremy.infinicastonline.com/2010/07/new-asp-net-mvc-gridview-extension/</link>
		<comments>http://jeremy.infinicastonline.com/2010/07/new-asp-net-mvc-gridview-extension/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 14:57:27 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Asp.net]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[Helper Methods]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://jeremy.infinicastonline.com/?p=223</guid>
		<description><![CDATA[I needed a table builder for a project I was working on. Well I didn&#8217;t need it, I was just tired of having to rebuild a table each time I needed one. So I came up with an obvious solution&#8230; kind of&#8230; I created a helper method! My Super Kick Ass GridView! Here is an [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a table builder for a project I was working on. Well I didn&#8217;t need it, I was just tired of having to rebuild a table each time I needed one. So I came up with an obvious solution&#8230; kind of&#8230; I created a helper method!</p>
<p>My Super Kick Ass GridView!</p>
<p>Here is an excerpt of how to use it</p>
<p><a href="http://jeremy.infinicastonline.com/wp-content/uploads/2010/07/GridView.png"><img class="size-large wp-image-224 alignnone" title="GridView" src="http://jeremy.infinicastonline.com/wp-content/uploads/2010/07/GridView-1024x240.png" alt="" width="491" height="115" /></a></p>
<p><a href="http://jeremy.infinicastonline.com/wp-content/uploads/2010/07/GridView.txt">GridView</a> &#8211; Download me! NOW!</p>
]]></content:encoded>
			<wfw:commentRss>http://jeremy.infinicastonline.com/2010/07/new-asp-net-mvc-gridview-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C#, Enums and Strings oh my!</title>
		<link>http://jeremy.infinicastonline.com/2010/05/c-enums-and-strings-oh-my/</link>
		<comments>http://jeremy.infinicastonline.com/2010/05/c-enums-and-strings-oh-my/#comments</comments>
		<pubDate>Fri, 07 May 2010 20:06:12 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://jeremy.infinicastonline.com/?p=187</guid>
		<description><![CDATA[I find myself having to lookup the same snippets of code a lot. You know, those insignificant lines of code you &#8220;never&#8221; use. Recently I have had to look this up twice, and hopefully by placing it here, I will never need to again (knock on wood). So again, without further ado&#8230; drum roll please&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jeremy.infinicastonline.com/wp-content/uploads/2010/04/dotnet-logo.png"><img class="alignleft size-thumbnail wp-image-180" title="dotnet-logo" src="http://jeremy.infinicastonline.com/wp-content/uploads/2010/04/dotnet-logo-150x150.png" alt="" width="150" height="150" /></a>I find myself having to lookup the same snippets of code a lot. You know, those insignificant lines of code you &#8220;never&#8221; use.</p>
<p>Recently I have had to look this up twice, and hopefully by placing it here, I will never need to again (knock on wood). So again, without further ado&#8230; drum roll please&#8230;</p>
<pre class="brush:csharp">enum CcType { Visa, MasterCard, Discover, Amex, Solo, Maestro }
CcType ccType = CcType.Visa;
string cardType = ccType.ToString();
// This will make cardType = "Visa"
// This is easy to remember, because well you are telling it to turn visa to a string.
// The next part I have to look up each time
ccType = (CcType)Enum.Parse(typeof(ccType), "MasterCard");
// There you go, the simple one line string to enum solution.</pre>
<p>I hope this saves some Googling&#8230; for you and me!</p>
]]></content:encoded>
			<wfw:commentRss>http://jeremy.infinicastonline.com/2010/05/c-enums-and-strings-oh-my/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Asp.Net MVC DropDownList With OptGroups</title>
		<link>http://jeremy.infinicastonline.com/2010/04/asp-net-mvc-dropdownlist-with-optgroups/</link>
		<comments>http://jeremy.infinicastonline.com/2010/04/asp-net-mvc-dropdownlist-with-optgroups/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 16:51:47 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://jeremy.infinicastonline.com/?p=176</guid>
		<description><![CDATA[So rarely do I use opt groups, that I had to actually look up their syntax! So when I wanted to use them in a project I&#8217;m working on in Asp.Net MVC, I wasn&#8217;t very shocked the MVC DropDownList extension didn&#8217;t exist for it. So I ended up writing a bit of my own.  Stole some code [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://jeremy.infinicastonline.com/wp-content/uploads/2010/04/dotnet-logo.png" alt="" title="dotnet-logo" width="200" height="200" class="alignleft size-full wp-image-180" />So rarely do I use opt groups, that I had to actually look up their syntax! So when I wanted to use them in a project I&#8217;m working on in Asp.Net MVC, I wasn&#8217;t very shocked the MVC DropDownList extension didn&#8217;t exist for it. So I ended up writing a bit of my own.  Stole some code here and there (no shame in that).</p>
<p>So without further ado, for everyones enjoyment, I present GroupDropDownList and SelectListOptionGroup.</p>
<pre class="brush:csharp">
public static class Extenders {
    public static string GroupDownDropList(this HtmlHelper helper, string name, IEnumerable&gt;SelectListOptionGroup> data, string optionLabel, object htmlAttributes) {
        if (data == null &#038;&#038; helper.ViewData != null) data = helper.ViewData.Eval(name) as IEnumerable&gt;SelectListOptionGroup>;
        if (data == null) return string.Empty;

        var select = new TagBuilder("select");

        if (htmlAttributes != null)
            select.MergeAttributes(new RouteValueDictionary(htmlAttributes));

        select.GenerateId(name);

        var optgroupHtml = new StringBuilder(string.Concat("
<option value=\"\">", optionLabel, "</option>

"));
        var groups = data.ToList();
        foreach (var group in data) {
            var groupTag = new TagBuilder("optgroup");
            groupTag.Attributes.Add("label", helper.Encode(group.Name));
            var optHtml = new StringBuilder();
            foreach (var item in group.Items) {
                var option = new TagBuilder("option");
                option.Attributes.Add("value", helper.Encode(item.Value));
                if (item.Selected)
                    option.Attributes.Add("selected", "selected");
                option.InnerHtml = helper.Encode(item.Text);
                optHtml.AppendLine(option.ToString(TagRenderMode.Normal));
            }
            groupTag.InnerHtml = optHtml.ToString();
            optgroupHtml.AppendLine(groupTag.ToString(TagRenderMode.Normal));
        }
        select.InnerHtml = optgroupHtml.ToString();
        return select.ToString(TagRenderMode.Normal);
    }
}
public class SelectListOptionGroup {
    public string Name { get; set; }
    public List&gt;SelectListItem> Items { get; set; }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jeremy.infinicastonline.com/2010/04/asp-net-mvc-dropdownlist-with-optgroups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter Feed Reader</title>
		<link>http://jeremy.infinicastonline.com/2010/03/twitter-feed-reader/</link>
		<comments>http://jeremy.infinicastonline.com/2010/03/twitter-feed-reader/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 15:59:09 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://jeremy.infinicastonline.com/?p=151</guid>
		<description><![CDATA[I have done this many times over, and for once I plan on publishing the code so I can reuse it.  This is a Twitter Feed Reader, you pass it the user_status RSS url, with the number of updates you want. This should work flawlessly, but if it doesn&#8217;t&#8230; I&#8217;m sorry. If you need any [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jeremy.infinicastonline.com/wp-content/uploads/2010/03/twitter_t_logo.png"><img src="http://jeremy.infinicastonline.com/wp-content/uploads/2010/03/twitter_t_logo-150x150.png" alt="" title="twitter_t_logo" width="150" height="150" class="alignleft size-thumbnail wp-image-153" /></a>I have done this many times over, and for once I plan on publishing the code so I can reuse it.  This is a Twitter Feed Reader, you pass it the user_status RSS url, with the number of updates you want.  This should work flawlessly, but if it doesn&#8217;t&#8230; I&#8217;m sorry.  If you need any help implementing this, just let me know.  I&#8217;m always around to help.</p>
<div class="csharp" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> TwitterStatus <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Status <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Url <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> DateTime Date <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> TwitterStatus<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> GetTwitter<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> url, <span style="color: #6666cc; font-weight: bold;">int</span> length<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; XDocument xRoot <span style="color: #008000;">=</span> XDocument<span style="color: #008000;">.</span><span style="color: #0000FF;">Load</span><span style="color: #008000;">&#40;</span>url<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; var items <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">from</span> item <span style="color: #0600FF; font-weight: bold;">in</span> xRoot<span style="color: #008000;">.</span><span style="color: #0000FF;">Descendants</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;item&quot;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">select</span> <a style="color: #000060;" href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> TwitterStatus<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Status <span style="color: #008000;">=</span> LinkifyStatusUpdate<span style="color: #008000;">&#40;</span>item<span style="color: #008000;">.</span><span style="color: #0000FF;">Element</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;title&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Date <span style="color: #008000;">=</span> DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">.</span><span style="color: #0000FF;">Element</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;pubDate&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Url <span style="color: #008000;">=</span> item<span style="color: #008000;">.</span><span style="color: #0000FF;">Element</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;link&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Take</span><span style="color: #008000;">&#40;</span>length<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> items<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">string</span> LinkifyStatusUpdate<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> status<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> ret <span style="color: #008000;">=</span> status<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span>status<span style="color: #008000;">.</span><span style="color: #0000FF;">IndexOf</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;: &quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ret <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span>ret, <span style="color: #666666;">@&quot;(http[s]?:\/\/[^\s]+)&quot;</span>, <span style="color: #666666;">&quot;&lt;a href=<span style="color: #008080; font-weight: bold;">\&quot;</span>$1<span style="color: #008080; font-weight: bold;">\&quot;</span>&gt;$1&lt;/a&gt;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ret <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span>ret, <span style="color: #666666;">@&quot;(#[^\W]+)&quot;</span>, <span style="color: #666666;">&quot;&lt;a href=<span style="color: #008080; font-weight: bold;">\&quot;</span>http://www.twitter.com/search?q=$1/<span style="color: #008080; font-weight: bold;">\&quot;</span>&gt;$1&lt;/a&gt;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ret <span style="color: #008000;">=</span> Regex<span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span>ret, <span style="color: #666666;">@&quot;@([^\W]+)&quot;</span>, <span style="color: #666666;">&quot;&lt;a href=<span style="color: #008080; font-weight: bold;">\&quot;</span>http://www.twitter.com/$1/<span style="color: #008080; font-weight: bold;">\&quot;</span>&gt;@$1&lt;/a&gt;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> ret<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div>
]]></content:encoded>
			<wfw:commentRss>http://jeremy.infinicastonline.com/2010/03/twitter-feed-reader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gif2Png &#8211; Gray scale Only</title>
		<link>http://jeremy.infinicastonline.com/2010/02/gif2png-gray-scale-only/</link>
		<comments>http://jeremy.infinicastonline.com/2010/02/gif2png-gray-scale-only/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 18:02:56 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[Image Manipulation]]></category>

		<guid isPermaLink="false">http://jeremy.infinicastonline.com/?p=125</guid>
		<description><![CDATA[I&#8217;m working with a client that saved out a bunch of motifs in to &#8220;transparent&#8221; gifs, but wants those motifs on a background &#8220;without the jaggy&#8221; white pixes. After doing the first 10 or so by hand in PhotoShop (a pain in my rear), I wrote a little C# app to handle all of this [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working with a client that saved out a bunch of motifs in to &#8220;transparent&#8221; gifs, but wants those motifs on a background &#8220;without the jaggy&#8221; white pixes.</p>
<p>After doing the first 10 or so by hand in PhotoShop (a pain in my rear), I wrote a little C# app to handle all of this for me.</p>
<p>It assumes the image is gray scale, and that white/transparent is the background.</p>
<p>Use it, abuse it! <a href="http://jeremy.infinicastonline.com/wp-content/uploads/2010/02/gif2png.zip">gif2png</a> (source only)</p>
<div id="attachment_129" class="wp-caption alignnone" style="width: 85px"><a href="http://jeremy.infinicastonline.com/wp-content/uploads/2010/02/cat.gif"><img class="size-full wp-image-129" title="Gif2Png Input (Cat.gif)" src="http://jeremy.infinicastonline.com/wp-content/uploads/2010/02/cat.gif" alt="Gif2Png Input (Cat.gif)" width="75" height="75" /></a><p class="wp-caption-text">Gif2Png Input (Cat.gif)</p></div>
<div id="attachment_130" class="wp-caption alignnone" style="width: 85px"><a href="http://jeremy.infinicastonline.com/wp-content/uploads/2010/02/cat.png"><img class="size-full wp-image-130" title="Gif2Png Output (Cat.png)" src="http://jeremy.infinicastonline.com/wp-content/uploads/2010/02/cat.png" alt="Gif2Png Output (Cat.png)" width="75" height="75" /></a><p class="wp-caption-text">Gif2Png Output (Cat.png)</p></div>
]]></content:encoded>
			<wfw:commentRss>http://jeremy.infinicastonline.com/2010/02/gif2png-gray-scale-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
