private void FormMain_Load(object sender, EventArgs e) { registry = new ProxyRegistry(); isProxyEnable = registry.ProxyEnable; registry.GetProxyServer(ref proxyAddress, ref proxyPort); registry.GetProxyOverride(ref proxyExceptions, ref bypassLocal); monitor = new RegistryMonitor(registry.Key); monitor.RegChanged += Monitor_RegChanged; monitor.Start(); }
private void Monitor_RegChanged(object sender, EventArgs e) { if (InvokeRequired) { BeginInvoke(new EventHandler(Monitor_RegChanged), new object[] { sender, e }); } else { isProxyEnable = registry.ProxyEnable; registry.GetProxyServer(ref proxyAddress, ref proxyPort); registry.GetProxyOverride(ref proxyExceptions, ref bypassLocal); if (FormWindowState.Minimized == WindowState) { SetNotifyIconAndMenu(); } else { SetFormControlValues(); } } }