+ UICheckBoxGroup:增加全选、全不选、反选

This commit is contained in:
Sunny 2020-06-24 22:25:44 +08:00
parent d508e93218
commit d7621596be
8 changed files with 112 additions and 8 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -34,11 +34,17 @@
this.uiCheckBox4 = new Sunny.UI.UICheckBox();
this.uiCheckBox2 = new Sunny.UI.UICheckBox();
this.uiCheckBoxGroup1 = new Sunny.UI.UICheckBoxGroup();
this.uiButton1 = new Sunny.UI.UIButton();
this.uiButton2 = new Sunny.UI.UIButton();
this.uiButton3 = new Sunny.UI.UIButton();
this.PagePanel.SuspendLayout();
this.SuspendLayout();
//
// PagePanel
//
this.PagePanel.Controls.Add(this.uiButton3);
this.PagePanel.Controls.Add(this.uiButton2);
this.PagePanel.Controls.Add(this.uiButton1);
this.PagePanel.Controls.Add(this.uiCheckBoxGroup1);
this.PagePanel.Controls.Add(this.uiCheckBox2);
this.PagePanel.Controls.Add(this.uiCheckBox4);
@ -129,6 +135,39 @@
this.uiCheckBoxGroup1.Text = "UICheckBoxGroup";
this.uiCheckBoxGroup1.ValueChanged += new Sunny.UI.UICheckBoxGroup.OnValueChanged(this.uiCheckBoxGroup1_ValueChanged);
//
// uiButton1
//
this.uiButton1.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiButton1.Location = new System.Drawing.Point(30, 310);
this.uiButton1.Name = "uiButton1";
this.uiButton1.Size = new System.Drawing.Size(100, 35);
this.uiButton1.TabIndex = 42;
this.uiButton1.Text = "全选";
this.uiButton1.Click += new System.EventHandler(this.uiButton1_Click);
//
// uiButton2
//
this.uiButton2.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiButton2.Location = new System.Drawing.Point(136, 310);
this.uiButton2.Name = "uiButton2";
this.uiButton2.Size = new System.Drawing.Size(100, 35);
this.uiButton2.TabIndex = 43;
this.uiButton2.Text = "全不选";
this.uiButton2.Click += new System.EventHandler(this.uiButton2_Click);
//
// uiButton3
//
this.uiButton3.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton3.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiButton3.Location = new System.Drawing.Point(242, 310);
this.uiButton3.Name = "uiButton3";
this.uiButton3.Size = new System.Drawing.Size(100, 35);
this.uiButton3.TabIndex = 44;
this.uiButton3.Text = "反选";
this.uiButton3.Click += new System.EventHandler(this.uiButton3_Click);
//
// FCheckBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
@ -150,5 +189,8 @@
private UICheckBox uiCheckBox3;
private UICheckBox uiCheckBox2;
private UICheckBoxGroup uiCheckBoxGroup1;
private UIButton uiButton3;
private UIButton uiButton2;
private UIButton uiButton1;
}
}

View File

@ -1,4 +1,5 @@
using System.Text;
using System;
using System.Text;
using System.Windows.Forms;
namespace Sunny.UI.Demo
@ -10,11 +11,6 @@ namespace Sunny.UI.Demo
InitializeComponent();
}
private void uiRadioButtonGroup1_ValueChanged(object sender, int index, string text)
{
MessageBox.Show(index.ToString());
}
private void uiCheckBoxGroup1_ValueChanged(object sender, int index, string text, bool isChecked)
{
StringBuilder sb = new StringBuilder();
@ -25,7 +21,22 @@ namespace Sunny.UI.Demo
sb.Append(", ");
}
this.ShowInfoDialog("SelectedIndex: " + index + ", SelectedText: " + text + "\n" + sb.ToString());
this.ShowSuccessTip("SelectedIndex: " + index + ", SelectedText: " + text + "\n" + sb.ToString());
}
private void uiButton1_Click(object sender, System.EventArgs e)
{
uiCheckBoxGroup1.SelectAll();
}
private void uiButton2_Click(object sender, System.EventArgs e)
{
uiCheckBoxGroup1.UnSelectAll();
}
private void uiButton3_Click(object sender, System.EventArgs e)
{
uiCheckBoxGroup1.ReverseSelected();
}
}
}

View File

@ -139,7 +139,11 @@ namespace Sunny.UI
private void Box_ValueChanged(object sender, bool value)
{
UICheckBox checkBox = (UICheckBox)sender;
ValueChanged?.Invoke(this, checkBox.Tag.ToString().ToInt(), checkBox.Text, checkBox.Checked);
if (!multiChange)
{
ValueChanged?.Invoke(this, checkBox.Tag.ToString().ToInt(), checkBox.Text, checkBox.Checked);
}
}
[Browsable(false)]
@ -251,5 +255,49 @@ namespace Sunny.UI
box.Font = Font;
}
}
/// <summary>
/// 全部选择
/// </summary>
public void SelectAll()
{
multiChange = true;
foreach (var box in boxes)
{
box.Checked = true;
}
multiChange = false;
}
/// <summary>
/// 全部不选
/// </summary>
public void UnSelectAll()
{
multiChange = true;
foreach (var box in boxes)
{
box.Checked = false;
}
multiChange = false;
}
/// <summary>
/// 反转选择
/// </summary>
public void ReverseSelected()
{
multiChange = true;
foreach (var box in boxes)
{
box.Checked = !box.Checked;
}
multiChange = false;
}
private bool multiChange;
}
}

View File

@ -1,5 +1,8 @@
+ 增加; - 删除; * 修改
2020.06.24
+ UICheckBoxGroup增加全选、全不选、反选
2020.06.23
* UIButton增加ShowFocusLine可获得焦点并显示