From 43a766ec5aa605b871cac89fc4e0dd13aebac65f Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Mon, 23 Apr 2018 21:32:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=82=B9=E5=87=BB=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=B7=B1=E6=8E=A7=E5=88=B6Enable?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WinFormControl/UButton.cs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/WinFormControl/UButton.cs b/WinFormControl/UButton.cs index 4c67173..b4d4002 100644 --- a/WinFormControl/UButton.cs +++ b/WinFormControl/UButton.cs @@ -30,6 +30,12 @@ namespace WinFormControl [Browsable(true), Description("状态保持")] public bool WithStataHode { get; set; } + [Browsable(true), Description("组支持")] + public bool EnableGroup { get; set; } + + [Browsable(true), Description("自身控制Enable")] + public bool SelfControlEnable { get; set; } + private bool clicked; public bool AsClicked { @@ -59,6 +65,22 @@ namespace WinFormControl } } + void RemoveGroupClickState() + { + if (!EnableGroup || !WithStataHode) + return; + foreach (var ctl in Parent.Controls) + { + var btn = ctl as UButton; + if (btn == null) + continue; + if (btn.Text == this.Text) + continue; + if (btn.EnableGroup && btn.WithStataHode && btn.AsClicked) + btn.AsClicked = false; + } + } + protected override void OnMouseDown(MouseEventArgs mevent) { if (mevent.Button == MouseButtons.Left) @@ -77,8 +99,10 @@ namespace WinFormControl if (PlaySound) SoundPalyUtil.PlaySound(SoundType); base.OnClick(e); - this.Enabled = true; + if (!SelfControlEnable) + this.Enabled = true; AsClicked = !clicked; + RemoveGroupClickState(); } catch {