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 }); }
private void RegisterButtons() { var children = _gridKeyButtons.Children; foreach (var item in children) { var button = item as RadioButton; var keycode = KeyConversionHelper.ExtractFromElementName((button.Name)); _keyButtonPairs.Add(keycode, button); } }