* UIProcessBar:可设置显示进度条小数个数
This commit is contained in:
parent
921311153f
commit
47d633531a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -45,7 +45,7 @@ namespace Sunny.UI.Demo
|
||||
|
||||
private void btnStatus2_Click(object sender, EventArgs e)
|
||||
{
|
||||
ShowStatusForm(100, "数据加载中......");
|
||||
ShowStatusForm(100, "数据加载中......", 0);
|
||||
for (int i = 0; i < 88; i++)
|
||||
{
|
||||
SystemEx.Delay(50);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -74,7 +74,7 @@ namespace Sunny.UI
|
||||
posValue = Math.Max(value, 0);
|
||||
posValue = Math.Min(posValue, maximum);
|
||||
processWidth = (int)(posValue * Width * 1.0 / Maximum);
|
||||
processText = (posValue * 100.0 / maximum).ToString("F1") + "%";
|
||||
processText = (posValue * 100.0 / maximum).ToString("F" + DecimalCount) + "%";
|
||||
ValueChanged?.Invoke(this, posValue);
|
||||
Invalidate();
|
||||
}
|
||||
@ -157,10 +157,18 @@ namespace Sunny.UI
|
||||
image?.Dispose();
|
||||
image = null;
|
||||
processWidth = (int)(posValue * Width * 1.0 / Maximum);
|
||||
Text = (posValue * 100.0 / maximum).ToString("F1") + "%";
|
||||
Text = (posValue * 100.0 / maximum).ToString("F" + DecimalCount) + "%";
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private int decimalCount = 1;
|
||||
|
||||
public int DecimalCount
|
||||
{
|
||||
get => decimalCount;
|
||||
set => decimalCount = Math.Max(value, 0);
|
||||
}
|
||||
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
|
@ -1478,14 +1478,16 @@ namespace Sunny.UI
|
||||
#endregion 拉拽调整窗体大小
|
||||
|
||||
#region 一些辅助窗口
|
||||
|
||||
/// <summary>
|
||||
/// 显示进度提示窗
|
||||
/// </summary>
|
||||
/// <param name="desc">描述文字</param>
|
||||
/// <param name="maximum">最大进度值</param>
|
||||
public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...")
|
||||
/// <param name="decimalCount">显示进度条小数个数</param>
|
||||
public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...", int decimalCount = 1)
|
||||
{
|
||||
UIStatusFormService.ShowStatusForm(maximum, desc);
|
||||
UIStatusFormService.ShowStatusForm(maximum, desc, decimalCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -85,10 +85,10 @@ namespace Sunny.UI
|
||||
public class UIStatusFormService
|
||||
{
|
||||
private static bool IsRun;
|
||||
public static void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...")
|
||||
public static void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...", int decimalCount = 1)
|
||||
{
|
||||
if (IsRun) return;
|
||||
Instance.CreateForm(maximum, desc);
|
||||
Instance.CreateForm(maximum, desc, decimalCount);
|
||||
IsRun = true;
|
||||
}
|
||||
|
||||
@ -133,12 +133,12 @@ namespace Sunny.UI
|
||||
private Thread thread;
|
||||
private UIStatusForm form;
|
||||
|
||||
private void CreateForm(int max, string desc)
|
||||
private void CreateForm(int max, string desc, int decimalCount = 1)
|
||||
{
|
||||
CloseForm();
|
||||
thread = new Thread(delegate ()
|
||||
{
|
||||
form = new UIStatusForm(max, desc);
|
||||
form = new UIStatusForm(max, desc, decimalCount);
|
||||
form.VisibleChanged += WaitForm_VisibleChanged;
|
||||
Application.Run(form);
|
||||
IsRun = false;
|
||||
|
@ -32,13 +32,14 @@ namespace Sunny.UI
|
||||
Description = UILocalize.SystemProcessing;
|
||||
}
|
||||
|
||||
public UIStatusForm(int max, string desc)
|
||||
public UIStatusForm(int max, string desc, int decimalCount = 1)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Maximum = max;
|
||||
Description = desc;
|
||||
Value = 0;
|
||||
DecimalCount = decimalCount;
|
||||
}
|
||||
|
||||
[DefaultValue(100)]
|
||||
@ -98,6 +99,12 @@ namespace Sunny.UI
|
||||
set => labelDescription.Text = value;
|
||||
}
|
||||
|
||||
public int DecimalCount
|
||||
{
|
||||
get => processBar.DecimalCount;
|
||||
set => processBar.DecimalCount = value;
|
||||
}
|
||||
|
||||
private delegate void SetTextHandler(string text);
|
||||
|
||||
public void SetDescription(string text)
|
||||
|
@ -298,14 +298,16 @@ namespace Sunny.UI
|
||||
}
|
||||
|
||||
#region 一些辅助窗口
|
||||
|
||||
/// <summary>
|
||||
/// 显示进度提示窗
|
||||
/// </summary>
|
||||
/// <param name="desc">描述文字</param>
|
||||
/// <param name="maximum">最大进度值</param>
|
||||
public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...")
|
||||
/// <param name="decimalCount">显示进度条小数个数</param>
|
||||
public void ShowStatusForm(int maximum = 100, string desc = "系统正在处理中,请稍候...", int decimalCount = 1)
|
||||
{
|
||||
UIStatusFormService.ShowStatusForm(maximum, desc);
|
||||
UIStatusFormService.ShowStatusForm(maximum, desc, decimalCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user