Exemplo n.º 1
0
        private void formLogin_Load(object sender, EventArgs e)
        {
            try
            {
                string path=Environment.SystemDirectory + "\\drivers\\etc\\hosts";
                if (System.IO.File.Exists(path))
                {
                    var hostAction = new HostAction(path);
                    hostAction.RestoreHosts();
                }
                else
                {
                    this.btnSwitchServer.Enabled = false;
                    formSelectTicket.hostEnable = false;
                    MessageBox.Show("没有找到hosts文件,请新建后重新启动本程序以恢复自动切换功能,否则切换功能将不可用.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch(Exception ex) {
                formSelectTicket.hostEnable = false;
                MessageBox.Show(string.Format("由于加载Hosts文件失败,失败原因:{0}\r\n可能导致软件的IP切换功能无效,如果想启用,请允许程序访问Hosts文件或者去除Hosts文件的保护,然后重新启动本程序", ex.Message), "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            GetAutoCompleteSource();
            if(_nameSource!=null)
            { cboName.Items.AddRange(_nameSource); }
            

            var dc=new DesCryption();
            cboName.Text = ConfigInfo.conf.username;
            if(cboName.Text !=string.Empty)
                txtPwd.Text = dc.DecryptString(ConfigInfo.conf.password, ConfigInfo.conf.username);
        }
Exemplo n.º 2
0
 public CDNSwitcher()
 {
     if(hostAction==null)
         hostAction = new HostAction(Environment.SystemDirectory + "\\drivers\\etc\\hosts");
     if (CDN_List.Count > 0)
         _index = 0;
 }
Exemplo n.º 3
0
 private void InitHostPath()
 {
     try
     {
         hostAction = new HostAction(Environment.SystemDirectory + "\\drivers\\etc\\hosts");
     }
     catch
     {
         hostEnable = false;
     }
 }
Exemplo n.º 4
0
 private void InitHostPath()
 {
     try
     {
         hostAction = new HostAction(Environment.SystemDirectory + "\\drivers\\etc\\hosts");
     }
     catch
     {
         hostEnable = false;
     }
 }
Exemplo n.º 5
0
 public CDNSwitcher()
 {
     if (hostAction == null)
     {
         hostAction = new HostAction(Environment.SystemDirectory + "\\drivers\\etc\\hosts");
     }
     if (CDN_List.Count > 0)
     {
         _index = 0;
     }
 }