Example #1
0
        void _updateLines()
        {
            int count = this._pointerLocations.Keys.Count;

            D.assert(this._pointerQueue.Count >= count);

            if (count < 2)
            {
                this._initialLine = this._currentLine;
            }
            else if (this._initialLine != null &&
                     this._initialLine.pointerStartId == this._pointerQueue[0] &&
                     this._initialLine.pointerEndId == this._pointerQueue[1])
            {
                this._currentLine = new _LineBetweenPointers(
                    pointerStartId: this._pointerQueue[0],
                    pointerStartLocation: this._pointerLocations[this._pointerQueue[0]],
                    pointerEndId: this._pointerQueue[1],
                    pointerEndLocation: this._pointerLocations[this._pointerQueue[1]]
                    );
            }
            else
            {
                this._initialLine = new _LineBetweenPointers(
                    pointerStartId: this._pointerQueue[0],
                    pointerStartLocation: this._pointerLocations[this._pointerQueue[0]],
                    pointerEndId: this._pointerQueue[1],
                    pointerEndLocation: this._pointerLocations[this._pointerQueue[1]]
                    );
                this._currentLine = null;
            }
        }
Example #2
0
        void _updateLines()
        {
            int count = _pointerLocations.Keys.Count;

            D.assert(_pointerQueue.Count >= count);

            if (count < 2)
            {
                _initialLine = _currentLine;
            }
            else if (_initialLine != null &&
                     _initialLine.pointerStartId == _pointerQueue[0] &&
                     _initialLine.pointerEndId == _pointerQueue[1])
            {
                _currentLine = new _LineBetweenPointers(
                    pointerStartId: _pointerQueue[0],
                    pointerStartLocation: _pointerLocations[_pointerQueue[0]],
                    pointerEndId: _pointerQueue[1],
                    pointerEndLocation: _pointerLocations[_pointerQueue[1]]
                    );
            }
            else
            {
                _initialLine = new _LineBetweenPointers(
                    pointerStartId: _pointerQueue[0],
                    pointerStartLocation: _pointerLocations[_pointerQueue[0]],
                    pointerEndId: _pointerQueue[1],
                    pointerEndLocation: _pointerLocations[_pointerQueue[1]]
                    );
                _currentLine = null;
            }
        }
Example #3
0
        bool _reconfigure(int pointer)
        {
            this._initialFocalPoint     = this._currentFocalPoint;
            this._initialSpan           = this._currentSpan;
            this._initialLine           = this._currentLine;
            this._initialHorizontalSpan = this._currentHorizontalSpan;
            this._initialVerticalSpan   = this._currentVerticalSpan;
            if (this._state == _ScaleState.started)
            {
                if (this.onEnd != null)
                {
                    VelocityTracker tracker = this._velocityTrackers[pointer];
                    D.assert(tracker != null);

                    Velocity velocity = tracker.getVelocity();
                    if (_ScaleGestureUtils._isFlingGesture(velocity))
                    {
                        Offset pixelsPerSecond = velocity.pixelsPerSecond;
                        if (pixelsPerSecond.distanceSquared >
                            Constants.kMaxFlingVelocity * Constants.kMaxFlingVelocity)
                        {
                            velocity = new Velocity(
                                pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) *
                                Constants.kMaxFlingVelocity);
                        }

                        this.invokeCallback <object>("onEnd", () => {
                            this.onEnd(new ScaleEndDetails(velocity: velocity));
                            return(null);
                        });
                    }
                    else
                    {
                        this.invokeCallback <object>("onEnd", () => {
                            this.onEnd(new ScaleEndDetails(velocity: Velocity.zero));
                            return(null);
                        });
                    }
                }

                this._state = _ScaleState.accepted;
                return(false);
            }

            return(true);
        }