public object Deserialize(StructuredText node) { PipeTerminalParameter tp = new PipeTerminalParameter(); tp.ExeFilePath = node.Get("exeFilePath", null); tp.CommandLineOptions = node.Get("commandLineOptions", null); List<PipeTerminalParameter.EnvironmentVariable> envList = new List<PipeTerminalParameter.EnvironmentVariable>(); foreach (StructuredText s in node.FindMultipleNote("environmentVariable")) { string name = s.Get("name", null); string value = s.Get("value", null); if (name != null && value != null) { envList.Add(new PipeTerminalParameter.EnvironmentVariable(name, value)); } } tp.EnvironmentVariables = (envList.Count > 0) ? envList.ToArray() : null; tp.InputPipePath = node.Get("inputPipePath", null); tp.OutputPipePath = node.Get("outputPipePath", null); tp.SetTerminalName(node.Get("terminal-type", "vt100")); tp.AutoExecMacroPath = node.Get("autoexec-macro", null); return tp; }
public object Deserialize(StructuredText node) { PipeTerminalParameter tp = new PipeTerminalParameter(); tp.ExeFilePath = node.Get("exeFilePath", null); tp.CommandLineOptions = node.Get("commandLineOptions", null); List <PipeTerminalParameter.EnvironmentVariable> envList = new List <PipeTerminalParameter.EnvironmentVariable>(); foreach (StructuredText s in node.FindMultipleNote("environmentVariable")) { string name = s.Get("name", null); string value = s.Get("value", null); if (name != null && value != null) { envList.Add(new PipeTerminalParameter.EnvironmentVariable(name, value)); } } tp.EnvironmentVariables = (envList.Count > 0) ? envList.ToArray() : null; tp.InputPipePath = node.Get("inputPipePath", null); tp.OutputPipePath = node.Get("outputPipePath", null); tp.SetTerminalName(node.Get("terminal-type", "vt100")); tp.AutoExecMacroPath = node.Get("autoexec-macro", null); return(tp); }
private bool ValidateParams(out PipeTerminalParameter param, out PipeTerminalSettings settings) { PipeTerminalParameter paramTmp = new PipeTerminalParameter(); PipeTerminalSettings settingsTmp = new PipeTerminalSettings(); StringResource res = PipePlugin.Instance.Strings; try { string caption; if (_radioButtonProcess.Checked) { string exePath = _textBoxExePath.Text; if (exePath.Length == 0) { throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoExePath")); } paramTmp.ExeFilePath = exePath; paramTmp.CommandLineOptions = _textBoxCommandLineOptions.Text; paramTmp.EnvironmentVariables = _environmentVariables; caption = Path.GetFileName(exePath); } else if (_radioButtonPipe.Checked) { string path = _textBoxInputPath.Text; if (path.Length == 0) { throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoInputPath")); } paramTmp.InputPipePath = path; caption = Path.GetFileName(path); if (!_checkBoxBidirectinal.Checked) { path = _textBoxOutputPath.Text; if (path.Length == 0) { throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoOutputPath")); } paramTmp.OutputPipePath = path; caption += "/" + Path.GetFileName(path); } } else { throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoOpenMode")); } TerminalType terminalType = ((EnumListItem <TerminalType>)_comboBoxTerminalType.SelectedItem).Value; paramTmp.SetTerminalName(terminalType.ToString().ToLowerInvariant()); LogType logType = ((EnumListItem <LogType>)_comboBoxLogType.SelectedItem).Value; ISimpleLogSettings logSettings = null; if (logType != LogType.None) { string logFile = _textBoxLogFile.Text; LogFileCheckResult r = LogUtil.CheckLogFileName(logFile, this); if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error) { throw new Exception(""); } logSettings = PipePlugin.Instance.TerminalEmulatorService.CreateDefaultSimpleLogSettings(); logSettings.LogPath = logFile; logSettings.LogType = logType; logSettings.LogAppend = (r == LogFileCheckResult.Append); } string autoExecMacroPath = null; if (_textBoxAutoExecMacroPath.Text.Length != 0) { autoExecMacroPath = _textBoxAutoExecMacroPath.Text; } IAutoExecMacroParameter autoExecParams = paramTmp.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter; if (autoExecParams != null) { autoExecParams.AutoExecMacroPath = autoExecMacroPath; } settingsTmp.BeginUpdate(); settingsTmp.Caption = caption; settingsTmp.Icon = Poderosa.Pipe.Properties.Resources.Icon16x16; settingsTmp.Encoding = ((EnumListItem <EncodingType>)_comboBoxEncoding.SelectedItem).Value; settingsTmp.LocalEcho = _comboBoxLocalEcho.SelectedIndex == 1; settingsTmp.TransmitNL = ((EnumListItem <NewLine>)_comboBoxNewLine.SelectedItem).Value; settingsTmp.TerminalType = terminalType; if (logSettings != null) { settingsTmp.LogSettings.Reset(logSettings); } settingsTmp.EndUpdate(); param = paramTmp; settings = settingsTmp; return(true); } catch (Exception e) { if (e.Message.Length > 0) { GUtil.Warning(this, e.Message); } param = null; settings = null; return(false); } }
private bool ValidateParams(out PipeTerminalParameter param, out PipeTerminalSettings settings) { PipeTerminalParameter paramTmp = new PipeTerminalParameter(); PipeTerminalSettings settingsTmp = new PipeTerminalSettings(); StringResource res = PipePlugin.Instance.Strings; try { string caption; if (_radioButtonProcess.Checked) { string exePath = _textBoxExePath.Text; if (exePath.Length == 0) throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoExePath")); paramTmp.ExeFilePath = exePath; paramTmp.CommandLineOptions = _textBoxCommandLineOptions.Text; paramTmp.EnvironmentVariables = _environmentVariables; caption = Path.GetFileName(exePath); } else if (_radioButtonPipe.Checked) { string path = _textBoxInputPath.Text; if (path.Length == 0) throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoInputPath")); paramTmp.InputPipePath = path; caption = Path.GetFileName(path); if (!_checkBoxBidirectinal.Checked) { path = _textBoxOutputPath.Text; if (path.Length == 0) throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoOutputPath")); paramTmp.OutputPipePath = path; caption += "/" + Path.GetFileName(path); } } else { throw new Exception(res.GetString("Form.OpenPipeDialog.Error.NoOpenMode")); } TerminalType terminalType = ((EnumListItem<TerminalType>)_comboBoxTerminalType.SelectedItem).Value; paramTmp.SetTerminalName(terminalType.ToString().ToLowerInvariant()); LogType logType = ((EnumListItem<LogType>)_comboBoxLogType.SelectedItem).Value; ISimpleLogSettings logSettings = null; if (logType != LogType.None) { string logFile = _textBoxLogFile.Text; LogFileCheckResult r = LogUtil.CheckLogFileName(logFile, this); if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error) throw new Exception(""); logSettings = PipePlugin.Instance.TerminalEmulatorService.CreateDefaultSimpleLogSettings(); logSettings.LogPath = logFile; logSettings.LogType = logType; logSettings.LogAppend = (r == LogFileCheckResult.Append); } string autoExecMacroPath = null; if (_textBoxAutoExecMacroPath.Text.Length != 0) autoExecMacroPath = _textBoxAutoExecMacroPath.Text; IAutoExecMacroParameter autoExecParams = paramTmp.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter; if (autoExecParams != null) autoExecParams.AutoExecMacroPath = autoExecMacroPath; settingsTmp.BeginUpdate(); settingsTmp.Caption = caption; settingsTmp.Icon = Poderosa.Pipe.Properties.Resources.Icon16x16; settingsTmp.Encoding = ((EnumListItem<EncodingType>)_comboBoxEncoding.SelectedItem).Value; settingsTmp.LocalEcho = _comboBoxLocalEcho.SelectedIndex == 1; settingsTmp.TransmitNL = ((EnumListItem<NewLine>)_comboBoxNewLine.SelectedItem).Value; settingsTmp.TerminalType = terminalType; if (logSettings != null) settingsTmp.LogSettings.Reset(logSettings); settingsTmp.EndUpdate(); param = paramTmp; settings = settingsTmp; return true; } catch (Exception e) { if (e.Message.Length > 0) GUtil.Warning(this, e.Message); param = null; settings = null; return false; } }