//写入软件本次配置保存 private void UI_writeConfig() { saveConfig saveCfg = new saveConfig(null); //参数null,使用默认文件名 saveCfg.Write("netPwd", netPwd); //saveCfg.Write("gateway", gateway); saveCfg.Write("routerAcc", routerAcc); saveCfg.Write("routerPwd", routerPwd); saveCfg.Write("cloneMAC", normal_comboBox_Mac.Text); saveCfg.Write("special", normal_comboBox_special.Text); saveCfg.Write("wifiAcc", wifiAcc); saveCfg.Write("wifiPwd", wifiPwd); if (r != null && r.routerType != 0) { saveCfg.Write("routerType", r.routerType.ToString()); } saveCfg.Write("save", normal_checkBox_save.Checked.ToString()); }
//检测路由支持,并设置UI相关 //本方法应另开线程,因其中有阻塞内容 private void UI_verifyRouterSupport() { pubFun_setText_simpleButton_showUser("正在检测路由支持", Color.White); UI_lockButton(false); //路由检测时不允许点击按钮 foreach (String gate in netSup.getGateways()) { r = new routerP(gate); if (r.routerType > 0) //如果路由获得支持 { if (netAcc() == null) //如果路由支持但无许可证 { pubFun_setText_simpleButton_showUser("路由已支持,请从QQ群241108736获取许可证", Color.White); } else { String str = "路由已支持"; saveConfig saveCfg = new saveConfig(null); if (saveCfg.Read("routerType") != null) { if (!saveCfg.Read("routerType").Equals(r.routerType.ToString())) { str += ",此路由器并非上次使用的设备,请注意路由密码正确"; } } pubFun_setText_simpleButton_showUser(str, Color.White); } if (r.routerType == 1) //如果路由器时getI型 { pubFun_setVisible_easy_label_routerAcc(true); pubFun_setVisible_easy_textBox_routerAcc(true); } UI_lockButton(true); //如果路由获得支持所有按键解放 break; } } if (r.routerType <= 0) { pubFun_setText_simpleButton_showUser("路由不支持", Color.Red); } }
//读取软件上一次的保存配置,并映射到前台 private void UI_readConfig() { saveConfig saveCfg = new saveConfig(null); //参数null,使用默认文件名 //如果上次UI退出前没点保存 if (saveCfg.Read("save") != null) { if (!saveCfg.Read("save").Equals("True")) { return; } else { normal_checkBox_save.Checked = true; } } //宽带密码 netPwd = saveCfg.Read("netPwd"); if (netPwd != null && !netPwd.Equals("")) { normal_textBox_netPwd.Text = netPwd; } ////网关 ////gateway = saveCfg.Read("gateway"); ////if (gateway != null && !gateway.Equals("")) //// normal_textBox_routerGateway.Text = gateway; //路由账号 routerAcc = saveCfg.Read("routerAcc"); if (routerAcc != null && !routerAcc.Equals("")) { normal_textBox_routerAcc.Text = routerAcc; } //路由密码 routerPwd = saveCfg.Read("routerPwd"); if (routerPwd != null && !routerPwd.Equals("")) { normal_textBox_routerPwd.Text = routerPwd; } //克隆MAC String cloneMacRead = saveCfg.Read("cloneMAC"); switch (cloneMacRead) { case "本机MAC": cloneMAC = "pc"; normal_comboBox_Mac.Text = "本机MAC"; break; case "路由MAC": cloneMAC = "router"; normal_comboBox_Mac.Text = "路由MAC"; break; default: if (cloneMacRead != null && !cloneMacRead.Equals("")) { cloneMAC = cloneMacRead; normal_comboBox_Mac.Text = cloneMacRead; } else { cloneMAC = "pc"; normal_comboBox_Mac.Text = "本机MAC"; } break; } //特殊拨号 String specialRead = saveCfg.Read("special"); if (specialRead != null) { for (int i = 1; i <= 7; i++) { if (specialRead.IndexOf(i.ToString()) != -1) { special = i; normal_comboBox_special.Text = "特殊拨号" + i.ToString(); break; } if (i == 7) { special = 0; normal_comboBox_special.Text = "正常拨号"; break; } } } //wifi账号 wifiAcc = saveCfg.Read("wifiAcc"); if (wifiAcc != null && !wifiAcc.Equals("")) { normal_textBox_wifiAcc.Text = wifiAcc; } //wifi密码 wifiPwd = saveCfg.Read("wifiPwd"); if (wifiPwd != null && !wifiPwd.Equals("")) { normal_textBox_wifiPwd.Text = wifiPwd; } }