public void ApplySplitInfo(string format) { try { //現状を獲得 IPoderosaView[] previous_views = GetAllViews(); IPoderosaDocument[] documents = new IPoderosaDocument[previous_views.Length]; //分割適用後アクティブになるやつ for (int i = 0; i < previous_views.Length; i++) { documents[i] = previous_views[i].Document; } IPoderosaView[] new_views; SessionManagerPlugin sm = SessionManagerPlugin.Instance; if (format.Length > 0) { Form container = _parent.AsForm(); container.SuspendLayout(); Control old_root = this.RootControl; _paneDivision.ApplySplitInfo(old_root.Parent, old_root, format, delegate(string label) { return(CreateNewPane(_defaultViewFactory, DockStyle.Fill)); }); //とりあえずデフォルトファクトリで作成 container.ResumeLayout(true); _singlePane = null; //成功裏に終わったときのみ new_views = GetAllViews(); //新しいのを取得 } else { IContentReplaceableView view; UnifyAll(out view); new_views = new IPoderosaView[] { view }; } //既存ドキュメントに再適用 foreach (DocumentHost dh in sm.GetAllDocumentHosts()) { int index = CollectionUtil.ArrayIndexOf(previous_views, dh.LastAttachedView); if (index != -1) { IPoderosaView new_view = index < new_views.Length ? new_views[index] : new_views[0]; //個数が減ったら先頭に dh.AlternateView(new_view); } } //もともとActiveだったやつを再適用 for (int i = 0; i < documents.Length; i++) { if (documents[i] != null) { sm.AttachDocumentAndView(documents[i], sm.FindDocumentHost(documents[i]).LastAttachedView); //LastAttachedViewはこの上のループで適用済み } } } catch (Exception ex) { RuntimeUtil.ReportException(ex); } }
void Update(IPoderosaMainWindow window) { IPoderosaDocument odocument; if (dict.TryGetValue(window, out odocument)) { window.AsForm().Text = String.Format("{0} - Poderosa", odocument.Caption); } else { window.AsForm().Text = "Poderosa"; } }
void odocument_OnCaptionChanged(object sender, EventArgs e) { IPoderosaMainWindow win = dict2[(IPoderosaDocument)sender]; if (win.AsForm().InvokeRequired) { win.AsForm().BeginInvoke((System.Threading.ThreadStart) delegate(){ this.Update(win); }); } else { this.Update(win); } }
private void ShowAbnormalTerminationMessage() { IPoderosaMainWindow window = _session.OwnerWindow; if (window != null) { Debug.Assert(window.AsForm().InvokeRequired); ITCPParameter tcp = (ITCPParameter)GetConnection().Destination.GetAdapter(typeof(ITCPParameter)); if (tcp != null) { string msg = String.Format(GEnv.Strings.GetString("Message.AbstractTerminal.TCPDisconnected"), tcp.Destination); switch (GEnv.Options.DisconnectNotification) { case WarningOption.StatusBar: window.StatusBar.SetMainText(msg); break; case WarningOption.MessageBox: window.Warning(msg); //TODO Disableオプションつきのサポート break; } } } }
/// <summary> /// Command execution /// </summary> public override CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { PipeTerminalParameter paramInit = null; PipeTerminalSettings settingsInit = null; IExtensionPoint ext = PipePlugin.Instance.PoderosaWorld.PluginManager.FindExtensionPoint("org.poderosa.terminalsessions.loginDialogUISupport"); if (ext != null && ext.ExtensionInterface == typeof(ILoginDialogUISupport)) { foreach (ILoginDialogUISupport sup in ext.GetExtensions()) { ITerminalParameter terminalParam; ITerminalSettings terminalSettings; sup.FillTopDestination(typeof(PipeTerminalParameter), out terminalParam, out terminalSettings); PipeTerminalParameter paramTemp = terminalParam as PipeTerminalParameter; PipeTerminalSettings settingsTemp = terminalSettings as PipeTerminalSettings; if (paramInit == null) { paramInit = paramTemp; } if (settingsInit == null) { settingsInit = settingsTemp; } } } if (paramInit == null) { paramInit = new PipeTerminalParameter(); } if (settingsInit == null) { settingsInit = new PipeTerminalSettings(); } IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow)); CommandResult commandResult = CommandResult.Failed; using (OpenPipeDialog dialog = new OpenPipeDialog()) { dialog.OpenPipe = delegate(PipeTerminalParameter param, PipeTerminalSettings settings) { PipeTerminalConnection connection = PipeCreator.CreateNewPipeTerminalConnection(param, settings); commandResult = PipePlugin.Instance.CommandManager.Execute( PipePlugin.Instance.TerminalSessionsService.TerminalSessionStartCommand, window, connection, settings); return(commandResult == CommandResult.Succeeded); }; dialog.ApplyParams(paramInit, settingsInit); DialogResult dialogResult = dialog.ShowDialog(window != null ? window.AsForm() : null); if (dialogResult == DialogResult.Cancel) { commandResult = CommandResult.Cancelled; } } return(commandResult); }
public ITerminalConnection EstablishConnection(IPoderosaMainWindow window, ITerminalParameter destination, ITerminalSettings settings) { ISSHLoginParameter ssh = (ISSHLoginParameter)destination.GetAdapter(typeof(ISSHLoginParameter)); if (ssh.LetUserInputPassword && ssh.AuthenticationType != Granados.AuthenticationType.KeyboardInteractive) //ダイアログで入力を促して接続 { SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(window, ssh, settings); if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK) { ITerminalConnection con = dlg.Result; AdjustCaptionAndText(settings, ((ITCPParameter)con.Destination.GetAdapter(typeof(ITCPParameter))).Destination, StartCommandIcon.NewConnection); return(con); } else { return(null); } } else //主にReproduceやマクロ。設定済みのパスワードで接続 { IProtocolService protocolservice = TerminalSessionsPlugin.Instance.ProtocolService; ISynchronizedConnector conn = protocolservice.CreateFormBasedSynchronozedConnector(window); IInterruptable r = protocolservice.AsyncSSHConnect(conn.InterruptableConnectorClient, ssh); AdjustCaptionAndText(settings, ((ITCPParameter)destination.GetAdapter(typeof(ITCPParameter))).Destination, StartCommandIcon.NewConnection); return(conn.WaitConnection(r, TerminalSessionsPlugin.Instance.TerminalSessionOptions.TerminalEstablishTimeout)); //時間? } }
public override CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); MacroList dlg = new MacroList(); dlg.ShowDialog(window.AsForm()); return(CommandResult.Succeeded); }
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); }
private void CharDecodeErrorDialog(IPoderosaMainWindow window, string msg) { WarningWithDisableOption dlg = new WarningWithDisableOption(msg); dlg.ShowDialog(window.AsForm()); if (dlg.CheckedDisableOption) { GEnv.Options.CharDecodeErrorBehavior = WarningOption.Ignore; } }
private static CommandResult CmdGenerateKeyPair(ICommandTarget target) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); Debug.Assert(window != null); KeyGenWizard dlg = new KeyGenWizard(); DialogResult r = dlg.ShowDialog(window.AsForm()); return(r == DialogResult.OK ? CommandResult.Succeeded : CommandResult.Cancelled); }
private static CommandResult CmdChangePassphrase(ICommandTarget target) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); Debug.Assert(window != null); ChangePassphrase dlg = new ChangePassphrase(); DialogResult r = dlg.ShowDialog(window.AsForm()); return(r == DialogResult.OK ? CommandResult.Succeeded : CommandResult.Cancelled); }
private static CommandResult CmdAgentKeyListDialog(ICommandTarget target) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); Debug.Assert(window != null); AgentKeyListDialog dlg = new AgentKeyListDialog(); DialogResult r = dlg.ShowDialog(window.AsForm()); return(r == DialogResult.OK ? CommandResult.Succeeded : CommandResult.Cancelled); }
private static CommandResult CmdNewWindow(ICommandTarget target) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); Form f = window.AsForm(); Rectangle location = f.WindowState == FormWindowState.Normal? f.DesktopBounds : f.RestoreBounds; location.X += 20; location.Y += 20; //少し右下に表示 MainWindowArgument arg = new MainWindowArgument(location, FormWindowState.Normal, "", "", 1); WindowManagerPlugin.Instance.CreateNewWindow(arg); return(CommandResult.Succeeded); }
/// <summary> /// Gets System.Windows.Forms.Form of the target. /// </summary> /// <param name="target">Target object which has been passed to the IPoderosaCommand's method.</param> /// <returns>Form object if it is available. Otherwise null.</returns> protected Form GetForm(ICommandTarget target) { IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow)); if (window != null) { return(window.AsForm()); } else { return(null); } }
public void EndCommand(List<GLine> command_result) { string[] stringarray_result = AsStringArrayResult(command_result); Debug.Assert(_window.AsForm().InvokeRequired); //この処理中に次のアクションがセットされることもある if (_currentAction.ReceiverThreadAction != null) _currentAction.ReceiverThreadAction(stringarray_result); else { _window.AsControl().Invoke(_currentAction.MainThreadAction, stringarray_result); } if (_actions.Count > 0) ProcessNextAction(); }
/// <summary> /// メインウィンドウ表示コマンド /// </summary> /// <param name="target">CommandTarget</param> private static CommandResult MainWindow(ICommandTarget target) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); if (window != null) { ConnectProfileForm Form = new ConnectProfileForm(); if (Form.ShowDialog(window.AsForm()) == DialogResult.OK) { return(CommandResult.Succeeded); } } return(CommandResult.Cancelled); }
private static CommandResult CmdExtensionPointList(ICommandTarget target) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); if (window == null) { return(CommandResult.Ignored); } ExtensionPointList dlg = new ExtensionPointList(); dlg.ShowDialog(window.AsForm()); return(CommandResult.Succeeded); }
//文字系のエラー通知 protected void CharDecodeError(string msg) { IPoderosaMainWindow window = _session.OwnerWindow; if (window == null) { return; } Debug.Assert(window.AsForm().InvokeRequired); Monitor.Exit(GetDocument()); //これは忘れるな switch (GEnv.Options.CharDecodeErrorBehavior) { case WarningOption.StatusBar: window.StatusBar.SetMainText(msg); break; case WarningOption.MessageBox: window.AsForm().Invoke(new CharDecodeErrorDialogDelegate(CharDecodeErrorDialog), window, msg); break; } Monitor.Enter(GetDocument()); }
public static CommandResult OpenOptionDialog(ICommandTarget target) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); OptionDialog dlg = new OptionDialog(); if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK) { return(CommandResult.Succeeded); } else { return(CommandResult.Cancelled); } }
public static CommandResult OpenPreferenceEditor(ICommandTarget target) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); PreferenceEditor dlg = new PreferenceEditor(OptionDialogPlugin.Instance.CoreServices.Preferences); if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK) { return(CommandResult.Succeeded); } else { return(CommandResult.Cancelled); } }
//ドキュメントロック中でないと呼んではだめ public void IndicateBell() { IPoderosaMainWindow window = _session.OwnerWindow; if (window != null) { Debug.Assert(window.AsForm().InvokeRequired); Monitor.Exit(GetDocument()); window.StatusBar.SetStatusIcon(Poderosa.TerminalEmulator.Properties.Resources.Bell16x16); Monitor.Enter(GetDocument()); } if (GEnv.Options.BeepOnBellChar) { Win32.MessageBeep(-1); } }
public override void InitializePlugin(IPoderosaWorld poderosa) { base.InitializePlugin(poderosa); #if USING_GENERIC_COMMAND //"ダイアログ"コマンドカテゴリを取得 ICoreServices cs = (ICoreServices)poderosa.GetAdapter(typeof(ICoreServices)); ICommandCategory dialog = cs.CommandManager.CommandCategories.Dialogs; //コマンド作成 GeneralCommandImpl cmd = new GeneralCommandImpl("org.poderosa.helloworld", "Hello World Command", dialog, delegate(ICommandTarget target) { //コマンドの実装 //このコマンドはメインメニューから起動するので、CommandTargetからウィンドウが取得できるはず IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow)); Debug.Assert(window != null); MessageBox.Show(window.AsForm(), "Hello World", "HelloWorld Plugin"); return(CommandResult.Succeeded); }); //コマンドマネージャへの登録 cs.CommandManager.Register(cmd); //ヘルプメニューに登録 IExtensionPoint helpmenu = poderosa.PluginManager.FindExtensionPoint("org.poderosa.menu.help"); helpmenu.RegisterExtension(new PoderosaMenuGroupImpl(new PoderosaMenuItemImpl("org.poderosa.helloworld", "Hello World"))); #else //単なるIPoderosaCommand版 //コマンド作成 PoderosaCommandImpl cmd = new PoderosaCommandImpl(delegate(ICommandTarget target) { //コマンドの実装 //このコマンドはメインメニューから起動するので、CommandTargetからウィンドウが取得できるはず IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow)); Debug.Assert(window != null); MessageBox.Show(window.AsForm(), "Hello World", "HelloWorld Plugin"); return(CommandResult.Succeeded); }); //ヘルプメニューに登録 IExtensionPoint helpmenu = poderosa.PluginManager.FindExtensionPoint("org.poderosa.menu.help"); helpmenu.RegisterExtension(new PoderosaMenuGroupImpl(new PoderosaMenuItemImpl(cmd, "Hello World"))); #endif }
//AboutBox表示のメニューとコマンド private static CommandResult CmdAboutBox(ICommandTarget target) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); if (window == null) { return(CommandResult.Ignored); } IPoderosaAboutBoxFactory f = AboutBoxUtil.GetCurrentAboutBoxFactory(); if (f != null) { AboutBoxUtil.ResetKeyBufferInAboutBox(); f.CreateAboutBox().ShowDialog(window.AsForm()); return(CommandResult.Succeeded); } else { return(CommandResult.Failed); } }
private static CommandResult CmdCopyToFile(ICommandTarget target) { string text = GetSelectedText(target, TextFormatOption.Default); if (text == null) { return(CommandResult.Ignored); } IPoderosaMainWindow window = TerminalCommandTarget.AsTerminal(target).OwnerWindow; SaveFileDialog dlg = new SaveFileDialog(); //dlg.InitialDirectory = GApp.Options.DefaultFileDir; dlg.Title = GEnv.Strings.GetString("Util.DestinationToSave"); dlg.Filter = "All Files(*.*)|*.*"; if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK) { StreamWriter wr = null; try { wr = new StreamWriter(new FileStream(dlg.FileName, FileMode.Create), Encoding.Default); wr.Write(text); return(CommandResult.Succeeded); } catch (Exception ex) { window.Warning(ex.Message); return(CommandResult.Failed); } finally { if (wr != null) { wr.Close(); } } } else { return(CommandResult.Cancelled); } }
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.Port); 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); }
public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow)); if (window == null) { return(CommandResult.Ignored); } LocalShellLoginDialog dlg = new LocalShellLoginDialog(window); using (dlg) { dlg.ApplyParam(); if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK) { ITerminalConnection con = dlg.Result; if (con != null) { ISessionManager sm = (ISessionManager)CygwinPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager)); TerminalSession ts = new TerminalSession(con, dlg.TerminalSettings); sm.StartNewSession(ts, dlg.TargetView); sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction); IAutoExecMacroParameter autoExecParam = con.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter; if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && CygwinPlugin.Instance.MacroEngine != null) { CygwinPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts); } return(CommandResult.Succeeded); } } } return(CommandResult.Cancelled); }
public ITerminalConnection EstablishConnection(IPoderosaMainWindow window, ITerminalParameter destination, ITerminalSettings settings) { ISSHLoginParameter ssh = (ISSHLoginParameter)destination.GetAdapter(typeof(ISSHLoginParameter)); if (ssh.LetUserInputPassword && ssh.AuthenticationType != Granados.AuthenticationType.KeyboardInteractive) { //ダイアログで入力を促して接続 SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(window, ssh, settings); if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK) { ITerminalConnection con = dlg.Result; AdjustCaptionAndText(settings, ((ITCPParameter)con.Destination.GetAdapter(typeof(ITCPParameter))).Destination, StartCommandIcon.NewConnection); return con; } else return null; } else { //主にReproduceやマクロ。設定済みのパスワードで接続 IProtocolService protocolservice = TerminalSessionsPlugin.Instance.ProtocolService; ISynchronizedConnector conn = protocolservice.CreateFormBasedSynchronozedConnector(window); IInterruptable r = protocolservice.AsyncSSHConnect(conn.InterruptableConnectorClient, ssh); AdjustCaptionAndText(settings, ((ITCPParameter)destination.GetAdapter(typeof(ITCPParameter))).Destination, StartCommandIcon.NewConnection); return conn.WaitConnection(r, TerminalSessionsPlugin.Instance.TerminalSessionOptions.TerminalEstablishTimeout); //時間? } }
private void CharDecodeErrorDialog(IPoderosaMainWindow window, string msg) { WarningWithDisableOption dlg = new WarningWithDisableOption(msg); dlg.ShowDialog(window.AsForm()); if (dlg.CheckedDisableOption) { GEnv.Options.CharDecodeErrorBehavior = WarningOption.Ignore; } }
public void OnDocumentActivated(IPoderosaMainWindow window, IPoderosaDocument document) { window.AsForm().Text = String.Format("{0} - Poderosa", document.Caption); }
public void OnDocumentDeactivated(IPoderosaMainWindow window) { window.AsForm().Text = "Poderosa"; }
public void OnDocumentDeactivated(IPoderosaMainWindow window) { window.AsForm().Text = "Poderosa"; }
public void OnDocumentActivated(IPoderosaMainWindow window, IPoderosaDocument document) { window.AsForm().Text = String.Format("{0} - Poderosa", document.Caption); }