Example #1
0
        public static void Register(IPluginManager pm, ICommandManager cm)
        {
            StringResource     sr      = TEnv.Strings;
            ICommandCategory   filecat = cm.CommandCategories.File;
            GeneralCommandImpl open    = new GeneralCommandImpl("org.poderosa.sessions.openShortcutFile", sr, "Command.OpenShortcutFile", filecat, new ExecuteDelegate(OpenShortcutFile));
            GeneralCommandImpl save    = new GeneralCommandImpl("org.poderosa.sessions.saveShortcutFile", sr, "Command.SaveShortcutFile", filecat, new ExecuteDelegate(SaveShortcutFile),
                                                                delegate(ICommandTarget target) {
                return(TerminalCommandTarget.AsTerminal(target) != null);
            });

            cm.Register(open);
            cm.Register(save);

            IExtensionPoint filemenu = pm.FindExtensionPoint("org.poderosa.menu.file");

            filemenu.RegisterExtension(new PoderosaMenuGroupImpl(new IPoderosaMenu[] {
                new PoderosaMenuItemImpl(open, sr, "Menu.OpenShortcutFile"),
                new PoderosaMenuItemImpl(save, sr, "Menu.SaveShortcutFile")
            }).SetPosition(PositionType.NextTo, CygwinPlugin.Instance.CygwinMenuGroupTemp));

            ShortcutFileToolBarComponent tb = new ShortcutFileToolBarComponent(open, save);

            pm.FindExtensionPoint("org.poderosa.core.window.toolbar").RegisterExtension(tb);
            TerminalSessionsPlugin.Instance.SessionManager.AddActiveDocumentChangeListener(tb);
        }
Example #2
0
        private static CommandResult SaveShortcutFile(ICommandTarget target)
        {
            ITerminalControlHost t = TerminalCommandTarget.AsTerminal(target);

            if (t == null)
            {
                return(CommandResult.Failed);
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title        = TEnv.Strings.GetString("Caption.SaveShortcutFile");
            dlg.DefaultExt   = "gts";
            dlg.AddExtension = true;
            dlg.Filter       = "Terminal Shortcut(*.gts)|*.gts";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try {
                    new ShortcutFileContent(t.TerminalSettings, t.TerminalConnection.Destination).SaveToXML(dlg.FileName);
                    return(CommandResult.Succeeded);
                }
                catch (Exception ex) {
                    RuntimeUtil.ReportException(ex);
                    return(CommandResult.Failed);
                }
            }
            else
            {
                return(CommandResult.Cancelled);
            }
        }
Example #3
0
        private static CommandResult CmdShellSchemeEditor(ICommandTarget target)
        {
            IPoderosaMainWindow  window  = CommandTargetUtil.AsWindow(target);
            ITerminalControlHost session = TerminalCommandTarget.AsTerminal(target);
            ShellSchemeEditor    dlg     = new ShellSchemeEditor(session == null ? null : session.TerminalSettings.ShellScheme);

            dlg.ShowDialog(window.AsForm());
            return(CommandResult.Succeeded);
        }