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 {