* 重构进度提示框和等待提示框,解决有时无法关闭的问题,并作为窗体的扩展方法使用。
This commit is contained in:
parent
6e57c86b22
commit
9949f795f1
@ -147,8 +147,11 @@ namespace Sunny.UI
|
||||
{
|
||||
Invalidate();
|
||||
Index++;
|
||||
Tick?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public event EventHandler Tick;
|
||||
|
||||
private void ClearImage()
|
||||
{
|
||||
if (image != null)
|
||||
|
@ -58,7 +58,6 @@ using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
@ -1851,88 +1850,6 @@ namespace Sunny.UI
|
||||
|
||||
#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>
|
||||
|
@ -1,57 +1,127 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
public class UIWaitFormService
|
||||
public class UIFormService
|
||||
{
|
||||
private static bool IsRun;
|
||||
public static void ShowWaitForm(string desc = "系统正在处理中,请稍候...")
|
||||
protected Thread thread;
|
||||
public bool IsRun => thread != null && thread.ThreadState == ThreadState.Running;
|
||||
}
|
||||
|
||||
public static class UIFormServiceHelper
|
||||
{
|
||||
private static UIWaitFormService WaitFormService;
|
||||
private static UIProcessIndicatorFormService ProcessFormService;
|
||||
private static UIStatusFormService StatusFormService;
|
||||
|
||||
static UIFormServiceHelper()
|
||||
{
|
||||
if (IsRun) return;
|
||||
IsRun = true;
|
||||
Instance.CreateForm(desc);
|
||||
WaitFormService = new();
|
||||
ProcessFormService = new();
|
||||
StatusFormService = new();
|
||||
}
|
||||
|
||||
public static void HideWaitForm()
|
||||
/// <summary>
|
||||
/// 显示等待提示窗
|
||||
/// </summary>
|
||||
/// <param name="owner"></param>
|
||||
/// <param name="size"></param>
|
||||
public static void ShowProcessForm(this Form owner, int size = 200)
|
||||
{
|
||||
if (!IsRun) return;
|
||||
Instance.CloseForm();
|
||||
IsRun = false;
|
||||
if (ProcessFormService.IsRun) return;
|
||||
ProcessFormService.CreateForm(size);
|
||||
}
|
||||
|
||||
public static void SetDescription(string desc)
|
||||
internal static bool ProcessFormServiceClose;
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏等待提示窗
|
||||
/// </summary>
|
||||
public static void HideProcessForm(this Form owner)
|
||||
{
|
||||
if (!IsRun) return;
|
||||
Instance.SetFormDescription(desc);
|
||||
ProcessFormServiceClose = true;
|
||||
}
|
||||
|
||||
private static UIWaitFormService _instance;
|
||||
private static readonly object syncLock = new object();
|
||||
|
||||
private static UIWaitFormService Instance
|
||||
/// <summary>
|
||||
/// 显示等待提示窗
|
||||
/// </summary>
|
||||
/// <param name="desc">描述文字</param>
|
||||
public static void ShowWaitForm(this Form owner, string desc = "系统正在处理中,请稍候...")
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
lock (syncLock)
|
||||
{
|
||||
_instance = new UIWaitFormService();
|
||||
}
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
if (WaitFormService.IsRun) return;
|
||||
WaitFormService.CreateForm(desc);
|
||||
}
|
||||
|
||||
private Thread thread;
|
||||
internal static bool WaitFormServiceClose;
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏等待提示窗
|
||||
/// </summary>
|
||||
public static void HideWaitForm(this Form owner)
|
||||
{
|
||||
WaitFormServiceClose = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置等待提示窗描述文字
|
||||
/// </summary>
|
||||
/// <param name="desc">描述文字</param>
|
||||
public static void SetWaitFormDescription(this Form owner, string desc)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public class UIWaitFormService : UIFormService
|
||||
{
|
||||
private UIWaitForm form;
|
||||
|
||||
private void CreateForm(string desc)
|
||||
public void CreateForm(string desc)
|
||||
{
|
||||
CloseForm();
|
||||
thread = new Thread(delegate ()
|
||||
{
|
||||
form = new UIWaitForm(desc);
|
||||
@ -61,73 +131,27 @@ namespace Sunny.UI
|
||||
if (IsRun) Application.Run(form);
|
||||
});
|
||||
|
||||
if (IsRun)
|
||||
thread.Start();
|
||||
else
|
||||
CloseForm();
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
private void CloseForm()
|
||||
{
|
||||
if (form != null) form.NeedClose = true;
|
||||
}
|
||||
|
||||
private void SetFormDescription(string desc)
|
||||
public void SetDescription(string desc)
|
||||
{
|
||||
try
|
||||
{
|
||||
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 void CreateForm(int size = 200)
|
||||
public void CreateForm(int size = 200)
|
||||
{
|
||||
CloseForm();
|
||||
thread = new Thread(delegate ()
|
||||
{
|
||||
form = new UIProcessIndicatorForm();
|
||||
@ -136,123 +160,49 @@ namespace Sunny.UI
|
||||
form.TopMost = true;
|
||||
form.Render();
|
||||
Application.Run(form);
|
||||
IsRun = false;
|
||||
});
|
||||
|
||||
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 void CreateForm(int max, string desc, int decimalCount = 1)
|
||||
public void CreateForm(int max, string desc, int decimalCount = 1)
|
||||
{
|
||||
CloseForm();
|
||||
thread = new Thread(delegate ()
|
||||
{
|
||||
form = new UIStatusForm(max, desc, decimalCount);
|
||||
form.ShowInTaskbar = false;
|
||||
form.TopMost = true;
|
||||
form.Render();
|
||||
form.VisibleChanged += WaitForm_VisibleChanged;
|
||||
Application.Run(form);
|
||||
IsRun = false;
|
||||
});
|
||||
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
private void WaitForm_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!form.Visible)
|
||||
{
|
||||
form.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseForm()
|
||||
{
|
||||
form?.StepIt(form.Maximum);
|
||||
}
|
||||
|
||||
private void SetFormDescription(string desc)
|
||||
public void SetFormDescription(string desc)
|
||||
{
|
||||
try
|
||||
{
|
||||
form?.SetDescription(desc);
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
private void SetFormStepIt()
|
||||
public void SetFormStepIt()
|
||||
{
|
||||
try
|
||||
{
|
||||
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>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.uiProgressIndicator1 = new Sunny.UI.UIProgressIndicator();
|
||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||
this.SuspendLayout();
|
||||
components = new System.ComponentModel.Container();
|
||||
uiProgressIndicator1 = new UIProgressIndicator();
|
||||
timer1 = new System.Windows.Forms.Timer(components);
|
||||
SuspendLayout();
|
||||
//
|
||||
// uiProgressIndicator1
|
||||
//
|
||||
this.uiProgressIndicator1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.uiProgressIndicator1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.uiProgressIndicator1.Location = new System.Drawing.Point(5, 5);
|
||||
this.uiProgressIndicator1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiProgressIndicator1.Name = "uiProgressIndicator1";
|
||||
this.uiProgressIndicator1.Size = new System.Drawing.Size(190, 190);
|
||||
this.uiProgressIndicator1.TabIndex = 0;
|
||||
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);
|
||||
uiProgressIndicator1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
uiProgressIndicator1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
uiProgressIndicator1.Location = new System.Drawing.Point(5, 5);
|
||||
uiProgressIndicator1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
uiProgressIndicator1.Name = "uiProgressIndicator1";
|
||||
uiProgressIndicator1.Size = new System.Drawing.Size(190, 190);
|
||||
uiProgressIndicator1.TabIndex = 0;
|
||||
uiProgressIndicator1.Text = "uiProgressIndicator1";
|
||||
uiProgressIndicator1.Tick += uiProgressIndicator1_Tick;
|
||||
//
|
||||
// UIProcessIndicatorForm
|
||||
//
|
||||
this.AllowShowTitle = false;
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(200, 200);
|
||||
this.Controls.Add(this.uiProgressIndicator1);
|
||||
this.Name = "UIProcessIndicatorForm";
|
||||
this.Padding = new System.Windows.Forms.Padding(2, 0, 2, 2);
|
||||
this.ShowTitle = false;
|
||||
this.Text = "UIProcessIndicatorForm";
|
||||
this.ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 800, 450);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
AllowShowTitle = false;
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
ClientSize = new System.Drawing.Size(200, 200);
|
||||
Controls.Add(uiProgressIndicator1);
|
||||
Name = "UIProcessIndicatorForm";
|
||||
Padding = new System.Windows.Forms.Padding(2, 0, 2, 2);
|
||||
ShowTitle = false;
|
||||
Text = "UIProcessIndicatorForm";
|
||||
ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 800, 450);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Sunny.UI
|
||||
namespace Sunny.UI
|
||||
{
|
||||
public partial class UIProcessIndicatorForm : UIForm
|
||||
{
|
||||
@ -11,16 +9,14 @@ namespace Sunny.UI
|
||||
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;
|
||||
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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<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>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.labelDescription = new Sunny.UI.UILabel();
|
||||
this.processBar = new Sunny.UI.UIProcessBar();
|
||||
this.SuspendLayout();
|
||||
components = new System.ComponentModel.Container();
|
||||
labelDescription = new UILabel();
|
||||
processBar = new UIProcessBar();
|
||||
timer1 = new System.Windows.Forms.Timer(components);
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelDescription
|
||||
//
|
||||
this.labelDescription.AutoSize = true;
|
||||
this.labelDescription.BackColor = System.Drawing.Color.Transparent;
|
||||
this.labelDescription.Font = new System.Drawing.Font("宋体", 12F);
|
||||
this.labelDescription.Location = new System.Drawing.Point(32, 55);
|
||||
this.labelDescription.Name = "labelDescription";
|
||||
this.labelDescription.Size = new System.Drawing.Size(178, 21);
|
||||
this.labelDescription.TabIndex = 1;
|
||||
this.labelDescription.Text = "系统正在处理中,请稍候...";
|
||||
this.labelDescription.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
labelDescription.AutoSize = true;
|
||||
labelDescription.BackColor = System.Drawing.Color.Transparent;
|
||||
labelDescription.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
labelDescription.Location = new System.Drawing.Point(32, 55);
|
||||
labelDescription.Name = "labelDescription";
|
||||
labelDescription.Size = new System.Drawing.Size(207, 16);
|
||||
labelDescription.TabIndex = 1;
|
||||
labelDescription.Text = "系统正在处理中,请稍候...";
|
||||
labelDescription.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// processBar
|
||||
//
|
||||
this.processBar.Font = new System.Drawing.Font("宋体", 12F);
|
||||
this.processBar.Location = new System.Drawing.Point(32, 91);
|
||||
this.processBar.MinimumSize = new System.Drawing.Size(70, 23);
|
||||
this.processBar.Name = "processBar";
|
||||
this.processBar.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
|
||||
this.processBar.Size = new System.Drawing.Size(409, 29);
|
||||
this.processBar.TabIndex = 3;
|
||||
this.processBar.Text = "0.0%";
|
||||
this.processBar.ValueChanged += new Sunny.UI.UIProcessBar.OnValueChanged(this.processBar_ValueChanged);
|
||||
processBar.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
processBar.Location = new System.Drawing.Point(32, 91);
|
||||
processBar.MinimumSize = new System.Drawing.Size(70, 23);
|
||||
processBar.Name = "processBar";
|
||||
processBar.RadiusSides = UICornerRadiusSides.None;
|
||||
processBar.Size = new System.Drawing.Size(409, 29);
|
||||
processBar.TabIndex = 3;
|
||||
processBar.Text = "0.0%";
|
||||
processBar.ValueChanged += processBar_ValueChanged;
|
||||
//
|
||||
// timer1
|
||||
//
|
||||
timer1.Tick += timer1_Tick;
|
||||
//
|
||||
// UIStatusForm
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(473, 153);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.processBar);
|
||||
this.Controls.Add(this.labelDescription);
|
||||
this.IsForbidAltF4 = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "UIStatusForm";
|
||||
this.Text = "提示";
|
||||
this.TopMost = true;
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
ClientSize = new System.Drawing.Size(473, 153);
|
||||
ControlBox = false;
|
||||
Controls.Add(processBar);
|
||||
Controls.Add(labelDescription);
|
||||
IsForbidAltF4 = true;
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "UIStatusForm";
|
||||
Text = "提示";
|
||||
TopMost = true;
|
||||
ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 473, 153);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private UILabel labelDescription;
|
||||
private UIProcessBar processBar;
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@ namespace Sunny.UI
|
||||
InitializeComponent();
|
||||
Text = UILocalize.InfoTitle;
|
||||
Description = UILocalize.SystemProcessing;
|
||||
timer1.Start();
|
||||
}
|
||||
|
||||
public UIStatusForm(int max, string desc, int decimalPlaces = 1)
|
||||
@ -40,6 +41,7 @@ namespace Sunny.UI
|
||||
Description = desc;
|
||||
Value = 0;
|
||||
DecimalPlaces = decimalPlaces;
|
||||
timer1.Start();
|
||||
}
|
||||
|
||||
[DefaultValue(100)]
|
||||
@ -80,7 +82,7 @@ namespace Sunny.UI
|
||||
{
|
||||
if (MaxAutoHide && value == Maximum)
|
||||
{
|
||||
Hide();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,5 +136,15 @@ namespace Sunny.UI
|
||||
processBar.StepIt();
|
||||
}
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, System.EventArgs e)
|
||||
{
|
||||
if (UIFormServiceHelper.StatusFormServiceClose)
|
||||
{
|
||||
timer1.Stop();
|
||||
UIFormServiceHelper.StatusFormServiceClose = false;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
<?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
|
||||
|
||||
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>
|
||||
@ -26,36 +26,36 @@
|
||||
<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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
@ -117,4 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</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>
|
@ -19,8 +19,6 @@
|
||||
* 2020-10-13: V3.0.0 增加文件说明
|
||||
******************************************************************************/
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (NeedClose) Close();
|
||||
if (UIFormServiceHelper.WaitFormServiceClose)
|
||||
{
|
||||
UIFormServiceHelper.WaitFormServiceClose = false;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
@ -1113,88 +1112,6 @@ namespace Sunny.UI
|
||||
|
||||
#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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user