상속: LoginDialogBase
예제 #1
0
            public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
            {
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));

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

#if OLD_LOGIN_DIALOG
                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);
#else
                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);
                }
#endif
            }
예제 #2
0
            public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
            {
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
                if (window == null)
                    return CommandResult.Ignored;

                #if OLD_LOGIN_DIALOG
                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;
                #else
                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;
                }
                #endif
            }
예제 #3
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;
                //Task.Run(() =>
                {
                    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;
            }