예제 #1
0
        public void ContainsTest()
        {
            var v1 = (NSString)"1";
            var v2 = (NSString)"2";

            using (var st = new NSSet <NSString> (v1)) {
                Assert.Throws <ArgumentNullException> (() => st.Contains((NSString)null), "Contains ANE 1");
                Assert.IsTrue(st.Contains(v1), "Contains 1");
                Assert.IsFalse(st.Contains(v2), "Contains 2");
            }
        }
예제 #2
0
 public override void TouchesCancelled(NSSet touches, UIEvent @event)
 {
     if (touches.Contains(this.trackingTouch))
     {
         this.ResetInteraction();
     }
 }
예제 #3
0
 public override void TouchesMoved(NSSet touches, UIEvent @event)
 {
     if (touches.Contains(this.trackingTouch))
     {
         this.UpdateStickPosition(this.trackingTouch.LocationInNode(this));
         this.Delegate.PadOverlayVirtualStickInteractionDidChange(this);
     }
 }
예제 #4
0
        public override void TouchesEnded(NSSet touches, UIEvent touchEvent)
        {
            if (panningTouch != null && touches.Contains(panningTouch))
            {
                panningTouch = null;
            }

            if (padTouch == null)
            {
                return;
            }

            if (touches.Contains(padTouch) || !touchEvent.TouchesForView(this).Contains(padTouch))
            {
                padTouch  = null;
                direction = new CGPoint(0, 0);
                DirectionDidChange();
            }
        }
예제 #5
0
		public void OperatorPlus ()
		{
			var one = new NSSet (1, 2, 3);
			var two = new NSSet (4, 5, 6);
			var sum = one + two;
			Assert.AreEqual (sum.Count, 6);

			var objs = new NSObject [5];
			for (int i = 0; i < objs.Length; i++)
				objs [i] = new NSNumber (i*100);

			sum = new NSSet (objs) + one + two;
			Assert.AreEqual (sum.Count, 11);
			sum = new NSSet (objs) + new NSSet (objs);
			Assert.AreEqual (sum.Count, 5);

			Assert.AreEqual ((one + one).Count, 3);
			var sub = one - one;
			Assert.AreEqual (sub.Count, 0);

			var three = new NSSet (1, 2, 3, 4, 5, 6);
			var subt = three - two;
			Assert.AreEqual (subt.Count, 3);
			Assert.True (three.Contains (1));
			Assert.True (three.Contains (2));
			Assert.True (three.Contains (3));
			subt = three - one;
			Assert.AreEqual (subt.Count, 3);
			Assert.True (three.Contains (4));
			Assert.True (three.Contains (5));
			Assert.True (three.Contains (6));

		}
예제 #6
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            if (Heroes.Count < 1)
            {
                return;
            }

            UITouch touch = DefaultPlayer.MovementTouch;

            if (touch != null && touches.Contains(touch))
            {
                DefaultPlayer.MovementTouch = null;
                DefaultPlayer.FireAction    = false;
            }
        }
예제 #7
0
        static public PKContactFields GetValue(NSSet set)
        {
            var fields = PKContactFields.None;

            if (set == null)
            {
                return(fields);
            }

            foreach (PKContactFields value in Enum.GetValues(typeof(PKContactFields)))
            {
                var constant = value.GetConstant();
                // None does not have an associated native value and Contains would throw an ANE
                if ((constant != null) && set.Contains(constant))
                {
                    fields |= value;
                }
            }
            return(fields);
        }
예제 #8
0
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            if (Heroes.Count < 1)
            {
                return;
            }

            UITouch touch = DefaultPlayer.MovementTouch;

            if (touch == null)
            {
                return;
            }

            if (touches.Contains(touch))
            {
                DefaultPlayer.TargetLocation = touch.LocationInNode(DefaultPlayer.Hero.Parent);
                if (!DefaultPlayer.FireAction)
                {
                    DefaultPlayer.MoveRequested = true;
                }
            }
        }
예제 #9
0
        /// <summary>
        /// TouchesEnded decrements the touches down from two or more touches and sets the
        /// state of the GestureRecognizer.
        /// </summary>
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            NSSet AllTouchesInRecognizer = evt.TouchesForGestureRecognizer(this);
            int   touchesLeft            = (int)(AllTouchesInRecognizer.Count - touches.Count);

            if (touchesLeft == 0)
            {
                HasSingleTouch        = false;
                HasTwoTouches         = false;
                HasMoreThanTwoTouches = false;
                State = UIGestureRecognizerState.Ended;
                Reset();
            }

            if (touchesLeft == 1)
            {
                // Just to be uber-safe...
                foreach (UITouch touch in AllTouchesInRecognizer)
                {
                    if (!touches.Contains(touch))
                    {
                        TrackingTouch   = touch;
                        AnchorLocation  = touch.LocationInView(this.View);
                        CurrentLocation = touch.LocationInView(this.View);
                    }
                }

                HasSingleTouch        = true;
                HasTwoTouches         = false;
                HasMoreThanTwoTouches = false;
            }

            if (touchesLeft == 2)
            {
                // stubbed
            }
        }
예제 #10
0
		public override void TouchesEnded (NSSet touches, UIEvent touchEvent)
		{
			if (panningTouch != null && touches.Contains (panningTouch))
				panningTouch = null;

			if (padTouch == null)
				return;

			if (touches.Contains (padTouch) || !touchEvent.TouchesForView (this).Contains (padTouch)) {
				padTouch = null;
				direction = new CGPoint (0, 0);
				DirectionDidChange ();
			}
		}
예제 #11
0
        virtual public Gesture UpdateGestureFromTouches(NSSet touches, TouchEventType touchType)
        {
            if (touches.Count() == 0)
            {
                // No touches, do nothing
                return(null);
            }

            // Update the set of current touches
            switch (touchType)
            {
            case TouchEventType.TouchBegan:
            case TouchEventType.TouchMoved:
                var touchesUnion = currentTouches.Union(touches);
                var touchesArray = new UITouch[touchesUnion.Count()];
                int i            = 0;
                foreach (UITouch touch in touchesUnion)
                {
                    touchesArray[i] = touch;
                    i++;
                }
                currentTouches = new NSSet(touchesArray);
                break;

            case TouchEventType.TouchCanceled:
            case TouchEventType.TouchEnded:
                var notInTouches = NSPredicate.FromExpression(new NSPredicateEvaluator((evaluatedObject, bindings) => !touches.Contains(evaluatedObject)));
                currentTouches = currentTouches.FilterUsingPredicate(notInTouches);
                break;
            }


            var expectedTouchCount = (this is SingleFingerGesture) ? 1 : 2;

            if (currentTouches.Count() == expectedTouchCount)
            {
                this.UpdateGesture(null);
                return(this);
            }
            else
            {
                this.FinishGesture();
                this.refreshTimer?.Dispose();
                // Erase reference to timer in case callback fires one last time
                this.refreshTimer = null;

                // Switch to two-finger gesture if was single-finger. If was two-finger, return null
                return((this is SingleFingerGesture)
                                        ? Gesture.StartGestureFromTouches(currentTouches, this.SceneView, LastUsedObject, manager)
                                         : null);
            }
        }
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            if (Heroes.Count < 1)
                return;

            UITouch touch = DefaultPlayer.MovementTouch;

            if (touch == null)
                return;

            if (touches.Contains (touch)) {
                DefaultPlayer.TargetLocation = touch.LocationInNode (DefaultPlayer.Hero.Parent);
                if (!DefaultPlayer.FireAction)
                    DefaultPlayer.MoveRequested = true;
            }
        }
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            if (Heroes.Count < 1)
                return;

            UITouch touch = DefaultPlayer.MovementTouch;
            if (touch != null && touches.Contains (touch)) {
                DefaultPlayer.MovementTouch = null;
                DefaultPlayer.FireAction = false;
            }
        }