private void ProxyAccountTestButton_Click(object sender, EventArgs e) { ProxyInfo proxy = GetSelectedProxy(); if (proxy != null) { TestProxyAccount(proxy); } }
private void ProxyAccountsList_SelectedIndexChanged(object sender, EventArgs e) { int sel = ucProxyAccounts.AccountsList.SelectedIndex; if (Config.ProxyList != null && sel != -1 && sel < Config.ProxyList.Count && Config.ProxyList[sel] != null) { ProxyInfo acc = Config.ProxyList[sel]; ucProxyAccounts.SettingsGrid.SelectedObject = acc; Config.ProxyActive = acc; Config.ProxySelected = ucProxyAccounts.AccountsList.SelectedIndex; } }
private ProxyInfo GetSelectedProxy() { ProxyInfo acc = null; if (ucProxyAccounts.AccountsList.SelectedIndex != -1 && Config.ProxyList.Count >= ucProxyAccounts.AccountsList.Items.Count) { acc = Config.ProxyList[ucProxyAccounts.AccountsList.SelectedIndex]; } return(acc); }
public Uploader() { Errors = new List <string>(); IsUploading = false; BufferSize = 8192; AllowReportProgress = true; ServicePointManager.DefaultConnectionLimit = 25; ServicePointManager.Expect100Continue = false; ServicePointManager.UseNagleAlgorithm = false; if (ProxyInfo == null) { ProxyInfo = new ProxyInfo(); } }
public static void TestProxyAccount(ProxyInfo acc) { string msg = "Success!"; try { NetworkCredential cred = new NetworkCredential(acc.UserName, acc.Password); WebProxy wp = new WebProxy(acc.GetAddress(), true, null, cred); WebClient wc = new WebClient { Proxy = wp }; wc.DownloadString("http://www.google.com"); } catch (Exception ex) { msg = ex.Message; } if (!string.IsNullOrEmpty(msg)) { MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void ProxyAdd(ProxyInfo acc) { Config.ProxyList.Add(acc); ucProxyAccounts.AccountsList.Items.Add(acc); ucProxyAccounts.AccountsList.SelectedIndex = ucProxyAccounts.AccountsList.Items.Count - 1; }