void SilverlightGraphicsCanvas_PointerPressed(DispatcherTimerTickEventArgs sender, PointerEventArgs e)
        {
            var handle = new IntPtr(e.Pointer.PointerId);
            //Debug.WriteLine (string.Format ("{0} PRESSED {1}", DateTime.Now, handle));

            var now = DateTime.Now;
            var pos = ToPointF(e.GetCurrentPoint(this));

            //
            // Look for double taps
            //
            var tapCount = 1;

            if (_lastDownTime.ContainsKey(handle) &&
                _lastBeganPosition.ContainsKey(handle)) {
                var dt = now - _lastDownTime[handle];

                if (dt.TotalSeconds < 0.5 && pos.DistanceTo(_lastBeganPosition[handle]) < DoubleClickMinDistance) {
                    tapCount++;
                }
            }

            //
            // TouchBegan
            //
            var touch = new NetfxCoreTouch {
                Handle = handle,
                Time = now,
                SuperCanvasLocation = ToPointF(e.GetCurrentPoint((UIElement)Parent)),
                CanvasLocation = pos,
                TapCount = tapCount,
                IsMoving = false,
            };
            touch.PreviousTime = touch.Time;
            touch.SuperCanvasPreviousLocation = touch.SuperCanvasLocation;
            touch.CanvasPreviousLocation = touch.CanvasLocation;

            _lastBeganPosition [handle] = pos;
            _lastDownTime[handle] = now;

            _activeTouches[handle] = touch;

            if (Content != null) {
                Content.TouchesBegan(new[] { touch });
            }
        }
Ejemplo n.º 2
0
        void SilverlightGraphicsCanvas_PointerPressed(DispatcherTimerTickEventArgs sender, PointerRoutedEventArgs e)
        {
            var handle = new IntPtr(e.Pointer.PointerId);
            //Debug.WriteLine (string.Format ("{0} PRESSED {1}", DateTime.Now, handle));

            var now = DateTime.Now;
            var pos = ToPointF(e.GetCurrentPoint(this));

            //
            // Look for double taps
            //
            var tapCount = 1;

            if (_lastDownTime.ContainsKey(handle) &&
                _lastBeganPosition.ContainsKey(handle)) {
                var dt = now - _lastDownTime[handle];

                if (dt.TotalSeconds < 0.5 && pos.DistanceTo(_lastBeganPosition[handle]) < DoubleClickMinDistance) {
                    tapCount++;
                }
            }

            //
            // TouchBegan
            //
            var touch = new NetfxCoreTouch {
                Handle = handle,
                Time = now,
                SuperCanvasLocation = ToPointF(e.GetCurrentPoint((UIElement)Parent)),
                CanvasLocation = pos,
                TapCount = tapCount,
                IsMoving = false,
            };
            touch.PreviousTime = touch.Time;
            touch.SuperCanvasPreviousLocation = touch.SuperCanvasLocation;
            touch.CanvasPreviousLocation = touch.CanvasLocation;

            _lastBeganPosition [handle] = pos;
            _lastDownTime[handle] = now;

            _activeTouches[handle] = touch;

            if (Content != null) {
                var keys = CanvasKeys.None;
                var ctrl = Windows.UI.Core.CoreWindow.GetForCurrentThread ().GetKeyState (Windows.System.VirtualKey.Control);
                var shift = Windows.UI.Core.CoreWindow.GetForCurrentThread ().GetKeyState (Windows.System.VirtualKey.Shift);
                if ((ctrl & Windows.UI.Core.CoreVirtualKeyStates.Down) != 0) {
                    keys = keys | CanvasKeys.Command;
                }
                if ((shift & Windows.UI.Core.CoreVirtualKeyStates.Down) != 0) {
                    keys = keys | CanvasKeys.Shift;
                }

                Content.TouchesBegan(new[] { touch }, keys);
            }
        }
        void SilverlightGraphicsCanvas_PointerPressed(DispatcherTimerTickEventArgs sender, PointerRoutedEventArgs e)
        {
            var handle = new IntPtr(e.Pointer.PointerId);
            //Debug.WriteLine (string.Format ("{0} PRESSED {1}", DateTime.Now, handle));

            var now = DateTime.Now;
            var pos = ToPointF(e.GetCurrentPoint(this));

            //
            // Look for double taps
            //
            var tapCount = 1;

            if (_lastDownTime.ContainsKey(handle) &&
                _lastBeganPosition.ContainsKey(handle))
            {
                var dt = now - _lastDownTime[handle];

                if (dt.TotalSeconds < 0.5 && pos.DistanceTo(_lastBeganPosition[handle]) < DoubleClickMinDistance)
                {
                    tapCount++;
                }
            }

            //
            // TouchBegan
            //
            var touch = new NetfxCoreTouch {
                Handle = handle,
                Time   = now,
                SuperCanvasLocation = ToPointF(e.GetCurrentPoint((UIElement)Parent)),
                CanvasLocation      = pos,
                TapCount            = tapCount,
                IsMoving            = false,
            };

            touch.PreviousTime = touch.Time;
            touch.SuperCanvasPreviousLocation = touch.SuperCanvasLocation;
            touch.CanvasPreviousLocation      = touch.CanvasLocation;

            _lastBeganPosition [handle] = pos;
            _lastDownTime[handle]       = now;

            _activeTouches[handle] = touch;

            if (Content != null)
            {
                var keys  = CanvasKeys.None;
                var ctrl  = Windows.UI.Core.CoreWindow.GetForCurrentThread().GetKeyState(Windows.System.VirtualKey.Control);
                var shift = Windows.UI.Core.CoreWindow.GetForCurrentThread().GetKeyState(Windows.System.VirtualKey.Shift);
                if ((ctrl & Windows.UI.Core.CoreVirtualKeyStates.Down) != 0)
                {
                    keys = keys | CanvasKeys.Command;
                }
                if ((shift & Windows.UI.Core.CoreVirtualKeyStates.Down) != 0)
                {
                    keys = keys | CanvasKeys.Shift;
                }

                Content.TouchesBegan(new[] { touch }, keys);
            }
        }