// This code is distributed under MIT license. // Copyright (c) 2015 George Mamaladze // See license.txt or https://mit-license.org/ using System.Collections.Generic; namespace Gma.System.MouseKeyHook.HotKeys { /// /// A collection of HotKeySets /// public sealed class HotKeySetCollection : List { private KeyChainHandler m_keyChain; /// /// Adds a HotKeySet to the collection. /// /// public new void Add(HotKeySet hks) { m_keyChain += hks.OnKey; base.Add(hks); } /// /// Removes the HotKeySet from the collection. /// /// public new void Remove(HotKeySet hks) { m_keyChain -= hks.OnKey; base.Remove(hks); } /// /// Uses a multi-case delegate to invoke individual HotKeySets if the Key is in use by any HotKeySets. /// /// internal void OnKey(KeyEventArgsExt e) { if (m_keyChain != null) m_keyChain(e); } private delegate void KeyChainHandler(KeyEventArgsExt kex); } }