/// <summary> /// Modify icon to which is obtained from the executable file /// </summary> /// <param name="param"></param> /// <param name="settings"></param> private static void OverrideSettings(PipeTerminalParameter param, PipeTerminalSettings settings) { if (param.ExeFilePath != null) { Image icon = GetExeFileIcon(param.ExeFilePath); if (icon != null) { Image oldIcon = settings.Icon; settings.BeginUpdate(); settings.Icon = icon; settings.EndUpdate(); // FIXME: // oldIcon may being used to repainting, so we don't dispose it here. // I don't know where the icon is disposed... // //if (oldIcon != null) // oldIcon.Dispose(); } } }
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; } }