public override void TouchesEnded (NSSet touches, UIEvent evt)
		{
			CanvasView.DrawTouches (touches, evt);
			CanvasView.EndTouches (touches, false);

			if (visualizeAzimuth) {
				foreach (var touch in touches.Cast<UITouch> ()) {
					ReticleView.Hidden |= touch.Type == UITouchType.Stylus;
				}
			}
		}
		public override void TouchesBegan (NSSet touches, UIEvent evt)
		{
			CanvasView.DrawTouches (touches, evt);

			if (visualizeAzimuth) {
				foreach (var touch in touches.Cast<UITouch> ()) {
					if (touch.Type != UITouchType.Stylus)
						continue;

					ReticleView.Hidden = false;
					UpdateReticleView (touch);
				}
			}
		}
		public override void TouchesEnded (NSSet touches, UIEvent evt)
		{
			base.TouchesEnded (touches, evt);

			var firstTouch = touches.Cast<UITouch> ().FirstOrDefault ();
			if (firstTouch == null)
				return;

			var pointOfTouch = firstTouch.LocationInView (this);
			pointOfTouch.Y += bottomMargin;

			if (graphLayer.Contains (pointOfTouch))
				editPoint = ProcessTouch (pointOfTouch);

			touchDown = false;
			UpdateFrequenciesAndResonance ();
		}
Beispiel #4
0
        public override void TouchesCancelled(NSSet touches, UIEvent evt)
        {
            base.TouchesCancelled(touches, evt);

            foreach (UITouch touch in touches.Cast <UITouch>())
            {
                long id = touch.Handle.ToInt64();

                if (capture)
                {
                    FireEvent(this, id, TouchActionType.Cancelled, touch, false);
                }
                else if (idToTouchDictionary[id] != null)
                {
                    FireEvent(idToTouchDictionary[id], id, TouchActionType.Cancelled, touch, false);
                }
                idToTouchDictionary.Remove(id);
            }
        }
		public override void TouchesMoved (NSSet touches, UIEvent evt)
		{
			CanvasView.DrawTouches (touches, evt);

			if (visualizeAzimuth) {
				foreach (var touch in touches.Cast<UITouch> ()) {
					if (touch.Type != UITouchType.Stylus)
						continue;

					UpdateReticleView (touch);

					UITouch[] predictedTouches = evt?.GetPredictedTouches (touch);
					UITouch predictedTouch = predictedTouches?.LastOrDefault ();

					if (predictedTouch != null)
						UpdateReticleView (predictedTouch, true);
				}
			}
		}
Beispiel #6
0
        // touches = touches of interest; evt = all touches of type UITouch
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            base.TouchesBegan(touches, evt);

            foreach (UITouch touch in touches.Cast <UITouch>())
            {
                long id = touch.Handle.ToInt64();

                FireEvent(this, id, TouchActionType.Pressed, touch, true);

                if (!idToTouchDictionary.ContainsKey(id))
                {
                    idToTouchDictionary.Add(id, this);
                }
            }

            // Save the setting of the Capture property
            capture = touchEffect.Capture;
        }
Beispiel #7
0
        public void TouchesMoved(NSSet touches, UIEvent evt)
        {
            foreach (UITouch touch in touches.Cast <UITouch>())
            {
                // Add point to path
                _touchDictionary[touch.Handle] = touch.LocationInView(_view);
            }

            if (_currentTouchType == TouchType.OneFingerTouch)
            {
                // where only handling taps, so no need to process this
            }
            if (_currentTouchType == TouchType.TwoFingerTouch)
            {
                var firstViewTouchPoint  = _touchDictionary[_touchList[0]];
                var secondViewTouchPoint = _touchDictionary[_touchList[1]];

                var touchData = new TwoFingerTouch(0, firstViewTouchPoint, secondViewTouchPoint, GestureState.Change);
                TwoFingerTouchEvent(this, new EventArgs <TwoFingerTouch>(touchData));
            }
        }
Beispiel #8
0
        public void TouchesEnded(NSSet touches, UIEvent evt)
        {
            Debug.WriteLine("TouchesEnded: " + touches.Count);
            if (touches.Count == 1 && _currentTouchType == TouchType.OneFingerTouch)
            {
                Debug.WriteLine("TouchesEnded (TouchType.SingleTouch): " + touches.Count);
                if (SingleFingerTouchEvent != null)
                {
                    var touch     = (UITouch)touches.First();
                    var touchData = new SingleFingerTouch(0, touch.LocationInView(_view), GestureState.End);
                    SingleFingerTouchEvent(this, new EventArgs <SingleFingerTouch>(touchData));
                }

                _currentTouchType = TouchType.None;
            }
            if (_currentTouchType == TouchType.TwoFingerTouch)
            {
                if (TwoFingerTouchEvent != null)
                {
                    Debug.WriteLine("TouchesEnded");

                    var firstViewTouchPoint  = _touchDictionary[_touchList[0]];
                    var secondViewTouchPoint = _touchDictionary[_touchList[1]];

                    var touchData = new TwoFingerTouch(0, firstViewTouchPoint, secondViewTouchPoint, GestureState.End);
                    TwoFingerTouchEvent(this, new EventArgs <TwoFingerTouch>(touchData));
                }

                _currentTouchType = TouchType.None;
            }

            foreach (UITouch touch in touches.Cast <UITouch>())
            {
                var handle = touch.Handle;
                _touchDictionary.Remove(handle);
                _touchList.Remove(handle);
            }
            Debug.WriteLine("TouchesEnded: type: " + _currentTouchType);
        }
Beispiel #9
0
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            base.TouchesMoved(touches, evt);

            foreach (UITouch touch in touches.Cast <UITouch>())
            {
                long id = touch.Handle.ToInt64();

                if (capture)
                {
                    FireEvent(this, id, TouchActionType.Moved, touch, true);
                }
                else
                {
                    CheckForBoundaryHop(touch);

                    if (idToTouchDictionary[id] != null)
                    {
                        FireEvent(idToTouchDictionary[id], id, TouchActionType.Moved, touch, true);
                    }
                }
            }
        }
Beispiel #10
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            var firstTouch = touches.Cast <UITouch> ().FirstOrDefault();

            if (firstTouch == null)
            {
                return;
            }

            var pointOfTouch = firstTouch.LocationInView(this);

            pointOfTouch.Y += bottomMargin;

            if (graphLayer.Contains(pointOfTouch))
            {
                editPoint = ProcessTouch(pointOfTouch);
            }

            touchDown = false;
            UpdateFrequenciesAndResonance();
        }
Beispiel #11
0
        public void UpdateEstimatedPropertiesForTouches(NSSet touches)
        {
            foreach (var touch in touches.Cast <UITouch> ())
            {
                bool isPending = false;

                // Look to retrieve a line from `activeLines`. If no line exists, look it up in `pendingLines`.
                Line possibleLine;
                if (!activeLines.TryGetValue(touch, out possibleLine))
                {
                    isPending = pendingLines.TryGetValue(touch, out possibleLine);
                }

                // If no line is related to the touch, return as there is no additional work to do.
                if (possibleLine == null)
                {
                    return;
                }

                CGRect rect;
                if (possibleLine.UpdateWithTouch(touch, out rect))
                {
                    SetNeedsDisplayInRect(rect);
                }

                // If this update updated the last point requiring an update, move the line to the `frozenImage`.
                if (isPending && possibleLine.IsComplete)
                {
                    FinishLine(possibleLine);
                    pendingLines.Remove(touch);
                }
                else
                {
                    CommitLine(possibleLine);
                }
            }
        }
Beispiel #12
0
        public void DrawTouches(NSSet touches, UIEvent evt)
        {
            var updateRect = CGRectNull();

            foreach (var touch in touches.Cast <UITouch> ())
            {
                Line line;

                // Retrieve a line from activeLines. If no line exists, create one.
                if (!activeLines.TryGetValue(touch, out line))
                {
                    line = AddActiveLineForTouch(touch);
                }

                // Remove prior predicted points and update the updateRect based on the removals. The touches
                // used to create these points are predictions provided to offer additional data. They are stale
                // by the time of the next event for this touch.
                updateRect = updateRect.UnionWith(line.RemovePointsWithType(PointType.Predicted));

                // Incorporate coalesced touch data. The data in the last touch in the returned array will match
                // the data of the touch supplied to GetCoalescedTouches
                var coalescedTouches = evt.GetCoalescedTouches(touch) ?? new UITouch[0];
                var coalescedRect    = AddPointsOfType(PointType.Coalesced, coalescedTouches, line);
                updateRect = updateRect.UnionWith(coalescedRect);

                // Incorporate predicted touch data. This sample draws predicted touches differently; however,
                // you may want to use them as inputs to smoothing algorithms rather than directly drawing them.
                // Points derived from predicted touches should be removed from the line at the next event for this touch.
                if (isPredictionEnabled)
                {
                    var predictedTouches = evt.GetPredictedTouches(touch) ?? new UITouch[0];
                    var predictedRect    = AddPointsOfType(PointType.Predicted, predictedTouches, line);
                    updateRect = updateRect.UnionWith(predictedRect);
                }
            }
            SetNeedsDisplayInRect(updateRect);
        }
Beispiel #13
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            base.TouchesBegan(touches, evt);

            foreach (UITouch touch in touches.Cast <UITouch>())
            {
                Polyline polyline = new Polyline
                {
                    Color     = StrokeColor,
                    Thickness = StrokeWidth
                };

                //Alternative

                /*Polyline polyline = new Polyline();
                 * polyline.Color = StrokeColor;
                 * polyline.Thickness = StrokeWidth;
                 */

                polyline.Path.MoveToPoint(touch.LocationInView(this));
                inProgressPolylines.Add(touch.Handle, polyline);
            }
            SetNeedsDisplay();
        }
Beispiel #14
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            foreach (UITouch touch in touches.Cast <UITouch>())
            {
                long id = touch.Handle.ToInt64();

                if (_capture)
                {
                    FireEvent(this, id, TouchActionType.Released, touch, false);
                }
                else
                {
                    CheckForBoundaryHop(touch);

                    if (IdToTouchDictionary.ContainsKey(id))
                    {
                        FireEvent(IdToTouchDictionary[id], id, TouchActionType.Released, touch, false);
                    }
                }
                IdToTouchDictionary.Remove(id);
            }
        }
		HashSet<UITouch> Touches (NSSet touches)
		{
			return new HashSet<UITouch> (touches.Cast<UITouch> ());
		}
		public override void TouchesEstimatedPropertiesUpdated (NSSet touches)
		{
			foreach (var touch in touches.Cast<UITouch> ()) {
				StrokeIndex val;
				if (outstandingUpdateIndexes.TryGetValue (touch.EstimationUpdateIndex.Int32Value, out val)) {
					var stroke = val.Stroke;
					var sampleIndex = val.Index;
					var sample = stroke.Samples [sampleIndex];

					var expectedUpdates = sample.EstimatedPropertiesExpectingUpdates;
					// Only force is reported this way as of iOS 10.0
					if (expectedUpdates.HasFlag (UITouchProperties.Force)) {
						sample.Force = touch.Force;

						// Only remove the estimate flag if the new value isn't estimated as well.
						if (!touch.EstimatedProperties.HasFlag (UITouchProperties.Force))
							sample.EstimatedProperties &= ~UITouchProperties.Force;
					}
					sample.EstimatedPropertiesExpectingUpdates = touch.EstimatedPropertiesExpectingUpdates;

					if (touch.EstimatedPropertiesExpectingUpdates == 0)
						outstandingUpdateIndexes.Remove (sampleIndex);
					stroke.Update (sample, sampleIndex);
				}
			}
		}
Beispiel #17
0
		public void EndTouches (NSSet touches, bool cancel)
		{
			var updateRect = CGRect.Empty;

			foreach (var touch in touches.Cast<UITouch> ()) {
				// Skip over touches that do not correspond to an active line.
				Line line;
				if (!activeLines.TryGetValue (touch, out line))
					continue;

				if (cancel)
					updateRect = updateRect.UnionWith (line.Cancel ());

				if (line.IsComplete) {
					FinishLine (line);
				} else {
					pendingLines.Add (touch, line);
				}
			}

			SetNeedsDisplayInRect (updateRect);
		}
Beispiel #18
0
		public void DrawTouches (NSSet touches, UIEvent evt)
		{
			var updateRect = CGRectNull ();

			foreach (var touch in touches.Cast<UITouch> ()) {
				Line line;

				// Retrieve a line from activeLines. If no line exists, create one.
				if (!activeLines.TryGetValue (touch, out line))
					line = AddActiveLineForTouch (touch);

				// Remove prior predicted points and update the updateRect based on the removals. The touches
				// used to create these points are predictions provided to offer additional data. They are stale
				// by the time of the next event for this touch.
				updateRect = updateRect.UnionWith (line.RemovePointsWithType (PointType.Predicted));

				// Incorporate coalesced touch data. The data in the last touch in the returned array will match
				// the data of the touch supplied to GetCoalescedTouches
				var coalescedTouches = evt.GetCoalescedTouches (touch) ?? new UITouch[0];
				var coalescedRect = AddPointsOfType (PointType.Coalesced, coalescedTouches, line);
				updateRect = updateRect.UnionWith (coalescedRect);

				// Incorporate predicted touch data. This sample draws predicted touches differently; however, 
				// you may want to use them as inputs to smoothing algorithms rather than directly drawing them. 
				// Points derived from predicted touches should be removed from the line at the next event for this touch.
				if (isPredictionEnabled) {
					var predictedTouches = evt.GetPredictedTouches (touch) ?? new UITouch[0];
					var predictedRect = AddPointsOfType (PointType.Predicted, predictedTouches, line);
					updateRect = updateRect.UnionWith (predictedRect);
				}
			}
			SetNeedsDisplayInRect (updateRect);
		}
Beispiel #19
0
		public void EndTouches (NSSet touches, bool cancel)
		{
			var updateRect = CGRectNull ();

			foreach (var touch in touches.Cast<UITouch> ()) {
				// Skip over touches that do not correspond to an active line.
				Line line;
				if (!activeLines.TryGetValue (touch, out line))
					continue;

				// If this is a touch cancellation, cancel the associated line.
				if (cancel)
					updateRect = updateRect.UnionWith (line.Cancel ());

				// If the line is complete (no points needing updates) or updating isn't enabled, move the line to the frozenImage.
				if (line.IsComplete)
					FinishLine (line);
				else
					pendingLines.Add (touch, line);

				// This touch is ending, remove the line corresponding to it from `activeLines`.
				activeLines.Remove (touch);
			}

			SetNeedsDisplayInRect (updateRect);
		}
 /// <summary> Called when the touch has begun </summary>
 /// <param name="touches"></param>
 /// <param name="evt"></param>
 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     base.TouchesBegan(touches, evt);
     AddTouches(touches.Cast <UITouch>(), TouchEvent.Type.PRESS);
 }
Beispiel #21
0
		public void UpdateEstimatedPropertiesForTouches (NSSet touches)
		{
			foreach (var touch in touches.Cast<UITouch> ()) {
				bool isPending = false;

				// Look to retrieve a line from `activeLines`. If no line exists, look it up in `pendingLines`.
				Line possibleLine;
				if (!activeLines.TryGetValue (touch, out possibleLine))
					isPending = pendingLines.TryGetValue (touch, out possibleLine);

				// If no line is related to the touch, return as there is no additional work to do.
				if (possibleLine == null)
					return;

				CGRect rect;
				if (possibleLine.UpdateWithTouch (touch, out rect))
					SetNeedsDisplayInRect (rect);

				// If this update updated the last point requiring an update, move the line to the `frozenImage`.
				if (isPending && possibleLine.IsComplete) {
					FinishLine (possibleLine);
					pendingLines.Remove (touch);
				} else {
					CommitLine (possibleLine);
				}
			}
		}
 /// <summary> Called when the touch has been moved </summary>
 /// <param name="touches"></param>
 /// <param name="evt"></param>
 public override void TouchesMoved(NSSet touches, UIEvent evt)
 {
     base.TouchesMoved(touches, evt);
     AddTouches(touches.Cast <UITouch>(), TouchEvent.Type.MOVE);
 }
Beispiel #23
0
		public void DrawTouches (NSSet touches, UIEvent evt)
		{
			var updateRect = CGRect.Empty;

			foreach (var touch in touches.Cast<UITouch> ()) {
				Line line;

				// Retrieve a line from `activeLines`. If no line exists, create one.
				if (!activeLines.TryGetValue (touch, out line))
					line = AddActiveLineForTouch (touch);
				updateRect = updateRect.UnionWith (line.RemovePointsWithType (PointType.Predicted));

				var coalescedTouches = evt.GetCoalescedTouches (touch) ?? new UITouch[0];
				var coalescedRect = AddPointsOfType (PointType.Coalesced, coalescedTouches, line, updateRect);
				updateRect = updateRect.UnionWith (coalescedRect);

				if (isPredictionEnabled) {
					var predictedTouches = evt.GetPredictedTouches (touch) ?? new UITouch[0];
					var predictedRect = AddPointsOfType (PointType.Predicted, predictedTouches, line, updateRect);
					updateRect = updateRect.UnionWith (predictedRect);
				}
			}
			SetNeedsDisplay ();
//			SetNeedsDisplayInRect (updateRect);
		}
 HashSet <UITouch> Touches(NSSet touches)
 {
     return(new HashSet <UITouch> (touches.Cast <UITouch> ()));
 }
Beispiel #25
0
        public void TouchesBegan(NSSet touches, UIEvent evt)
        {
            Debug.WriteLine("TouchesBegan: " + touches.Count);
            if (touches.Count == 1 && _currentTouchType == TouchType.None)
            {
                _currentTouchType = TouchType.OneFingerTouch;
                var touch          = (UITouch)touches.ElementAt(0);
                var handle         = touch.Handle;
                var viewTouchPoint = touch.LocationInView(_view);
                Debug.WriteLine("TouchesBegan (TouchType.None): " + touches.Count + ", TouchType: " + _currentTouchType + ", Handle: " + handle + ", Point: " + viewTouchPoint);

                _touchDictionary.Add(handle, viewTouchPoint);
                _touchList.Add(handle);
                if (SingleFingerTouchEvent != null)
                {
                    var firstViewTouchPoint = _touchDictionary[_touchList[0]];
                    var touchData           = new SingleFingerTouch(0, firstViewTouchPoint, GestureState.Start);
                    SingleFingerTouchEvent(this, new EventArgs <SingleFingerTouch>(touchData));
                }
            }
            else if (touches.Count == 1 && _currentTouchType == TouchType.OneFingerTouch)
            {
                var touch          = (UITouch)touches.ElementAt(0);
                var handle         = touch.Handle;
                var viewTouchPoint = touch.LocationInView(_view);
                Debug.WriteLine("TouchesBegan: " + touches.Count + ", TouchType.SingleTouch, Handle: " + handle + ", Point: " + viewTouchPoint);
                _touchDictionary.Add(handle, viewTouchPoint);
                _touchList.Add(handle);
                if (SingleFingerTouchEvent != null)
                {
                    var existingViewTouchPoint = _touchDictionary[_touchList[0]];
                    var touchData = new SingleFingerTouch(0, existingViewTouchPoint, GestureState.Cancelled);
                    SingleFingerTouchEvent(this, new EventArgs <SingleFingerTouch>(touchData));
                }
                if (TwoFingerTouchEvent != null)
                {
                    var firstViewTouchPoint  = _touchDictionary[_touchList[0]];
                    var secondViewTouchPoint = _touchDictionary[_touchList[1]];

                    Debug.WriteLine("firstViewTouchPoint: " + firstViewTouchPoint.ToString() + ", secondViewTouchPoint:" + secondViewTouchPoint.ToString());

                    var touchData = new TwoFingerTouch(0, firstViewTouchPoint, secondViewTouchPoint, GestureState.Start);
                    TwoFingerTouchEvent(this, new EventArgs <TwoFingerTouch>(touchData));
                }
                _currentTouchType = TouchType.TwoFingerTouch;
            }
            else if (touches.Count == 2 && _currentTouchType == TouchType.None)
            {
                foreach (UITouch touch in touches.Cast <UITouch>())
                {
                    var handle         = touch.Handle;
                    var viewTouchPoint = touch.LocationInView(_view);
                    _touchDictionary.Add(handle, viewTouchPoint);
                    _touchList.Add(handle);
                }

                if (TwoFingerTouchEvent != null)
                {
                    var firstViewTouchPoint  = _touchDictionary[_touchList[0]];
                    var secondViewTouchPoint = _touchDictionary[_touchList[1]];

                    var touchData = new TwoFingerTouch(0, firstViewTouchPoint, secondViewTouchPoint, GestureState.Start);
                    TwoFingerTouchEvent(this, new EventArgs <TwoFingerTouch>(touchData));
                }
                _currentTouchType = TouchType.TwoFingerTouch;
            }
            else if (_currentTouchType == TouchType.TwoFingerTouch)
            {
                foreach (UITouch touch in touches.Cast <UITouch>())
                {
                    var handle         = touch.Handle;
                    var viewTouchPoint = touch.LocationInView(_view);
                    _touchDictionary.Add(handle, viewTouchPoint);
                    _touchList.Add(handle);
                }

                if (TwoFingerTouchEvent != null)
                {
                    var firstViewTouchPoint  = _touchDictionary[_touchList[0]];
                    var secondViewTouchPoint = _touchDictionary[_touchList[1]];

                    var touchData = new TwoFingerTouch(0, firstViewTouchPoint, secondViewTouchPoint, GestureState.Cancelled);
                    TwoFingerTouchEvent(this, new EventArgs <TwoFingerTouch>(touchData));
                }
                _currentTouchType = TouchType.None;
            }
            Debug.WriteLine("TouchesBegan: type: " + _currentTouchType);
        }
		public override void TouchesCancelled (NSSet touches, UIEvent evt)
		{
			if (touches == null)
				return;

			CanvasView.EndTouches (touches, true);
			if (visualizeAzimuth) {
				foreach (var touch in touches.Cast<UITouch> ())
					ReticleView.Hidden |= touch.Type == UITouchType.Stylus;
			}
		}
 /// <summary> Called when a touch has been cancelled </summary>
 /// <param name="touches"></param>
 /// <param name="evt"></param>
 public override void TouchesCancelled(NSSet touches, UIEvent evt)
 {
     base.TouchesCancelled(touches, evt);
     AddTouches(touches.Cast <UITouch>(), TouchEvent.Type.RELEASE);
 }