public RegisteredCommandElement(CommandManager commandManager, UIElement sourceElement, KeyShortcutCollection keyShortcutCollection, object target) { if (commandManager == null) { throw new ArgumentNullException(nameof(commandManager)); } if (sourceElement == null) { throw new ArgumentNullException(nameof(sourceElement)); } if (keyShortcutCollection == null) { throw new ArgumentNullException(nameof(keyShortcutCollection)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } this.commandManager = commandManager; this.weakSourceElement = new WeakReference(sourceElement); this.weakTarget = new WeakReference(target); this.keyShortcutCollection = keyShortcutCollection; this.commandTargetInfos = new List <CommandTargetFilterInfo>(); CommandTarget = new CommandTargetCollection(this); sourceElement.PreviewKeyDown += SourceElement_PreviewKeyDown; sourceElement.PreviewTextInput += SourceElement_PreviewTextInput; }
public IRegisteredCommandElement Register(UIElement sourceElement, object target) { if (sourceElement == null) { throw new ArgumentNullException(nameof(sourceElement)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } var coll = new KeyShortcutCollection(); foreach (var provider in commandInfoProviders) { coll.Add(provider.Value, target); } var cmdElem = new RegisteredCommandElement(this, sourceElement, coll, target); foreach (var c in commandTargetFilterProviders) { var filter = c.Value.Create(target); if (filter == null) { continue; } cmdElem.AddFilter(filter, c.Metadata.Order); } return(cmdElem); }
public IRegisteredCommandElement Register(UIElement sourceElement, object target) { if (sourceElement == null) throw new ArgumentNullException(nameof(sourceElement)); if (target == null) throw new ArgumentNullException(nameof(target)); var coll = new KeyShortcutCollection(); foreach (var provider in commandInfoProviders) coll.Add(provider.Value, target); var cmdElem = new RegisteredCommandElement(this, sourceElement, coll, target); foreach (var c in commandTargetFilterProviders) { var filter = c.Value.Create(target); if (filter == null) continue; cmdElem.AddFilter(filter, c.Metadata.Order); } return cmdElem; }