Beispiel #1
0
 public override void Dispose()
 {
     if (_driver != null)
     {
         _driver.Dispose();
         _driver = null;
     }
     base.Dispose();
 }
Beispiel #2
0
 public override void Dispose()
 {
     if (_driver != null)
     {
         _driver.Dispose();
         _driver = null;
     }
     base.Dispose();
 }
Beispiel #3
0
        public EditorViewModel( IPluginConfigAccessor scrollConfig, IPluginConfigAccessor keyboardTriggerConfig, IKeyboardDriver keyboardHook, IPointerDeviceDriver pointerHook )
        {
            _scrollConfig = scrollConfig;
            _keyboardTriggerConfig = keyboardTriggerConfig;

            _keyboardHook = keyboardHook;
            _pointerHook = pointerHook;
            _currentIndexStrategy = KeyScrollerPlugin.AvailableStrategies.IndexOf(_scrollConfig.User.GetOrSet( "Strategy", "BasicScrollingStrategy" ));
            this.DisplayName = R.ScrollEditor;
        }
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                GraphicsDevice.Initialize();
                _keyboard = new JsKeyboardDriver(JsRuntime);
                _graphics = new GraphicsDeviceManager(this);
                _graphics.IsFullScreen          = false;
                _graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;

                Accelerometer.Initialize();

                await InitializeAsync();
            }
        }
Beispiel #5
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();
        }
Beispiel #6
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();
 }