コード例 #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);
        }
コード例 #3
0
        public bool Update(IRotaryBase control, Point location)
        {
            // for visualization purposes, this is where we are, even if we don't update now
            DragPoint = location;

            // calculate new drag vector and change versus vector where we last updated
            Vector dragVector = location - _centerPoint;

            if (!_initialDragAngle.HasValue)
            {
                // see if we are far enough from center to start dragging
                HandleAttachMode(dragVector);
                return(false);
            }

            // see if we dragged enough radially for update
            double currentAngle = Vector.AngleBetween(new Vector(0d, 1d), dragVector);
            double changeAngle  = Vector.AngleBetween(_lastUpdate, dragVector);

            if (Math.Abs(changeAngle) < _radialThreshold)
            {
                // Logger.Debug("radial interaction ignored change of {Degrees} against threshold of {Threshold} at {Location}", changeAngle,
                // _radialThreshold, dragPoint);
                return(false);
            }

            Logger.Debug(
                "radial interaction handle now at {Angle} after change of {Degrees} against threshold of {Threshold} at {Location}",
                currentAngle, changeAngle,
                _radialThreshold, location);

            // commit to this change
            _lastUpdate = dragVector;
            if (currentAngle - changeAngle < -180d)
            {
                // wrapped clockwise
                Logger.Debug(
                    "radial interaction wrapped clockwise to {AbsoluteDegrees} after change of {Degrees} against threshold of {Threshold} at {Location}",
                    currentAngle, changeAngle, _radialThreshold, location);
                _rotations += 360d;
            }
            else if (currentAngle - changeAngle > 180d)
            {
                // wrapped counter clockwise
                Logger.Debug(
                    "radial interaction wrapped counter-clockwise to {AbsoluteDegrees} after change of {Degrees} against threshold of {Threshold} at {Location}",
                    currentAngle, changeAngle, _radialThreshold, location);
                _rotations -= 360d;
            }

            // determine the angle the control should be at for our radial line to remain attached
            // to the control
            double newControlAngle = _initialControlAngle + currentAngle - _initialDragAngle.Value + _rotations;

            Logger.Debug(
                "radial interaction set new absolute position {AbsoluteDegrees} after change of {Degrees} against threshold of {Threshold} at {Location}",
                newControlAngle, changeAngle, _radialThreshold, location);
            control.ControlAngle = newControlAngle;

            return(true);
        }