本文整理汇总了C#中Android.Views.MotionEvent类的典型用法代码示例。如果您正苦于以下问题:C# MotionEvent类的具体用法?C# MotionEvent怎么用?C# MotionEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MotionEvent类属于Android.Views命名空间,在下文中一共展示了MotionEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTouch
// Check touch position on button
public bool OnTouch(View v, MotionEvent e)
{
switch (e.Action)
{
// Get the x and y position for a touch (always before move)
case MotionEventActions.Down:
old_x = e.GetX ();
old_y = e.GetY ();
Console.WriteLine ("x = " + old_x + " y = " + old_y);
break;
// Get the x and y position difference continously
case MotionEventActions.Move:
// Get the difference between current position and old position
new_x = e.GetX () - old_x;
new_y = e.GetY () - old_y;
// Convert to int, to remove decimal numbers (apparently can't be send through the tcp listener)
int_x = Convert.ToInt32 (new_x);
int_y = Convert.ToInt32 (new_y);
// Convert to string, so it can be send
send_x = Convert.ToString (int_x);
send_y = Convert.ToString (int_y);
// Send x and y position over two messages
Connect (ipAddress, send_x);
Connect (ipAddress, send_y);
// Set old position to current position
old_x = e.GetX ();
old_y = e.GetY ();
break;
}
return true;
}
示例2: UpdateStateByEvent
protected internal override void UpdateStateByEvent(MotionEvent curr)
{
base.UpdateStateByEvent(curr);
MotionEvent prev = mPrevEvent;
mCurrLen = -1;
mPrevLen = -1;
// Previous
float px0 = prev.GetX(0);
float py0 = prev.GetY(0);
float px1 = prev.GetX(1);
float py1 = prev.GetY(1);
float pvx = px1 - px0;
float pvy = py1 - py0;
mPrevFingerDiffX = pvx;
mPrevFingerDiffY = pvy;
// Current
float cx0 = curr.GetX(0);
float cy0 = curr.GetY(0);
float cx1 = curr.GetX(1);
float cy1 = curr.GetY(1);
float cvx = cx1 - cx0;
float cvy = cy1 - cy0;
mCurrFingerDiffX = cvx;
mCurrFingerDiffY = cvy;
}
示例3: OnTouchEvent
public override bool OnTouchEvent(MotionEvent e)
{
if (this.Orientation == Orientation.Vertical)
{
if (!this.Enabled)
{
return false;
}
switch (e.Action)
{
case MotionEventActions.Down:
case MotionEventActions.Move:
case MotionEventActions.Up:
this.Progress = Max - (int)(Max * e.GetY() / Height);
this.OnSizeChanged(Width, Height, 0, 0);
break;
default:
return base.OnTouchEvent(e);
}
return true;
}
return base.OnTouchEvent(e);
}
示例4: OnTouchEvent
public override bool OnTouchEvent(MotionEvent e)
{
bool returnValue = base.OnTouchEvent(e);
// Get the touch position
int x = ((int) e.GetX())/(_blockSize * 5 + StrokeWidthBorder);
int y = ((int) e.GetY())/(_blockSize * 5 + StrokeWidthBorder);
// Lower the value if it is too high
if(x >= Constants.NbProposedPiece/Constants.NbLinePropPiece)
{
x = Constants.NbProposedPiece/Constants.NbLinePropPiece - 1;
}
if(y >= Constants.NbLinePropPiece)
{
y = Constants.NbLinePropPiece - 1;
}
// Get the piece number
int i = x + y * _nbPieceByLine;
if(i >= Constants.NbProposedPiece)
{
i = Constants.NbProposedPiece - 1;
}
// Select the piece
selectPiece(i);
Invalidate();
return returnValue;
}
示例5: OnSingleTapConfirmed
public override bool OnSingleTapConfirmed (MotionEvent e)
{
b.touchPoint = new Point ((int)e.GetX (), (int)e.GetY ());
CommonSampleLibrary.Log.Debug (TAG, "Single tap captured.");
b.Toggle ();
return true;
}
示例6: OnGenericMotionEvent
public override bool OnGenericMotionEvent (MotionEvent e)
{
AmazonFireGameController.SetDPad(e.GetAxisValue(Axis.HatX));
AmazonFireGameController.SetLeftAnalogStick (e.GetAxisValue (Axis.X));
return true;
}
示例7: OnDoubleTap
public override bool OnDoubleTap(MotionEvent e)
{
Console.WriteLine("sadfssdf");
m_ScaleImageView.MaxZoomTo((int)e.GetX(), (int)e.GetY());
m_ScaleImageView.Cutting();
return true;
}
示例8: UpdateStateByEvent
/// <summary>
/// Updates the current state with the given event.
/// </summary>
/// <param name="curr">The current event.</param>
protected override void UpdateStateByEvent (MotionEvent curr)
{
base.UpdateStateByEvent (curr);
MotionEvent prev = _previousEvent;
_currLen = -1;
_prevLen = -1;
if (prev != null && prev.PointerCount > 1 &&
curr.PointerCount > 1) {
// previous
float px0 = prev.GetX (0);
float py0 = prev.GetY (0);
float px1 = prev.GetX (1);
float py1 = prev.GetY (1);
float pvx = px1 - px0;
float pvy = py1 - py0;
_prevFingerDiffX = pvx;
_prevFingerDiffY = pvy;
// current
float cx0 = curr.GetX (0);
float cy0 = curr.GetY (0);
float cx1 = curr.GetX (1);
float cy1 = curr.GetY (1);
float cvx = cx1 - cx0;
float cvy = cy1 - cy0;
_currFingerDiffX = cvx;
_currFingerDiffY = cvy;
}
}
示例9: OnInterceptTouchEvent
public override bool OnInterceptTouchEvent(MotionEvent ev)
{
bool intercept = base.OnInterceptTouchEvent(SwapTouchEvent(ev));
//If not intercept, touch event should not be swapped.
SwapTouchEvent(ev);
return intercept;
}
示例10: OnFling
public bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
{
float dx = e2.GetX() - e1.GetX();
float dy = e2.GetY() - e1.GetY();
if (Math.Abs((int) dx) <= MINIMUM_MOVEMENT_DISTANCE &&
Math.Abs((int) dy) <= MINIMUM_MOVEMENT_DISTANCE)
return false;
Command cmd = null;
if (Math.Abs (dx) > Math.Abs (dy))
{
if (dx > 0)
cmd = new SwipeRightCommand ();
else
cmd = new SwipeLeftCommand ();
}
else
{
if (dy > 0)
cmd = new SwipeDownCommand ();
else
cmd = new SwipeUpCommand ();
}
if (cmd != null)
Easter.AddCommand (cmd);
return false;
}
示例11: OnTouchEvent
public override bool OnTouchEvent(MotionEvent e)
{
if (PagerEnabled)
return base.OnTouchEvent(e);
return false;
}
示例12: OnInterceptTouchEvent
public override bool OnInterceptTouchEvent(MotionEvent ev)
{
if (PagerEnabled)
return base.OnInterceptTouchEvent(ev);
return false;
}
示例13: OnInterceptHoverEvent
public override bool OnInterceptHoverEvent(MotionEvent e)
{
if (PagerEnabled)
return base.OnInterceptHoverEvent(e);
return false;
}
示例14: OnInterceptTouchEvent
public bool OnInterceptTouchEvent (RecyclerView rv, MotionEvent e)
{
// TODO : this part intercep any touch inside recycler
// and delete pending items.
// A better method could be used.
if (e.Action == MotionEventActions.Down) {
var undoAdapter = (IUndoAdapter)rv.GetAdapter ();
View view = GetChildViewUnder (e);
if (view == null) {
undoAdapter.DeleteSelectedItem ();
} else {
int position = recyclerView.GetChildLayoutPosition (view);
if (!undoAdapter.IsUndo (position)) {
undoAdapter.DeleteSelectedItem ();
}
}
}
if (IsEnabled) {
gestureDetector.OnTouchEvent (e);
}
return false;
}
示例15: DispatchTouchEvent
public override bool DispatchTouchEvent(MotionEvent ev)
{
var didConsumeTouch = _gestureTouchDispatcher.DispatchTouchEvent (ev);
//TODO - consider not passing this along?
var isHandledByNormalRouting = base.DispatchTouchEvent (ev);
return isHandledByNormalRouting;
}