Ejemplo n.º 1
0
        public static void Main()
        {
            Process ThisProcess = Process.GetCurrentProcess();

            Process[] appProcesses = Process.GetProcessesByName(ThisProcess.ProcessName);

            //only proceed if not already running (counting this instance).
            if (appProcesses.Length == 1)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                SortableBindingList <ProxySetting> proxyList = new SortableBindingList <ProxySetting>();

                //Get all proxies defined in the config file.
                ProxyDefinitionSection section = (ProxyDefinitionSection)ConfigurationManager.GetSection("ProxyDefinition");
                if (section.ProxyDefinitions != null)
                {
                    foreach (ProxyElement proxyElement in section.ProxyDefinitions)
                    {
                        ProxySetting newSetting = new ProxySetting(proxyElement);
                        proxyList.Add(newSetting);
                    }
                }


                if (proxyList.Count == 0)
                {
                    DialogResult result = MessageBox.Show("You currently have no Proxy Settings defined.  \n\n Would you like to create an initial configuration based on your current proxy settings in Internet Explorer?", "Create Initial Proxy Set", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (result == DialogResult.Yes)
                    {
                        ProxySetting          currentRegistryProxy = ProxySetting.GetCurrentProxyFromInternetExplorer();
                        ProxyNamePromptDialog dlgNamePrompt        = new ProxyNamePromptDialog(proxyList);
                        dlgNamePrompt.txtName.Text = currentRegistryProxy.Name;
                        result = dlgNamePrompt.ShowDialog();
                        if (result == DialogResult.OK)
                        {
                            currentRegistryProxy.Name = dlgNamePrompt.txtName.Text;
                            currentRegistryProxy.SaveInConfigFile();
                            proxyList.Add(currentRegistryProxy);
                        }
                    }
                }


                new MainForm(proxyList);
                Application.Run();
            }
        }
Ejemplo n.º 2
0
        private void captureCurrentIESettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ProxySetting          currentRegistryProxy = ProxySetting.GetCurrentProxyFromInternetExplorer();
            ProxyNamePromptDialog dlgNamePrompt        = new ProxyNamePromptDialog(_proxyList);

            dlgNamePrompt.txtName.Text = "Current IE Proxy Settings";
            DialogResult result = dlgNamePrompt.ShowDialog();

            if (result == DialogResult.OK)
            {
                currentRegistryProxy.Name = dlgNamePrompt.txtName.Text;
                currentRegistryProxy.SaveInConfigFile();
                _proxyList.Add(currentRegistryProxy);
                _proxyList.Sort();
            }
        }