private void configDlg_FormClosing(object sender, FormClosingEventArgs e) { foreach (Control control in this.tabPage2.Controls) { if (control.GetType() == this.txtPassword.GetType()) { if ((control == this.txtWidth) && (control.Text == string.Empty)) { control.Text = "700"; } if ((control == this.txtHeight) && (control.Text == string.Empty)) { control.Text = "500"; } } } this.cfg.password = this.txtPassword.Text; this.cfg.pic_width = System.Convert.ToInt32(this.txtWidth.Text); this.cfg.pic_height = System.Convert.ToInt32(this.txtHeight.Text); this.cfg.isMerger = this.cbIsMerger.Checked ? 1 : 0; this.edt(this.cfg); ini_config _config = new ini_config("config.ini"); _config.write_ini("isMerger", this.cfg.isMerger.ToString(), "App"); _config.write_ini("pwd", this.cfg.password, "App"); if (this.old_type != this.new_type) { new ini_config("config.ini").write_ini("formtype", this.new_type.ToString(), "App"); MessageBox.Show("界面修改将在下次软件重启后生效", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void dl_config() { AddText method = new AddText(this.add_text); AddListItem item = new AddListItem(this.add_list_item); base.Invoke(method, new object[] { "检测是否有新版本..." }); base.Invoke(method, new object[] { "读取远程配置文件..." }); ini_config _config = new ini_config("config.ini"); try { bool flag = false; Thread thread = new Thread(new ThreadStart(this.GetAddress)) { IsBackground = true }; thread.Start(); thread.Join(); if (!string.IsNullOrEmpty(this.text)) { if (this.text.IndexOf("#END#") == -1) { throw new Exception(); } string[] strArray = this.text.Split(Environment.NewLine.ToCharArray()); string str = string.Empty; string str2 = _config.read_ini("VeryPdf", "App"); string str3 = string.Empty; string str4 = ""; for (int i = 0; i < (strArray.Length - 1); i++) { if (strArray[i] != string.Empty) { if (strArray[i].Contains("#END#")) { break; } if (strArray[i].Contains("version")) { str = strArray[i].Split(new char[] { ',' })[1]; } else if (strArray[i].Contains("veryPdf")) { str3 = strArray[i].Split(new char[] { ',' })[1]; } else { string[] strArray2 = strArray[i].Split(new char[] { ',' }); if (!(PDF_Convert.Version.dic_ver.TryGetValue(strArray2[0], out str4) && (System.Convert.ToInt32(PDF_Convert.Version.dic_ver[strArray2[0]].Replace(".", "")) >= System.Convert.ToInt32(strArray2[1].Replace(".", ""))))) { this.dl_lst.Add(new detail_list(strArray2[2], System.Convert.ToInt32(strArray2[3]))); base.Invoke(item); flag = true; } } } } if (!string.IsNullOrEmpty(str3)) { try { if (string.IsNullOrEmpty(str2) || (System.Convert.ToDouble(str2) < System.Convert.ToDouble(str3))) { this.dl_lst.Add(new detail_list("VeryPdf.rar", 0x4f832a)); base.Invoke(item); flag = true; } } catch { } } if (flag) { base.Invoke(new _Show(this.show_this_window)); base.Invoke(method, new object[] { "开始下载新文件..." }); Thread thread2 = new Thread(new ThreadStart(this.dl_file)) { IsBackground = true }; thread2.Start(); thread2.Join(); ProcessStartInfo startInfo = new ProcessStartInfo(Application.StartupPath + @"\PDF Update.exe") { Arguments = "Madoka " + Process.GetCurrentProcess().Id.ToString() }; foreach (detail_list _list in this.dl_lst) { startInfo.Arguments = startInfo.Arguments + string.Format(" \"{0}\"", _list.file_name); } Process.Start(startInfo); base.Invoke(method, new object[] { "下载新文件成功,程序即将退出以便进行更新" }); Thread.Sleep(0x3e8); _config.write_ini("Version", str, "App"); _config.write_ini("VeryPdf", str3, "App"); } base.Invoke(new _Exit(this.Close)); } } catch { base.Invoke(new _Exit(this.Close)); } }