当前位置: 首页>>代码示例>>C#>>正文


C# UIEvent.GetPredictedTouches方法代码示例

本文整理汇总了C#中UIEvent.GetPredictedTouches方法的典型用法代码示例。如果您正苦于以下问题:C# UIEvent.GetPredictedTouches方法的具体用法?C# UIEvent.GetPredictedTouches怎么用?C# UIEvent.GetPredictedTouches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIEvent的用法示例。


在下文中一共展示了UIEvent.GetPredictedTouches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawTouches

		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);
		}
开发者ID:xamarin,项目名称:monotouch-samples,代码行数:33,代码来源:CanvasView.cs

示例2: Append

		bool Append (HashSet<UITouch> touches, UIEvent uievent)
		{
			var touchToAppend = trackedTouch;
			if (touchToAppend == null)
				return false;

			// Cancel the stroke recognition if we get a second touch during cancellation period.
			foreach (var touch in touches) {
				if (touch != touchToAppend && (touch.Timestamp - initialTimestamp < cancellationTimeInterval)) {
					State = (State == Possible) ? Failed : Cancelled;
					return false;
				}
			}

			// See if those touches contain our tracked touch. If not, ignore gracefully.
			if (!touches.Contains (touchToAppend))
				return false;

			var coalescedTouches = uievent.GetCoalescedTouches (touchToAppend);
			var lastIndex = coalescedTouches.Length - 1;
			for (var index = 0; index <= lastIndex; index++)
				Collect (Stroke, coalescedTouches [index], CoordinateSpaceView, (index != lastIndex), false);

			if (Stroke.State == StrokeState.Active) {
				var predictedTouches = uievent.GetPredictedTouches (touchToAppend);
				foreach (var touch in predictedTouches)
					Collect (Stroke, touch, CoordinateSpaceView, false, true);
			}
			return true;
		}
开发者ID:xamarin,项目名称:monotouch-samples,代码行数:30,代码来源:StrokeGestureRecognizer.cs

示例3: DrawTouches

		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);
		}
开发者ID:93asad,项目名称:monotouch-samples,代码行数:25,代码来源:CanvasView.cs


注:本文中的UIEvent.GetPredictedTouches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。