Esempio n. 1
0
        /// <summary>
        /// Initializes the form base on the provided LoginInfo that is loaded from the Registry.
        /// </summary>
        /// <param name="s">The LoginInfo object.</param>
        public Login(SettingInfoBase s)
        {
            InitializeComponent();

            _info = s;

            txtServer.Text    = s.Get <string>(LoginInfo.ServerName);
            txtPort.Text      = s.Get <int>(LoginInfo.ServerPort).ToString();
            txtUserName.Text  = s.Get <string>(LoginInfo.UserName);
            txtPassword.Text  = s.Get <string>(LoginInfo.Password);
            txtRemoteDir.Text = s.Get <string>(LoginInfo.RemoteDir);
            txtLocalDir.Text  = s.Get <string>(LoginInfo.LocalDir);

            chkUtf8Encoding.Checked = s.Get <bool>(LoginInfo.Utf8Encoding);

            txtProxyHost.Text            = s.Get <string>(LoginInfo.ProxyServer);
            txtProxyPort.Text            = s.Get <int>(LoginInfo.ProxyPort).ToString();
            txtProxyUser.Text            = s.Get <string>(LoginInfo.ProxyUser);
            txtProxyPassword.Text        = s.Get <string>(LoginInfo.ProxyPassword);
            txtProxyDomain.Text          = s.Get <string>(LoginInfo.ProxyDomain);
            cbxProxyType.SelectedIndex   = s.Get <int>(LoginInfo.ProxyType);
            cbxProxyMethod.SelectedIndex = s.Get <int>(LoginInfo.ProxyHttpAuthnMethod);

#if FTP
#if !SFTP
            sftp.Visible = false;
#endif
            #region FTP
            chkPasv.Checked                = s.Get <bool>(FtpLoginInfo.PasvMode);
            txtCertificate.Text            = s.Get <string>(FtpLoginInfo.Certificate);
            cbxSec.SelectedIndex           = s.Get <int>(FtpLoginInfo.SecurityMode);
            chkClearCommandChannel.Checked = s.Get <bool>(FtpLoginInfo.ClearCommandChannel);
            #endregion
#endif

#if SFTP
#if !FTP
            ftp.Visible    = false;
            cbxSec.Visible = false;

            // Remove FTP Proxy items.
            cbxProxyType.Items.RemoveAt(cbxProxyType.Items.Count - 1);
            cbxProxyType.Items.RemoveAt(cbxProxyType.Items.Count - 1);
            cbxProxyType.Items.RemoveAt(cbxProxyType.Items.Count - 1);
#endif
            #region SFTP
            chkCompress.Checked = s.Get <bool>(SftpLoginInfo.EnableCompression);
            txtPrivateKey.Text  = s.Get <string>(SftpLoginInfo.PrivateKey);
            #endregion
#endif

            switch (s.Get <TraceEventType>(LoginInfo.LogLevel))
            {
            case TraceEventType.Error:
                cbxLogLevel.SelectedIndex = 1;
                break;

            case TraceEventType.Information:
                cbxLogLevel.SelectedIndex = 2;
                break;

            case TraceEventType.Verbose:
                cbxLogLevel.SelectedIndex = 3;
                break;

            case TraceEventType.Transfer:
                cbxLogLevel.SelectedIndex = 4;
                break;

            default:     // None
                cbxLogLevel.SelectedIndex = 0;
                break;
            }

            _sites = SiteLoader.GetSites();

            if (_sites == null)
            {
                MessageBox.Show("FtpSites.xml not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            foreach (SiteInfo info in _sites)
            {
                cbxSites.Items.Add(info.Description);
            }
        }