<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><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/" 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Farooq Azam</title>
	
	<link>http://www.farooqazam.net</link>
	<description>Unity 3D, Game Development and C# Programming.</description>
	<lastBuildDate>Tue, 31 Jan 2012 19:59:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/farooqazamblog" /><feedburner:info uri="farooqazamblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>farooqazamblog</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Simple Unity Game tutorial</title>
		<link>http://feedproxy.google.com/~r/farooqazamblog/~3/dMqbmCjQsTM/</link>
		<comments>http://www.farooqazam.net/simple-unity-game-tutorial/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 19:00:36 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[cube]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=374</guid>
		<description><![CDATA[In this tutorial I will teach you how to make a simple game. This tutorial is mainly aimed at users who are new to Unity. So let&#8217;s begin. First off create a new project if you haven&#8217;t already made one. &#8230; <a href="http://www.farooqazam.net/simple-unity-game-tutorial/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript"><!--
google_ad_client = "pub-7756739986631233";
/* 468x60, created 9/12/09 */
google_ad_slot = "1727532708";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><p><img class="alignnone size-medium wp-image-388" title="Cubes game" src="http://www.farooqazam.net/wp-content/uploads/2011/11/cube-game-300x235.png" alt="Cubes game" width="300" height="235" /></p>
<p>In this tutorial I will teach you how to make a simple game. This tutorial is mainly aimed at users who are new to Unity. So let&#8217;s begin.<span id="more-374"></span></p>
<p>First off create a new project if you haven&#8217;t already made one.</p>
<p>Right-click inside your Project tab and click Import Package &gt; Character Controller. Click on &#8220;none&#8221; at the bottom left and scroll down to the bottom. Under Scripts tick &#8220;MouseLook.cs&#8221;. This will import the MouseLook script. It will help us rotate the camera around using mouse movement.</p>
<p><a href="http://www.farooqazam.net/wp-content/uploads/2011/11/import-package.png"><img title="Import package" src="http://www.farooqazam.net/wp-content/uploads/2011/11/import-package.png" alt="Import package" width="679" height="364" /></a></p>
<p>Now that we&#8217;ve got the MouseLook script let&#8217;s attach it to our camera. Select the <em>MainCamera </em>in the <em>Hierarchy</em> and in the top menu go to Component &gt; Camera-Control &gt; MouseLook. Viola! Now if you play the game you can rotate the camera around by moving the mouse but our scene is empty and all you see is a blank blue background. Let&#8217;s design a simple level.</p>
<p>In the top menu go to GameObject &gt; Create Other &gt; Plane. In the<em> Inspector</em> set its x/y/z position to &#8220;0&#8243; and set its x/y/z scale to &#8220;2&#8243;, so our camera can see it. Hit Play and now you can see that if you move the mouse the camera will rotate!</p>
<p><a href="http://www.farooqazam.net/wp-content/uploads/2011/11/plane.png"><img class="alignnone size-full wp-image-393" title="plane" src="http://www.farooqazam.net/wp-content/uploads/2011/11/plane.png" alt="" width="727" height="550" /></a></p>
<p>But its pretty dark in here, isn&#8217;t it? Let&#8217;s add a light so we can see things a little better.</p>
<p>Go to GameObject &gt; Create Other &gt; Point Light and use the following values:</p>
<p><a href="http://www.farooqazam.net/wp-content/uploads/2011/11/point-light.png"><img class="alignnone size-full wp-image-384" title="Point Light" src="http://www.farooqazam.net/wp-content/uploads/2011/11/point-light.png" alt="Point Light" width="289" height="347" /></a></p>
<p>Play the game and you&#8217;ll see its not dark anymore.</p>
<p>So, now we&#8217;ve got a simple level and we can rotate the <em>Camera </em>using the mouse! But that&#8217;s not interesting. Let&#8217;s add some stuff we can interact with.</p>
<p>Go to GameObject &gt; Create Other &gt; Cube and in the <em>Inspector</em> set its x/y/z position to &#8220;X: 0, Y: 0.5, Z: 0&#8243;. Next go to Component &gt; Physics &gt; Rigidbody to make it a Rigidbody. Now it will be affected by gravity and it will respond to collisions with real time Physics etc. You can read more about Rigidbodies at the <a href="http://unity3d.com/support/documentation/Components/class-Rigidbody.html">Unity Documentation</a>.</p>
<p>Go to Edit &gt; Duplicate and make 5 copies of it so you&#8217;ll have 6 cubes in your scene. Position them like this:</p>
<p><a href="http://www.farooqazam.net/wp-content/uploads/2011/11/cubes.png"><img class="alignnone size-full wp-image-385" title="Cubes" src="http://www.farooqazam.net/wp-content/uploads/2011/11/cubes.png" alt="Cubes" width="500" height="378" /></a></p>
<p>Now we&#8217;re gonna make the player throw a ball. Go to GameObject &gt; Create Other &gt; Sphere. We want the ball to be affected by gravity and want it to collide with cubes. So add a Rigidbody to it by going to Component &gt; Physics &gt; Rigidbody. Position the ball right in front of the cubes but not too close the cubes.</p>
<p>To make the player throw the ball we&#8217;ll need a script. In the Project tab click on Create &gt; Javascript, name it &#8220;ThrowScript&#8221;. Double click to edit the script and use this code:</p>
<pre class="brush: plain; title: ; notranslate">
// This variable will contain a refernce the ball
var ball : GameObject;

// Speed of the ball
var speed : float = 800f;

function Update ()
{
	// If the Space key is pressd, apply force on the ball in z-axis (forward)
	if(Input.GetKeyDown(&quot;space&quot;))
		ball.rigidbody.AddForce(0, 0, speed);
}
</pre>
<p>We&#8217;re almost done. In the <em>Project</em> tab drag the ThrowScript and drop it over the <em>MainCamera </em>in the <em>Hierarchy </em>to attach it to the camera. All we need to do now is to tell the script which ball to use. Select the <em>MainCamera</em> and scroll down to the ThrowScript in the Inspector and drag and drop the Sphere into the Ball variable.</p>
<p><a href="http://www.farooqazam.net/wp-content/uploads/2011/11/camera-throw.png"><img class="alignnone size-full wp-image-387" title="camera-throw" src="http://www.farooqazam.net/wp-content/uploads/2011/11/camera-throw.png" alt="" width="600" height="454" /></a></p>
<p>That&#8217;s it! Our simple game is now finished. Play the game and press space and you&#8217;ll see how the cubes react when the balls collides with them.</p>
<p><a href="http://www.farooqazam.net/wp-content/uploads/2011/11/cube-game.png"><img title="Cubes game" src="http://www.farooqazam.net/wp-content/uploads/2011/11/cube-game.png" alt="Cubes game" width="573" height="450" /></a></p>
<p>If you have any questions or tutorial requests post a comment below.</p>
<img src="http://feeds.feedburner.com/~r/farooqazamblog/~4/dMqbmCjQsTM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/simple-unity-game-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.farooqazam.net/simple-unity-game-tutorial/</feedburner:origLink></item>
		<item>
		<title>Unity FPS Game Update #3</title>
		<link>http://feedproxy.google.com/~r/farooqazamblog/~3/Z46FP00YXeo/</link>
		<comments>http://www.farooqazam.net/unity-fps-game-update-3/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 08:49:43 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=402</guid>
		<description><![CDATA[This is a huge update. Lots of new features and also we&#8217;re now using our own models and animations. New features: 2 new weapons. AK47 and Walther PPk Bullet marks Weapons now eject bullet cases Normal reload and Full reload &#8230; <a href="http://www.farooqazam.net/unity-fps-game-update-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><iframe width="584" height="329" src="http://www.youtube.com/embed/4nZm6Z20zw8?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>This is a huge update. Lots of new features and also we&#8217;re now using our own models and animations.</p>
<p>New features:<br />
2 new weapons. AK47 and Walther PPk<br />
Bullet marks<br />
Weapons now eject bullet cases<br />
Normal reload and Full reload (when chamber is empty)<br />
Different sprint animation for handguns</p>
<p>Models and animations made by Felixfors.</p>
<img src="http://feeds.feedburner.com/~r/farooqazamblog/~4/Z46FP00YXeo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/unity-fps-game-update-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.farooqazam.net/unity-fps-game-update-3/</feedburner:origLink></item>
		<item>
		<title>Unity FPS Game Update</title>
		<link>http://feedproxy.google.com/~r/farooqazamblog/~3/dEgZ77D-aQg/</link>
		<comments>http://www.farooqazam.net/unity-fps-game-update/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 23:05:44 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[fps]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=398</guid>
		<description><![CDATA[Added some cool new features to my game. Suggestions and feedback appreciated.]]></description>
			<content:encoded><![CDATA[<p>Added some cool new features to my game. Suggestions and feedback appreciated.</p>
<p><iframe width="584" height="329" src="http://www.youtube.com/embed/SKQVEyHhec0?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<img src="http://feeds.feedburner.com/~r/farooqazamblog/~4/dEgZ77D-aQg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/unity-fps-game-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.farooqazam.net/unity-fps-game-update/</feedburner:origLink></item>
		<item>
		<title>Unity 3D Game Development tutorials coming soon!</title>
		<link>http://feedproxy.google.com/~r/farooqazamblog/~3/sMgiRJXgqDI/</link>
		<comments>http://www.farooqazam.net/unity-3d-game-development-tutorials-coming-soon/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 20:52:16 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=363</guid>
		<description><![CDATA[I will be posing Unity tutorials in the next few weeks. Stay tuned! Also, I am currently working on an FPS Game in my spare time. Here&#8217;s a video of it: If I had time I would make a video serious which &#8230; <a href="http://www.farooqazam.net/unity-3d-game-development-tutorials-coming-soon/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I will be posing <a title="Unity 3D" href="http://www.unity3d.com">Unity</a> tutorials in the next few weeks. Stay tuned!</p>
<p>Also, I am currently working on an FPS Game in my spare time. Here&#8217;s a video of it:</p>
<p><iframe width="584" height="329" src="http://www.youtube.com/embed/pGBYuiz99cg?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>If I had time I would make a video serious which will teach how to make a game like that.</p>
<img src="http://feeds.feedburner.com/~r/farooqazamblog/~4/sMgiRJXgqDI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/unity-3d-game-development-tutorials-coming-soon/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.farooqazam.net/unity-3d-game-development-tutorials-coming-soon/</feedburner:origLink></item>
		<item>
		<title>Image Viewer application using C#</title>
		<link>http://feedproxy.google.com/~r/farooqazamblog/~3/0qEbatJt_MA/</link>
		<comments>http://www.farooqazam.net/image-viewer-application-using-c-sharp/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 19:00:45 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[c sharp]]></category>
		<category><![CDATA[image viewer]]></category>
		<category><![CDATA[picturebox]]></category>
		<category><![CDATA[rotate]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=126</guid>
		<description><![CDATA[A detailed tutorial about creating an Image Viewer or Picture Viewer application in C#. This application also converts Images from one type to another. Following are the features of this application: Open / Save images. Convert images. Rotate Images. All &#8230; <a href="http://www.farooqazam.net/image-viewer-application-using-c-sharp/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A detailed tutorial about creating an Image Viewer or Picture Viewer application in C#. This application also converts Images from one type to another.</p>
<p><a href="http://www.farooqazam.net/wp-content/uploads/2009/09/image-viewer.gif"><img title="image-viewer" src="http://www.farooqazam.net/wp-content/uploads/2009/09/image-viewer-300x263.gif" alt="" width="270" height="237" /></a></p>
<p>Following are the features of this application:</p>
<ul>
<li>Open / Save images.</li>
<li>Convert images.</li>
<li>Rotate Images.</li>
<li>All popular image formats are supported.</li>
</ul>
<p>Let&#8217;s get started!<span id="more-126"></span></p>
<h3>Setting up the Designer</h3>
<p>For this application you will need an openFileDialog, saveFileDialog, pictureBox and a few buttons.</p>
<ol>
<li>Add openFileDialog and saveFileDialog to the form.</li>
<li>Use this filter for the openFileDialog and saveFileDialog: &#8221; JPEG File|*.jpg|GIF File|*.gif|PNG File|*.png|BMP File|*.bmp &#8220;</li>
<li>Add 4 buttons (<a title="Image Viewer" href="http://www.farooqazam.net/wp-content/uploads/2009/09/image-viewer.gif">refer to the image above</a>). Name the buttons just like I&#8217;ve did in that image.</li>
<li>Set the &#8220;Enabled&#8221; property for &#8220;Save&#8221; button to &#8220;False&#8221;. And set &#8220;Visible&#8221; to &#8220;False&#8221; for &#8220;RotateClockwise&#8221; and &#8220;RotateCounterclockwise&#8221; buttons.</li>
<li>Add a pictureBox and place it under the buttons (refer to the image above).</li>
</ol>
<p>That&#8217;s it. Now lets get on with the code.</p>
<h3>The Code</h3>
<p>First of all, add this code to the very top of your form:</p>
<pre class="brush: csharp; title: ; notranslate">

using System.Drawing.Imaging;
</pre>
<p>Declare these methods after the &#8220;public Form1() { &#8230;.&#8221; method:</p>
<pre class="brush: csharp; title: ; notranslate">// This method will be used to save the image

private void saveImage(string ext)
{
   ImageFormat format = null;

   if(ext == &quot;.gif&quot;)
      format = ImageFormat.Gif;
   else if(ext == &quot;.jpg&quot; || ext == &quot;.jpeg&quot;)
      format = ImageFormat.Jpeg;
   else if(ext == &quot;png&quot;)
      format = ImageFormat.Png;
   else if(ext == &quot;.bmp&quot;)
      format = ImageFormat.Bmp;

   pictureBox1.Image.Save(saveFileDialog1.FileName, format);
}

// This method will be used for rotating the image.
private void rotateImage(int angle)
{
   Bitmap img = new Bitmap(pictureBox1.Image);

   // 0 = Clockwise, 1 = counter-clockwise
   if (angle == 0)
      img.RotateFlip(RotateFlipType.Rotate90FlipNone);
   else if (angle == 1)
      img.RotateFlip(RotateFlipType.Rotate90FlipXY);

   pictureBox1.Size = img.Size;
   pictureBox1.Image = img;
}
</pre>
<p>Double-click the &#8220;Open&#8221; button to add the &#8220;Click()&#8221; event for it and use this code:</p>
<pre class="brush: csharp; title: ; notranslate">private void openBtn_Click(object sender, EventArgs e)
{
   DialogResult result = openFileDialog1.ShowDialog();

   if (result == DialogResult.OK)
   {
      Image img = Image.FromFile(openFileDialog1.FileName);

      // Assigns the opened image to picturebox.
      pictureBox1.Image = img;

      // Makes the pictureBox width/height same as the opened image.
      pictureBox1.Width = img.Width;
      pictureBox1.Height = img.Height;
   }

   // Enables the Save button.
   saveBtn.Enabled = true;

   // Shows the RotateClockwise and Counterclockwise buttons.
   rotateClockwise.Show();

   rotateCounter.Show();
 }</pre>
<p>Double-click the Save button and use this code:</p>
<pre class="brush: csharp; title: ; notranslate">private void saveBtn_Click(object sender, EventArgs e)
{
   DialogResult res = saveFileDialog1.ShowDialog();

   if (res == DialogResult.OK)
   {

      // Extracts the extension from the opened file.
      string ext = System.IO.Path.GetExtension(saveFileDialog1.FileName);

      ext = ext.ToLower();
      saveImage(ext);
   }
}</pre>
<p>Double-click the RotateClockwise button and use this code:</p>
<pre class="brush: csharp; title: ; notranslate">private void rotateClockwise_Click(object sender, EventArgs e)
{
   // Calls the rotateImage method and passes the parameter &quot;0&quot;
   // Refer to the rotateImage method to see how it works.
   rotateImage(0);
}
</pre>
<p>And lastly, double-click the Rotate Counterclockwise button and use this code:</p>
<pre class="brush: csharp; title: ; notranslate"> private void rotateCounter_Click(object sender, EventArgs e)
{
   // 1 = counter-clockwise
   rotateImage(1);
}
</pre>
<p>That&#8217;s it! We are done.</p>
<h3>Source Code</h3>
<p>ImageViewer Source – <a title="Download ScreenCapture class" href="../source/ImageViewer.zip"><strong>Download Now</strong></a> (42 Kb)</p>
<p><a title="Buy domain names" href="http://www.networksolutions.com">Buy domain names</a></p>
<img src="http://feeds.feedburner.com/~r/farooqazamblog/~4/0qEbatJt_MA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/image-viewer-application-using-c-sharp/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.farooqazam.net/image-viewer-application-using-c-sharp/</feedburner:origLink></item>
		<item>
		<title>Screen Capture Class For C#</title>
		<link>http://feedproxy.google.com/~r/farooqazamblog/~3/QrQCNP49jbM/</link>
		<comments>http://www.farooqazam.net/screen-capture-class-for-c-sharp/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 20:30:46 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[c sharp]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[screen capture]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=106</guid>
		<description><![CDATA[A class that will help you take screenshots quickly and easily. Following are the features of this class: Take screenshot of the whole screen Take screenshot of a particular area using a Rectangle Copy the screenshot to Clipboard. Save the &#8230; <a href="http://www.farooqazam.net/screen-capture-class-for-c-sharp/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A class that will help you take screenshots quickly and easily.</p>
<p><img title="ScreenCapture" src="http://www.farooqazam.net/wp-content/uploads/2009/09/ScreenCapture.gif" alt="ScreenCapture" width="396" height="233" /></p>
<p>Following are the features of this class:</p>
<ul>
<li>Take screenshot of the whole screen</li>
<li>Take screenshot of a particular area using a Rectangle</li>
<li>Copy the screenshot to Clipboard.</li>
<li>Save the screenshot straight after it is captured.</li>
<li>All popular image formats are supported.</li>
</ul>
<p><span id="more-106"></span></p>
<h3>How to use?</h3>
<p>To import this class into your C# project all you have to do is to drag and drop the “ScreenCapture.cs” file into your project.</p>
<p>It is very simple to use this class. Here’s an overview of all the features:</p>
<pre class="brush: csharp; title: ; notranslate">// Add this code to the top of your code
// i.e: add it above &quot;public Form1() { ......&quot;

SC.ScreenCapture SC = new SC.ScreenCapture();

// To take a screenshot of the whole screen
// Use this code:

SC.CaptureScreen();

// If you want to save the screenshot straight after it is taken
// Use this code:
// Replace &quot;C:\\screenshot.jpg&quot; with your own path

SC.CaptureScreen(@&quot;C:\screenshot.jpg&quot;);

// To take screenshot of a particular area
// Use this code:
// Replace &quot;Rect&quot; with a Rectangle

SC.CaptureRectangle(Rect);

// To save the screenshot straight after it is taken
// Use this code:
// Replace &quot;C:\screenshot-rect.jpg&quot; with your own path and &quot;Rect&quot; with a rectangle.

SC.CaptureRectangle(Rect, &quot;C:\\screenshot-rect.jpg&quot;);

// Note: Use the code below after you've taken a screenshot.
// To copy the screenshot to Clipboard
// Use this code

SC.CopyToClipboard();
</pre>
<p>The above instructions showed you all the features this class offers. However, if you want to see this class in acton. Then I’ve made a simple application for you, which uses this class. Download the class alone or the sample application below:</p>
<h3>Dowload the ScreenCapture class and a sample application</h3>
<blockquote><p>ScreenCapture Class – <a title="Download ScreenCapture class" href="../source/ScreenCapture-class.zip"><strong>Download Now</strong></a> (1 Kb)</p>
<p>Sample Application – <a title="Download Sample Application" href="../source/ScreenCapture-sample.zip"><strong>Download Now</strong></a> (46 Kb)</p></blockquote>
<img src="http://feeds.feedburner.com/~r/farooqazamblog/~4/QrQCNP49jbM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/screen-capture-class-for-c-sharp/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://www.farooqazam.net/screen-capture-class-for-c-sharp/</feedburner:origLink></item>
		<item>
		<title>C# – Check if connected to internet</title>
		<link>http://feedproxy.google.com/~r/farooqazamblog/~3/QzXGlve25qg/</link>
		<comments>http://www.farooqazam.net/csharp-check-if-connected-to-internet/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 10:26:31 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[c sharp]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=274</guid>
		<description><![CDATA[I was working on an application which checked for updates. I used WebRequest/WebResponse for checking updates. It showed a continuous Progressbar while checking for updates. But there was a problem. It worked properly when you were connected to internet but it &#8230; <a href="http://www.farooqazam.net/csharp-check-if-connected-to-internet/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was working on an application which checked for updates. I used WebRequest/WebResponse for checking updates. It showed a continuous Progressbar while checking for updates. But there was a problem. It worked properly when you were connected to internet but it  just showed the progressbar all the time if not connected.</p>
<p>The solution for that was to check for internet connection before checking for updates. If connected then check for updates otherwise show an error.</p>
<p>Checking for the state of internet connection is very simple. Let&#8217;s get started.</p>
<p><span id="more-274"></span></p>
<p>Firstly, import <em>System.Runtime.InteropServices</em> namespace. Add this to the top of your code:</p>
<pre class="brush: csharp; title: ; notranslate">using System.Runtime.InteropServices;</pre>
<p>Then use this code for checking connection state:</p>
<p><small><em>For C# Beginners: Add this code above or below public Form1() { &#8230; }</em></small></p>
<pre class="brush: csharp; title: ; notranslate">// API Method
[DllImport(&quot;wininet.dll&quot;)]
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);

// A method for checking the state
public static bool IsConnected()
{
    int Description;
    return InternetGetConnectedState(out Description, 0);
}</pre>
<p>Now you can use the above method to check for connection before doing anything that requires internet connection.</p>
<p>Example use:</p>
<pre class="brush: csharp; title: ; notranslate">// If internet connection is active
if (IsConnected())
{
    // do something
}
else
{
   MessageBox.Show(&quot;Please connect to the internet.&quot;);
</pre>
<p>If you have any questions please don&#8217;t hesitate to post a comment.</p>
<img src="http://feeds.feedburner.com/~r/farooqazamblog/~4/QzXGlve25qg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/csharp-check-if-connected-to-internet/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.farooqazam.net/csharp-check-if-connected-to-internet/</feedburner:origLink></item>
		<item>
		<title>Crop Image – C# and VB.NET</title>
		<link>http://feedproxy.google.com/~r/farooqazamblog/~3/dmsV5IBKhoI/</link>
		<comments>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/#comments</comments>
		<pubDate>Mon, 24 May 2010 04:00:00 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[c sharp]]></category>
		<category><![CDATA[crop]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=239</guid>
		<description><![CDATA[For cropping an image in C# &#38; VB.NET we can use the Graphics class. We&#8217;ll use a method (or function in VB.NET) which will take 2 parameters, a source image and a rectangle of the section that should be cropped.  &#8230; <a href="http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For cropping an image in C# &amp; VB.NET we can use the <em>Graphics</em> class. We&#8217;ll use a method (or function in VB.NET) which will take 2 parameters, a source image and a rectangle of the section that should be cropped.  Let&#8217;s code!</p>
<p><a href="http://www.farooqazam.net/wp-content/uploads/2010/05/crop.gif"><img title="crop" src="http://www.farooqazam.net/wp-content/uploads/2010/05/crop.gif" alt="" width="350" height="234" /></p>
<p><span id="more-239"></span></a></p>
<h3>The Code</h3>
<p><strong><br />
C#:</strong></p>
<pre class="brush: csharp; title: ; notranslate">
public Bitmap CropImage(Bitmap source, Rectangle section)
{

 // An empty bitmap which will hold the cropped image
 Bitmap bmp = new Bitmap(section.Width, section.Height);

 Graphics g = Graphics.FromImage(bmp);

 // Draw the given area (section) of the source image
 // at location 0,0 on the empty bitmap (bmp)
 g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel);

 return bmp;
}

// Example use:

Bitmap source = new Bitmap(@&quot;C:\tulips.jpg&quot;);
Rectangle section = new Rectangle(new Point(12, 50), new Size(150, 150));

Bitmap CroppedImage = CropImage(source, section);
</pre>
<p><strong><br />
VB.NET</strong></p>
<pre class="brush: vb; title: ; notranslate">
Function CropImage(ByVal source As Bitmap, ByVal section As Rectangle) As Bitmap

 ' An empty bitmap which will hold the cropped image
 Dim bmp As New Bitmap(section.Width, section.Height)

 Dim g As Graphics = Graphics.FromImage(bmp)

 ' Draw the given area (section) of the source image
 ' at location 0,0 on the empty bitmap (bmp)
 g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel)

 return bmp
End Function

' Example use:

Dim source As New Bitmap(&quot;C:\tulips.jpg&quot;)
Dim section As New Rectangle(new Point(12, 50), new Size(150, 150))

Dim CroppedImage As Bitmap = CropImage(source, section)
</pre>
<h3>Explanation</h3>
<p>The above code will work perfectly but it seems confusing, doesn&#8217;t it? You might have been wondering how it works. Well&#8230;</p>
<p>We first make an empty bitmap of the same width/height as the <em>section</em> rectangle. This bitmap will hold the cropped image. We use the <em>section</em> rectangle&#8217;s width/height because it determines the size of the cropped image. Then we use the <em>Graphics</em> class&#8217;s <em>DrawImage()</em> method (function) for the cropping. It draws the given area (<em>section</em>) of the <em>source</em> image on the empty bitmap and that&#8217;s it. The <span style="text-decoration: line-through;">empty</span> bitmap now holds the cropped image.</p>
<h3>Source Code</h3>
<p><a href="http://www.farooqazam.net/source/CropImage-Csharp.zip">Download Source Code for C#</a></p>
<p><a href="http://www.farooqazam.net/source/CropImage-VB.zip">Download Source Code for VB.NET</a></p>
<p>If you have any questions, don&#8217;t hesitate to post a comment.</p>
<p>Thanks</p>
<img src="http://feeds.feedburner.com/~r/farooqazamblog/~4/dmsV5IBKhoI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/</feedburner:origLink></item>
		<item>
		<title>C# – Autocomplete Textbox</title>
		<link>http://feedproxy.google.com/~r/farooqazamblog/~3/F04GOO07pU0/</link>
		<comments>http://www.farooqazam.net/c-sharp-autocomplete-textbox/#comments</comments>
		<pubDate>Sat, 15 May 2010 08:52:37 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[c sharp]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=207</guid>
		<description><![CDATA[There are times when you&#8217;ll need an autocomplete textbox. Autocomplete textbox makes the user&#8217;s life easier. It shows suggestions as the user types. In case of a web browser, if you type &#8220;goo&#8221; it will automatically show all the suggestions &#8230; <a href="http://www.farooqazam.net/c-sharp-autocomplete-textbox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are times when you&#8217;ll need an autocomplete textbox. Autocomplete textbox makes the user&#8217;s life easier. It shows suggestions as the user types. In case of a web browser, if you type &#8220;goo&#8221; it will automatically show all the suggestions starting with or containing &#8220;goo&#8221; like &#8220;Google, Goofy&#8221; etc. It really helps both you or your users when hunting for something. Of course, it seems difficult to set up, but the reality is very different. So whether they&#8217;re typing in &#8220;<a href="http://www.o2.co.uk/broadband/">find O2 UK BROADBAND</a>&#8221; or you&#8217;re hunting for &#8220;that holiday video&#8221;, then your users are likely to find it a lot faster. Enough talk! Lets get on with it.</p>
<p><a href="http://www.farooqazam.net/wp-content/uploads/2010/05/auto-complete-textbox.gif"><img title="Autocomplete textbox" src="http://www.farooqazam.net/wp-content/uploads/2010/05/auto-complete-textbox.gif" alt="" width="369" height="215" /></a></p>
<p>Fortunately, textbox has a built-in autocomplete feature! We don&#8217;t have to do any coding.</p>
<p>You can either set it up from the Designer (if you are using Visual Studio or <a title="Sharp Develop" href="http://www.icsharpcode.net/opensource/sd/">#Develop</a>) or do it via code. It is simple both ways. Lets do it!<br />
<span id="more-207"></span></p>
<h3>Setting up AutoComplete</h3>
<p><a href="../wp-content/uploads/2010/05/auto-completes.gif"><img title="AutoComplete Properties" src="../wp-content/uploads/2010/05/auto-completes.gif" alt="" width="357" height="215" /></a></p>
<p>For setting up autocomplete you&#8217;ll have to use three properties of the TextBox class &#8212; AutoCompleteSource, AutoCompleteCustomSource and AutoCompleteMode. Here&#8217;s an explanation of these properties:</p>
<p><strong>AutoCompleteSource</strong> is the source of the suggestions. You can assign it CustomSource if you want to use custom suggestions or use other auto sources like FileSystem, HistoryList etc. Below are all the available sources:</p>
<ul>
<li><strong>FileSystem</strong>: This will show suggestions from the file system i.e files stored on the computer. Like if you write &#8220;C:\&#8221; it&#8217;ll show all the files stored on C: drive.</li>
<li><strong>FileSystemDirectories:</strong> This is same as FileSystem but it shows directory names instead of file names.</li>
<li><strong>HistoryList:</strong> This will show URLs from Internet Explorer&#8217;s history.</li>
<li><strong>RecentlyUsedList:</strong> A list of recently used applications, folders, and URLs (from internet explorer).</li>
<li><strong>AllUrl: </strong>This specifies an equivalent of HistoryList and RecentlyUsedList as the source.</li>
<li><strong>AllSystemSources:</strong> Specifies an equivalent of AllUrl and FileSystem as the source.</li>
</ul>
<p><strong>AutoCompleteModes</strong> are of 3 types. Suggest, Append and SuggestAppend:</p>
<ul>
<li><strong>Suggest</strong> will show suggestions in a drop-down as the user types.</li>
<li><strong>Append</strong> will auto complete as you type. Like if you write &#8220;Goo&#8221; it&#8217;ll automatically make it &#8220;Google&#8221;.</li>
<li><strong>SuggestAppend</strong> will do both Suggest/Append.</li>
</ul>
<p><strong>AutoCompleteCustomSource</strong> is collection of custom suggestions. It will be used when you assign &#8220;CustomSource&#8221; as &#8220;AutoCompleteSource&#8221;.</p>
<p>Okay enough explanations. Lets make an autocomplete textbox now.</p>
<h3>Using Designer:</h3>
<p>If you are using the Designer, then all you have to do is to select your TextBox and change those three properties (explained above). For instance, if you want to use custom suggestions then use &#8220;CustomSource&#8221; and add the custom suggestions to &#8220;AutoCompleteCustomSource&#8221; (don&#8217;t forget to set up AutoCompleteMode). Debug your project and see! Its that easy <img src='http://www.farooqazam.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Don&#8217;t forget that you can also use all the other sources like FileSystem, HistoryList etc.</p>
<p><a href="http://www.farooqazam.net/wp-content/uploads/2010/05/auto-completes.gif"><img title="AutoComplete Properties" src="http://www.farooqazam.net/wp-content/uploads/2010/05/auto-completes.gif" alt="" width="357" height="215" /></a></p>
<h3>Via Coding:</h3>
<p>Here&#8217;s an example:</p>
<pre class="brush: csharp; title: ; notranslate">
// List of custom suggestions
string[] suggestions = new string[] {
&quot;Google&quot;,
&quot;Google Images&quot;,
&quot;Yahoo&quot;,
&quot;Youtube&quot;
};

// Use the AutoCompleteMode that suits you.
textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;

// Since we are using custom suggestions you
// should use this source.
// Use the other non-custom sources if you
// don't want to use custom suggestions.
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;

// And finally add the above suggestions to the CustomSource
textBox1.AutoCompleteCustomSource.AddRange(suggestions);
</pre>
<p>That&#8217;s it.</p>
<p>If you have any questions, don&#8217;t hesitate to post a comment.</p>
<img src="http://feeds.feedburner.com/~r/farooqazamblog/~4/F04GOO07pU0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/c-sharp-autocomplete-textbox/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://www.farooqazam.net/c-sharp-autocomplete-textbox/</feedburner:origLink></item>
		<item>
		<title>C# – Check if Form is already running</title>
		<link>http://feedproxy.google.com/~r/farooqazamblog/~3/-ChAt5Z-zsw/</link>
		<comments>http://www.farooqazam.net/c-sharp-check-if-form-is-already-running/#comments</comments>
		<pubDate>Wed, 12 May 2010 18:02:35 +0000</pubDate>
		<dc:creator>Farooq Azam</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[c sharp]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[running]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.farooqazam.net/?p=191</guid>
		<description><![CDATA[To check if a form is already running you&#8217;ll have to look for it in the Application.OpenForms collection. When a form is opened it is added to that collection. Here&#8217;s a boolean method that checks whether a form is open &#8230; <a href="http://www.farooqazam.net/c-sharp-check-if-form-is-already-running/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To check if a form is already running you&#8217;ll have to look for it in the Application.OpenForms collection. When a form is opened it is added to that collection.</p>
<p>Here&#8217;s a boolean method that checks whether a form is open or not :</p>
<pre class="brush: csharp; title: ; notranslate">
private bool CheckForm(Form form)
{
   foreach (Form f in Application.OpenForms)
       if (form == f)
          return true;

 return false;
}
</pre>
<p>Example use:</p>
<pre class="brush: csharp; title: ; notranslate">
// if form2 is not running

if (!CheckForm(form2))
  {
      // do something
  }
</pre>
<p>Thanks.</p>
<p>If you have any questions, don&#8217;t hesitate to post a comment.</p>
<img src="http://feeds.feedburner.com/~r/farooqazamblog/~4/-ChAt5Z-zsw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.farooqazam.net/c-sharp-check-if-form-is-already-running/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.farooqazam.net/c-sharp-check-if-form-is-already-running/</feedburner:origLink></item>
	</channel>
</rss>

