diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index 9457def1..ead4c1ab 100644 Binary files a/Bin/net40/SunnyUI.Demo.exe and b/Bin/net40/SunnyUI.Demo.exe differ diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index a8d2b818..931547b3 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Controls/FProcess.designer.cs b/SunnyUI.Demo/Controls/FProcess.designer.cs index 7683f676..b21af005 100644 --- a/SunnyUI.Demo/Controls/FProcess.designer.cs +++ b/SunnyUI.Demo/Controls/FProcess.designer.cs @@ -175,6 +175,7 @@ namespace Sunny.UI.Demo // uiRoundProcess2 // this.uiRoundProcess2.BackColor = System.Drawing.Color.Transparent; + this.uiRoundProcess2.DecimalPlaces = 0; this.uiRoundProcess2.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiRoundProcess2.ForeColor = System.Drawing.Color.White; this.uiRoundProcess2.Inner = 0; @@ -186,7 +187,7 @@ namespace Sunny.UI.Demo this.uiRoundProcess2.Style = Sunny.UI.UIStyle.Custom; this.uiRoundProcess2.StyleCustomMode = true; this.uiRoundProcess2.TabIndex = 93; - this.uiRoundProcess2.Text = "0.0%"; + this.uiRoundProcess2.Text = "0%"; // // uiLine9 // diff --git a/SunnyUI/Controls/UIProcessBar.cs b/SunnyUI/Controls/UIProcessBar.cs index 6b5f1001..3a34ddc1 100644 --- a/SunnyUI/Controls/UIProcessBar.cs +++ b/SunnyUI/Controls/UIProcessBar.cs @@ -135,7 +135,7 @@ namespace Sunny.UI processSize = posValue * Height * 1.0f / Maximum; if (ShowPercent) - processText = (posValue * 100.0 / maximum).ToString("F" + DecimalCount) + "%"; + processText = (posValue * 100.0 / maximum).ToString("F" + decimalCount) + "%"; else processText = posValue.ToString(); @@ -204,10 +204,19 @@ namespace Sunny.UI } } + [Description("显示文字小数位数"), Category("SunnyUI")] + [DefaultValue(1)] + public int DecimalPlaces + { + get => decimalCount; + set => decimalCount = Math.Max(value, 0); + } + private int decimalCount = 1; [Description("显示文字小数位数"), Category("SunnyUI")] - [DefaultValue(1)] + [DefaultValue(1), Browsable(false)] + [Obsolete("请用DecimalPlaces代替。")] public int DecimalCount { get => decimalCount; diff --git a/SunnyUI/Controls/UIRoundProcess.cs b/SunnyUI/Controls/UIRoundProcess.cs index cb81718d..863916ca 100644 --- a/SunnyUI/Controls/UIRoundProcess.cs +++ b/SunnyUI/Controls/UIRoundProcess.cs @@ -17,6 +17,7 @@ * 创建日期: 2021-04-08 * * 2021-04-08: V3.0.2 增加文件说明 + * 2021-10-18: V3.0.8 增加显示小数位数 ******************************************************************************/ using System; @@ -48,6 +49,20 @@ namespace Sunny.UI ShowRect = false; } + [Description("显示文字小数位数"), Category("SunnyUI")] + [DefaultValue(1)] + public int DecimalPlaces + { + get => decimalCount; + set + { + decimalCount = Math.Max(value, 0); + Text = (posValue * 100.0 / maximum).ToString("F" + decimalCount) + "%"; + } + } + + private int decimalCount = 1; + private int maximum = 100; [DefaultValue(100)] @@ -138,7 +153,7 @@ namespace Sunny.UI { posValue = Math.Max(value, 0); posValue = Math.Min(posValue, maximum); - Text = (posValue * 100.0 / maximum).ToString("F1") + "%"; + Text = (posValue * 100.0 / maximum).ToString("F" + decimalCount) + "%"; ValueChanged?.Invoke(this, posValue); Invalidate(); } diff --git a/SunnyUI/Forms/UIStatusForm.cs b/SunnyUI/Forms/UIStatusForm.cs index 0621b7bb..a2ec57d6 100644 --- a/SunnyUI/Forms/UIStatusForm.cs +++ b/SunnyUI/Forms/UIStatusForm.cs @@ -19,6 +19,7 @@ * 2020-05-05: V2.2.5 增加文件 ******************************************************************************/ +using System; using System.ComponentModel; namespace Sunny.UI @@ -32,14 +33,14 @@ namespace Sunny.UI Description = UILocalize.SystemProcessing; } - public UIStatusForm(int max, string desc, int decimalCount = 1) + public UIStatusForm(int max, string desc, int decimalPlaces = 1) { InitializeComponent(); Maximum = max; Description = desc; Value = 0; - DecimalCount = decimalCount; + DecimalPlaces = decimalPlaces; } [DefaultValue(100)] @@ -99,10 +100,18 @@ namespace Sunny.UI set => labelDescription.Text = value; } + public int DecimalPlaces + { + get => processBar.DecimalPlaces; + set => processBar.DecimalPlaces = value; + } + + + [Obsolete("请用DecimalPlaces代替。")] public int DecimalCount { - get => processBar.DecimalCount; - set => processBar.DecimalCount = value; + get => processBar.DecimalPlaces; + set => processBar.DecimalPlaces = value; } private delegate void SetTextHandler(string text);