コード例 #1
0
 protected virtual void OnHeld(ButtonHandlerEventArgs e)
 {
     if (!_initialized)
     {
         throw new InvalidOperationException($"Not initialized {_pin}");
     }
     Held?.Invoke(this, e);
 }
コード例 #2
0
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (IsPressed)
     {
         Held?.Invoke(this, EventArgs.Empty);                    // fire the event
         timer.Interval = 100;                                   // sebsequent events fire every tenth second
     }
     else
     {
         timer.Enabled  = false;                                                 // kill the timer, we're done
         timer.Interval = 500;                                                   // reset to startup delay
     }
 }
コード例 #3
0
 private void HoldButton_Pressed(object sender, EventArgs e)
 {
     IsPressed = true;                                   // note button is pressed
     Held?.Invoke(this, EventArgs.Empty);                // fire the event at least once at the start
     timer.Enabled = true;                               // start timer w/initial half-second startup delay
 }