Ejemplo n.º 1
0
        /// <summary>
        /// Start the IR Server plugin.
        /// </summary>
        /// <returns><c>true</c> if successful, otherwise <c>false</c>.</returns>
        public override void Start()
        {
#if TRACE
            Trace.WriteLine("Start MicrosoftMceTransceiver");
#endif

            if (_driver != null)
            {
                throw new InvalidOperationException("MicrosoftMceTransceiver already started");
            }

            _config = new Config();
            ConfigManagement.LoadSettings(ref _config);

            // Put this in a try...catch so that if the registry keys don't exist we don't throw an ugly exception.
            try
            {
                _ignoreAutomaticButtons = CheckAutomaticButtons();
            }
            catch
            {
                _ignoreAutomaticButtons = false;
            }

            if (_config._disableMceServices)
            {
                DisableMceServices();
            }

            Guid   deviceGuid;
            string devicePath;

            Driver newDriver = null;

            if (FindDevice(out deviceGuid, out devicePath))
            {
                if (deviceGuid == MicrosoftGuid)
                {
                    if (Environment.OSVersion.Version.Major >= VistaVersionNumber)
                    {
                        newDriver = new DriverVista(deviceGuid, devicePath, RemoteEvent, KeyboardEvent, MouseEvent);
                    }
                    else
                    {
                        newDriver = new DriverXP(deviceGuid, devicePath, RemoteEvent, KeyboardEvent, MouseEvent);
                    }
                }
                else
                {
                    newDriver = new DriverReplacement(deviceGuid, devicePath, RemoteEvent, KeyboardEvent, MouseEvent);
                }
            }
            else
            {
                throw new InvalidOperationException("Device not found");
            }

            newDriver.Start();

            _driver = newDriver;
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Start the IR Server plugin.
    /// </summary>
    /// <returns><c>true</c> if successful, otherwise <c>false</c>.</returns>
    public override void Start()
    {
#if TRACE
      Trace.WriteLine("Start MicrosoftMceTransceiver");
#endif

      if (_driver != null)
        throw new InvalidOperationException("MicrosoftMceTransceiver already started");

      _config = new Config();
      ConfigManagement.LoadSettings(ref _config);

      // Put this in a try...catch so that if the registry keys don't exist we don't throw an ugly exception.
      try
      {
        _ignoreAutomaticButtons = CheckAutomaticButtons();
      }
      catch
      {
        _ignoreAutomaticButtons = false;
      }

      if (_config._disableMceServices)
        DisableMceServices();

      Guid deviceGuid;
      string devicePath;

      Driver newDriver = null;

      if (FindDevice(out deviceGuid, out devicePath))
      {
        if (deviceGuid == MicrosoftGuid)
        {
          if (Environment.OSVersion.Version.Major >= VistaVersionNumber)
            newDriver = new DriverVista(deviceGuid, devicePath, RemoteEvent, KeyboardEvent, MouseEvent);
          else
            newDriver = new DriverXP(deviceGuid, devicePath, RemoteEvent, KeyboardEvent, MouseEvent);
        }
        else
        {
          newDriver = new DriverReplacement(deviceGuid, devicePath, RemoteEvent, KeyboardEvent, MouseEvent);
        }
      }
      else
      {
        throw new InvalidOperationException("Device not found");
      }

      newDriver.Start();

      _driver = newDriver;
    }