<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><!-- generator="wordpress/2.3.3" --><rss 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/" version="2.0">

<channel>
	<title>Versia.com</title>
	<link>http://versia.com</link>
	<description>(version)controlling thoughts</description>
	<pubDate>Thu, 07 Aug 2008 12:44:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/versia" type="application/rss+xml" /><item>
		<title>Vertical panel in GNOME</title>
		<link>http://versia.com/2008/06/08/vertical-panel-in-gnome/</link>
		<comments>http://versia.com/2008/06/08/vertical-panel-in-gnome/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 12:20:42 +0000</pubDate>
		<dc:creator>Alexander Kojevnikov</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://versia.com/2008/06/08/vertical-panel-in-gnome/</guid>
		<description><![CDATA[I&#8217;ve been playing with various desktop GNU/Linux distributions last couple of months. I&#8217;m not exactly a newbie to Linux, I have been administering a VPS box for my hobby project for several years now, but I never managed to play with it on a desktop.
So I did. And I must say I&#8217;m very impressed. Last [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing with various desktop <a href="http://www.gnu.org/">GNU/Linux</a> distributions last couple of months. I&#8217;m not exactly a newbie to Linux, I have been administering a VPS box for my <a href="http://metaltabs.com">hobby project</a> for several years now, but I never managed to play with it on a desktop.</p>
<p>So I did. And I must say I&#8217;m very impressed. Last time I checked (<a href="http://www.freebsd.org/">FreeBSD</a> 4 back in 2000), FLOSS desktop was mostly a geek toy, these days it <em>is</em> ready for the average user.</p>
<p>I will spare the overview of the <a href="http://www.ubuntu.com/">distros</a> <a href="http://www.opensuse.org/">that</a> <a href="http://fedoraproject.org/">I</a> <a href="http://www.mandriva.com/">tried</a>, as well as my take on the <a href="http://www.kde.org/">KDE</a> vs. <a href="http://www.gnome.org/">GNOME</a> flame war for another post, here I want to talk about one particular annoyance that I <em>really</em> want to see fixed.</p>
<p>You see, these days it&#8217;s hard not to have a wide-screen monitor sitting on your desktop. They are great for watching films and playing games but this comes at a cost &#8212; you end up with fewer vertical pixels. </p>
<p>Vertical space is much more important for most other tasks I do on the computer, be it browsing the web, coding or writing blog posts. And the only way to maximise it is to move the everlasting task bar sitting on the bottom of most operating systems to the left or right of the screen.</p>
<p><a href='http://versia.com/wp-content/uploads/2008/06/vista.png' title='Vertical layout in Vista'><img src='http://versia.com/wp-content/uploads/2008/06/vista.thumbnail.png' alt='Vertical layout in Vista' align='right' style='margin-left: 10px' /></a><a href='http://versia.com/wp-content/uploads/2008/06/kde.png' title='Vertical layout in KDE'><img src='http://versia.com/wp-content/uploads/2008/06/kde.thumbnail.png' alt='Vertical layout in KDE' align='right' style='margin-left: 10px' /></a>This is how it looks like in Vista and KDE. I know it takes some getting used to, but it&#8217;s worth a few days of slight disorientation. And I&#8217;m not <a href="http://greasypc.blogspot.com/2008/05/vertical-taskbar-for-more-efficient.html">the</a> <a href="http://www.ghacks.net/2008/04/10/why-my-taskbar-is-on-the-right-side-of-the-screen/">only</a> <a href="http://lifehacker.com/software/windows/geek-to-live--top-windows-tweaks-158144.php">one</a> who thinks so.</p>
<p>The vertical layout works great in XP, Vista and KDE, but not in GNOME. I want to list here all open issues along with the links to the GNOME <a href="http://bugzilla.gnome.org/">bug database</a>. I guess we have all these issues because not many GNOME developers are using the vertical layout, or even aware of the benefits it can give them. I hope this post will help it, even if only a little bit.</p>
<p><a href='http://versia.com/wp-content/uploads/2008/06/gnome.png' title='Vertical layout in GNOME'><img src='http://versia.com/wp-content/uploads/2008/06/gnome.thumbnail.png' alt='Vertical layout in GNOME' align='right' style='margin-left: 10px' /></a><strong>Window List</strong>: The list of open windows is arguably the most important piece of information sitting on the panel. And the most terribly behaving in vertical layout. </p>
<p>First of all, the height of the window list applet is fixed, meaning the list doesn&#8217;t occupy all available vertical space.</p>
<p>Second, the height of the buttons that represent the open windows, stretches to fill the entire applet. The buttons should have a fixed height that depends on the font used in the buttons.</p>
<p>Third, after you open a few windows, the list splits to two columns and becomes irresponsible to mouse clicks. This is the most annoying bug of the three.</p>
<p>These issues are documented in <a href="http://bugzilla.gnome.org/show_bug.cgi?id=86382">bug 86382</a> that was open back in 2002! The bug has a patch, but it looks like it&#8217;s not perfect either.</p>
<p><strong>Notificatioin Area</strong>: In vertical layout the notification area wastes a lot of space by placing one icon in a row. It also uses different sizes for different icons, some are really huge, e.g. 128&#215;128. It should instead use a flow layout for icons and use the same size for all of them. This is described in <a href="http://bugzilla.gnome.org/show_bug.cgi?id=531371">bug 531371</a>.</p>
<p><strong>Quick Launch</strong>: The quick-lounge applet had a bug that made it nearly impossible to use on a vertical panel (see <a href="http://bugzilla.gnome.org/show_bug.cgi?id=531358">bug 531358</a>). It&#8217;s fixed now in the trunk, hopefully it will be integrated into the next GNOME release.</p>
<p>There are other related annoyances (see <a href="http://bugzilla.gnome.org/show_bug.cgi?id=428943">bug 428943</a> and Ubuntu idea <a href="http://brainstorm.ubuntu.com/idea/1906/">#1906</a>) but I can live with them if the above issues are resolved.</p>
]]></content:encoded>
			<wfw:commentRss>http://versia.com/2008/06/08/vertical-panel-in-gnome/feed/</wfw:commentRss>
		</item>
		<item>
		<title>My Visual Studio Colour Scheme</title>
		<link>http://versia.com/2008/02/08/my-visual-studio-colour-scheme/</link>
		<comments>http://versia.com/2008/02/08/my-visual-studio-colour-scheme/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 06:55:59 +0000</pubDate>
		<dc:creator>Alexander Kojevnikov</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://versia.com/2008/02/08/my-visual-studio-colour-scheme/</guid>
		<description><![CDATA[In his recent post Scott is listing various Visual Studio themes. He also mentions a positive impact of good colour schemes on productivity.
I can certainly confirm this. I switched to a custom theme several month ago and I&#8217;m never going back. 
 
Unfortunately I can&#8217;t remember which scheme I used as a base, but it [...]]]></description>
			<content:encoded><![CDATA[<p>In his recent post <a href="http://www.hanselman.com/blog/VisualStudioProgrammerThemesGallery.aspx">Scott is listing</a> various Visual Studio themes. He also mentions a positive impact of good colour schemes on productivity.</p>
<p>I can certainly confirm this. I switched to a custom theme several month ago and I&#8217;m never going back. </p>
<p><a href="http://versia.com/wp-content/uploads/2008/02/visual-studio-colour-scheme.png"><img height="139" alt="Visual Studio Colour Scheme" src="http://versia.com/wp-content/uploads/2008/02/visual-studio-colour-scheme-thumb.png" width="244" border="0" /></a> </p>
<p>Unfortunately I can&#8217;t remember which scheme I used as a base, but it must have been an offspring of <a href="http://alternateidea.com/blog/articles/2006/01/03/textmate-vibrant-ink-theme-and-prototype-bundle">Vibrant Ink</a>. The code sample is by <a href="http://www.codinghorror.com/blog/archives/000682.html">Jeff Atwood</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://versia.com/2008/02/08/my-visual-studio-colour-scheme/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SQL Server: Full-Text Searching Across Multiple Tables</title>
		<link>http://versia.com/2008/02/06/sql-server-full-text-searching-across-multiple-tables/</link>
		<comments>http://versia.com/2008/02/06/sql-server-full-text-searching-across-multiple-tables/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 11:29:02 +0000</pubDate>
		<dc:creator>Alexander Kojevnikov</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://versia.com/2008/02/06/sql-server-full-text-searching-across-multiple-tables/</guid>
		<description><![CDATA[Sometimes a full-text search needs to be performed on multiple tables. For example, if we have two tables, Post and Comment, we may want to search for posts that have keywords both in the post text and in the comments.
SQL Server doesn&#8217;t allow to include multiple tables in the CONTAINS and FREETEXT predicates. We can [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes a full-text search needs to be performed on multiple tables. For example, if we have two tables, Post and Comment, we may want to search for posts that have keywords both in the post text and in the comments.</p>
<p>SQL Server doesn&#8217;t allow to include multiple tables in the CONTAINS and FREETEXT predicates. We can of course use several predicates in our SQL query, but this can get pretty complex if we need to search in many columns.</p>
<p>Luckily there&#8217;s a workaround. Starting from version 2005, SQL Server allows to add FTS indices to <a href="http://msdn2.microsoft.com/en-us/library/ms187317.aspx">views</a>. Knowing this, we can create a view that combines text columns from both tables and then search on it.</p>
<p>There are a few caveats:</p>
<ol>
<li>The view must be created with the SCHEMABINDING option. </li>
<li>Tables in the view must be referenced by their schema name, e.g. dbo.Post </li>
<li>Before adding an FTS index, the view must have a unique clustered index. This itself limits the kinds of views that can be <a href="http://msdn2.microsoft.com/en-us/library/aa933148(SQL.80).aspx">indexed</a>. Among other things, the SELECT statement of the view cannot contain: UNION operator, sub-queries, derived tables, OUTER JOINs, some aggregate functions, rowset functions, etc. </li>
<li>The FTS index cannot be added on text, ntext, image and xml columns. Thankfully, it can still be added on varchar(max), nvarchar(max) and varbinary(max) columns, introduced in version 2005. </li>
</ol>
<p>Here is how our fictitious example can be implemented.</p>
<p>The tables:</p>
<pre class="csharpcode"><span class="kwrd">CREATE</span> <span class="kwrd">TABLE</span> Post
(
    ID <span class="kwrd">int</span> <span class="kwrd">NOT</span> <span class="kwrd">NULL</span> <span class="kwrd">IDENTITY</span>(1,1) <span class="kwrd">PRIMARY</span> <span class="kwrd">KEY</span>,
    Text nvarchar(<span class="kwrd">max</span>) <span class="kwrd">NOT</span> <span class="kwrd">NULL</span>
)
<span class="kwrd">CREATE</span> <span class="kwrd">TABLE</span> Comment
(
    ID <span class="kwrd">int</span> <span class="kwrd">NOT</span> <span class="kwrd">NULL</span> <span class="kwrd">IDENTITY</span>(1,1) <span class="kwrd">PRIMARY</span> <span class="kwrd">KEY</span>,
    PostID <span class="kwrd">int</span> <span class="kwrd">NOT</span> <span class="kwrd">NULL</span> <span class="kwrd">FOREIGN</span> <span class="kwrd">KEY</span> <span class="kwrd">REFERENCES</span> Post(ID),
    Text nvarchar(<span class="kwrd">max</span>) <span class="kwrd">NOT</span> <span class="kwrd">NULL</span>
)</pre>
<p>The view and its unique index:</p>
<pre class="csharpcode"><span class="kwrd">CREATE</span> <span class="kwrd">VIEW</span> ViewSearch <span class="kwrd">WITH</span> SCHEMABINDING <span class="kwrd">AS</span>
<span class="kwrd">SELECT</span> c.ID, p.Text <span class="kwrd">AS</span> PostText, c.Text <span class="kwrd">AS</span> CommentText
<span class="kwrd">FROM</span> dbo.Comment <span class="kwrd">AS</span> c
<span class="kwrd">JOIN</span> dbo.Post <span class="kwrd">AS</span> p <span class="kwrd">ON</span> p.ID=c.PostID
<span class="kwrd">GO</span>
<span class="kwrd">CREATE</span> <span class="kwrd">UNIQUE</span> <span class="kwrd">CLUSTERED</span> <span class="kwrd">INDEX</span> IX_ViewSearch <span class="kwrd">ON</span> ViewSearch (ID)</pre>
<p>After the full-text catalog is created and the index is added on the view, we can use this query:</p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode"><span class="kwrd">SELECT</span> <span class="kwrd">DISTINCT</span> p.ID
<span class="kwrd">FROM</span> Post <span class="kwrd">AS</span> p
<span class="kwrd">JOIN</span> Comment <span class="kwrd">AS</span> c <span class="kwrd">ON</span> c.PostID=p.ID
<span class="kwrd">JOIN</span> ViewSearch <span class="kwrd">AS</span> s <span class="kwrd">ON</span> s.ID=c.ID
<span class="kwrd">WHERE</span> <span class="kwrd">CONTAINS</span>(s.*, <span class="str">&#8216;foo&#8217;</span>) <span class="kwrd">AND</span> <span class="kwrd">CONTAINS</span>(s.*, <span class="str">&#8216;bar&#8217;</span>)</pre>
<p>Unfortunately a single CONTAINS(s.*, &#8216;&quot;foo&quot; AND &quot;bar&quot;&#8217;) won&#8217;t work, SQL Server <a href="http://technet.microsoft.com/en-us/library/ms345119.aspx">always</a> uses OR when CONTAINS is applied to multiple columns.</p>
<p>If you have a keen eye you may have noticed a problem in the solution above. It doesn&#8217;t work for posts that have no comments at all. Ideally we would need to use a LEFT JOIN in our FTS view, but the SQL Server wouldn&#8217;t let us to create a unique index on it.</p>
<p>A possible workaround is to add a full-text index on Post.Text and to rewrite the query like this:</p>
<pre class="csharpcode"><span class="kwrd">SELECT</span> p.ID
<span class="kwrd">FROM</span> Post <span class="kwrd">AS</span> p
<span class="kwrd">JOIN</span> Comment <span class="kwrd">AS</span> c <span class="kwrd">ON</span> c.PostID=p.ID
<span class="kwrd">JOIN</span> ViewSearch <span class="kwrd">AS</span> s <span class="kwrd">ON</span> s.ID=c.ID
<span class="kwrd">WHERE</span> <span class="kwrd">CONTAINS</span>(s.*, <span class="str">&#8216;foo&#8217;</span>) <span class="kwrd">AND</span> <span class="kwrd">CONTAINS</span>(s.*, <span class="str">&#8216;bar&#8217;</span>)
<span class="kwrd">UNION</span>
<span class="kwrd">SELECT</span> p.ID
<span class="kwrd">FROM</span> Post <span class="kwrd">AS</span> p
<span class="kwrd">WHERE</span> <span class="kwrd">CONTAINS</span>(p.Text, <span class="str">&#8216;&quot;foo&quot; AND &quot;bar&quot;&#8217;</span>)</pre>
]]></content:encoded>
			<wfw:commentRss>http://versia.com/2008/02/06/sql-server-full-text-searching-across-multiple-tables/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Editing icons of WinForms controls.</title>
		<link>http://versia.com/2008/02/01/editing-icons-of-winforms-controls/</link>
		<comments>http://versia.com/2008/02/01/editing-icons-of-winforms-controls/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 07:51:02 +0000</pubDate>
		<dc:creator>Alexander Kojevnikov</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://versia.com/2008/02/06/editing-icons-of-winforms-controls/</guid>
		<description><![CDATA[I love icons! I use them all the time in my WinForms applications - anywhere from buttons and tab pages to tool strip items. Icons look nice (at least they should be), but editing them is not.
In WinForms you need to edit the original image and change the corresponding .Image or .Icon properties everywhere that [...]]]></description>
			<content:encoded><![CDATA[<p>I love icons! I use them all the time in my WinForms applications - anywhere from buttons and tab pages to tool strip items. Icons look nice (at least they should be), but editing them is not.</p>
<p>In WinForms you need to edit the original image and change the corresponding .Image or .Icon properties everywhere that image is used. Some controls, such as the TabPage, can only refer to an ImageList, so you would need to amend it and be extra careful not to screw up the image indices.</p>
<p><a href="http://versia.com/wp-content/uploads/2008/02/imageresource.png"><img height="119" alt="ImageResource" src="http://versia.com/wp-content/uploads/2008/02/imageresource-thumb.png" width="244" align="right" border="0" /></a>I wrote a small component to ease the process (of editing, not screwing up, mind you). When ImageResource is dropped into a form it adds a new string property to Forms, Buttons, TabPages and ToolStripItems. You just need to enter the resource name of the icon and the rest is done automatically.</p>
<p>Here&#8217;s the code:</p>
<div style="auto">
<pre class="csharpcode"><span class="kwrd">using</span> System;
<span class="kwrd">using</span> System.ComponentModel;
<span class="kwrd">using</span> System.Reflection;
<span class="kwrd">using</span> System.Collections.Generic;
<span class="kwrd">using</span> System.Drawing;
<span class="kwrd">using</span> System.Windows.Forms;
<span class="kwrd">using</span> System.IO;

<span class="kwrd">namespace</span> Versia.Samples
{
    [ProvideProperty(<span class="str">&quot;ImageResource&quot;</span>, <span class="kwrd">typeof</span>(<span class="kwrd">object</span>))]
    <span class="kwrd">public</span> <span class="kwrd">partial</span> <span class="kwrd">class</span> ImageResource : Component, IExtenderProvider
    {
        <span class="kwrd">private</span> <span class="kwrd">readonly</span> Dictionary&lt;<span class="kwrd">object</span>, <span class="kwrd">string</span>&gt; _values = <span class="kwrd">new</span> Dictionary&lt;<span class="kwrd">object</span>, <span class="kwrd">string</span>&gt;();
        <span class="kwrd">private</span> <span class="kwrd">readonly</span> Dictionary&lt;<span class="kwrd">string</span>, Icon&gt; _icons = <span class="kwrd">new</span> Dictionary&lt;<span class="kwrd">string</span>, Icon&gt;();

        <span class="kwrd">public</span> ImageResource()
        {
            InitializeComponent();
        }

        <span class="kwrd">public</span> ImageResource(IContainer container)
        {
            container.Add(<span class="kwrd">this</span>);

            InitializeComponent();
        }

        <span class="kwrd">public</span> <span class="kwrd">bool</span> CanExtend(<span class="kwrd">object</span> target)
        {
            <span class="kwrd">return</span> target <span class="kwrd">is</span> ButtonBase || target <span class="kwrd">is</span> TabPage || target <span class="kwrd">is</span> Form || target <span class="kwrd">is</span> ToolStripItem;
        }

        [Category(<span class="str">&quot;Appearance&quot;</span>)]
        [Description(<span class="str">&quot;Sets the resource name of the image to add to the control.&quot;</span>)]
        [DefaultValue(<span class="str">&quot;&quot;</span>)]
        <span class="kwrd">public</span> <span class="kwrd">string</span> GetImageResource(<span class="kwrd">object</span> target)
        {
            <span class="kwrd">string</span> <span class="kwrd">value</span>;
            <span class="kwrd">if</span>(_values.TryGetValue(target, <span class="kwrd">out</span> <span class="kwrd">value</span>))
            {
                <span class="kwrd">return</span> <span class="kwrd">value</span>;
            }
            <span class="kwrd">return</span> String.Empty;
        }

        <span class="kwrd">public</span> <span class="kwrd">void</span> SetImageResource(<span class="kwrd">object</span> target, <span class="kwrd">string</span> name)
        {
            _values[target] = name;

            <span class="kwrd">if</span>(!_imageList.Images.ContainsKey(name))
            {
                <span class="rem">// Get the assembly from the resource name.</span>
                Stream stream = <span class="kwrd">null</span>;
                <span class="kwrd">foreach</span>(Assembly assembly <span class="kwrd">in</span> AppDomain.CurrentDomain.GetAssemblies())
                {
                    <span class="kwrd">try</span>
                    {
                        stream = assembly.GetManifestResourceStream(name);
                    }
                    <span class="kwrd">catch</span>(NotSupportedException)
                    {
                    }
                    <span class="kwrd">catch</span>(FileNotFoundException)
                    {
                    }

                    <span class="kwrd">if</span>(stream != <span class="kwrd">null</span>) <span class="kwrd">break</span>;
                }

                <span class="kwrd">if</span>(stream == <span class="kwrd">null</span>) <span class="kwrd">return</span>;

                <span class="rem">// Read the image from the resource.</span>
                <span class="kwrd">if</span>(name.EndsWith(<span class="str">&quot;.ico&quot;</span>, StringComparison.CurrentCultureIgnoreCase))
                {
                    Icon icon = <span class="kwrd">new</span> Icon(stream);
                    _icons[name] = icon;
                    _imageList.Images.Add(name, icon);
                }
                <span class="kwrd">else</span>
                {
                    _imageList.Images.Add(name, Image.FromStream(stream));
                }
            }
            <span class="rem">// Add the image to the control.</span>
            <span class="kwrd">if</span>(target <span class="kwrd">is</span> ButtonBase)
            {
                ButtonBase button = (ButtonBase)target;
                button.Image = _imageList.Images[name];
            }
            <span class="kwrd">else</span> <span class="kwrd">if</span>(target <span class="kwrd">is</span> TabPage)
            {
                <span class="rem">// ImageList is attached to the TabControl.</span>
                TabPage tabPage = target <span class="kwrd">as</span> TabPage;
                <span class="kwrd">if</span>(tabPage.Parent != <span class="kwrd">null</span>)
                {
                    ((TabControl)tabPage.Parent).ImageList = _imageList;
                    tabPage.ImageKey = name;
                }
                <span class="kwrd">else</span>
                {
                    tabPage.ParentChanged += <span class="kwrd">delegate</span>(<span class="kwrd">object</span> sender, EventArgs e)
                    {
                        TabPage page = (TabPage)sender;
                        <span class="kwrd">if</span>(page.Parent <span class="kwrd">is</span> TabControl)
                        {
                            ((TabControl)page.Parent).ImageList = _imageList;
                            page.ImageKey = name;
                        }
                    };
                }
            }
            <span class="kwrd">else</span> <span class="kwrd">if</span>(target <span class="kwrd">is</span> Form)
            {
                Form form = (Form)target;
                <span class="kwrd">if</span>(_icons.ContainsKey(name)) form.Icon = _icons[name];
            }
            <span class="kwrd">else</span> <span class="kwrd">if</span>(target <span class="kwrd">is</span> ToolStripItem)
            {
                ToolStripItem item = (ToolStripItem)target;
                item.Image = _imageList.Images[name];
            }
        }
    }
}</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://versia.com/2008/02/01/editing-icons-of-winforms-controls/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
