private void ChangeEncoding(object sender, System.EventArgs e) { if (_blockEventHandler) { return; } EncodingProfile enc = EncodingProfile.Get((EncodingType)_encodingBox.SelectedIndex); ContainerConnectionCommandTarget t = GApp.GetConnectionCommandTarget(); t.SetEncoding(enc); t.Focus(); }
private SerialTerminalParam ValidateParam() { SerialTerminalParam p = new SerialTerminalParam(); try { p.LogType = (LogType)EnumDescAttributeT.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None); if (p.LogType != LogType.None) { p.LogPath = _logFileBox.Text; if (p.LogPath == GUtil.CreateLogFileName(null)) { p.LogPath = GUtil.CreateLogFileName(String.Format("com{0}", _portBox.SelectedIndex + 1)); } LogFileCheckResult r = GCUtil.CheckLogFileName(p.LogPath, this); if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error) { return(null); } p.LogAppend = (r == LogFileCheckResult.Append); } p.Port = _portBox.SelectedIndex + 1; p.BaudRate = Int32.Parse(_baudRateBox.Text); p.ByteSize = (byte)(_dataBitsBox.SelectedIndex == 0? 7 : 8); p.StopBits = (StopBits)_stopBitsBox.SelectedIndex; p.Parity = (Parity)_parityBox.SelectedIndex; p.FlowControl = (FlowControl)_flowControlBox.SelectedIndex; p.EncodingProfile = EncodingProfile.Get((EncodingType)_encodingBox.SelectedIndex); p.LocalEcho = _localEchoBox.SelectedIndex == 1; p.TransmitNL = (NewLine)EnumDescAttributeT.For(typeof(NewLine)).FromDescription(_newLineBox.Text, LogType.None); p.TransmitDelayPerChar = Int32.Parse(_transmitDelayPerCharBox.Text); p.TransmitDelayPerLine = Int32.Parse(_transmitDelayPerLineBox.Text); return(p); } catch (Exception ex) { GUtil.Warning(this, ex.Message); return(null); } }
//入力内容に誤りがあればそれを警告してnullを返す。なければ必要なところを埋めたTCPTerminalParamを返す private TCPTerminalParam ValidateContent() { string msg = null; TCPTerminalParam p = null; SSHTerminalParam sp = null; try { ConnectionMethod m = ParseMethod(_methodBox.Text); if (m == ConnectionMethod.Telnet) { p = new TelnetTerminalParam(""); } else { p = sp = new SSHTerminalParam(ConnectionMethod.SSH2, "", "", ""); sp.Method = m; sp.Account = _userNameBox.Text; } p.Host = _hostBox.Text; try { p.Port = ParsePort(_portBox.Text); } catch (FormatException ex) { msg = ex.Message; } if (_hostBox.Text.Length == 0) { msg = GApp.Strings.GetString("Message.LoginDialog.HostIsEmpty"); } p.LogType = (LogType)EnumDescAttributeT.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None); if (p.LogType != LogType.None) { p.LogPath = _logFileBox.Text; if (p.LogPath == GUtil.CreateLogFileName(null)) { p.LogPath = GUtil.CreateLogFileName(_hostBox.Text); } LogFileCheckResult r = GCUtil.CheckLogFileName(p.LogPath, this); if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error) { return(null); } p.LogAppend = (r == LogFileCheckResult.Append); } if (p.IsSSH) { Debug.Assert(sp != null); sp.AuthType = (AuthType)_authOptions.SelectedIndex; if (sp.AuthType == AuthType.PublicKey) { if (!File.Exists(_privateKeyFile.Text)) { msg = GApp.Strings.GetString("Message.LoginDialog.KeyFileNotExist"); } else { sp.IdentityFile = _privateKeyFile.Text; } } } p.EncodingProfile = EncodingProfile.Get((EncodingType)_encodingBox.SelectedIndex); p.LocalEcho = _localEchoBox.SelectedIndex == 1; p.TransmitNL = (NewLine)EnumDescAttributeT.For(typeof(NewLine)).FromDescription(_newLineBox.Text, NewLine.CR); p.TerminalType = (TerminalType)_terminalTypeBox.SelectedIndex; if (msg != null) { ShowError(msg); return(null); } else { return(p); } } catch (Exception ex) { GUtil.Warning(this, ex.Message); return(null); } }