Exemplo n.º 1
0
        public ProxySetting Clone()
        {
            ProxySetting returnProxy = new ProxySetting();

            returnProxy.AutoDetectSettings         = this.AutoDetectSettings;
            returnProxy.BypassProxyForLocalAddress = this.BypassProxyForLocalAddress;
            returnProxy.ExcludeAddressesFromProxy  = this.ExcludeAddressesFromProxy;
            returnProxy.FTPProxyAddress            = this.FTPProxyAddress;
            returnProxy.FTPProxyPort       = this.FTPProxyPort;
            returnProxy.GopherProxyAddress = this.GopherProxyAddress;
            returnProxy.GopherProxyPort    = this.GopherProxyPort;
            returnProxy.HTTPProxyAddress   = this.HTTPProxyAddress;
            returnProxy.HTTPProxyPort      = this.HTTPProxyPort;
            returnProxy.Name = this.Name;
            returnProxy.SecureProxyAddress                = this.SecureProxyAddress;
            returnProxy.SecureProxyPort                   = this.SecureProxyPort;
            returnProxy.SocksProxyAddress                 = this.SocksProxyAddress;
            returnProxy.SocksProxyPort                    = this.SocksProxyPort;
            returnProxy.UseAutoConfigureScript            = this.UseAutoConfigureScript;
            returnProxy.UseAutoConfigureScriptAddress     = this.UseAutoConfigureScriptAddress;
            returnProxy.UseProxyServer                    = this.UseProxyServer;
            returnProxy.UseProxyServerAddress             = this.UseProxyServerAddress;
            returnProxy.UseProxyServerPort                = this.UseProxyServerPort;
            returnProxy.UseSameProxyServerForAllProtocols = this.UseSameProxyServerForAllProtocols;

            return(returnProxy);
        }
Exemplo n.º 2
0
        /// <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;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the Click event of the useAutoConfigProxyToolStripMenuItem 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 useAutoConfigProxyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool useProxy = !useAutoConfigProxyToolStripMenuItem.Checked;

            useAutoConfigProxyToolStripMenuItem.Checked = useProxy;

            if (useProxy)
            {
                string currentAutoConfigURL = ProxySetting.GetCurrentActiveAutoConfigURL();
                AutoConfigScriptPromptForm frmConfigScript = new AutoConfigScriptPromptForm();
                frmConfigScript.txtAddress.Text = currentAutoConfigURL;
                DialogResult result = frmConfigScript.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ProxySetting.ModifyCurrentActiveAutoConfigProxyURL(frmConfigScript.txtAddress.Text);
                }
                else
                {
                    return;
                }
            }

            ProxySetting.ModifyCurrentActiveAutoConfigProxy(useProxy);

            RefreshTrayIcon();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handles the Click event of the useProxyToolStripMenuItem 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 useProxyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool useProxy = !useProxyToolStripMenuItem.Checked;

            useProxyToolStripMenuItem.Checked = useProxy;
            ProxySetting.ModifyCurrentActiveUseProxy(useProxy);

            RefreshTrayIcon();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Refreshes the tray icon.
 /// </summary>
 private void RefreshTrayIcon()
 {
     if (ProxySetting.AnyCurrentActiveProxySet())
     {
         this.icnProxyNotifyIcon.Icon = enabledIcon;
     }
     else
     {
         this.icnProxyNotifyIcon.Icon = disabledIcon;
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Handles the Click event of the btnDelete 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 btnDelete_Click(object sender, EventArgs e)
        {
            ProxySetting selectedProxy = (ProxySetting)this.gridProxySettings.SelectedRows[0].DataBoundItem;
            DialogResult result        = MessageBox.Show(this, "Are you sure you want to delete the \"" + selectedProxy.Name + "\" proxy setting?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                selectedProxy.DeleteFromConfig();
                _proxyList.Remove(selectedProxy);
                _proxyList.Sort();
            }
        }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Edits the proxy.
        /// </summary>
        /// <param name="selectedProxyPosition">The selected proxy position in the array.</param>
        private void EditProxy(int selectedProxyPosition)
        {
            //make a copy of the current selected proxy setting so we can ignore when user cancels.
            ProxySetting     selectedProxy  = _proxyList[selectedProxyPosition].Clone();
            LanSettingDialog dlgLanSettings = new LanSettingDialog(selectedProxy);
            DialogResult     result         = dlgLanSettings.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                selectedProxy.SaveInConfigFile();
                //replace the one in the list
                _proxyList[selectedProxyPosition] = selectedProxy;
                this.gridProxySettings.Refresh();
            }
        }
Exemplo n.º 9
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();
            }
        }
Exemplo n.º 10
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();
            }
        }
Exemplo n.º 11
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();
                }
            }
        }
Exemplo n.º 12
0
 public void Copy(ProxySetting newValues)
 {
     this.AutoDetectSettings         = newValues.AutoDetectSettings;
     this.BypassProxyForLocalAddress = newValues.BypassProxyForLocalAddress;
     this.ExcludeAddressesFromProxy  = newValues.ExcludeAddressesFromProxy;
     this.FTPProxyAddress            = newValues.FTPProxyAddress;
     this.FTPProxyPort       = newValues.FTPProxyPort;
     this.GopherProxyAddress = newValues.GopherProxyAddress;
     this.GopherProxyPort    = newValues.GopherProxyPort;
     this.HTTPProxyAddress   = newValues.HTTPProxyAddress;
     this.HTTPProxyPort      = newValues.HTTPProxyPort;
     this.Name = newValues.Name;
     this.SecureProxyAddress                = newValues.SecureProxyAddress;
     this.SecureProxyPort                   = newValues.SecureProxyPort;
     this.SocksProxyAddress                 = newValues.SocksProxyAddress;
     this.SocksProxyPort                    = newValues.SocksProxyPort;
     this.UseAutoConfigureScript            = newValues.UseAutoConfigureScript;
     this.UseAutoConfigureScriptAddress     = newValues.UseAutoConfigureScriptAddress;
     this.UseProxyServer                    = newValues.UseProxyServer;
     this.UseProxyServerAddress             = newValues.UseProxyServerAddress;
     this.UseProxyServerPort                = newValues.UseProxyServerPort;
     this.UseSameProxyServerForAllProtocols = newValues.UseSameProxyServerForAllProtocols;
 }
Exemplo n.º 13
0
 public AdvancedDialog()
 {
     InitializeComponent();
     ActiveProxy = new ProxySetting();
 }
Exemplo n.º 14
0
 public LanSettingDialog()
 {
     InitializeComponent();
     activeProxy = new ProxySetting();
 }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
 public LanSettingDialog(ProxySetting proxy)
 {
     InitializeComponent();
     activeProxy = proxy;
 }
Exemplo n.º 17
0
        /// <summary>
        /// Handles the Click event of the btnSetAsCurrent 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 btnSetAsCurrent_Click(object sender, EventArgs e)
        {
            ProxySetting selectedProxy = (ProxySetting)this.gridProxySettings.SelectedRows[0].DataBoundItem;

            selectedProxy.SetAsCurrentProxy();
        }
Exemplo n.º 18
0
 public AdvancedDialog(ProxySetting proxy)
 {
     InitializeComponent();
     this.ActiveProxy = proxy;
 }