* UIProcessBar: 修改不显示百分比时,显示数值

This commit is contained in:
Sunny 2021-08-14 21:51:38 +08:00
parent a427a71f1e
commit 4414b86b93
7 changed files with 2 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -319,7 +319,6 @@ namespace Sunny.UI.Demo
this.uiProcessBar3.MinimumSize = new System.Drawing.Size(70, 1); this.uiProcessBar3.MinimumSize = new System.Drawing.Size(70, 1);
this.uiProcessBar3.Name = "uiProcessBar3"; this.uiProcessBar3.Name = "uiProcessBar3";
this.uiProcessBar3.Size = new System.Drawing.Size(203, 169); this.uiProcessBar3.Size = new System.Drawing.Size(203, 169);
this.uiProcessBar3.Style = Sunny.UI.UIStyle.Custom;
this.uiProcessBar3.TabIndex = 103; this.uiProcessBar3.TabIndex = 103;
this.uiProcessBar3.Value = 50; this.uiProcessBar3.Value = 50;
// //

View File

@ -124,7 +124,7 @@ namespace Sunny.UI
base.OnPaint(e); base.OnPaint(e);
float processSize; float processSize;
string processText = "0.0%"; string processText;
if (Direction == UILine.LineDirection.Horizontal) if (Direction == UILine.LineDirection.Horizontal)
processSize = posValue * Width * 1.0f / Maximum; processSize = posValue * Width * 1.0f / Maximum;
@ -134,7 +134,7 @@ namespace Sunny.UI
if (ShowPercent) if (ShowPercent)
processText = (posValue * 100.0 / maximum).ToString("F" + DecimalCount) + "%"; processText = (posValue * 100.0 / maximum).ToString("F" + DecimalCount) + "%";
else else
processText = (posValue * 1.0 / maximum).ToString("F" + DecimalCount); processText = posValue.ToString();
SizeF sf = e.Graphics.MeasureString(processText, Font); SizeF sf = e.Graphics.MeasureString(processText, Font);
bool canShow = Height > sf.Height + 4; bool canShow = Height > sf.Height + 4;