本文整理汇总了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;
}