Click here to Skip to main content
15,884,472 members
Articles / Programming Languages / Visual Basic

Windows 7 new features: Step by step in VB.NET and C#

Rate me:
Please Sign up or sign in to vote.
4.85/5 (88 votes)
31 Aug 2010CPOL9 min read 179.2K   4.7K   211  
Explaining all the new must have features in Windows 7 to make your application look shiny and professional, like the new features of the task bar and more.
// Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Runtime.InteropServices.ComTypes;

namespace Microsoft.WindowsAPICodePack.Sensors
{
    /// <summary>
    /// Represents all the data from a single sensor data report.
    /// </summary>
    public class SensorReport
    {
        /// <summary>
        /// Gets the time when the data report was generated.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "TimeStamp")]
        public DateTime TimeStamp
        {
            get
            {
                return timeStamp;
            }
        }

        /// <summary>
        /// Gets the data values in the report.
        /// </summary>
        public SensorData Values
        {
            get
            {
                return sensorData;
            }
        }

        /// <summary>
        /// Gets the sensor that is the source of this data report.
        /// </summary>
        public Sensor Source
        {
            get
            {
                return originator;
            }
        }

        #region implementation 
        private SensorData sensorData = null;
        private Sensor originator = null;
        private DateTime timeStamp = new DateTime( );

        internal static SensorReport FromNativeReport( Sensor originator, ISensorDataReport iReport )
        {

            SYSTEMTIME systemTimeStamp = new SYSTEMTIME( );
            iReport.GetTimestamp( out systemTimeStamp );
            FILETIME ftTimeStamp = new FILETIME( );
            SensorNativeMethods.SystemTimeToFileTime( ref systemTimeStamp, out ftTimeStamp );
            long lTimeStamp = (((long)ftTimeStamp.dwHighDateTime) << 32) + (long)ftTimeStamp.dwLowDateTime;
            DateTime timeStamp = DateTime.FromFileTime( lTimeStamp );

            SensorReport sensorReport = new SensorReport( );
            sensorReport.originator = originator;
            sensorReport.timeStamp = timeStamp;
            sensorReport.sensorData = SensorData.FromNativeReport( originator.internalObject, iReport );            

            return sensorReport;
        }
        #endregion

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer IDS
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions