/// <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; }
public Handler(ShortCutKeysDelegate shortCutKeys) { if (shortCutKeys == null) { throw new ArgumentNullException(nameof(shortCutKeys)); } ShortCutKeys = shortCutKeys; }
/// <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; } } }
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; }
/// <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); }