using AllBase; using NaiBa.Util.Extension; using NaiBa.Util.Helper; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using TemuKJD.BaseForms; namespace TemuKJD { public partial class InitForm : BaseForms.BaseGeneralForm { InitFormSettings initFormSettings = new InitFormSettings(); public InitForm() { InitializeComponent(); if (BaseClass.AgentCode.IsNullOrEmpty()) this.ShowIcon = false; this.Load += NewInitForm_Load; } private void NewInitForm_Load(object sender, EventArgs e) { //if (!BaseClass.AgentCode.IsNullOrEmpty()) // this.Icon = BaseClass.Ico; //if (!BaseClass.AgentCode.IsNullOrEmpty()) // this.Hide(); Task.Run(() => { while (!Work.Initialization.IsCheckFilesFinish || !Program.IsInit || this.progressBarX1.Value < 50) { Thread.Sleep(new Random().Next(10, 50)); Invoke(new Action(() => { this.progressBarX1.Value = Work.Initialization.InitPercent++; this.progressBarX1.Maximum = 50; })); if (this.progressBarX1.Value >= 50) Thread.Sleep(300); } Invoke(new Action(() => { OpenNewMainForm(); })); }); return; // if (File.Exists(System.Environment.CurrentDirectory + "\\YkdChoice.dll")) // { // this.panel3.Location = new Point(4, 4); // this.panel4.Visible = true; // this.rbPdd.Visible = true; // } // if (File.Exists(System.Environment.CurrentDirectory + "\\WxChoice.dll")) // { // this.panel3.Location = new Point(4, 4); // this.panel4.Visible = true; // this.rbWX.Visible = true; // } //#if DEBUG // this.panel3.Location = new Point(4, 4); // this.panel4.Visible = true; // this.rbPdd.Visible = true; // this.rbWX.Visible = true; //#endif // initFormSettings = ConfigHelper.LoadConfig("initFormSettings"); // if (initFormSettings == null) // initFormSettings = new InitFormSettings(); // this.chkRemember.Checked = initFormSettings.Remember; // this.rbTemu.Checked = initFormSettings.LoginType.ToLower() == "temu"; // this.rbPdd.Checked = initFormSettings.LoginType.ToLower() == "pdd"; // this.rbWX.Checked = initFormSettings.LoginType.ToLower() == "wx"; // if (initFormSettings.LoginType.ToLower() == "temu") // BaseClass.MainPath = "kuajingda"; // else if (initFormSettings.LoginType.ToLower() == "pdd") // BaseClass.MainPath = "29pdd"; // else if (initFormSettings.LoginType.ToLower() == "wx") // BaseClass.MainPath = "29wx"; // else if (initFormSettings.LoginType.ToLower() == "dy") // BaseClass.MainPath = "29dy"; // this.rbTemu.CheckedChanged += rbTemu_CheckedChanged; // this.rbPdd.CheckedChanged += rbTemu_CheckedChanged; // this.rbWX.CheckedChanged += rbTemu_CheckedChanged; // if (rbWX.Visible == false || rbPdd.Visible == false) // flowLayoutPanel1.Location = new Point(38, flowLayoutPanel1.Location.Y); // Task.Run(() => // { // while (!Work.Initialization.IsCheckFilesFinish || !Program.IsInit || this.progressBarX1.Value < 50) // { // Thread.Sleep(new Random().Next(10, 50)); // Invoke(new Action(() => // { // this.progressBarX1.Value = Work.Initialization.InitPercent++; // this.progressBarX1.Maximum = 50; // })); // if (this.progressBarX1.Value >= 50) // Thread.Sleep(300); // } // Invoke(new Action(() => // { // btnOK.Visible = true; // })); //#if DEBUG // Thread.Sleep(2500); //#else // if (File.Exists(System.Environment.CurrentDirectory + "\\YkdChoice.dll")) // { // Thread.Sleep(2500); // } //#endif // if (initFormSettings.Remember) // Thread.Sleep(500); // Invoke(new Action(() => // { // if(initFormSettings.Remember && isChangeType == false) // { // OpenNewMainForm(); // } // })); // }); } bool isOpen = false; void OpenNewMainForm() { if (isOpen) return; try { if (!Work.Initialization.IsCheckFilesSuccesss) { BaseMsgForm.ShowError("文件初始化失败,请检查是否有程序占用并使用管理员权限运行本程序!"); Process.GetCurrentProcess().Kill(); } this.Hide(); isOpen = true; new MainForm().ShowDialog(); } catch (Exception ex) { BaseMsgForm.ShowError(ex.Message); Process.GetCurrentProcess().Kill(); } } private void InitForm_FormClosed(object sender, FormClosedEventArgs e) { Process.GetCurrentProcess().Kill(); } private void btnOK_Click(object sender, EventArgs e) { if (isChangeType == false) OpenNewMainForm(); } private void chkRemember_CheckedChanged(object sender, EventArgs e) { initFormSettings.Remember = chkRemember.Checked; ConfigHelper.SaveConfig("initFormSettings", initFormSettings); } bool isChangeType = false; private void rbTemu_CheckedChanged(object sender, EventArgs e) { if ((sender as RadioButton).Checked == false) return; string newLoginType = "Temu"; if (sender == rbTemu && rbTemu.Checked) newLoginType = "Temu"; else if (sender == rbPdd && rbPdd.Checked) newLoginType = "Pdd"; else if (sender == rbWX && rbWX.Checked) newLoginType = "Wx"; if (initFormSettings.LoginType != newLoginType) { isChangeType = true; initFormSettings.LoginType = newLoginType; ConfigHelper.SaveConfig("initFormSettings", initFormSettings); BaseMsgForm.ShowInfo("更改了平台,需要重新启动"); { System.Diagnostics.Process.Start(Process.GetCurrentProcess().MainModule.FileName); Application.Exit(); } } } } class InitFormSettings { public string LoginType { get; set; } = "Temu"; public bool Remember { get; set; } = true; } }