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

            string area = args.Area;

            if (area == "viewer")
            {
                var control   = args.Control;
                var actionDos = new CheckCommand {
                    ID      = "dosAspect", MenuText = "Emulate Legacy &Aspect", ToolTip = "Stretch image vertically to emulate DOS",
                    Checked = RipDocument.Info.DosAspect
                };
                actionDos.CheckedChanged += actionDos_CheckedChanged;

                var aiView = args.Menu.Items.GetSubmenu("&View", 500);
                var aiEdit = args.Menu.Items.GetSubmenu("&Edit", 200);

                aiView.Items.Add(actionDos, 500);

                if (Generator.IsMac)
                {
                    control.MapPlatformCommand("undo", new Actions.Undo(this));
                    control.MapPlatformCommand("redo", new Actions.Redo(this));
                }
                else
                {
                    aiEdit.Items.Add(new Actions.Undo(this), 100);
                    aiEdit.Items.Add(new Actions.Redo(this), 100);
                }
            }
        }
示例#2
0
        public override void GenerateCommands(GenerateCommandArgs args)
        {
            base.GenerateCommands(args);

            bool   editMode = args.EditMode;
            string area     = args.Area;

            if (area == "main")
            {
                if (!editMode)
                {
                    baudRateMap = new BaudRateMapCollection();
#if DEBUG
#endif
                    baudRateMap.Add("Fastest", 0);
                    baudRateMap.Add(460800);
                    baudRateMap.Add(230400);
                    baudRateMap.Add(115200);
                    baudRateMap.Add(57600);
                    baudRateMap.Add(38400);
                    baudRateMap.Add(33600);
                    baudRateMap.Add(28800);
                    baudRateMap.Add(19200);
                    baudRateMap.Add(14400);
                    baudRateMap.Add(9600);
                    baudRateMap.Add(2400);
                    baudRateMap.Add(1200);
                    baudRateMap.Add(300);


                    var animAuto = new CheckCommand {
                        ID = "animAuto", MenuText = "&Auto Detect", Checked = autoDetectAnimation
                    };
                    animAuto.CheckedChanged += AutoDetect_CheckedChanged;

                    var animEnabled = new CheckCommand {
                        ID = "animEnabled", MenuText = "&Enabled", Checked = animationEnabled
                    };
                    animEnabled.CheckedChanged += AnimEnabled_CheckedChanged;


                    var aiView = args.Menu.Items.GetSubmenu("&View");

                    var aiAnim = aiView.Items.GetSubmenu("&Animate", 600);

                    aiAnim.Items.Add(animEnabled, 500);
                    aiAnim.Items.Add(animAuto, 500);
                    aiAnim.Items.AddSeparator(500);

                    foreach (BaudRateMap brm in baudRateMap)
                    {
                        brm.Command.Checked = (baudRate == brm.Baud);
                        aiAnim.Items.Add(brm.Command, 500);
                    }
                    baudRateMap.BaudChanged += baudRateMap_BaudChanged;
                }
            }
        }
示例#3
0
 void AddMoveAction(GenerateCommandArgs args, string id, string name, string toolTip, MoveDirection direction, Keys accelerator)
 {
     args.KeyboardCommands.Add(new Move(this, id, direction, accelerator)
     {
         Name = name, MenuText = name, ToolTip = toolTip
     });
     args.KeyboardCommands.Add(new MoveSelect(Tools.OfType <Tools.Selection>().First(), id, direction, Keys.Shift, accelerator)
     {
         Name = name, MenuText = name, ToolTip = toolTip
     });
 }
示例#4
0
        public override void GenerateCommands(GenerateCommandArgs args)
        {
            base.GenerateCommands(args);

            var control = args.Control;
            var edit    = args.Menu.Items.GetSubmenu("&Edit", 200);


            edit.Items.AddSeparator(200);
            edit.Items.Add(new Actions.Block.Deselect(this), 200);
            args.KeyboardCommands.Add(new Actions.Block.Deselect(this));

            args.KeyboardCommands.Add(new Actions.Block.Delete(this)
            {
                Shortcut = Keys.E
            });
            if (Platform.Instance.IsMac)
            {
                args.KeyboardCommands.Add(new Actions.Block.Delete(this));                 // Keys.Delete doesn't map on OS X for some reason
                control.MapPlatformCommand("cut", new Actions.Block.CutToClipboard(this));
                control.MapPlatformCommand("copy", new Actions.Block.CopyToClipboard(this));
                control.MapPlatformCommand("paste", new Actions.Block.PasteFromClipboard(this));
                control.MapPlatformCommand("selectAll", new Actions.Block.SelectAll(this));
                control.MapPlatformCommand("delete", new Actions.Block.Delete(this));
            }
            else
            {
                edit.Items.Add(new Actions.Block.CutToClipboard(this), 200);
                edit.Items.Add(new Actions.Block.CopyToClipboard(this), 200);
                edit.Items.Add(new Actions.Block.PasteFromClipboard(this), 200);
                edit.Items.Add(new Actions.Block.Delete(this), 200);
                edit.Items.AddSeparator(300);
                edit.Items.Add(new Actions.Block.SelectAll(this), 300);
            }
            edit.Items.Add(new Actions.Block.Move(this), 200);
            edit.Items.Add(new Actions.Block.Copy(this), 200);
            edit.Items.Add(new Actions.Block.Fill(this), 200);
            edit.Items.AddSeparator(200);

            edit.Items.Add(new Actions.Block.Stamp(this), 200);
            edit.Items.Add(new Actions.Block.Rotate(this), 200);
            edit.Items.Add(new Actions.Block.FlipX(this), 200);
            edit.Items.Add(new Actions.Block.FlipY(this), 200);
            edit.Items.Add(new Actions.Block.Paste(this), 200);
            edit.Items.AddSeparator(300);
            edit.Items.Add(new Actions.Block.Transparent(this), 300);
            edit.Items.Add(new Actions.Block.Under(this), 300);
        }
        public override void GenerateCommands(GenerateCommandArgs args)
        {
            bool   editMode = args.EditMode;;
            string area     = args.Area;

            if (area == "main")
            {
                var edit = args.Menu.Items.GetSubmenu("&Edit", 200);

                if (editMode)
                {
                    var actionShiftSelect = new CheckCommand {
                        ID = "shiftSelect", MenuText = "Use Shift+Movement to select", ToolBarText = "Shift Select", ToolTip = "Use Shift+Movement keys for selection", Checked = ShiftSelect
                    };
                    actionShiftSelect.CheckedChanged += actionShiftSelect_CheckedChanged;
                    edit.Items.Add(actionShiftSelect);
                }
            }

            base.GenerateCommands(args);
        }
示例#6
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)));
                    }
                }
            }
        }
示例#7
0
        public void GenerateActions()
        {
            bool canEdit = (handler != null && handler.CanEdit);

            if (args != null)
            {
                var disposableMenuItems = args.Menu.Items.SelectMany(r => AllItems(r)).Select(r => r.Command).OfType <IDisposable>().ToList();
                disposableMenuItems.AddRange(args.KeyboardCommands.OfType <IDisposable>());
                foreach (var item in disposableMenuItems)
                {
                    item.Dispose();
                }
                var disposableToolbarItems = args.ToolBar.Items.Select(r => r.Command).OfType <IDisposable>().Where(r => !disposableMenuItems.Contains(r));
                foreach (var item in disposableToolbarItems)
                {
                    item.Dispose();
                }
            }

            args = new GenerateCommandArgs {
                EditMode = EditMode, Area = "main"
            };

            //GC.Collect ();

            args.KeyboardCommands.Add(new Actions.FocusChatView(this));

            var prevCommand = new Command {
                ID = "prev", MenuText = "Open &Previous", ToolTip = "Opens the previous file in the list", Shortcut = Keys.Alt | Keys.Up
            };

            prevCommand.Executed += (sender, e) => fileList.GoToPrevious();;
            var nextCommand = new Command {
                ID = "next", MenuText = "Open &Next", ToolTip = "Opens the next file in the list", Shortcut = Keys.Alt | Keys.Down
            };

            nextCommand.Executed += (sender, e) => fileList.GoToNext();;

            var aiFile = args.Menu.Items.GetSubmenu("&File", 100);

            args.Menu.Items.GetSubmenu("&View", 300);
            args.Menu.Items.GetSubmenu("Options", 500);
            var aiNetwork = args.Menu.Items.GetSubmenu("&Network", 600);
            var aiHelp    = args.Menu.Items.GetSubmenu("&Help", 1000);


            args.Menu.AboutItem = new Actions.About(this);

            if (Platform.IsMac)
            {
                var quitCommand = new Command {
                    MenuText = "Quit", ToolTip = "Close the application", Shortcut = Keys.Q | Keys.Application
                };
                quitCommand.Executed += (sender, e) => ExitApplication();
                args.Menu.QuitItem    = quitCommand;
            }
            else
            {
                args.Menu.QuitItem = new Actions.Exit(this);
            }


            aiFile.Items.Add(new Actions.NewFile(this), 100);
            aiFile.Items.Add(new Actions.OpenFile(this), 100);
            aiFile.Items.Add(new Actions.EnclosingFolder(this), 100);
            if (!EditMode)
            {
                aiFile.Items.Add(nextCommand, 100);
                aiFile.Items.Add(prevCommand, 100);

                aiFile.Items.AddSeparator(300);
                aiFile.Items.Add(new Actions.DeleteFile(this), 300);
                aiFile.Items.Add(new Actions.RenameFile(this), 300);
                aiFile.Items.Add(new Actions.MoveFile(this), 300);
            }
            aiFile.Items.AddSeparator(400);
            aiFile.Items.Add(new Actions.EditSauce(this), 500);

            if (canEdit)
            {
                aiFile.Items.Add(new Actions.EditFile(this), 500);
            }

            aiFile.Items.Add(new Actions.EnableBackups(this), 500);

            // network
            //#if DEBUG
            aiNetwork.Items.Add(new Actions.ServerStart(this), 500);
            aiNetwork.Items.Add(new Actions.ClientConnect(this), 500);
            aiNetwork.Items.Add(new Actions.ServerStop(this), 500);
            //#endif

            // help
            aiHelp.Items.Add(new Actions.Homepage(), 500);

            args.ToolBar.Items.Add(new Actions.NewFile(this), 100);
            args.ToolBar.Items.Add(new Actions.OpenFile(this), 100);
            args.ToolBar.Items.Add(new Actions.EditSauce(this), 100);

            if (Platform.IsMac)
            {
                args.ToolBar.Items.AddSeparator(800, SeparatorToolItemType.FlexibleSpace);
                args.ToolBar.Items.Add(new Actions.ViewFile(this), 900);
                args.ToolBar.Items.Add(new Actions.EditFileRadio(this), 900);
            }
            else
            {
                args.ToolBar.Items.AddSeparator(200);
                args.ToolBar.Items.Add(new Actions.EditFile(this), 200);
            }

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

            var oldmenu    = Menu;
            var oldtoolbar = ToolBar;

            Menu    = args.Menu;
            ToolBar = args.ToolBar;

            Application.Instance.AsyncInvoke(() =>
            {
                /*if (oldtoolbar != null)
                 *      oldtoolbar.Dispose();
                 *
                 * if (oldmenu != null)
                 *      oldmenu.Dispose();*/
#if DEBUG
                GC.Collect();
                GC.WaitForPendingFinalizers();
#endif
            });
        }
示例#8
0
 public virtual void GenerateCommands(GenerateCommandArgs args)
 {
 }