示例#1
0
        public override void GenerateCommands(GenerateCommandArgs args)
        {
            base.GenerateCommands(args);

            if (args.Area == "viewer")
            {
                this.args = args;
                var control = args.Control;

                if (Generator.IsMac && control != null)
                {
                    control.MapPlatformCommand("cut", s_DisabledCommand);
                    control.MapPlatformCommand("copy", s_DisabledCommand);
                    control.MapPlatformCommand("paste", s_DisabledCommand);
                    control.MapPlatformCommand("selectAll", s_DisabledCommand);
                    control.MapPlatformCommand("delete", s_DisabledCommand);
                    control.MapPlatformCommand("undo", s_DisabledCommand);
                    control.MapPlatformCommand("redo", s_DisabledCommand);
                }

                var edit = args.Menu.Items.GetSubmenu("&Edit", 200);
                var view = args.Menu.Items.GetSubmenu("&View", 500);
                view.Items.AddSeparator(600);
                view.Items.Add(Info.GetFontMenu(this, 600));


                view.Items.Add(new ToggleDosAspect(this), 500);
                view.Items.Add(new ToggleUse9x(this), 500);
                view.Items.Add(new ToggleIceMode(this), 500);

                if (AllowEditing)
                {
#if DEBUG
                    edit.Items.Add(new StartDrawing(this), 700);
#endif

                    edit.Items.AddSeparator(700);
                    edit.Items.Add(new SetWidth(this), 700);
                    edit.Items.Add(new CharacterSetEditor(this), 700);

                    edit.Items.AddSeparator(800);
                    edit.Items.Add(new DefaultColour(this), 800);
                    edit.Items.Add(new SwitchForegroundBackground(this), 800);


                    args.ToolBar.Items.Add(new SetWidth(this), 500);

                    if (SelectedTool != null)
                    {
                        SelectedTool.GenerateCommands(args);
                    }

                    // block commands

                    if (Generator.IsMac && control != null)
                    {
                        control.MapPlatformCommand("undo", new Actions.Undo(this));
                        control.MapPlatformCommand("redo", new Redo(this));
                    }
                    else
                    {
                        edit.Items.Add(new Actions.Undo(this), 100);
                        edit.Items.Add(new Redo(this), 100);
                    }

                    edit.Items.Add(new ToggleInsertMode(this), 500);

                    args.KeyboardCommands.Add(new SwitchColour(this, -1, 0, Keys.Control | Keys.Up));
                    args.KeyboardCommands.Add(new SwitchColour(this, 1, 0, Keys.Control | Keys.Down));
                    args.KeyboardCommands.Add(new SwitchColour(this, 0, -1, Keys.Control | Keys.Left));
                    args.KeyboardCommands.Add(new SwitchColour(this, 0, 1, Keys.Control | Keys.Right));

                    for (int i = 0; i < Math.Min(10, CurrentPage.Palette.Count / 2); i++)
                    {
                        args.KeyboardCommands.Add(new ChangeColour(this, i, null, Keys.Control | (Keys.D0 + i)));
                        args.KeyboardCommands.Add(new ChangeColour(this, null, i, Keys.Alt | (Keys.D0 + i)));
                    }
                    AddMoveAction(args, "up", "Move Up", "Moves the cursor up one row", MoveDirection.Up, Keys.Up);
                    AddMoveAction(args, "down", "Move Down", "Moves the cursor down one row", MoveDirection.Down, Keys.Down);
                    AddMoveAction(args, "left", "Move Left", "Moves the cursor left one column", MoveDirection.Left, Keys.Left);
                    AddMoveAction(args, "right", "Move Right", "Moves the cursor right one column", MoveDirection.Right, Keys.Right);
                    AddMoveAction(args, "home", "Home", "Moves the cursor to the beginning of the row", MoveDirection.First, (Generator.IsMac) ? Keys.Application | Keys.Left : Keys.Home);
                    AddMoveAction(args, "end", "End", "Moves the cursor to the end of the row", MoveDirection.Last, (Generator.IsMac) ? Keys.Application | Keys.Right : Keys.End);
                    AddMoveAction(args, "pageUp", "Page Up", "Moves the cursor up one page", MoveDirection.PageUp, Keys.PageUp);
                    AddMoveAction(args, "pageDown", "Page Down", "Moves the cursor down one page", MoveDirection.PageDown, Keys.PageDown);
                    AddMoveAction(args, "top", "Move Top", "Moves the cursor to the top of the document", MoveDirection.Top, (Generator.IsMac) ? Keys.Application | Keys.Home : Keys.Control | Keys.PageUp);
                    AddMoveAction(args, "bottom", "Move Bottom", "Moves the cursor to the bottom of the document", MoveDirection.Bottom, (Generator.IsMac) ? Keys.Application | Keys.End : Keys.Control | Keys.PageDown);
                    args.KeyboardCommands.Add(new SelectAttribute(this));
                    args.KeyboardCommands.Add(new SelectAttribute(this)
                    {
                        Shortcut = Keys.Escape
                    });
                    args.KeyboardCommands.Add(new InsertColumn(this));
                    args.KeyboardCommands.Add(new DeleteColumn(this));
                    args.KeyboardCommands.Add(new InsertLine(this));
                    args.KeyboardCommands.Add(new DeleteLine(this));
                    args.KeyboardCommands.Add(new NewLine(this));
                    args.KeyboardCommands.Add(new Delete(this));
                    args.KeyboardCommands.Add(new Backspace(this));

                    args.KeyboardCommands.Add(new UseColour(this));

                    for (int i = 0; i < 12; i++)
                    {
                        args.KeyboardCommands.Add(new DrawCharacterSetChar(this, i, (Keys.F1 + i)));
                    }

                    for (int i = 0; i < 10; i++)
                    {
                        args.KeyboardCommands.Add(new SwitchCharacterSet(this, i, Keys.Alt | (Keys.F1 + i)));

                        args.KeyboardCommands.Add(new SwitchCharacterSet(this, i + 10, Keys.Control | (Keys.F1 + i)));
                    }
                }
            }
        }