public override bool ValidateCommand(Command command) { if (command == Commands.CustomCommand) command.Title = "Custom Command " + counter.ToString(); return base.ValidateCommand(command); }
public override bool CanExecute(Command command) { if (command == Commands.CustomCommand) return !eventManagedMenuItem.Enabled; return base.CanExecute(command); }
internal static Command Register(string name, string nativeName) { Command command; if (name == null) throw new ArgumentNullException("name"); if (nativeName == null) throw new ArgumentNullException("nativeName"); lock (commandDictionary) { if (!commandDictionary.TryGetValue(name, out command)) { command = new Command(name, nativeName); commandDictionary.Add(command.Name, command); } else // Ensure that the native name is correct { if (!IsValidName(nativeName)) throw new NameFormatException(name, Localization.GetExceptionText("CommandNameFormat", name)); command.SelectorName = GetSelectorName(nativeName); } } return command; }
public static Command Register(string name) { Command command; if (name == null) throw new ArgumentNullException("name"); lock (commandDictionary) { if (!commandDictionary.TryGetValue(name, out command)) { command = new Command(name); command.Title = name; commandDictionary.Add(command.Name, command); } } return command; }
public virtual bool ValidateCommand(Command command) { return CanExecute(command); }
public virtual void Execute(Command command, object sender) { if (CommandCache.IsSupported(this.GetType(), command.Name)) CommandCache.Invoke(command.Name, this, sender); }
public virtual bool CanExecute(Command command) { return CommandCache.IsSupported(this.GetType(), command.Name); }