in

Matt’s Blog

June 2009 - Posts

  • Windows 7 RC Training Kit for Developers

    If you are a developer looking to get a headstart on Windows 7 development you should consider downloading the Windows 7 RC Training Kit for Developers.   The Training Kit includes hands on labs, presentations, and demos demonstrating key windows features such as:

    • Taskbar
    • Libraries
    • Multi Touch
    • Sensors and Location
    • Ribbon
    • Trigger Start Services,
    • Instrumentation and ETW
    • Application Compatability

    To fully utilize the the training resources you need to have:

    Other resources you may also find helpful learning about Windows 7 development include:

    Posted Jun 29 2009, 10:52 AM by mbohn with no comments
    Filed under:
  • Windows 7 Enhanced Default Location Provider

    If you are wanting to experiment with writing code for Windows 7 that leverages the Sensor and Location API, you may be interested in the Enhanced Default Location Provider (eDLP) available from Microsoft on MSDN.   The enhanced default location provider is a WPF application built on top of the Windows 7 Beta SDK and the Windows 7 Sensor and Location Interop Library.

    To use the tool you will need the following prerequisites: 

    1. .NET 3.5 SP1 
    2. Visual Studio 2008
    3. Download and install the Windows 7 Beta SDK -  This is an ISO DVD image.

    You can also find more information on each of these at this link http://code.msdn.microsoft.com/SensorsAndLocation.

    To run the application you need to open the solution for the Windows 7 Sensor and Location Sample Library and build it.

    The next step is to open the solution for the Enhanced Default Location Provider add a reference to the Windows 7 Sensor and Location Interop Sample Library DLL and build the project.

    To use the the application you will need to run the WPF application as an administrator.

     

    To change your location right click on the map.   Clicking the "Save Address" button will save the address as the Windows default location.

     

    Posted Jun 16 2009, 01:41 PM by mbohn with 1 comment(s)
    Filed under:
  • Windows 7 - Accessing Sensors in .NET and C# Example

    In my previous post Setting up the Windows 7 SDK Beta Virtual Light Sensor, I walked through the setup of the Windows 7 SDK Beta, the Virtual Light Sensor,  Windows 7 Sensor and Location Interop Sample Library, and the Sample MSDN Reader application.  

    The Windows 7 SDK Beta provides APIs for interacting with sensors using native code.   If you are a .NET developer the Windows 7 Sensor and Location Interop Sample Library demonstrates how you can access Sensors using managed code.

    In this post, I will walk through the code necessary to retrieve a list of sensors and get data from the Virtual light sensor.  If you want to follow along I would recommend performing the setup outlined in Setting up the Windows 7 SDK Beta Virtual Light Sensor.   This example borrows from the MSDN Reader Demo, the main difference is this example is highly simplified.  It primarily focuses on retrieving sensors and getting data from a sensor.

    The code in this post requires the following prerequisites:

    1. .NET 3.5 SP1 
    2. Visual Studio 2008
    3. Download and install the Windows 7 Beta SDK -  This is an ISO DVD image.
    4. Download and un-zip the Windows 7 Sensor and Location Interop Sample Library.

    The first step you need to perform is building the Interop Sample library.   Open the project file located at UnzipLocation\Windows7IntegrationLibrary_Sensor_and_Location\ Windows7.SensorAndLocation\Windows7.SensorAndLocation.csproj.  Where UnzipLocation is the folder where you unzipped the library.

    Once the project is open, build it and the Windows7.SensorAndLocation.dll should be output to UnzipLocation\Windows7IntegrationLibrary_Sensor_and_Location\Windows7.SensorAndLocation\bin\.

    Now you are ready to create a new .NET project.   Create a new C# Windows Form Application called CSharpLightSensorExample.   The next step is to add a reference to the interop library (Windows7.SensorAndLocation.dll). 

    Now add two labels, a combo box, and a button to the form so that your form looks like this:

    Name the combo box "comboBoxSensors", the button "btnGetDataReport", and the bottom label "labelDataReport".

    Open Form1.cs and add the following using statements to make the Sensor objects available:

    The next step is to initialize the combo box with a list of available sensors.  To do this double click the form to add FormLoad event and add the following code so the event looks like this:

    Note how SensorManager.GetAllSensors() retrieves the list of available sensors.  If you build and run the project now, you should see a list of installed sensors loaded into the combo box.

    The next step is to retrieve a data report from a selected light sensor.  To do that add a button click event to btnGetDataReport and modify the code so that it looks like this:

     

    Line 25 retrieves the selected sensor from the combo box.  In lines 27-30 we check to make sure that the selected sensor is an Ambient Light Sensor.  Without this check the rest of the code might throw an exception for unexpected types of sensors.   Once we have the sensor and are sure it is an ambient light sensor we use the case statement to take action based on the current sensor state.    Lines 35-37 retrieves a data report and sets the label text to the current Lux value.

    Now if you start the virtual light sensor application, and run this form application you can select a sensor and click the button to get the current LUX value reported by the sensor.

     

  • Windows 7 Calculator Features for Developers

    Windows 7 has had several classic programs such as Paint, WordPad, and Calculator updated with new features. The classic Windows Calculator has several enhancements that I find helpful as a developer.   Calculator now includes Standard, Scientific, Programmer, and Statistics modes.   If you need unit conversions you can use the new unit conversion view to convert between almost any unit of measure. 

    As a developer one of my personal favorites, is the addition of the Date Calculation view.  Using this you can determine the difference between two dates, or add or subtract days to a date.  This is quite helpful when debugging date routines in SQL and .NET.

    Other features that may be helpful to developers is the addition of new binary operators (RoR, RoL, and Rsh).   In programmer mode there is also an improved display of binary numbers.  Binary numbers are shown grouped and key bit positions are indicated underneath.

     

Powered by Community Server (Commercial Edition), by Telligent Systems