/// <summary>
        /// Adds the command.
        /// </summary>
        /// <param name="menuCommandService">The menu command service.</param>
        /// <param name="command">The command.</param>
        public static void AddCommand(this IMenuCommandService menuCommandService, IVsMenuCommand command)
        {
            Guard.NotNull(() => menuCommandService, menuCommandService);
            Guard.NotNull(() => command, command);

            menuCommandService.AddCommand(new VsMenuCommandAdapter(command));
        }
Beispiel #2
0
		public static void AddCommand(this IMenuCommandService mcs, Guid menuGroup, int cmdID, Action commandEvent, Action<OleMenuCommand> queryEvent = null)
		{
			var cmd = mcs.FindCommand(new CommandID(menuGroup, cmdID));
			if (cmd != null)
				mcs.RemoveCommand(cmd);
			var command = CreateCommand(menuGroup, cmdID, commandEvent, queryEvent);
			// Add the command using our IMenuCommandService instance
			mcs.AddCommand(command);
		}
        public static Shell AddCommand(this Shell shell, string pattern, string description,
            InvokeShellCommandDelegate invokeHandler, CompleteShellCommandDelegate completeHandler)
        {
            if (shell == null) throw new ArgumentNullException(nameof(shell));
            if (invokeHandler == null) throw new ArgumentNullException(nameof(invokeHandler));

            var command = new ShellCommand(pattern, description);
            command.InvokeCommand +=
                (sender, args) => { invokeHandler(args.Shell, sender as IShellCommand, args.Arguments); };

            if (completeHandler != null)
            {
                command.CompleteCommand +=
                    (sender, args) =>
                    {
                        args.Result = completeHandler(args.Shell, sender as IShellCommand, args.Tokens);
                    };
            }

            return shell.AddCommand(command);
        }
 public static void Register(this IMenuCommandService instance, Guid guid, uint cmd, EventHandler method)
 {
     var menuCommandID = new CommandID(guid, (int)cmd);
     instance.AddCommand(new MenuCommand(method, menuCommandID));
 }
 public static Shell AddCommand(this Shell shell, string pattern,
     InvokeShellCommandDelegate invokeHandler)
 {
     return shell.AddCommand(pattern, invokeHandler, null);
 }
Beispiel #6
0
 public static void AddTribeContextCommands(this UIContextMenu menu, Map map, Tribe tribe)
 {
     string tribeDesc = string.Format("{0} ({1})", tribe.Tag, Common.GetPrettyNumber(tribe.AllPoints));
     if (tribe.Rank <= 20)
     {
         tribeDesc = string.Format("#{0} {1}", tribe.Rank, tribeDesc);
     }
     var tribeCommand = menu.AddCommand(tribeDesc, null, Properties.Resources.Tribe);
     tribeCommand.ToolTipText = tribe.Tooltip;
     var tribeContext = new TribeContextMenu(map, tribe);
     tribeCommand.Commands.AddRange(tribeContext.GetCommands().ToArray());
 }
Beispiel #7
0
 public static void AddSetVillageTypeCommand(this UIContextMenu menu, CommandEventHandler onVillageTypeChange, Village village)
 {
     VillageType currentVillageType = village == null ? VillageType.None : village.Type;
     UICommand villageTypes = menu.AddCommand("Set purpose", null, currentVillageType.GetImage(true));
     AddVillageTypeCommand(villageTypes, VillageType.Attack, currentVillageType, onVillageTypeChange);
     AddVillageTypeCommand(villageTypes, VillageType.Catapult, currentVillageType, onVillageTypeChange);
     AddVillageTypeCommand(villageTypes, VillageType.Defense, currentVillageType, onVillageTypeChange);
     villageTypes.Commands.AddSeparator();
     AddVillageTypeCommand(villageTypes, VillageType.Noble, currentVillageType, onVillageTypeChange);
     AddVillageTypeCommand(villageTypes, VillageType.Scout, currentVillageType, onVillageTypeChange);
     AddVillageTypeCommand(villageTypes, VillageType.Farm, currentVillageType, onVillageTypeChange);
 }
Beispiel #8
0
 public static void AddPlayerNobledContextCommands(this UIContextMenu menu, Map map, Player player, bool addTribeCommands)
 {
     var playerCommand = menu.AddCommand("Nobled from " + player.Name, null, Properties.Resources.nobleman);
     AddPlayerContextCommands(map, player, addTribeCommands, playerCommand);
 }
Beispiel #9
0
 public static void AddPlayerContextCommands(this UIContextMenu menu, Map map, Player player, bool addTribeCommands)
 {
     string playerDesc = string.Format("{0} ({1})", player.Name, Common.GetPrettyNumber(player.Points));
     if (player.Rank <= 100)
     {
         playerDesc = string.Format("#{0} {1}", player.Rank, playerDesc);
     }
     var playerCommand = menu.AddCommand(playerDesc, null, Properties.Resources.Player);
     AddPlayerContextCommands(map, player, addTribeCommands, playerCommand);
 }