* UIWaitFormService:更新线程终止为窗体关闭后关闭线程

This commit is contained in:
Sunny 2020-10-13 22:37:19 +08:00
parent b15b14087f
commit 4016c68776
7 changed files with 18 additions and 11 deletions

Binary file not shown.

Binary file not shown.

View File

@ -11,7 +11,6 @@ namespace Sunny.UI.Demo
public FMain()
{
InitializeComponent();
int pageIndex = 1000;
Header.SetNodePageIndex(Header.Nodes[0], pageIndex);
Header.SetNodeSymbol(Header.Nodes[0], 61451);

View File

@ -29,7 +29,7 @@ namespace Sunny.UI
[ToolboxItem(true)]
public sealed class UIWaitingBar : UIControl
{
private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
private readonly Timer timer = new Timer();
public UIWaitingBar()
{
@ -66,6 +66,8 @@ namespace Sunny.UI
set => blockCount = Math.Max(10, value);
}
public event EventHandler Tick;
private void Timer_Tick(object sender, EventArgs e)
{
//移动距离要减去滑块本身的宽度
@ -86,6 +88,8 @@ namespace Sunny.UI
dz = dMoveDistance * (1 + Math.Sin((d - 90) * Math.PI / 180)) / 2;
Invalidate();
Tick?.Invoke(sender, e);
}
[DefaultValue(200)]

View File

@ -63,14 +63,7 @@ namespace Sunny.UI
private void CloseForm()
{
try
{
thread?.Abort();
}
catch (Exception)
{
// ignored
}
if (form != null) form.NeedClose = true;
}
private void SetFormDescription(string desc)

View File

@ -1,4 +1,6 @@
namespace Sunny.UI
using System.ComponentModel;
namespace Sunny.UI
{
public partial class UIWaitForm : UIForm
{
@ -30,5 +32,13 @@
labelDescription.Invalidate();
}
}
[DefaultValue(false), Browsable(false)]
public bool NeedClose { get; set; }
private void Bar_Tick(object sender, System.EventArgs e)
{
if (NeedClose) Close();
}
}
}

View File

@ -53,6 +53,7 @@
this.Bar.Size = new System.Drawing.Size(409, 29);
this.Bar.TabIndex = 6;
this.Bar.Text = "uiWaitingBar1";
this.Bar.Tick += new System.EventHandler(this.Bar_Tick);
//
// UIWaitForm
//