Beispiel #1
0
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            base.TouchesMoved(touches, evt);
            var touch = touches.FirstOrDefault() as UITouch;

            Pressure(touch);
        }
Beispiel #2
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            // Add a conditional guard to deselect on map touch
            if (Element != null && Element.ShouldDeselectOnMapTouch && _shouldNotDismiss)
            {
                var isAnnotation = false;
                var touch        = touches.FirstOrDefault() as UITouch;
                if (touch != null && Control != null)
                {
                    // Detect when an annotation is touched
                    // May be enhanced in the future to detect when an MKCircle, MKPolyline or MKPointAnnotaiton is touched
                    if (touch.View is MKAnnotationView)
                    {
                        isAnnotation = true;
                    }
                }

                if (!isAnnotation)
                {
                    // Deselect annotation when map is touched
                    SelectedItem = null;
                }
            }
        }
Beispiel #3
0
        private void HandleTouches(NSSet touches, UIEvent evt)
        {
            var     touch = touches.FirstOrDefault() as UITouch;
            CGPoint point = touch.LocationInView(this);

            this.SetValue(point.X * this.scale, point.Y * this.scale);
            this.SetNeedsDisplayInRect(this.Bounds);
        }
 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     base.TouchesBegan(touches, evt);
     if (touches.FirstOrDefault() is UITouch touch && Control != null)
     {
         _touchBegan = touch.Timestamp;
     }
     _shouldNotDismiss = false; // reset
 }
        public MenuItem FindItem(string identifier)
        {
            MenuItem[] matchedItems = new MenuItem[] { };
            var        predicate    = NSPredicate.FromExpression((evaluatedObject, bindings) =>
            {
                return(((MenuItem)evaluatedObject).ItemNameKey == identifier);
            });

            matchedItems = new NSSet <MenuItem>(ManagedDataBackingInstance)
                           .FilterUsingPredicate(predicate)
                           .ToArray <MenuItem>();

            return(matchedItems.FirstOrDefault());
        }
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            // Add a conditional guard to deselect on map touch
            if (Element != null && Element.ShouldDeselectOnMapTouch && !_shouldNotDismiss)
            {
                var isAnnotation = false;
                if (touches.FirstOrDefault() is UITouch touch && Control != null)
                {
                    // MKAnnotationContainerView is a private inner class, so you cannot compare directly
                    var classHandle = Class.GetHandle("MKAnnotationContainerView");
                    var myClass     = classHandle != IntPtr.Zero ? new Class(classHandle) : null;
                    if (myClass != null && touch.View.IsKindOfClass(myClass))
                    {
                        var cgPoint  = touch.LocationInView(Control);
                        var location = Control.ConvertPoint(cgPoint, Control);
                        if (touch.Timestamp - _touchBegan >= 0.5) // 0.5 second like UILongPressGesture
                        {
                            Element.SendMapLongClicked(new Position(location.Latitude, location.Longitude));
                        }
                        else
                        {
                            Element.SendMapClicked(new Position(location.Latitude, location.Longitude));
                        }
                    }
                    // Detect when an annotation is touched
                    // May be enhanced in the future to detect when an MKCircle, MKPolyline or MKPointAnnotation is touched
                    if (touch.View is MKAnnotationView view && view.Annotation is UnifiedPointAnnotation unifiedPoint)
                    {
                        isAnnotation = true;
                        if (touch.Timestamp - _touchBegan < 0.5) // 0.5 second like UILongPressGesture
                        {
                            Element.SendPinClicked(unifiedPoint.Data);
                        }
                        else if (!unifiedPoint.Data.Draggable)
                        {
                            Element.SendPinLongClicked(unifiedPoint.Data);
                        }
                    }
                }

                if (!isAnnotation)
                {
                    // Deselect annotation when map is touched
                    SelectedItem = null;
                }
            }
        }
Beispiel #7
0
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            var first = (UITouch)touches.FirstOrDefault();

            if (first != null)
            {
                touchEvent.state = TouchState.Changed;
                touchEvent.SetLocation(first.LocationInView(gesture.View), gesture.Scale);
                gesture.OnTouch(touchEvent);
            }
            if (touchEvent.mode == GestureMode.None)
            {
                base.TouchesBegan(touches, evt);
            }
        }
Beispiel #8
0
        /// <returns>The screen position as Mapsui point. Can be null.</returns>
        private Point GetScreenPosition(NSSet touches)
        {
            if (touches.Count != 1)
            {
                return(null);
            }
            var touch       = touches.FirstOrDefault() as UITouch;
            var mapsuiPoint = touch?.LocationInView(this).ToMapsui();

            if (mapsuiPoint == null)
            {
                return(null);
            }
            return(new Point(mapsuiPoint.X * _skiaScale, mapsuiPoint.Y * _skiaScale));
        }
Beispiel #9
0
        private void HandleInfo(NSSet touches)
        {
            if (touches.Count != 1)
            {
                return;
            }
            var touch = touches.FirstOrDefault() as UITouch;

            if (touch == null)
            {
                return;
            }
            var screenPosition = touch.LocationInView(this);

            Map.InvokeInfo(screenPosition.ToMapsui(), _renderer.SymbolCache);
        }
		public override void TouchesMoved (NSSet touches, UIEvent evt)
		{
			CanvasView.DrawTouches (touches, evt);
			var touch = (UITouch)touches.FirstOrDefault ();
			if (touch == null)
				return;

			UpdateReticleView (touch);

			// Use the last predicted touch to update the reticle.
			UITouch[] predictedTouches = evt?.GetPredictedTouches (touch);
			UITouch predictedTouch = predictedTouches?.LastOrDefault ();

			if (predictedTouch != null)
				UpdateReticleView (predictedTouch, true);
		}
Beispiel #11
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            base.TouchesBegan(touches, evt);

            var pointOfTouch = ((UITouch)touches.FirstOrDefault()).LocationInView(this);

            pointOfTouch.Y += bottomMargin;

            if (graphLayer.Contains(pointOfTouch))
            {
                touchDown = true;
                editPoint = pointOfTouch;

                UpdateFrequenciesAndResonance();
            }
        }
Beispiel #12
0
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            CanvasView.DrawTouches(touches, evt);
            var touch = (UITouch)touches.FirstOrDefault();

            if (touch == null)
            {
                return;
            }

            UpdateReticleView(touch);

            // Use the last predicted touch to update the reticle.
            UITouch[] predictedTouches = evt?.GetPredictedTouches(touch);
            UITouch   predictedTouch   = predictedTouches?.LastOrDefault();

            if (predictedTouch != null)
            {
                UpdateReticleView(predictedTouch, true);
            }
        }
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            if (trackedTouch == null)
            {
                trackedTouch     = (UITouch)touches.FirstOrDefault();
                initialTimestamp = trackedTouch.Timestamp;

                if (!IsForPencil)
                {
                    BeginIfNeeded(null);
                }
                fingerStartTimer = NSTimer.CreateScheduledTimer(cancellationTimeInterval, BeginIfNeeded);
            }
            if (Append(Touches(touches), evt))
            {
                if (IsForPencil)
                {
                    State = Began;
                }
            }
        }
        private void TouchHandler(NSSet touches)
        {
            // Set reference to the location of the touch in member point
            var touch = touches.FirstOrDefault() as UITouch;

            if (touch == null)
            {
                return;
            }

            _point = touch.LocationInView(this);

            var indicator = GetIndicatorCoordinate(_point);

            _point = indicator.Point;
            var color = (hue : (nfloat)0, saturation : (nfloat)0f);

            if (!indicator.IsCenter)
            {
                color = HueSaturationAtPoint(new CGPoint(x: _point.X * _scale, y: _point.Y * _scale));
            }

            _color = UIColor.FromHSBA(hue: color.hue, saturation: color.saturation, brightness: _brightness, alpha: 1.0f);

            nfloat red   = 0f;
            nfloat green = 0f;
            nfloat blue  = 0f;
            nfloat alpha = 0f;

            _color.GetRGBA(out red, out green, out blue, out alpha);

            Console.WriteLine($"color hue: Red {Math.Round(red, 2)} Green {Math.Round(green, 2)} Blue {Math.Round(blue, 2)}");

            // Notify delegate of the new Hue and Saturation
            //delegate?.hueAndSaturationSelected(color.hue, saturation: color.saturation);

            // Draw the indicator
            DrawIndicator();
        }
		public override void TouchesBegan (NSSet touches, UIEvent evt)
		{
			if (trackedTouch == null) {
				trackedTouch = (UITouch)touches.FirstOrDefault ();
				initialTimestamp = trackedTouch.Timestamp;

				if (!IsForPencil)
					BeginIfNeeded (null);
					fingerStartTimer = NSTimer.CreateScheduledTimer (cancellationTimeInterval, BeginIfNeeded);
			}
			if (Append (Touches(touches), evt)) {
				if (IsForPencil)
					State = Began;
			}
		}
Beispiel #16
0
		public override void TouchesBegan (NSSet touches, UIEvent evt)
		{
			base.TouchesBegan (touches, evt);

			var pointOfTouch = ((UITouch)touches.FirstOrDefault ()).LocationInView (this);
			pointOfTouch.Y += bottomMargin;

			if (graphLayer.Contains (pointOfTouch)) {
				touchDown = true;
				editPoint = pointOfTouch;

				UpdateFrequenciesAndResonance ();
			}
		}
Beispiel #17
0
 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     base.TouchesBegan(touches, evt);
     touchExited = false;
     TouchMoved(touches.FirstOrDefault() as UITouch);
 }
Beispiel #18
0
 public override void TouchesCancelled(NSSet touches, UIEvent evt)
 {
     base.TouchesCancelled(touches, evt);
     TouchEnded(touches.FirstOrDefault() as UITouch);
 }