private void formLogin_Load(object sender, EventArgs e) { try { string path = Environment.SystemDirectory + "\\drivers\\etc\\hosts"; if (System.IO.File.Exists(path)) { HostAction hostAction = new HostAction(path); hostAction.RestoreHosts(); } else { 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); } ConfigInfo.readfromfile(); txtName.Text = EncodeAndDecode.DecodeBase64(EncodeAndDecode.DecodeBase64(ConfigInfo.conf.username)); txtPwd.Text = EncodeAndDecode.DecodeBase64(EncodeAndDecode.DecodeBase64(ConfigInfo.conf.password)); IntPtr o = this.Handle; GetRandCodeImg(); formStyle.ShowForm(this.Handle, 500); }
private void formSelectTicket_FormClosing(object sender, FormClosingEventArgs e) { try { notice.Visible = false; hostAction.RestoreHosts(); } finally{ } foreach (TabPage page in this.tabAccount.TabPages) { var tm = (TicketFrame)page.Controls[0]; SaveUsersConfigList(tm.UserName, tm.ConfigList); } }
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); } }