public static CommandResult Test(ICommandTarget target) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); ISplittableViewManager sp = (ISplittableViewManager)window.ViewManager.GetAdapter(typeof(ISplittableViewManager)); sp.ApplySplitInfo("V(33:Lterminal,33:Lterminal,L:Lterminal)"); return(CommandResult.Succeeded); }
public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { Debug.Assert(args.Length == 1); Debug.Assert(_module == args[0]); MacroPlugin.Instance.MacroManager.Execute(CommandTargetUtil.AsWindow(target).AsForm(), _module); return(CommandResult.Succeeded); }
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 static CommandResult PromptRecogTestCommand(ICommandTarget target) { ITerminalSession ts = (ITerminalSession)CommandTargetUtil.AsDocumentOrViewOrLastActivatedDocument(target).OwnerSession.GetAdapter(typeof(ITerminalSession)); Debug.Assert(ts != null); new PromptRecognitionTest().Start(ts); return(CommandResult.Succeeded); }
internal static ITerminalSession AsTerminalSession(ICommandTarget target) { IPoderosaDocument doc = CommandTargetUtil.AsDocumentOrViewOrLastActivatedDocument(target); if (doc == null) { return(null); } return(doc.OwnerSession.GetAdapter(typeof(ITerminalSession)) as ITerminalSession); }
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); }
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)); } TerminalControl tc = (TerminalControl)rv.GetCurrentContent().GetAdapter(typeof(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); } }
public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { _window = CommandTargetUtil.AsWindow(target); Debug.Assert(_window != null); if (_actions.Count == 0) return CommandResult.Ignored; else { //すぐに終わるものでない ProcessNextAction(); return CommandResult.Succeeded; } }
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 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); } }
//CommandTargetからTerminalSessionを得る public static ITerminalSession AsTerminalSession(ICommandTarget target) { IPoderosaDocument document = CommandTargetUtil.AsDocumentOrViewOrLastActivatedDocument(target); if (document == null) { return(null); } else { ISession session = document.OwnerSession; return((ITerminalSession)session.GetAdapter(typeof(ITerminalSession))); } }
public override CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { ITerminalControlHost host = TerminalCommandTarget.AsOpenTerminal(target); if (host.Terminal.CurrentModalTerminalTask != null) { //TODO 関連付けられたXZModemDialogをActivateするようにしたい return CommandResult.Ignored; } else { XZModemDialog dlg = new XZModemDialog(); dlg.Owner = CommandTargetUtil.AsViewOrLastActivatedView(target).ParentForm.AsForm(); dlg.Initialize(host.Terminal); dlg.Show(); return CommandResult.Succeeded; } }
/// <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); }
/// <summary> /// アクティブセッション追加コマンド /// </summary> /// <param name="target">CommandTarget</param> private static CommandResult AddConnectProfile(ICommandTarget target) { IPoderosaDocument document = CommandTargetUtil.AsDocumentOrViewOrLastActivatedDocument(target); if (document != null) { ITerminalSession ts = (ITerminalSession)document.OwnerSession.GetAdapter(typeof(ITerminalSession)); if (ts != null) { Commands _cmd = new Commands(); _cmd.NewProfileCurrentSessionCommand(ts); return(CommandResult.Succeeded); } } return(CommandResult.Cancelled); }
/// <summary> /// プラグイン実行 /// </summary> public override CommandResult InternalExecute(ICommandTarget target, params Poderosa.IAdaptable[] args) { // モードレス表示 IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); Form = new BroadcastCommandForm(window); Form.Show(); return(CommandResult.Succeeded); /* * // モーダル表示 * IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); * BroadcastCommandForm Form = new BroadcastCommandForm(window); * if (Form.ShowDialog(window.AsForm()) == DialogResult.OK) { * return CommandResult.Succeeded; * } else { * return CommandResult.Cancelled; * } */ }
public static ITerminalSession InvokeOpenSessionOrNull(ICommandTarget target, TerminalParam param) { ITerminalParameter tp = param.ConvertToTerminalParameter(); ITerminalSettings ts = CreateTerminalSettings(param); IViewManager pm = CommandTargetUtil.AsWindow(target).ViewManager; //独立ウィンドウにポップアップさせるようなことは考えていない IContentReplaceableView rv = (IContentReplaceableView)pm.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView)); TerminalControl tc = (TerminalControl)rv.GetCurrentContent().GetAdapter(typeof(TerminalControl)); if (tc != null) //ターミナルコントロールがないときは無理に設定しにいかない { RenderProfile rp = ts.UsingDefaultRenderProfile ? MacroPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile() : ts.RenderProfile; Size sz = tc.CalcTerminalSize(rp); tp.SetTerminalSize(sz.Width, sz.Height); } return((ITerminalSession)MacroPlugin.Instance.WindowManager.ActiveWindow.AsForm().Invoke(new OpenSessionDelegate(OpenSessionOrNull), tp, ts)); }
public void BypassDragDrop(Control target, DragEventArgs args) { ICommandTarget ct = CommandTargetUtil.AsCommandTarget(target as IAdaptable); if (ct == null) { return; } if (args.Data.GetDataPresent("FileDrop")) { string[] filenames = (string[])args.Data.GetData("FileDrop", true); IFileDropHandler[] hs = (IFileDropHandler[])_poderosaWorld.PluginManager.FindExtensionPoint(WindowManagerConstants.FILEDROPHANDLER_ID).GetExtensions(); foreach (IFileDropHandler h in hs) { if (h.CanAccept(ct, filenames)) { h.DoDropAction(ct, filenames); return; } } } }
/// <summary> /// 接続 /// </summary> public void Connect() { ITCPParameter tcp = null; // プロトコル if (_prof.Protocol == ConnectionMethod.Telnet) { // Telnet tcp = ConnectProfilePlugin.Instance.ProtocolService.CreateDefaultTelnetParameter(); tcp.Destination = _prof.HostName; tcp.Port = _prof.Port; ITelnetParameter telnetParameter = null; telnetParameter = (ITelnetParameter)tcp.GetAdapter(typeof(ITelnetParameter)); if (telnetParameter != null) { telnetParameter.TelnetNewLine = _prof.TelnetNewLine; } } else if ((_prof.Protocol == ConnectionMethod.SSH1) || (_prof.Protocol == ConnectionMethod.SSH2)) { // SSH ISSHLoginParameter ssh = ConnectProfilePlugin.Instance.ProtocolService.CreateDefaultSSHParameter(); tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter)); tcp.Destination = _prof.HostName; tcp.Port = _prof.Port; ssh.Method = (_prof.Protocol == ConnectionMethod.SSH1) ? SSHProtocol.SSH1 : SSHProtocol.SSH2; ssh.Account = _prof.UserName; ssh.AuthenticationType = ConvertAuth(_prof.AuthType); ssh.PasswordOrPassphrase = _prof.Password; ssh.IdentityFileName = _prof.KeyFile; ssh.LetUserInputPassword = (_prof.AutoLogin == true) ? false : true; } // TerminalSettings(表示プロファイル/改行コード/文字コード) ITerminalSettings terminalSettings = ConnectProfilePlugin.Instance.TerminalEmulatorService.CreateDefaultTerminalSettings(_prof.HostName, null); terminalSettings.BeginUpdate(); terminalSettings.RenderProfile = _prof.RenderProfile; terminalSettings.TransmitNL = _prof.NewLine; terminalSettings.Encoding = _prof.CharCode; terminalSettings.LocalEcho = false; terminalSettings.EndUpdate(); // TerminalParameter ITerminalParameter terminalParam = (ITerminalParameter)tcp.GetAdapter(typeof(ITerminalParameter)); // ターミナルサイズ(これを行わないとPoderosa起動直後のOnReceptionが何故か機能しない, 行わない場合は2回目以降の接続時は正常) IViewManager viewManager = CommandTargetUtil.AsWindow(ConnectProfilePlugin.Instance.WindowManager.ActiveWindow).ViewManager; IContentReplaceableView contentReplaceableView = (IContentReplaceableView)viewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView)); TerminalControl terminalControl = (TerminalControl)contentReplaceableView.GetCurrentContent().GetAdapter(typeof(TerminalControl)); if (terminalControl != null) { Size size = terminalControl.CalcTerminalSize(terminalSettings.RenderProfile); terminalParam.SetTerminalSize(size.Width, size.Height); } // 接続(セッションオープン) _terminalSession = (ITerminalSession)ConnectProfilePlugin.Instance.WindowManager.ActiveWindow.AsForm().Invoke(new OpenSessionDelegate(InvokeOpenSessionOrNull), terminalParam, terminalSettings); // 自動ログイン/SU/実行コマンド if (_terminalSession != null) { // 受信データオブジェクト作成(ユーザからのキーボード入力が不可) ReceptionData pool = new ReceptionData(); _terminalSession.Terminal.StartModalTerminalTask(pool); // Telnet自動ログイン if ((_prof.AutoLogin == true) && (_prof.Protocol == ConnectionMethod.Telnet)) { if (TelnetAutoLogin() != true) { return; } } // SU if ((_prof.AutoLogin == true) && (_prof.SUUserName != "")) { if (SUSwitch() != true) { return; } } // 実行コマンド if ((_prof.AutoLogin == true) && (_prof.ExecCommand != "")) { if (ExecCommand() != true) { return; } } // 受信データオブジェクト定義解除(ユーザからのキーボード入力を許可) _terminalSession.Terminal.EndModalTerminalTask(); } }