Esempio n. 1
0
 public override bool ValidateCommand(Command command)
 {
     if (command == Commands.CustomCommand)
         command.Title = "Custom Command " + counter.ToString();
     return base.ValidateCommand(command);
 }
Esempio n. 2
0
 public override bool CanExecute(Command command)
 {
     if (command == Commands.CustomCommand)
         return !eventManagedMenuItem.Enabled;
     return base.CanExecute(command);
 }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
 public virtual bool ValidateCommand(Command command)
 {
     return CanExecute(command);
 }
Esempio n. 6
0
 public virtual void Execute(Command command, object sender)
 {
     if (CommandCache.IsSupported(this.GetType(), command.Name))
         CommandCache.Invoke(command.Name, this, sender);
 }
Esempio n. 7
0
 public virtual bool CanExecute(Command command)
 {
     return CommandCache.IsSupported(this.GetType(), command.Name);
 }