Пример #1
0
        /// <summary>
        /// Manages the listener logic
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            var touchCollection = TouchPanel.GetState();

            foreach (var touchLocation in touchCollection)
            {
                switch (touchLocation.State)
                {
                case TouchLocationState.Pressed:
                    TouchStarted?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Moved:
                    TouchMoved?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Released:
                    TouchEnded?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Invalid:
                    TouchCancelled?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation));
                    break;
                }
            }
        }
Пример #2
0
        public override void Update(GameTime gameTime)
        {
            var touchCollection = TouchPanel.GetState();

            foreach (var touchLocation in touchCollection)
            {
                switch (touchLocation.State)
                {
                case TouchLocationState.Pressed:
                    TouchStarted?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Moved:
                    TouchMoved?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Released:
                    TouchEnded?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Invalid:
                    TouchCancelled?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;
                }
            }
        }
        public override void TouchesEnded(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            var touch = touches.AnyObject as UITouch;

            if (touch != null)
            {
                TouchEnded?.Invoke(this, touch);
            }
        }
Пример #4
0
        /// <summary>
        /// Called, when mouse/finger/pen anymore click/touch map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        /// <param name="releasedPoint">Released point, which was touched before</param>
        private bool OnTouchEnd(List <Geometries.Point> touchPoints, Geometries.Point releasedPoint)
        {
            var args = new TouchedEventArgs(touchPoints);

            TouchEnded?.Invoke(this, args);

            // Last touch released
            if (touchPoints.Count == 0)
            {
                _mode = TouchMode.None;
                _map.RefreshData(_viewport.Extent, _viewport.Resolution, true);
            }

            return(args.Handled);
        }
Пример #5
0
        /// <summary>
        /// Called, when mouse/finger/pen anymore click/touch map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        /// <param name="releasedPoint">Released point, which was touched before</param>
        private bool OnTouchEnd(List <Geometries.Point> touchPoints, Geometries.Point releasedPoint)
        {
            var args = new TouchedEventArgs(touchPoints);

            TouchEnded?.Invoke(this, args);

            // Last touch released
            if (touchPoints.Count == 0)
            {
                InvalidateCanvas();
                _mode = TouchMode.None;
                _map.ViewChanged(true);
            }

            return(args.Handled);
        }
Пример #6
0
 public void StopTouchCapture()
 {
     EnsureNotDisposed();
     if (!_acquired)
     {
         return;
     }
     _device.OnPacket -= OnDevicePacket;
     _device.Unacquire();
     _acquired = false;
     if (_touching)
     {
         TouchEnded?.Invoke(this, EventArgs.Empty);
         _touching = false;
     }
 }
Пример #7
0
        private void TouchEnds(Touch touch, int index)
        {
            if (_touches.ContainsKey(index))
            {
                var endPosition = touch.position;
                var totalDelta  = endPosition - _touches[index];
                if (TouchEnded != null)
                {
                    TouchEnded.Invoke(totalDelta);
                    if (_touchParticles != null)
                    {
                        var normalizedDelta = totalDelta.normalized;
                        _touchParticles.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(endPosition.x, endPosition.y, 0f) + Vector3.up * 11f);
                        _touchParticles.transform.LookAt(_touchParticles.transform.position + new Vector3(normalizedDelta.x, 0, normalizedDelta.y));

                        _touchParticles.Emit(52);
                    }
                }
            }
        }
Пример #8
0
        public override void Update(GameTime gameTime)
        {
            var touchCollection = TouchPanel.GetState();

            if (TouchPanel.IsGestureAvailable)
            {
                var gesture = TouchPanel.ReadGesture();
                if (gesture.GestureType == GestureType.Tap)
                {
                    int x = 0;
                }
                if (gesture.GestureType == GestureType.DoubleTap)
                {
                    int y = 0;
                }
            }

            foreach (var touchLocation in touchCollection)
            {
                switch (touchLocation.State)
                {
                case TouchLocationState.Pressed:
                    TouchStarted?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Moved:
                    TouchMoved?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Released:
                    TouchEnded?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;

                case TouchLocationState.Invalid:
                    TouchCancelled?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation));
                    break;
                }
            }
        }
Пример #9
0
 /// <summary>
 /// Protected overridable handler that raises TouchEnded event.
 /// </summary>
 protected virtual void OnTouchEnded(TouchEventArgs args)
 {
     TouchEnded?.Invoke(this, args);
 }
 public void OnTouchEnded(double positionX, double positionY)
 {
     TouchEnded?.Invoke(Content, new PositionEventArgs(positionX, positionY));
 }
Пример #11
0
 protected void SingleTouchEnded()
 {
     TouchEnded?.Invoke(FirstTouch);
 }
Пример #12
0
 protected virtual void OnTouchEnded(ITouchEventArgs e) =>
 TouchEnded?.Invoke(this, e);