本文整理汇总了C#中Android.Views.MotionEvent.SetLocation方法的典型用法代码示例。如果您正苦于以下问题:C# MotionEvent.SetLocation方法的具体用法?C# MotionEvent.SetLocation怎么用?C# MotionEvent.SetLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Views.MotionEvent
的用法示例。
在下文中一共展示了MotionEvent.SetLocation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SwapTouchEvent
private MotionEvent SwapTouchEvent(MotionEvent ev)
{
float width = Width;
float height = Height;
float swappedX = (ev.GetY() / height) * width;
float swappedY = (ev.GetX() / width) * height;
ev.SetLocation(swappedX, swappedY);
return ev;
}
示例2: OnTouchEvent
public override bool OnTouchEvent (MotionEvent e)
{
UpdateSourcePartial();
// The logic below is mostly copied from the parent class, since we
// can't update private mBounds variable.
// http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;
// f=core/java/android/view/TouchDelegate.java;hb=eclair#l98
Rect sourcePartial = mSourcePartial;
View target = mTarget;
int x = (int)e.GetX();
int y = (int)e.GetY();
bool sendToDelegate = false;
bool hit = true;
bool handled = false;
switch (e.Action) {
case MotionEventActions.Down:
if (sourcePartial.Contains(x, y)) {
mDelegateTargeted = true;
sendToDelegate = true;
}
break;
case MotionEventActions.Up:
case MotionEventActions.Move:
sendToDelegate = mDelegateTargeted;
if (sendToDelegate) {
if (!sourcePartial.Contains(x, y)) {
hit = false;
}
}
break;
case MotionEventActions.Cancel:
sendToDelegate = mDelegateTargeted;
mDelegateTargeted = false;
break;
}
if (sendToDelegate) {
if (hit) {
e.SetLocation(target.Width / 2, target.Height / 2);
} else {
e.SetLocation(-1, -1);
}
handled = target.DispatchTouchEvent(e);
}
return handled;
}
示例3: ProcessSingleTouchOutsideMinimap
private void ProcessSingleTouchOutsideMinimap(MotionEvent ev)
{
float x = ev.GetX();
float y = ev.GetY();
float lx = x - touchStartX;
float ly = y - touchStartY;
float l = (float)Math.Sqrt(lx * lx + ly * ly);
float dx = x - touchLastX;
float dy = y - touchLastY;
touchLastX = x;
touchLastY = y;
switch (ev.Action)
{
case MotionEventActions.Down:
touchStartX = x;
touchStartY = y;
touchLastX = x;
touchLastY = y;
scrolling = false;
break;
case MotionEventActions.Move:
if (scrolling || (smoothZoom > 1.0f && l > 30.0f))
{
if (!scrolling)
{
scrolling = true;
ev.Action = MotionEventActions.Cancel;
base.DispatchTouchEvent(ev);
}
smoothZoomX -= dx / zoom;
smoothZoomY -= dy / zoom;
return;
}
break;
case MotionEventActions.Outside:
case MotionEventActions.Up:
// tap
if (l < 30.0f)
{
// check double tap
if (SystemClock.ElapsedRealtime() - lastTapTime < 500)
{
if (smoothZoom == 1.0f)
SmoothZoomTo(maxZoom, x, y);
else
SmoothZoomTo(1.0f, Width / 2.0f, Height / 2.0f);
lastTapTime = 0;
ev.Action = MotionEventActions.Cancel;
base.DispatchTouchEvent(ev);
return;
}
lastTapTime = SystemClock.ElapsedRealtime();
PerformClick();
}
break;
}
ev.SetLocation(zoomX + (x - 0.5f * Width) / zoom, zoomY + (y - 0.5f * Height) / zoom);
try
{
base.DispatchTouchEvent(ev);
}
// Analysis disable once EmptyGeneralCatchClause
catch
{
}
}