Ejemplo n.º 1
0
        /// <summary>
        /// Private constructor. Initializes the HotkeyHandler with the supplied preset to
        /// hotkey mapping and message filter.
        /// </summary>
        /// <param name="presetToHotkeyMap">Mapping of presets to hotkeys.</param>
        /// <param name="hotkeyMessageFilter">Message filter that notifies subscribers when a global hotkey for this app has occurred.</param>
        private HotkeyHandler(PresetToHotkeyMap presetToHotkeyMap, HotkeyMessageFilter hotkeyMessageFilter)
        {
            mPresetToHotkeyMap = presetToHotkeyMap;

            mHotkeyMessageFilter = hotkeyMessageFilter;
            mHotkeyMessageFilter.PresetSwitchHotkeyPressed += OnPresetSwitchHotkeyPressed;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes the singleton instance of HotkeyHandler with the supplied
 /// preset to hotkey mappings, and the message filter that receives global
 /// hotkey events.
 /// </summary>
 /// <param name="presetToHotkeyMap">Mapping of presets to hotkeys.</param>
 /// <param name="hotkeyMessageFilter">Message filter that notifies subscribers when a global hotkey for this app has occurred.</param>
 public static void Initialize(PresetToHotkeyMap presetToHotkeyMap, HotkeyMessageFilter hotkeyMessageFilter)
 {
     if (mInstance == null)
     {
         mInstance = new HotkeyHandler(presetToHotkeyMap, hotkeyMessageFilter);
     }
     else
     {
         throw new Exception("Unexpected reiniitalization of Hotkey Handler");
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes global hotkey infrastructure.
        /// </summary>
        private void InitializeHotkey()
        {
            mMessageFilter = new HotkeyMessageFilter();

            HotkeyRegistrar.Initialize(PresetToHotkeyMap.GetInstance());
            HotkeyHandler.Initialize(PresetToHotkeyMap.GetInstance(), mMessageFilter);

            // Technically this can degrade performance, but we're not doing a ton of work in there.
            // Just have to make sure it's non-blocking.
            Application.AddMessageFilter(mMessageFilter);
        }