* UIProcessBar:修改最小高度,可绘制极细的进度条

This commit is contained in:
Sunny 2020-12-24 21:47:19 +08:00
parent 01a043ffb9
commit c96db8d21e
5 changed files with 29 additions and 12 deletions

Binary file not shown.

Binary file not shown.

View File

@ -56,11 +56,13 @@
this.uiLabel2 = new Sunny.UI.UILabel(); this.uiLabel2 = new Sunny.UI.UILabel();
this.uiLabel3 = new Sunny.UI.UILabel(); this.uiLabel3 = new Sunny.UI.UILabel();
this.uiToolTip1 = new Sunny.UI.UIToolTip(this.components); this.uiToolTip1 = new Sunny.UI.UIToolTip(this.components);
this.uiProcessBar2 = new Sunny.UI.UIProcessBar();
this.PagePanel.SuspendLayout(); this.PagePanel.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// PagePanel // PagePanel
// //
this.PagePanel.Controls.Add(this.uiProcessBar2);
this.PagePanel.Controls.Add(this.uiLabel3); this.PagePanel.Controls.Add(this.uiLabel3);
this.PagePanel.Controls.Add(this.uiLabel2); this.PagePanel.Controls.Add(this.uiLabel2);
this.PagePanel.Controls.Add(this.uiLabel1); this.PagePanel.Controls.Add(this.uiLabel1);
@ -141,11 +143,12 @@
// //
this.uiProcessBar1.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiProcessBar1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiProcessBar1.Location = new System.Drawing.Point(30, 136); this.uiProcessBar1.Location = new System.Drawing.Point(30, 136);
this.uiProcessBar1.MinimumSize = new System.Drawing.Size(70, 23); this.uiProcessBar1.MinimumSize = new System.Drawing.Size(70, 1);
this.uiProcessBar1.Name = "uiProcessBar1"; this.uiProcessBar1.Name = "uiProcessBar1";
this.uiProcessBar1.Size = new System.Drawing.Size(319, 29); this.uiProcessBar1.Size = new System.Drawing.Size(318, 29);
this.uiProcessBar1.TabIndex = 24; this.uiProcessBar1.TabIndex = 24;
this.uiProcessBar1.Text = "0.0%"; this.uiProcessBar1.Text = "50.0%";
this.uiProcessBar1.Value = 50;
// //
// uiLine3 // uiLine3
// //
@ -262,6 +265,7 @@
this.uiLedBulb4.BlinkInterval = 500; this.uiLedBulb4.BlinkInterval = 500;
this.uiLedBulb4.Location = new System.Drawing.Point(507, 52); this.uiLedBulb4.Location = new System.Drawing.Point(507, 52);
this.uiLedBulb4.Name = "uiLedBulb4"; this.uiLedBulb4.Name = "uiLedBulb4";
this.uiLedBulb4.On = false;
this.uiLedBulb4.Size = new System.Drawing.Size(32, 32); this.uiLedBulb4.Size = new System.Drawing.Size(32, 32);
this.uiLedBulb4.TabIndex = 41; this.uiLedBulb4.TabIndex = 41;
this.uiLedBulb4.Text = "uiLedBulb4"; this.uiLedBulb4.Text = "uiLedBulb4";
@ -377,6 +381,17 @@
this.uiToolTip1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(239)))), ((int)(((byte)(239))))); this.uiToolTip1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(239)))), ((int)(((byte)(239)))));
this.uiToolTip1.OwnerDraw = true; this.uiToolTip1.OwnerDraw = true;
// //
// uiProcessBar2
//
this.uiProcessBar2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiProcessBar2.Location = new System.Drawing.Point(30, 171);
this.uiProcessBar2.MinimumSize = new System.Drawing.Size(70, 1);
this.uiProcessBar2.Name = "uiProcessBar2";
this.uiProcessBar2.Size = new System.Drawing.Size(318, 5);
this.uiProcessBar2.TabIndex = 56;
this.uiProcessBar2.Text = "50.0%";
this.uiProcessBar2.Value = 50;
//
// FOther // FOther
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
@ -419,5 +434,6 @@
private UILabel uiLabel2; private UILabel uiLabel2;
private UILabel uiLabel1; private UILabel uiLabel1;
private UIToolTip uiToolTip1; private UIToolTip uiToolTip1;
private UIProcessBar uiProcessBar2;
} }
} }

View File

@ -1,6 +1,4 @@
using System.Drawing; namespace Sunny.UI.Demo
namespace Sunny.UI.Demo
{ {
public partial class FOther : UITitlePage public partial class FOther : UITitlePage
{ {
@ -9,8 +7,8 @@ namespace Sunny.UI.Demo
InitializeComponent(); InitializeComponent();
uiToolTip1.SetToolTip(uiLabel2, "赠人玫瑰手有余香", "SunnyUI"); uiToolTip1.SetToolTip(uiLabel2, "赠人玫瑰手有余香", "SunnyUI");
uiToolTip1.SetToolTip(uiLabel3, "赠人玫瑰手有余香"+'\n'+ "赠人玫瑰手有余香", uiToolTip1.SetToolTip(uiLabel3, "赠人玫瑰手有余香" + '\n' + "赠人玫瑰手有余香",
"SunnyUI", 61530,32,UIColor.Green); "SunnyUI", 61530, 32, UIColor.Green);
} }
private int value; private int value;
@ -25,7 +23,7 @@ namespace Sunny.UI.Demo
{ {
value++; value++;
uiTrackBar1.Value = value; uiTrackBar1.Value = value;
uiProcessBar1.Value = value; uiProcessBar2.Value = uiProcessBar1.Value = value;
} }
} }
} }

View File

@ -41,7 +41,7 @@ namespace Sunny.UI
public UIProcessBar() public UIProcessBar()
{ {
MinimumSize = new Size(70, 23); MinimumSize = new Size(70, 5);
Size = new Size(300, 29); Size = new Size(300, 29);
ShowText = false; ShowText = false;
@ -113,7 +113,10 @@ namespace Sunny.UI
{ {
base.OnPaint(e); base.OnPaint(e);
if (ShowValue) SizeF sf = e.Graphics.MeasureString(processText, Font);
bool canShow = Height > sf.Height + 4;
if (ShowValue && canShow)
{ {
e.Graphics.DrawString(processText, Font, foreColor, Size, Padding, TextAlign); e.Graphics.DrawString(processText, Font, foreColor, Size, Padding, TextAlign);
} }
@ -132,7 +135,7 @@ namespace Sunny.UI
g.SetHighQuality(); g.SetHighQuality();
g.FillRoundRectangle(rectColor, rect, Radius); g.FillRoundRectangle(rectColor, rect, Radius);
g.DrawRoundRectangle(rectColor, rect, Radius); g.DrawRoundRectangle(rectColor, rect, Radius);
if (ShowValue) if (ShowValue && canShow)
{ {
g.DrawString(processText, Font, fillColor, Size, Padding, TextAlign); g.DrawString(processText, Font, fillColor, Size, Padding, TextAlign);
} }