private void OnOK(object sender, EventArgs args) { this.DialogResult = DialogResult.None; if (_homeDirectoryBox.Text.Length == 0) { GUtil.Warning(this, GApp.Strings.GetString("Message.CygwinLoginDialog.EmptyHomeDirectory")); } else if (_shellBox.Text.Length == 0) { GUtil.Warning(this, GApp.Strings.GetString("Message.CygwinLoginDialog.EmptyShell")); } _param.LogType = (LogType)EnumDescAttributeT.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None); if (_param.LogType != LogType.None) { _param.LogPath = _logFileBox.Text; LogFileCheckResult r = GCUtil.CheckLogFileName(_param.LogPath, this); if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error) { return; } _param.LogAppend = (r == LogFileCheckResult.Append); } _param.Home = _homeDirectoryBox.Text; _param.Shell = _shellBox.Text; _okButton.Enabled = false; _cancelButton.Enabled = false; this.Cursor = Cursors.WaitCursor; _savedHWND = this.Handle; if (_param is CygwinTerminalParam) { this.Text = GApp.Strings.GetString("Caption.CygwinLoginDialog.ConnectingCygwin"); } else { this.Text = GApp.Strings.GetString("Caption.CygwinLoginDialog.ConnectingSFU"); } _connector = CygwinUtil.AsyncPrepareSocket(this, _param); if (_connector == null) { ClearConnectingState(); } }
private SSHTerminalParam ValidateContent() { SSHTerminalParam p = _terminalParam; string msg = null; try { p.LogType = (LogType)EnumDescAttributeT.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None); if (p.LogType != LogType.None) { p.LogPath = _logFileBox.Text; LogFileCheckResult r = GCUtil.CheckLogFileName(p.LogPath, this); if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error) { return(null); } p.LogAppend = (r == LogFileCheckResult.Append); } if (p.AuthType == AuthType.PublicKey) { if (!File.Exists(_privateKeyBox.Text)) { msg = GApp.Strings.GetString("Message.SSHShortcutLoginDialog.KeyFileNotExist"); } else { p.IdentityFile = _privateKeyBox.Text; } } if (msg != null) { GUtil.Warning(this, msg); return(null); } else { return(p); } } catch (Exception ex) { GUtil.Warning(this, ex.Message); return(null); } }
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); } }
private void OnOK(object sender, EventArgs args) { this.DialogResult = DialogResult.None; LogType t = (LogType)EnumDescAttributeT.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None); string path = null; bool append = false; if (t != LogType.None) { path = _fileNameBox.Text; LogFileCheckResult r = GCUtil.CheckLogFileName(path, this); if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error) { return; } append = (r == LogFileCheckResult.Append); } _connection.ResetLog(t, path, append); this.DialogResult = DialogResult.OK; }
//入力内容に誤りがあればそれを警告して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); } }