public WebProxy GetProxy() { WebProxy webProxy = null; switch (this.ProxyUse) { case ProxySettings.UseType.UseRandom: { if (this.ProxyItems.Count > 0) { ProxyItem proxyItem = this.ProxyItems[new Random().Next(this.ProxyItems.Count)]; webProxy = new WebProxy(proxyItem.IP, proxyItem.Port); if (proxyItem.NeedAuth) { webProxy.Credentials = new NetworkCredential(proxyItem.Username, proxyItem.Password); } } break; } case ProxySettings.UseType.Use: { webProxy = new WebProxy(this.Host, this.Port); if (this.NeedsAuth) { webProxy.Credentials = new NetworkCredential(this.Username, this.Password); } break; } } return(webProxy); }
public ProxyForm(ProxyItem item) { this.InitializeComponent(); if (item == null) { this.Text = "Add account"; this.item = new ProxyItem(); return; } this.Text = "Edit account"; this.item = item; }