118 lines
3.7 KiB
C#
118 lines
3.7 KiB
C#
using TemuKJD.KJDForms.BaseForms;
|
|
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 AllBase.Helper;
|
|
using NaiBa.Util.Helper;
|
|
|
|
namespace TemuKJD
|
|
{
|
|
public partial class InitForm : LRBaseForm
|
|
{
|
|
InitFormSettings initFormSettings = new InitFormSettings();
|
|
public InitForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Load += InitForm_Load;
|
|
}
|
|
|
|
private void InitForm_Load(object sender, EventArgs e)
|
|
{
|
|
#if DEBUG
|
|
this.panel3.Location = new Point(4, 4);
|
|
this.panel4.Visible=true;
|
|
#endif
|
|
initFormSettings = ConfigHelper.LoadConfig<InitFormSettings>("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() != "temu";
|
|
|
|
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);
|
|
}
|
|
if (initFormSettings.Remember)
|
|
Thread.Sleep(500);
|
|
Invoke(new Action(() =>
|
|
{
|
|
if(initFormSettings.Remember)
|
|
{
|
|
OpenNewMainForm();
|
|
}
|
|
}));
|
|
});
|
|
}
|
|
|
|
void OpenNewMainForm()
|
|
{
|
|
try
|
|
{
|
|
if (!Work.Initialization.IsCheckFilesSuccesss)
|
|
{
|
|
BaseMsgForm.ShowError("文件初始化失败,请检查是否有程序占用并使用管理员权限运行本程序!");
|
|
Process.GetCurrentProcess().Kill();
|
|
}
|
|
this.Hide();
|
|
new MainForm(initFormSettings.LoginType).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)
|
|
{
|
|
OpenNewMainForm();
|
|
}
|
|
|
|
private void chkRemember_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
initFormSettings.Remember = chkRemember.Checked;
|
|
ConfigHelper.SaveConfig("initFormSettings", initFormSettings);
|
|
}
|
|
|
|
private void rbTemu_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (rbTemu.Checked)
|
|
initFormSettings.LoginType = "Temu";
|
|
else
|
|
initFormSettings.LoginType = "Pdd";
|
|
ConfigHelper.SaveConfig("initFormSettings", initFormSettings);
|
|
}
|
|
}
|
|
|
|
class InitFormSettings
|
|
{
|
|
public string LoginType { get; set; } = "Temu";
|
|
public bool Remember { get; set; } = true;
|
|
}
|
|
}
|