<?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>WinSoft.se &#187; Visual Studio 10</title>
	<atom:link href="http://www.winsoft.se/category/dotnet/visualstudio10/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.winsoft.se</link>
	<description>Development with focus on Visual Basic .NET</description>
	<lastBuildDate>Thu, 26 Jan 2012 19:28:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Visual Basic: The coolest code editor you ever saw</title>
		<link>http://www.winsoft.se/2011/03/visual-basic-the-coolest-code-editor-you-ever-saw/</link>
		<comments>http://www.winsoft.se/2011/03/visual-basic-the-coolest-code-editor-you-ever-saw/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 20:20:49 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Studio 10]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1606</guid>
		<description><![CDATA[Let&#8217;s say that you&#8217;re typing a word. As you type&#8230; &#8230;the IntelliSense filters out the word you are typing. If you type something that isn&#8217;t in the list, the list is closing. If you decide that the last character you typed is wrong, use backspace to delete it. Instantly, the IntelliSense is displayed again, with [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say that you&#8217;re typing a word.</p>
<p><img alt="" src="http://imghost.winsoft.se/upload/8401613009114001.jpg" class="aligncenter" width="165" height="189" /></p>
<p>As you type&#8230;</p>
<p><img alt="" src="http://imghost.winsoft.se/upload/9793313009114062.jpg" class="aligncenter" width="165" height="96" /></p>
<p>&#8230;the IntelliSense filters out the word you are typing.</p>
<p><img alt="" src="http://imghost.winsoft.se/upload/8476713009114313.jpg" class="aligncenter" width="140" height="77" /></p>
<p>If you type something that isn&#8217;t in the list, the list is closing.</p>
<p><img alt="" src="http://imghost.winsoft.se/upload/1021113009114434.jpg" class="aligncenter" width="35" height="25" /></p>
<p>If you decide that the last character you typed is wrong, use backspace to delete it. Instantly, the IntelliSense is displayed again, with the possible option selected.</p>
<p><img alt="" src="http://imghost.winsoft.se/upload/9192913009114515.jpg" class="aligncenter" width="165" height="191" /></p>
<p>The C# editor has a behavior that is similar to this, but if you go pass an membership access operator, or something like that, the C# IntelliSense is completely lost. You can bring it up again by deleting the line, and start typing again, or by pressing Ctrl+J. The Visual Basic editor picks up automatically, as shown above, whenever you press backspace to delete a word.</p>
<p>Another big advantage in the Visual Basic editor is the enumeration awareness.  The Visual Basic editor recognizes when an enumeration is an available option, and provides possible options from the right location in the framework. The C# editor seems very unaware of enumerations, and you might have to look up enumerations that you are unfamiliar of, in the Object Browser by pressing Ctrl+Alt+J.</p>
<p><img alt="" src="http://imghost.winsoft.se/upload/388581300911394enum.jpg" class="aligncenter" width="377" height="78" /></p>
<p>Demonstrated here:</p>
<p><center><iframe title="YouTube video player" width="425" height="349" src="http://www.youtube.com/embed/RIjZG1vGRFc" frameborder="0" allowfullscreen></iframe></center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2011/03/visual-basic-the-coolest-code-editor-you-ever-saw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Basic: Serious error trapping</title>
		<link>http://www.winsoft.se/2011/03/visual-basic-serious-error-trapping/</link>
		<comments>http://www.winsoft.se/2011/03/visual-basic-serious-error-trapping/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 17:35:27 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Studio 10]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1603</guid>
		<description><![CDATA[The concept of filtering by exception type is familiar to any C# programmer. Visual Basic takes this one step further by also allowing a logical condition that also needs to be true for the block to be executed. If this feature is used, you can have one Try block with multiple Catch section that filters [...]]]></description>
			<content:encoded><![CDATA[<p>The concept of filtering by exception type is familiar to any C# programmer. Visual Basic takes this one step further by also allowing a logical condition that also needs to be true for the block to be executed. If this feature is used, you can have one Try block with multiple Catch section that filters on the same exception class. This is not possible in C# and not allowed in VB without this extra logical condition. The result is better readability and a more logical structure.</p>
<p>Imagine that you want to do an iteration, that fails after three errors. This is the ugly version:</p>
<pre>//Do something 10 times, bail after 3 errors.
for (int x = 0; x &lt; 10; x++)
{
   try
   {
      Console.WriteLine("Try something.");
      //This operation will fail.
      throw new Exception();
   }
   catch (Exception ex)
   {
      Console.WriteLine("Failed.");
      if (x &gt;= 2)
      {
         Console.WriteLine("Too many fails. Bail!");
         Console.ReadLine();
         return;
      }
   }
}</pre>
<p>And this is the Visual Basic version. Note the <strong>When</strong> keyword after the <strong>Catch</strong> keyword:</p>
<pre>'Do something 10 times, bail after 3 errors.
For X As Integer = 0 To 9
   Try
      Console.WriteLine("Try something.")
      'This operation will fail.
      Throw New Exception()
   Catch ex As Exception When X &lt; 3
      Console.WriteLine("Failed!")
   Catch ex As Exception
      Console.WriteLine("Too many fails. Bail!")
      Return
   End Try
Next</pre>
<p>The way it should be.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2011/03/visual-basic-serious-error-trapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Basic: The most excellent code editor</title>
		<link>http://www.winsoft.se/2011/03/visual-basic-the-most-excellent-code-editor/</link>
		<comments>http://www.winsoft.se/2011/03/visual-basic-the-most-excellent-code-editor/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 16:29:49 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Studio 10]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1600</guid>
		<description><![CDATA[I can&#8217;t hide the fact that I have a childish love for Visual Basic. I think this is worth a few blog posts. Than language and the code editor together works so incredible well for me. The language provides code blocks with keywords for opening and closing, so that you can read out what kind [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t hide the fact that I have a childish love for Visual Basic. I think this is worth a few blog posts. Than language and the code editor together works so incredible well for me. The language provides code blocks with keywords for opening and closing, so that you can read out what kind of block is closing. Because of this, the code editor knows about your intentions. Also, the C# editor cannot know if you intend to use curly brackets or not, because they are optional if only one statement will be contained within a block. In C#, to do an iteration with a test in, the iteration and its brackets has to be typed out, and then the test and its brackets has to be typed out.</p>
<p>In Visual Basic, I just write the iteration opening, and when hitting Enter, the editor closes my iteration, does the indentation and places the cursor within, so that I can continue writing my test. Again, I just write the opening part of the test and hit Enter, and the editor closes it, does the indentation and place my cursor within the new block.</p>
<pre>for (int a = 0; a &lt;= 10; a++)
{
   if (true)
   {
      //Alcatraz style
   }
}

For A As Integer = 0 To 10
  If True Then
     'Quick and nice!
  End If
Next</pre>
<p>Also, what <strong>}</strong> actually means, might depend. Yes, it is a closing block, but what block? In Visual Basic, the block closers are nice and readable. <strong>Next</strong> is closing <strong>For</strong>, <strong>End While</strong> is a closing <strong>While</strong>, <strong>End If</strong> is a closing <strong>If</strong>, and so on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2011/03/visual-basic-the-most-excellent-code-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with Silverlight in an existing web application</title>
		<link>http://www.winsoft.se/2010/09/getting-started-with-silverlight-in-an-existing-web-application/</link>
		<comments>http://www.winsoft.se/2010/09/getting-started-with-silverlight-in-an-existing-web-application/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 11:28:48 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Basic 10]]></category>
		<category><![CDATA[Visual Studio 10]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=1393</guid>
		<description><![CDATA[To get things started, I will show how to enhance a web application with a Silverlight object, and how to pass parameters to that object. To be able to follow, make sure that you have the Silverlight runtime installed. Also, you must have an existing ASP.NET Web Application loaded in Visual Studio 2010. If you&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>To get things started, I will show how to enhance a web application with a Silverlight object, and how to pass parameters to that object. To be able to follow, make sure that you have the Silverlight runtime installed. Also, you must have an existing ASP.NET Web Application loaded in Visual Studio 2010. If you&#8217;re using Visual Studio 2008, there is an Silverlight addon available for download from Microsoft.</p>
<p><strong>Adding a Silverlight object and passing data to it</strong><br />
I want to have a Silverlight object on a sub page, so I add a new ASPX page to my web application called sl.aspx. Also, I create a link to sl.aspx from my default page. I want my Silverlight object to accept a QueryString argument, so I pass one in my link:</p>
<pre>&lt;a href="sl.aspx?param=hello"&gt;Click here!&lt;/a&gt;</pre>
<p>1. Add a new Silverlight project to your solution. I use the name MySL for mine. Default, a test page is added. I unchecked the option to make the test page my start page.</p>
<p>2. The test page is a good help to copy the HTML code that is required to show the object from. The two JavaScript blocks goes in the head section and the OBJECT tag goes where you want your Silverlight object. Grab the DIV tag that contains the OBJECT tag and the IFRAME tag.</p>
<p>Now you&#8217;re done with adding the object. If you test your application, and click on your link, your (empty) Silverlight object.</p>
<p>3. I want to show the QueryString parameter in a textbox, so I add one to my Silverlight object (TextBox1). This is the code to grab the QueryString parameter and putting it in the textbox:</p>
<pre>Private Sub MainPage_Loaded(ByVal sender As Object, _
ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
   TextBox1.Text = _
   System.Windows.Browser.HtmlPage.Document.QueryString("param")
End Sub</pre>
<p>The result of course, is the word &#8220;hello&#8221; in the textbox.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/09/getting-started-with-silverlight-in-an-existing-web-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting the meta data for a table from Visual Basic</title>
		<link>http://www.winsoft.se/2010/01/getting-the-meta-data-for-a-table-from-visual-basic/</link>
		<comments>http://www.winsoft.se/2010/01/getting-the-meta-data-for-a-table-from-visual-basic/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 18:48:16 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Studio 10]]></category>
		<category><![CDATA[Data access]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=850</guid>
		<description><![CDATA[The last time I did this, I needed to build a custom Visual Basic entity generator. After two hours of coding, I had a tiny Windows Forms application that took some connection information and a table name, and returned an entity class with some properties and methods, and a collection class. With initialization, database write-back [...]]]></description>
			<content:encoded><![CDATA[<p>The last time I did this, I needed to build a custom Visual Basic entity generator. After two hours of coding, I had a tiny Windows Forms application that took some connection information and a table name, and returned an entity class with some properties and methods, and a collection class. With initialization, database write-back and all.</p>
<p>From the Management Studio, a call to the <strong>sp_help</strong> procedure and pass the name of the table you want to receive meta data about, like this:</p>
<pre>EXEC sp_help 'dbo.spt_values'</pre>
<p>(I still haven&#8217;t created any databases on the computer that I am writing this from, so I am grabbing the meta data from the <strong>spt_values</strong> table in the master database.</p>
<p>The procedure returns a few sets, and the second one contains a list of the table columns.</p>
<p>To call this from Visual Basic, you should know that the procedure is located in the <strong>sys</strong> namespace, and the parameter that it expects is called <strong>@objname</strong>. So, if you are using a dataset, the table with index 1 contains the column information. If you are using a data reader, you can call the <strong>NextResult</strong> function, like so (in a console application):</p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode">Using Cn <span class="kwrd">As</span> <span class="kwrd">New</span> SqlClient.SqlConnection(<span class="str">"Data Source=.;Initial Catalog=master;Integrated Security=True"</span>)
    Cn.Open()
    Using Cmd <span class="kwrd">As</span> <span class="kwrd">New</span> SqlClient.SqlCommand(<span class="str">"[sys].[sp_help]"</span>, Cn)
        Cmd.CommandType = CommandType.StoredProcedure
        Cmd.Parameters.AddWithValue(<span class="str">"@objname"</span>, <span class="str">"dbo.spt_values"</span>)
        <span class="kwrd">Dim</span> R <span class="kwrd">As</span> SqlClient.SqlDataReader = Cmd.ExecuteReader()
        R.NextResult()
        <span class="kwrd">Dim</span> ColumnNameColumn <span class="kwrd">As</span> <span class="kwrd">Integer</span> = R.GetOrdinal(<span class="str">"Column_name"</span>)
        <span class="kwrd">Dim</span> ColumnTypeColumn <span class="kwrd">As</span> <span class="kwrd">Integer</span> = R.GetOrdinal(<span class="str">"Type"</span>)
        <span class="kwrd">Dim</span> ColumnLength <span class="kwrd">As</span> <span class="kwrd">Integer</span> = R.GetOrdinal(<span class="str">"Length"</span>)
        <span class="kwrd">While</span> R.Read()
            Console.WriteLine(R.GetString(ColumnNameColumn))
            Console.WriteLine(R.GetString(ColumnTypeColumn))
            Console.WriteLine(R.GetInt32(ColumnLength).ToString())
        <span class="kwrd">End</span> <span class="kwrd">While</span>
        R.Close()
    <span class="kwrd">End</span> Using
    Cn.Close()
<span class="kwrd">End</span> Using</pre>
<p>If you are using this to create something like a code generator, remember that <strong>Length</strong> column holds the column size in bytes. This means that a nvarchar (Unicode string columns) with the length set to 10, only can hold 5 characters.</p>
<p>The above code targets .NET Framework 3.5, but it would look exactly the same in the version above and below. It is written in Visual Basic 10 (VBx).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/01/getting-the-meta-data-for-a-table-from-visual-basic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hardware accelerated graphics through XNA: Getting started</title>
		<link>http://www.winsoft.se/2010/01/hardware-accelerated-graphics-through-xna-getting-started/</link>
		<comments>http://www.winsoft.se/2010/01/hardware-accelerated-graphics-through-xna-getting-started/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 23:45:26 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Basic 10]]></category>
		<category><![CDATA[Visual Studio 10]]></category>
		<category><![CDATA[Game development]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=832</guid>
		<description><![CDATA[There are some features of the XNA Framework that is unavailable from Visual Basic, but this should not stop you from writing descent games in Visual Basic. On my machine, I have installed XNA Game Studio 3.1 (a game developing environment from Microsoft) and I also have a beta of Visual Studio 2010 that I [...]]]></description>
			<content:encoded><![CDATA[<p>There are some features of the XNA Framework that is unavailable from Visual Basic, but this should not stop you from writing descent games in Visual Basic. On my machine, I have installed <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&#038;FamilyID=80782277-d584-42d2-8024-893fcd9d3e82" target="_blank">XNA Game Studio 3.1</a> (a game developing environment from Microsoft) and I also have a beta of Visual Studio 2010 that I am going to use. This example will just contain the code necessary to get something on the screen, a sprite floating across.</p>
<p>From VS2010, I am using a regular console application and the target platform for the project is .NET Framework 3.5.</p>
<p>Now I must add two references: <strong>Microsoft.Xna.Framework</strong> and <strong>Microsoft.Xna.Framework.Game</strong>. I use version 3.1, the version that got installed when I installed XNA Game Studio 3.1.</p>
<p>The next step is to create the game class. I call my class <strong>TestGame</strong>. <strong>TestGame</strong> should inherit from the <strong>Microsoft.Xna.Framework.Game</strong> class. In here I create a <strong>Main</strong> method to get the program started, and I select that method to be the starting point for the program in the Project Settings window. This is the code so far:</p>
<pre class="csharpcode">
<span class="kwrd">Public</span> <span class="kwrd">Class</span> TestGame
    <span class="kwrd">Inherits</span> Microsoft.Xna.Framework.Game

    <span class="kwrd">Public</span> <span class="kwrd">Shared</span> <span class="kwrd">Sub</span> Main()

    <span class="kwrd">End</span> <span class="kwrd">Sub</span>

<span class="kwrd">End</span> Class</pre>
<p>In the <strong>Main</strong> method, I create my game (the <strong>TestGame</strong> class) and from the constructor, a graphics device manager for the game. I use the graphics device manager to set my preferred resolution (800&#215;600) and to switch to fullscreen mode. Note that I want to keep the reference to the graphics device manager as a member of my game class.</p>
<pre class="csharpcode">
<span class="kwrd">Public</span> <span class="kwrd">Class</span> TestGame
    <span class="kwrd">Inherits</span> Microsoft.Xna.Framework.Game

    <span class="kwrd">Private</span> Gfx <span class="kwrd">As</span> Microsoft.Xna.Framework.GraphicsDeviceManager

    <span class="kwrd">Public</span> <span class="kwrd">Shared</span> <span class="kwrd">Sub</span> Main()
        <span class="kwrd">Dim</span> Game <span class="kwrd">As</span> <span class="kwrd">New</span> TestGame()
        Game.Run()
    <span class="kwrd">End</span> <span class="kwrd">Sub</span>

    <span class="kwrd">Public</span> <span class="kwrd">Sub</span> <span class="kwrd">New</span>()
        <span class="kwrd">Me</span>.Gfx = <span class="kwrd">New</span> Microsoft.Xna.Framework.GraphicsDeviceManager(<span class="kwrd">Me</span>)
        <span class="kwrd">Me</span>.Gfx.PreferredBackBufferWidth = 800
        <span class="kwrd">Me</span>.Gfx.PreferredBackBufferHeight = 600
        <span class="kwrd">If</span> <span class="kwrd">Not</span> <span class="kwrd">Me</span>.Gfx.IsFullScreen <span class="kwrd">Then</span>
            <span class="kwrd">Me</span>.Gfx.ToggleFullScreen()
        <span class="kwrd">End</span> <span class="kwrd">If</span>
    <span class="kwrd">End</span> <span class="kwrd">Sub</span>

<span class="kwrd">End</span> Class</pre>
<p>The next thing to do is some overrides from the base class. These methods will be overloaded:</p>
<pre class="csharpcode">
<span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Initialize()
    <span class="kwrd">MyBase</span>.Initialize()
<span class="kwrd">End</span> <span class="kwrd">Sub</span>

<span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> LoadContent()
    <span class="kwrd">MyBase</span>.LoadContent()
<span class="kwrd">End</span> <span class="kwrd">Sub</span>

<span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> UnloadContent()
    <span class="kwrd">MyBase</span>.UnloadContent()
<span class="kwrd">End</span> <span class="kwrd">Sub</span>

<span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Update(<span class="kwrd">ByVal</span> gameTime <span class="kwrd">As</span> Microsoft.Xna.Framework.GameTime)
    <span class="kwrd">MyBase</span>.Update(gameTime)
<span class="kwrd">End</span> <span class="kwrd">Sub</span>

<span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Draw(<span class="kwrd">ByVal</span> gameTime <span class="kwrd">As</span> Microsoft.Xna.Framework.GameTime)
    <span class="kwrd">MyBase</span>.Draw(gameTime)
<span class="kwrd">End</span> Sub</pre>
<p>Just to make something happen on the screen, I am adding these members:</p>
<pre class="csharpcode">
<span class="kwrd">Private</span> Sb <span class="kwrd">As</span> Microsoft.Xna.Framework.Graphics.SpriteBatch
<span class="kwrd">Private</span> SpriteTexture <span class="kwrd">As</span> Microsoft.Xna.Framework.Graphics.Texture2D
<span class="kwrd">Private</span> SpriteX <span class="kwrd">As</span> <span class="kwrd">Integer</span> = 0
<span class="kwrd">Private</span> SpriteY <span class="kwrd">As</span> <span class="kwrd">Integer</span> = 0</pre>
<p>The <strong>SpriteBatch</strong> will manage my sprites and the <strong>Texture2D</strong> is the sprite graphics. In the LoadContent function, I will load a sprite from my hard drive.</p>
<pre class="csharpcode">
<span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> LoadContent()
    <span class="kwrd">Me</span>.Sb = <span class="kwrd">New</span> Microsoft.Xna.Framework.Graphics.SpriteBatch(<span class="kwrd">Me</span>.Gfx.GraphicsDevice)
    <span class="kwrd">Me</span>.SpriteTexture = Microsoft.Xna.Framework.Graphics.Texture2D.FromFile(<span class="kwrd">Me</span>.Gfx.GraphicsDevice, _
         <span class="str">"mysprite.png"</span>)
    <span class="kwrd">MyBase</span>.LoadContent()
<span class="kwrd">End</span> Sub</pre>
<p>The <strong>Update</strong> function is for changing the game scenery.</p>
<pre class="csharpcode">
<span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Update(<span class="kwrd">ByVal</span> gameTime <span class="kwrd">As</span> Microsoft.Xna.Framework.GameTime)
    SpriteX += 1
    SpriteY += 1
    <span class="kwrd">MyBase</span>.Update(gameTime)
<span class="kwrd">End</span> Sub</pre>
<p>And the <strong>Draw</strong> function is for screen rendering.</p>
<pre class="csharpcode">
<span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Draw(<span class="kwrd">ByVal</span> gameTime <span class="kwrd">As</span> Microsoft.Xna.Framework.GameTime)
    <span class="kwrd">Me</span>.Gfx.GraphicsDevice.Clear(Microsoft.Xna.Framework.Graphics.Color.Black)
    <span class="kwrd">Me</span>.Sb.Begin(Microsoft.Xna.Framework.Graphics.SpriteBlendMode.AlphaBlend)
    <span class="kwrd">Me</span>.Sb.Draw(<span class="kwrd">Me</span>.SpriteTexture, <span class="kwrd">New</span> Microsoft.Xna.Framework.Rectangle(<span class="kwrd">Me</span>.SpriteX, <span class="kwrd">Me</span>.SpriteY, 32, 32), _
         Microsoft.Xna.Framework.Graphics.Color.Red)
    <span class="kwrd">Me</span>.Sb.<span class="kwrd">End</span>()
    <span class="kwrd">MyBase</span>.Draw(gameTime)
<span class="kwrd">End</span> Sub</pre>
<p>This is the complete code that produces a sprite that floats over the screen in Visual Basic using XNA:</p>
<pre class="csharpcode">
<span class="kwrd">Public</span> <span class="kwrd">Class</span> TestGame
    <span class="kwrd">Inherits</span> Microsoft.Xna.Framework.Game

    <span class="kwrd">Private</span> Gfx <span class="kwrd">As</span> Microsoft.Xna.Framework.GraphicsDeviceManager

    <span class="kwrd">Private</span> Sb <span class="kwrd">As</span> Microsoft.Xna.Framework.Graphics.SpriteBatch
    <span class="kwrd">Private</span> SpriteTexture <span class="kwrd">As</span> Microsoft.Xna.Framework.Graphics.Texture2D
    <span class="kwrd">Private</span> SpriteX <span class="kwrd">As</span> <span class="kwrd">Integer</span> = 0
    <span class="kwrd">Private</span> SpriteY <span class="kwrd">As</span> <span class="kwrd">Integer</span> = 0

    <span class="kwrd">Public</span> <span class="kwrd">Shared</span> <span class="kwrd">Sub</span> Main()
        <span class="kwrd">Dim</span> Game <span class="kwrd">As</span> <span class="kwrd">New</span> TestGame()
        Game.Run()
    <span class="kwrd">End</span> <span class="kwrd">Sub</span>

    <span class="kwrd">Public</span> <span class="kwrd">Sub</span> <span class="kwrd">New</span>()
        <span class="kwrd">Me</span>.Gfx = <span class="kwrd">New</span> Microsoft.Xna.Framework.GraphicsDeviceManager(<span class="kwrd">Me</span>)
        <span class="kwrd">Me</span>.Gfx.PreferredBackBufferWidth = 800
        <span class="kwrd">Me</span>.Gfx.PreferredBackBufferHeight = 600
        <span class="kwrd">If</span> <span class="kwrd">Not</span> <span class="kwrd">Me</span>.Gfx.IsFullScreen <span class="kwrd">Then</span>
            <span class="kwrd">Me</span>.Gfx.ToggleFullScreen()
        <span class="kwrd">End</span> <span class="kwrd">If</span>
    <span class="kwrd">End</span> <span class="kwrd">Sub</span>

    <span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Initialize()
        <span class="kwrd">MyBase</span>.Initialize()
    <span class="kwrd">End</span> <span class="kwrd">Sub</span>

    <span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> LoadContent()
        <span class="kwrd">Me</span>.Sb = <span class="kwrd">New</span> Microsoft.Xna.Framework.Graphics.SpriteBatch(<span class="kwrd">Me</span>.Gfx.GraphicsDevice)
        <span class="kwrd">Me</span>.SpriteTexture = Microsoft.Xna.Framework.Graphics.Texture2D.FromFile(<span class="kwrd">Me</span>.Gfx.GraphicsDevice, _
              <span class="str">"mysprite.png"</span>)
        <span class="kwrd">MyBase</span>.LoadContent()
    <span class="kwrd">End</span> <span class="kwrd">Sub</span>

    <span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> UnloadContent()
        <span class="kwrd">MyBase</span>.UnloadContent()
    <span class="kwrd">End</span> <span class="kwrd">Sub</span>

    <span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Update(<span class="kwrd">ByVal</span> gameTime <span class="kwrd">As</span> Microsoft.Xna.Framework.GameTime)
        SpriteX += 1
        SpriteY += 1
        <span class="kwrd">MyBase</span>.Update(gameTime)
    <span class="kwrd">End</span> <span class="kwrd">Sub</span>

    <span class="kwrd">Protected</span> <span class="kwrd">Overrides</span> <span class="kwrd">Sub</span> Draw(<span class="kwrd">ByVal</span> gameTime <span class="kwrd">As</span> Microsoft.Xna.Framework.GameTime)
        <span class="kwrd">Me</span>.Gfx.GraphicsDevice.Clear(Microsoft.Xna.Framework.Graphics.Color.Black)
        <span class="kwrd">Me</span>.Sb.Begin(Microsoft.Xna.Framework.Graphics.SpriteBlendMode.AlphaBlend)
        <span class="kwrd">Me</span>.Sb.Draw(<span class="kwrd">Me</span>.SpriteTexture, <span class="kwrd">New</span> Microsoft.Xna.Framework.Rectangle(<span class="kwrd">Me</span>.SpriteX, <span class="kwrd">Me</span>.SpriteY, 32, 32), _
                Microsoft.Xna.Framework.Graphics.Color.Red)
        <span class="kwrd">Me</span>.Sb.<span class="kwrd">End</span>()
        <span class="kwrd">MyBase</span>.Draw(gameTime)
    <span class="kwrd">End</span> <span class="kwrd">Sub</span>

<span class="kwrd">End</span> <span class="kwrd">Class</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/01/hardware-accelerated-graphics-through-xna-getting-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The ups and downs of Visual Studio 2010: Auto list members</title>
		<link>http://www.winsoft.se/2010/01/the-ups-and-downs-of-visual-studio-2010-auto-list-members/</link>
		<comments>http://www.winsoft.se/2010/01/the-ups-and-downs-of-visual-studio-2010-auto-list-members/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 21:10:53 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Studio 10]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=825</guid>
		<description><![CDATA[In Visual Studio 2010, the auto list members feature is much more intelligent than in previous versions. For example, assuming that X is an object with a visible function called DoSomeWork, in earlier versions of Visual Studio, you would have to know that the method started with Do to find it in the list. If [...]]]></description>
			<content:encoded><![CDATA[<p>In Visual Studio 2010, the <em>auto list members</em> feature is much more intelligent than in previous versions. For example, assuming that <strong>X</strong> is an object with a visible function called <strong>DoSomeWork</strong>, in earlier versions of Visual Studio, you would have to know that the method started with <strong>Do</strong> to find it in the list. If you didn&#8217;t know that, you would have to scroll through the list of members and try to recall what you are looking for, or search in the object browser. Now, if you type <strong>X.Work</strong>, Visual Studio lists <strong>DoSomeWork</strong> as a suggestion, because matching is done within the name, not only from the beginning of the name. Also, you type an acronym of the function name. <strong>DSW</strong> would match <strong>DoSomeWork</strong>.</p>
<p>Previous versions of Visual Studio applied a <em>&#8220;suggest and complete&#8221;</em> policy, which is the default in Visual Studio 2010. This is usually the most effected mode. If you are aiming to call the <strong>DoSomeWork</strong> function, you can type something like <strong>X.DoSo</strong> and then what ever character you was going to type thereafter, likely an opening parenthesis. The problem with the <em>&#8220;suggest and complete&#8221;</em> policy shows up when you&#8217;re trying to call a function that isn&#8217;t implemented yet. The text editor will force your typing to be a call to something other than you are aiming at, something that already exists, at least if the not-yet-existing member has a name that is a subset of an existing name. I always end up grabbing my computer mouse when this happens. This is one example where the <em>&#8220;suggest only&#8221;</em> policy can be useful. This mode lets you type whatever you want, because it will not force you to choose from something in the list.</p>
<p>To toggle completion mode, press <strong>Ctrl+Alt+Space</strong> or look at the <strong>IntelliSense</strong> sub menu under the <strong>Edit</strong> menu. Just as the <a href="http://www.winsoft.se/2009/12/the-ups-and-downs-of-visual-studio-2010-call-hierarch/" target="_self">call hierarchy feature</a>, this feature is available no matter what language you&#8217;re using, but (at least in the Beta) it only works in the C# editor, not the Visual Basic editor.</p>
<p>Now, there is no reason to have a mouse connected to the computer anymore. Thank you, Microsoft!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2010/01/the-ups-and-downs-of-visual-studio-2010-auto-list-members/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The ups and downs of Visual Studio 2010: Fonts and scaling</title>
		<link>http://www.winsoft.se/2009/12/the-ups-and-downs-of-visual-studio-2010-fonts-and-scaling/</link>
		<comments>http://www.winsoft.se/2009/12/the-ups-and-downs-of-visual-studio-2010-fonts-and-scaling/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 09:38:02 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Studio 10]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=726</guid>
		<description><![CDATA[The first time I head of the zoom feature of VS2010 was in a talk by Dag König at Microsoft. The level of readability is a very important question for me, and the font rendering of Windows (Clear Type) is superb compared to the blurry font rendering that Macintosh has. The big question, does the [...]]]></description>
			<content:encoded><![CDATA[<p>The first time I head of the zoom feature of VS2010 was in a talk by <a href="http://buzzfrog.blogs.com/" target="_blank">Dag König</a> at Microsoft. The level of readability is a very important question for me, and the font rendering of Windows (Clear Type) is superb compared to the blurry font rendering that Macintosh has. The big question, does the zoom feature affect the font rendering of the text editor? To the left, Visual Studio 9 with Consolas 8. To the right, Visual Studio 2010 with Consolas 8.</p>
<p><img class="alignnone" title="Font rendering" src="http://imghost.winsoft.se/upload/247311260695303fontrendering.png" alt="" width="364" height="91" /></p>
<p>VS2010 still uses clear type, and the readability is still there. The hue is slightly reduced, if the anti aliasing is too gray, the text will appear blurry as it does on a Macintosh that only uses a gray scale for smoothing edges. The upper side of reducing the hue is that smoothing works better with text in different colors.  In VS2010, the default color for a class keyword in Visual Basic is cyan as opposed to black in VS9.</p>
<p>And the zooming feature: Hold down Ctrl and use your mouse wheel. Not a feature I use every day – I use a font size that I can read without zooming, but really cool to use in presentations.</p>
<p>The .NET Framework lets you control how text is rendered in your programs. The property of the <strong>Graphics</strong> object you use to control this is called <strong>TextRenderingHint</strong>. Examine this code:</p>
<pre class="csharpcode"><span class="kwrd">Private</span> <span class="kwrd">Sub</span> Form1_Paint(<span class="kwrd">ByVal</span> sender <span class="kwrd">As</span> <span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> e <span class="kwrd">As</span> System.Windows.Forms.PaintEventArgs) <span class="kwrd">_
    Handles</span> <span class="kwrd">Me</span>.Paint
    Using B <span class="kwrd">As</span> <span class="kwrd">New</span> System.Drawing.Bitmap(300, 300)
        Using G <span class="kwrd">As</span> System.Drawing.Graphics = System.Drawing.Graphics.FromImage(B)
            Using F <span class="kwrd">As</span> <span class="kwrd">New</span> System.Drawing.Font(<span class="str">"Consolas"</span>, 10)
                G.FillRectangle(Brushes.White, 0, 0, 300, 300)

                <span class="rem">'Regular smoothing</span>
                G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
                G.DrawString(<span class="str">"Hello"</span>, F, Brushes.Black, 10, 10)

                <span class="rem">'Regular smoothing with grid fit</span>
                G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
                G.DrawString(<span class="str">"Hello"</span>, F, Brushes.Black, 10, 25)

                <span class="rem">'Clear Type smoothing with grid fit</span>
                G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
                G.DrawString(<span class="str">"Hello"</span>, F, Brushes.Black, 10, 40)

            <span class="kwrd">End</span> Using
        <span class="kwrd">End</span> Using
        e.Graphics.DrawImage(B, 0, 0)
    <span class="kwrd">End</span> Using
<span class="kwrd">End</span> Sub</pre>
<p>The option called <strong>AntiAlias</strong> renders text in a similar way to the Macintosh. The text appears blurry, but the outcome has true proportions, meaning that what you see on screen is a blurrier version of what you would see on a printed version. This option works best in high resolutions and for print previewing.</p>
<p>The <strong>AntiAliasGridFit</strong> makes the text less blurry, because letters align to the pixel grid of the screen. The downside is that character spacing is incorrect, but readability is much higher. This option works best with CRT screens.</p>
<p>The <strong>ClearTypeGridFit</strong> also aligns characters to the pixel grid, but it uses clear type. This option works best with a flat screen.</p>
<p>The output from the above code is shown here:</p>
<p><img class="alignnone" title="Font rendering" src="http://imghost.winsoft.se/upload/892851260697027text2.png" alt="" width="212" height="173" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2009/12/the-ups-and-downs-of-visual-studio-2010-fonts-and-scaling/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The ups and downs of Visual Studio 2010: Call Hierarchy</title>
		<link>http://www.winsoft.se/2009/12/the-ups-and-downs-of-visual-studio-2010-call-hierarch/</link>
		<comments>http://www.winsoft.se/2009/12/the-ups-and-downs-of-visual-studio-2010-call-hierarch/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 15:21:56 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Studio 10]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=722</guid>
		<description><![CDATA[The function that finds all references to a function or a variable has been in Visual Studio for a few versions now. VS2010 has a similar feature called Call Hierarchy. Right click on any function definition or function call, and click View Call Hierarchy. This shows the Call Hierarchy window with a tree structure that [...]]]></description>
			<content:encoded><![CDATA[<p>The function that finds all references to a function or a variable has been in Visual Studio for a few versions now. VS2010 has a similar feature called Call Hierarchy. Right click on any function definition or function call, and click <strong>View Call Hierarchy</strong>. This shows the Call Hierarchy window with a tree structure that displays what other functions are called from the function you clicked on, and who is calling it. This can help discover unused code and understanding the call stack of a program. In C#, not in Visual Basic. The View Call Hierarchy isn’t there if you right click on a Visual Basic function in VS2010 Beta 2. A quick look at Microsoft Connect tells me that the subject has been brought up, but nothing else has happened yet.</p>
<p><img class="alignnone" title="Call Hierarchy" src="http://imghost.winsoft.se/upload/919161260630643callhierarchy.jpg" alt="" width="456" height="429" /></p>
<p>One thing that does work, is the automated generation of sequence diagrams. VS2010 not only does this automatically, but the output is also editable. Objects on the diagram can be resized, moved or deleted, and new items can be added. All you have to do is click <strong>Generate Sequence Diagram</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2009/12/the-ups-and-downs-of-visual-studio-2010-call-hierarch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>VS at Professional Developers Conference 2008</title>
		<link>http://www.winsoft.se/2008/12/vs-at-professional-developers-conference-2008/</link>
		<comments>http://www.winsoft.se/2008/12/vs-at-professional-developers-conference-2008/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 09:02:39 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Studio 10]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=143</guid>
		<description><![CDATA[At PDC2008, Microsoft gave some information about the future of Visual Studio and C#. In 2010, C# and the .NET Framework will be in version 4 and Visual Studio and Visual Basic .NET will be in version 10. For those of you that wasn’t as lucky as mr. Alsing to actually be there, the speeches [...]]]></description>
			<content:encoded><![CDATA[<p>At PDC2008, Microsoft gave some information about the future of Visual Studio and C#. In 2010, C# and the .NET Framework will be in version 4 and Visual Studio and Visual Basic .NET will be in version 10. For those of you that wasn’t as lucky as <a href="http://rogeralsing.com/" target="_blank">mr. Alsing</a> to actually be there, the speeches are available online at <a href="http://www.microsoftpdc.com/" target="_blank">http://www.microsoftpdc.com/</a>.</p>
<p>Some of the highlights: <a href="http://www.microsoft.com/presspass/exec/techfellow/Hejlsberg/default.mspx" target="_blank">Anders Hejlsberg</a> is talking about the future of C# and the game developer Frank Savage talks about XNA Game Studio and the XNA Framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2008/12/vs-at-professional-developers-conference-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

