Example #1
0
        public HotKey AddHotKey(HotKey hotKey)
        {
            try
            {
                if (hotKey == null)
                {
                    throw new ArgumentNullException("value");
                }
                /* We let em add as many null keys to the list as they want, but never register them*/
                if (hotKey.Key != Key.None && hotKeys.ContainsValue(hotKey))
                {
                    throw new HotKeyAlreadyRegisteredException("HotKey already registered!", hotKey);
                    //Log.O("HotKey already registered!");
                }


                int id = idGen.Next();
                if (hotKey.Enabled && hotKey.Key != Key.None)
                {
                    RegisterHotKey(id, hotKey);
                }
                hotKey.PropertyChanging += hotKey_PropertyChanging;
                hotKey.PropertyChanged  += hotKey_PropertyChanged;
                hotKeys[id]              = hotKey;
                return(hotKey);
            }
            catch (HotKeyAlreadyRegisteredException e)
            {
                Log.O("HotKey already registered!");
            }
            return(null);
        }
Example #2
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == WM_HotKey)
            {
                Log.O("HotKeys WndProc: IsEnabled - {0}", IsEnabled.ToString());
                if (IsEnabled && hotKeys.ContainsKey((int)wParam))
                {
                    HotKey h = hotKeys[(int)wParam];
                    Log.O("HotKeys WndProc: HotKey - {0}", h.KeysString);
                    if (h.Global)
                    {
                        if (h.Command != null)
                        {
                            h.Command.Execute(null, _window);
                        }
                    }
                }
            }

            return(new IntPtr(0));
        }