Exemple #1
0
        /// <summary>
        /// Update the mouse manager.
        /// </summary>
        public override void Update(bool isActive)
        {
            //clear out the taps & touches
            Clicks.Clear();
            Highlights.Clear();
            Drags.Clear();
            Drops.Clear();
            Flicks.Clear();
            Pinches.Clear();

            if (null != Pinch)
            {
                //reset the pinch delta
                Pinch.Delta = 0f;
            }

            if (isActive)
            {
                TouchCollection = TouchPanel.GetState();

                //get the new taps & touches
                GetGestures();
                GetTouches();
            }

            //Add the pinch event if there is an ongoing gesture
            if (null != Pinch)
            {
                Pinches.Add(new PinchEventArgs(Pinch.Delta));
            }
        }
Exemple #2
0
        /// <summary>
        /// Update the mouse manager.
        /// </summary>
        public override void Update(bool isActive)
        {
            //clear out the taps & touches
            Clicks.Clear();
            Highlights.Clear();
            Drags.Clear();
            Drops.Clear();
            Flicks.Clear();
            Pinches.Clear();
            Holds.Clear();

            if (null != Pinch)
            {
                //reset the pinch delta
                Pinch.Delta = 0f;
            }

            if (isActive && IsEnabled)
            {
                TouchCollection = TouchPanel.GetState();

                //get the new taps & touches
                GetGestures();
                GetTouches();
            }

            //Add the pinch event if there is an ongoing gesture
            if (null != Pinch)
            {
                if (Pinch.Finished)
                {
                    Pinches.Add(new PinchEventArgs(Pinch.First, Pinch.Second, Pinch.Delta)
                    {
                        Release = true
                    });
                    Pinch = null;
                }
                else
                {
                    Pinches.Add(new PinchEventArgs(Pinch.First, Pinch.Second, Pinch.Delta));
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// get all the current touches
        /// </summary>
        private void GetTouches()
        {
            //go though the points that are being touched
            foreach (var touch in TouchCollection)
            {
                var touchIndex = touch.Id % _numTouches;

                if (touch.State == TouchLocationState.Pressed)
                {
                    AddHighlightEvent(touch);

                    //set the drag operation, just in case
                    TouchStartPosition[touchIndex] = touch;
                }
                else if (touch.State == TouchLocationState.Moved)
                {
                    AddHighlightEvent(touch);

                    //Sometimes TryGetPreviousLocation can fail.
                    //Bail out early if this happened or if the last state didn't move
                    TouchLocation prevLoc;
                    if (!touch.TryGetPreviousLocation(out prevLoc) ||
                        prevLoc.State != TouchLocationState.Moved ||
                        TouchStartPosition[touchIndex].Id != touch.Id)
                    {
                        continue;
                    }

                    // get your delta
                    var delta = touch.Position - prevLoc.Position;

                    //fire off drag event
                    Drags.Add(new DragEventArgs()
                    {
                        Start   = ConvertCoordinate(TouchStartPosition[touchIndex].Position),
                        Current = ConvertCoordinate(touch.Position),
                        Delta   = (touch.Position - prevLoc.Position),
                        Button  = MouseButton.Left
                    });
                }
                else if (touch.State == TouchLocationState.Released)
                {
                    //Sometimes TryGetPreviousLocation can fail.
                    //Bail out early if this happened or if the last state didn't move
                    TouchLocation prevLoc;
                    if (!touch.TryGetPreviousLocation(out prevLoc) ||
                        prevLoc.State != TouchLocationState.Moved ||
                        TouchStartPosition[touchIndex].Id != touch.Id)
                    {
                        continue;
                    }

                    // get your delta
                    var dragStartPosition = ConvertCoordinate(TouchStartPosition[touchIndex].Position);
                    var touchPos          = ConvertCoordinate(touch.Position);
                    var delta             = touchPos - dragStartPosition;

                    // Usually you don't want to do something if the user drags 1 pixel.
                    if (delta.LengthSquared() < _dragDelta)
                    {
                        continue;
                    }

                    //fire off drop event
                    Drops.Add(new DropEventArgs()
                    {
                        Start  = dragStartPosition,
                        Drop   = touchPos,
                        Button = MouseButton.Left
                    });
                }
            }
        }
 public EditDragsView(MainViewModel mainVM, Drags drags)
 {
     InitializeComponent();
     DataContext = new EditDragsViewModel(mainVM, drags);
 }