示例#1
0
 internal void LogEvents(ChordHotKey HotKey)
 {
     if (LogEvent)
     {
         txtLog.Text += string.Format("{0} : Hotkey Processed! Name: {1}; {2}",
                                      HotKey.Name, HotKey.FullInfo(), Environment.NewLine);
         txtLog.Select(txtLog.Text.Length, 0);
         txtLog.ScrollToCaret();
     }
 }
 internal void LogEvents(ChordHotKey HotKey)
 {
     if (LogEvent)
     {
         txtLog.Text += string.Format("{0} : Hotkey Processed! Name: {1}; {2}",
                                      HotKey.Name, HotKey.FullInfo(), Environment.NewLine);
         txtLog.Select(txtLog.Text.Length, 0);
         txtLog.ScrollToCaret();
     }
 }
 /// <summary>Unregisters a ChordHotKey.
 /// </summary>
 /// <param name="hotKey">The hotKey to be removed</param>
 /// <returns>True if success, otherwise false</returns>
 public bool RemoveChordHotKey(ChordHotKey hotKey)
 {
     if (ChordHotKeyContainer.Remove(hotKey) == true)
     { --ChordHotKeyCount; return true; }
     else { return false; }
 }
 /// <summary>Checks if a ChordHotKey has been registered.
 /// </summary>
 /// <param name="chordhotkey">The ChordHotKey to check.</param>
 /// <returns>True if the ChordHotKey has been registered, false otherwise.</returns>
 public bool HotKeyExists(ChordHotKey chordhotkey)
 {
     return ChordHotKeyContainer.Exists
         (
         delegate(ChordHotKey c)
         {
             return (c == chordhotkey);
         }
     );
 }
        /// <summary>Registers a ChordHotKey.
        /// </summary>
        /// <param name="hotKey">The hotKey which will be added. Must not be null and can be registered only once.</param>
        /// <returns>True if registered successfully, false otherwise.</returns>
        /// <exception cref="HotKeyAlreadyRegisteredException">thrown if a LocalHotkey with the same name and or key and modifier has already been added.</exception>
        public bool AddChordHotKey(ChordHotKey hotKey)
        {
            if (hotKey == null)
            {
                if (!this.SuppressException)
                    throw new ArgumentNullException("value");

                return false;
            }
            if (hotKey.BaseKey == 0 || hotKey.ChordKey == 0)
            {
                if (!this.SuppressException)
                    throw new ArgumentNullException("value.Key");

                return false;
            }

            //Check if a LocalHotKey already has its Key and Modifier.
            bool LocalExits = LocalHotKeyContainer.Exists
            (
                delegate(LocalHotKey f)
                {
                    return (f.Key == hotKey.BaseKey && f.Modifier == hotKey.BaseModifier);
                }
            );

            if (ChordHotKeyContainer.Contains(hotKey) || LocalExits)
            {
                if (!this.SuppressException)
                    throw new HotKeyAlreadyRegisteredException("HotKey already registered!", hotKey);

                return false;
            }

            ChordHotKeyContainer.Add(hotKey);
            ++ChordHotKeyCount;
            return true;
        }
 public HotKeyAlreadyRegisteredException(string message, ChordHotKey hotKey, Exception inner)
     : base(message, inner)
 {
     ChordKey = hotKey;
 }
 public ChordHotKeyEventArgs(ChordHotKey hotkey)
 {
     HotKey = hotkey;
 }
示例#8
0
        /// <summary>Checks if a ChordHotKey has been registered.
        /// </summary>
        /// <param name="chordhotkey">The ChordHotKey to check.</param>
        /// <returns>True if the ChordHotKey has been registered, false otherwise.</returns>
        public bool HotKeyExists(ChordHotKey chordhotkey)
        {
            return (((from item in ChordHotKeyContainer
                      where item == chordhotkey
                      select item).FirstOrDefault()) != null);

            //return ChordHotKeyContainer.Exists
            //    (
            //    delegate(ChordHotKey c)
            //    {
            //        return (c == chordhotkey);
            //    }
            //);
        }