コード例 #1
0
ファイル: KeyPressService.cs プロジェクト: cpwood/Ukor
        public async Task HandleKeyPress(Application.KeyPress keyPress)
        {
            _logger.LogInformation($"Received KeyPress {keyPress} at {DateTime.Now.ToLongTimeString()}");

            _presses.Enqueue(keyPress);

            while (_presses.Count > _generalOptions.Value.KeySequenceLength)
            {
                _presses.TryDequeue(out _);
            }

            var matched = _applicationOptions.Value.Applications.FirstOrDefault(x =>
                                                                                x.LaunchKeySequence != null && x.LaunchKeySequence.SequenceEqual(_presses));

            if (matched != null)
            {
                _logger.LogInformation($"Launching '{matched.Name}' application..");
                _presses.Clear();
                await _appService.DoActionAsync(matched);
            }
        }
コード例 #2
0
ファイル: KeyPressController.cs プロジェクト: cpwood/Ukor
        public async Task <IActionResult> DoKeyPress(Application.KeyPress id)
        {
            await _service.HandleKeyPress(id);

            return(Ok());
        }