private void OnBtnOK(object sender, EventArgs e) { ProxyServerType pst = ProxyServerType.System; if (m_rbNoProxy.Checked) { pst = ProxyServerType.None; } else if (m_rbManualProxy.Checked) { pst = ProxyServerType.Manual; } ProxyAuthType pat = ProxyAuthType.Default; if (m_rbAuthNone.Checked) { pat = ProxyAuthType.None; } else if (m_rbAuthManual.Checked) { pat = ProxyAuthType.Manual; } AceIntegration ace = Program.Config.Integration; ace.ProxyType = pst; ace.ProxyAddress = m_tbAddress.Text; ace.ProxyPort = m_tbPort.Text; ace.ProxyAuthType = pat; ace.ProxyUserName = m_tbUser.Text; ace.ProxyPassword = m_tbPassword.TextEx.ReadString(); Program.Config.Apply(AceApplyFlags.Proxy); }
private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); this.Icon = AppIcons.Default; ProxyServerType pst = Program.Config.Integration.ProxyType; if (pst == ProxyServerType.None) { m_rbNoProxy.Checked = true; } else if (pst == ProxyServerType.Manual) { m_rbManualProxy.Checked = true; } else { m_rbSystemProxy.Checked = true; } m_tbAddress.Text = Program.Config.Integration.ProxyAddress; m_tbPort.Text = Program.Config.Integration.ProxyPort; string strUserName = Program.Config.Integration.ProxyUserName; string strPassword = Program.Config.Integration.ProxyPassword; ProxyAuthType pat = Program.Config.Integration.ProxyAuthType; if (pat == ProxyAuthType.Auto) { if ((strUserName.Length > 0) || (strPassword.Length > 0)) { pat = ProxyAuthType.Manual; } else { pat = ProxyAuthType.Default; } } if (pat == ProxyAuthType.None) { m_rbAuthNone.Checked = true; } else if (pat == ProxyAuthType.Manual) { m_rbAuthManual.Checked = true; } else { m_rbAuthDefault.Checked = true; } m_tbUser.Text = strUserName; m_tbPassword.Text = strPassword; EnableControlsEx(); }
internal static void SetProxy(ProxyServerType pst, string strAddr, string strPort, ProxyAuthType pat, string strUserName, string strPassword) { m_pstProxyType = pst; m_strProxyAddr = (strAddr ?? string.Empty); m_strProxyPort = (strPort ?? string.Empty); m_patProxyAuthType = pat; m_strProxyUserName = (strUserName ?? string.Empty); m_strProxyPassword = (strPassword ?? string.Empty); }
private static void AssignCredentials(IWebProxy prx) { if (prx == null) { return; // No assert } string strUserName = m_strProxyUserName; string strPassword = m_strProxyPassword; ProxyAuthType pat = m_patProxyAuthType; if (pat == ProxyAuthType.Auto) { if ((strUserName.Length > 0) || (strPassword.Length > 0)) { pat = ProxyAuthType.Manual; } else { pat = ProxyAuthType.Default; } } try { if (pat == ProxyAuthType.None) { prx.Credentials = null; } else if (pat == ProxyAuthType.Default) { prx.Credentials = CredentialCache.DefaultCredentials; } else if (pat == ProxyAuthType.Manual) { if ((strUserName.Length > 0) || (strPassword.Length > 0)) { prx.Credentials = new NetworkCredential( strUserName, strPassword); } } else { Debug.Assert(false); } } catch (Exception) { Debug.Assert(false); } }