* 重构进度提示框和等待提示框,解决有时无法关闭的问题,并作为窗体的扩展方法使用。
This commit is contained in:
parent
6e57c86b22
commit
9949f795f1
@ -147,8 +147,11 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
Invalidate();
|
Invalidate();
|
||||||
Index++;
|
Index++;
|
||||||
|
Tick?.Invoke(this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public event EventHandler Tick;
|
||||||
|
|
||||||
private void ClearImage()
|
private void ClearImage()
|
||||||
{
|
{
|
||||||
if (image != null)
|
if (image != null)
|
||||||
|
@ -58,7 +58,6 @@ using System.ComponentModel;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Design;
|
using System.Drawing.Design;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
@ -1851,88 +1850,6 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
#region 一些辅助窗口
|
#region 一些辅助窗口
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 显示进度提示窗
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="desc">描述文字</param>
|
|
||||||
/// <param name="maximum">最大进度值</param>
|
|
||||||
/// <param name="decimalCount">显示进度条小数个数</param>
|
|
||||||
public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...", int decimalCount = 1)
|
|
||||||
{
|
|
||||||
UIStatusFormService.ShowStatusForm(maximum, desc, decimalCount);
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 隐藏进度提示窗
|
|
||||||
/// </summary>
|
|
||||||
public void HideStatusForm()
|
|
||||||
{
|
|
||||||
UIStatusFormService.HideStatusForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置进度提示窗步进值加1
|
|
||||||
/// </summary>
|
|
||||||
public void StatusFormStepIt()
|
|
||||||
{
|
|
||||||
UIStatusFormService.StepIt();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置进度提示窗描述文字
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="desc">描述文字</param>
|
|
||||||
public void SetStatusFormDescription(string desc)
|
|
||||||
{
|
|
||||||
UIStatusFormService.SetDescription(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 显示等待提示窗
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="desc">描述文字</param>
|
|
||||||
public void ShowWaitForm(string desc = "系统正在处理中,请稍候...")
|
|
||||||
{
|
|
||||||
UIWaitFormService.ShowWaitForm(desc);
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 隐藏等待提示窗
|
|
||||||
/// </summary>
|
|
||||||
public void HideWaitForm()
|
|
||||||
{
|
|
||||||
UIWaitFormService.HideWaitForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置等待提示窗描述文字
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="desc">描述文字</param>
|
|
||||||
public void SetWaitFormDescription(string desc)
|
|
||||||
{
|
|
||||||
UIWaitFormService.SetDescription(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 显示等待提示窗
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="size">大小</param>
|
|
||||||
public void ShowProcessForm(int size = 200)
|
|
||||||
{
|
|
||||||
UIProcessIndicatorFormService.ShowForm(size);
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 隐藏等待提示窗
|
|
||||||
/// </summary>
|
|
||||||
public void HideProcessForm()
|
|
||||||
{
|
|
||||||
UIProcessIndicatorFormService.HideForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 正确信息提示框
|
/// 正确信息提示框
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,57 +1,127 @@
|
|||||||
using System;
|
using System.Threading;
|
||||||
using System.Threading;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
public class UIWaitFormService
|
public class UIFormService
|
||||||
{
|
{
|
||||||
private static bool IsRun;
|
protected Thread thread;
|
||||||
public static void ShowWaitForm(string desc = "系统正在处理中,请稍候...")
|
public bool IsRun => thread != null && thread.ThreadState == ThreadState.Running;
|
||||||
{
|
|
||||||
if (IsRun) return;
|
|
||||||
IsRun = true;
|
|
||||||
Instance.CreateForm(desc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void HideWaitForm()
|
public static class UIFormServiceHelper
|
||||||
{
|
{
|
||||||
if (!IsRun) return;
|
private static UIWaitFormService WaitFormService;
|
||||||
Instance.CloseForm();
|
private static UIProcessIndicatorFormService ProcessFormService;
|
||||||
IsRun = false;
|
private static UIStatusFormService StatusFormService;
|
||||||
|
|
||||||
|
static UIFormServiceHelper()
|
||||||
|
{
|
||||||
|
WaitFormService = new();
|
||||||
|
ProcessFormService = new();
|
||||||
|
StatusFormService = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetDescription(string desc)
|
/// <summary>
|
||||||
|
/// 显示等待提示窗
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="owner"></param>
|
||||||
|
/// <param name="size"></param>
|
||||||
|
public static void ShowProcessForm(this Form owner, int size = 200)
|
||||||
{
|
{
|
||||||
if (!IsRun) return;
|
if (ProcessFormService.IsRun) return;
|
||||||
Instance.SetFormDescription(desc);
|
ProcessFormService.CreateForm(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UIWaitFormService _instance;
|
internal static bool ProcessFormServiceClose;
|
||||||
private static readonly object syncLock = new object();
|
|
||||||
|
|
||||||
private static UIWaitFormService Instance
|
/// <summary>
|
||||||
|
/// 隐藏等待提示窗
|
||||||
|
/// </summary>
|
||||||
|
public static void HideProcessForm(this Form owner)
|
||||||
{
|
{
|
||||||
get
|
ProcessFormServiceClose = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示等待提示窗
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="desc">描述文字</param>
|
||||||
|
public static void ShowWaitForm(this Form owner, string desc = "系统正在处理中,请稍候...")
|
||||||
{
|
{
|
||||||
if (_instance == null)
|
if (WaitFormService.IsRun) return;
|
||||||
|
WaitFormService.CreateForm(desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool WaitFormServiceClose;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 隐藏等待提示窗
|
||||||
|
/// </summary>
|
||||||
|
public static void HideWaitForm(this Form owner)
|
||||||
{
|
{
|
||||||
lock (syncLock)
|
WaitFormServiceClose = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置等待提示窗描述文字
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="desc">描述文字</param>
|
||||||
|
public static void SetWaitFormDescription(this Form owner, string desc)
|
||||||
{
|
{
|
||||||
_instance = new UIWaitFormService();
|
if (!WaitFormService.IsRun) return;
|
||||||
|
WaitFormService.SetDescription(desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示进度提示窗
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="desc">描述文字</param>
|
||||||
|
/// <param name="maximum">最大进度值</param>
|
||||||
|
/// <param name="decimalCount">显示进度条小数个数</param>
|
||||||
|
public static void ShowStatusForm(this Form owner, int maximum = 100, string desc = "系统正在处理中,请稍候...", int decimalCount = 1)
|
||||||
|
{
|
||||||
|
if (StatusFormService.IsRun) return;
|
||||||
|
StatusFormService.CreateForm(maximum, desc, decimalCount);
|
||||||
|
Thread.Sleep(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool StatusFormServiceClose;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 隐藏进度提示窗
|
||||||
|
/// </summary>
|
||||||
|
public static void HideStatusForm(this Form owner)
|
||||||
|
{
|
||||||
|
StatusFormServiceClose = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置进度提示窗步进值加1
|
||||||
|
/// </summary>
|
||||||
|
public static void SetStatusFormStepIt(this Form owner)
|
||||||
|
{
|
||||||
|
if (!StatusFormService.IsRun) return;
|
||||||
|
StatusFormService.SetFormStepIt();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置进度提示窗描述文字
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="desc">描述文字</param>
|
||||||
|
public static void SetStatusFormDescription(this Form owner, string desc)
|
||||||
|
{
|
||||||
|
if (!StatusFormService.IsRun) return;
|
||||||
|
StatusFormService.SetFormDescription(desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _instance;
|
public class UIWaitFormService : UIFormService
|
||||||
}
|
{
|
||||||
}
|
|
||||||
|
|
||||||
private Thread thread;
|
|
||||||
private UIWaitForm form;
|
private UIWaitForm form;
|
||||||
|
|
||||||
private void CreateForm(string desc)
|
public void CreateForm(string desc)
|
||||||
{
|
{
|
||||||
CloseForm();
|
|
||||||
thread = new Thread(delegate ()
|
thread = new Thread(delegate ()
|
||||||
{
|
{
|
||||||
form = new UIWaitForm(desc);
|
form = new UIWaitForm(desc);
|
||||||
@ -61,73 +131,27 @@ namespace Sunny.UI
|
|||||||
if (IsRun) Application.Run(form);
|
if (IsRun) Application.Run(form);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (IsRun)
|
|
||||||
thread.Start();
|
thread.Start();
|
||||||
else
|
|
||||||
CloseForm();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloseForm()
|
public void SetDescription(string desc)
|
||||||
{
|
|
||||||
if (form != null) form.NeedClose = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetFormDescription(string desc)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
form?.SetDescription(desc);
|
form?.SetDescription(desc);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch
|
||||||
{
|
{
|
||||||
// ignored
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UIProcessIndicatorFormService
|
public class UIProcessIndicatorFormService : UIFormService
|
||||||
{
|
{
|
||||||
private static bool IsRun;
|
|
||||||
|
|
||||||
public static void ShowForm(int size = 100)
|
|
||||||
{
|
|
||||||
if (IsRun) return;
|
|
||||||
Instance.CreateForm(size);
|
|
||||||
IsRun = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HideForm()
|
|
||||||
{
|
|
||||||
if (!IsRun) return;
|
|
||||||
Instance.CloseForm();
|
|
||||||
IsRun = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static UIProcessIndicatorFormService _instance;
|
|
||||||
private static readonly object syncLock = new object();
|
|
||||||
|
|
||||||
private static UIProcessIndicatorFormService Instance
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
lock (syncLock)
|
|
||||||
{
|
|
||||||
_instance = new UIProcessIndicatorFormService();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Thread thread;
|
|
||||||
private UIProcessIndicatorForm form;
|
private UIProcessIndicatorForm form;
|
||||||
|
|
||||||
private void CreateForm(int size = 200)
|
public void CreateForm(int size = 200)
|
||||||
{
|
{
|
||||||
CloseForm();
|
|
||||||
thread = new Thread(delegate ()
|
thread = new Thread(delegate ()
|
||||||
{
|
{
|
||||||
form = new UIProcessIndicatorForm();
|
form = new UIProcessIndicatorForm();
|
||||||
@ -136,123 +160,49 @@ namespace Sunny.UI
|
|||||||
form.TopMost = true;
|
form.TopMost = true;
|
||||||
form.Render();
|
form.Render();
|
||||||
Application.Run(form);
|
Application.Run(form);
|
||||||
IsRun = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
thread.Start();
|
thread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloseForm()
|
|
||||||
{
|
|
||||||
if (form != null && form.Visible)
|
|
||||||
{
|
|
||||||
form.NeedClose = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UIStatusFormService
|
public class UIStatusFormService : UIFormService
|
||||||
{
|
{
|
||||||
private static bool IsRun;
|
|
||||||
public static void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...", int decimalCount = 1)
|
|
||||||
{
|
|
||||||
if (IsRun) return;
|
|
||||||
Instance.CreateForm(maximum, desc, decimalCount);
|
|
||||||
IsRun = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HideStatusForm()
|
|
||||||
{
|
|
||||||
if (!IsRun) return;
|
|
||||||
Instance.CloseForm();
|
|
||||||
IsRun = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetDescription(string desc)
|
|
||||||
{
|
|
||||||
if (!IsRun) return;
|
|
||||||
Instance.SetFormDescription(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void StepIt()
|
|
||||||
{
|
|
||||||
if (!IsRun) return;
|
|
||||||
Instance.SetFormStepIt();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static UIStatusFormService _instance;
|
|
||||||
private static readonly object syncLock = new object();
|
|
||||||
|
|
||||||
private static UIStatusFormService Instance
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
lock (syncLock)
|
|
||||||
{
|
|
||||||
_instance = new UIStatusFormService();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Thread thread;
|
|
||||||
private UIStatusForm form;
|
private UIStatusForm form;
|
||||||
|
|
||||||
private void CreateForm(int max, string desc, int decimalCount = 1)
|
public void CreateForm(int max, string desc, int decimalCount = 1)
|
||||||
{
|
{
|
||||||
CloseForm();
|
|
||||||
thread = new Thread(delegate ()
|
thread = new Thread(delegate ()
|
||||||
{
|
{
|
||||||
form = new UIStatusForm(max, desc, decimalCount);
|
form = new UIStatusForm(max, desc, decimalCount);
|
||||||
form.ShowInTaskbar = false;
|
form.ShowInTaskbar = false;
|
||||||
form.TopMost = true;
|
form.TopMost = true;
|
||||||
form.Render();
|
form.Render();
|
||||||
form.VisibleChanged += WaitForm_VisibleChanged;
|
|
||||||
Application.Run(form);
|
Application.Run(form);
|
||||||
IsRun = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
thread.Start();
|
thread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WaitForm_VisibleChanged(object sender, EventArgs e)
|
public void SetFormDescription(string desc)
|
||||||
{
|
|
||||||
if (!form.Visible)
|
|
||||||
{
|
|
||||||
form.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CloseForm()
|
|
||||||
{
|
|
||||||
form?.StepIt(form.Maximum);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetFormDescription(string desc)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
form?.SetDescription(desc);
|
form?.SetDescription(desc);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch
|
||||||
{
|
{
|
||||||
// ignored
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetFormStepIt()
|
public void SetFormStepIt()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
form?.StepIt();
|
form?.StepIt();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch
|
||||||
{
|
{
|
||||||
// ignored
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
53
SunnyUI/Forms/UIProcessIndicatorForm.Designer.cs
generated
53
SunnyUI/Forms/UIProcessIndicatorForm.Designer.cs
generated
@ -28,42 +28,35 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
components = new System.ComponentModel.Container();
|
||||||
this.uiProgressIndicator1 = new Sunny.UI.UIProgressIndicator();
|
uiProgressIndicator1 = new UIProgressIndicator();
|
||||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
timer1 = new System.Windows.Forms.Timer(components);
|
||||||
this.SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// uiProgressIndicator1
|
// uiProgressIndicator1
|
||||||
//
|
//
|
||||||
this.uiProgressIndicator1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
uiProgressIndicator1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
uiProgressIndicator1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
uiProgressIndicator1.Location = new System.Drawing.Point(5, 5);
|
||||||
this.uiProgressIndicator1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
uiProgressIndicator1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
this.uiProgressIndicator1.Location = new System.Drawing.Point(5, 5);
|
uiProgressIndicator1.Name = "uiProgressIndicator1";
|
||||||
this.uiProgressIndicator1.MinimumSize = new System.Drawing.Size(1, 1);
|
uiProgressIndicator1.Size = new System.Drawing.Size(190, 190);
|
||||||
this.uiProgressIndicator1.Name = "uiProgressIndicator1";
|
uiProgressIndicator1.TabIndex = 0;
|
||||||
this.uiProgressIndicator1.Size = new System.Drawing.Size(190, 190);
|
uiProgressIndicator1.Text = "uiProgressIndicator1";
|
||||||
this.uiProgressIndicator1.TabIndex = 0;
|
uiProgressIndicator1.Tick += uiProgressIndicator1_Tick;
|
||||||
this.uiProgressIndicator1.Text = "uiProgressIndicator1";
|
|
||||||
this.uiProgressIndicator1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
|
|
||||||
//
|
|
||||||
// timer1
|
|
||||||
//
|
|
||||||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
|
||||||
//
|
//
|
||||||
// UIProcessIndicatorForm
|
// UIProcessIndicatorForm
|
||||||
//
|
//
|
||||||
this.AllowShowTitle = false;
|
AllowShowTitle = false;
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||||
this.ClientSize = new System.Drawing.Size(200, 200);
|
ClientSize = new System.Drawing.Size(200, 200);
|
||||||
this.Controls.Add(this.uiProgressIndicator1);
|
Controls.Add(uiProgressIndicator1);
|
||||||
this.Name = "UIProcessIndicatorForm";
|
Name = "UIProcessIndicatorForm";
|
||||||
this.Padding = new System.Windows.Forms.Padding(2, 0, 2, 2);
|
Padding = new System.Windows.Forms.Padding(2, 0, 2, 2);
|
||||||
this.ShowTitle = false;
|
ShowTitle = false;
|
||||||
this.Text = "UIProcessIndicatorForm";
|
Text = "UIProcessIndicatorForm";
|
||||||
this.ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 800, 450);
|
ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 800, 450);
|
||||||
this.ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System.ComponentModel;
|
namespace Sunny.UI
|
||||||
|
|
||||||
namespace Sunny.UI
|
|
||||||
{
|
{
|
||||||
public partial class UIProcessIndicatorForm : UIForm
|
public partial class UIProcessIndicatorForm : UIForm
|
||||||
{
|
{
|
||||||
@ -11,16 +9,14 @@ namespace Sunny.UI
|
|||||||
uiProgressIndicator1.Active = true;
|
uiProgressIndicator1.Active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void timer1_Tick(object sender, System.EventArgs e)
|
private void uiProgressIndicator1_Tick(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
if (NeedClose)
|
if (UIFormServiceHelper.ProcessFormServiceClose)
|
||||||
{
|
{
|
||||||
|
UIFormServiceHelper.ProcessFormServiceClose = false;
|
||||||
uiProgressIndicator1.Active = false;
|
uiProgressIndicator1.Active = false;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DefaultValue(false), Browsable(false)]
|
|
||||||
public bool NeedClose { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,64 @@
|
|||||||
<root>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
77
SunnyUI/Forms/UIStatusForm.Designer.cs
generated
77
SunnyUI/Forms/UIStatusForm.Designer.cs
generated
@ -28,54 +28,61 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.labelDescription = new Sunny.UI.UILabel();
|
components = new System.ComponentModel.Container();
|
||||||
this.processBar = new Sunny.UI.UIProcessBar();
|
labelDescription = new UILabel();
|
||||||
this.SuspendLayout();
|
processBar = new UIProcessBar();
|
||||||
|
timer1 = new System.Windows.Forms.Timer(components);
|
||||||
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelDescription
|
// labelDescription
|
||||||
//
|
//
|
||||||
this.labelDescription.AutoSize = true;
|
labelDescription.AutoSize = true;
|
||||||
this.labelDescription.BackColor = System.Drawing.Color.Transparent;
|
labelDescription.BackColor = System.Drawing.Color.Transparent;
|
||||||
this.labelDescription.Font = new System.Drawing.Font("宋体", 12F);
|
labelDescription.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.labelDescription.Location = new System.Drawing.Point(32, 55);
|
labelDescription.Location = new System.Drawing.Point(32, 55);
|
||||||
this.labelDescription.Name = "labelDescription";
|
labelDescription.Name = "labelDescription";
|
||||||
this.labelDescription.Size = new System.Drawing.Size(178, 21);
|
labelDescription.Size = new System.Drawing.Size(207, 16);
|
||||||
this.labelDescription.TabIndex = 1;
|
labelDescription.TabIndex = 1;
|
||||||
this.labelDescription.Text = "系统正在处理中,请稍候...";
|
labelDescription.Text = "系统正在处理中,请稍候...";
|
||||||
this.labelDescription.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
labelDescription.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
//
|
//
|
||||||
// processBar
|
// processBar
|
||||||
//
|
//
|
||||||
this.processBar.Font = new System.Drawing.Font("宋体", 12F);
|
processBar.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.processBar.Location = new System.Drawing.Point(32, 91);
|
processBar.Location = new System.Drawing.Point(32, 91);
|
||||||
this.processBar.MinimumSize = new System.Drawing.Size(70, 23);
|
processBar.MinimumSize = new System.Drawing.Size(70, 23);
|
||||||
this.processBar.Name = "processBar";
|
processBar.Name = "processBar";
|
||||||
this.processBar.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
|
processBar.RadiusSides = UICornerRadiusSides.None;
|
||||||
this.processBar.Size = new System.Drawing.Size(409, 29);
|
processBar.Size = new System.Drawing.Size(409, 29);
|
||||||
this.processBar.TabIndex = 3;
|
processBar.TabIndex = 3;
|
||||||
this.processBar.Text = "0.0%";
|
processBar.Text = "0.0%";
|
||||||
this.processBar.ValueChanged += new Sunny.UI.UIProcessBar.OnValueChanged(this.processBar_ValueChanged);
|
processBar.ValueChanged += processBar_ValueChanged;
|
||||||
|
//
|
||||||
|
// timer1
|
||||||
|
//
|
||||||
|
timer1.Tick += timer1_Tick;
|
||||||
//
|
//
|
||||||
// UIStatusForm
|
// UIStatusForm
|
||||||
//
|
//
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||||
this.ClientSize = new System.Drawing.Size(473, 153);
|
ClientSize = new System.Drawing.Size(473, 153);
|
||||||
this.ControlBox = false;
|
ControlBox = false;
|
||||||
this.Controls.Add(this.processBar);
|
Controls.Add(processBar);
|
||||||
this.Controls.Add(this.labelDescription);
|
Controls.Add(labelDescription);
|
||||||
this.IsForbidAltF4 = true;
|
IsForbidAltF4 = true;
|
||||||
this.MaximizeBox = false;
|
MaximizeBox = false;
|
||||||
this.MinimizeBox = false;
|
MinimizeBox = false;
|
||||||
this.Name = "UIStatusForm";
|
Name = "UIStatusForm";
|
||||||
this.Text = "提示";
|
Text = "提示";
|
||||||
this.TopMost = true;
|
TopMost = true;
|
||||||
this.ResumeLayout(false);
|
ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 473, 153);
|
||||||
this.PerformLayout();
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private UILabel labelDescription;
|
private UILabel labelDescription;
|
||||||
private UIProcessBar processBar;
|
private UIProcessBar processBar;
|
||||||
|
private System.Windows.Forms.Timer timer1;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,6 +30,7 @@ namespace Sunny.UI
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Text = UILocalize.InfoTitle;
|
Text = UILocalize.InfoTitle;
|
||||||
Description = UILocalize.SystemProcessing;
|
Description = UILocalize.SystemProcessing;
|
||||||
|
timer1.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UIStatusForm(int max, string desc, int decimalPlaces = 1)
|
public UIStatusForm(int max, string desc, int decimalPlaces = 1)
|
||||||
@ -40,6 +41,7 @@ namespace Sunny.UI
|
|||||||
Description = desc;
|
Description = desc;
|
||||||
Value = 0;
|
Value = 0;
|
||||||
DecimalPlaces = decimalPlaces;
|
DecimalPlaces = decimalPlaces;
|
||||||
|
timer1.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
[DefaultValue(100)]
|
[DefaultValue(100)]
|
||||||
@ -80,7 +82,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (MaxAutoHide && value == Maximum)
|
if (MaxAutoHide && value == Maximum)
|
||||||
{
|
{
|
||||||
Hide();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,5 +136,15 @@ namespace Sunny.UI
|
|||||||
processBar.StepIt();
|
processBar.StepIt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void timer1_Tick(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
if (UIFormServiceHelper.StatusFormServiceClose)
|
||||||
|
{
|
||||||
|
timer1.Stop();
|
||||||
|
UIFormServiceHelper.StatusFormServiceClose = false;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -19,8 +19,6 @@
|
|||||||
* 2020-10-13: V3.0.0 增加文件说明
|
* 2020-10-13: V3.0.0 增加文件说明
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
public sealed partial class UIWaitForm : UIForm
|
public sealed partial class UIWaitForm : UIForm
|
||||||
@ -54,12 +52,13 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DefaultValue(false), Browsable(false)]
|
|
||||||
public bool NeedClose { get; set; }
|
|
||||||
|
|
||||||
private void Bar_Tick(object sender, System.EventArgs e)
|
private void Bar_Tick(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
if (NeedClose) Close();
|
if (UIFormServiceHelper.WaitFormServiceClose)
|
||||||
|
{
|
||||||
|
UIFormServiceHelper.WaitFormServiceClose = false;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ using System.ComponentModel;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Design;
|
using System.Drawing.Design;
|
||||||
using System.Threading;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
@ -1113,88 +1112,6 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
#region 一些辅助窗口
|
#region 一些辅助窗口
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 显示进度提示窗
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="desc">描述文字</param>
|
|
||||||
/// <param name="maximum">最大进度值</param>
|
|
||||||
/// <param name="decimalCount">显示进度条小数个数</param>
|
|
||||||
public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...", int decimalCount = 1)
|
|
||||||
{
|
|
||||||
UIStatusFormService.ShowStatusForm(maximum, desc, decimalCount);
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 隐藏进度提示窗
|
|
||||||
/// </summary>
|
|
||||||
public void HideStatusForm()
|
|
||||||
{
|
|
||||||
UIStatusFormService.HideStatusForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置进度提示窗步进值加1
|
|
||||||
/// </summary>
|
|
||||||
public void StatusFormStepIt()
|
|
||||||
{
|
|
||||||
UIStatusFormService.StepIt();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置进度提示窗描述文字
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="desc">描述文字</param>
|
|
||||||
public void SetStatusFormDescription(string desc)
|
|
||||||
{
|
|
||||||
UIStatusFormService.SetDescription(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 显示等待提示窗
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="desc">描述文字</param>
|
|
||||||
public void ShowWaitForm(string desc = "系统正在处理中,请稍候...")
|
|
||||||
{
|
|
||||||
UIWaitFormService.ShowWaitForm(desc);
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 隐藏等待提示窗
|
|
||||||
/// </summary>
|
|
||||||
public void HideWaitForm()
|
|
||||||
{
|
|
||||||
UIWaitFormService.HideWaitForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 显示等待提示窗
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="size">大小</param>
|
|
||||||
public void ShowProcessForm(int size = 200)
|
|
||||||
{
|
|
||||||
UIProcessIndicatorFormService.ShowForm(size);
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 隐藏等待提示窗
|
|
||||||
/// </summary>
|
|
||||||
public void HideProcessForm()
|
|
||||||
{
|
|
||||||
UIProcessIndicatorFormService.HideForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置等待提示窗描述文字
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="desc">描述文字</param>
|
|
||||||
public void SetWaitFormDescription(string desc)
|
|
||||||
{
|
|
||||||
UIWaitFormService.SetDescription(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 正确信息提示框
|
/// 正确信息提示框
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user