using System; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace DPumpHydr.WinFrmUI.WenSkin.Forms { public partial class LodingForm : Form { public LodingForm(bool button = false) { InitializeComponent(); wenImageButton1.Visible = button; } public string Mes { get => label1.Text; set { if (this.IsHandleCreated) { this.Invoke(new Action(() => { label1.Text = value; })); } else label1.Text = value; } } public int Value = 0; private void timer1_Tick(object sender, EventArgs e) { if (Value > 100) { Value = 0; } Value += 10; wenCircleProgress1.Value = Value; } /// /// 开启新的线程启动 /// public void Start() { new Task(() => { this.ShowDialog(); }).RunSynchronously(); } /// /// 不用管理线程关闭 /// public void End() { AcClose(); } public void AcClose() { Invoke(new Action(() => { this.Close(); })); } public bool PEnabled { get => timer1.Enabled; set { timer1.Enabled = value; if (!value) { Invoke(new Action(() => { wenImageButton1.Visible = true; wenCircleProgress1.Value = 100; })); } } } public void MessageClick(string mes, bool enabled) { Mes = mes; PEnabled = enabled; } private void wenImageButton1_Click(object sender, EventArgs e) { this.Close(); } public void Pass() { PEnabled = false; } } }