<?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; Tools</title>
	<atom:link href="http://tech.avivo.si/category/tools/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>Three essential plugins for Expression Blend</title>
		<link>http://tech.avivo.si/2010/07/three-essential-plugins-for-expression-blend/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=three-essential-plugins-for-expression-blend</link>
		<comments>http://tech.avivo.si/2010/07/three-essential-plugins-for-expression-blend/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 09:49:00 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=529</guid>
		<description><![CDATA[When it comes to vector graphics in Windows applications XAML is the most advanced format to choose from. XAML is great because developer/designer has full control over the graphics. Hidden reference lines, or garbage shapes, or objects can be relatively easily detected and removed from the code as compared to those formats that entirely rely [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to vector graphics in Windows applications <a title="Extensible application markup language" href="http://en.wikipedia.org/wiki/Extensible_Application_Markup_Language">XAML</a> is the most advanced format to choose from. XAML is great because developer/designer has full control over the graphics. Hidden reference lines, or garbage shapes, or objects can be relatively easily detected and removed from the code as compared to those formats that entirely rely on GUI editor.</p>
<p>A XAML document can be created with plain Notepad but there are great apps like Visual Studio, Expression Blend and Kaxaml that simplify editing. What is missing in those apps is lack of XAML exporting support, like saving .xaml to .png file. Luckily there are plugins to do just that.</p>
<p><strong><a title="Expression Blend Printing Add-in" href="http://xbprint.codeplex.com/">xbprint</a> </strong>is printing <strong>plugin </strong>for <strong>Expression Blend</strong> 3 hosted on CodePlex. Installation of the utility must be perfomed manually by extracting files to the Addins folder in Expression Blend directory. But once the plugin is installed it is easy to use. Set margins, alignment, paper size and click Print.</p>
<p><a rel="attachment wp-att-531" href="http://tech.avivo.si/2010/07/three-essential-plugins-for-expression-blend/xbprint_medium/"><img class="alignnone size-medium wp-image-531" title="xbprint screenshot" src="http://tech.avivo.si/wp-content/uploads/2010/07/xbprint_medium-600x375.jpg" alt="xbprint screenshot" width="600" height="375" /></a></p>
<p><strong><a title="Expression Blend Rasterizer Add-in" href="http://xbraster.codeplex.com/">xbraster</a> </strong>is <strong>xaml to raster image</strong> converting plugin, a close relative to xbprint. Installation and use is similar. xbraster can convert XAML to PNG, JPEG, TIFF, GIF or bitmap.</p>
<p><a rel="attachment wp-att-532" href="http://tech.avivo.si/2010/07/three-essential-plugins-for-expression-blend/xbraster_medium/"><img class="alignnone size-medium wp-image-532" title="xbraster screenshot" src="http://tech.avivo.si/wp-content/uploads/2010/07/xbraster_medium-600x375.jpg" alt="xbraster screenshot" width="600" height="375" /></a></p>
<p><a title="Sprite Generator Add-in for Expression Blend" href="http://xbsprite.codeplex.com"><strong>xbsprite</strong></a> is a <strong>sprite image generating</strong> plugin. Input xaml files are rasterized and combined in one image with optional CSS and HTML output for use on a web page.</p>
<p><a rel="attachment wp-att-535" href="http://tech.avivo.si/2010/07/three-essential-plugins-for-expression-blend/xbsprite_medium/"><img class="alignnone size-medium wp-image-535" title="xbsprite screenshot" src="http://tech.avivo.si/wp-content/uploads/2010/07/xbsprite_medium-600x375.jpg" alt="xbsprite screenshot" width="600" height="375" /></a></p>
<p>For advanced and professional use of XAML xbprint, xbraster and xbsprite are must-have plugins.</p>
<p><strong>EDIT: xbprint, xbraster and xbsprite can run directly from desktop &#8211; no need to have<br />
Expression Blend installed.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/07/three-essential-plugins-for-expression-blend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto-incement assembly build version in Visual Studio 2008</title>
		<link>http://tech.avivo.si/2010/01/auto-incement-assembly-build-version-in-visual-studio-2008/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=auto-incement-assembly-build-version-in-visual-studio-2008</link>
		<comments>http://tech.avivo.si/2010/01/auto-incement-assembly-build-version-in-visual-studio-2008/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 16:12:35 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[auto]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[increment]]></category>
		<category><![CDATA[version]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=288</guid>
		<description><![CDATA[When building a project with Visual Studio an output assembly with embedded version is generated. Version indicates how an application is advancing in development. Developer can change output assembly version for each project by opening project&#8217;s properties (right click, Properties), clicking Assembly Information&#8230; button and editing text in fields (see marked area on the image [...]]]></description>
			<content:encoded><![CDATA[<p>When building a project with Visual Studio an output assembly with embedded version is generated. Version indicates how an application is advancing in development.</p>
<p>Developer can change output assembly version for each project by opening project&#8217;s properties (right click, Properties), clicking <em>Assembly Information&#8230;</em> button and editing text in fields (see marked area on the image below).</p>
<div id="attachment_290" class="wp-caption alignnone" style="width: 675px"><img class="size-full wp-image-290" title="vs2008-cs-assembly-build-version" src="http://tech.avivo.si/wp-content/uploads/2010/01/vs2008-cs-assembly-build-version.jpg" alt="VS2008 window for changing assembly version" width="665" height="519" /><p class="wp-caption-text">VS2008 window for changing assembly version</p></div>
<p>Alternative is to open <em>Properties/AssemblyInfo.cs</em> or <em>.vb</em> and change <em>AssemblyVersion</em> value in a text editor.</p>
<p>Version can be automatically incremented on each build. To enable counter open <em>Properties/AssemblyInfo.cs</em> and set:</p>
<pre class="c-sharp">//Change AssemblyVersion's value from 1.0.0.0 to 1.0.* and comment AssemblyFileVersion
[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]</pre>
<p>Auto-increment symbol (&#8216;*&#8217;) cannot be set in GUI (like screenshot above) but only in code.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/01/auto-incement-assembly-build-version-in-visual-studio-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create sceenshot for part of the screen &#8211; quickly</title>
		<link>http://tech.avivo.si/2009/12/create-sceenshot-for-part-of-the-screen-quickly/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-sceenshot-for-part-of-the-screen-quickly</link>
		<comments>http://tech.avivo.si/2009/12/create-sceenshot-for-part-of-the-screen-quickly/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 08:43:52 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=219</guid>
		<description><![CDATA[If you have Microsoft Office 2007 installed and Microsoft Office OneNote 2007 and if he is active in your SystemTray then just click on Windows key + S and select desirable area of your screen. You can set options of this program by right clicking on it and choose to save it only in clipboard.]]></description>
			<content:encoded><![CDATA[<p>If you have Microsoft Office 2007 installed and Microsoft Office OneNote 2007 and if he is active in your SystemTray then just click on Windows key + S and select desirable area of your screen.</p>
<p>You can set options of this program by right clicking on it and choose to save it only in clipboard.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/12/create-sceenshot-for-part-of-the-screen-quickly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# sizeof &#8211; Gets a size of a custom class programatically</title>
		<link>http://tech.avivo.si/2009/10/c-sizeof-gets-a-size-of-a-custom-class-programatically/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=c-sizeof-gets-a-size-of-a-custom-class-programatically</link>
		<comments>http://tech.avivo.si/2009/10/c-sizeof-gets-a-size-of-a-custom-class-programatically/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 13:06:08 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[calculate]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[size]]></category>
		<category><![CDATA[sizeof]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=171</guid>
		<description><![CDATA[In .NET, sizeof() works only for basic variable types, like int, double, etc. If you try to use sizeof() for a managed class then compiler reports error: Cannot take the address of, get the size of, or declare a pointer to a managed type Alternative to sizeof() would be System.Runtime.InteropServices.Marshal.SizeOf() but this one works with [...]]]></description>
			<content:encoded><![CDATA[<p>In .NET, <strong>sizeof</strong>() works only for basic variable types, like <em>int, double</em>, etc. If you try to use <em>sizeof()</em> for a <em>managed class</em> then compiler reports error:</p>
<p><em>Cannot take the address of, get the size of, or declare a pointer to a managed type</em></p>
<p>Alternative to <em>sizeof()</em> would be <em>System.Runtime.InteropServices.Marshal.SizeOf()</em> but this one works with unmanaged types (not a native .NET class).</p>
<p>So far, a decent solution would be to serialize object into binary stream and get the stream size. Source code:</p>
<blockquote><p>public static long SizeOf(object obj)<br />
{<br />
long size = 0;</p>
<p>try<br />
{<br />
System.IO.MemoryStream stream = new System.IO.MemoryStream();<br />
BinaryFormatter objFormatter = new BinaryFormatter();<br />
objFormatter.Serialize(stream, obj);<br />
size = stream.Length;<br />
}<br />
catch (Exception ex)<br />
{<br />
}</p>
<p>return size;<br />
}</p></blockquote>
<p>A non-programatic alternative is to use .NET profiler to retrieve object size.</p>
<p>Reference: http://social.msdn.microsoft.com/forums/en-US/clr/thread/b871dee4-6eb5-4dca-be79-b9589a79f5e9/</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/10/c-sizeof-gets-a-size-of-a-custom-class-programatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight 2.0 &#8211; Invoke method with Reflection</title>
		<link>http://tech.avivo.si/2009/07/silverlight-20-invoke-method-with-reflection/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-20-invoke-method-with-reflection</link>
		<comments>http://tech.avivo.si/2009/07/silverlight-20-invoke-method-with-reflection/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 13:45:39 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[invoke]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[reflection]]></category>
		<category><![CDATA[run-time]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[wcf]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=123</guid>
		<description><![CDATA[When deciding whether to create a rich graphical web application with lots of animations either with Silverlight or ASP .NET, Silverlight definitely wins. But when deciding whether put a database in first place then server side scripts (i.e. ASP .NET) have the advantage. Anyway, if you are accessing database from Silverlight you&#8217;ve probably came across [...]]]></description>
			<content:encoded><![CDATA[<p>When deciding whether to create a rich graphical web application with lots of animations either with Silverlight or ASP .NET, Silverlight definitely wins. But when deciding whether put a database in first place then server side scripts (i.e. ASP .NET) have the advantage.</p>
<p>Anyway, if you are <strong>accessing database from Silverlight</strong> you&#8217;ve probably came across WCF or other  web services. Let&#8217;s say you have <strong>100 tables</strong> and want to use <strong>WCF</strong>. Each table has <strong>Select</strong>, <strong>Insert</strong>, <strong>Update </strong>and <strong>Delete </strong>methods generated like <strong>InsertUser(User item)</strong>. Visual Studio 2008 can automatically generated WCF proxy classes in Silverlight which are asynchronous. Suddenly, handling application logic and database becomes complex for development.</p>
<p>Those methods have <strong>similarities </strong>- Select, Insert, Update and Delete are repeated but for <strong>different table names</strong>. Idea is to use <strong>System.Reflection</strong> to simply and minimize development time. What the Reflection classes do is they use run time variables (i.e. string, int, etc.) to dynamically invoke methods according to situation in run time (cannot be determined in design time while developing).</p>
<p>Let&#8217;s say you have a method <strong>InsertCustomer(Customer item) in WCF</strong> and Visual Studio generates <strong>InsertCustomerAsync(Customer item) for Silverlight</strong>. Application can generate &#8220;InsertCustomerAsync&#8221; as string on demand. Then a method invoke by string is needed:</p>
<blockquote><p>using System.Reflection;</p>
<p>&#8230;</p>
<p>//MyWebService is WCF proxy class and Customer is data entity</p>
<p>MethodInfo methodInfo = typeof(MyWebService).GetMethod(&#8220;InsertCustomerAsync&#8221;, new Type[] { typeof(Customer) });</p>
<p>methodInfo.Invoke(con, BindingFlags.Public | BindingFlags.Instance, null, new object[] { this.item, }, null);</p></blockquote>
<p>Then a &#8220;completed&#8221; event needs to be caught:</p>
<blockquote><p>MethodInfo handlerInfo = typeof(ReflectionDemo&lt;T&gt;).GetMethod(&#8220;SaveHandler&#8221;, BindingFlags.NonPublic | BindingFlags.Instance);<br />
EventInfo eventInfo = typeof(MyWebService).GetEvent(eventName);<br />
eventInfo.AddEventHandler(con, Delegate.CreateDelegate(eventInfo.EventHandlerType, this, handlerInfo));</p></blockquote>
<p>Putting all code together:</p>
<blockquote><p>public class ReflectionDemo&lt;T&gt; where T : new()<br />
{<br />
private T item;</p>
<p>public bool IsUpdate<br />
{<br />
get;<br />
set;<br />
}</p>
<p>public void Save()<br />
{<br />
try<br />
{<br />
if (this.item != null)<br />
{<br />
//Get names<br />
string methodName = (this.IsUpdate ? &#8220;Update&#8221; : &#8220;Insert&#8221;) + typeof(T).Name + &#8220;Async&#8221;; //e.g. UpdateCustomerAsync<br />
string eventName = (this.IsUpdate ? &#8220;Update&#8221; : &#8220;Insert&#8221;) + typeof(T).Name + &#8220;Completed&#8221;; //e.g. UpdateCustomerCompleted<br />
string eventArgsName = (this.IsUpdate ? &#8220;Update&#8221; : &#8220;Insert&#8221;) + typeof(T).Name + &#8220;CompletedEventArgs&#8221;; //e.g. UpdateCustomerCompletedEventArgs</p>
<p>//Create a connection<br />
MyWebService con = new MyWebService();</p>
<p>//Attach an event handler in run time retrieved event (e.g. something like &#8220;con.UpdateCustomerCompleted += &#8230;&#8221; at design time)<br />
MethodInfo handlerInfo = typeof(ReflectionDemo&lt;T&gt;).GetMethod(&#8220;SaveHandler&#8221;, BindingFlags.NonPublic | BindingFlags.Instance);<br />
EventInfo eventInfo = typeof(MyWebService).GetEvent(eventName);<br />
eventInfo.AddEventHandler(con, Delegate.CreateDelegate(eventInfo.EventHandlerType, this, handlerInfo));</p>
<p>//Invoke method in run time (e.g. something like &#8220;con.UpdateCustomerAsync(this.item);&#8221; at design time)<br />
MethodInfo methodInfo = typeof(MyWebService).GetMethod(methodName, new Type[] { typeof(T) }); //From overloaded methods get the one with single parameter<br />
methodInfo.Invoke(con, BindingFlags.Public | BindingFlags.Instance, null, new object[] { this.item, }, null); //Invoke the method immediately<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
//Exception may be thrown in various situations (e.g. method cannot be found)<br />
//Insert breakpoint here while debugging<br />
}<br />
}</p>
<p>protected void SaveHandler(object sender, EventArgs args)<br />
{</p>
<p>//Handle event logic here<br />
//Sample how to cast to a derived EventArgs with known properties:</p>
<p>Type type = args.GetType();<br />
Exception ex = type.GetProperty(&#8220;Error&#8221;).GetValue(args, null) as Exception ?? null;<br />
Customer item = (Customer)type.GetProperty(&#8220;Customer&#8221;).GetValue(args, null);<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/07/silverlight-20-invoke-method-with-reflection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Number list generator</title>
		<link>http://tech.avivo.si/2009/04/number-list-generator/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=number-list-generator</link>
		<comments>http://tech.avivo.si/2009/04/number-list-generator/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 08:53:56 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[listing]]></category>
		<category><![CDATA[number generator]]></category>
		<category><![CDATA[number list generator]]></category>
		<category><![CDATA[order number]]></category>
		<category><![CDATA[sequence]]></category>
		<category><![CDATA[sequence generator]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=54</guid>
		<description><![CDATA[For example you want to produce a text file with all the integers in order from 1 to 2000, and have the file named &#8220;List2000.txt&#8221; your command line would look like this: Start DOS prompt. Type: C:\&#62;for /L %i in (1,1,2000) do @echo %i &#62;&#62;List2000.txt The three integers (no fractions!) within the parentheses are start, [...]]]></description>
			<content:encoded><![CDATA[<p>For example you want to produce a text file with all the integers in order from 1 to 2000, and have the file named &#8220;List2000.txt&#8221; your command line would look like this:</p>
<ul>
<li>Start DOS prompt.</li>
<li> Type:<br />
<strong>C:\&gt;for /L %i in (1,1,2000) do @echo %i &gt;&gt;List2000.txt</strong></li>
<li>The three integers (no fractions!) within the parentheses are start, step, and end numbers. Here we start with 1, go by steps of 1, till we hit 2000, and write the file.</li>
<li>Hit &lt;ENTER&gt;. The computer chugs for a few seconds, and generates the file.</li>
<li>To go backwards from 100 to 0 by step 2, the command line would read:<strong><br />
C:\&gt;for /L %i in (100,-2,0) do @echo %i &gt;&gt;List-100a.txt</strong></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/04/number-list-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

