* 值切换事件增加了一些判断

This commit is contained in:
Sunny 2022-01-13 10:35:31 +08:00
parent 6fb3d45891
commit 1de997a47c
10 changed files with 41 additions and 44 deletions

Binary file not shown.

Binary file not shown.

View File

@ -271,7 +271,7 @@ namespace Sunny.UI.Demo.Properties {
}
/// <summary>
/// 查找类似 20220109 的本地化字符串。
/// 查找类似 20220113 的本地化字符串。
/// </summary>
internal static string BuildDate {
get {

View File

@ -155,7 +155,7 @@
<value>..\Resources\brescia.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="BuildDate" xml:space="preserve">
<value>20220109</value>
<value>20220113</value>
</data>
<data name="ChartDarkStyle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ChartDarkStyle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>

View File

@ -79,11 +79,14 @@ namespace Sunny.UI
}
protected override void ItemForm_ValueChanged(object sender, object value)
{
if (Value != (Color)value)
{
Value = (Color)value;
Invalidate();
ValueChanged?.Invoke(this, Value);
}
}
private readonly UIColorItem item = new UIColorItem();

View File

@ -97,11 +97,14 @@ namespace Sunny.UI
set
{
value = CheckMaxMin(value);
if (_value != value)
{
_value = value;
pnlValue.Text = _value.ToString();
ValueChanged?.Invoke(this, _value);
}
}
}
protected override void OnFontChanged(EventArgs e)
{

View File

@ -386,7 +386,6 @@ namespace Sunny.UI
this.b0.Cursor = System.Windows.Forms.Cursors.Hand;
this.b0.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b0.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.b0.IsScaled = false;
this.b0.Location = new System.Drawing.Point(3, 3);
this.b0.MinimumSize = new System.Drawing.Size(1, 1);
this.b0.Name = "b0";
@ -404,7 +403,6 @@ namespace Sunny.UI
//
this.b1.Cursor = System.Windows.Forms.Cursors.Hand;
this.b1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b1.IsScaled = false;
this.b1.Location = new System.Drawing.Point(81, 3);
this.b1.MinimumSize = new System.Drawing.Size(1, 1);
this.b1.Name = "b1";
@ -418,7 +416,6 @@ namespace Sunny.UI
//
this.b3.Cursor = System.Windows.Forms.Cursors.Hand;
this.b3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b3.IsScaled = false;
this.b3.Location = new System.Drawing.Point(145, 3);
this.b3.MinimumSize = new System.Drawing.Size(1, 1);
this.b3.Name = "b3";
@ -432,7 +429,6 @@ namespace Sunny.UI
//
this.b2.Cursor = System.Windows.Forms.Cursors.Hand;
this.b2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b2.IsScaled = false;
this.b2.Location = new System.Drawing.Point(113, 3);
this.b2.MinimumSize = new System.Drawing.Size(1, 1);
this.b2.Name = "b2";
@ -446,7 +442,6 @@ namespace Sunny.UI
//
this.b7.Cursor = System.Windows.Forms.Cursors.Hand;
this.b7.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b7.IsScaled = false;
this.b7.Location = new System.Drawing.Point(273, 3);
this.b7.MinimumSize = new System.Drawing.Size(1, 1);
this.b7.Name = "b7";
@ -460,7 +455,6 @@ namespace Sunny.UI
//
this.b6.Cursor = System.Windows.Forms.Cursors.Hand;
this.b6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b6.IsScaled = false;
this.b6.Location = new System.Drawing.Point(241, 3);
this.b6.MinimumSize = new System.Drawing.Size(1, 1);
this.b6.Name = "b6";
@ -474,7 +468,6 @@ namespace Sunny.UI
//
this.b5.Cursor = System.Windows.Forms.Cursors.Hand;
this.b5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b5.IsScaled = false;
this.b5.Location = new System.Drawing.Point(209, 3);
this.b5.MinimumSize = new System.Drawing.Size(1, 1);
this.b5.Name = "b5";
@ -488,7 +481,6 @@ namespace Sunny.UI
//
this.b4.Cursor = System.Windows.Forms.Cursors.Hand;
this.b4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b4.IsScaled = false;
this.b4.Location = new System.Drawing.Point(177, 3);
this.b4.MinimumSize = new System.Drawing.Size(1, 1);
this.b4.Name = "b4";
@ -502,7 +494,6 @@ namespace Sunny.UI
//
this.b15.Cursor = System.Windows.Forms.Cursors.Hand;
this.b15.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b15.IsScaled = false;
this.b15.Location = new System.Drawing.Point(529, 3);
this.b15.MinimumSize = new System.Drawing.Size(1, 1);
this.b15.Name = "b15";
@ -516,7 +507,6 @@ namespace Sunny.UI
//
this.b14.Cursor = System.Windows.Forms.Cursors.Hand;
this.b14.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b14.IsScaled = false;
this.b14.Location = new System.Drawing.Point(497, 3);
this.b14.MinimumSize = new System.Drawing.Size(1, 1);
this.b14.Name = "b14";
@ -530,7 +520,6 @@ namespace Sunny.UI
//
this.b13.Cursor = System.Windows.Forms.Cursors.Hand;
this.b13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b13.IsScaled = false;
this.b13.Location = new System.Drawing.Point(465, 3);
this.b13.MinimumSize = new System.Drawing.Size(1, 1);
this.b13.Name = "b13";
@ -544,7 +533,6 @@ namespace Sunny.UI
//
this.b12.Cursor = System.Windows.Forms.Cursors.Hand;
this.b12.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b12.IsScaled = false;
this.b12.Location = new System.Drawing.Point(433, 3);
this.b12.MinimumSize = new System.Drawing.Size(1, 1);
this.b12.Name = "b12";
@ -558,7 +546,6 @@ namespace Sunny.UI
//
this.b11.Cursor = System.Windows.Forms.Cursors.Hand;
this.b11.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b11.IsScaled = false;
this.b11.Location = new System.Drawing.Point(401, 3);
this.b11.MinimumSize = new System.Drawing.Size(1, 1);
this.b11.Name = "b11";
@ -572,7 +559,6 @@ namespace Sunny.UI
//
this.b10.Cursor = System.Windows.Forms.Cursors.Hand;
this.b10.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b10.IsScaled = false;
this.b10.Location = new System.Drawing.Point(369, 3);
this.b10.MinimumSize = new System.Drawing.Size(1, 1);
this.b10.Name = "b10";
@ -586,7 +572,6 @@ namespace Sunny.UI
//
this.b9.Cursor = System.Windows.Forms.Cursors.Hand;
this.b9.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b9.IsScaled = false;
this.b9.Location = new System.Drawing.Point(337, 3);
this.b9.MinimumSize = new System.Drawing.Size(1, 1);
this.b9.Name = "b9";
@ -600,7 +585,6 @@ namespace Sunny.UI
//
this.b8.Cursor = System.Windows.Forms.Cursors.Hand;
this.b8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b8.IsScaled = false;
this.b8.Location = new System.Drawing.Point(305, 3);
this.b8.MinimumSize = new System.Drawing.Size(1, 1);
this.b8.Name = "b8";
@ -615,7 +599,6 @@ namespace Sunny.UI
this.b16.Cursor = System.Windows.Forms.Cursors.Hand;
this.b16.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.b16.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.b16.IsScaled = false;
this.b16.Location = new System.Drawing.Point(561, 3);
this.b16.MinimumSize = new System.Drawing.Size(1, 1);
this.b16.Name = "b16";
@ -636,12 +619,13 @@ namespace Sunny.UI
this.p1.Controls.Add(this.btnSelect);
this.p1.Controls.Add(this.uiLabel2);
this.p1.Controls.Add(this.uiLabel1);
this.p1.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
this.p1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.p1.IsScaled = false;
this.p1.Location = new System.Drawing.Point(727, 3);
this.p1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.p1.MinimumSize = new System.Drawing.Size(1, 1);
this.p1.Name = "p1";
this.p1.Radius = 0;
this.p1.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
this.p1.Size = new System.Drawing.Size(216, 29);
this.p1.TabIndex = 17;
@ -654,10 +638,10 @@ namespace Sunny.UI
this.edtPage.ButtonSymbol = 61761;
this.edtPage.Cursor = System.Windows.Forms.Cursors.IBeam;
this.edtPage.DoubleValue = 10D;
this.edtPage.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
this.edtPage.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.edtPage.HasMinimum = true;
this.edtPage.IntValue = 10;
this.edtPage.IsScaled = false;
this.edtPage.Location = new System.Drawing.Point(28, 0);
this.edtPage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.edtPage.Maximum = 2147483647D;
@ -676,7 +660,6 @@ namespace Sunny.UI
//
this.btnSelect.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSelect.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.btnSelect.IsScaled = false;
this.btnSelect.Location = new System.Drawing.Point(111, 0);
this.btnSelect.MinimumSize = new System.Drawing.Size(1, 1);
this.btnSelect.Name = "btnSelect";
@ -691,10 +674,9 @@ namespace Sunny.UI
this.uiLabel2.AutoSize = true;
this.uiLabel2.BackColor = System.Drawing.Color.Transparent;
this.uiLabel2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.uiLabel2.IsScaled = false;
this.uiLabel2.Location = new System.Drawing.Point(81, 4);
this.uiLabel2.Name = "uiLabel2";
this.uiLabel2.Size = new System.Drawing.Size(33, 28);
this.uiLabel2.Size = new System.Drawing.Size(23, 20);
this.uiLabel2.TabIndex = 2;
this.uiLabel2.Text = "页";
this.uiLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@ -704,10 +686,9 @@ namespace Sunny.UI
this.uiLabel1.AutoSize = true;
this.uiLabel1.BackColor = System.Drawing.Color.Transparent;
this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.uiLabel1.IsScaled = false;
this.uiLabel1.Location = new System.Drawing.Point(5, 4);
this.uiLabel1.Name = "uiLabel1";
this.uiLabel1.Size = new System.Drawing.Size(33, 28);
this.uiLabel1.Size = new System.Drawing.Size(23, 20);
this.uiLabel1.TabIndex = 0;
this.uiLabel1.Text = "第";
this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@ -717,8 +698,8 @@ namespace Sunny.UI
this.cb1.DataSource = null;
this.cb1.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
this.cb1.FillColor = System.Drawing.Color.White;
this.cb1.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
this.cb1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.cb1.IsScaled = false;
this.cb1.Items.AddRange(new object[] {
"20条/页",
"50条/页",
@ -978,6 +959,9 @@ namespace Sunny.UI
private void p1_LocationChanged(object sender, EventArgs e)
{
cb1.Left = p1.Right;
PageLocationChanged?.Invoke(p1.Right, EventArgs.Empty);
}
public event EventHandler PageLocationChanged;
}
}

View File

@ -89,12 +89,16 @@ namespace Sunny.UI
get => posValue;
set
{
posValue = Math.Max(value, 0);
posValue = Math.Min(posValue, maximum);
value = Math.Max(value, 0);
value = Math.Min(value, maximum);
if (posValue != value)
{
posValue = value;
ValueChanged?.Invoke(this, posValue);
Invalidate();
}
}
}
private bool showValue = true;

View File

@ -151,13 +151,17 @@ namespace Sunny.UI
get => posValue;
set
{
posValue = Math.Max(value, 0);
posValue = Math.Min(posValue, maximum);
value = Math.Max(value, 0);
value = Math.Min(value, maximum);
if (posValue != value)
{
posValue = value;
Text = (posValue * 100.0 / maximum).ToString("F" + decimalCount) + "%";
ValueChanged?.Invoke(this, posValue);
Invalidate();
}
}
}
public delegate void OnValueChanged(object sender, int value);

View File

@ -125,10 +125,9 @@ namespace Sunny.UI
if (trackBarValue != v)
{
trackBarValue = v;
ValueChanged?.Invoke(this, EventArgs.Empty);
Invalidate();
}
ValueChanged?.Invoke(this, EventArgs.Empty);
}
}