Example #1
0
 internal protected override void Update(IEnumerable <Gesture> gestures)
 {
     if (state == State.Initial && Input.WasMousePressed(ButtonIndex))
     {
         state = State.Recognizing;
         MousePressPosition = Input.MousePosition;
         began.Raise();
     }
     if (state == State.Recognizing)
     {
         if (!Input.IsMousePressed(ButtonIndex))
         {
             ended.Raise();
             state = State.Initial;
         }
         else if ((MousePosition - MousePressPosition).SqrLength > DragThreshold.Sqr())
         {
             CancelOtherGestures(gestures);
             state             = State.Changing;
             prevMousePosition = Input.MousePosition;
             recognized.Raise();
         }
     }
     if (state == State.Changing)
     {
         var curMousePos = Input.MousePosition;
         if (prevMousePosition != curMousePos)
         {
             changed.Raise();
         }
         prevMousePosition = curMousePos;
         if (!Input.IsMousePressed(ButtonIndex))
         {
             ended.Raise();
             state = State.Initial;
         }
     }
 }
Example #2
0
 protected override bool CanStartDrag()
 {
     return
         ((MousePosition - MousePressPosition).SqrLength > DragThreshold.Sqr() ||
          TouchDistance != Vector2.Distance(Touch0, Touch1));
 }