public CredentialsForm(string message, XmlProxyUrlResolver resolver)
        {
            InitializeComponent();
            this.resolver = resolver;
            labelMessage.Text = message;
            NetworkCredential cred = (NetworkCredential)resolver.GetCredentials();
            if (cred != null)
            {
                textBoxUser.Text = cred.UserName;
                textBoxPassword.Text = cred.Password;
                checkBoxUseServer.Checked = true;
            }
            else
                checkBoxUseServer.Checked = false;

            comboBoxType.SelectedItem = resolver.ProxyType;

            WebProxy proxy = (WebProxy)resolver.Proxy;
            if (proxy != null)
            {
                textBoxServer.Text = proxy.Address.Host;
                textBoxPort.Text = proxy.Address.Port.ToString();
                NetworkCredential cred2 = (NetworkCredential)proxy.Credentials;
                if (cred2 != null)
                {
                    textBoxProxyUser.Text = cred2.UserName;
                    textBoxProxyPassword.Text = cred2.Password;
                }
                checkBoxUseProxy.Checked = true;
            }
            else
                checkBoxUseProxy.Checked = false;

            UpdateControls();
        }
Exemple #2
0
        public CredentialsForm(string message, XmlProxyUrlResolver resolver)
        {
            InitializeComponent();
            this.resolver     = resolver;
            labelMessage.Text = message;
            NetworkCredential cred = (NetworkCredential)resolver.GetCredentials();

            if (cred != null)
            {
                textBoxUser.Text          = cred.UserName;
                textBoxPassword.Text      = cred.Password;
                checkBoxUseServer.Checked = true;
            }
            else
            {
                checkBoxUseServer.Checked = false;
            }

            comboBoxType.SelectedItem = resolver.ProxyType;

            WebProxy proxy = (WebProxy)resolver.Proxy;

            if (proxy != null)
            {
                textBoxServer.Text = proxy.Address.Host;
                textBoxPort.Text   = proxy.Address.Port.ToString();
                NetworkCredential cred2 = (NetworkCredential)proxy.Credentials;
                if (cred2 != null)
                {
                    textBoxProxyUser.Text     = cred2.UserName;
                    textBoxProxyPassword.Text = cred2.Password;
                }
                checkBoxUseProxy.Checked = true;
            }
            else
            {
                checkBoxUseProxy.Checked = false;
            }

            UpdateControls();
        }