예제 #1
0
        public bool Update(IRotaryBase control, Point location)
        {
            double newAngle = GetAngle(_lastUpdateLocation, location);

            if (!(Math.Abs(newAngle) > _swipeThreshold))
            {
                // Logger.Debug("swipe interaction ignored change of {Degrees} against threshold of {Threshold} at {Location}", newAngle,
                // _swipeThreshold, location);
                return(false);
            }

            Logger.Debug(
                "swipe interaction pulsing rotary after change of {Degrees} against threshold of {Threshold} at {Location}",
                newAngle, _swipeThreshold, location);
            _lastUpdateLocation = location;
            control.Pulse(newAngle > 0 ? 1 : -1);
            return(true);
        }
예제 #2
0
        public bool Update(IRotaryBase control, Point location)
        {
            int currentTick = Environment.TickCount & int.MaxValue;
            int numPulses   = 0;

            if (_repeating && (currentTick < _lastPulse || currentTick - _lastPulse > _repeatRate))
            {
                numPulses += Pulses;
                _lastPulse = currentTick;
            }

            if (currentTick < _lastRepeat || currentTick - _lastRepeat > _repeatDelay)
            {
                if (_repeating && _repeatRate > 33)
                {
                    _repeatRate = _repeatRate / 2;
                    if (_repeatRate < 33)
                    {
                        _repeatRate = 33;
                    }
                }

                numPulses  += Pulses;
                _lastPulse  = currentTick;
                _lastRepeat = currentTick;
                _repeating  = true;
            }

            if (numPulses == 0)
            {
                return(false);
            }

            control.Pulse(numPulses);
            return(true);
        }