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


C# RectF.Contains方法代码示例

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


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

示例1: OnTouchEvent

		//TODO: Step 5 - Subscribe to touch events in the view
        public override bool OnTouchEvent(MotionEvent ev)
        {
            Log.Debug(GetType().FullName, "Number of touches: {0}", ev.PointerCount);

            Log.Debug(GetType().FullName, "Touch Type: {0}", ev.Action);

            float width = _icon.IntrinsicWidth, height = _icon.IntrinsicHeight;

			//TODO: Step 6 - Detect scale events
            _scaleDetector.OnTouchEvent(ev);

            MotionEventActions action = ev.Action & MotionEventActions.Mask;
            int pointerIndex;

            switch (action)
            {
				case MotionEventActions.Down:
					_lastTouchX = ev.GetX ();
					_lastTouchY = ev.GetY ();
					_activePointerId = ev.GetPointerId (0);
                    break;

				case MotionEventActions.Move:
					pointerIndex = ev.FindPointerIndex (_activePointerId);
					float x = ev.GetX (pointerIndex);
					float y = ev.GetY (pointerIndex);

					if (!_scaleDetector.IsInProgress) {
						// Only move the ScaleGestureDetector isn't already processing a gesture.
						float deltaX = x - _lastTouchX;
						float deltaY = y - _lastTouchY;
						_posX += deltaX;
						_posY += deltaY;
						Invalidate ();
					}

					_lastTouchX = x;
					_lastTouchY = y;
                    break;

                case MotionEventActions.Up:
                case MotionEventActions.Cancel:
                    // This events occur when something cancels the gesture (for example the
                    // activity going in the background) or when the pointer has been lifted up.
                    // We no longer need to keep track of the active pointer.
                    _activePointerId = InvalidPointerId;
                    break;

				case MotionEventActions.PointerUp:
                    // We only want to update the last touch position if the the appropriate pointer
                    // has been lifted off the screen.
					pointerIndex = (int)(ev.Action & MotionEventActions.PointerIndexMask) >> (int)MotionEventActions.PointerIndexShift;
					int pointerId = ev.GetPointerId (pointerIndex);
					if (pointerId == _activePointerId) {
						// This was our active pointer going up. Choose a new
						// action pointer and adjust accordingly
						int newPointerIndex = pointerIndex == 0 ? 1 : 0;
						_lastTouchX = ev.GetX (newPointerIndex);
						_lastTouchY = ev.GetY (newPointerIndex);
						_activePointerId = ev.GetPointerId (newPointerIndex);
					}
                    break;
            }

            //Determine if the image is within the touch area
            if (Math.Abs(_scaleFactor - 1.0f) > 0.001) { width *= _scaleFactor; height *= _scaleFactor; }
            var rc = new RectF(_posX, _posY, _posX + width, _posY + height);
            float touchX = ev.GetX(), touchY = ev.GetY();
            bool contains = rc.Contains(touchX, touchY);
            Log.Debug(GetType().FullName, "{0} - ({1},{2}) - CONTAINS: {3}", rc, touchX, touchY, contains);

            return true;
        }
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:74,代码来源:GestureRecognizerView.cs


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