public static CommandResult OpenShortcutFile(ICommandTarget target, string filename) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); if (window == null) { window = (IPoderosaMainWindow)CommandTargetUtil.AsViewOrLastActivatedView(target).ParentForm.GetAdapter(typeof(IPoderosaMainWindow)); } if (window == null) { return(CommandResult.Ignored); } if (!File.Exists(filename)) { window.Warning(String.Format("{0} is not a file", filename)); return(CommandResult.Failed); } ShortcutFileContent f = null; try { f = ShortcutFileContent.LoadFromXML(filename); } catch (Exception ex) { //変なファイルをドロップしたなどで例外は簡単に起こりうる window.Warning(String.Format("Failed to read {0}\n{1}", filename, ex.Message)); return(CommandResult.Failed); } try { //独立ウィンドウにポップアップさせるようなことは考えていない IContentReplaceableView rv = (IContentReplaceableView)target.GetAdapter(typeof(IContentReplaceableView)); if (rv == null) { rv = (IContentReplaceableView)window.ViewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView)); } Poderosa.Terminal.TerminalControl tc = (Poderosa.Terminal.TerminalControl)rv.GetCurrentContent().GetAdapter(typeof(Poderosa.Terminal.TerminalControl)); if (tc != null) //ターミナルコントロールがないときは無理に設定しにいかない { RenderProfile rp = f.TerminalSettings.UsingDefaultRenderProfile ? TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile() : f.TerminalSettings.RenderProfile; Size sz = tc.CalcTerminalSize(rp); f.TerminalParameter.SetTerminalSize(sz.Width, sz.Height); } ITerminalSession s = TerminalSessionsPlugin.Instance.TerminalSessionStartCommand.StartTerminalSession(target, f.TerminalParameter, f.TerminalSettings); return(s != null ? CommandResult.Succeeded : CommandResult.Failed); } catch (Exception ex) { RuntimeUtil.ReportException(ex); return(CommandResult.Failed); } }
protected void OnOK(object sender, EventArgs args) { this.DialogResult = DialogResult.None; _targetView = GetTargetView(); ITerminalParameter term = PrepareTerminalParameter(); if (term == null) { return; //設定に誤りがある場合 } Poderosa.Terminal.TerminalControl tc = (Poderosa.Terminal.TerminalControl)_targetView.GetAdapter(typeof(Poderosa.Terminal.TerminalControl)); Size sz = tc.CalcTerminalSize((_terminalSettings.RenderProfile == null) ? this.GetInitialRenderProfile() : _terminalSettings.RenderProfile); term.SetTerminalSize(sz.Width, sz.Height); _loginButton.Enabled = false; _cancelButton.Enabled = false; this.Cursor = Cursors.WaitCursor; _originalText = this.Text; this.Text = String.Format("{0} - {1}", _originalText, TEnv.Strings.GetString("Caption.HowToCancel")); StartConnection(); }