コード例 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            int limit;

            try
            {
                limit = int.Parse(txtThrottle.Text);
            }
            catch (Exception exc)
            {
                Util.ShowError(exc, "Invalid Throttle");
                return;
            }
            if (limit < 0)
            {
                MessageBox.Show("Invalid throttle", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int timeout;

            try
            {
                timeout = int.Parse(txtTimeout.Text);
            }
            catch (Exception exc)
            {
                Util.ShowError(exc, "Invalid Timeout");
                return;
            }
            if (timeout < 1)
            {
                MessageBox.Show("Invalid timeout, it must be greater than or equal to 1", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int keepaliveint;

            try
            {
                keepaliveint = int.Parse(txtKeepAliveInterval.Text);
            }
            catch (Exception exc)
            {
                Util.ShowError(exc, "Invalid Interval");
                return;
            }
            if (keepaliveint < 10)
            {
                MessageBox.Show("Invalid keep alive interval, it must be greater than or equal to 10", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _info.Set(SettingInfo.AsciiTransfer, rbtAscii.Checked);
            _info.Set(SettingInfo.KeepAlive, keepaliveint);
            _info.Set(SettingInfo.Throttle, limit);
            _info.Set(SettingInfo.Timeout, timeout);
            _info.Set(SettingInfo.ProgressUpdateInterval, tbProgress.Value * 50);
            _info.Set(SettingInfo.ShowProgressWhileDeleting, chkShowProgress.Checked);
            _info.Set(SettingInfo.ShowProgressWhileTransferring, chkShowProgressWhileTransferring.Checked);
            _info.Set(SettingInfo.RestoreFileProperties, chkRestoreProperties.Checked);

#if FTP
            _info.Set(FtpSettingInfo.SendAborCommand, GetState(chkSendABOR.CheckState));
            _info.Set(FtpSettingInfo.SendAbortSignals, chkSendSignals.Checked);
            _info.Set(FtpSettingInfo.ChangeDirBeforeListing, chkChDirBeforeListing.Checked);
            _info.Set(FtpSettingInfo.ChangeDirBeforeTransfer, chkChDirBeforeTransfer.Checked);
            _info.Set(FtpSettingInfo.Compress, chkCompress.Checked);
            _info.Set(FtpSettingInfo.SmartPath, chkSmartPath.Checked);
#endif

#if SFTP
            _info.Set(SftpSettingInfo.ServerOs, cbxServerOs.SelectedIndex);
#endif

            this.DialogResult = DialogResult.OK;
        }
コード例 #2
0
        /// <summary>
        /// Handles the Login button's Click event.
        /// </summary>
        /// <param name="sender">The button object.</param>
        /// <param name="e">The event arguments.</param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            int port;

            // Check port number.
            try
            {
                port = int.Parse(txtPort.Text);
            }
            catch (Exception exc)
            {
                Util.ShowError(exc, "Invalid Port");
                return;
            }
            if (port < 0 || port > 65535)
            {
                MessageBox.Show("Invalid port number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check server name.
            if (txtServer.Text.Length == 0)
            {
                MessageBox.Show("Host name cannot be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check proxy port.
            int proxyport;

            try
            {
                proxyport = int.Parse(txtProxyPort.Text);
            }
            catch (Exception exc)
            {
                Util.ShowError(exc, "Invalid Proxy Port");
                return;
            }
            if (proxyport < 0 || proxyport > 65535)
            {
                MessageBox.Show("Invalid port number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _info.Set(LoginInfo.ServerName, txtServer.Text);
            _info.Set(LoginInfo.ServerPort, int.Parse(txtPort.Text));
            _info.Set(LoginInfo.UserName, txtUserName.Text);
            _info.Set(LoginInfo.Password, txtPassword.Text);
            _info.Set(LoginInfo.RemoteDir, txtRemoteDir.Text);
            _info.Set(LoginInfo.LocalDir, txtLocalDir.Text);

            _info.Set(LoginInfo.Utf8Encoding, chkUtf8Encoding.Checked);

            _info.Set(LoginInfo.ProxyServer, txtProxyHost.Text);
            _info.Set(LoginInfo.ProxyPort, int.Parse(txtProxyPort.Text));
            _info.Set(LoginInfo.ProxyUser, txtProxyUser.Text);
            _info.Set(LoginInfo.ProxyPassword, txtProxyPassword.Text);
            _info.Set(LoginInfo.ProxyDomain, txtProxyDomain.Text);
            _info.Set(LoginInfo.ProxyType, cbxProxyType.SelectedIndex);
            _info.Set(LoginInfo.ProxyHttpAuthnMethod, cbxProxyMethod.SelectedIndex);

#if FTP
            #region FTP
            _info.Set(FtpLoginInfo.PasvMode, chkPasv.Checked);
            _info.Set(FtpLoginInfo.Certificate, txtCertificate.Text);
            _info.Set(FtpLoginInfo.SecurityMode, (SecurityMode)cbxSec.SelectedIndex);
            _info.Set(FtpLoginInfo.ClearCommandChannel, chkClearCommandChannel.Checked);
            #endregion
#endif

#if SFTP
            #region SFTP
            _info.Set(SftpLoginInfo.EnableCompression, chkCompress.Checked);
            _info.Set(SftpLoginInfo.PrivateKey, txtPrivateKey.Text);
            #endregion
#endif

            switch (cbxLogLevel.SelectedIndex)
            {
            case 0:
                _info.Set(LoginInfo.LogLevel, 0);
                break;

            case 1:
                _info.Set(LoginInfo.LogLevel, (int)TraceEventType.Error);
                break;

            case 2:
                _info.Set(LoginInfo.LogLevel, (int)TraceEventType.Information);
                break;

            case 3:
                _info.Set(LoginInfo.LogLevel, (int)TraceEventType.Verbose);
                break;

            case 4:
                _info.Set(LoginInfo.LogLevel, (int)TraceEventType.Transfer);
                break;
            }

            DialogResult = DialogResult.OK;
            Close();
        }