Exemplo n.º 1
0
        private void ConfigList_SelectedIndexChanged(object sender, EventArgs e)
        {
            SettingItem st  = (SettingItem)ConfigList.SelectedItem;
            Hashtable   ret = Xml.getSettingById(st.Id);

            if (ret == null)
            {
                return;
            }
            if ((string)ret["ProxyEnable"] == "1")
            {
                EnableProxy.Checked = true;
                HTTP_IP.Text        = HTTP_Port.Text = HTTPS_IP.Text = HTTPS_Port.Text = FTP_IP.Text = FTP_Port.Text = SOCKS_IP.Text = SOCKS_Port.Text = "";
                if (((string)ret["ProxyServer"]).IndexOf("=") == -1)
                {
                    UseAllSameSetting.Checked = true;
                    string[] proxy = ((string)ret["ProxyServer"]).Split(':');
                    HTTP_IP.Text   = proxy[0];
                    HTTP_Port.Text = proxy[1];
                }
                else
                {
                    UseAllSameSetting.Checked = false;
                    string[] proxys = ((string)ret["ProxyServer"]).Split(';');
                    foreach (string p in proxys)
                    {
                        string[] proxy = p.Split('=');
                        string[] sett  = proxy[1].Split(':');
                        switch (proxy[0].ToUpper())
                        {
                        case "HTTP":
                            HTTP_IP.Text   = sett[0];
                            HTTP_Port.Text = sett[1];
                            break;

                        case "HTTPS":
                            HTTPS_IP.Text   = sett[0];
                            HTTPS_Port.Text = sett[1];
                            break;

                        case "FTP":
                            FTP_IP.Text   = sett[0];
                            FTP_Port.Text = sett[1];
                            break;

                        case "SOCKS":
                            SOCKS_IP.Text   = sett[0];
                            SOCKS_Port.Text = sett[1];
                            break;
                        }
                    }
                }
                SkipLocalProxy.Checked = (((string)ret["ProxyOverride"]).IndexOf("<local>") != -1);
            }
            else
            {
                EnableProxy.Checked = false;
            }
            ProxyOverride.Text = ((string)ret["ProxyOverride"]).Replace("<local>", "");
            HostContent.Text   = (string)ret["Hosts"];

            SaveSetting.Enabled  = true;
            ApplySetting.Enabled = true;
            ShareConfig.Enabled  = true;
        }