Exemplo n.º 1
0
        public async void OnKeyClick(object sender, RoutedEventArgs e)
        {
            var clickedButton = sender as ToggleButton;

            //HACK : 나중에 tag 바꿔야 되니까 얘만 캐시해둔다.
            if (!_isSelectingKey)
            {
                _selectedButton = clickedButton;
            }

            int keycode = KeyConversionHelper.ExtractFromElementName(clickedButton.Name);

            Hotkey hotkey;
            bool   hasHotkey = TriggerHotkeyPairs.ContainsKey(keycode);

            if (hasHotkey)
            {
                hotkey = TriggerHotkeyPairs[keycode];
            }
            else
            {
                hotkey = new Hotkey(new KeyInfo(keycode, 0), new KeyInfo());
            }

            await _eventAggregator.PublishOnUIThreadAsync(new KeySelectedEvent { Hotkey = hotkey, IsNew = !hasHotkey });
        }
Exemplo n.º 2
0
        public Task HandleAsync(ProfileDeletedEvent message, CancellationToken cancellationToken)
        {
            Profile = null;
            TriggerHotkeyPairs.Clear();

            return(Task.CompletedTask);
        }
Exemplo n.º 3
0
        private void SetTriggerHotkeyPairs(HotkeyProfile profile)
        {
            TriggerHotkeyPairs.Clear();

            foreach (var hotkey in profile.Hotkeys)
            {
                TriggerHotkeyPairs.Add(hotkey.Trigger.Key, hotkey);
            }
        }
Exemplo n.º 4
0
        public Task HandleAsync(HotkeyModifiedEvent message, CancellationToken cancellationToken)
        {
            switch (message.ModifiedEvent)
            {
            case EHotkeyModifiedEvent.Added:
                _selectedButton.Tag = "True";
                TriggerHotkeyPairs.Add(message.Hotkey.Trigger.Key, message.Hotkey);
                break;

            case EHotkeyModifiedEvent.Modified:
                TriggerHotkeyPairs[message.Hotkey.Trigger.Key] = message.Hotkey;
                break;

            case EHotkeyModifiedEvent.Deleted:
                _selectedButton.Tag = "False";
                TriggerHotkeyPairs.Remove(message.Hotkey.Trigger.Key);
                break;

            default:
                break;
            }

            return(Task.CompletedTask);
        }