Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #3
0
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ProxySetting          selectedProxy = (ProxySetting)this.gridProxySettings.SelectedRows[0].DataBoundItem;
            ProxySetting          newProxy      = selectedProxy.Clone();
            ProxyNamePromptDialog dlgNamePrompt = new ProxyNamePromptDialog(_proxyList);

            dlgNamePrompt.txtName.Text = selectedProxy.Name;
            DialogResult result = dlgNamePrompt.ShowDialog();

            if (result == DialogResult.OK)
            {
                newProxy.Name = dlgNamePrompt.txtName.Text;

                //Add the proxy
                newProxy.SaveInConfigFile();
                _proxyList.Add(newProxy);
                _proxyList.Sort();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Handles the Click event of the btnAdd control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ProxyNamePromptDialog dlgNamePrompt = new ProxyNamePromptDialog(_proxyList);
            DialogResult          result        = dlgNamePrompt.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                ProxySetting newProxy = new ProxySetting();
                newProxy.Name = dlgNamePrompt.txtName.Text;

                LanSettingDialog dlgLanSettings = new LanSettingDialog(newProxy);
                result = dlgLanSettings.ShowDialog(this);
                if (result == DialogResult.OK)
                {
                    //don't add it until they've entered the data for it and saved it.
                    newProxy.SaveInConfigFile();
                    _proxyList.Add(newProxy);
                    _proxyList.Sort();
                }
            }
        }