Exemplo n.º 1
0
 //DoubleTappedRoutedEventArgs
 public UwpTapEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs args, int numberOfTaps)
 {
     ViewPosition = element.GetXfViewFrame();
     //Touches = new Xamarin.Forms.Point[] { args.GetPosition(null).ToXfPoint() };
     Touches      = new Xamarin.Forms.Point[] { args.GetPosition(element).ToXfPoint() };
     NumberOfTaps = numberOfTaps;
 }
Exemplo n.º 2
0
 public UwpRotateEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.ManipulationCompletedRoutedEventArgs args)
 {
     ViewPosition = element.GetXfViewFrame();
     Touches      = new Xamarin.Forms.Point[] { args.Position.ToXfPoint() };
     Angle        = 0;
     TotalAngle   = args.Cumulative.Rotation;
 }
Exemplo n.º 3
0
 public UwpPinchEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs args)
 {
     ViewPosition = element.GetXfViewFrame();
     Touches      = new Xamarin.Forms.Point[] { args.Position.ToXfPoint() };
     DeltaScale   = args.Delta.Scale;
     TotalScale   = args.Cumulative.Scale;
 }
Exemplo n.º 4
0
        private void UpdateFromScrollChanged(float offsetX, float offsetY)
        {
            var offSetNew = new Xamarin.Forms.Point(offsetX, offsetY);

            _formView.ScrollOffset = offSetNew;
            _formView.RaiseScrollChanged(offSetNew);
        }
Exemplo n.º 5
0
 protected override void OnElementChanged(ElementChangedEventArgs <CustomStackLayout> e)
 {
     base.OnElementChanged(e);
     grid             = this.Element.Children[0] as SfDataGrid;
     grid.GridTapped += Grid_GridTapped;
     point            = new Xamarin.Forms.Point();
 }
 //PointerRoutedEventArgs
 public UwpLongPressEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.PointerRoutedEventArgs args, long elapsedMilliseconds)
 {
     ViewPosition = element.GetXfViewFrame();
     //Touches = new Xamarin.Forms.Point[] { args.GetCurrentPoint(null).Position.ToXfPoint() };
     Touches  = new Xamarin.Forms.Point[] { args.GetCurrentPoint(element).Position.ToXfPoint() };
     Duration = elapsedMilliseconds;
 }
Exemplo n.º 7
0
        private bool HandleUp(MotionEvent e)
        {
            foreach (var gesture in _activeGestures)
            {
                var point      = new Xamarin.Forms.Point(_context.FromPixels(e.GetX()), _context.FromPixels(e.GetY()));
                var isCanceled = !gesture.Item1.RenderBounds.Contains(point);
                gesture.Item2.SendTouchUp(gesture.Item1, _context.FromPixels(e.GetX()) - gesture.Item1.RenderBounds.X, _context.FromPixels(e.GetY()) - gesture.Item1.RenderBounds.Y, isCanceled);
            }

            _activeGestures.Clear();

            if (_activePanGesture != null)
            {
                if (_activePanGesture is IMycoPanGestureRecognizerController)
                {
                    (_activePanGesture as IMycoPanGestureRecognizerController).SendPanCompleted(_activePanGestureView);
                }

                _activePanGesture     = null;
                _activePanGestureView = null;

                return(true);
            }

            return(false);
        }
Exemplo n.º 8
0
 public UwpPanEventArgs(FrameworkElement element, ManipulationCompletedRoutedEventArgs args)
 {
     ViewPosition  = element.GetXfViewFrame();
     Touches       = new Xamarin.Forms.Point[] { args.Position.ToXfPoint() };
     TotalDistance = args.Cumulative.Translation.ToXfPoint();
     Velocity      = args.Velocities.Linear.ToXfPoint();
 }
Exemplo n.º 9
0
        public override bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
        {
            bool gestureHandled = false;

            var point1 = new Xamarin.Forms.Point(e1.GetX(), e1.GetY());
            var point2 = new Xamarin.Forms.Point(e2.GetX(), e2.GetY());

            if (_activePanGesture == null && Math.Abs(point1.Distance(point2)) > ScrollThreshold)
            {
                var gestureRecognizers = new List <Tuple <MycoView, IMycoGestureRecognizerController> >();

                _container.GetGestureRecognizers(new Xamarin.Forms.Point(_context.FromPixels(e1.GetX()), _context.FromPixels(e1.GetY())), gestureRecognizers);

                foreach (var gestureRecognizer in gestureRecognizers)
                {
                    var panGesture = gestureRecognizer.Item2 as IMycoPanGestureRecognizerController;

                    if (panGesture != null)
                    {
                        _activePanGestureView = gestureRecognizer.Item1;
                        _activePanGesture     = panGesture;
                        panGesture.SendPanStarted(gestureRecognizer.Item1);
                        gestureHandled = true;
                        break;
                    }
                }
            }
            else if (_activePanGesture != null)
            {
                _activePanGesture.SendPanUpdatedWithUpdate(_activePanGestureView, _context.FromPixels(distanceX), _context.FromPixels(distanceY));
                gestureHandled = true;
            }

            return(gestureHandled);
        }
Exemplo n.º 10
0
 public static PointF ToPointF(this Xamarin.Forms.Point point)
 {
     return(new PointF(
                (float)point.X,
                (float)point.Y
                ));
 }
Exemplo n.º 11
0
        public void Render(IGraphicProvider gfx)
        {
            Xamarin.Forms.Point     ul     = m_Mapper.GetGraphicsPoint(m_Top.Start);
            Xamarin.Forms.Point     lr     = m_Mapper.GetGraphicsPoint(m_Right.End);
            Xamarin.Forms.Rectangle bounds = new Xamarin.Forms.Rectangle(ul, new Xamarin.Forms.Size(lr.X - ul.X, lr.Y - ul.Y));

            //gfx.DrawString(ul, new Font(FontFamily.GenericSansSerif, 10), m_Player.Color, m_Player.Initials);
        }
 public void SetTranslationInView(Xamarin.Forms.Point translation, Xamarin.Forms.VisualElement view)
 {
     //NOT really supported in Android
     //TODO take account of view
     _currentTranslation = translation;
     _currentPoint       = translation;
     _previousPoint      = translation;
 }
Exemplo n.º 13
0
 public UwpRightClickEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.RightTappedRoutedEventArgs args, FormsGestures.Listener listener) 
 {
     ElementPosition = element.GetXfViewFrame();
     var point = args.GetPosition(element);
     ElementTouches = new Xamarin.Forms.Point[] { point.ToXfPoint() };
     WindowTouches = new Xamarin.Forms.Point[] { element.PointInNativeAppWindowCoord(point).ToXfPoint() };
     Listener = listener;
 }
        public bool OnSingleTapUp(MotionEvent e)
        {
            State           = GestureRecognizerState.Recognized;
            FirstTouchPoint = new Xamarin.Forms.Point(e.GetX(0), e.GetY(0));
            Console.WriteLine("On Tap");

            OnGesture();
            return(true);
        }
Exemplo n.º 15
0
        //DoubleTappedRoutedEventArgs
        public UwpTapEventArgs(FrameworkElement element, DoubleTappedRoutedEventArgs args, int numberOfTaps)
        {
            ElementPosition = element.GetXfViewFrame();
            var point = args.GetPosition(element);

            ElementTouches = new Xamarin.Forms.Point[] { point.ToXfPoint() };
            WindowTouches  = new Xamarin.Forms.Point[] { element.PointInNativeAppWindowCoord(point).ToXfPoint() };
            NumberOfTaps   = numberOfTaps;
        }
Exemplo n.º 16
0
        bool IsMoveSufficientToBegin(Xamarin.Forms.Point newLocation)
        {
            var absoluteDistance = new Xamarin.Forms.Point(FirstTouchPoint.X - newLocation.X, FirstTouchPoint.Y - newLocation.Y);
            var absX             = Math.Abs(absoluteDistance.X);
            var absY             = Math.Abs(absoluteDistance.Y);
            var biggestValue     = Math.Max(absX, absY);

            return(biggestValue >= _minimumMoveDistance);
        }
        public bool OnSingleTapUp(MotionEvent e)
        {
            State = GestureRecognizerState.Recognized;
            FirstTouchPoint = new Xamarin.Forms.Point (e.GetX (0), e.GetY (0));
            Console.WriteLine ("On Tap");

            OnGesture ();
            return true;
        }
 public bool OnDown(MotionEvent e)
 {
     State = GestureRecognizerState.Began;
     _currentTranslation = new Xamarin.Forms.Point (e.GetX (), e.GetY ());
     _currentPoint = new Xamarin.Forms.Point (e.GetX (), e.GetY ());
     _previousPoint = new Xamarin.Forms.Point (e.GetX (), e.GetY ());
     OnGesture ();
     return true;
 }
Exemplo n.º 19
0
        //PointerRoutedEventArgs
        public UwpLongPressEventArgs(FrameworkElement element, Windows.UI.Xaml.Input.PointerRoutedEventArgs args, long elapsedMilliseconds)
        {
            ElementPosition = element.GetXfViewFrame();
            var point = args.GetCurrentPoint(element).Position;

            ElementTouches = new Xamarin.Forms.Point[] { point.ToXfPoint() };
            WindowTouches  = new Xamarin.Forms.Point[] { element.PointInNativeAppWindowCoord(point).ToXfPoint() };
            Duration       = elapsedMilliseconds;
        }
Exemplo n.º 20
0
        public UwpPinchEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.ManipulationCompletedRoutedEventArgs args)
        {
            ElementPosition = element.GetXfViewFrame();
            var point = args.Position;

            ElementTouches = new Xamarin.Forms.Point[] { point.ToXfPoint() };
            WindowTouches  = new Xamarin.Forms.Point[] { element.PointInNativeAppWindowCoord(point).ToXfPoint() };
            TotalScale     = args.Cumulative.Scale;
        }
 public bool OnDown(MotionEvent e)
 {
     State = GestureRecognizerState.Began;
     _currentTranslation = new Xamarin.Forms.Point(e.GetX(), e.GetY());
     _currentPoint       = new Xamarin.Forms.Point(e.GetX(), e.GetY());
     _previousPoint      = new Xamarin.Forms.Point(e.GetX(), e.GetY());
     OnGesture();
     return(true);
 }
Exemplo n.º 22
0
 public UwpPanEventArgs(FrameworkElement element, ManipulationDeltaRoutedEventArgs args)
 {
     ElementPosition = element.GetXfViewFrame();
     ElementTouches  = new Xamarin.Forms.Point[] { args.Position.ToXfPoint() };
     WindowTouches   = new Xamarin.Forms.Point[] { element.PointInNativeAppWindowCoord(args.Position).ToXfPoint() };
     DeltaDistance   = args.Delta.Translation.ToXfPoint();
     TotalDistance   = args.Cumulative.Translation.ToXfPoint();
     Velocity        = args.Velocities.Linear.ToXfPoint();
 }
Exemplo n.º 23
0
        public UwpDownUpArgs(FrameworkElement element, TappedRoutedEventArgs args)
        {
            Cancelled    = false;
            ViewPosition = element.GetXfViewFrame();
            //var currentPoint = args.GetPosition(null);
            var currentPoint = args.GetPosition(element);

            Touches           = new Xamarin.Forms.Point[] { currentPoint.ToXfPoint() };
            TriggeringTouches = new[] { 0 };
        }
Exemplo n.º 24
0
        public static Xamarin.Forms.Point GetCanvasCenter(this SKImageInfo info)
        {
            var result = new Xamarin.Forms.Point()
            {
                X = info.Width / 2,
                Y = info.Height / 2
            };

            return(result);
        }
Exemplo n.º 25
0
        public UwpDownUpArgs(FrameworkElement element, TappedRoutedEventArgs args)
        {
            Cancelled       = false;
            ElementPosition = element.GetXfViewFrame();
            var point = args.GetPosition(element);

            ElementTouches    = new Xamarin.Forms.Point[] { point.ToXfPoint() };
            WindowTouches     = new Xamarin.Forms.Point[] { element.PointInNativeAppWindowCoord(point).ToXfPoint() };
            TriggeringTouches = new[] { 0 };
        }
        void MapClicked(object o, MapboxMap.MapClickEventArgs args)
        {
            Element.IsTouchInMap = false;

            var point      = _map.Projection.ToScreenLocation(args.P0);
            var xfPoint    = new Xamarin.Forms.Point(point.X, point.Y);
            var xfPosition = new Position(args.P0.Latitude, args.P0.Longitude);

            Element.DidTapOnMapCommand?.Execute(new Tuple <Position, Xamarin.Forms.Point> (xfPosition, xfPoint));
        }
Exemplo n.º 27
0
        //PointerRoutedEventArgs
        public UwpTapEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.PointerRoutedEventArgs args, int numberOfTaps)
        {
            ElementPosition = element.GetXfViewFrame();
            //ElementTouches = new Xamarin.Forms.Point[] { args.GetCurrentPoint(null).Position.ToXfPoint() };
            var point = args.GetCurrentPoint(element).Position;

            ElementTouches = new Xamarin.Forms.Point[] { point.ToXfPoint() };
            WindowTouches  = new Xamarin.Forms.Point[] { element.PointInNativeAppWindowCoord(point).ToXfPoint() };
            NumberOfTaps   = numberOfTaps;
        }
Exemplo n.º 28
0
        public UwpRotateEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs args)
        {
            ElementPosition = element.GetXfViewFrame();
            var point = args.Position;

            ElementTouches = new Xamarin.Forms.Point[] { point.ToXfPoint() };
            WindowTouches  = new Xamarin.Forms.Point[] { element.PointInNativeAppWindowCoord(point).ToXfPoint() };
            Angle          = 0;
            DeltaAngle     = args.Delta.Rotation;
            TotalAngle     = args.Cumulative.Rotation;
        }
Exemplo n.º 29
0
        /// <summary>
        /// From <![CDATA[https://www.daniweb.com/programming/software-development/threads/389117/drawing-bezier-curves-using-de-casteljau-algorithm-in-c-open-gl]]>
        /// </summary>
        /// <param name="A"></param>
        /// <param name="B"></param>
        /// <param name="C"></param>
        /// <param name="D"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        public static Point GetBezierPoint(Point A, Point B, Point C, Point D, double t)
        {
            var P = new Point
            {
                X = Math.Pow((1 - t), 3) * A.X + 3 * t * Math.Pow((1 - t), 2) * B.X + 3 * (1 - t) * Math.Pow(t, 2) * C.X + Math.Pow(t, 3) * D.X,
                Y = Math.Pow((1 - t), 3) * A.Y + 3 * t * Math.Pow((1 - t), 2) * B.Y + 3 * (1 - t) * Math.Pow(t, 2) * C.Y + Math.Pow(t, 3) * D.Y
            };

            //P.z = Math.Pow((1 - t), 3) * A.z + 3 * t * pow((1 - t), 2) * B.z + 3 * (1 - t) * pow(t, 2) * C.z + pow(t, 3) * D.z;

            return(P);
        }
 public bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
 {
     if (e2.ActionMasked == MotionEventActions.Move || e2.ActionMasked == MotionEventActions.Scroll) {
         _previousPoint = _currentPoint;
         _currentPoint = new Xamarin.Forms.Point (e2.GetX (), e2.GetY ());
         _currentTranslation = new Xamarin.Forms.Point (distanceX, distanceY);
         State = GestureRecognizerState.Changed;
     }
     //			Console.WriteLine ("_currentTranslation " + _currentTranslation);
     //			Console.WriteLine ("State " + State + "_previousPoint " + _previousPoint + " _currentPoint" + _currentPoint);
     OnGesture ();
     return true;
 }
 void OnDown(GestureMotionEvent e)
 {
     //TODO - really should be possible at this point - min distance should trigger began
     State     = GestureRecognizerState.Possible;
     PointerId = e.GetPointerId(0);
     Console.WriteLine("PAN POSSIBLE");
     _rawTranslation     = new Xamarin.Forms.Point(0, 0);
     _currentPoint       = new Xamarin.Forms.Point(e.GetX(), e.GetY());
     _currentScreenPoint = new Xamarin.Forms.Point(e.GetX(), e.GetY());
     _previousPoint      = new Xamarin.Forms.Point(e.GetX(), e.GetY());
     _startPoint         = new Xamarin.Forms.Point(NativeView.GetX(), NativeView.GetY());
     SendGestureEvent();
 }
        public bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
        {
            if (e2.ActionMasked == MotionEventActions.Move || e2.ActionMasked == MotionEventActions.Scroll)
            {
                _previousPoint      = _currentPoint;
                _currentPoint       = new Xamarin.Forms.Point(e2.GetX(), e2.GetY());
                _currentTranslation = new Xamarin.Forms.Point(distanceX, distanceY);
                State = GestureRecognizerState.Changed;
            }
//			Console.WriteLine ("_currentTranslation " + _currentTranslation);
//			Console.WriteLine ("State " + State + "_previousPoint " + _previousPoint + " _currentPoint" + _currentPoint);
            OnGesture();
            return(true);
        }
Exemplo n.º 33
0
        protected Xamarin.Forms.Point GetLocationInAncestorView(Xamarin.Forms.Point location, Xamarin.Forms.VisualElement view)
        {
            var targetViewRenderer = view.GetRenderer();
            var targetView         = targetViewRenderer.ViewGroup;
            var parent             = NativeView;
            var returnPoint        = location;

            while (parent != null && parent != targetView)
            {
                returnPoint.X += parent.Left;
                returnPoint.Y += parent.Top;
                parent         = NativeView.Parent as View;
            }
            return(returnPoint);
        }
 public void SetTranslationInView(Xamarin.Forms.Point translation, Xamarin.Forms.VisualElement view)
 {
     //NOT really supported in Android
     //TODO take account of view
     _currentTranslation = translation;
     _currentPoint = translation;
     _previousPoint = translation;
 }
		void OnMove (GestureMotionEvent e)
		{
			_currentScreenPoint = new Xamarin.Forms.Point (e.GetX (), e.GetY ());
			var currentViewPosition = Recognizer.View.GetNativeScreenPosition ();
			var currentViewOffset = new Xamarin.Forms.Point (currentViewPosition.X - _viewStartLocation.X, currentViewPosition.Y - _viewStartLocation.Y);
			var eventPoint = new Xamarin.Forms.Point (e.GetX () + currentViewOffset.X, e.GetY () + currentViewOffset.Y);


//			Console.WriteLine ("ePoint {0} cvp {1} voffset {2} csp {3}", eventPoint.PrettyPrint (), currentViewPosition.PrettyPrint (), currentViewOffset.PrettyPrint (), _currentScreenPoint.PrettyPrint ());
			if (State == GestureRecognizerState.Possible || State == GestureRecognizerState.Began || State == GestureRecognizerState.Changed) {
//
//				if (e.GetX () < 0 || e.GetX () > NativeView.Width || e.GetY () < 0 || e.GetY () > NativeView.Height) {
//					Console.WriteLine ("Gesture exited from view - it's over");
//					State = GestureRecognizerState.Ended;
//				} else

				if (e.ActionMasked == MotionEventActions.Move || e.ActionMasked == MotionEventActions.Scroll) {
					_previousPoint = _currentPoint;
					_currentPoint = eventPoint;
					_velocity = new Xamarin.Forms.Point (_currentPoint.X - _previousPoint.X, _currentPoint.Y - _previousPoint.Y);

					if (State == GestureRecognizerState.Possible && !IsMoveSufficientToBegin (_currentScreenPoint)) {
						Console.WriteLine ("not moved enough - not starting");
						return;
					}
					//TODO proper conversion
					_rawTranslation.X += _velocity.X / 2;
					_rawTranslation.Y += _velocity.Y / 2;
					State = State == GestureRecognizerState.Possible ? GestureRecognizerState.Began : GestureRecognizerState.Changed;
					e.IsCancelled = Recognizer.CancelsTouchesInView;
				}
//				Console.WriteLine ("State " + State + "_previousPoint " + _previousPoint.PrettyPrint () + " _currentPoint" + _currentPoint.PrettyPrint () + "rt " + _rawTranslation.PrettyPrint ());
			}
		}
		bool IsMoveSufficientToBegin (Xamarin.Forms.Point newLocation)
		{
			var absoluteDistance = new Xamarin.Forms.Point (FirstTouchPoint.X - newLocation.X, FirstTouchPoint.Y - newLocation.Y);
			var absX = Math.Abs (absoluteDistance.X);
			var absY = Math.Abs (absoluteDistance.Y);
			var biggestValue = Math.Max (absX, absY);
			return biggestValue >= _minimumMoveDistance;
		}
		public void SetTranslationInView (Xamarin.Forms.Point translation, Xamarin.Forms.VisualElement view)
		{
			//Experimental android support
			_rawTranslation = translation;
		}
		void OnDown (GestureMotionEvent e)
		{
			//TODO - really should be possible at this point - min distance should trigger began
			State = GestureRecognizerState.Possible;
			PointerId = e.GetPointerId (0);
			Console.WriteLine ("PAN POSSIBLE");
			_rawTranslation = new Xamarin.Forms.Point (0, 0);
			FirstTouchPoint = new Xamarin.Forms.Point (e.GetX (), e.GetY ()); 
			_currentPoint = FirstTouchPoint;
			_currentScreenPoint = FirstTouchPoint;
			_previousPoint = FirstTouchPoint;

			_viewStartLocation = Recognizer.View.GetNativeScreenPosition ();
		}