internal static MapContextCommand ShowMapContextMenu(Control parent, Point location, MapContextCommand[] hideCommands, CommandManager commandManager)
        {
            Command returnCommand;

            using (CommandLoader commandLoader = new CommandLoader(commandManager, FilterMapContextMenuCommands(hideCommands)))
            {
                CommandContextMenuDefinition ccmd = new CommandContextMenuDefinition();
                ccmd.CommandBar = false;
                ccmd.Entries.Add(CommandId.MapAddPushpin, false, true);
                ccmd.Entries.Add(CommandId.MapZoomStreetLevel, false, false);
                ccmd.Entries.Add(CommandId.MapZoomCityLevel, false, false);
                ccmd.Entries.Add(CommandId.MapZoomRegionLevel, false, false);
                ccmd.Entries.Add(CommandId.MapCenterMap, false, false);

                returnCommand = CommandContextMenu.ShowModal(
                    commandManager, parent, location, ccmd);
            }

            if (returnCommand != null)
            {
                return((MapContextCommand)_mapCommandIds[Enum.Parse(typeof(CommandId), returnCommand.Identifier)]);
            }
            else
            {
                return(MapContextCommand.None);
            }
        }
        private void InitializeCommands()
        {
            commandContextManager = new CommandContextManager(_decoratorsManager.CommandManager);
            commandContextManager.BeginUpdate();

            commandAddMenu = new Command(CommandId.AddDecorator);
            _decoratorsManager.CommandManager.Add(commandAddMenu);
            addCommandContextMenuDefinition = new CommandContextMenuDefinition(components);
            if (_decoratorsManager != null)
            {
                for (int i = 0; i < _decoratorsManager.ImageDecoratorGroups.Length; i++)
                {
                    ImageDecoratorGroup imageDecoratorGroup = _decoratorsManager.ImageDecoratorGroups[i];

                    foreach (ImageDecorator imageDecorator in imageDecoratorGroup.ImageDecorators)
                    {
                        if (!imageDecorator.IsHidden) //don't show hidden decorators in the command list
                        {
                            Command ImageDecoratorApplyCommand = imageDecorator.Command;
                            MenuDefinitionEntryCommand imageDecoratorMenuEntry = new MenuDefinitionEntryCommand(components);
                            imageDecoratorMenuEntry.CommandIdentifier = ImageDecoratorApplyCommand.Identifier;
                            addCommandContextMenuDefinition.Entries.Add(imageDecoratorMenuEntry);

                            ImageDecoratorApplyCommand.Execute += new EventHandler(imageDecoratorApplyCommand_Execute);
                            ImageDecoratorApplyCommand.Tag      = imageDecorator.Id;
                        }
                    }
                }
            }

            commandImageRemove          = new Command(CommandId.RemoveDecorator);
            commandImageRemove.Execute += new EventHandler(commandRemoveMenu_Execute);
            commandContextManager.AddCommand(commandImageRemove, CommandContext.Normal);

            _decoratorsManager.CommandManager.SuppressEvents = true;
            try
            {
                commandContextManager.EndUpdate();
            }
            finally
            {
                _decoratorsManager.CommandManager.SuppressEvents = true;
            }
        }
        private void btnOptions_Click(object sender, System.EventArgs e)
        {
            CommandContextMenuDefinition menu = new CommandContextMenuDefinition();

            menu.Entries.Add(CommandId.RecentPost, false, false);
            menu.Entries.Add(CommandId.Glossary, false, false);

            Point          screenPoint    = PointToScreen(new Point(btnOptions.Left, btnOptions.Bottom));
            Point          altScreenPoint = PointToScreen(new Point(btnOptions.Right, btnOptions.Bottom));
            LinkingCommand command        = (LinkingCommand)CommandContextMenu.ShowModal(CommandManager, this, screenPoint, altScreenPoint.X, menu);

            if (command != null)
            {
                if (command.FindLink(textBoxLinkText.Text, this))
                {
                    textBoxAddress.Focus();
                }
            }
        }
        private CommandContextMenuDefinition GetWeblogContextMenuDefinition(bool includeAllCommands)
        {
            // initialize context-menu definition
            CommandContextMenuDefinition weblogContextMenuDefinition = new CommandContextMenuDefinition(this.components);

            weblogContextMenuDefinition.CommandBar = true;

            if (includeAllCommands)
            {
                weblogContextMenuDefinition.Entries.Add(CommandId.ViewWeblog, false, false);
                weblogContextMenuDefinition.Entries.Add(CommandId.ViewWeblogAdmin, false, false);
                weblogContextMenuDefinition.Entries.Add(CommandId.ConfigureWeblog, true, true);
            }

            // weblog switching commands
            foreach (string commandIdentifier in _switchWeblogCommandMenu.CommandIdentifiers)
            {
                weblogContextMenuDefinition.Entries.Add(commandIdentifier, false, false);
            }

            weblogContextMenuDefinition.Entries.Add(CommandId.AddWeblog, true, false);
            return(weblogContextMenuDefinition);
        }
        internal static PushpinContextCommand ShowPushpinContextMenu(Control parent, Point location, CommandManager commandManager)
        {
            Command command;

            using (CommandLoader commandLoader = new CommandLoader(commandManager, PushpinContextMenuIds))
            {
                CommandContextMenuDefinition ccmd = new CommandContextMenuDefinition();
                ccmd.CommandBar = false;
                ccmd.Entries.Add(CommandId.MapEditPushpin, false, false);
                ccmd.Entries.Add(CommandId.MapDeletePushpin, false, false);

                command = CommandContextMenu.ShowModal(
                    commandManager, parent, location, ccmd);
            }

            if (command != null)
            {
                return((PushpinContextCommand)_pushpinCommandIds[Enum.Parse(typeof(CommandId), command.Identifier)]);
            }
            else
            {
                return(PushpinContextCommand.None);
            }
        }