Beispiel #1
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");
     }
 }
Beispiel #2
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);
        }