private void btnSearch_Click(object sender, EventArgs e) { try { if (txtDbFile.Text.Trim() == "") { MessageBox.Show(@"请先设置纯真IP数据库文件!"); btnBrowser_Click(sender, e); return; } if (txtIPAdress.Text.Trim() == "") { MessageBox.Show(@"请填写IP地址"); txtIPAdress.Focus(); return; } richTextBox1.Text = IpThread.SearchIp(this.txtIPAdress.Text.Trim(), this.txtDbFile.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnStart_Click(object sender, EventArgs e) { try { if (txtDbFile.Text.Trim() == "") { MessageBox.Show(@"请先设置纯真IP数据库文件!"); btnBrowser_Click(sender, e); return; } if (_application.ProxyList.Count == 0) { MessageBox.Show(@"代理列表数据为空!"); return; } if (_application.IsDownloadingOrTesting) { MessageBox.Show(@"代理公布器正在下载数据或验证代理,请先关闭以免占用更多资源!"); return; } try { _application.EnabledProxyPageUI(false); var setting = new IpSeekerSetting { DbFileName = txtDbFile.Text, ThreadCount = Convert.ToInt32(numericUpDown1.Value) }; _application.XmlSerialize(_settingFilename, setting, typeof(IpSeekerSetting)); } catch (Exception) { } richTextBox1.Clear(); _threads = new List <IpThread>(); ProxyQueue = new Queue <Proxy>(); _sw = new Stopwatch(); _sw.Start(); foreach (ProxyServer dr in _application.ProxyList) { var pe = new Proxy { Ip = dr.proxy, Port = dr.port }; ProxyQueue.Enqueue(pe); } var threadCount = (int)numericUpDown1.Value; threadCount = _application.ProxyList.Count >= threadCount ? threadCount : _application.ProxyList.Count; for (int i = 0; i < threadCount; i++) { var thread = new IpThread(txtDbFile.Text, _application); thread.Completed += CheckCompelted; thread.Start(); } Refresh("正在验证地理位置,请稍后..."); btnStart.Enabled = false; btnStop.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }