Beispiel #1
0
        /// <summary>
        /// Converts the specified raw device info to the <see cref="DeviceInfo"/>.
        /// </summary>
        /// <param name="rawDeviceInfo">The raw device info.</param>
        /// <param name="deviceName">Name of the device.</param>
        /// <param name="deviceHandle">The device handle.</param>
        /// <returns></returns>
        internal static DeviceInfo Convert(ref RawDeviceInformation rawDeviceInfo, string deviceName, IntPtr deviceHandle)
        {
            DeviceInfo deviceInfo = null;

            switch (rawDeviceInfo.Type)
            {
            case DeviceType.HumanInputDevice:
                deviceInfo = new HidInfo(ref rawDeviceInfo, deviceName, deviceHandle);
                break;

            case DeviceType.Keyboard:
                deviceInfo = new KeyboardInfo(ref rawDeviceInfo, deviceName, deviceHandle);
                break;

            case DeviceType.Mouse:
                deviceInfo = new MouseInfo(ref rawDeviceInfo, deviceName, deviceHandle);
                break;

            default:
                throw new InvalidOperationException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Unsupported Device Type [{0}]", (int)rawDeviceInfo.Type));
            }
            return(deviceInfo);
        }
Beispiel #2
0
 /// <summary>
 /// Converts the specified raw device info to the <see cref="DeviceInfo"/>.
 /// </summary>
 /// <param name="rawDeviceInfo">The raw device info.</param>
 /// <param name="deviceName">Name of the device.</param>
 /// <param name="deviceHandle">The device handle.</param>
 /// <returns></returns>
 internal static DeviceInfo Convert(ref RawDeviceInformation rawDeviceInfo, string deviceName, IntPtr deviceHandle)
 {
     DeviceInfo deviceInfo = null;
     switch (rawDeviceInfo.Type)
     {
         case DeviceType.HumanInputDevice:
             deviceInfo = new HidInfo(ref rawDeviceInfo, deviceName, deviceHandle);
             break;
         case DeviceType.Keyboard:
             deviceInfo = new KeyboardInfo(ref rawDeviceInfo, deviceName, deviceHandle);
             break;
         case DeviceType.Mouse:
             deviceInfo = new MouseInfo(ref rawDeviceInfo, deviceName, deviceHandle);
             break;
         default:
             throw new InvalidOperationException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Unsupported Device Type [{0}]", (int)rawDeviceInfo.Type));
     }
     return deviceInfo;
 }