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);
            }
        }
Example #2
0
        private void _textBox_ContextMenuTriggered(object sender, TextBoxEditorControl.ContextMenuTriggeredEventArgs e)
        {
            OnCommandStateChanged();
            Command command = CommandContextMenu.ShowModal(CommandManager, (Control)sender, e.ContextMenuLocation, contextMenu);

            if (command != null)
            {
                command.PerformExecute();
            }
        }
        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();
                }
            }
        }
        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);
            }
        }
Example #5
0
    public Example()
    {
        Icon = SystemIcons.Application;
        Text = "Example";
        Size = new Size(400, 350);
        Controls.Add(new StatusBar());

        // Menu and toolbar
        CommandBarItem newItem  = new CommandBarItem(Images.New, "&New", null, Keys.Control | Keys.N);
        CommandBarItem openItem = new CommandBarItem(Images.Open, "&Open...", null, Keys.Control | Keys.O);
        CommandBarItem saveItem = new CommandBarItem(Images.Save, "&Save", null, Keys.Control | Keys.S);

        toolBar.Items.Add(newItem);
        toolBar.Items.Add(openItem);
        toolBar.Items.Add(saveItem);
        toolBar.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));

        CommandBarItem cutItem    = new CommandBarItem(Images.Cut, "Cu&t", null, Keys.Control | Keys.X);
        CommandBarItem copyItem   = new CommandBarItem(Images.Copy, "&Copy", null, Keys.Control | Keys.C);
        CommandBarItem pasteItem  = new CommandBarItem(Images.Paste, "&Paste", null, Keys.Control | Keys.V);
        CommandBarItem deleteItem = new CommandBarItem(Images.Delete, "&Delete", null, Keys.Delete);

        toolBar.Items.Add(cutItem);
        toolBar.Items.Add(copyItem);
        toolBar.Items.Add(pasteItem);
        toolBar.Items.Add(deleteItem);
        toolBar.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));

        CommandBarItem undoItem = new CommandBarItem(Images.Undo, "&Undo", null, Keys.Control | Keys.Z);
        CommandBarItem redoItem = new CommandBarItem(Images.Redo, "&Redo", null, Keys.Control | Keys.Y);

        toolBar.Items.Add(undoItem);
        toolBar.Items.Add(redoItem);
        toolBar.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));

        CommandBarItem fileItem = new CommandBarItem("&File");

        menuBar.Items.Add(fileItem);
        fileItem.Style = CommandBarItemStyle.DropDown;
        fileItem.Items.Add(newItem);
        fileItem.Items.Add(openItem);
        fileItem.Items.Add(saveItem);
        fileItem.Items.Add(new CommandBarItem("&Save As...", null));
        fileItem.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));
        fileItem.Items.Add(new CommandBarItem(Images.Preview, "Print Pre&view", null));
        fileItem.Items.Add(new CommandBarItem(Images.Print, "&Print", null, Keys.Control | Keys.P));
        fileItem.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));
        fileItem.Items.Add(new CommandBarItem("E&xit", new EventHandler(Exit_Click)));

        CommandBarItem editItem = new CommandBarItem("&Edit");

        menuBar.Items.Add(editItem);
        editItem.Items.Add(undoItem);
        editItem.Items.Add(redoItem);
        editItem.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));
        editItem.Items.Add(cutItem);
        editItem.Items.Add(copyItem);
        editItem.Items.Add(pasteItem);
        editItem.Items.Add(deleteItem);
        editItem.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));
        editItem.Items.Add(new CommandBarItem("Select &All", null, Keys.Control | Keys.A));

        CommandBarItem viewItem = new CommandBarItem("&View");
        CommandBarItem goToItem = new CommandBarItem("&Go To");

        goToItem.Items.Add(new CommandBarItem(Images.Back, "&Back", null, Keys.Alt | Keys.Left));
        goToItem.Items.Add(new CommandBarItem(Images.Forward, "&Forward", null, Keys.Alt | Keys.Right));
        goToItem.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));
        goToItem.Items.Add(new CommandBarItem(Images.Home, "&Home", null));
        viewItem.Items.Add(goToItem);

        viewItem.Items.Add(new CommandBarItem(Images.Stop, "&Stop", null, Keys.Escape));
        viewItem.Items.Add(new CommandBarItem(Images.Refresh, "&Refresh", null, Keys.F5));
        menuBar.Items.Add(viewItem);

        enabledItem         = new CommandBarItem(Images.Tiles, "&Enabled", null);
        enabledItem.Enabled = false;
        visibleItem         = new CommandBarItem(Images.Icons, "&Visible", null);
        visibleItem.Visible = false;
        CommandBarItem checkedPlainItem = new CommandBarItem("&Checked Plain", new EventHandler(ToggleCheck_Click));

        checkedPlainItem.Checked = true;
        CommandBarItem checkedBitmapItem = new CommandBarItem(Images.List, "&Checked Bitmap", new EventHandler(ToggleCheck_Click));

        checkedBitmapItem.Checked = true;

        toolBar.Items.Add(enabledItem);
        toolBar.Items.Add(visibleItem);
        toolBar.Items.Add(checkedPlainItem);
        toolBar.Items.Add(checkedBitmapItem);

        CommandBarItem testItem = new CommandBarItem("&Test");

        menuBar.Items.Add(testItem);
        testItem.Items.Add(new CommandBarItem("&Enabled On/Off", new EventHandler(ToggleEnabled_Click)));
        testItem.Items.Add(enabledItem);
        testItem.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));
        testItem.Items.Add(new CommandBarItem("&Visible On/Off", new EventHandler(ToggleVisible_Click)));
        testItem.Items.Add(visibleItem);
        testItem.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));
        testItem.Items.Add(checkedPlainItem);
        testItem.Items.Add(checkedBitmapItem);
        testItem.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));
        testItem.Items.Add(new CommandBarItem("Change Font", new EventHandler(ChangeFont_Click)));

        CommandBarItem helpItem = new CommandBarItem("&Help");

        menuBar.Items.Add(helpItem);
        helpItem.Items.Add(new CommandBarItem(Images.Mail, "&Your Feedback", null));
        helpItem.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));
        helpItem.Items.Add(new CommandBarItem("&About", null));

        reBar.Bands.Add(menuBar);
        reBar.Bands.Add(toolBar);
        Controls.Add(reBar);

        // Context menu
        CommandContextMenu contextMenu = new CommandContextMenu();

        contextMenu.Items.Add(undoItem);
        contextMenu.Items.Add(redoItem);
        contextMenu.Items.Add(new CommandBarItem(CommandBarItemStyle.Separator));
        contextMenu.Items.Add(cutItem);
        contextMenu.Items.Add(copyItem);
        contextMenu.Items.Add(pasteItem);
        contextMenu.Items.Add(deleteItem);
        contextMenu.Items = contextMenu.Items;         // $TODO triggers update.
        ContextMenu       = contextMenu;
    }