示例#1
0
 public static int FindHotKeyAction(HotKey hk)
 {
     lock (m_HotKeyActions)
     {
         foreach (DictionaryEntry ent in m_HotKeyActions)
         {
             if (ent.Value.ToString() == hk.ToString()) return Convert.ToInt32(ent.Key);
         }
         return 0;
     }
 }
示例#2
0
 static bool UnregisterHotKey(HotKey hk)
 {
     lock (m_HotKeys)
     {
         Int32 atom = FindHotKeyAtom(hk);
         UnregisterHotKey(Global.Desktop.Handle, atom);
         m_HotKeys.Remove(atom);
         return true;
     }
 }
示例#3
0
 static Int32 FindHotKeyAtom(HotKey hk)
 {
     foreach (DictionaryEntry ent in m_HotKeys)
     {
         if (ent.Value.ToString() == hk.ToString())
         {
             return Convert.ToInt32(ent.Key);
         }
     }
     return 0;
 }
示例#4
0
        static bool RegisterHotKey(HotKey hk)
        {
            if (FindHotKeyAtom(hk) != 0) return true;

            IntPtr atom = GlobalAddAtom(Guid.NewGuid().ToString());
            int hotKeyId = atom.ToInt32();
            if (hotKeyId == 0) return false;

            HotKeyModifiers fsModifiers = 0;
            if (hk.CtrlKey) fsModifiers |= HotKeyModifiers.MOD_CONTROL;
            if (hk.ShiftKey) fsModifiers |= HotKeyModifiers.MOD_SHIFT;
            if (hk.AltKey) fsModifiers |= HotKeyModifiers.MOD_ALT;

            if (!RegisterHotKey(Global.Desktop.Handle, hotKeyId, (uint)fsModifiers, hk.KeyCode)) return false;

            lock (m_HotKeys)
            {
                m_HotKeys[hotKeyId] = hk;
            }

            return true;
        }
示例#5
0
 public static bool RegisterHotKeyAction(int action, HotKey hk)
 {
     lock (m_HotKeyActions)
     {
         if (m_HotKeyActions.ContainsKey(action))
         {
             if (m_HotKeyActions[action].ToString() != hk.ToString())
             {
                 UnregisterHotKey(m_HotKeyActions[action] as HotKey);
                 m_HotKeyActions.Remove(action);
             }
             else
             {
                 return true;
             }
         }
         if (!RegisterHotKey(hk)) return false;
         m_HotKeyActions[action] = hk;
         return true;
     }
 }