예제 #1
0
        private void OnButtonPress(object sender, PinValueChangedEventArgs pinValueChangedEventArgs)
        {
            //todo: extend this to support double click, on hold, etc

            if (pinValueChangedEventArgs.ChangeType == PinEventTypes.Falling)
            {
                pressedDown = DateTime.Now;
            }
            else
            {
                var e = new ButtonHandlerEventArgs()
                {
                    pin = _pin
                };

                var _holdTime = (DateTime.Now - pressedDown);
                if (_holdTime.Seconds > 1)
                {
                    OnHeld(e);
                }
                else
                {
                    OnClick(e);
                }
            }
        }
예제 #2
0
 protected virtual void OnHeld(ButtonHandlerEventArgs e)
 {
     if (!_initialized)
     {
         throw new InvalidOperationException($"Not initialized {_pin}");
     }
     Held?.Invoke(this, e);
 }