/// <summary> /// 设置内置浏览器代理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmiInnerBrowser_Click(object sender, EventArgs e) { try { AutoSwitchingHelper.StartBrowserProxy(GetProxyInfo(false)); } catch (Exception ex) { MsgBox.ShowExceptionMessage(ex); } }
private void btnOK_Click(object sender, EventArgs e) { if (chbEnable.Checked) { string proxy = txtProxy.Text.Trim(); var regex = new Regex( @"(?<Proxy>(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9]))\:(?<Port>\d{1,5})"); MatchCollection matchs = regex.Matches(proxy); if (matchs.Count == 1) { AutoSwitchingHelper.StartBrowserProxy(proxy); } } else { AutoSwitchingHelper.StartBrowserProxy(""); } Close(); }
private void timerAutoSwitchingProxy_Elapsed(object sender, EventArgs e) { try { if (TimerAutoSwitchingProxy.Enabled && Config.TsCountDown.TotalMilliseconds > 0) { var sb = new StringBuilder("Next Time:"); if (Config.TsCountDown.Days > 0) { sb.Append(Config.TsCountDown.Days + "d"); } if (Config.TsCountDown.Hours > 0) { sb.Append(Config.TsCountDown.Hours + "h"); } if (Config.TsCountDown.Minutes > 0) { sb.Append(Config.TsCountDown.Minutes + "m"); } sb.Append(Config.TsCountDown.Seconds + "s"); tsslCountdown.Text = sb.ToString(); Config.TsCountDown = Config.TsCountDown.Add(new TimeSpan(0, 0, -1)); } else if (TimerAutoSwitchingProxy.Enabled && Config.TsCountDown.TotalMilliseconds == 0) { TimerAutoSwitchingProxy.Stop(); var aHelper = new AutoSwitchingHelper(); aHelper.SwitchingProxy(); } else { tsslCountdown.Text = DateTime.Now.ToShortDateString(); } } catch (Exception ex) { MsgBox.ShowExceptionMessage(ex); } }