Пример #1
0
 /// <summary>
 /// Only a Form class can instantiate this class
 /// </summary>
 /// <param name="baseProcessCmdKey">Method base.ProcessCmdKey</param>
 public ShortCutKeysHandler(ShortCutKeysDelegate baseProcessCmdKey)
 {
     if (baseProcessCmdKey == null)
     {
         throw new ArgumentNullException(nameof(baseProcessCmdKey));
     }
     _baseProcessCmdKey = baseProcessCmdKey;
 }
Пример #2
0
 public Handler(ShortCutKeysDelegate shortCutKeys)
 {
     if (shortCutKeys == null)
     {
         throw new ArgumentNullException(nameof(shortCutKeys));
     }
     ShortCutKeys = shortCutKeys;
 }
Пример #3
0
 /// <summary>
 /// Remove the handler for ShortcutKeys
 /// </summary>
 /// <param name="method"></param>
 public void Remove(ShortCutKeysDelegate method)
 {
     if (method == null)
     {
         throw new ArgumentNullException(nameof(method));
     }
     for (int i = 0; i < _handlerList.Count; i++)
     {
         if (_handlerList[i].ShortCutKeys == method)
         {
             _handlerList.Remove(_handlerList[i]);
             break;
         }
     }
 }
Пример #4
0
            public Handler(TActionList actionList)
            {
                ActionList = actionList;
                _actionListWithShortCuts = new List <TAction>();
                ActionCollection col = actionList.Actions;

                for (int i = 0; i < col.Count; i++)
                {
                    TAction action = col[i];
                    if (action.ShortcutKeys != Keys.None)
                    {
                        _actionListWithShortCuts.Add(action);
                    }
                }
                ShortCutKeys = ShortCutKeysMethod;
            }
Пример #5
0
        /// <summary>
        /// Add a method that handles ShortcutKeys
        /// </summary>
        /// <param name="method"></param>
        public void Add(ShortCutKeysDelegate method)
        {
            if (method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }
            for (int i = 0; i < _handlerList.Count; i++)
            {
                if (_handlerList[i].ShortCutKeys == method)
                {
                    return; //don't add the same method
                }
            }
            Handler handler = new Handler(method);

            _handlerList.Add(handler);
        }