示例#1
0
        /// <summary>
        /// Display on the screen the paste bare with an animation.
        /// </summary>
        internal void DisplayBar()
        {
            var delayer = new Delayer <object>(TimeSpan.FromMilliseconds(250));

            delayer.Action += (sender, args) =>
            {
                if (Settings.Default.ClosePasteBarWhenMouseIsAway && !CoreHelper.IsUnitTesting())
                {
                    _mouseAndKeyboardHookService              = ServiceLocator.GetService <MouseAndKeyboardHookService>();
                    _mouseAndKeyboardHookService.MouseAction += MouseAndKeyboardHookService_MouseAction;
                    _mouseAndKeyboardHookService.Resume();
                }

                if (Settings.Default.ClosePasteBarWithHotKey && !CoreHelper.IsUnitTesting())
                {
                    if (_mouseAndKeyboardHookService == null)
                    {
                        _mouseAndKeyboardHookService = ServiceLocator.GetService <MouseAndKeyboardHookService>();
                    }
                    _mouseAndKeyboardHookService.HotKeyDetected += MouseAndKeyboardHookService_HotKeyDetected;
                    _mouseAndKeyboardHookService.RegisterHotKey(Consts.PasteShortcutName, Settings.Default.KeyboardShortcut.Cast <Key>().ToArray());
                    _mouseAndKeyboardHookService.Resume();
                    Logger.Instance.Information($"The keyboard is listened. The expecting shortcut is {JsonConvert.SerializeObject(Settings.Default.KeyboardShortcut.Cast<Key>().ToArray())}.");
                }
            };
            delayer.ResetAndTick();
        }
        private void ExecuteToggleChangeHotKeysCommand()
        {
            IsChangeHotKeyPopupOpened = true;
            MessengerInstance.Send(new Message(), MessageIdentifiers.ChangeHotKeyPopupOpened);

            _keyboardShortcut.Clear();
            DisplayedTemporaryKeyboardShortcut = DisplayedCurrentKeyboardShortcut;
            AcceptHotKeysCommand.RaiseCanExecuteChanged();
            _mouseAndKeyboardHookService.KeyboardAction += MouseAndKeyboardHookService_KeyboardAction;
            _mouseAndKeyboardHookService.Resume();
        }
示例#3
0
        private void ExecuteCopyCommand(DataEntry dataEntry)
        {
            var delayer = new Delayer <DataEntry>(TimeSpan.FromMilliseconds(200));

            delayer.Action += (sender, args) =>
            {
                Logger.Instance.Information("Copy command activated.");
                Requires.NotNull(args.Data, nameof(args.Data));

                _mouseAndKeyboardHookService?.Pause();
                _dataService.CopyData(args.Data);
                _mouseAndKeyboardHookService?.Resume();
            };
            delayer.ResetAndTick(dataEntry);
        }