<?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>Avivo Tech Blog &#187; c#</title>
	<atom:link href="http://tech.avivo.si/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.avivo.si</link>
	<description>Solving problems</description>
	<lastBuildDate>Tue, 24 Jan 2012 14:46:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>The easiest way to generate a QR Code for software developers</title>
		<link>http://tech.avivo.si/2012/01/the-easiest-way-to-generate-a-qr-code-for-programmers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-easiest-way-to-generate-a-qr-code-for-programmers</link>
		<comments>http://tech.avivo.si/2012/01/the-easiest-way-to-generate-a-qr-code-for-programmers/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 14:46:11 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[HTML, Javascript and CSS]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[qr code generators]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[simple]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1445</guid>
		<description><![CDATA[So you want to simply generate a QR Code image without diving into the technical specifics? This blog post contains a few simple examples. Just copy-paste where you need it. Idea is to build a URL, make an HTTP request and download the QR Code image. Result is the following image: HTTP Request URL looks [...]]]></description>
			<content:encoded><![CDATA[<p>So you want to simply generate a QR Code image without diving into the technical specifics? This blog post contains a few simple examples. Just copy-paste where you need it.</p>
<p>Idea is to build a URL, make an HTTP request and download the QR Code image. Result is the following image:</p>
<pre><img src="http://www.esponce.com/api/v3/generate?content=your%20content%20goes%20here&#038;format=png" alt="your content goes here" /></pre>
<h2>HTTP Request</h2>
<p>URL looks like<strong> http://www.esponce.com/api/v3/generate?content={content}&amp;format={format}</strong> where <strong>{content}</strong> is URL encoded content to be embedded in QR and <strong>{format}</strong> is output image format. Available formats are <strong>png, jpg, bmp, tif, xaml, svg, eps, txt, html, zip</strong> (containing all listed formats)</p>
<p>List of other parameters like color and size can be found <a href="http://www.esponce.com/help/api-v3/generate#parameters">here</a>.</p>
<h2>C# Sample</h2>
<p>This code can be used in <strong>.NET 2.0</strong> including ASP.NET and WPF or <strong>Silverlight</strong> for web or <strong>WP7</strong></p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.IO;
using System.Web;
using System.Net;

public class Program
{
  public static void Main(string[] args)
  {
    //Generate a QR Code and save it to file &quot;sample.png&quot;
    Generate(&quot;your content goes here&quot;, &quot;png&quot;, &quot;sample.png&quot;);
  }

  public static void Generate(string content, string format, string path)
  {
    string encoded = HttpUtility.UrlEncode(content);
    Uri uri = new Uri(&quot;http://www.esponce.com/api/v3/generate?content=&quot; + encoded + &quot;&amp;format=&quot; + format);
    WebClient client = new WebClient();
    client.DownloadFile(uri, path);
  }
}
</pre>
<h2>Java Sample</h2>
<p>This code can be used in a classic <strong>Java</strong> application or web <strong>applet</strong> or <strong>Android</strong> application</p>
<pre class="brush: java; title: ; notranslate">
import java.io.*;
import java.net.*;

public class qrcode
{
  public static void main(String args[])
  {
    //Generate a QR Code image and save it to file &quot;sample.png&quot;
    generate(&quot;your content goes here&quot;, &quot;png&quot;, &quot;sample.png&quot;);
  }

  public static void generate(String content, String format, String path)
  {
    try
    {
      String encoded = URLEncoder.encode(content, &quot;UTF-8&quot;);
      String url = &quot;http://www.esponce.com/api/v3/generate?content=&quot; + encoded + &quot;&amp;format=&quot; + format;
      BufferedInputStream ins = new BufferedInputStream(new URL(url).openStream());
      FileOutputStream fos = new FileOutputStream(path);
      BufferedOutputStream bos = new BufferedOutputStream(fos, 1024);

      int size = 0;
      byte data[] = new byte[1024];
      while ((size = ins.read(data, 0, 1024)) &amp;gt; 0)
      {
        bos.write(data, 0, size);
      }

      bos.close();
      fos.close();
      ins.close();
    }
    catch (Exception e)
    {
    }
  }
}
</pre>
<h2>Python Sample</h2>
<p>Using Python 2.7</p>
<pre class="brush: python; title: ; notranslate">
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import urllib
import httplib

def generate(content, format = &quot;png&quot;):
    query = urllib.urlencode({ &quot;content&quot;: content, &quot;format&quot;: format })
    con = httplib.HTTPConnection(&quot;www.esponce.com&quot;)
    con.request(&quot;GET&quot;, &quot;/api/v3/generate?&quot; + query)
    response = con.getresponse()
    image = response.read()
    con.close()
    return image

image = generate(&quot;your content goes here&quot;)
file = open(&quot;sample.png&quot;, &quot;wb&quot;)
file.write(image)
file.close()
</pre>
<h2>JavaScript Sample</h2>
<p>JavaScript in combination with HTML</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;img id=&quot;qrcode&quot; src=&quot;&quot; alt=&quot;QR Code&quot; /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    function generate(content)
    {
        var url = &quot;http://www.esponce.com/api/v3/generate?content=&quot; + encodeURI(content) + &quot;&amp;format=png&quot;;
        var img = document.getElementById(&quot;qrcode&quot;);
        img.src = url;
    }
    generate(&quot;your content goes here&quot;);
&lt;/script&gt;
</pre>
<h2>PHP Sample</h2>
<pre class="brush: php; title: ; notranslate">
&lt;img src=&quot;&lt;?php echo generate(&quot;your content goes here&quot;); ?&gt;&quot; alt=&quot;QR Code&quot; /&gt;

&lt;?php
function generate($content, $format = &quot;png&quot;)
{
    $encoded = urlencode($content);
    $url = &quot;http://www.esponce.com/api/v3/generate?content=$encoded&amp;format=$format&quot;;
    return $url;
}
?&gt;
</pre>
<h2>There is more</h2>
<p>Download all samples with <em>make</em> script <a href="http://tech.avivo.si/wp-content/uploads/2012/01/generate-qr-code-samples-src.zip">here</a>.</p>
<p>Other QR Code related methods like decoding (reverse process of generating) and tracking scans can be found at <a href="http://www.esponce.com/help">esponce.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2012/01/the-easiest-way-to-generate-a-qr-code-for-programmers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So, you can not delete Cookie? Huh, something about headers or headache&#8230;</title>
		<link>http://tech.avivo.si/2011/07/so-you-can-not-delete-cookie-huh-something-about-headers-or-headache/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=so-you-can-not-delete-cookie-huh-something-about-headers-or-headache</link>
		<comments>http://tech.avivo.si/2011/07/so-you-can-not-delete-cookie-huh-something-about-headers-or-headache/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 12:18:55 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA["Server cannot modify cookies after HTTP headers have been sent"]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[can not delete cookie]]></category>
		<category><![CDATA[charp]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[delete cookie]]></category>
		<category><![CDATA[headers]]></category>
		<category><![CDATA[response]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1337</guid>
		<description><![CDATA[We wanted to delete cookie setting its expired date property to something in the past like this: HttpCookie cookie = new HttpCookie(this.Name); cookie.Expires = DateTime.UtcNow.AddMonths(-1); HttpContext.Current.Response.Cookies.Add(cookie); But we got an error: Server cannot modify cookies after HTTP headers have been sent. After searching and searching if we have somewhere Response.Write in or ASP.NET MVC code [...]]]></description>
			<content:encoded><![CDATA[<p>We wanted to delete cookie setting its expired date property to something in the past like this:</p>
<pre class="csharp">
HttpCookie cookie = new HttpCookie(this.Name);
cookie.Expires = DateTime.UtcNow.AddMonths(-1);
HttpContext.Current.Response.Cookies.Add(cookie);
</pre>
<div style="margin-top:30px;">But we got an error: </div>
<p><b>Server cannot modify cookies after HTTP headers have been sent.</b></p>
<p>After searching and searching if we have somewhere <b>Response.Write</b> in or ASP.NET MVC code we found out that we don&#8217;t have such things.<br />
Suddenly, we found out that we played with <b>Session</b> object (trying to clear it) before deleting <b>Cookie</b> and that was it. Reordering these operations solved our problem.</p>
<div style="margin-top:30px;"><b>Conclusion</b><br/>Session object also use cookies, we forgot.</div>
<h2 style="margin-top:30px; color:red;">Update on this case</h2>
<div style="margin-top:20px; color:red;">
This &#8220;solution&#8221; didn&#8217;t helped&#8230; Everything is so simple and was done with <a href="http://www.electrictoolbox.com/jquery-cookies/" target="_blank">JQuery cookie plugin</a>. One line of code from Javascript!</div>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/07/so-you-can-not-delete-cookie-huh-something-about-headers-or-headache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create random web hex color in C# / ASP.NET MVC</title>
		<link>http://tech.avivo.si/2011/04/create-random-web-hex-color-in-c-asp-net-mvc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-random-web-hex-color-in-c-asp-net-mvc</link>
		<comments>http://tech.avivo.si/2011/04/create-random-web-hex-color-in-c-asp-net-mvc/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 22:46:16 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[colour]]></category>
		<category><![CDATA[hash color]]></category>
		<category><![CDATA[random color]]></category>
		<category><![CDATA[web color]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1305</guid>
		<description><![CDATA[Random random = new Random(); int red = random.Next(0, 255); int green = random.Next(0, 255); int blue = random.Next(0, 255); string hexColour = String.Format("#{0:X2}{1:X2}{2:X2}", red, green, blue);]]></description>
			<content:encoded><![CDATA[<pre class=csharp>
Random random = new Random();
int red = random.Next(0, 255);
int green = random.Next(0, 255);
int blue = random.Next(0, 255);
string hexColour = String.Format("#{0:X2}{1:X2}{2:X2}", red, green, blue);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/04/create-random-web-hex-color-in-c-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight: Equidistant items in a stack panel</title>
		<link>http://tech.avivo.si/2011/03/silverlight-xaml-equidistant-items-in-a-stack-panel/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-xaml-equidistant-items-in-a-stack-panel</link>
		<comments>http://tech.avivo.si/2011/03/silverlight-xaml-equidistant-items-in-a-stack-panel/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 13:00:28 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[axis]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[chart]]></category>
		<category><![CDATA[coordinates]]></category>
		<category><![CDATA[equidistant]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[stackpanel]]></category>
		<category><![CDATA[wpf]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1164</guid>
		<description><![CDATA[This post describes how to align items in a container so the two neighbour items are always aligned with equal distance. Solution should be flexible, meaning that when items are changed or when container is resized items should keep equal distance in between. Reader should have some basic knowledge about C# and XAML for Silverlight. [...]]]></description>
			<content:encoded><![CDATA[<p>This post describes how to align items in a container so the two neighbour items are always aligned with equal distance. Solution should be flexible, meaning that when items are changed or when container is resized items should keep equal distance in between. Reader should have some basic knowledge about C# and XAML for Silverlight.</p>
<h2>Ideas</h2>
<ul>
<li>using Canvas and positioning items with <strong>absolute coordinates</strong> &#8211; items are always fixed, coordinates need to be calculated, so it is the least flexible approach, no</li>
<li>using <strong>StackPanel</strong> with items that have margin &#8211; margins need to be recalculated when an item is added or removed or when container is resized, maybe</li>
<li>using Grid with <strong>predefined rows and columns</strong> &#8211; notice <em>predefined</em>, means less flexibility, but offers equal size rows/columns, maybe</li>
<li>using a <strong>custom control</strong> &#8211; making Grid more dynamic but extending number of rows/columns when items are added, yes</li>
</ul>
<h2>Custom Control: EqualDistanceStackPanel</h2>
<p>As written before, custom control should extend Grid to become more flexible</p>
<pre style="background: #eeeeee; padding: 15px;">public class EqualDistanceStackPanel : Grid
{
}</pre>
<p>&nbsp;</p>
<p><em>EqualDistanceStackPanel</em> should implement <em>ItemsSource</em> and <em>ItemTemplate</em> just like <em><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol%28v=vs.95%29.aspx" target="_blank">ItemsControl</a></em></p>
<pre style="background: #eeeeee; padding: 15px;">#region ItemsSource
public IEnumerable ItemsSource
{
  get { return (IEnumerable)GetValue(ItemsSourceProperty); }
  set { SetValue(ItemsSourceProperty, value); }
}

public static readonly DependencyProperty ItemsSourceProperty =
  DependencyProperty.Register("ItemsSource", typeof(IEnumerable),
  typeof(EqualDistanceStackPanel), new PropertyMetadata(ItemsSourceChanged));

private static void ItemsSourceChanged(DependencyObject d,
  DependencyPropertyChangedEventArgs e)
{
  var panel = d as EqualDistanceStackPanel;
  if (panel != null)
  {
    if (e.OldValue != null)
    {
      panel.ClearItems();
    }
    if (e.NewValue != null)
    {
      panel.BindItems(e.NewValue as IEnumerable);
    }
  }
}
#endregion

public DataTemplate ItemTemplate
{
  get;
  set;
}</pre>
<p>&nbsp;</p>
<p><em>ClearItems</em> method deletes all previous elements from the panel and <em>BindItems</em> attaches fresh controls from item template.</p>
<pre style="background: #eeeeee; padding: 15px;">protected void ClearItems()
{
  this.Children.Clear();
}

protected void BindItems(IEnumerable items)
{
  if (this.ItemTemplate == null)
  {
    return;
  }

  //Create and attach children
  foreach (var item in items)
  {
    var element = this.ItemTemplate.LoadContent() as FrameworkElement;
    element.DataContext = item;
    this.Children.Add(element);
  }

  //Realign in container
  Refresh();
}</pre>
<p>&nbsp;</p>
<p>How should the custom control look in XAML? <em>EqualDistanceStackPanel</em> gets a collection of items, e.g. of UIElement type.</p>
<pre style="background: #eeeeee; padding: 15px;">&lt;Grid xmlns:c="clr-namespace:Avivo.Controls"&gt;
  &lt;c:EqualDistanceStackPanel ItemsSource="{Binding Items}" Orientation="Vertical"&gt;
    &lt;c:EqualDistanceStackPanel.ItemTemplate&gt;
      &lt;DataTemplate&gt;
        &lt;ContentPresenter Content="{Binding}" /&gt;
      &lt;/DataTemplate&gt;
    &lt;/c:EqualDistanceStackPanel.ItemTemplate&gt;
  &lt;/c:EqualDistanceStackPanel&gt;
&lt;/Grid&gt;</pre>
<p>&nbsp;</p>
<h2>Example</h2>
<p>Ruler has been made to demonstrate the usage of EqualDistanceStackPanel. Numbers are bound to the control and ticks are bound to another control using the same binding collection. Left image represents container height 300px and right when resized to 460px &#8211; elements are automatically aligned with equal distance.<br />
<img class="alignnone size-full wp-image-1177" title="Example of a ruler" src="http://tech.avivo.si/wp-content/uploads/2011/01/equidistant-stack-panel.jpg" alt="" width="414" height="734" /></p>
<p><a href="http://labs.avivo.si/equidistant/" target="_blank">Try demo</a>, resize browser to see the effect. This control has been originally developed for custom chart axes in <a href="http://qrcode.good-survey.com/" target="_blank">QR Code Statistics</a> application. <em>EqualDistanceStackPanel</em> control is lightweight, works for the statistics application and should be improved for general usage.</p>
<h2>Source code</h2>
<ul>
<li><a href="http://labs.avivo.si/equidistant/EqualDistanceStackPanel.zip">Source code</a>, Visual Studio sample Silverlight and web project</li>
</ul>
<h2>References</h2>
<ul>
<li><a href="http://chris.59north.com/post/Using-DataTemplates-in-custom-controls.aspx" target="_blank">Using DataTemplates in custom controls</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/03/silverlight-xaml-equidistant-items-in-a-stack-panel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to trim leading and trailing HTML spaces in C#</title>
		<link>http://tech.avivo.si/2010/12/how-to-trim-leading-and-trailing-html-spaces-in-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-trim-leading-and-trailing-html-spaces-in-c</link>
		<comments>http://tech.avivo.si/2010/12/how-to-trim-leading-and-trailing-html-spaces-in-c/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 12:27:52 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[remove trailing and leading html spaces]]></category>
		<category><![CDATA[trim]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=948</guid>
		<description><![CDATA[Some HTML WYSIWYG editors create &#8216;br&#8217; tags or leave &#8216;&#38;nbsp;&#8217; garbage spaces when no content is entered. Described TrimWhiteSpaces method is useful when you need to determine if user left blank content in WYSIWYG editor or if you just want to clean HTML code. TrimWhiteSpaces accepts raw HTML content and removes white spaces, tabs, new [...]]]></description>
			<content:encoded><![CDATA[<p>Some HTML WYSIWYG editors create &#8216;br&#8217; tags or leave &#8216;&amp;nbsp;&#8217; garbage spaces when no content is entered. Described <strong>TrimWhiteSpaces </strong>method is useful when you need to determine if user left blank content in WYSIWYG editor or if you just want to clean HTML code.</p>
<p><strong>TrimWhiteSpaces</strong> accepts raw HTML content and removes white spaces, tabs, new line characters, &#8216;br&#8217; tags and &#8216;&amp;nbsp;&#8217; chunks from before and after the actual content.</p>
<pre class=csharp>
public static string TrimWhiteSpaces(string html)
{
  string result = html;

  //Remove leading spaces
  result = Regex.Replace(result, @"<span style="color: red;">^(?&lt;leading&gt;(\s|\r|\n|\&lt;br\s*/?\&gt;|&amp;nbsp;)*)</span>", "",
RegexOptions.IgnoreCase);

  //Remove trailing spaces
  result = Regex.Replace(result, @"<span style="color: red;">(?&lt;trailing&gt;(\s|\r|\n|\&lt;br\s*/?\&gt;|&amp;nbsp;)*)$</span>", "",
RegexOptions.IgnoreCase);

  return result;
}
</pre>
<div style="margin-top:20px;">
<strong>Example:</strong>
</div>
<div style="margin-top:20px;">
<strong>Input:</strong></p>
<pre><span style="color: red;">&amp;nbsp;&lt;br /&gt;&lt;BR   &gt;&lt;BR&gt; &amp;nbsp;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;</span><span style="color: blue;">
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;p&gt;Pellentesque lorem neque, accumsan eget euismod ut, tristique et odio.&lt;/p&gt;</span>
<span style="color: red;">&amp;nbsp;&lt;br /&gt; &lt;br&gt;
&amp;nbsp;</span>
</pre>
</div>
<div style="margin-top:20px;">
<strong>Output:</strong></p>
<pre class=csharp>
<span style="color: blue;">
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;p&gt;Pellentesque lorem neque, accumsan eget euismod ut, tristique et odio.&lt;/p&gt;
</span>
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/12/how-to-trim-leading-and-trailing-html-spaces-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Managing memory leaks in WinForms application</title>
		<link>http://tech.avivo.si/2010/12/managing-memory-leaks-in-winforms-application/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=managing-memory-leaks-in-winforms-application</link>
		<comments>http://tech.avivo.si/2010/12/managing-memory-leaks-in-winforms-application/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 08:23:01 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[dispose]]></category>
		<category><![CDATA[garbage collection]]></category>
		<category><![CDATA[memory leaks]]></category>
		<category><![CDATA[memory leaks in winforms applications]]></category>
		<category><![CDATA[removing events]]></category>
		<category><![CDATA[windows forms memory leaks]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=940</guid>
		<description><![CDATA[Few things that can create memory leaks are: If you have a UserControl which you add dynamically to your form and if you attach events dynamically to this UserControl using:< br /> ucMyControl.btnSave.Click += new EventHandler(btnSave_Click); and if you are removing you UserControl from the form using Controls.Clear() method then you must first remove all [...]]]></description>
			<content:encoded><![CDATA[<p>Few things that can create memory leaks are:</p>
<ol>
<li>If you have a UserControl which you add dynamically to your form and if you attach events dynamically to this UserControl using:< br />
<pre class=csharp>
ucMyControl.btnSave.Click += new EventHandler(btnSave_Click);
</pre>
<p> and if you are removing you UserControl from the form using <strong>Controls.Clear() </strong>method then you must first remove all attached events before removing your UserControl using
<pre class=csharp>
ucMyControl.btnSave.Click -= new EventHandler(btnSave_Click);
</pre>
</li>
<li style="margin-top:25px;">When removing dynamically added control from Form/Panel calling <strong>Controls.Clear()</strong> is not enough and instance stays in the heap after thar, so before this command call <strong>Dispose()</strong> on your dynamically added UserControl (that means that you should save a reference to your control in order to dispose it after)
</li>
<li style="margin-top:25px;">
If you have modal forms do not forget to call <strong>Dispose()</strong> after <strong>ShowDialog()</strong> method and set their reference to null in order to be garbage collected!</p>
<pre>
MyDialog dialog = new MyDialog();
dialog.ShowModal();
dialog.Dispose();
dialog = null;
</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/12/managing-memory-leaks-in-winforms-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to span columns or rows in TableLayoutPanel?</title>
		<link>http://tech.avivo.si/2010/12/how-to-span-columns-or-rows-in-tablelayoutpanel/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-span-columns-or-rows-in-tablelayoutpanel</link>
		<comments>http://tech.avivo.si/2010/12/how-to-span-columns-or-rows-in-tablelayoutpanel/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 23:55:03 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[span columns in TableLayoutPanel]]></category>
		<category><![CDATA[span rows in TableLayoutPanel]]></category>
		<category><![CDATA[TableLayoutPanel]]></category>
		<category><![CDATA[winforms]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=935</guid>
		<description><![CDATA[How you can span columns or rows in WinForms TableLayoutPanel? Using designer you can not span columns and rows directly in TableLayoutPanel but you can, when add one control into TableLayoutPanel set ColumnSpan or RowSpan of this control instead. Drag a TableLayoutPanel control from the Toolbox onto your form. Drag a ListBox control from the [...]]]></description>
			<content:encoded><![CDATA[<p>How you can span columns or rows in WinForms TableLayoutPanel?<br />
Using designer you can not span columns and rows directly in TableLayoutPanel but you can, when add one control into TableLayoutPanel set <strong>ColumnSpan </strong>or <strong>RowSpan </strong>of this control instead.</p>
<ol>
<li>Drag a <strong>TableLayoutPanel</strong> control from the <strong>Toolbox</strong> onto your form.</li>
<li>Drag a <strong>ListBox</strong> control from the <strong>Toolbox</strong> into the upper-left cell of the <strong>TableLayoutPanel</strong> control.</li>
<li>Set the <strong>ListBox</strong> control&#8217;s <strong>ColumnSpan</strong> property to <strong>2</strong>. Note that the <strong>ListBox</strong> control spans the first and second columns.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/12/how-to-span-columns-or-rows-in-tablelayoutpanel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing URL query string into key-value pairs in C#</title>
		<link>http://tech.avivo.si/2010/12/parsing-url-query-string-into-key-value-pairs-in-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=parsing-url-query-string-into-key-value-pairs-in-c</link>
		<comments>http://tech.avivo.si/2010/12/parsing-url-query-string-into-key-value-pairs-in-c/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 12:08:31 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[key-value pairs from query string]]></category>
		<category><![CDATA[parsing query string]]></category>
		<category><![CDATA[query string]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=917</guid>
		<description><![CDATA[Imagine you have URL something like this: http://www.yourdomain.com?param1=value1&#38;param2=value2&#38;param3=value3&#38;param4=value4 and you want to get key-value pairs such as {&#8220;param1&#8243;, &#8220;param2&#8243;, &#8220;param3&#8243;, &#8220;param4&#8243;} {&#8220;value1&#8243;, &#8220;value2&#8243;, &#8220;value3&#8243;, &#8220;value4&#8243;} It is easy to do using system function: using System.Collections.Specialized; NameValueCollection query = HttpUtility.ParseQueryString(queryString); Response.Write(query["param1"]);]]></description>
			<content:encoded><![CDATA[<p>Imagine you have URL something like this:</p>
<p><strong>http://www.yourdomain.com?param1=value1&amp;param2=value2&amp;param3=value3&amp;param4=value4</strong></p>
<p>and you want to get key-value pairs such as</p>
<ul>
<li>{&#8220;param1&#8243;, &#8220;param2&#8243;, &#8220;param3&#8243;, &#8220;param4&#8243;}</li>
<li>{&#8220;value1&#8243;, &#8220;value2&#8243;, &#8220;value3&#8243;, &#8220;value4&#8243;}</li>
</ul>
<p>It is easy to do using system function:</p>
<pre class=charp>
using System.Collections.Specialized;
NameValueCollection query = HttpUtility.ParseQueryString(queryString);
Response.Write(query["param1"]);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/12/parsing-url-query-string-into-key-value-pairs-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove items from List using LINQ</title>
		<link>http://tech.avivo.si/2010/11/remove-items-from-list-using-linq/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=remove-items-from-list-using-linq</link>
		<comments>http://tech.avivo.si/2010/11/remove-items-from-list-using-linq/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 18:13:52 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[collections]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[ms sql server]]></category>
		<category><![CDATA[Remove items from list using linq]]></category>
		<category><![CDATA[remove items in runtime]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=821</guid>
		<description><![CDATA[Typical scenario: you got your list of items from database but you want to remove some items from it (items that match additional criterion). It is simple as this (i.e. assuming that your list is named yourItems): yourItems.RemoveAll(x => x.ItemPropertyId != null);]]></description>
			<content:encoded><![CDATA[<p>Typical scenario: you got your list of items from database but you want to remove some items from it (items that match additional criterion).</p>
<p>It is simple as this (i.e. assuming that your list is named <strong>yourItems</strong>):</p>
<pre class=csharp>
yourItems.RemoveAll(x => x.ItemPropertyId != null);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/11/remove-items-from-list-using-linq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force dot as decimal separator and ignore thousand separator when formatting decimal numbers</title>
		<link>http://tech.avivo.si/2010/10/force-dot-as-decimal-separator-and-ignore-thousand-separator-when-formatting-decimal-numbers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=force-dot-as-decimal-separator-and-ignore-thousand-separator-when-formatting-decimal-numbers</link>
		<comments>http://tech.avivo.si/2010/10/force-dot-as-decimal-separator-and-ignore-thousand-separator-when-formatting-decimal-numbers/#comments</comments>
		<pubDate>Thu, 21 Oct 2010 17:00:01 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[charp]]></category>
		<category><![CDATA[force dot as decimal separator]]></category>
		<category><![CDATA[format decimal numbers]]></category>
		<category><![CDATA[how to remove thousands separator]]></category>
		<category><![CDATA[ignore or remove thousand separator]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=658</guid>
		<description><![CDATA[Sometimes, when you are doing data integrations, you can have a vendor that can accept numbers only in specific format. So (for EN culture), our vendor said to us: This is not valid: 10,000.44 This is valid for me: 10000.44 That means we had to remove thousand separator and needed to force dot as decimal [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, when you are doing data integrations, you can have a vendor that can accept numbers only in specific format.<br />
So (for EN culture), our vendor said to us:<br />
This is not valid: <b>10,000.44</b><br />
This is valid for me: <b>10000.44</b></p>
<p>That means we had to remove thousand separator and needed to force dot as decimal separator (btw, we are SI culture and we use comma as decimal separator and dot is thousand separator).</p>
<p>This is the way how to do it:</p>
<pre lang=csharp>
CultureInfo ci = CultureInfo.GetCultureInfo("en-US");
NumberFormatInfo nfi = (NumberFormatInfo)ci.NumberFormat.Clone();
//Now force thousand separator to be empty string
nfi.NumberGroupSeparator = "";
//Format decimal number to 2 decimal places
string decimalFormatted = product.Price.ToString("n2", nfi);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/10/force-dot-as-decimal-separator-and-ignore-thousand-separator-when-formatting-decimal-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

