/// <summary> /// /// </summary> /// <param name="host"></param> /// <param name="settings"></param> /// <param name="connection"></param> /// <exclude/> public TerminalTransmission(AbstractTerminal host, ITerminalSettings settings, ITerminalConnection connection) { _host = host; _settings = settings; _connection = connection; _dataForLocalEcho = new ByteDataFragment(); }
public void SuccessfullyExit(ITerminalConnection result) { if (_timeout) return; _result = result; //_result.SetServerInfo(((TCPTerminalParam)_result.Param).Host, swt.IPAddress); _event.Set(); }
public TerminalSession(ITerminalConnection connection, ITerminalSettings terminalSettings) { _terminalSettings = terminalSettings; //VT100�w��ł�xterm�V�[�P���X�𑗂��Ă���A�v���P�[�V�������������Ȃ��̂� _terminal = AbstractTerminal.Create(new TerminalInitializeInfo(this, connection.Destination)); _output = new TerminalTransmission(_terminal, _terminalSettings, connection); _terminalSettings.ChangeCaption += delegate(string caption) { this.OwnerWindow.DocumentTabFeature.Update(_terminal.IDocument); }; }
public TerminalSession(ITerminalConnection connection, ITerminalSettings terminalSettings) { _terminalSettings = terminalSettings; //VT100指定でもxtermシーケンスを送ってくるアプリケーションが後をたたないので _terminal = AbstractTerminal.Create(new TerminalInitializeInfo(this, connection.Destination)); _output = new TerminalTransmission(_terminal, _terminalSettings, connection); _terminalSettings.ChangeCaption += delegate(string caption) { this.OwnerWindow.DocumentTabFeature.Update(_terminal.IDocument); }; }
public override CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow)); SerialLoginDialog dlg = new SerialLoginDialog(); using (dlg) { SerialTerminalParam tp = new SerialTerminalParam(); SerialTerminalSettings ts = SerialPortUtil.CreateDefaultSerialTerminalSettings(tp.PortName); dlg.ApplyParam(tp, ts); if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK) //TODO 親ウィンドウ指定 { ITerminalConnection con = dlg.ResultConnection; if (con != null) { return(_instance.CommandManager.Execute(_instance.TerminalSessionsService.TerminalSessionStartCommand, window, con, dlg.ResultTerminalSettings)); } } } return(CommandResult.Cancelled); }
/// <summary> /// Gets SSHConnection from the target. /// Returns null if current terminal doesn't have SSH connection. /// </summary> /// <param name="target">Target object which has been passed to the IPoderosaCommand's method.</param> /// <returns>A SSH connection object corresponding with current terminal. Null if it cannot be found.</returns> protected SSHConnection GetSSHConnection(ICommandTarget target) { ITerminalConnection connection = GetTerminalConnection(target); // Implementation classes for SSH connection are internal classes in another assembly. // We need to use reflection to get an instance of SSHChannel. if (connection != null && connection.Socket != null) { Type socketType = connection.Socket.GetType(); PropertyInfo prop = socketType.GetProperty("Channel", BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty); if (prop != null && prop.CanRead) { SSHChannel channel = prop.GetValue(connection.Socket, null) as SSHChannel; if (channel != null) { return(channel.Connection); } } } return(null); }
public void SuccessfullyExit(ITerminalConnection connection) { ITerminalSettings terminalSettings = PoderosaTerminalEmulatorService.CreateDefaultTerminalSettings(Connection.DisplayName, null); TerminalSession session = new TerminalSession(connection, terminalSettings); SessionHost sessionHost = new SessionHost(PoderosaSessionManagerPlugin, session); TerminalView terminalView = new TerminalView(null, _terminal); RenderProfile renderProfile = new RenderProfile(_terminal.GetRenderProfile()); renderProfile.BackColor = Connection.BackgroundColor; renderProfile.ForeColor = Connection.TextColor; renderProfile.FontName = Connection.FontFamily; renderProfile.FontSize = Connection.FontSize; session.TerminalSettings.BeginUpdate(); session.TerminalSettings.Encoding = Connection.Encoding; session.TerminalSettings.RenderProfile = renderProfile; session.TerminalSettings.EndUpdate(); _telnetConnection = (TelnetTerminalConnection)connection; Invoke( new Action( () => { _terminal.Attach(session); session.InternalStart(sessionHost); session.InternalAttachView(sessionHost.DocumentAt(0), terminalView); _telnetConnection.ConnectionEventReceiver.NormalTermination += ConnectionEventReceiver_NormalTermination; _telnetConnection.ConnectionEventReceiver.AbnormalTermination += ConnectionEventReceiver_AbnormalTermination; ParentForm.Closing += ParentForm_OnClosing; connection.TerminalOutput.Resize(session.Terminal.GetDocument().TerminalWidth, session.Terminal.GetDocument().TerminalHeight); OnConnected(_terminal, null); })); }
private ITerminalConnection CreateSSHConnection(SSHProtocol sshprotocol) { ISSHLoginParameter ssh = _protocolService.CreateDefaultSSHParameter(); ssh.Method = sshprotocol; ssh.Account = UnitTestUtil.GetUnitTestConfig("protocols.ssh_account"); ssh.PasswordOrPassphrase = UnitTestUtil.GetUnitTestConfig("protocols.ssh_password"); ITCPParameter tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter)); tcp.Destination = UnitTestUtil.GetUnitTestConfig("protocols.ssh_connectable"); Debug.Assert(tcp.Port == 22); ISynchronizedConnector sc = _protocolService.CreateFormBasedSynchronozedConnector(null); IInterruptable t = _protocolService.AsyncSSHConnect(sc.InterruptableConnectorClient, ssh); ITerminalConnection con = sc.WaitConnection(t, 5000); Debug.Assert(con.Destination == ssh); _rawsocket = ((InterruptableConnector)t).RawSocket; _testReceiver = new TestReceiver(); con.Socket.RepeatAsyncRead(_testReceiver); return(con); }
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); }
/// <summary> /// Check if current terminal is accepted. /// </summary> /// <param name="target">Target object which has been passed to the IPoderosaCommand's method.</param> /// <param name="acceptSSH1">Whether SSH1 connection is accepted.</param> /// <param name="acceptSSH2">Whether SSH2 connection is accepted.</param> /// <returns>True if current terminal is accepted.</returns> protected bool IsAcceptable(ICommandTarget target, bool acceptSSH1, bool acceptSSH2) { // Getting a connection object using GetSSHConnection() may be heavy. // We check a connection parameter. ITerminalConnection connection = GetTerminalConnection(target); if (connection != null && connection.Destination != null) { ISSHLoginParameter param = (ISSHLoginParameter)connection.Destination.GetAdapter(typeof(ISSHLoginParameter)); if (param != null) { switch (param.Method) { case SSHProtocol.SSH1: return(acceptSSH1); case SSHProtocol.SSH2: return(acceptSSH2); } } } return(false); }
public CreateUserCommand(ITerminalConnection term) : base("create-user", "Creates a new user. Params: login password") { _term = term; }
public void SuccessfullyExit(ITerminalConnection result) { _successCount++; _connection = result; _event.Set(); }
//基本のスタートセッション 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; }
public void InitializeModelTerminalTask(IModalTerminalTaskSite site, IByteAsyncInputStream default_handler, ITerminalConnection connection) { _site = site; _defaultHandler = default_handler; _connection = connection; }
private void _cancelButton_Click(object sender, EventArgs e) { if (_interruptable != null) { Interrupt(); return; } _terminalSettings = null; _terminalConnection = null; this.DialogResult = DialogResult.Cancel; Close(); }
public bool StartConnection() { bool bConResult = false; _isConnected = false; /*if (_session != null) * if (_session.TerminalConnection != null) * _isConnected = _session.TerminalConnection.IsClosed; */ if (_Console == null) { _Console = new ConsoleMain(); } //ISynchronizedConnector synchCon = _Console.CreateSynchronizedConnector(null); if (ssh != null) { _connector = _Console.AsyncSSHConnect(this /* synchCon.InterruptableConnectorClient */, ssh); } else { _connector = _Console.AsyncTelnetConnect(this /* synchCon.InterruptableConnectorClient */, tcp); } if (_connector == null) { _isRunning = false; return(bConResult); } //_result = synchCon.WaitConnection(_connector, _timeout * 1000); while ((!_timedOut) && (!_isConnected)) { Thread.Sleep(100); } _result = ((InterruptableConnector)_connector).Result; if (_result == null) { _connector = null; _isRunning = false; return(bConResult); } try { _session = new TerminalSession(((InterruptableConnector)_connector).Result, _terminalSettings, _terminalOptions); _session._parent = this; //SessionHost host = new SessionHost(this, session); _session.InternalStart(); // => _output.Connection.Socket.RepeatAsyncRead(_terminal); bConResult = true; } catch (Exception ex) { bConResult = false; if (_debug > 0) { Console.WriteLine(ex.Message); } } return(bConResult); }
public void Connect() { try { switch (_protocol) { case ProtocolType.Cywin: _synchronizedConnector = _basePoderosaInstance.ProtocolService.CreateFormBasedSynchronozedConnector(_window); _asyncConnection = _basePoderosaInstance.ProtocolService.AsyncCygwinConnect(_synchronizedConnector.InterruptableConnectorClient, (ICygwinParameter)_terminalParameter); _terminalConnection = _synchronizedConnector.WaitConnection(_asyncConnection, _basePoderosaInstance.TerminalSessionsPlugin.TerminalSessionOptions.TerminalEstablishTimeout); break; case ProtocolType.Raw: break; case ProtocolType.RLogin: break; case ProtocolType.Serial: _terminalConnection =(ITerminalConnection) SerialPortUtil.CreateNewSerialConnection(_window,(SerialTerminalParam)_terminalParameter,(SerialTerminalSettings)_terminalSettings); break; case ProtocolType.SSH1: case ProtocolType.SSH2: _synchronizedConnector = _basePoderosaInstance.ProtocolService.CreateFormBasedSynchronozedConnector(_window); _asyncConnection = _basePoderosaInstance.ProtocolService.AsyncSSHConnect(_synchronizedConnector.InterruptableConnectorClient, (ISSHLoginParameter)_terminalParameter); _terminalConnection = _synchronizedConnector.WaitConnection(_asyncConnection, _basePoderosaInstance.TerminalSessionsPlugin.TerminalSessionOptions.TerminalEstablishTimeout); break; case ProtocolType.Telnet: _synchronizedConnector = _basePoderosaInstance.ProtocolService.CreateFormBasedSynchronozedConnector(_window); _asyncConnection = _basePoderosaInstance.ProtocolService.AsyncTelnetConnect(_synchronizedConnector.InterruptableConnectorClient, (ITCPParameter)_terminalParameter); _terminalConnection = _synchronizedConnector.WaitConnection(_asyncConnection, _basePoderosaInstance.TerminalSessionsPlugin.TerminalSessionOptions.TerminalEstablishTimeout); break; default: _terminalConnection = null; break; } _terminalSession = new TerminalSession(_terminalConnection, _terminalSettings); _basePoderosaInstance.SessionManagerPlugin.StartNewSession(_terminalSession, _terminalView); _basePoderosaInstance.SessionManagerPlugin.ActivateDocument(_terminalSession.Terminal.IDocument, ActivateReason.InternalAction); } catch (Exception ex) { RuntimeUtil.ReportException(ex); //return CommandResult.Failed; } }
public void InitializeModelTerminalTask(IModalTerminalTaskSite site, IByteAsyncInputStream default_handler, ITerminalConnection connection) { _site = site; _bufferForMacro = new StringBuilder(); _closed = false; }
//復活 /// <exclude/> public void Revive(ITerminalConnection connection, int terminal_width, int terminal_height) { _connection = connection; Resize(terminal_width, terminal_height); }
public void Revive(ITerminalConnection connection) { TerminalDocument doc = _terminal.GetDocument(); _output.Revive(connection, doc.TerminalWidth, doc.TerminalHeight); this.OwnerWindow.DocumentTabFeature.Update(_terminal.IDocument); _output.Connection.Socket.RepeatAsyncRead(_terminal); //再受信 }
//ISocketWithTimeoutClient これらはこのウィンドウとは別のスレッドで実行されるので慎重に public void SuccessfullyExit(ITerminalConnection result) { if (this.InvokeRequired) { this.Invoke(new SuccessfullyExitDelegate(this.SuccessfullyExit), new object[] { result }); } else { _result = result; this.DialogResult = DialogResult.OK; this.Cursor = Cursors.Default; Close(); } }
public GetUsersCommand(ITerminalConnection term) : base("get-users", "Gets the list of all users") { _term = term; }
public void ConnectionFailed(string message) { _terminalConnection = null; errorMsg = message; mreConnect.Set(); }
public bool Start() { _logger = LogManager.GetLogger("[MainHost]"); _logger.Info("------------------------------JEDIUM SERVER---------------------------"); _logger.Info("Starting at: " + DateTime.Now); //settings var parser = new FileIniDataParser(); IniData data = parser.ReadFile("config\\ServerConfig.ini"); MainSettings.BehavioursPluginPath = data["Server"]["BehavioursPluginPath"]; MainSettings.WebApiHost = data["Server"]["WebApiHost"]; MainSettings.DBUrl = data["Server"]["DBUrl"]; MainSettings.DatabaseName = data["Server"]["DatabaseName"]; MainSettings.CollectMessageStats = bool.Parse(data["Statistics"]["CollectMessageStats"]); MainSettings.StatsCollectionInterval = int.Parse(data["Statistics"]["StatsCollectionInterval"]); MainSettings.mainURL = data["Server"]["MainURL"]; MainSettings.TickDelay = int.Parse(data["Server"]["TickDelay"]); _logger.Warn("___TICK DELAY:" + MainSettings.TickDelay); MD5 mcalc = MD5.Create(); byte[] dbytes = File.ReadAllBytes("Domain.dll"); MainSettings.ServerHash = mcalc.ComputeHash(dbytes).ToHex(false); _logger.Info($"Server domain hash: {MainSettings.ServerHash}"); //preload domain var type = typeof(ISceneActor); if (type == null) { throw new InvalidProgramException("!"); } //load plugins // BehaviourManager.LoadBehaviours(MainSettings.BehavioursPluginPath); //get config (app.config) AkkaConfigurationSection section = (AkkaConfigurationSection)ConfigurationManager.GetSection("akka"); //_logger.Info(); Config aconfig = section.AkkaConfig; Config localConfig = ConfigurationFactory.ParseString("akka.remote.helios.tcp.hostname = " + MainSettings.mainURL) .WithFallback(aconfig); //попытаться запустить актер сервера try { _system = ActorSystem.Create("VirtualFramework", localConfig); } catch (Exception ex) { _logger.Error(ex.Message); throw; } // на случай разрыва соединения DeadRequestProcessingActor.Install(_system); _databaseAgent = _system.ActorOf(Props.Create(() => new MongoDbActor()), "DataBase") .Cast <DatabaseAgentRef>(); //TODO: Add test for connection _terminal = _system.ActorOf(Props.Create(() => new TerminalConnection(_databaseAgent)), "Terminal") .Cast <TerminalConnectionRef>(); _serverConnection = _system .ActorOf(Props.Create(() => new ServerConnection(_databaseAgent)), "ServerEndpoint") .Cast <ConnectionRef>(); //_databaseAgent.SetDummyObjectTest().Wait(); _manager = _system .ActorOf(Props.Create(() => new ObjectsManager(_databaseAgent, _serverConnection)), "ObjectManager") .Cast <ObjectsManagerRef>(); //Editor _editorConnection = _system.ActorOf(Props.Create(() => new EditorConnection(_manager, _databaseAgent)), "EditorConnection") .Cast <EditorConnectionRef>(); //assets host _webApiHost = _system .ActorOf(Props.Create(() => new WebApiHost(MainSettings.WebApiHost, _databaseAgent, _manager)), "AssetsHost") .Cast <WebApiHostRef>(); _pluginsHost = _system.ActorOf(Props.Create(() => new PluginsHost(_databaseAgent, _manager)), "PluginsHost") .Cast <PluginsHostRef>(); // _pluginsHost.LoadPlugins().Wait(); _manager.LoadAllScenes().Wait(); return(true); }
// -------------------------------------------------------------------- // 接続成功 (IInterruptableConnectorClient.SuccessfullyExit) // -------------------------------------------------------------------- /// <summary> /// IInterruptableConnectorClient.SuccessfullyExitのコールバック関数です。 /// </summary> /// <remarks> /// SSH接続もしくはTelnet接続が確立したときに呼ばれます。ターミナル画面を表示するために /// 以下の手順で処理を行います。<br/> /// (1) 新規にPoderosa.Forms.MainWindowを作成します。<br/> /// (2) MainWindow上にビューを作成します。<br/> /// (3) 作成したビュー上でターミナルセッションを開始します。<br/> /// (4) MainWindow上にあるメニューチップとツールチップを非表示にします。<br/> /// (5) ターミナル画面のみが表示されたMainWindowを本コントロール上に載せます。<br/> /// (6) TerminalConnectedイベントを発行します。 /// </remarks> /// <param name="result">Newly-created SSH connection.</param> public void SuccessfullyExit(ITerminalConnection result) { #if DEBUG WriteLog("SuccessfullyExit()が呼び出されました。"); #endif // // 返されたターミナルコネクションがICloseableTerminalConnectionであれば、 // コネクションが切断されたことを通知するイベントが利用できますので、ハンドラを // 設定します。 // ※ SSH接続時はICloseableTerminalConnectionが返されますが、Telnet接続時は返されません。 // ICloseableTerminalConnection closableConnection = result as ICloseableTerminalConnection; if (closableConnection != null) { _isCloseableConnection = true; closableConnection.ConnectionClosed += terminal_ConnectionClosed; closableConnection.ConnectionLost += terminal_ConnectionLost; } else { _isCloseableConnection = false; } // // ウィンドウマネージャを取得します。 // ICoreServices coreServices = (ICoreServices)PoderosaAccessPoint.World.GetAdapter(typeof(ICoreServices)); IWindowManager windowManager = coreServices.WindowManager; // // Invokeメソッドを用いてGUIスレッド上で処理実行させます。 // windowManager.MainWindows.First().AsForm().Invoke(new Action(() => { // // 返されたターミナルコネクションとターミナル設定から、ターミナルセッションを // 作成します。 // _session = new Sessions.TerminalSession(result, _settings); // // Poderosa.Forms.MainWindowを新規に生成し、ビューを作成します。 // IPoderosaMainWindow window = windowManager.CreateNewWindow( new MainWindowArgument(ClientRectangle, FormWindowState.Normal, "", "", 1)); IViewManager viewManager = window.ViewManager; IContentReplaceableView view = (IContentReplaceableView)viewManager.GetCandidateViewForNewDocument().GetAdapter( typeof(IContentReplaceableView)); // // セッションマネージャに新しいターミナルセッションを作成したビュー上で // 開始するように要求します。 // coreServices.SessionManager.StartNewSession(_session, view); // // ターミナルセッションの設定を調整します。 // - サイズチップは表示しません。 // _session.TerminalControl.HideSizeTip = true; // // ビューの親フォームはPoderosa.Forms.MainWindowです。 // MainWindow上にはメニューストリップやツールストリップが載せられていますので、 // ターミナル画面以外の全てを非表示にします。 // Form containerForm = view.ParentForm.AsForm(); foreach (Control control in containerForm.Controls) { if (control is MenuStrip || control.GetType().Name == "PoderosaStatusBar") { control.Visible = false; } else if (control.GetType().Name == "PoderosaToolStripContainer") { foreach (ToolStripPanel child in control.Controls.OfType<ToolStripPanel>()) { child.Visible = false; } foreach (ToolStripContentPanel child in control.Controls.OfType<ToolStripContentPanel>()) { foreach (Control grandChild in child.Controls) { if (grandChild.GetType().Name != "TerminalControl") { grandChild.Visible = false; } } } } } // // ターミナル画面のみが表示されるMainWindowを本コントロール上に載せます。 // containerForm.TopLevel = false; containerForm.FormBorderStyle = FormBorderStyle.None; containerForm.Width = Width; containerForm.Height = Height; containerForm.Dock = DockStyle.Fill; containerForm.Parent = this; // // ビューコントロールのBackColorChangedイベントを捕捉することで、 // Telnet接続時のCtrl-D入力やlogoutコマンドによる切断を検査する契機とします。 // ※ Ctrl-Dを送信した後、ビューコントロールのBackColorChangedイベントは // 2回発生します。1回目はBlackに変わっており、2回目はControlDarkです。 // これにより、表示プロファイルの背景色とかぶっても問題がないと言えます。 // view.AsControl().BackColorChanged += new EventHandler(view_BackColorChanged); view.AsControl().Focus(); })); // // TerminalConnectイベントを発行します。 // State = LineState.Connected; if (TerminalConnected != null) { TerminalConnected(this, new EventArgs()); } }
public void SuccessfullyExit(ITerminalConnection result) { _succeeded = true; _message = null; _notified = true; _event.Set(); }
public void SuccessfullyExit(ITerminalConnection result) { if (this.InvokeRequired) { this.Invoke((Action)(() => { SuccessfullyExit(result); })); return; } _interruptable = null; // allow dialog to close _terminalConnection = result; this.DialogResult = DialogResult.OK; this.Cursor = Cursors.Default; Close(); }
public void SuccessfullyExit(ITerminalConnection result) { _terminalConnection = result; mreConnect.Set(); }
/// <summary> /// コンストラクタ /// </summary> public void InitializeModelTerminalTask(IModalTerminalTaskSite site, IByteAsyncInputStream default_handler, ITerminalConnection connection) { _site = site; _buffer = new StringBuilder(); _closed = false; }
/// <summary> /// Called when <see cref="IProtocolService.AsyncSSHConnect"/> is able to successfully establish the SSH connection. Creates a new /// <see cref="IPoderosaMainWindow"/> instance and points the newly created connection to a new document instance within that window. We then steal /// the <see cref="IContentReplaceableView"/> terminal window from Poderosa and set its parent to ourself, thus displaying the terminal within this /// control. /// </summary> /// <param name="result">Newly-created SSH connection.</param> public void SuccessfullyExit(ITerminalConnection result) { ICoreServices coreServices = (ICoreServices)_poderosaWorld.GetAdapter(typeof(ICoreServices)); IWindowManager windowManager = coreServices.WindowManager; // Wire up the event handlers on the newly-created connection. (result as ICloseableTerminalConnection).ConnectionClosed += TerminalControl_ConnectionClosed; (result as ICloseableTerminalConnection).ConnectionLost += TerminalControl_ConnectionLost; // We run all of this logic within an Invoke() to avoid trying to do this on the wrong GUI thread windowManager.MainWindows.First().AsForm().Invoke( new Action( () => { // Create a new Poderosa window to contain the connection terminal IPoderosaMainWindow window = windowManager.CreateNewWindow(new MainWindowArgument(ClientRectangle, FormWindowState.Normal, "", "", 1)); IViewManager viewManager = window.ViewManager; Sessions.TerminalSession session = new Sessions.TerminalSession(result, _settings); // Create a new connection window within the Poderosa window, which we will later steal IContentReplaceableView view = (IContentReplaceableView)viewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView)); coreServices.SessionManager.StartNewSession(session, view); session.TerminalControl.HideSizeTip = true; Form containerForm = view.ParentForm.AsForm(); // Hide all of the toolbar and statusbar chrome in the connection window and display only the terminal itself (it's a little // clumsy, I know) foreach (Control control in containerForm.Controls) { if (control is MenuStrip || control.GetType().Name == "PoderosaStatusBar") { control.Visible = false; } else if (control.GetType().Name == "PoderosaToolStripContainer") { foreach (ToolStripPanel child in control.Controls.OfType <ToolStripPanel>()) { child.Visible = false; } foreach (ToolStripContentPanel child in control.Controls.OfType <ToolStripContentPanel>()) { foreach (Control grandChild in child.Controls) { if (grandChild.GetType().Name != "TerminalControl") { grandChild.Visible = false; } } } } } // Steal the terminal view and display it within this control containerForm.TopLevel = false; containerForm.FormBorderStyle = FormBorderStyle.None; containerForm.Width = Width; containerForm.Height = Height; containerForm.Dock = DockStyle.Fill; containerForm.Parent = this; view.AsControl().Focus(); })); // Invoke the Connected event if (Connected != null) { Connected(this, new EventArgs()); } }