Exemplo n.º 1
0
        public override void ItemsSelected(NSCollectionView collectionView, NSSet indexPaths)
        {
            var paths = indexPaths.ToArray <NSIndexPath>();
            var index = (int)paths[0].Item;

            // Datasource.Data[index];
        }
Exemplo n.º 2
0
 public void OpenUrlContexts(UIScene scene, NSSet <UIOpenUrlContext> urlContexts)
 {
     if (urlContexts.Count >= 1)
     {
         AGCAppLinking.GetSharedInstance().OpenDeepLinkURL(urlContexts.ToArray()[0]?.Url);
     }
 }
Exemplo n.º 3
0
        public override void PressesBegan(NSSet <UIPress> presses, UIPressesEvent evt)
        {
            base.PressesBegan(presses, evt);
            var pressesList = presses.ToArray().ToList();
            var firstPress  = pressesList.FirstOrDefault();

            if (firstPress != null)
            {
                var keyCode = KeyCode.Unknown;

                switch (firstPress.Key.KeyCode)
                {
                case UIKeyboardHidUsage.KeyboardUpArrow:
                    keyCode = KeyCode.UpArrow;
                    break;

                case UIKeyboardHidUsage.KeyboardDownArrow:
                    keyCode = KeyCode.DownArrow;
                    break;
                }

                if (keyCode != KeyCode.Unknown)
                {
                    KeyPressed?.Invoke(this, new KeyPressEventArgs(keyCode, firstPress.Key.Characters));
                }
            }
        }
Exemplo n.º 4
0
        public static List <UITouch> ToTouchList(this NSSet touches)
        {
            var touchArray = touches.ToArray <UITouch>();
            var touchList  = new List <UITouch>(touchArray);

            return(touchList);
        }
Exemplo n.º 5
0
        public override void TouchesBegan(NSSet touchesSet, UIEvent evt)
        {
            var touches = touchesSet.ToArray <UITouch> ();

            touchPhaseLabel.Text = "Phase:Touches began";
            touchInfoLabel.Text  = "";

            var numTaps = touches.Sum(t => t.TapCount);

            if (numTaps >= 2)
            {
                touchInfoLabel.Text = string.Format("{0} taps", numTaps);
                if (numTaps == 2 && piecesOnTop)
                {
                    // recieved double tap -> align the three pieces diagonal.
                    firstImage.Center = new CGPoint(padding + firstImage.Frame.Width / 2f,
                                                    touchInfoLabel.Frame.Bottom + padding + firstImage.Frame.Height / 2f);
                    secondImage.Center = new CGPoint(View.Bounds.Width / 2f, View.Bounds.Height / 2f);
                    thirdImage.Center  = new CGPoint(View.Bounds.Width - thirdImage.Frame.Width / 2f - padding,
                                                     touchInstructionLabel.Frame.Top - thirdImage.Frame.Height);
                    touchInstructionLabel.Text = "";
                }
            }
            else
            {
                touchTrackingLabel.Text = "";
            }
            foreach (var touch in touches)
            {
                // Send to the dispatch method, which will make sure the appropriate subview is acted upon
                DispatchTouchAtPoint(touch.LocationInView(View));
            }
        }
Exemplo n.º 6
0
 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     if (TrackLayer.Frame.Contains(Layer.ConvertPointToLayer(touches.ToArray <UITouch>()[0].LocationInView(this), Layer)))
     {
         SetOn(internalSwitchState != SwitchState.On, true);
     }
 }
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            _backupAttributedText = AttributedText;
            var arr = touches.ToArray <UITouch>();

            foreach (var touch in arr)
            {
                var touchPoint = touch.LocationInView(this);
                var rangeValue = AttributedTextRangeForPoint(touchPoint);
                if (rangeValue == null)
                {
                    continue;
                }

                var range            = rangeValue.Value;
                var attributedString = new NSMutableAttributedString(AttributedText);
                attributedString.AddAttributes(LinkAttributeHighlight, range);
                TransitionNotify(this, HighLightAnimationTime, UIViewAnimationOptions.TransitionCrossDissolve, () =>
                {
                    AttributedText = attributedString;
                }, null);
            }

            this.BackgroundColor = UIColor.Blue;
        }
Exemplo n.º 8
0
 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     foreach (UITouch touch in touches.ToArray<UITouch>())
     {
         Console.WriteLine(touch);
     }
 }
        public override void ItemsDeselected(NSCollectionView collectionView, NSSet indexPaths)
        {
            var paths = indexPaths.ToArray <NSIndexPath>();
            var index = paths[0].Item;

            ParentViewController.ThumbnailSelected = null;
        }
Exemplo n.º 10
0
        public override void TouchesBeganWithEvent(NSEvent aEvent)
        {
            if (!Enabled)
            {
                return;
            }

            NSSet touches = aEvent.TouchesMatchingPhaseinView(NSTouchPhase.Touching, View);

            if (touches.Count == 2)
            {
                iInitialPoint = View.ConvertPointFromBase(aEvent.LocationInWindow);
                foreach (NSTouch t in touches.ToArray <NSTouch>())
                {
                    iInitialTouches.Add(t);
                    iCurrentTouches.Add(t);
                }
            }
            else if (touches.Count > 2)
            {
                if (iIsTracking)
                {
                    CancelTracking();
                }
            }
        }
Exemplo n.º 11
0
 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     foreach (UITouch touch in touches.ToArray <UITouch>())
     {
         Console.WriteLine(touch);
     }
 }
        public override void ItemsSelected(NSCollectionView collectionView, NSSet indexPaths)
        {
            var paths = indexPaths.ToArray <NSIndexPath>();
            var index = (int)paths[0].Item;

            ParentViewController.ThumbnailSelected = ParentViewController.Source.Data[index];
        }
Exemplo n.º 13
0
        public void TouchesBegan(NSSet touchSet, UIEvent evnt)
        {
            if (DispatchEvents) {
                List<TouchHandler> handlers = new List<TouchHandler>(_touchHandlers);

                // Make full-aot aware of the needed ICollection<UITouch> types
                ICollection<UITouch> touches_col = (ICollection<UITouch>)touchSet.ToArray<UITouch>();

                #pragma warning disable 0219
                // this is a tiny hack, make sure the AOT compiler knows about
                // UICollection.Count, as it will need it when we instantiate the list below
                int touches_count = touches_col.Count;
                #pragma warning restore 0219

                List<UITouch> touches = new List<UITouch>(touches_col);

                foreach (TouchHandler handler in handlers) {
                    if (handler.TouchesBegan(touches, evnt)) {
                        break;
                    }
                    if (touches.IsEmpty()) {
                        break;
                    }
                }
            }
        }
        public override void TouchesBegan(NSSet touchesSet, UIEvent evt)
        {
            var touches = touchesSet.ToArray<UITouch> ();
            touchPhaseLabel.Text = "Phase:Touches began";
            touchInfoLabel.Text = "";

            var numTaps = touches.Sum (t => t.TapCount);
            if (numTaps >= 2){
                touchInfoLabel.Text = string.Format ("{0} taps", numTaps);
                if (numTaps == 2 && piecesOnTop) {
                    // recieved double tap -> align the three pieces diagonal.
                    firstImage.Center = new PointF (padding + firstImage.Frame.Width / 2f,
                        touchInfoLabel.Frame.Bottom + padding + firstImage.Frame.Height / 2f);
                    secondImage.Center = new PointF (View.Bounds.Width / 2f, View.Bounds.Height / 2f);
                    thirdImage.Center = new PointF (View.Bounds.Width - thirdImage.Frame.Width / 2f - padding,
                        touchInstructionLabel.Frame.Top - thirdImage.Frame.Height);
                    touchInstructionLabel.Text = "";
                }

            } else {
                touchTrackingLabel.Text = "";
            }
            foreach (var touch in touches) {
                // Send to the dispatch method, which will make sure the appropriate subview is acted upon
                DispatchTouchAtPoint (touch.LocationInView (View));
            }
        }
		public override void TouchesBegan (NSSet touchesSet, UIEvent evt)
		{
			var touches = touchesSet.ToArray<UITouch> ();
			touchPhaseLabel.Text = "Phase:Touches began";
			touchInfoLabel.Text = "";
		
			var numTaps = touches.Sum (t => t.TapCount);
			if (numTaps >= 2){
				touchInfoLabel.Text = string.Format ("{0} taps", numTaps);
				if (numTaps == 2 && piecesOnTop) {
					// recieved double tap -> align the three pieces diagonal.
					if (firstImage.Center.X == secondImage.Center.X)
						secondImage.Center = new PointF (firstImage.Center.X - 50, firstImage.Center.Y - 50);
					if (firstImage.Center.X == thirdImage.Center.X)
						thirdImage.Center = new PointF (firstImage.Center.X + 50, firstImage.Center.Y + 50);
					if (secondImage.Center.X == thirdImage.Center.X)
						thirdImage.Center = new PointF (secondImage.Center.X + 50, secondImage.Center.Y + 50);
					touchInstructionLabel.Text = "";
				}
					
			} else {
				touchTrackingLabel.Text = "";
			}
			foreach (var touch in touches) {
				// Send to the dispatch method, which will make sure the appropriate subview is acted upon
				DispatchTouchAtPoint (touch.LocationInView (window));
			}
		}
        /// <summary>
        /// Called when a touch gesture begins.
        /// </summary>
        /// <param name="touches">The touches.</param>
        /// <param name="evt">The event arguments.</param>
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            base.TouchesBegan(touches, evt);

            if (this.activeTouches.Count >= 2)
            {
                // we already have two touches
                return;
            }

            // Grab 1-2 touches to track
            var newTouches = touches.ToArray <UITouch>();
            var firstTouch = !this.activeTouches.Any();

            this.activeTouches.AddRange(newTouches.Take(2 - this.activeTouches.Count));

            if (firstTouch)
            {
                // HandleTouchStarted initializes the entire multitouch gesture,
                // with the first touch used for panning.
                this.TouchEventArgs = this.activeTouches.First().ToTouchEventArgs(this.View);
            }

            this.CalculateStartingDistance();
        }
		void ProcessTouches (NSSet touches)
		{
			if (ripple == null)
				return;
			
			foreach (UITouch touch in touches.ToArray<UITouch> ())
				ripple.InitiateRippleAtLocation (touch.LocationInView (touch.View));
		}
Exemplo n.º 18
0
 public override void TouchesCancelled(NSSet touches, UIEvent evt)
 {
     foreach (UITouch touch in touches.ToArray <UITouch> ())
     {
         UInt64 touchId = touch.GetNativeHash();
         XamarinTouchesCancelled(touchId);
     }
 }
Exemplo n.º 19
0
        public override void ItemsDeselected(NSCollectionView collectionView, NSSet indexPaths)
        {
            var paths = indexPaths.ToArray <NSIndexPath>();
            var index = paths[0].Item;

            // Clear selection
            // ParentViewController.PersonSelected = null;
        }
Exemplo n.º 20
0
 public override void TouchesCancelled(NSSet touchesSet, UIEvent evt)
 {
     touchPhaseLabel.Text = "Phase: Touches cancelled";
     foreach (var touch in touchesSet.ToArray <UITouch> ())
     {
         DispatchTouchEndEvent(touch.View, touch.LocationInView(View));
     }
 }
Exemplo n.º 21
0
		public static MouseEventArgs ConvertMouse (UIView view, NSSet touches, UIEvent evt)
		{
			if (touches.Count > 0) {
				UITouch touch = touches.ToArray<UITouch> () [0];
				var location = touch.LocationInView (view);
				return new MouseEventArgs (MouseButtons.Primary, Key.None, location.ToEtoPoint ());
			}
			return new MouseEventArgs (MouseButtons.Primary, Key.None, Point.Empty);
		}
Exemplo n.º 22
0
 public override void TouchesEnded(NSSet touches, UIEvent evt)
 {
     foreach (UITouch touch in touches.ToArray <UITouch> ())
     {
         CGPoint location = touch.LocationInView(View);
         UInt64  touchId  = touch.GetNativeHash();
         XamarinTouchesEnded(touchId, (int)location.X, (int)location.Y);
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// Handles one or more items being selected.
        /// </summary>
        /// <param name="collectionView">The parent Collection view.</param>
        /// <param name="indexPaths">The Index paths of the items being selected.</param>
        public override void ItemsSelected(NSCollectionView collectionView, NSSet indexPaths)
        {
            // Dereference path
            var paths = indexPaths.ToArray <NSIndexPath>();
            var index = (int)paths[0].Item;

            // Save the selected item
            ParentViewController.PersonSelected = ParentViewController.Datasource.Data[index];
        }
Exemplo n.º 24
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            var ts = touches.ToArray <UITouch>();

            foreach (var t in ts)
            {
                _activeTouches[t.Handle] = t;
            }
        }
Exemplo n.º 25
0
 private void ProcessTouches(NSSet touches)
 {
     if (this.Ripple != null)
     {
         foreach (UITouch touch in touches.ToArray <UITouch>())
         {
             this.Ripple.InitiateRippleAtLocation(touch.LocationInView(touch.View));
         }
     }
 }
 public override void TouchesEnded(NSSet touches, UIEvent evt)
 {
     var touchArray = touches.ToArray<UITouch>();
     if(touches.Count>0)
     {
         var coord = touchArray[0].LocationInView(touchArray[0].View);
         interactionLabel.Text= string.Format("{0} ({1},{2})", DescribeTouch(touchArray[0]), coord.X, coord.Y);
         SetTimerToClearMotionLabel();
     }
 }
Exemplo n.º 27
0
        public void ToArrayTest()
        {
            var v1 = (NSString)"1";

            using (var st = new NSSet <NSString> (v1)) {
                var arr = st.ToArray();
                Assert.AreEqual(1, arr.Length, "ToArray Length");
                Assert.AreSame(v1, arr [0], "ToArray () [0]");
            }
        }
Exemplo n.º 28
0
        public CWNetwork [] ScanForNetworksWithSsid(NSData ssid, bool includeHidden, out NSError error)
        {
            NSSet networks = _ScanForNetworksWithSsid(ssid, includeHidden, out error);

            if (networks != null)
            {
                return(networks.ToArray <CWNetwork> ());
            }
            return(null);
        }
Exemplo n.º 29
0
 public static MouseEventArgs ConvertMouse(UIView view, NSSet touches, UIEvent evt)
 {
     if (touches.Count > 0)
     {
         UITouch touch    = touches.ToArray <UITouch> () [0];
         var     location = touch.LocationInView(view);
         return(new MouseEventArgs(MouseButtons.Primary, Key.None, ConvertF(location)));
     }
     return(new MouseEventArgs(MouseButtons.Primary, Key.None, Point.Empty));
 }
Exemplo n.º 30
0
        public CWNetwork [] ScanForNetworksWithName(string networkName, bool includeHidden, out NSError error)
        {
            NSSet networks = _ScanForNetworksWithName(networkName, includeHidden, out error);

            if (networks != null)
            {
                return(networks.ToArray <CWNetwork> ());
            }
            return(null);
        }
Exemplo n.º 31
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);
            DebugLogViewer.WriteLine(string.Format("TouchesEnded"));

            foreach (UITouch touch in touches.ToArray <UITouch>())
            //foreach (UITouch touch in evt.AllTouches.ToArray<UITouch>())
            {
                SendHandlerOnTouchEvent(touch, View, MotionEvent.ACTION_NONE);
            }
        }
 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     var touchArray = touches.ToArray<UITouch>();
     if(touches.Count>0)
     {
         var coord = touchArray[0].LocationInView(touchArray[0].View);
         if(touchArray[0].TapCount < 2)
             StartCoord = coord;
         interactionLabel.Text= string.Format("{0} ({1},{2})", DescribeTouch(touchArray[0]), coord.X, coord.Y);
     }
 }
Exemplo n.º 33
0
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            //Grab touches and update location

            var touch = touches.ToArray <UITouch>()[0];

            location = touch.LocationInView(this);

            //TODO: set background color
            SetNeedsDisplay();
        }
Exemplo n.º 34
0
        public override void TouchesBegan(NSSet touches, UIEvent @event)
        {
            this.trackingTouch = touches.ToArray <UITouch>().FirstOrDefault();
            this.startLocation = this.trackingTouch.LocationInNode(this);
            // Center start location
            this.startLocation.X -= this.Size.Width / 2f;
            this.startLocation.Y -= this.Size.Height / 2f;

            this.UpdateStickPosition(this.trackingTouch.LocationInNode(this));
            this.Delegate.PadOverlayVirtualStickInteractionDidStart(this);
        }
Exemplo n.º 35
0
 public void OpenUrlContexts(UIScene scene, NSSet <UIOpenUrlContext> urlContexts)
 {
     if (urlContexts?.Count > 0)
     {
         var context = urlContexts.ToArray <UIOpenUrlContext>().First();
         if (context != null)
         {
             KRTApp.Application(UIApplication.SharedApplication, context.Url);
         }
     }
 }
        void ProcessTouches(NSSet touches)
        {
            if (ripple == null)
            {
                return;
            }

            foreach (UITouch touch in touches.ToArray <UITouch> ())
            {
                ripple.InitiateRippleAtLocation(touch.LocationInView(touch.View));
            }
        }
Exemplo n.º 37
0
        public TwoFingerGesture(NSSet touches, ARSCNView view, VirtualObject parentObject, VirtualObjectManager manager) : base(touches, view, parentObject, manager)
        {
            var tArray = touches.ToArray <UITouch>();

            FirstTouch  = tArray[0];
            SecondTouch = tArray[1];

            var firstTouchPoint  = FirstTouch.LocationInView(SceneView);
            var secondTouchPoint = SecondTouch.LocationInView(SceneView);

            InitialMidpoint = firstTouchPoint.Add(secondTouchPoint).Divide(2f);

            // Compute the two other corners of the rectangle defined by the two fingers
            // and compute the points in between.
            var thirdCorner  = new CGPoint(firstTouchPoint.X, secondTouchPoint.Y);
            var fourthCorner = new CGPoint(secondTouchPoint.X, firstTouchPoint.Y);

            //  Compute points in between.
            var midpoints = new[]
            {
                thirdCorner.Add(firstTouchPoint).Divide(2f),
                thirdCorner.Add(secondTouchPoint).Divide(2f),
                fourthCorner.Add(firstTouchPoint).Divide(2f),
                fourthCorner.Add(secondTouchPoint).Divide(2f),
                InitialMidpoint.Add(firstTouchPoint).Divide(2f),
                InitialMidpoint.Add(secondTouchPoint).Divide(2f),
                InitialMidpoint.Add(thirdCorner).Divide(2f),
                InitialMidpoint.Add(fourthCorner).Divide(2f)
            };

            // Check if any of the two fingers or their midpoint is touching the object.
            // Based on that, translation, rotation and scale will be enabled or disabled.
            var allPoints = new List <CGPoint>(new[] { firstTouchPoint, secondTouchPoint, thirdCorner, fourthCorner, InitialMidpoint });

            allPoints.AddRange(midpoints);
            FirstTouchedObject = allPoints.Select(pt => this.VirtualObjectAt(pt)).Where(vo => vo != null).FirstOrDefault();

            if (FirstTouchedObject != null)
            {
                ObjectBaseScale  = FirstTouchedObject.Scale.X;
                AllowTranslation = true;
                AllowRotation    = true;
                InitialDistanceBetweenFingers = (firstTouchPoint.Subtract(secondTouchPoint)).Length();
                InitialFingerAngle            = Math.Atan2(InitialMidpoint.X, InitialMidpoint.Y);
                InitialObjectAngle            = FirstTouchedObject.EulerAngles.Y;
            }
            else
            {
                AllowTranslation = false;
                AllowRotation    = false;
            }
        }
Exemplo n.º 38
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            var ts = touches.ToArray <UITouch>();

            foreach (var t in ts)
            {
                _activeTouches.Remove(t.Handle);
            }
            if (_activeTouches.Count == 0)
            {
                _gesture = GestureType.None;
            }
        }
Exemplo n.º 39
0
        private void HandleTouches(NSSet touchesSet)
        {
            var touches = touchesSet.ToArray<UITouch>();

            if (touches != null)
            {
                foreach (var uitouch in touches)
                {
                    var id = uitouch.Handle.ToInt32();
                    var position = NormalizeScreenPosition(CGPointToVector2(uitouch.LocationInView(view)));

                    HandlePointerEvents(id, position, GetState(uitouch));
                }
            }
        }
        public static BarcodeResult[] FindBarcodes(UIImage image)
        {
            if (image == null)
                throw new ArgumentNullException ("image");

            IntPtr result = FindBarcodesInUIImage (image.Handle);
            if (result == IntPtr.Zero)
                return null;

            NSSet aset = new NSSet (result);
            BarcodeResult[] results = aset.ToArray<BarcodeResult> ();
            aset.Dispose ();

            return results;
        }
Exemplo n.º 41
0
		public override void TouchesCancelled (NSSet touches, UIEvent evt)
		{
			if (touches == null)
				return;

			CanvasView.EndTouches (touches, true);
			if (visualizeAzimuth) {
				foreach (var touch in touches.ToArray<UITouch> ())
					ReticleView.Hidden |= touch.Type == UITouchType.Stylus;
			}
		}
Exemplo n.º 42
0
 public override void TouchesMoved(NSSet touches, UIEvent evt)
 {
     XamGame.TouchMove (touches.ToArray<UITouch> () [0].LocationInView (this));
     base.TouchesMoved (touches, evt);
 }
        // Handles the continuation of a touch
        public override void TouchesMoved(NSSet touchesSet, UIEvent evt)
        {
            var touches = touchesSet.ToArray<UITouch> ();
            touchPhaseLabel.Text = "Phase: Touches moved";

            foreach (var touch in touches) {
                // Send to the dispatch touch method, which ensures that the image is moved
                DispatchTouchEvent (touch.View, touch.LocationInView (View));
            }

            // When multiple touches, report the number of touches.
            if (touches.Length > 1) {
                touchTrackingLabel.Text = string.Format ("Tracking {0} touches", touches.Length);
            } else {
                touchTrackingLabel.Text = "Tracking 1 touch";
            }
        }
Exemplo n.º 44
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            try {
                if (!_touchDown) {
                    var touch = touches.ToArray<UITouch> ()[0];
                    if (ActiveArea.Contains (touch.LocationInView (this))) {
                        _touchDown = true;

                        if (!CanCommand ()) {
                            if (Def != null && Def.ComponentType == LcarsComponentType.Gray) {
                                Sounds.PlayNotActive ();
                            }
                            return;
                        }

                        var prevState = _selState;

                        if (prevState == LcarsComp.SelectionState.NotSelected) {
                            if (_def.NeedsDoubleTap) {
                                _selState = LcarsComp.SelectionState.Pending;
                                NSTimer.CreateScheduledTimer (ConfirmWait, delegate {
                                    _selState = LcarsComp.SelectionState.NotSelected;
                                    OnModelChanged ();
                                });
                            } else {
                                _selState = LcarsComp.SelectionState.Selected;
                            }
                        } else {
                            _selState = LcarsComp.SelectionState.Selected;
                        }

                        if (_selState == LcarsComp.SelectionState.Pending) {
                            Sounds.PlayPendingCommand ();
                        } else {
                            if (prevState == LcarsComp.SelectionState.Pending) {
                                Sounds.PlayConfirmPendingCommand ();
                            } else {
                                PlayConfirmCommand ();
                            }
                        }

                        OnModelChanged ();
                    }
                }
            } catch (Exception error) {
                Log.Error (error);
            }
        }
Exemplo n.º 45
0
		// TODO: Review FillTouchCollection
		private void FillTouchCollection (NSSet touches)
		{
			if (touches.Count == 0)
				return;

			TouchCollection collection = TouchPanel.Collection;
			var touchesArray = touches.ToArray<UITouch> ();
			for (int i = 0; i < touchesArray.Length; ++i) {
				var touch = touchesArray [i];

				//Get position touch
				var location = touch.LocationInView (touch.View);
				var position = GetOffsetPosition (new Vector2 (location.X, location.Y), true);
				var id = touch.Handle.ToInt32 ();

				switch (touch.Phase) {
				case UITouchPhase.Stationary:
				case UITouchPhase.Moved:
					collection.Update (id, TouchLocationState.Moved, position);

					if (i == 0) {
						Mouse.State.X = (int) position.X;
						Mouse.State.Y = (int) position.Y;
					}
					break;
				case UITouchPhase.Began:
					collection.Add (id, position);
					if (i == 0) {
						Mouse.State.X = (int) position.X;
						Mouse.State.Y = (int) position.Y;
						Mouse.State.LeftButton = ButtonState.Pressed;
					}
					break;
				case UITouchPhase.Ended	:
					collection.Update (id, TouchLocationState.Released, position);

					if (i == 0) {
						Mouse.State.X = (int) position.X;
						Mouse.State.Y = (int) position.Y;
						Mouse.State.LeftButton = ButtonState.Released;
					}
					break;
				case UITouchPhase.Cancelled:
					collection.Update (id, TouchLocationState.Invalid, position);
					break;
				default:
					break;
				}
			}
		}
Exemplo n.º 46
0
			public override void TouchesEnded (NSSet touches, UIEvent evt)
			{
				TextColor = UIColor.DarkTextColor;

				var t = touches.ToArray<UITouch> ().First ();
				if (Bounds.Contains (t.LocationInView (this))) {
					var ev = TouchUpInside;
					if (ev != null) {
						ev (this, EventArgs.Empty);
					}
				}
			}
Exemplo n.º 47
0
        /// <summary>
        /// Called when a touch gesture is moving.
        /// </summary>
        /// <param name="touches">The touches.</param>
        /// <param name="evt">The event arguments.</param>
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            // it seems to be easier to handle touch events here than using UIPanGesturRecognizer and UIPinchGestureRecognizer
            base.TouchesMoved(touches, evt);

            // convert the touch points to an array
            var ta = touches.ToArray<UITouch>();

            if (ta.Length > 0)
            {
                // get current and previous location of the first touch point
                var t1 = ta[0];
                var l1 = t1.LocationInView(this).ToScreenPoint();
                var pl1 = t1.PreviousLocationInView(this).ToScreenPoint();
                var l = l1;
                var t = l1 - pl1;
                var s = new ScreenVector(1, 1);
                if (ta.Length > 1)
                {
                    // get current and previous location of the second touch point
                    var t2 = ta[1];
                    var l2 = t2.LocationInView(this).ToScreenPoint();
                    var pl2 = t2.PreviousLocationInView(this).ToScreenPoint();
                    var d = l1 - l2;
                    var pd = pl1 - pl2;
                    if (!this.KeepAspectRatioWhenPinching)
                    {
                        var scalex = System.Math.Abs(pd.X) > 0 ? System.Math.Abs(d.X / pd.X) : 1;
                        var scaley = System.Math.Abs(pd.Y) > 0 ? System.Math.Abs(d.Y / pd.Y) : 1;
                        s = new ScreenVector(scalex, scaley);
                    }
                    else
                    {
                        var scale = pd.Length > 0 ? d.Length / pd.Length : 1;
                        s = new ScreenVector(scale, scale);
                    }
                }

                var e = new OxyTouchEventArgs { Position = l, DeltaTranslation = t, DeltaScale = s };
                this.ActualController.HandleTouchDelta(this, e);
            }
        }
Exemplo n.º 48
0
        public override void TouchesMoved(NSSet touchSet, UIEvent evt)
        {
            var touches = touchSet.ToArray<UITouch> ();
            if (touchedCrayon != null) {
                if (touches.All (touch => GetTouchingCrayon (touch) == null))
                    touchedCrayon = null;
                return;
            }

            AddPoint (touches);
        }
Exemplo n.º 49
0
        /// <summary>
        /// Fills the touches.
        /// </summary>
        /// <param name="touches">The touches.</param>
        private void FillTouches(NSSet touches)
        {
            UITouch[] touchArray = touches.ToArray<UITouch>();
            WaveEngine.Adapter.Input.InputManager inputManager = (WaveEngine.Adapter.Input.InputManager)this.adapter.InputManager;

            List<int> movedIds = new List<int>();

            TouchPanelState oldState = inputManager.CurrentState;
            inputManager.CurrentState.Clear();

            for (int i = 0; i < touchArray.Length; i++)
            {
                UITouch touch = touchArray[i];

                // Position is always the same since we rotate the view
                var position = touch.LocationInView(touch.View);
                position.X *= this.ContentScaleFactor;
                position.Y *= this.ContentScaleFactor;

                int touchId = touch.Handle.ToInt32();

                TouchLocationState state;

                // Touch Type
                switch (touch.Phase)
                {
                    case UITouchPhase.Began:
                        state = TouchLocationState.Pressed;
                        break;
                    case UITouchPhase.Ended:
                    case UITouchPhase.Cancelled:
                        state = TouchLocationState.Release;
                        movedIds.Add(touchId);
                        break;
                    case UITouchPhase.Stationary:
                    case UITouchPhase.Moved:
                        state = TouchLocationState.Moved;
                        movedIds.Add(touchId);
                        break;
                    default:
                        state = TouchLocationState.Invalid;
                        break;
                }

                if (state != TouchLocationState.Release)
                {
                    inputManager.CurrentState.AddTouchLocation(touchId, state, (float)position.X, (float)position.Y);
                }
            }

            foreach (TouchLocation location in oldState)
            {
                if ((location.State == TouchLocationState.Moved || location.State == TouchLocationState.Pressed) && !movedIds.Contains(location.Id))
                {
                    inputManager.CurrentState.AddTouchLocation(location.Id, location.State, location.Position.X, location.Position.Y);
                }
            }
        }
Exemplo n.º 50
0
        private void FillTouchCollection(NSSet touches)
        {
            UITouch []touchesArray = touches.ToArray<UITouch>();

            TouchPanel.Collection.Clear();
            TouchPanel.Collection.Capacity = touchesArray.Length;

            for (int i=0; i<touchesArray.Length;i++)
            {
                TouchLocationState state;
                UITouch touch = touchesArray[i];
                switch (touch.Phase)
                {
                    case UITouchPhase.Began	:
                        state = TouchLocationState.Pressed;
                        break;
                    case UITouchPhase.Cancelled	:
                    case UITouchPhase.Ended	:
                        state = TouchLocationState.Released;
                        break;
                    default :
                        state = TouchLocationState.Moved;
                        break;
                }

                TouchLocation tlocation;
                TouchLocation previousTouch;
                if (state != TouchLocationState.Pressed && previousTouches.TryGetValue (touch.Handle, out previousTouch))
                {
                    Vector2 position = new Vector2 (touch.LocationInView (touch.View));
                    Vector2 translatedPosition = position;

                    switch (CurrentOrientation)
                    {
                        case DisplayOrientation.Portrait :
                        {
                            break;
                        }

                        case DisplayOrientation.LandscapeRight :
                        {
                            translatedPosition = new Vector2( ClientBounds.Height - position.Y, position.X );
                            break;
                        }

                        case DisplayOrientation.LandscapeLeft :
                        {
                            translatedPosition = new Vector2( position.Y, ClientBounds.Width - position.X );
                            break;
                        }

                        case DisplayOrientation.PortraitUpsideDown :
                        {
                            translatedPosition = new Vector2( ClientBounds.Width - position.X, ClientBounds.Height - position.Y );
                            break;
                        }
                    }
                    tlocation = new TouchLocation(touch.Handle.ToInt32(), state, translatedPosition, 1.0f, previousTouch.State, previousTouch.Position, previousTouch.Pressure);
                }
                else
                {
                    Vector2 position = new Vector2 (touch.LocationInView (touch.View));
                    Vector2 translatedPosition = position;

                    switch (CurrentOrientation)
                    {
                        case DisplayOrientation.Portrait :
                        {
                            break;
                        }

                        case DisplayOrientation.LandscapeRight :
                        {
                            translatedPosition = new Vector2( ClientBounds.Height - position.Y, position.X );
                            break;
                        }

                        case DisplayOrientation.LandscapeLeft :
                        {
                            translatedPosition = new Vector2( position.Y, ClientBounds.Width - position.X );
                            break;
                        }

                        case DisplayOrientation.PortraitUpsideDown :
                        {
                            translatedPosition = new Vector2( ClientBounds.Width - position.X, ClientBounds.Height - position.Y );
                            break;
                        }
                    }
                    tlocation = new TouchLocation(touch.Handle.ToInt32(), state, translatedPosition, 1.0f);
                }

                TouchPanel.Collection.Add (tlocation);

                if (state != TouchLocationState.Released)
                    previousTouches[touch.Handle] = tlocation;
                else
                    previousTouches.Remove(touch.Handle);
            }
        }
Exemplo n.º 51
0
 public override void TouchesEnded(NSSet touches, UIEvent evt)
 {
     var ts = touches.ToArray<UITouch>();
     foreach (var t in ts) {
         _activeTouches.Remove(t.Handle);
     }
     if (_activeTouches.Count == 0) {
         _gesture = GestureType.None;
     }
 }
Exemplo n.º 52
0
        private void FillTouchCollection(NSSet touches)
        {
            UITouch []touchesArray = touches.ToArray<UITouch>();

            for (int i=0; i < touchesArray.Length;i++)
            {

                //Get IOS touch
                UITouch touch = touchesArray[i];

                //Get position touch
                Vector2 position = new Vector2 (touch.LocationInView (touch.View));
                Vector2 translatedPosition = GetOffsetPosition(position);

                TouchLocation tlocation;
                TouchCollection collection = TouchPanel.Collection;
                int index;
                switch (touch.Phase)
                {
                    case UITouchPhase.Stationary:
                    case UITouchPhase.Moved:
                        index = collection.FindById(touch.Handle.ToInt32(), out tlocation);
                        if (index >= 0)
                        {
                            tlocation.State = TouchLocationState.Moved;
                            tlocation.Position = translatedPosition;
                            collection[index] = tlocation;
                        }
                        break;
                    case UITouchPhase.Began	:
                        tlocation = new TouchLocation(touch.Handle.ToInt32(), TouchLocationState.Pressed, translatedPosition);
                        collection.Add(tlocation);
                        break;
                    case UITouchPhase.Ended	:
                        index = collection.FindById(touch.Handle.ToInt32(), out tlocation);
                        if (index >= 0)
                        {
                            tlocation.State = TouchLocationState.Released;
                            collection[index] = tlocation;
                        }
                        break;
                    default :
                        break;
                }
            }
        }
Exemplo n.º 53
0
 private UITouch GetTouch(NSSet touches)
 {
     var touch = touches.ToArray<UITouch>()[0];
     return touch;
 }
Exemplo n.º 54
0
        public override void TouchesEnded(NSSet touchSet, UIEvent evt)
        {
            if (touchedCrayon != null) {
                foreach (var crayon in Crayons)
                    crayon.Selected = false;
                touchedCrayon.Selected = true;
                swatchSlider.MinimumTrackTintColor = UIColor.FromRGB(touchedCrayon.R/255f, touchedCrayon.G/255f, touchedCrayon.B/255f);

            } else {

                AddPoint (touchSet.ToArray<UITouch> ());
                DrawPoints (Drawing.Context);
                Points.Clear ();
            }
            SetNeedsDisplay ();
        }
Exemplo n.º 55
0
 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     var ts = touches.ToArray<UITouch>();
     foreach (var t in ts) {
         _activeTouches[t.Handle] = t;
     }
 }
Exemplo n.º 56
0
        /******Touches******/
        public override void TouchesBegan(NSSet touchSet, UIEvent evt)
        {
            var touches = touchSet.ToArray<UITouch> ();
            foreach (var touch in touches) {
                touchedCrayon = GetTouchingCrayon (touch);
                if (touchedCrayon != null)
                     return;
            }

            AddPoint (touches);
        }
Exemplo n.º 57
0
        void ProcessTouchChange(NSSet touches)
        {
            var touchesArray = touches.ToArray<UITouch> ();

            for (int i = 0; i < touchesArray.Length; ++i)
            {
                var touch = touchesArray [i];

                //Get position touch
                var location = touch.LocationInView (this);
                var id = touch.Handle.ToInt32 ();
                var phase = touch.Phase;

                // seems to be a problem with mono touch reporting a new touch with
                // the same id across multiple frames.
                if (touchState.Keys.Contains (id) && phase == UITouchPhase.Began)
                {
                    phase = UITouchPhase.Stationary;
                }

                var ts = new iOSTouchState ();
                ts.Handle = id;
                ts.LastUpdated = this.frameCounter;
                ts.Location = location;

                ts.Phase = phase;

                if (phase == UITouchPhase.Began)
                {
                    //Console.WriteLine ("add "+id);
                    touchState.Add (id, ts);
                }
                else
                {
                    if (touchState.ContainsKey (id) )
                    {
                        touchState[id] = ts;

                        if (ts.Phase == UITouchPhase.Began)
                        {
                            ts.Phase = UITouchPhase.Stationary;
                        }

                    }
                    else
                    {
                        throw new Exception ("eerrr???");
                    }
                }
            }

            UpdateRawTouches ();

            changedCount++;
        }
 public override void TouchesEnded(NSSet touchesSet, UIEvent evt)
 {
     touchPhaseLabel.Text = "Phase: Touches ended";
     foreach (var touch in touchesSet.ToArray<UITouch> ()) {
         DispatchTouchEndEvent (touch.View, touch.LocationInView (View));
     }
 }
Exemplo n.º 59
0
		// TODO: Review FillTouchCollection
		private void FillTouchCollection (NSSet touches)
		{
			if (touches.Count == 0)
				return;

			var touchesArray = touches.ToArray<UITouch> ();
			for (int i = 0; i < touchesArray.Length; ++i) {
				var touch = touchesArray [i];

				//Get position touch
				var location = touch.LocationInView (touch.View);
				var position = GetOffsetPosition (new Vector2 ((float)location.X, (float)location.Y), true);
				var id = touch.Handle.ToInt32 ();

				switch (touch.Phase) 
                {
				//case UITouchPhase.Stationary:
				case UITouchPhase.Moved:
					TouchPanel.AddEvent(id, TouchLocationState.Moved, position);					
					break;
				case UITouchPhase.Began:
                    TouchPanel.AddEvent(id, TouchLocationState.Pressed, position);
					break;
				case UITouchPhase.Ended	:
                    TouchPanel.AddEvent(id, TouchLocationState.Released, position);
					break;
				case UITouchPhase.Cancelled:
                    TouchPanel.AddEvent(id, TouchLocationState.Released, position);
					break;
				default:
					break;
				}
			}
		}
Exemplo n.º 60
0
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            var touch = touches.ToArray<UITouch>().First();
            DragInfo drag;
            if (!drags.TryGetValue(touch, out drag))
                return;

            var loc = touch.LocationInView(this);
            var ploc = touch.PreviousLocationInView(this);

            BringSubviewToFront(drag.View);

            var fr = drag.View.Frame;
            fr.X += (loc.X - ploc.X);
            fr.Y += (loc.Y - ploc.Y);
            drag.View.Frame = fr;
        }