* UIProgressIndicator: 增加Active属性,是否激活动态显示

+ UIProcessIndicatorForm: 增加等待窗体
This commit is contained in:
Sunny 2022-12-18 11:53:23 +08:00
parent 8306e3ffcb
commit c1df84826e
7 changed files with 272 additions and 1 deletions

View File

@ -19,6 +19,7 @@
* 2020-01-01: V2.2.0 * 2020-01-01: V2.2.0
* 2020-04-25: V2.2.4 * 2020-04-25: V2.2.4
* 2022-03-19: V3.1.1 * 2022-03-19: V3.1.1
* 2022-12-18: V3.3.0 Active属性
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -42,7 +43,6 @@ namespace Sunny.UI
timer = new Timer(); timer = new Timer();
timer.Interval = 200; timer.Interval = 200;
timer.Tick += timer_Tick; timer.Tick += timer_Tick;
timer.Start();
ShowText = false; ShowText = false;
ShowRect = false; ShowRect = false;
@ -50,6 +50,14 @@ namespace Sunny.UI
foreColor = UIStyles.Blue.ProgressIndicatorColor; foreColor = UIStyles.Blue.ProgressIndicatorColor;
} }
[Description("是否激活动态显示"), Category("SunnyUI")]
[DefaultValue(false)]
public bool Active
{
get => timer.Enabled;
set => timer.Enabled = value;
}
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); base.Dispose(disposing);

View File

@ -1874,6 +1874,23 @@ namespace Sunny.UI
UIWaitFormService.SetDescription(desc); UIWaitFormService.SetDescription(desc);
} }
/// <summary>
/// 显示等待提示窗
/// </summary>
/// <param name="size">大小</param>
public void ShowProcessForm(int size = 200)
{
UIProcessIndicatorFormService.ShowForm(size);
}
/// <summary>
/// 隐藏等待提示窗
/// </summary>
public void HideProcessForm()
{
UIProcessIndicatorFormService.HideForm();
}
/// <summary> /// <summary>
/// 正确信息提示框 /// 正确信息提示框
/// </summary> /// </summary>

View File

@ -85,6 +85,72 @@ namespace Sunny.UI
} }
} }
public class UIProcessIndicatorFormService
{
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)
{
CloseForm();
thread = new Thread(delegate ()
{
form = new UIProcessIndicatorForm();
form.Size = new System.Drawing.Size(size, size);
form.ShowInTaskbar = false;
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
{ {
private static bool IsRun; private static bool IsRun;

View File

@ -0,0 +1,74 @@
namespace Sunny.UI
{
partial class UIProcessIndicatorForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </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();
//
// 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);
//
// 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);
}
#endregion
private UIProgressIndicator uiProgressIndicator1;
private System.Windows.Forms.Timer timer1;
}
}

View File

@ -0,0 +1,26 @@
using System.ComponentModel;
namespace Sunny.UI
{
public partial class UIProcessIndicatorForm : UIForm
{
public UIProcessIndicatorForm()
{
InitializeComponent();
timer1.Start();
uiProgressIndicator1.Active = true;
}
private void timer1_Tick(object sender, System.EventArgs e)
{
if (NeedClose)
{
uiProgressIndicator1.Active = false;
Close();
}
}
[DefaultValue(false), Browsable(false)]
public bool NeedClose { get; set; }
}
}

View File

@ -0,0 +1,63 @@
<root>
<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">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<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>

View File

@ -1151,6 +1151,23 @@ namespace Sunny.UI
UIWaitFormService.HideWaitForm(); UIWaitFormService.HideWaitForm();
} }
/// <summary>
/// 显示等待提示窗
/// </summary>
/// <param name="size">大小</param>
public void ShowProcessForm(int size = 200)
{
UIProcessIndicatorFormService.ShowForm(size);
}
/// <summary>
/// 隐藏等待提示窗
/// </summary>
public void HideProcessForm()
{
UIProcessIndicatorFormService.HideForm();
}
/// <summary> /// <summary>
/// 设置等待提示窗描述文字 /// 设置等待提示窗描述文字
/// </summary> /// </summary>