protected override void OnClick(EventArgs e) { base.OnClick(e); EventArgs.Cancel = false; if (State == EnumButtonState.StateA) { if (_ClickAtStateA != null) { _ClickAtStateA(this, EventArgs); } } else { if (_ClickAtStateB != null) { _ClickAtStateB(this, EventArgs); } } if (!EventArgs.Cancel) { _State = (EnumButtonState)(1 - (int)State); } UpdateText(); }
/// <summary> /// 重置状态 /// </summary> /// <param name="State">目标状态</param> public void ResetState(EnumButtonState State) { this._State = State; UpdateText(); }