Exemple #1
0
 private void OnPresetToHotkeyMapChanged(string presetName, VirtualHotkey keyCode, PresetToHotkeyMap.PresetToHotkeyMappingChangeType changeType)
 {
     // Dumbly update the entire working dictionary of preset to hotkey mappings.
     mPresetToHotkeyDictionaryForComboBox = mPresetToHotkeyMap.GetHotkeyMappings();
     ShowSelectedPresetKeyCombination(((DisplayPreset)presetsComboBox.SelectedItem).Name);
 }
        /// <summary>
        /// Event handler for when a display preset has a hotkey set or cleared. Registers
        /// new hotkey and deregisters old hotkeys as appropriate.
        /// </summary>
        /// <param name="presetName">The name of the preset changed.</param>
        /// <param name="virtualHotkey">The new hotkey if applicable.</param>
        /// <param name="changeType">The type of change, either a hotkey has been set or removed.</param>
        private void OnPresetHotkeyMapChanged(string presetName, VirtualHotkey virtualHotkey, PresetToHotkeyMap.PresetToHotkeyMappingChangeType changeType)
        {
            if (changeType == PresetToHotkeyMap.PresetToHotkeyMappingChangeType.HotkeyRemoved)
            {
                int existingHotkeyId;
                if (mPresetToHotkeyId.TryGetValue(presetName, out existingHotkeyId))
                {
                    DeregisterHotkeyAndUpdateIdMapping(presetName, existingHotkeyId);
                }
                else
                {
                    throw new Exception("Tried to deregister hotkey for unknown preset: " + presetName);
                }
            }
            else if (changeType == PresetToHotkeyMap.PresetToHotkeyMappingChangeType.HotkeySet)
            {
                // If a hotkey already exists for this, we need to deregister the old one
                // and register the new one.
                int existingHotkeyId;
                if (mPresetToHotkeyId.TryGetValue(presetName, out existingHotkeyId))
                {
                    DeregisterHotkeyAndUpdateIdMapping(presetName, existingHotkeyId);
                }

                RegisterHotkeyAndUpdateIdMapping(presetName, virtualHotkey);
            }
        }