Browse Source

按钮点击 支持自己控制Enable属性。

master
yibo 7 years ago
parent
commit
43a766ec5a
1 changed files with 25 additions and 1 deletions
  1. +25
    -1
      WinFormControl/UButton.cs

+ 25
- 1
WinFormControl/UButton.cs View File

@ -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
{


Loading…
Cancel
Save