Ejemplo n.º 1
0
 void UpdateGestureDirection(RoutedEventArgs originalArgs)
 {
     if (_direction == C1DragDirection.None)
     {
         Point  position = C1InputEventArgs.GetPosition(originalArgs, null);
         double x        = position.X - _origin.X;
         double num2     = position.Y - _origin.Y;
         if ((x != 0.0) || (num2 != 0.0))
         {
             double num3 = Math.Sqrt(Math.Pow(x, 2.0) + Math.Pow(num2, 2.0));
             double num4 = x / num3;
             double num5 = num2 / num3;
             if (Math.Abs(num5) < 0.4)
             {
                 _direction = C1DragDirection.Horizontal;
             }
             else if (Math.Abs(num4) < 0.4)
             {
                 _direction = C1DragDirection.Vertical;
             }
             else
             {
                 _direction = C1DragDirection.Diagonal;
             }
         }
     }
 }
Ejemplo n.º 2
0
 void OnPointerMoved(object sender, PointerRoutedEventArgs e)
 {
     if (_pointerPressed)
     {
         Point position = C1InputEventArgs.GetPosition(e, null);
         if (!_dragStarted)
         {
             Point point2 = new Point(position.X - _origin.X, position.Y - _origin.Y);
             if (((Math.Abs(point2.X) > _actualInitialThreshold) && _actualMode.TranslateX()) || ((Math.Abs(point2.Y) > _actualInitialThreshold) && _actualMode.TranslateY()))
             {
                 if (_actualCaptureElementOnMouseDown || TryCaptureMouse(e))
                 {
                     Start(e);
                 }
                 else
                 {
                     _pointerPressed = false;
                 }
             }
         }
         if (_dragStarted)
         {
             Point deltaTranslation = new Point(position.X - _lastPos.X, position.Y - _lastPos.Y);
             _points.Push(new KeyValuePair <DateTime, Point>(DateTime.Now, position));
             _cumulativeTranslation = new Point(_cumulativeTranslation.X + deltaTranslation.X, _cumulativeTranslation.Y + deltaTranslation.Y);
             RaiseDragDelta(e, _cumulativeTranslation, deltaTranslation, false);
             _lastPos = position;
         }
     }
 }
Ejemplo n.º 3
0
 void OnPointerPressed(object sender, PointerRoutedEventArgs e)
 {
     _pointerType = C1InputEventArgs.GetPointerType(e);
     if (_pointerType != C1PointerDeviceType.Touch)
     {
         Complete(e);
         _origin  = C1InputEventArgs.GetPosition(e, null);
         _lastPos = _origin;
         if (RaiseDragStarting(e))
         {
             if (!_actualCaptureElementOnMouseDown || TryCaptureMouse(e))
             {
                 _pointerPressed = true;
             }
             if (_pointerPressed && (_actualInitialThreshold == 0.0))
             {
                 Start(e);
             }
             if (_useRightButton)
             {
                 e.Handled = true;
             }
         }
     }
 }
Ejemplo n.º 4
0
 void OnManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
 {
     _pointerType = C1InputEventArgs.GetPointerType(e);
     if ((_pointerType == C1PointerDeviceType.Touch) || !_listenPointerEvents)
     {
         Complete(e);
         _origin = C1InputEventArgs.GetPosition(e, null);
         _manipulationStarted = RaiseDragStarting(e);
         if (_manipulationStarted && (_actualInitialThreshold == 0.0))
         {
             Start(e);
         }
     }
 }
Ejemplo n.º 5
0
 void OnPointerReleased(object sender, PointerRoutedEventArgs e)
 {
     if (_pointerPressed)
     {
         _pointerPressed = false;
         if (_dragStarted)
         {
             Point position = C1InputEventArgs.GetPosition(e, null);
             _points.Push(new KeyValuePair <DateTime, Point>(DateTime.Now, position));
             Point finalVelocities = GetFinalVelocities();
             if ((finalVelocities != new Point()) && _actualMode.IsInertial())
             {
                 StartInertia(e, finalVelocities);
             }
             else
             {
                 Complete(e);
             }
         }
         _points.Clear();
         ReleaseMouseCapture();
     }
 }