/// <summary> /// Raises the state changed event. /// </summary> /// <param name="e"> /// The button event arguments. /// </param> protected virtual void OnStateChanged(ButtonEventArgs e) { if (this.StateChanged != null) { this.StateChanged(this, e); if (e.IsPressed) { this.OnPressed(e); } if (e.IsReleased) { this.OnReleased(e); } } }
/// <summary> /// Raises the <see cref="ButtonBase.Released"/> event. /// </summary> /// <param name="e"> /// The event arguments. /// </param> protected virtual void OnReleased(ButtonEventArgs e) { if (this.Released != null) { this.Released(this, e); } if ((this._holdTimer != null) && (this._holdTimer.Enabled)) { this._holdTimer.Stop(); } }
/// <summary> /// Raises the <see cref="ButtonBase.Hold"/> event. /// </summary> /// <param name="e"> /// The event arguments. /// </param> protected virtual void OnHold(ButtonEventArgs e) { if (this.Hold != null) { this.Hold(this, e); } }
/// <summary> /// Raises the <see cref="ButtonBase.Pressed"/> event. /// </summary> /// <param name="e"> /// The event arguments. /// </param> protected virtual void OnPressed(ButtonEventArgs e) { if (this.Pressed != null) { this.Pressed(this, e); } if (this._holdTimer == null) { this._holdTimer = new Timer(2000); this._holdTimer.AutoReset = true; this._holdTimer.Elapsed += this.HoldTimer_Elapsed; } if (this._holdTimer.Enabled) { this._holdTimer.Stop(); } this._holdTimer.Start(); }