Exemplo 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;
        }
        public static PresetToHotkeyMap GetInstance()
        {
            if (mInstance == null)
            {
                mInstance = new PresetToHotkeyMap();
            }

            return(mInstance);
        }
Exemplo n.º 3
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");
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Private constructor. Initializes the HotkeyRegistrar with the supplied preset to hotkey map
 /// instance. Performs initial registration of hotkeys.
 /// </summary>
 /// <param name="presetToHotkeyMap"></param>
 private HotkeyRegistrar(PresetToHotkeyMap presetToHotkeyMap)
 {
     // Register all existing hotkeys
     mPresetToHotkeyMap = presetToHotkeyMap;
     mPresetToHotkeyId  = new Dictionary <string, int>();
     mPresetToHotkeyMap.OnPresetToHotkeyMappingChanged += OnPresetHotkeyMapChanged;
     foreach (KeyValuePair <string, VirtualHotkey> presetAndHotkey in mPresetToHotkeyMap.GetHotkeyMappings())
     {
         RegisterHotkeyAndUpdateIdMapping(presetAndHotkey.Key, presetAndHotkey.Value);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes the singleton instance of HotkeyRegistrar.
 /// </summary>
 /// <param name="presetToHotkeyMap">The mapping of presets to hotkeys.</param>
 /// <param name="messageFilter"></param>
 public static void Initialize(PresetToHotkeyMap presetToHotkeyMap)
 {
     if (mInstance == null)
     {
         mInstance = new HotkeyRegistrar(presetToHotkeyMap);
     }
     else
     {
         throw new Exception("Unexpected reinitialization of HotkeyRegistrar.");
     }
 }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public PresetHotkeyForm(DisplayPresetCollection displayPresetCollection, PresetToHotkeyMap presetToHotkeyMap)
        {
            InitializeComponent();

            mNewHotkey = new NewHotkey();

            mPresetToHotkeyMap = presetToHotkeyMap;
            mPresetToHotkeyDictionaryForComboBox = new Dictionary <string, VirtualHotkey>(mPresetToHotkeyMap.GetHotkeyMappings());
            mPresetToHotkeyMap.OnPresetToHotkeyMappingChanged += OnPresetToHotkeyMapChanged;

            presetsComboBox.Items.AddRange(displayPresetCollection.GetPresets().ToArray());
            presetsComboBox.SelectedIndexChanged += PresetsComboBox_SelectedIndexChanged;
            if (presetsComboBox.Items.Count > 0)
            {
                presetsComboBox.SelectedIndex = 0;
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Event handler for when "Edit global hotkeys" context menu item is clicked. Launches
 /// a form to allow the user to edit global hotkeys for the display presets.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EditGlobalHotkeys_ItemClicked(object sender, EventArgs e)
 {
     if (mPresetHotkeyForm == null)
     {
         mPresetHotkeyForm             = new PresetHotkeyForm(DisplayPresetCollection.GetDisplayPresetCollection(), PresetToHotkeyMap.GetInstance());
         mPresetHotkeyForm.FormClosed += MPresetHotkeyForm_FormClosed;
     }
     else if (!mPresetHotkeyForm.Visible)
     {
         mPresetHotkeyForm.ShowDialog();
     }
     else
     {
         mPresetHotkeyForm.Activate();
     }
 }