+ UISignal: 增加信号强度显示控件
This commit is contained in:
parent
2693135d15
commit
6aa7b06cf9
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
97
SunnyUI.Demo/Controls/FOther.Designer.cs
generated
97
SunnyUI.Demo/Controls/FOther.Designer.cs
generated
@ -47,11 +47,25 @@
|
||||
this.uiLabel2 = new Sunny.UI.UILabel();
|
||||
this.uiLabel3 = new Sunny.UI.UILabel();
|
||||
this.uiToolTip1 = new Sunny.UI.UIToolTip(this.components);
|
||||
this.uiSignal1 = new Sunny.UI.UISignal();
|
||||
this.uiLine1 = new Sunny.UI.UILine();
|
||||
this.uiSignal2 = new Sunny.UI.UISignal();
|
||||
this.uiSignal3 = new Sunny.UI.UISignal();
|
||||
this.uiSignal4 = new Sunny.UI.UISignal();
|
||||
this.uiSignal5 = new Sunny.UI.UISignal();
|
||||
this.uiSignal6 = new Sunny.UI.UISignal();
|
||||
this.PagePanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PagePanel
|
||||
//
|
||||
this.PagePanel.Controls.Add(this.uiSignal6);
|
||||
this.PagePanel.Controls.Add(this.uiSignal5);
|
||||
this.PagePanel.Controls.Add(this.uiSignal4);
|
||||
this.PagePanel.Controls.Add(this.uiSignal3);
|
||||
this.PagePanel.Controls.Add(this.uiSignal2);
|
||||
this.PagePanel.Controls.Add(this.uiLine1);
|
||||
this.PagePanel.Controls.Add(this.uiSignal1);
|
||||
this.PagePanel.Controls.Add(this.uiLabel3);
|
||||
this.PagePanel.Controls.Add(this.uiLabel2);
|
||||
this.PagePanel.Controls.Add(this.uiLabel1);
|
||||
@ -282,6 +296,82 @@
|
||||
this.uiToolTip1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(239)))), ((int)(((byte)(239)))));
|
||||
this.uiToolTip1.OwnerDraw = true;
|
||||
//
|
||||
// uiSignal1
|
||||
//
|
||||
this.uiSignal1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiSignal1.Level = 0;
|
||||
this.uiSignal1.Location = new System.Drawing.Point(35, 246);
|
||||
this.uiSignal1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiSignal1.Name = "uiSignal1";
|
||||
this.uiSignal1.Size = new System.Drawing.Size(35, 35);
|
||||
this.uiSignal1.TabIndex = 56;
|
||||
this.uiSignal1.Text = "uiSignal1";
|
||||
//
|
||||
// uiLine1
|
||||
//
|
||||
this.uiLine1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLine1.Location = new System.Drawing.Point(30, 220);
|
||||
this.uiLine1.MinimumSize = new System.Drawing.Size(16, 16);
|
||||
this.uiLine1.Name = "uiLine1";
|
||||
this.uiLine1.Size = new System.Drawing.Size(319, 20);
|
||||
this.uiLine1.TabIndex = 57;
|
||||
this.uiLine1.Text = "UISignal";
|
||||
this.uiLine1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// uiSignal2
|
||||
//
|
||||
this.uiSignal2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiSignal2.Level = 1;
|
||||
this.uiSignal2.Location = new System.Drawing.Point(76, 246);
|
||||
this.uiSignal2.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiSignal2.Name = "uiSignal2";
|
||||
this.uiSignal2.Size = new System.Drawing.Size(35, 35);
|
||||
this.uiSignal2.TabIndex = 58;
|
||||
this.uiSignal2.Text = "uiSignal2";
|
||||
//
|
||||
// uiSignal3
|
||||
//
|
||||
this.uiSignal3.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiSignal3.Level = 2;
|
||||
this.uiSignal3.Location = new System.Drawing.Point(117, 246);
|
||||
this.uiSignal3.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiSignal3.Name = "uiSignal3";
|
||||
this.uiSignal3.Size = new System.Drawing.Size(35, 35);
|
||||
this.uiSignal3.TabIndex = 59;
|
||||
this.uiSignal3.Text = "uiSignal3";
|
||||
//
|
||||
// uiSignal4
|
||||
//
|
||||
this.uiSignal4.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiSignal4.Level = 3;
|
||||
this.uiSignal4.Location = new System.Drawing.Point(158, 246);
|
||||
this.uiSignal4.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiSignal4.Name = "uiSignal4";
|
||||
this.uiSignal4.Size = new System.Drawing.Size(35, 35);
|
||||
this.uiSignal4.TabIndex = 60;
|
||||
this.uiSignal4.Text = "uiSignal4";
|
||||
//
|
||||
// uiSignal5
|
||||
//
|
||||
this.uiSignal5.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiSignal5.Level = 4;
|
||||
this.uiSignal5.Location = new System.Drawing.Point(199, 246);
|
||||
this.uiSignal5.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiSignal5.Name = "uiSignal5";
|
||||
this.uiSignal5.Size = new System.Drawing.Size(35, 35);
|
||||
this.uiSignal5.TabIndex = 61;
|
||||
this.uiSignal5.Text = "uiSignal5";
|
||||
//
|
||||
// uiSignal6
|
||||
//
|
||||
this.uiSignal6.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiSignal6.Location = new System.Drawing.Point(240, 246);
|
||||
this.uiSignal6.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiSignal6.Name = "uiSignal6";
|
||||
this.uiSignal6.Size = new System.Drawing.Size(35, 35);
|
||||
this.uiSignal6.TabIndex = 62;
|
||||
this.uiSignal6.Text = "uiSignal6";
|
||||
//
|
||||
// FOther
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
@ -314,5 +404,12 @@
|
||||
private UILabel uiLabel2;
|
||||
private UILabel uiLabel1;
|
||||
private UIToolTip uiToolTip1;
|
||||
private UISignal uiSignal6;
|
||||
private UISignal uiSignal5;
|
||||
private UISignal uiSignal4;
|
||||
private UISignal uiSignal3;
|
||||
private UISignal uiSignal2;
|
||||
private UILine uiLine1;
|
||||
private UISignal uiSignal1;
|
||||
}
|
||||
}
|
@ -120,9 +120,6 @@
|
||||
<metadata name="uiToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>107, 17</value>
|
||||
</metadata>
|
||||
<metadata name="uiToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>107, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>35</value>
|
||||
</metadata>
|
||||
|
@ -148,7 +148,7 @@ namespace Sunny.UI
|
||||
|
||||
if (Shape == UIShape.Circle)
|
||||
{
|
||||
Radius = ShowSize;
|
||||
if (Radius != ShowSize) Radius = ShowSize;
|
||||
GraphicsPath CirclePath = new GraphicsPath();
|
||||
CirclePath.AddEllipse(2, 2, ShowSize - 4, ShowSize - 4);
|
||||
g.Smooth();
|
||||
@ -181,7 +181,7 @@ namespace Sunny.UI
|
||||
|
||||
if (Shape == UIShape.Square)
|
||||
{
|
||||
Radius = 0;
|
||||
if (Radius != 0) Radius = 0;
|
||||
g.FillRoundRectangle(color, 2, 2, ShowSize - 4, ShowSize - 4, 5);
|
||||
|
||||
if (ShowCenterColor)
|
||||
|
147
SunnyUI/Controls/UISignal.cs
Normal file
147
SunnyUI/Controls/UISignal.cs
Normal file
@ -0,0 +1,147 @@
|
||||
/******************************************************************************
|
||||
* SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。
|
||||
* CopyRight (C) 2012-2021 ShenYongHua(沈永华).
|
||||
* QQ群:56829229 QQ:17612584 EMail:SunnyUI@QQ.Com
|
||||
*
|
||||
* Blog: https://www.cnblogs.com/yhuse
|
||||
* Gitee: https://gitee.com/yhuse/SunnyUI
|
||||
* GitHub: https://github.com/yhuse/SunnyUI
|
||||
*
|
||||
* SunnyUI.dll can be used for free under the GPL-3.0 license.
|
||||
* If you use this code, please keep this note.
|
||||
* 如果您使用此代码,请保留此说明。
|
||||
******************************************************************************
|
||||
* 文件名称: UISignal.cs
|
||||
* 文件说明: 信号强度显示
|
||||
* 当前版本: V3.0
|
||||
* 创建日期: 2021-06-19
|
||||
*
|
||||
* 2021-06-19: V3.0.4 增加文件说明
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
[DefaultEvent("Click")]
|
||||
[DefaultProperty("Level")]
|
||||
[ToolboxItem(true)]
|
||||
public class UISignal : UIControl
|
||||
{
|
||||
public UISignal()
|
||||
{
|
||||
SetStyleFlags(true, false);
|
||||
Width = Height = 35;
|
||||
ShowText = ShowRect = false;
|
||||
}
|
||||
|
||||
private int lineWidth = 3;
|
||||
|
||||
[DefaultValue(3)]
|
||||
[Description("线宽"), Category("SunnyUI")]
|
||||
public int LineWidth
|
||||
{
|
||||
get => lineWidth;
|
||||
set
|
||||
{
|
||||
lineWidth = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private int lineInterval = 2;
|
||||
|
||||
[DefaultValue(2)]
|
||||
[Description("线间隔"), Category("SunnyUI")]
|
||||
public int LineInterval
|
||||
{
|
||||
get => lineInterval;
|
||||
set
|
||||
{
|
||||
lineInterval = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private int lineHeight = 5;
|
||||
|
||||
[DefaultValue(5)]
|
||||
[Description("线高"), Category("SunnyUI")]
|
||||
public int LineHeight
|
||||
{
|
||||
get => lineHeight;
|
||||
set
|
||||
{
|
||||
lineHeight = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private int level = 5;
|
||||
|
||||
[DefaultValue(5)]
|
||||
[Description("线高"), Category("SunnyUI")]
|
||||
public int Level
|
||||
{
|
||||
get => level;
|
||||
set
|
||||
{
|
||||
level = Math.Max(0, value);
|
||||
level = Math.Min(5, level);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private Color onColor = Color.FromArgb(80, 160, 255);
|
||||
|
||||
[DefaultValue(typeof(Color), "80, 160, 255")]
|
||||
[Description("有信号颜色"), Category("SunnyUI")]
|
||||
public Color OnColor
|
||||
{
|
||||
get => onColor;
|
||||
set
|
||||
{
|
||||
onColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private Color offColor = Color.Silver;
|
||||
|
||||
[DefaultValue(typeof(Color), "Silver")]
|
||||
[Description("无信号颜色"), Category("SunnyUI")]
|
||||
public Color OffColor
|
||||
{
|
||||
get => offColor;
|
||||
set
|
||||
{
|
||||
offColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaintFill(Graphics g, GraphicsPath path)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
int left = (Width - lineWidth * 5 - lineInterval * 4) / 2;
|
||||
int top = (Height - lineHeight * 5) / 2;
|
||||
int bottom = top + lineHeight * 5;
|
||||
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
Color color = level >= i ? onColor : offColor;
|
||||
top = bottom - lineHeight * i;
|
||||
e.Graphics.FillRectangle(color, left, top, lineWidth, lineHeight * i);
|
||||
left += lineWidth + lineInterval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user