Esempio n. 1
0
            public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
            {
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));

                if (window == null)
                {
                    return(CommandResult.Ignored);
                }

                using (OpenSessionDialog dlg = new OpenSessionDialog(window)) {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        IContentReplaceableView view       = (IContentReplaceableView)window.ViewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView));
                        IPoderosaView           targetView = view.AssureViewClass(typeof(TerminalView));

                        ISessionManager sm = (ISessionManager)TelnetSSHPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
                        TerminalSession ts = new TerminalSession(dlg.TerminalConnection, dlg.TerminalSettings);
                        sm.StartNewSession(ts, targetView);
                        sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction);

                        IAutoExecMacroParameter autoExecParam = dlg.TerminalConnection.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                        if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null)
                        {
                            TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts);
                        }
                        return(CommandResult.Succeeded);
                    }
                    return(CommandResult.Cancelled);
                }
            }
Esempio n. 2
0
        private static CommandResult CmdUnifyAll(ICommandTarget target)
        {
            IContentReplaceableView view = CommandTargetUtil.AsContentReplaceableViewOrLastActivatedView(target);

            if (view == null)
            {
                return(CommandResult.Ignored);
            }

            IPoderosaDocument       doc  = view.Document;
            ISplittableViewManager  svm  = (ISplittableViewManager)view.ViewManager.GetAdapter(typeof(ISplittableViewManager));
            IContentReplaceableView next = null;

            CommandResult r = svm.UnifyAll(out next);

            if (r == CommandResult.Succeeded)
            {
                ISessionManager sm = SessionManagerPlugin.Instance;
                ISessionManagerForViewSplitter smp = SessionManagerPlugin.Instance;
                smp.ChangeLastAttachedViewForWindow(view.ViewManager.ParentWindow, next);
                if (doc != null)
                {
                    sm.ActivateDocument(doc, ActivateReason.InternalAction);
                }
            }
            return(r);
        }
Esempio n. 3
0
        private static CommandResult CmdSplitUnify(ICommandTarget target)
        {
            IContentReplaceableView view = CommandTargetUtil.AsContentReplaceableViewOrLastActivatedView(target);

            if (view == null)
            {
                return(CommandResult.Ignored);
            }

            ISplittableViewManager  svm  = (ISplittableViewManager)view.ViewManager.GetAdapter(typeof(ISplittableViewManager));
            IContentReplaceableView next = null;
            IPoderosaDocument       document_unifying = view.Document;
            CommandResult           r = svm.Unify(view, out next);

            if (r == CommandResult.Succeeded)
            {
                ISessionManager sm = SessionManagerPlugin.Instance;
                ISessionManagerForViewSplitter smp = SessionManagerPlugin.Instance;
                smp.ChangeLastAttachedViewForAllDocuments(view, next);

                //次のフォーカスのドキュメントがなければ旧ドキュメントを移行。そしてnextのドキュメントをアクティブに
                if (document_unifying != null && next.Document == null)
                {
                    sm.AttachDocumentAndView(document_unifying, next);
                    Debug.Assert(next.Document == document_unifying);
                }

                if (next.Document != null)
                {
                    sm.ActivateDocument(next.Document, ActivateReason.InternalAction);
                }
            }
            return(r);
        }
        //基本のスタートセッション
        public ITerminalSession StartTerminalSession(ICommandTarget target, ITerminalConnection connection, ITerminalSettings settings)
        {
            Debug.Assert(connection != null);
            Debug.Assert(settings != null);
            //ここでターミナルエミュレータの遅延初期化
            TerminalSessionsPlugin.Instance.TerminalEmulatorService.LaterInitialize();

            ISessionManager sm = (ISessionManager)TerminalSessionsPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));

            IPoderosaView view = ToPoderosaView(target);

            Debug.Assert(view != null);

            TerminalSession session = new TerminalSession(connection, settings);

            sm.StartNewSession(session, view);
            sm.ActivateDocument(session.Terminal.IDocument, ActivateReason.InternalAction);

            IAutoExecMacroParameter autoExecParam = connection.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;

            if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null)
            {
                TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, session);
            }

            return(session);
        }
Esempio n. 5
0
            public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
            {
                ISessionManager sm = (ISessionManager)SessionTestPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
                DummySession    ts = new DummySession();
                IViewManager    vm = WindowManagerPlugin.Instance.ActiveWindow.ViewManager;

                sm.StartNewSession(ts, vm.GetCandidateViewForNewDocument());
                sm.ActivateDocument(ts.Document, ActivateReason.InternalAction);

                return(CommandResult.Succeeded);
            }
Esempio n. 6
0
            public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
            {
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));

                if (window == null)
                {
                    return(CommandResult.Ignored);
                }
                TelnetSSHLoginDialog dlg = new TelnetSSHLoginDialog(window);

                dlg.ApplyParam();

                CommandResult res = CommandResult.Cancelled;

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    ITerminalConnection con = dlg.Result;
                    if (con != null)
                    {
                        ISessionManager sm = (ISessionManager)TelnetSSHPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
                        TerminalSession ts = new TerminalSession(con, dlg.TerminalSettings);
                        sm.StartNewSession(ts, (IPoderosaView)dlg.TargetView.GetAdapter(typeof(IPoderosaView)));
                        sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction);

                        IAutoExecMacroParameter autoExecParam = con.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                        if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null)
                        {
                            TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts);
                        }

                        return(CommandResult.Succeeded);
                    }
                }
                dlg.Dispose();

                return(res);
            }
Esempio n. 7
0
        private static void SessionEntryPoint(AbstractTerminal terminal, CommandResultDocument document)
        {
            try {
                TerminalControl tc = terminal.TerminalHost.TerminalControl;
                Debug.Assert(tc != null);
                RenderProfile          rp          = (RenderProfile)tc.GetRenderProfile().Clone();
                CommandResultSession   session     = new CommandResultSession(document, rp); //現在のRenderProfileを使ってセッションを作る
                TerminalDocument       terminaldoc = terminal.GetDocument();
                PopupViewCreationParam cp          = new PopupViewCreationParam(_viewFactory);
                //結果のサイズに合わせる。ただし高さは20行を上限とする
                cp.InitialSize = new Size(tc.ClientSize.Width, (int)(RuntimeUtil.AdjustIntRange(document.Size, 0, 20) * rp.Pitch.Height) + 2);
                cp.OwnedByCommandTargetWindow = GEnv.Options.CommandPopupAlwaysOnTop;
                cp.ShowInTaskBar = GEnv.Options.CommandPopupInTaskBar;

                IWindowManager       wm     = TerminalEmulatorPlugin.Instance.GetWindowManager();
                ISessionManager      sm     = TerminalEmulatorPlugin.Instance.GetSessionManager();
                IPoderosaPopupWindow window = wm.CreatePopupView(cp);
                sm.StartNewSession(session, window.InternalView);
                sm.ActivateDocument(session.Document, ActivateReason.InternalAction);
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
            }
        }