Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int index = lstSettings.SelectedIndex;

            if (index < 0)
            {
                return;
            }

            if (index < this.ProxyEntries.Count)
            {
                var item = this.ProxyEntries[index];
                if (item != null)
                {
                    item.Name      = tbName.Text;
                    item.NetworkID = tbNetwork.Text;
                    item.Proxy     = tbProxy.Text;
                    item.Port      = tbPort.Text;
                    item.Username  = tbUsername.Text;
                    item.Password  = StringEncryption.Protect(tbPassword.Text);
                    item.Bypass    = cbBypass.Checked;
                }
                SaveJson();
                LoadUIList();
            }
        }
Beispiel #2
0
        private void SetProxy(ProxySettingItem proxy)
        {
            CurrentlyAppliedProxy = proxy;
            RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);

            if (proxy == null || (proxy != null && string.IsNullOrEmpty(proxy.Proxy) && string.IsNullOrEmpty(proxy.Port)))
            {
                registry.SetValue("ProxyEnable", 0);
                registry.SetValue("ProxyServer", "");
                registry.SetValue("ProxyUser", "");
                registry.SetValue("ProxyPass", "");
                registry.SetValue("ProxyOverride", "");
            }
            else
            {
                registry.SetValue("ProxyEnable", 1);
                registry.SetValue("ProxyServer", proxy.Proxy + ":" + proxy.Port);
                if (!string.IsNullOrEmpty(proxy.Username) && !string.IsNullOrEmpty(proxy.Password))
                {
                    registry.SetValue("ProxyUser", proxy.Username);
                    registry.SetValue("ProxyPass", StringEncryption.Unprotect(proxy.Password));
                }
                else
                {
                    registry.SetValue("ProxyUser", "");
                    registry.SetValue("ProxyPass", "");
                }

                if (proxy.Bypass)
                {
                    registry.SetValue("ProxyOverride", "<local>");
                }
                else
                {
                    registry.SetValue("ProxyOverride", "");
                }
            }

            settingsReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
            refreshReturn  = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);

            notifyIcon1.BalloonTipText = "Proxy Change (" + proxy.Name + ":" + proxy.NetworkID + ":" + proxy.Proxy + ":" + proxy.Port + ")";
            notifyIcon1.Text           = "Proxy (" + proxy.Name + ":" + proxy.NetworkID + ":" + proxy.Proxy + ":" + proxy.Port + ")";
            notifyIcon1.ShowBalloonTip(3000);
        }
Beispiel #3
0
        private void lstSettings_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = lstSettings.SelectedIndex;

            if (index < 0)
            {
                return;
            }

            if (index < this.ProxyEntries.Count)
            {
                var item = this.ProxyEntries[index];
                if (item != null)
                {
                    tbName.Text      = item.Name;
                    tbNetwork.Text   = item.NetworkID;
                    tbProxy.Text     = item.Proxy;
                    tbPort.Text      = item.Port;
                    tbUsername.Text  = item.Username;
                    tbPassword.Text  = StringEncryption.Unprotect(item.Password);
                    cbBypass.Checked = item.Bypass;
                }
            }
        }