/// <summary> /// Handles the Opening event of the cxmNotifyIconMenu control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param> private void cxmNotifyIconMenu_Opening(object sender, CancelEventArgs e) { //populate the set config... dropdown setCurrentProxyToolStripMenuItem.DropDownItems.Clear(); foreach (ProxySetting aProxy in _proxyList) { ToolStripItem proxyMenuItem = setCurrentProxyToolStripMenuItem.DropDownItems.Add(aProxy.Name); proxyMenuItem.Click += new System.EventHandler(this.proxyMenuItem_Click); } //set the check marks on the proxy flags useAutoDetectProxyToolStripMenuItem.Checked = ProxySetting.GetCurrentActiveAutoDetectProxy(); useAutoConfigProxyToolStripMenuItem.Checked = ProxySetting.GetCurrentActiveAutoConfigProxy(); useProxyToolStripMenuItem.Checked = ProxySetting.GetCurrentActiveUseProxy(); //set the check mark on the autorun option. RegistryKey autoRunKey = Registry.CurrentUser.OpenSubKey(BaseAutoRunKey); string autorunexe = Convert.ToString(autoRunKey.GetValue("Advanced Proxy Manager")); if (string.IsNullOrEmpty(autorunexe)) { autorunAtStartupToolStripMenuItem.Checked = false; } else { autorunAtStartupToolStripMenuItem.Checked = true; } }
public static ProxySetting GetCurrentProxyFromInternetExplorer() { ProxySetting returnProxy = new ProxySetting(); returnProxy.AutoDetectSettings = ProxySetting.GetCurrentActiveAutoDetectProxy(); returnProxy.UseAutoConfigureScript = ProxySetting.GetCurrentActiveAutoConfigProxy(); returnProxy.UseAutoConfigureScriptAddress = ProxySetting.GetCurrentActiveAutoConfigURL(); returnProxy.UseProxyServer = ProxySetting.GetCurrentActiveUseProxy(); string proxyServerString = ProxySetting.GetCurrentActiveProxyServerURLs(); if (!string.IsNullOrEmpty(proxyServerString.Trim())) { string[] proxyServerList = proxyServerString.Split(';'); if (proxyServerList.Length > 1) { returnProxy.UseSameProxyServerForAllProtocols = false; foreach (string aProxyServer in proxyServerList) { string[] proxyServer = aProxyServer.Split('='); string type = proxyServer[0]; string[] serverAddressAndPort = proxyServer[1].Split(':'); switch (type) { case ("http"): returnProxy.HTTPProxyAddress = serverAddressAndPort[0]; returnProxy.HTTPProxyPort = serverAddressAndPort[1]; break; case ("https"): returnProxy.SecureProxyAddress = serverAddressAndPort[0]; returnProxy.SecureProxyPort = serverAddressAndPort[1]; break; case ("ftp"): returnProxy.FTPProxyAddress = serverAddressAndPort[0]; returnProxy.FTPProxyPort = serverAddressAndPort[1]; break; case ("gopher"): returnProxy.GopherProxyAddress = serverAddressAndPort[0]; returnProxy.GopherProxyPort = serverAddressAndPort[1]; break; case ("socks"): returnProxy.SocksProxyAddress = serverAddressAndPort[0]; returnProxy.SocksProxyPort = serverAddressAndPort[1]; break; } } } else { returnProxy.UseSameProxyServerForAllProtocols = true; string[] serverAddressAndPort = proxyServerString.Split(':'); returnProxy.UseProxyServerAddress = serverAddressAndPort[0]; returnProxy.UseProxyServerPort = serverAddressAndPort[1]; } returnProxy.Name = "Initial Proxy Settings"; } returnProxy.ExcludeAddressesFromProxy = ProxySetting.GetCurrentActiveBypassProxy(); if (returnProxy.ExcludeAddressesFromProxy.EndsWith("<local>")) { returnProxy.BypassProxyForLocalAddress = true; returnProxy.ExcludeAddressesFromProxy = returnProxy.ExcludeAddressesFromProxy.Substring(0, returnProxy.ExcludeAddressesFromProxy.Length - 8); } else { returnProxy.BypassProxyForLocalAddress = false; } return(returnProxy); }