void UpdateReticleView(UITouch touch, bool predicated = false)
        {
            if (touch == null || touch.Type != UITouchType.Stylus)
            {
                return;
            }

            ReticleView.PredictedDotLayer.Hidden  = !predicated;
            ReticleView.PredictedLineLayer.Hidden = !predicated;

            var azimuthAngle      = touch.GetAzimuthAngle(View);
            var azimuthUnitVector = touch.GetAzimuthUnitVector(View);
            var altitudeAngle     = touch.AltitudeAngle;

            if (predicated)
            {
                ReticleView.PredictedAzimuthAngle      = azimuthAngle;
                ReticleView.PredictedAzimuthUnitVector = azimuthUnitVector;
                ReticleView.PredictedAltitudeAngle     = altitudeAngle;
            }
            else
            {
                var location = touch.PreviousLocationInView(View);
                ReticleView.Center                  = location;
                ReticleView.ActualAzimuthAngle      = azimuthAngle;
                ReticleView.ActualAzimuthUnitVector = azimuthUnitVector;
                ReticleView.ActualAltitudeAngle     = altitudeAngle;
            }
        }
Esempio n. 2
0
        public LinePoint(UITouch touch, int sequenceNumber, PointType pointType)
        {
            SequenceNumber = sequenceNumber;
            Type           = touch.Type;
            PointType      = pointType;
            Timestamp      = touch.Timestamp;

            var view = touch.View;

            Location        = touch.LocationInView(view);
            PreciseLocation = touch.GetPreciseLocation(view);
            AzimuthAngle    = touch.GetAzimuthAngle(view);

            EstimatedProperties = touch.EstimatedProperties;
            EstimatedPropertiesExpectingUpdates = touch.EstimatedPropertiesExpectingUpdates;
            AltitudeAngle = touch.AltitudeAngle;
            Force         = (Type == UITouchType.Stylus || touch.Force > 0) ? touch.Force : 1f;

            if (EstimatedPropertiesExpectingUpdates != 0)
            {
                PointType |= PointType.NeedsUpdate;
            }

            EstimationUpdateIndex = touch.EstimationUpdateIndex;
        }
Esempio n. 3
0
        void UpdateReticleView(UITouch touch, bool predicated = false)
        {
            if (touch == null)
            {
                return;
            }

            ReticleView.PredictedDotLayer.Hidden  = !predicated;
            ReticleView.PredictedLineLayer.Hidden = !predicated;

            ReticleView.Center = touch.LocationInView(touch.View);

            var azimuthAngle      = touch.GetAzimuthAngle(touch.View);
            var azimuthUnitVector = touch.GetAzimuthUnitVector(touch.View);
            var altitudeAngle     = touch.AltitudeAngle;

            if (predicated)
            {
                ReticleView.PredictedAzimuthAngle      = azimuthAngle;
                ReticleView.PredictedAzimuthUnitVector = azimuthUnitVector;
                ReticleView.PredictedAzimuthAngle      = altitudeAngle;
            }
            else
            {
                ReticleView.ActualAzimuthAngle      = azimuthAngle;
                ReticleView.ActualAzimuthUnitVector = azimuthUnitVector;
                ReticleView.ActualAzimuthAngle      = altitudeAngle;
            }
        }
Esempio n. 4
0
		public LinePoint (UITouch touch, int sequenceNumber, PointType pointType)
		{
			SequenceNumber = sequenceNumber;
			Type = touch.Type;
			PointType = pointType;

			Timestamp = touch.Timestamp;
			var view = touch.View;
			Location = touch.LocationInView (view);
			PreciseLocation = touch.GetPreciseLocation (view);
			AzimuthAngle = touch.GetAzimuthAngle (view);
			EstimatedProperties = touch.EstimatedProperties;
			EstimatedPropertiesExpectingUpdates = touch.EstimatedPropertiesExpectingUpdates;
			AltitudeAngle = touch.AltitudeAngle;
			Force = (Type == UITouchType.Stylus || touch.Force > 0) ? touch.Force : 1f;

			if (EstimatedPropertiesExpectingUpdates != 0)
				PointType = this.PointType.Add (PointType.NeedsUpdate);

			EstimationUpdateIndex = touch.EstimationUpdateIndex;
		}
		void UpdateReticleView (UITouch touch, bool predicated = false)
		{
			if (touch == null)
				return;

			ReticleView.PredictedDotLayer.Hidden = !predicated;
			ReticleView.PredictedLineLayer.Hidden = !predicated;

			ReticleView.Center = touch.LocationInView (touch.View);

			var azimuthAngle = touch.GetAzimuthAngle (touch.View);
			var azimuthUnitVector = touch.GetAzimuthUnitVector (touch.View);
			var altitudeAngle = touch.AltitudeAngle;

			if (predicated) {
				ReticleView.PredictedAzimuthAngle = azimuthAngle;
				ReticleView.PredictedAzimuthUnitVector = azimuthUnitVector;
				ReticleView.PredictedAzimuthAngle = altitudeAngle;
			} else {
				ReticleView.ActualAzimuthAngle = azimuthAngle;
				ReticleView.ActualAzimuthUnitVector = azimuthUnitVector;
				ReticleView.ActualAzimuthAngle = altitudeAngle;
			}
		}
Esempio n. 6
0
        public bool UpdateWithTouch(UITouch touch)
        {
            if (!touch.EstimationUpdateIndex.IsEqualTo(EstimationUpdateIndex))
            {
                return(false);
            }

            // An array of the touch properties that may be of interest.
            UITouchProperties[] touchProperties =
            {
                UITouchProperties.Location,
                UITouchProperties.Force,
                UITouchProperties.Altitude,
                UITouchProperties.Azimuth
            };

            // Iterate through possible properties.
            foreach (var expectedProperty in touchProperties)
            {
                // If an update to this property is not expected, continue to the next property.
                if (EstimatedPropertiesExpectingUpdates.HasFlag(expectedProperty))
                {
                    continue;
                }

                switch (expectedProperty)
                {
                case UITouchProperties.Force:
                    Force = touch.Force;
                    break;

                case UITouchProperties.Azimuth:
                    AzimuthAngle = touch.GetAzimuthAngle(touch.View);
                    break;

                case UITouchProperties.Altitude:
                    AltitudeAngle = touch.AltitudeAngle;
                    break;

                case UITouchProperties.Location:
                    Location        = touch.LocationInView(touch.View);
                    PreciseLocation = touch.PreviousLocationInView(touch.View);
                    break;
                }

                // Flag that this point now has a 'final' value for this property.
                if (!touch.EstimatedProperties.HasFlag(expectedProperty))
                {
                    EstimatedProperties &= ~expectedProperty;
                }

                // Flag that this point is no longer expecting updates for this property.
                if (!touch.EstimatedPropertiesExpectingUpdates.HasFlag(expectedProperty))
                {
                    EstimatedPropertiesExpectingUpdates &= ~expectedProperty;

                    if (EstimatedPropertiesExpectingUpdates == 0)
                    {
                        PointType &= ~PointType.NeedsUpdate;
                        PointType |= PointType.Updated;
                    }
                }
            }

            return(true);
        }
		void Collect (Stroke stroke, UITouch touch, UIView view, bool coalesced, bool predicted)
		{
			if (view == null)
				throw new ArgumentNullException ();

			// Only collect samples that actually moved in 2D space.
			var location = touch.GetPreciseLocation (view);
			var previousSample = stroke.Samples.LastOrDefault ();
			if (Distance (previousSample?.Location, location) < 0.003)
				return;

			var sample = new StrokeSample {
				Timestamp = touch.Timestamp,
				Location = location,
				Coalesced = coalesced,
				Predicted = predicted
			};
			bool collectForce = touch.Type == UITouchType.Stylus || view.TraitCollection.ForceTouchCapability == UIForceTouchCapability.Available;
			if (collectForce)
				sample.Force = touch.Force;

			if (touch.Type == UITouchType.Stylus) {
				var estimatedProperties = touch.EstimatedProperties;
				sample.EstimatedProperties = estimatedProperties;
				sample.EstimatedPropertiesExpectingUpdates = touch.EstimatedPropertiesExpectingUpdates;
				sample.Altitude = touch.AltitudeAngle;
				sample.Azimuth = touch.GetAzimuthAngle (view);

				if (stroke.Samples.Count == 0 && estimatedProperties.HasFlag (UITouchProperties.Azimuth)) {
					stroke.ExpectsAltitudeAzimuthBackfill = true;
				} else if (stroke.ExpectsAltitudeAzimuthBackfill &&
						   !estimatedProperties.HasFlag (UITouchProperties.Azimuth)) {
					for (int index = 0; index < stroke.Samples.Count; index++) {
						var priorSample = stroke.Samples [index];
						var updatedSample = priorSample;

						if (updatedSample.EstimatedProperties.HasFlag (UITouchProperties.Altitude)) {
							updatedSample.EstimatedProperties &= ~UITouchProperties.Altitude;
							updatedSample.Altitude = sample.Altitude;
						}
						if (updatedSample.EstimatedProperties.HasFlag (UITouchProperties.Azimuth)) {
							updatedSample.EstimatedProperties &= ~UITouchProperties.Azimuth;
							updatedSample.Azimuth = sample.Azimuth;
						}
						stroke.Update (updatedSample, index);
					}
					stroke.ExpectsAltitudeAzimuthBackfill = false;
				}
			}

			if (predicted) {
				stroke.AddPredicted (sample);
			} else {
				var index = stroke.Add (sample);
				if (touch.EstimatedPropertiesExpectingUpdates != 0) {
					outstandingUpdateIndexes [touch.EstimationUpdateIndex] = new StrokeIndex {
						Stroke = stroke,
						Index = index
					};
				}
			}
		}
		void UpdateReticleView (UITouch touch, bool predicated = false)
		{
			if (touch == null || touch.Type != UITouchType.Stylus)
				return;

			ReticleView.PredictedDotLayer.Hidden = !predicated;
			ReticleView.PredictedLineLayer.Hidden = !predicated;

			var azimuthAngle = touch.GetAzimuthAngle (View);
			var azimuthUnitVector = touch.GetAzimuthUnitVector (View);
			var altitudeAngle = touch.AltitudeAngle;

			if (predicated) {
				ReticleView.PredictedAzimuthAngle = azimuthAngle;
				ReticleView.PredictedAzimuthUnitVector = azimuthUnitVector;
				ReticleView.PredictedAltitudeAngle = altitudeAngle;
			} else {
				var location = touch.PreviousLocationInView (View);
				ReticleView.Center = location;
				ReticleView.ActualAzimuthAngle = azimuthAngle;
				ReticleView.ActualAzimuthUnitVector = azimuthUnitVector;
				ReticleView.ActualAltitudeAngle = altitudeAngle;
			}
		}
        void Collect(Stroke stroke, UITouch touch, UIView view, bool coalesced, bool predicted)
        {
            if (view == null)
            {
                throw new ArgumentNullException();
            }

            // Only collect samples that actually moved in 2D space.
            var location       = touch.GetPreciseLocation(view);
            var previousSample = stroke.Samples.LastOrDefault();

            if (Distance(previousSample?.Location, location) < 0.003)
            {
                return;
            }

            var sample = new StrokeSample {
                Timestamp = touch.Timestamp,
                Location  = location,
                Coalesced = coalesced,
                Predicted = predicted
            };
            bool collectForce = touch.Type == UITouchType.Stylus || view.TraitCollection.ForceTouchCapability == UIForceTouchCapability.Available;

            if (collectForce)
            {
                sample.Force = touch.Force;
            }

            if (touch.Type == UITouchType.Stylus)
            {
                var estimatedProperties = touch.EstimatedProperties;
                sample.EstimatedProperties = estimatedProperties;
                sample.EstimatedPropertiesExpectingUpdates = touch.EstimatedPropertiesExpectingUpdates;
                sample.Altitude = touch.AltitudeAngle;
                sample.Azimuth  = touch.GetAzimuthAngle(view);

                if (stroke.Samples.Count == 0 && estimatedProperties.HasFlag(UITouchProperties.Azimuth))
                {
                    stroke.ExpectsAltitudeAzimuthBackfill = true;
                }
                else if (stroke.ExpectsAltitudeAzimuthBackfill &&
                         !estimatedProperties.HasFlag(UITouchProperties.Azimuth))
                {
                    for (int index = 0; index < stroke.Samples.Count; index++)
                    {
                        var priorSample   = stroke.Samples [index];
                        var updatedSample = priorSample;

                        if (updatedSample.EstimatedProperties.HasFlag(UITouchProperties.Altitude))
                        {
                            updatedSample.EstimatedProperties &= ~UITouchProperties.Altitude;
                            updatedSample.Altitude             = sample.Altitude;
                        }
                        if (updatedSample.EstimatedProperties.HasFlag(UITouchProperties.Azimuth))
                        {
                            updatedSample.EstimatedProperties &= ~UITouchProperties.Azimuth;
                            updatedSample.Azimuth              = sample.Azimuth;
                        }
                        stroke.Update(updatedSample, index);
                    }
                    stroke.ExpectsAltitudeAzimuthBackfill = false;
                }
            }

            if (predicted)
            {
                stroke.AddPredicted(sample);
            }
            else
            {
                var index = stroke.Add(sample);
                if (touch.EstimatedPropertiesExpectingUpdates != 0)
                {
                    outstandingUpdateIndexes [touch.EstimationUpdateIndex] = new StrokeIndex {
                        Stroke = stroke,
                        Index  = index
                    };
                }
            }
        }
Esempio n. 10
0
		public bool UpdateWithTouch (UITouch touch)
		{
			if (!touch.EstimationUpdateIndex.IsEqualTo(EstimationUpdateIndex))
				return false;

			// An array of the touch properties that may be of interest.
			UITouchProperties[] touchProperties = {
				UITouchProperties.Location,
				UITouchProperties.Force,
				UITouchProperties.Altitude,
				UITouchProperties.Azimuth
			};

			// Iterate through possible properties.
			foreach (var expectedProperty in touchProperties) {
				// If an update to this property is not expected, continue to the next property.
				if (EstimatedPropertiesExpectingUpdates.HasFlag (expectedProperty))
					continue;

				switch (expectedProperty) {
				case UITouchProperties.Force:
					Force = touch.Force;
					break;
				case UITouchProperties.Azimuth:
					AzimuthAngle = touch.GetAzimuthAngle (touch.View);
					break;
				case UITouchProperties.Altitude:
					AltitudeAngle = touch.AltitudeAngle;
					break;
				case UITouchProperties.Location:
					Location = touch.LocationInView (touch.View);
					PreciseLocation = touch.PreviousLocationInView (touch.View);
					break;
				}

				// Flag that this point now has a 'final' value for this property.
				if (!touch.EstimatedProperties.HasFlag (expectedProperty))
					EstimatedProperties &= ~expectedProperty;

				// Flag that this point is no longer expecting updates for this property.
				if (!touch.EstimatedPropertiesExpectingUpdates.HasFlag (expectedProperty)) {
					EstimatedPropertiesExpectingUpdates &= ~expectedProperty;

					if (EstimatedPropertiesExpectingUpdates == 0) {
						PointType &= ~PointType.NeedsUpdate;
						PointType |= PointType.Updated;
					}
				}
			}

			return true;
		}