Example #1
0
        public PointerPoint GetCurrentPoint(UIElement relativeTo)
        {
            var timestamp   = ToTimeStamp(_nativeTouch.Timestamp);
            var device      = Windows.Devices.Input.PointerDevice.For((Windows.Devices.Input.PointerDeviceType)Pointer.PointerDeviceType);
            var rawPosition = (Point)_nativeTouch.GetPreciseLocation(null);
            var position    = relativeTo == null
                                ? rawPosition
                                : (Point)_nativeTouch.GetPreciseLocation(relativeTo);

            return(new PointerPoint(FrameId, timestamp, device, Pointer.PointerId, rawPosition, position, Pointer.IsInContact, _properties));
        }
Example #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;
        }
Example #3
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;
		}
Example #4
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            UITouch Touch = touches.AnyObject as UITouch;

            if (OpenDropDown != null)
            {
                for (int i = 0; i < OpenDropDown.Items.Count; i++)
                {
                    if (OpenDropDown.Items[i].Frame.Contains(Touch.GetPreciseLocation(View)))
                    {
                        Console.WriteLine("TouchedInside");
                    }
                    else
                    {
                        for (int k = 0; k < OpenDropDown.Items.Count; k++)
                        {
                            OpenDropDown.Items[k].Hidden = true;
                        }
                        OpenDropDown.Scrolled.UserInteractionEnabled = true;
                    }
                }
            }
            Console.WriteLine("Touch");
        }
		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 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
                    };
                }
            }
        }