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


C# MotionEvent.GetHistoricalX方法代码示例

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


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

示例1: handleTouch

		//Iterate through the touch history since the last touch event and add them to the path and points list.
		void handleTouch (MotionEvent e)
		{
			float touchX = e.GetX ();
			float touchY = e.GetY ();

			System.Drawing.PointF touch = new System.Drawing.PointF (touchX, touchY);

			resetBounds (touchX, touchY);
			
			for (var i = 0; i < e.HistorySize; i++) {
				float historicalX = e.GetHistoricalX(i);
				float historicalY = e.GetHistoricalY(i);

				System.Drawing.PointF historical = new System.Drawing.PointF (historicalX, historicalY);

				updateBounds (historicalX, historicalY);

				currentPath.LineTo (historicalX, historicalY);
				currentPoints.Add (historical);
			}

			currentPath.LineTo (touchX, touchY);
			currentPoints.Add (touch);
		}
开发者ID:ronrat,项目名称:SignaturePad,代码行数:25,代码来源:SignaturePadView.cs

示例2: OnTouchEvent

        public override bool OnTouchEvent(MotionEvent e)
        {
            if (e.Action == MotionEventActions.Down) {
                CaptureMovementCheck (e);
                return true;
            }
            if (!isTracking && !CaptureMovementCheck (e))
                return true;

            if (e.Action != MotionEventActions.Move || MoveDirectionTest (e))
                velocityTracker.AddMovement (e);

            if (e.Action == MotionEventActions.Move) {
                var x = e.HistorySize > 0 ? e.GetHistoricalX (0) : e.GetX ();
                var traveledDistance = (int)Math.Round (Math.Abs (x - (startX)));
                SetNewOffset (stateBeforeTracking ?
                    MaxOffset - Math.Min (MaxOffset, traveledDistance)
                    : Math.Max (0, traveledDistance));
            } else if (e.Action == MotionEventActions.Up
                && stateBeforeTracking == opened) {
                velocityTracker.ComputeCurrentVelocity (1000, maxFlingVelocity);
                if (Math.Abs (velocityTracker.XVelocity) > minFlingVelocity)
                    SetOpened (!opened);
                else if (!opened && contentOffsetX > MaxOffset / 2)
                    SetOpened (true);
                else if (opened && contentOffsetX < MaxOffset / 2)
                    SetOpened (false);
                else
                    SetOpened (opened);

                preTracking = isTracking = false;
            }

            return true;
        }
开发者ID:howsgame,项目名称:howsgame,代码行数:35,代码来源:FlyOutContainer.cs

示例3: OnTouchEvent

        public override bool OnTouchEvent(MotionEvent ev)
        {
            float x = ev.GetX();
            float y = ev.GetY();

            switch (ev.Action)
            {
                case MotionEventActions.Down:
                    touch_start(x, y);
                    Invalidate();
                    break;

                case MotionEventActions.Move:
                    for (int i = 0, n = ev.HistorySize; i < n; i++)
                    {
                        touch_move(ev.GetHistoricalX(i), ev.GetHistoricalY(i));
                    }
                    touch_move(x, y);
                    Invalidate();
                    break;

                case MotionEventActions.Up:
                    touch_up(x, y);
                    Invalidate();
                    break;
            }
            return true;
        }
开发者ID:phatware,项目名称:WritePadSDK,代码行数:28,代码来源:InkView.cs

示例4: OnTouchOrHoverEvent

			bool OnTouchOrHoverEvent (MotionEvent e, bool isTouch)
			{
				MotionEventButtonState buttonState = e.ButtonState;
				MotionEventButtonState pressedButtons = buttonState & ~mOldButtonState;
				mOldButtonState = buttonState;

				if ((pressedButtons & MotionEventButtonState.Secondary) != 0) {
					// Advance color when the right mouse button or first stylus button
					// is pressed.
					AdvanceColor ();
				}

				PaintMode mode;
				if ((buttonState & MotionEventButtonState.Tertiary) != 0) {
					// Splat paint when the middle mouse button or second stylus button is pressed.
					mode = PaintMode.Splat;
				} else if (isTouch || (buttonState & MotionEventButtonState.Primary) != 0) {
					// Draw paint when touching or if the primary button is pressed.
					mode = PaintMode.Draw;
				} else {
					// Otherwise, do not paint anything.
					return false;
				}

				MotionEventActions action = e.ActionMasked;
				if (action ==  MotionEventActions.Down || action == MotionEventActions.Move
					|| action == MotionEventActions.HoverMove) {
					int N = e.HistorySize;
					int P = e.PointerCount;
					for (int i = 0; i < N; i++) {
						for (int j = 0; j < P; j++) {
							Paint (GetPaintModeForTool (e.GetToolType (j), mode),
								e.GetHistoricalX (j, i),
								e.GetHistoricalY(j, i),
								e.GetHistoricalPressure (j, i),
								e.GetHistoricalTouchMajor (j, i),
								e.GetHistoricalTouchMinor (j, i),
								e.GetHistoricalOrientation (j, i),
								e.GetHistoricalAxisValue (Axis.Distance, j, i),
								e.GetHistoricalAxisValue (Axis.Tilt, j, i));
						}
					}
					for (int j = 0; j < P; j++) {
						Paint (GetPaintModeForTool (e.GetToolType (j), mode),
							e.GetX (j),
							e.GetY (j),
							e.GetPressure (j),
							e.GetTouchMajor (j),
							e.GetTouchMinor (j),
							e.GetOrientation (j),
							e.GetAxisValue (Axis.Distance, j),
							e.GetAxisValue (Axis.Tilt, j));
					}
					mCurX = e.GetX ();
					mCurY = e.GetY ();
				}
				return true;
			}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:58,代码来源:TouchPaint.cs

示例5: OnTrackballEvent

			public override bool OnTrackballEvent (MotionEvent e)
			{
				MotionEventActions action = e.ActionMasked;
				if (action == MotionEventActions.Down) {
					// Advance color when the trackball button is pressed.
					AdvanceColor ();
				}

				if (action == MotionEventActions.Down || action == MotionEventActions.Move) {
					int N = e.HistorySize;
					float scaleX = e.XPrecision * TRACKBALL_SCALE;
					float scaleY = e.YPrecision * TRACKBALL_SCALE;
					for (int i = 0; i < N; i++) {
						MoveTrackball (e.GetHistoricalX (i) * scaleX,
							e.GetHistoricalY (i) * scaleY);
					}
					MoveTrackball (e.GetX () * scaleX, e.GetY () * scaleY);
				}
				return true;
			}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:20,代码来源:TouchPaint.cs

示例6: OnTouchEvent

		public override bool OnTouchEvent (MotionEvent e) {
			var spos = new Vector2 (e.GetX (), _size.Y - e.GetY ());
			var pos = this.NormalizeToViewport (spos);

			switch (e.Action) {
				case MotionEventActions.Down:
					_queue.Enqueue (new Touch (TouchState.Start, pos, spos));
					break;
				case MotionEventActions.Up:
					_queue.Enqueue (new Touch (TouchState.End, pos, spos));
					break;
				case MotionEventActions.Move:
					for (var i = 0; i < e.HistorySize; i++) {
						var shpos = new Vector2 (e.GetHistoricalX (i), _size.Y - e.GetHistoricalY (i));
						var hpos = this.NormalizeToViewport (shpos);
						_queue.Enqueue (new Touch (TouchState.Move, hpos, shpos));
					}
					_queue.Enqueue (new Touch (TouchState.Move, pos, spos));
					break;
				case MotionEventActions.Cancel:
					_queue.Enqueue (new Touch (TouchState.Cancel, pos, spos));
					break;
				default:
					break;
			}
			if (_gestureDetector != null)
				_gestureDetector.OnTouchEvent (e);
			return true;
		}
开发者ID:jpernst,项目名称:GameStack,代码行数:29,代码来源:AndroidGameView.cs


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