Example #1
0
 private void InitKeyboardDriver(KeyboardDriverConfig config)
 {
     if (string.IsNullOrEmpty(config.Type))
         throw new ApplicationException("Не определен тип драйвера клавиатуры");
     var driverType = Type.GetType(config.Type);
     if (driverType == null)
         throw new ApplicationException("Не найден тип драйвера клавиатуры " + config.Type);
     if (!driverType.IsImplementInterface(typeof (IKeyboardDriver)))
         throw new ApplicationException(String.Format(
             "Тип драйвера клавиатуры {0} не реализует интерфейс IKeyboardDriver", config.Type));
     if (_driver != null)
     {
         _driver.Dispose();
         _driver = null;
     }
     IKeyboardDriver newDriver;
     try
     {
         newDriver = (IKeyboardDriver) Activator.CreateInstance(driverType);
         newDriver.Init(config, Logger);
         Logger.LogInfo(Message.KeyboardDriverCreated, config.Type);
     }
     catch (Exception ex)
     {
         Logger.LogInfo(Message.KeyboardDriverCreationFailed, config.Type, ex);
         throw;
     }
     _driver = newDriver;
     _driver.KeyPressed += (sender, e) => OnNewDataReady(e.ScanCode, e.TimeStamp);
     _driver.Start();
 }
Example #2
0
 public override void Init(KeyboardDriverConfig config, ILogger logger)
 {
     base.Init(config, logger);
     KeyboardType type;
     var typeStr = config.Settings[DRIVER_KEYBOARD_TYPE];
     if (typeStr != null)
         type = (KeyboardType)Enum.Parse(typeof(KeyboardType), typeStr.Value, true);
     else
         type = KeyboardType.Default;
     _logger.LogInfo(Message.KeyboardType, type, (int)type);
     KeyboardProvider((int)type);
 }
Example #3
0
 public virtual void Init(KeyboardDriverConfig config, ILogger logger)
 {
     _logger = logger;
 }