<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Coding4Fun : windows mobile</title><link>http://blogs.msdn.com/coding4fun/archive/tags/windows+mobile/default.aspx</link><description>Tags: windows mobile</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>GPS tools</title><link>http://blogs.msdn.com/coding4fun/archive/2009/08/11/9864795.aspx</link><pubDate>Tue, 11 Aug 2009 22:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9864795</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9864795.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9864795</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9864795</wfw:comment><description>&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/GPStools_C54C/ToolboxBig%5B1%5D_2.png" mce_href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/GPStools_C54C/ToolboxBig%5B1%5D_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: 0px" title=ToolboxBig[1] border=0 alt=ToolboxBig[1] align=right src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/GPStools_C54C/ToolboxBig%5B1%5D_thumb.png" width=256 height=256 mce_src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/GPStools_C54C/ToolboxBig%5B1%5D_thumb.png"&gt;&lt;/A&gt; GeoFrameworks and Jon Person released their GPS Framework for .NET on CodePlex!&amp;nbsp; The really nice thing about this framework is it works with both the full blown .NET Framework and the Compact Framework.&amp;nbsp; If you’re developing for a Windows Mobile, embedded, laptop or desktop computer, it should handle all your needs.&lt;/P&gt;
&lt;P&gt;Just a few of the features are:&lt;/P&gt;
&lt;LI&gt;Automatic detection of serial GPS devices (or devices found via a virtual serial port). &lt;/LI&gt;
&lt;LI&gt;Automatic detection of Bluetooth devices (when using the Microsoft Bluetooth stack.) &lt;/LI&gt;
&lt;LI&gt;Automatic baud rate detection. &lt;/LI&gt;
&lt;LI&gt;Automatic recovery of lost connections. &lt;/LI&gt;
&lt;LI&gt;Advanced GPS precision via Kalman filtering. &lt;/LI&gt;
&lt;LI&gt;Support for desktops and mobile devices. &lt;/LI&gt;
&lt;LI&gt;Support for real-time GPS data without relying on Microsoft's GPS API. &lt;/LI&gt;
&lt;LI&gt;Support for control and monitoring of precision. &lt;/LI&gt;
&lt;LI&gt;A set of animated gauge controls for desktops and mobile devices (Altimeter, Compass, Speedometer, SatelliteViewer, SatelliteSignalBar). 
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt; Forgot to put in the link!&amp;nbsp; &lt;A href="http://gps3.codeplex.com/"&gt;http://gps3.codeplex.com&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9864795" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/c4fnews/default.aspx">c4fnews</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows+mobile/default.aspx">windows mobile</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/GPS/default.aspx">GPS</category></item><item><title>Building a Full Featured Mobile Camera Application: C4FCamera</title><link>http://blogs.msdn.com/coding4fun/archive/2009/07/07/9725275.aspx</link><pubDate>Tue, 07 Jul 2009 22:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9725275</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9725275.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9725275</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9725275</wfw:comment><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/Code4FunPicture4_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="Code4FunPicture4" border="0" alt="Code4FunPicture4" align="right" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/Code4FunPicture4_thumb.jpg" width="180" height="240" /&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/Code4FunPicture2_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="Code4FunPicture2" border="0" alt="Code4FunPicture2" align="right" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/Code4FunPicture2_thumb.jpg" width="180" height="240" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;By &lt;a href="mailto:robert.fischer@daugherty.com"&gt;Robert Fischer&lt;/a&gt;, Technical Architect, Daugherty Business Solutions    &lt;br /&gt;&lt;a href="mailto:Pierre.Lafromboise@Daugherty.com"&gt;Pierre Lafromboise&lt;/a&gt;, Business Intelligence Architect, Daugherty Business Solutions, and Anne Fischer&lt;/p&gt;  &lt;p&gt;Maybe you have always wanted to get started developing a Windows Mobile 6.x application but weren’t sure where or how to get started. The nice thing about mobile development is that it is actually simpler than desktop application development in many ways. This is due to the fact that when developing against the .NET Compact Framework you have fewer options. The .NET Compact Framework contains a subset of the .NET Framework. This article focuses on building a Mobile Camera Phone application using the Windows Mobile 6 SDK and the .NET Compact Framework Version 3.5. It is a great application for learning the Compact Framework since it covers a variety of scenarios you are likely to experience when developing a mobile application that you wouldn’t typically come across when developing a desktop application.&amp;#160; For a good source of background information for Windows Mobile Development, check out the following Microsoft site: &lt;a href="http://msdn.microsoft.com/en-us/windowsmobile/default.aspx"&gt;http://msdn.microsoft.com/en-us/windowsmobile/default.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To build and run this application sample, you will need to install the following:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Source Code:&lt;/b&gt; &lt;a href="http://WinMoCamera.codeplex.com"&gt;Download&lt;/a&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Difficulty:&lt;/b&gt; Intermediate&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Time Required:&lt;/b&gt; 5 hours&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Cost:&lt;/b&gt; Free-ish&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Software Needed:&lt;/b&gt; &lt;a href="http://www.microsoft.com/visualstudio/en-us/try/default.mspx"&gt;Visual Studio Professional&lt;/a&gt; (student?&amp;#160; Get it as &lt;a href=" https://www.dreamspark.com/"&gt;Dream Spark&lt;/a&gt;), &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=06111A3A-A651-4745-88EF-3D48091A390B&amp;amp;displaylang=en"&gt;Windows Mobile 6 SDK&lt;/a&gt;, &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Hardware:&lt;/b&gt; Windows Mobile Touch Screen phone&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;This article will not go through the steps of installing and configuring your development environment since it can get pretty involved. However a good starting point would be MSDN’s article: &lt;a href="http://msdn.microsoft.com/en-us/library/bb158509.aspx"&gt;&lt;i&gt;Development Tools and Resources for Windows Mobile 6&lt;/i&gt;&lt;/a&gt;&lt;i&gt;.&lt;/i&gt;&lt;/p&gt;  &lt;h2&gt;C4FCamera Solution Overview&lt;/h2&gt;  &lt;p&gt;The C4FCamera Visual Studio solution contains three projects: &lt;strong&gt;C4FCamera&lt;/strong&gt;, &lt;strong&gt;C4FCameraLib&lt;/strong&gt; and &lt;strong&gt;CameraTests&lt;/strong&gt;. Three projects were created due to necessity. The C4FCamera application makes use of the &lt;i&gt;CameraCaptureDialog&lt;/i&gt; class. This class provides an easy, mobile-device-neutral wrapper for the camera and video functionality provided by the mobile device. This is very convenient because it abstracts away the specific implementations that would occur from the different mobile device manufacturers and the headaches that would occur if you needed to access each device through hardware specific drivers. This class returns a JPEG when used to capture still images.&lt;/p&gt;  &lt;p&gt;A difficulty arises when developing with the &lt;i&gt;CameraCaptureDialog&lt;/i&gt; class and testing the application using a mobile emulator. This is due to the emulator not having a real camera attached to it. The C4FCamera project allows you to save the picture as Color, Black and White, or Sepia tone. But since there is not an actual camera attached to the phone, how do you test the filters? In this project, we solved the problem by creating a mobile application library and then testing the application using a Visual Studio Test project. For Test Driven Design (TDD) practitioners, this would be just the beginning. For those not familiar with TDD, this gives you an example of one of the many benefits that come from using TDD.&lt;/p&gt;  &lt;p&gt;Superficial exploration of C4FCamera will reveal that it demonstrates many common tasks and scenarios that would likely be encountered when developing a mobile application. First the project makes use of multiple mobile device forms and controls. Second, the application demonstrates several workarounds that arise from limitations in the compact framework. Altogether, the application should help the new mobile developer gain an understanding of how mobile development differs from other types of software development.&lt;/p&gt;  &lt;h2&gt;Exploring the C4FCamera Project&lt;/h2&gt;  &lt;h4&gt;The Main Application Interface: Coding4FunCameraForm&lt;/h4&gt;  &lt;p&gt;The project has three forms. The main screen provides the user with the ability to set the location where pictures are stored, the resolution of the pictures, and the default file name. When developing a professional application, it may not make sense to offer all the settings to a user on the main interface. It is up to you to decide based on your knowledge of the target user’s profile. The majority of the settings on the main form relate to the properties of the &lt;i&gt;CameraCaptureDialog&lt;/i&gt; class. The filter selection radio buttons are not directly related to the &lt;i&gt;CameraCaptureDialog class&lt;/i&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/clip_image002%5B7%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image002[7]" border="0" alt="clip_image002[7]" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/clip_image002%5B7%5D_thumb.jpg" width="250" height="379" /&gt;&lt;/a&gt; &lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/clip_image004%5B7%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image004[7]" border="0" alt="clip_image004[7]" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/clip_image004%5B7%5D_thumb.jpg" width="250" height="296" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Many of the control settings and default values are kept in a resource file. A resource file provides a convenient location where localized settings can be kept. Since most text in an application is culture and location specific, it makes sense to use resource files as a matter of habit. Resource files can hold strings, images, icons, and even audio files.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/clip_image006%5B7%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image006[7]" border="0" alt="clip_image006[7]" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/clip_image006%5B7%5D_thumb.jpg" width="500" height="273" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We will cover other aspects of the user interface later in this article. For now, it is important to recognize that the user interface directly relates to information we need to present to the &lt;i&gt;CameraCaptureDialog&lt;/i&gt; class. &lt;/p&gt;  &lt;h4&gt;CameraCaptureDialog Class&lt;/h4&gt;  &lt;p&gt;The C4FCamera application revolves around the &lt;i&gt;CameraCaptureDialog&lt;/i&gt; class. This class is extremely simple to use. Below is the code from the C4FCamera project.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;CameraCaptureDialog cameraCapture = &lt;span class="kwrd"&gt;new&lt;/span&gt; CameraCaptureDialog();
cameraCapture.StillQuality = &lt;span class="kwrd"&gt;this&lt;/span&gt;.StillQuality;
cameraCapture.Owner = &lt;span class="kwrd"&gt;this&lt;/span&gt;;
cameraCapture.DefaultFileName = textDefaultFileName.Text;
cameraCapture.InitialDirectory = PictureDirectoryPath.Text;
cameraCapture.Resolution = &lt;span class="kwrd"&gt;new&lt;/span&gt; Size(Convert.ToInt32(textWidth.Text), Convert.ToInt32(textHeight.Text));

&lt;span class="rem"&gt;// Displays the &amp;quot;Camera Capture&amp;quot; dialog box&lt;/span&gt;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (DialogResult.OK == cameraCapture.ShowDialog())
{
   &lt;span class="kwrd"&gt;string&lt;/span&gt; fileName = cameraCapture.FileName.Replace(&lt;span class="str"&gt;&amp;quot;___TEMP&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);
   ICameraFilter filter = GetPictureFilter(cameraCapture.FileName);
   &lt;span class="kwrd"&gt;string&lt;/span&gt; saveFileName = CameraFileUtilities.incrementFileNameNumber(fileName);
   filter.Apply().Save(saveFileName, ImageFormat.Jpeg);
   File.Delete(cameraCapture.FileName);
   &lt;span class="rem"&gt;// The method completed successfully.&lt;/span&gt;
   MessageBox.Show(
      &lt;span class="str"&gt;&amp;quot;The picture has been successfully captured and saved to:\n\n&amp;quot;&lt;/span&gt; + saveFileName, &lt;span class="kwrd"&gt;this&lt;/span&gt;.Text,&lt;br /&gt;       MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The code in this example creates a new instance of the &lt;i&gt;CameraCaptureDialog&lt;/i&gt; class and then calls the &lt;b&gt;ShowDialog&lt;/b&gt; method. The &lt;b&gt;ShowDialog&lt;/b&gt; method brings up the camera interface including the viewfinder of the camera. There really isn’t much you can do with this interface, but fortunately you don’t need to. When the &lt;b&gt;ShowDialog&lt;/b&gt; method returns, the class has already written the image to a file. What file? A file is created with the name specified in &lt;b&gt;DefaultFileName&lt;/b&gt; property. If a file with the same file name already exists it is overwritten. For a consumer application this would be unacceptable, so a method was added to prevent this.&lt;/p&gt;

&lt;p&gt;Imagine you are at a friend’s wedding. You capture a picture that exemplifies the specialness of the event. Later, you go to take a picture of one of your friends acting goofy at the reception. Without purposely creating some sort of file versioning logic, you are going to lose the original image. To address this issue, the &lt;i&gt;CameraFileUtilities&lt;/i&gt; class and a static method called &lt;b&gt;incrementFileNameNumber&lt;/b&gt; are included with the project. This method performs a check to determine if a file with the same name exists. If one does, it increments the version number by one.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; incrementFileNameNumber(&lt;span class="kwrd"&gt;string&lt;/span&gt; file)
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt; newFileName;
    &lt;span class="kwrd"&gt;int&lt;/span&gt; fileVersionNumber = 0;

    FileInfo fileInfo = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileInfo(file);
    newFileName = fileInfo.FullName;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (File.Exists(newFileName))
    {
        &lt;span class="kwrd"&gt;do&lt;/span&gt;
      {
        newFileName = fileInfo.DirectoryName + &lt;span class="str"&gt;&amp;quot;\\&amp;quot; + &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color="#000000"&gt;fileInfo.Name.Replace(fileInfo.Extension, &amp;quot;&lt;/font&gt;&lt;/span&gt;&amp;quot;) + (++fileVersionNumber) + fileInfo.Extension;
      }
      &lt;span class="kwrd"&gt;while&lt;/span&gt; (File.Exists(newFileName));
    }

    &lt;span class="kwrd"&gt;return&lt;/span&gt; newFileName;
}&lt;/pre&gt;

&lt;p&gt;There are many strategies you could employ here, but appending an integer value to the end of the file name before the extension is probably the simplest. We actually delete the file created by &lt;i&gt;CameraCaptureDialog&lt;/i&gt;. That is because we are applying a filter to the still image that we have captured. Even if we are applying the Color filter to the image, we want to call the &lt;i&gt;ICameraFilter&lt;/i&gt; interface and use the &lt;b&gt;Apply&lt;/b&gt; method. Since the &lt;b&gt;Apply&lt;/b&gt; method returns an instance of the &lt;i&gt;Bitmap&lt;/i&gt; class, we use the short hand of call &lt;b&gt;Save&lt;/b&gt; on the &lt;i&gt;Bitmap&lt;/i&gt; instance.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;ICameraFilter filter = GetPictureFilter(cameraCapture.FileName);
&lt;span class="kwrd"&gt;string&lt;/span&gt; saveFileName = CameraFileUtilities.incrementFileNameNumber(fileName);
filter.Apply().Save(saveFileName, ImageFormat.Jpeg);
File.Delete(cameraCapture.FileName);&lt;/pre&gt;

&lt;p&gt;The &lt;i&gt;ICameraFilter&lt;/i&gt; is an interface. We are using this interface in a way that roughly resembles the Gang of Four Abstract Factory design pattern. The interface allows us to handle the &lt;i&gt;ColorFilter&lt;/i&gt; class, the &lt;i&gt;BlackAndWhiteFilter&lt;/i&gt; class, and the &lt;i&gt;SepiaFilter&lt;/i&gt; class in same way at runtime. Because they all implement the &lt;i&gt;ICameraFilter&lt;/i&gt; interface, we don’t even care which one is selected, they all adhere to the contract defined in the &lt;i&gt;ICameraFilter&lt;/i&gt; interface. This allows receiving the correct class already instantiated (in other word: built), hence it is a factory pattern. &lt;/p&gt;

&lt;h2&gt;The ICameraFilter Interface and Filter Implementations&lt;/h2&gt;

&lt;p&gt;The ICameraFilter interface is very simple. We are only expecting each filter to return a bitmap. &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; ICameraFilter
{
   Bitmap Apply();
}&lt;/pre&gt;

&lt;p&gt;The actual implementation of the filters is little bit more complicated. Let’s look at the code for the BlackAndWhiteFilter class. &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; BlackAndWhiteFilter : ICameraFilter
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; _fileName;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; BlackAndWhiteFilter(&lt;span class="kwrd"&gt;string&lt;/span&gt; fileName)
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (!File.Exists(fileName))
        {
            &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ApplicationException(
    &lt;span class="str"&gt;&amp;quot;Cannot apply Camera filter to a file that doesn't exist&amp;quot;&lt;/span&gt;);
        }
        &lt;span class="kwrd"&gt;else&lt;/span&gt;
        {
            &lt;span class="kwrd"&gt;this&lt;/span&gt;._fileName = fileName;
        }
    }

    &lt;span class="preproc"&gt;#region&lt;/span&gt; ICameraFilter Members

    &lt;span class="kwrd"&gt;public&lt;/span&gt; Bitmap Apply()
    {
        Bitmap newBitmap;

        &lt;span class="kwrd"&gt;using&lt;/span&gt; (Bitmap original = &lt;span class="kwrd"&gt;new&lt;/span&gt; Bitmap(_fileName))
        {
            &lt;span class="rem"&gt;//make an empty Bitmap the same size as original&lt;/span&gt;
            newBitmap =
               &lt;span class="kwrd"&gt;new&lt;/span&gt; Bitmap(original.Width, original.Height);

            &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; original.Width; i++)
            {
                &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; j = 0; j &amp;lt; original.Height; j++)
                {
                    &lt;span class="rem"&gt;//get the pixel color from the original image&lt;/span&gt;
                    Color originalColor = original.GetPixel(i, j);

                    &lt;span class="rem"&gt;//create the grayscale pixel value&lt;/span&gt;
                    &lt;span class="kwrd"&gt;int&lt;/span&gt; grayScale =
                       (&lt;span class="kwrd"&gt;int&lt;/span&gt;)((originalColor.R * .3) +
                              (originalColor.G * .59) +
                              (originalColor.B * .11));

                    &lt;span class="rem"&gt;//create the color object&lt;/span&gt;
                    Color newColor =
                       Color.FromArgb(grayScale, grayScale, grayScale);

                    &lt;span class="rem"&gt;//set the new image's pixel to the grayscale pixel //value&lt;/span&gt;
                    newBitmap.SetPixel(i, j, newColor);
                }
            }
        }
        &lt;span class="kwrd"&gt;return&lt;/span&gt; newBitmap;
    }

    &lt;span class="preproc"&gt;#endregion&lt;/span&gt;
}&lt;/pre&gt;

&lt;p&gt;In the &lt;i&gt;BlackAndWhiteFilter&lt;/i&gt;, we are creating a grayscale version of the image we received from the &lt;i&gt;CaptureCameraDialog&lt;/i&gt; class. The code adjusts every pixel, removing the red, green, and blue values from the pixel. This would actually be one of the least efficient ways to process the image if we were using the full .NET framework. However, we are using the .NET Compact Framework and this is one area where the differences become obvious. Using the full .NET Framework we would make use of the &lt;i&gt;ColorMatrix&lt;/i&gt; class. The &lt;i&gt;ColorMatrix&lt;/i&gt; class is not available in the .NET Compact Framework and is rather complex to use. However, it is used commonly and most code samples involving grayscale will employ this method, so it is important to know about its existence. &lt;/p&gt;

&lt;p&gt;The &lt;i&gt;SepiaFilter&lt;/i&gt; is very much like the &lt;i&gt;BlackAndWhiteFilter&lt;/i&gt;, with a couple of changes in the 2nd for loop.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Color originalColor = original.GetPixel(i, j);

&lt;span class="kwrd"&gt;double&lt;/span&gt; outputRed = (originalColor.R * .393) + (originalColor.G * .769) + (originalColor.B * .189);
&lt;span class="kwrd"&gt;double&lt;/span&gt; outputGreen = (originalColor.R * .349) + (originalColor.G * .686) + (originalColor.B * .168);
&lt;span class="kwrd"&gt;double&lt;/span&gt; outputBlue = (originalColor.R * .272) + (originalColor.G * .534) + (originalColor.B * .131);

&lt;span class="kwrd"&gt;int&lt;/span&gt; ioutputRed = Convert.ToInt16(outputRed);
&lt;span class="kwrd"&gt;int&lt;/span&gt; ioutputGreen = Convert.ToInt16(outputGreen);
&lt;span class="kwrd"&gt;int&lt;/span&gt; ioutputBlue = Convert.ToInt16(outputBlue);                        

&lt;span class="kwrd"&gt;if&lt;/span&gt; (ioutputRed &amp;gt; 255)
      ioutputRed = 255;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (ioutputGreen &amp;gt; 255)
    ioutputGreen = 255;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (ioutputBlue &amp;gt; 255)
    ioutputBlue = 255;&lt;/pre&gt;

&lt;p&gt;Since the filters are located in a Mobile Device Library, we can test the filters without using the mobile device camera. You simple create a test project and reference the library. Visual Studio will give a warning about using a mobile library with a test project. We ignored the warning without any ramifications. If you are concerned, paste the filters in a regular Windows Library project.&lt;/p&gt;

&lt;p&gt;Once the filter has been applied, the image is written to … where? If you haven’t set the main form to use a specific directory location, a default location will be set when the main form initializes. Since it is always unwise to assume the directory layout of any system, the code uses an environment defined enum that can be used to retrieve the initial path: &lt;i&gt;Environment&lt;/i&gt;.&lt;b&gt;SpecialFolder.Personal&lt;/b&gt;. Using this enum, we can retrieve the user’s personal directory.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; _personaldirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; PersonalDirectory
{
      get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _personaldirectory; }
}&lt;/pre&gt;

&lt;h6&gt;&lt;/h6&gt;

&lt;h6&gt;&lt;/h6&gt;

&lt;h2&gt;Directory Browser Form&lt;/h2&gt;

&lt;p&gt;The compact framework doesn't ship with a directory browser dialog. This makes it difficult for the user to configure the target storage location for the pictures. As this is a common problem when working in a Windows Mobile Smart Phone environment, a Directory Browser form has been added to the project. The form simply allows the user to browse the local file system and select an appropriate storage location for the images.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/clip_image017%5B7%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image017[7]" border="0" alt="clip_image017[7]" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/clip_image017%5B7%5D_thumb.jpg" width="162" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The form itself consists of a &lt;b&gt;TreeView&lt;/b&gt; control and a label to display the currently selected path. On initialization the form calls the &lt;b&gt;PopulateTree&lt;/b&gt; method which, as the name suggests, populates the &lt;b&gt;TreeView&lt;/b&gt; control:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; PopulateTree(&lt;span class="kwrd"&gt;string&lt;/span&gt; directoryValue, TreeNode parentNode)
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt;[] directoryArray = Directory.GetDirectories(directoryValue);

    &lt;span class="kwrd"&gt;try&lt;/span&gt;
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (directoryArray.Length != 0)
        {
            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt; directory &lt;span class="kwrd"&gt;in&lt;/span&gt; directoryArray)
            {
                substringDirectory = directory.Substring(
                directory.LastIndexOf(&lt;span class="str"&gt;'\\')&lt;font color="#000000"&gt; + 1,
                directory.Length - directory.LastIndexOf(&lt;/font&gt;&lt;span class="str"&gt;'\\'&lt;/span&gt;&lt;/span&gt;) - 1);

                TreeNode myNode = &lt;span class="kwrd"&gt;new&lt;/span&gt; TreeNode(substringDirectory);
                myNode.ImageIndex = 0;
                myNode.SelectedImageIndex = 1;

                parentNode.Nodes.Add(myNode);

                PopulateTree(directory, myNode);
            }
        }
    }
    &lt;span class="kwrd"&gt;catch&lt;/span&gt; (UnauthorizedAccessException)
    {
        parentNode.Nodes.Add(&lt;span class="str"&gt;&amp;quot;Access denied&amp;quot;&lt;/span&gt;);
    } &lt;span class="rem"&gt;// end catch&lt;/span&gt;
}&lt;/pre&gt;

&lt;p&gt;This method recursively walks the file system starting at the root to build a complete directory tree. It also has some rudimentary error handling for unauthorized file system nodes.&lt;/p&gt;

&lt;p&gt;The C4FCamera application employs this directory browser on the main configuration form. The user simply selects the target directory on the tree. The path of this directory is stored as a string in the &lt;b&gt;SelectedDirectory&lt;/b&gt; property of the form. On return, the configuration form uses the property to fetch the desired target path:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnSetPictureDirectory_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
{
    DirectoryBrowser directory = &lt;span class="kwrd"&gt;new&lt;/span&gt; DirectoryBrowser();
    directory.ShowDialog();
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (directory.DialogResult == DialogResult.OK
        &amp;amp;&amp;amp; directory.SelectedDirectory != &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty)
    {
        PictureDirectoryPath.Text = directory.SelectedDirectory;
    }
}&lt;/pre&gt;

&lt;p&gt;Building a directory browser is a simple way to add greater usability to your application.&lt;/p&gt;

&lt;h2&gt;Browse Pictures Form&lt;/h2&gt;

&lt;p&gt;In addition to the directory browser the application needs a simple way for users to be able to browse the results of their photography. To achieve this, a basic image browser was added to the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/clip_image021%5B7%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image021[7]" border="0" alt="clip_image021[7]" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingaFullFeaturedMobileCameraApplica_FB33/clip_image021%5B7%5D_thumb.jpg" width="158" height="240" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Browse Pictures form provides the ability to view and delete images that are stored in the application's picture storage path. On initialization the form calls the &lt;b&gt;InitializeViewer&lt;/b&gt; method. This method checks the file type of each file in the storage directory. If the file is an image, the file name is added to a &lt;b&gt;ComboBox&lt;/b&gt; list and the first image file is loaded in a &lt;b&gt;PictureBox&lt;/b&gt; control:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; InitializeViewer(&lt;span class="kwrd"&gt;string&lt;/span&gt; directory)
{
    &lt;span class="kwrd"&gt;bool&lt;/span&gt; filesFound = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
    dropdownPictures.Items.Clear();
    InitialDirectory = directory;
    &lt;span class="kwrd"&gt;string&lt;/span&gt;[] files = Directory.GetFiles(InitialDirectory);
    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt; file &lt;span class="kwrd"&gt;in&lt;/span&gt; files)
    {
        FileInfo fileinfo = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileInfo(file);
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (fileinfo.Extension.ToLower() == &lt;span class="str"&gt;&amp;quot;.jpg&amp;quot;&lt;/span&gt; ||
        fileinfo.Extension.ToLower() == &lt;span class="str"&gt;&amp;quot;.bmp&amp;quot;&lt;/span&gt; ||
        fileinfo.Extension.ToLower() == &lt;span class="str"&gt;&amp;quot;.jpeg&amp;quot;&lt;/span&gt;)
        {
            dropdownPictures.Items.Add(fileinfo.Name);
            filesFound = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
        }

    }

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (filesFound)
    {
        &lt;span class="kwrd"&gt;string&lt;/span&gt; file = files[0];
        Bitmap picture = &lt;span class="kwrd"&gt;new&lt;/span&gt; Bitmap(file);
        pictureViewer.Image = picture;
        dropdownPictures.SelectedIndex = 0;
    }
}&lt;/pre&gt;

&lt;p&gt;A user can navigate the images in the directory by changing the selection in the &lt;b&gt;ComboBox&lt;/b&gt;. The currently selected image can be deleted by selecting &lt;b&gt;Delete&lt;/b&gt; in the form menu.&lt;/p&gt;

&lt;p&gt;The Picture Browser can be accessed through the application’s main menu.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;This article has shown you how to use an internal mobile camera with the .NET Compact Framework. The resulting application also addresses some of the limitations imposed by the mobile platform by presenting a basic directory browser. Additionally, it introduces some common image filtering methods for grayscale and sepia toned photos. Hopefully this will inspire you to go forward and create your own Windows Mobile applications.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9725275" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows+mobile/default.aspx">windows mobile</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/image+manipulation/default.aspx">image manipulation</category></item><item><title>Want more cowbell? Yes please!</title><link>http://blogs.msdn.com/coding4fun/archive/2008/11/10/9059259.aspx</link><pubDate>Tue, 11 Nov 2008 07:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9059259</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9059259.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9059259</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9059259</wfw:comment><description>
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=470 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Author:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;Clint Rutkas: &lt;A href="http://twitter.com/crutkas" mce_href="http://twitter.com/crutkas"&gt;twitter&lt;/A&gt;, &lt;A href="http://betterthaneveryone.com/" mce_href="http://betterthaneveryone.com/"&gt;blog&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Download:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;&lt;A class="" href="http://peacelovecode.com/code/cowbell/cowbell.zip" mce_href="http://peacelovecode.com/code/cowbell/cowbell.zip"&gt;http://peacelovecode.com/code/cowbell/cowbell.zip&lt;/A&gt; &lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Software:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;&lt;A href="http://msdn.microsoft.com/en-us/evalcenter/bb655861.aspx" mce_href="http://msdn.microsoft.com/en-us/evalcenter/bb655861.aspx"&gt;Visual Studio 2008 Standard&lt;/A&gt; or better (Trial Download) &lt;BR&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=06111A3A-A651-4745-88EF-3D48091A390B&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=06111A3A-A651-4745-88EF-3D48091A390B&amp;amp;displaylang=en"&gt;Windows Mobile 6.0 SDK &lt;BR&gt;Windows Mobile 6.1 Emulator Images (Optional)&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Hardware:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;Windows Mobile Pro (Optional)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Time Required:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;2 hours&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Cost:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;Free-ish&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;After playing way too much guitar hero, bought a guitar only to quickly realize I’m horrible.&amp;nbsp; Asking my friends, I decided to adopt the world’s hardest instrument to play, that’s right, the cow bell.&amp;nbsp; It takes years to master and I decide to turn my cell phone, an HTC Touch Diamond&amp;nbsp; into this magical instrument too.&lt;/P&gt;
&lt;P&gt;This is a fairly straight forward application.&amp;nbsp; We’ll touch on altering the volume of a cell phone along with interacting with a touch screen and how to do a deploy for Windows Mobile so you can have a cowbell band of your own.&amp;nbsp; The application will also properly resize an image to match the screen proportions, however you’ll have to download the source code for that.&lt;/P&gt;
&lt;P&gt;You’ll see while getting your system up and working with the emulator may take a few additional steps, it will code mostly like a typical windows application for this instance.&lt;/P&gt;
&lt;P&gt;The source code shown isn’t everything you need to get the application running, please download the source code to get the rest.&amp;nbsp; The link is at the top of the article.&lt;/P&gt;
&lt;H2&gt;Getting up and running with baby steps&lt;/H2&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image.png" mce_href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image.png"&gt;&lt;IMG title=image style="DISPLAY: inline; MARGIN: 0px 0px 0px 10px" height=351 alt=image src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb.png" width=229 align=right border=0 mce_src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb.png"&gt;&lt;/A&gt;After you get Visual Studio 2008 up and running, if you don’t have the Windows Mobile 6.0 SDK, please download it and install it.&amp;nbsp; The link is at the top of this article.&amp;nbsp; Visual Studio 2008 only comes with the Windows mobile 5.0 SDK.&lt;/P&gt;
&lt;P&gt;On the right is a picture of the emulator in one of styling forms.&amp;nbsp; On top of just being able to test on an emulator, you can do a direct deploy to your cell phone.&amp;nbsp; Now a Windows Mobile Professional phone can do this directly, however a Windows Mobile Standard (non-touch screen) does require a few extra steps.&amp;nbsp; I blogged about these steps over on my blog.&amp;nbsp; After your phone is properly configured, all you need to do is change your target deployment.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_3.png" mce_href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_3.png"&gt;&lt;IMG title=image style="DISPLAY: inline" height=155 alt=image src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_3.png" width=378 border=0 mce_src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I highlighted the device deploy instead of the emulator.&lt;/P&gt;
&lt;H2&gt;Smart Device Creation&lt;/H2&gt;
&lt;P&gt;To create a new solution we go to File –&amp;gt; New –&amp;gt; Project.&amp;nbsp; We’ll select the language of our choice (c# for me) then go to “Smart Device”&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.betterthaneveryone.com/images/WindowsMobileDevelopmentGettingStartedS_223A/image.png" mce_href="http://www.betterthaneveryone.com/images/WindowsMobileDevelopmentGettingStartedS_223A/image.png"&gt;&lt;IMG title=image height=313 alt=image src="http://www.betterthaneveryone.com/images/WindowsMobileDevelopmentGettingStartedS_223A/image_thumb.png" width=500 border=0 mce_src="http://www.betterthaneveryone.com/images/WindowsMobileDevelopmentGettingStartedS_223A/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Easy so far, right?&amp;nbsp; Next comes selecting the framework along with your target platform.&amp;nbsp; Select “Windows Mobile 6 Professional SDK” then click OK and you’re good to start.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_4.png" mce_href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_4.png"&gt;&lt;IMG title=image style="DISPLAY: inline" height=243 alt=image src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_4.png" width=500 border=0 mce_src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_4.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;H2&gt;Altering Volume&lt;/H2&gt;
&lt;P&gt;To alter your volume currently in the compact framework, you have to do some pinvokes to call native API calls.&amp;nbsp; This is scary for some but don’t fret.&amp;nbsp; There is a site called &lt;A href="http://pinvoke.net/" mce_href="http://pinvoke.net"&gt;pinvoke.net&lt;/A&gt; that makes doing these calls simple as pie.&amp;nbsp; We’ll create a new class called Audio to encapsulate all audio functions.&amp;nbsp; This includes playing a file and altering the volume.&amp;nbsp; First we’ll do the simple ability to play an audio file.&amp;nbsp; Since we’ll be grabbing our data from the resources, we’ll use a &lt;STRONG&gt;MemoryStream&lt;/STRONG&gt; object convert the bytes to a stream so we can read it in.&amp;nbsp; We’ll need to include the &lt;STRONG&gt;System.Media &lt;/STRONG&gt;namespace to be able to play audio.&amp;nbsp; To do the pinvokes, we’ll include the &lt;STRONG&gt;System.Runtime.InteropServices.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;C#&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;readonly&lt;/SPAN&gt; SoundPlayer sp;

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; Audio(&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;[] AudioResource)
    {
        sp = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; SoundPlayer(&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; MemoryStream(AudioResource));
        sp.Load();
    }

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Play()
    {
        sp.Play();
    }

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; PlayLoop()
    {
        sp.PlayLooping();
    }

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Stop()
    {
        sp.Stop();
    }&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;VB&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;ReadOnly&lt;/SPAN&gt; sp &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; SoundPlayer

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; AudioResource &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Byte&lt;/SPAN&gt;())
        sp = &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; SoundPlayer(&lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; MemoryStream(AudioResource))
        sp.Load()
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; Play()
        sp.Play()
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; PlayLoop()
        sp.PlayLooping()
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; [&lt;SPAN class=kwrd&gt;Stop&lt;/SPAN&gt;]()
        sp.[&lt;SPAN class=kwrd&gt;Stop&lt;/SPAN&gt;]()
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; Sub&lt;/PRE&gt;
&lt;P&gt;And in the application, we’ll call the audio file like the following:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;c#&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;readonly&lt;/SPAN&gt; Audio audio = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Audio(Properties.Resources.CowBellAudio);&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;VB&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;ReadOnly&lt;/SPAN&gt; audio &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; Audio(My.Resources.CowBellAudio)&lt;/PRE&gt;
&lt;P&gt;Next we’ll add in the ability to alter the volume with the pinvokes.&amp;nbsp; Sadly, I’m not sure why the set volume numbers act as they do.&amp;nbsp; After searching the internet, these numbers kept appearing.&amp;nbsp; In a perfect world, I would have liked to see 0 to 100 or something like that but it isn’t so.&amp;nbsp; We’ll create get / sets in the wrapper to make a more seamless wrapper object to hide the pinvoke calls.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;C#&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    [DllImport(&lt;SPAN class=str&gt;"coredll.dll"&lt;/SPAN&gt;)]
    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;extern&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; waveOutGetVolume(IntPtr hwo, &lt;SPAN class=kwrd&gt;out&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;uint&lt;/SPAN&gt; dwVolume);

    [DllImport(&lt;SPAN class=str&gt;"coredll.dll"&lt;/SPAN&gt;)]
    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;extern&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; waveOutSetVolume(IntPtr hwo, &lt;SPAN class=kwrd&gt;uint&lt;/SPAN&gt; dwVolume);

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;uint&lt;/SPAN&gt; Volume
    {
        get
        {
            &lt;SPAN class=kwrd&gt;uint&lt;/SPAN&gt; _volume;
            waveOutGetVolume(IntPtr.Zero, &lt;SPAN class=kwrd&gt;out&lt;/SPAN&gt; _volume);
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; _volume;
        }

        set
        {
            waveOutSetVolume(IntPtr.Zero, &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;);
        }
    }

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;enum&lt;/SPAN&gt; Volumes
    {
        OFF = 0,
        LOW = 858993459,
        NORMAL = 1717986918,
        MEDIUM = -1717986919,
        HIGH = -858993460,
        VERY_HIGH = -1
    }&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;VB&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;Declare&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Function&lt;/SPAN&gt; waveOutGetVolume &lt;SPAN class=kwrd&gt;Lib&lt;/SPAN&gt; &lt;SPAN class=str&gt;"coredll.dll"&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; uDeviceID &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByRef&lt;/SPAN&gt; lpdwVolume &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;) &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;Declare&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Function&lt;/SPAN&gt; waveOutSetVolume &lt;SPAN class=kwrd&gt;Lib&lt;/SPAN&gt; &lt;SPAN class=str&gt;"coredll.dll"&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; device &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; IntPtr, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; volume &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;) &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Shared&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Property&lt;/SPAN&gt; AudioVolume() &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;Get&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; _volume &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;
            waveOutGetVolume(IntPtr.Zero, _volume)
            &lt;SPAN class=kwrd&gt;Return&lt;/SPAN&gt; _volume
        &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Get&lt;/SPAN&gt;

        &lt;SPAN class=kwrd&gt;Set&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; value &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;)
            waveOutSetVolume(IntPtr.Zero, value)
        &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Set&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Property&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Enum&lt;/SPAN&gt; Volumes
        OFF = 0
        LOW = 858993459
        NORMAL = 1717986918
        MEDIUM = -1717986919
        HIGH = -858993460
        VERY_HIGH = -1
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; Enum&lt;/PRE&gt;
&lt;H2&gt;Creating the Cowbell&lt;/H2&gt;
&lt;H3&gt;Pretty Pictures and sounds&lt;/H3&gt;
&lt;P&gt;This is a cowbell application so we need an actual cowbell on it.&amp;nbsp; After a quick image search, I found the cowbell image on the internet and the X is from the &lt;A href="http://www.famfamfam.com/lab/icons/silk/" mce_href="http://www.famfamfam.com/lab/icons/silk/"&gt;Famfamfam Silk icon collection&lt;/A&gt;.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;We’ll want to embed these images to make deployment easier and have everything self-contained so we’ll use the resource in the project’s property tab.&amp;nbsp; To reach this, you go to &lt;STRONG&gt;Project-&amp;gt;Properties &lt;/STRONG&gt;or right click on your project and at the bottom, there is the Properties menu option.&lt;/P&gt;
&lt;P&gt;In here, we’ll want to use the Images section along with the audio section.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_5.png" mce_href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_5.png"&gt;&lt;IMG title=image style="DISPLAY: inline" height=178 alt=image src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_5.png" width=200 border=0 mce_src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_5.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;When you select the section you want, click the &lt;STRONG&gt;Add Resource&lt;/STRONG&gt; button and track down the file you need.&amp;nbsp; Referencing these resources is pretty straight forward now but each language has a slightly different way to do it.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;C#&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    Properties.Resources.cowBellImage;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;VB&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    My.Resources.cowBellImage&lt;/PRE&gt;
&lt;P&gt;Easy no?&lt;/P&gt;
&lt;H3&gt;Items on the form&lt;/H3&gt;
&lt;P&gt;We’ll want to turn off some elements on the form to maximize the cowbell.&amp;nbsp; We’ll set the &lt;STRONG&gt;WindowState&lt;/STRONG&gt; to Maximum, &lt;STRONG&gt;TopMost&lt;/STRONG&gt; to True, &lt;STRONG&gt;MinimizeBox&lt;/STRONG&gt; to False and &lt;STRONG&gt;FormBorder&lt;/STRONG&gt; to None.&lt;/P&gt;
&lt;P&gt;We’ll drag on two picture boxes on the form naming them &lt;STRONG&gt;picCowbell &lt;/STRONG&gt;and &lt;STRONG&gt;picClose&lt;/STRONG&gt;.&amp;nbsp; We’ll set the background to both elements to be transparent.&amp;nbsp; We’ll also want to double click on each picture boxes to create a Click event.&amp;nbsp; For the &lt;STRONG&gt;picClose &lt;/STRONG&gt;element, we’ll add in the &lt;STRONG&gt;Close()&lt;/STRONG&gt; method to shut down the application.&lt;/P&gt;
&lt;P&gt;We’ll also create a MouseDown event on the picCowbell.&amp;nbsp; Here we’ll determine how loud to play then play the sound.&amp;nbsp; We’ll create the Audio object during the form creation so it is already loaded into memory and will only be created once.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;C#&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;readonly&lt;/SPAN&gt; Audio audio = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Audio(Properties.Resources.CowBellAudio);
&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; picCowbell_MouseDown(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, MouseEventArgs e)
{
    Audio.Volumes &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;;
    &lt;SPAN class=kwrd&gt;switch&lt;/SPAN&gt; ((&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;)Math.Round((e.Y / (Height * 1.0)) * 5))
    {
        &lt;SPAN class=rem&gt;//case 0: // implied with default;&lt;/SPAN&gt;
        &lt;SPAN class=rem&gt;//case 1:&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;default&lt;/SPAN&gt;:
            &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; = Audio.Volumes.LOW;
            &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
        &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; 2:
            &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; = Audio.Volumes.NORMAL;
            &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
        &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; 3:
            &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; = Audio.Volumes.MEDIUM;
            &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
        &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; 4:
            &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; = Audio.Volumes.HIGH;
            &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
        &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; 5:
            &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; = Audio.Volumes.VERY_HIGH;
            &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
    }

    &lt;SPAN class=rem&gt;// no need to take the performance hit of changing the volume&lt;/SPAN&gt;
    &lt;SPAN class=rem&gt;// if the values aren't different&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( oldValue != &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;)
    {
        Audio.Volume = (&lt;SPAN class=kwrd&gt;uint&lt;/SPAN&gt;) &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;;
        oldValue = &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;;
    }
    audio.Play();
}&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;VB&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;ReadOnly&lt;/SPAN&gt; audio &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; Audio(My.Resources.CowBellAudio)
&lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; picCowbell_MouseDown(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; System.&lt;SPAN class=kwrd&gt;Object&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; System.Windows.Forms.MouseEventArgs)
    &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; value &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; Audio.Volumes
    &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; Convert.ToInt32(Math.Round((e.Y / (Height * 1)) * 5))
        &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; 2
            value = audio.Volumes.NORMAL
            &lt;SPAN class=kwrd&gt;Exit&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; 3
            value = audio.Volumes.MEDIUM
            &lt;SPAN class=kwrd&gt;Exit&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; 4
            value = audio.Volumes.HIGH
            &lt;SPAN class=kwrd&gt;Exit&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; 5
            value = audio.Volumes.VERY_HIGH
            &lt;SPAN class=kwrd&gt;Exit&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Else&lt;/SPAN&gt;
            &lt;SPAN class=rem&gt;'case 0: // implied with default;&lt;/SPAN&gt;
            &lt;SPAN class=rem&gt;'case 1:&lt;/SPAN&gt;
            value = audio.Volumes.LOW
            &lt;SPAN class=kwrd&gt;Exit&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;

    &lt;SPAN class=rem&gt;' no need to take the performance hit of changing the volume&lt;/SPAN&gt;
    &lt;SPAN class=rem&gt;' if the values aren't different&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt; oldValue &amp;lt;&amp;gt; value &lt;SPAN class=kwrd&gt;Then&lt;/SPAN&gt;
        audio.AudioVolume = Convert.ToInt32(value)
        oldValue = value
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt;
    audio.Play()
&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; Sub&lt;/PRE&gt;
&lt;H2&gt;Hailing a CAB for deployment&lt;/H2&gt;
&lt;P&gt;We’ll right click on the solution in the solution explorer or we can go to File-&amp;gt;New-&amp;gt;Project.&amp;nbsp; If you do the file menu route, you’ll have a screen that is slightly different than mine.&amp;nbsp; At the bottom you’ll have a drop down menu where you’ll want to change it from “Create a new solution” to “Add to Solution”.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image.png" mce_href="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image.png"&gt;&lt;IMG title=image style="DISPLAY: inline" height=298 alt=image src="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_thumb.png" width=500 border=0 mce_src="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Since I want a CAB install, I’ll go to the “Other Project Types” then to “Setup and Deployment” and select a Smart Device CAB Project”.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From there, right click on “Application Folder” and go to “Add”.&amp;nbsp; Select “Primary Output” and hit OK.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_3.png" mce_href="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_3.png"&gt;&lt;IMG title=image style="DISPLAY: inline" height=435 alt=image src="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_thumb_3.png" width=377 border=0 mce_src="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;So with the output added in now, we’ll need to do some more magic.&amp;nbsp; In the “File System” window, we’ll right-click on “File System on Target Machine” and go “Add Special Folder” then to “Start Menu Folder”.&lt;/P&gt;
&lt;P&gt;Now that we have our start menu, we’ll go back to the “Application Menu” and right click on the “Primary output from Cowbell”.&amp;nbsp; Select “Create Shortcut” and drag that shortcut to your start menu folder.&amp;nbsp; I suggest you rename it too.&lt;/P&gt;
&lt;P&gt;Then you can build it, drag the CAB over and install on your device.&lt;/P&gt;
&lt;H2&gt;Rocking out&lt;/H2&gt;
&lt;P&gt;To download the application’s full source code, please download it from &lt;A class="" href="http://peacelovecode.com/code/cowbell/cowbell.zip" mce_href="http://peacelovecode.com/code/cowbell/cowbell.zip"&gt;http://peacelovecode.com/code/cowbell/cowbell.zip&lt;/A&gt; &lt;/TD&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image14.png" mce_href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image14.png"&gt;&lt;IMG title=image style="DISPLAY: inline; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px" height=334 alt=image src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image14_thumb.png" width=240 border=0 mce_src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image14_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;H2&gt;About the Author&lt;/H2&gt;
&lt;P&gt;Clint Rutkas works for Microsoft and has created a few cool projects in the past like a Disco Dance Floor, an automated bartender system and a self-balancing skateboard.&amp;nbsp; His blog is &lt;A href="http://betterthaneveryone.com/" mce_href="http://BetterThanEveryone.com"&gt;http://BetterThanEveryone.com&lt;/A&gt; where he posts about what crazy application idea he is working on next.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9059259" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows+mobile/default.aspx">windows mobile</category></item></channel></rss>