本文整理汇总了C#中Android.Views.MotionEvent类的典型用法代码示例。如果您正苦于以下问题:C# MotionEvent类的具体用法?C# MotionEvent怎么用?C# MotionEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MotionEvent类属于Android.Views命名空间,在下文中一共展示了MotionEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Blahfargl,项目名称:Glubenheim,代码行数:34,代码来源:MainActivity.cs
示例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;
}
开发者ID:davidlook,项目名称:dropbox-sync-component,代码行数:25,代码来源:TwoFingerGestureDetector.cs
示例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);
}
开发者ID:evnik,项目名称:UIFramework,代码行数:26,代码来源:Slider.Droid.cs
示例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;
}
开发者ID:lea-and-anthony,项目名称:Tetrim,代码行数:32,代码来源:ProposedPieceView.cs
示例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;
}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:7,代码来源:FloatingActionButton.cs
示例6: OnGenericMotionEvent
public override bool OnGenericMotionEvent (MotionEvent e)
{
AmazonFireGameController.SetDPad(e.GetAxisValue(Axis.HatX));
AmazonFireGameController.SetLeftAnalogStick (e.GetAxisValue (Axis.X));
return true;
}
开发者ID:geekish-interlude,项目名称:mobile-samples,代码行数:7,代码来源:MainActivity.cs
示例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;
}
开发者ID:Aranjedeath,项目名称:SpecimenCode,代码行数:7,代码来源:ScaleImageView.cs
示例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;
}
}
开发者ID:JoeCooper,项目名称:ui,代码行数:36,代码来源:TwoFingerGestureDetector.cs
示例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;
}
开发者ID:alexrainman,项目名称:CarouselView,代码行数:7,代码来源:VerticalViewPager.cs
示例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;
}
开发者ID:Redth,项目名称:EggsToGo,代码行数:31,代码来源:GestureRecognizer.cs
示例11: OnTouchEvent
public override bool OnTouchEvent(MotionEvent e)
{
if (PagerEnabled)
return base.OnTouchEvent(e);
return false;
}
开发者ID:RobSchoenaker,项目名称:MonoDroidToolkit,代码行数:7,代码来源:StickyViewPager.cs
示例12: OnInterceptTouchEvent
public override bool OnInterceptTouchEvent(MotionEvent ev)
{
if (PagerEnabled)
return base.OnInterceptTouchEvent(ev);
return false;
}
开发者ID:RobSchoenaker,项目名称:MonoDroidToolkit,代码行数:7,代码来源:StickyViewPager.cs
示例13: OnInterceptHoverEvent
public override bool OnInterceptHoverEvent(MotionEvent e)
{
if (PagerEnabled)
return base.OnInterceptHoverEvent(e);
return false;
}
开发者ID:RobSchoenaker,项目名称:MonoDroidToolkit,代码行数:7,代码来源:StickyViewPager.cs
示例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;
}
开发者ID:eatskolnikov,项目名称:mobile,代码行数:25,代码来源:ItemTouchListener.cs
示例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;
}
开发者ID:deadean,项目名称:TwinTechsFormsLib,代码行数:7,代码来源:MainActivity.cs
示例16: OnTouch
public bool OnTouch(View view, MotionEvent motion_event)
{
if (FullScreenActivity.AUTO_HIDE)
activity.DelayedHide(FullScreenActivity.AUTO_HIDE_DELAY_MILLIS);
return false;
}
开发者ID:assanee,项目名称:monodroid-samples,代码行数:7,代码来源:FullScreenActivity.cs
示例17: OnScroll
public bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
{
Console.WriteLine ("Pinch");
OnGesture ();
//TODO set the scale
return true;
}
开发者ID:Pizzajongen,项目名称:TwinTechsFormsLib,代码行数:7,代码来源:NativePinchGestureRecgonizer.cs
示例18: OnTouchEvent
public override bool OnTouchEvent(MotionEvent e)
{
var touchX = e.GetX();
var touchY = e.GetY();
switch (e.Action)
{
case MotionEventActions.Down:
DrawPath.MoveTo(touchX, touchY);
break;
case MotionEventActions.Move:
DrawPath.LineTo(touchX, touchY);
break;
case MotionEventActions.Up:
DrawCanvas.DrawPath(DrawPath, DrawPaint);
DrawPath.Reset();
break;
default:
return false;
}
Invalidate();
return true;
}
开发者ID:kimuraeiji214,项目名称:Keys,代码行数:25,代码来源:DrawView.cs
示例19: OnTouch
public bool OnTouch(View v, MotionEvent @event)
{
lock (this)
{
TouchEvent touchEvent = touchEventPool.newObject();
switch (@event.Action)
{
case MotionEvent.ACTION_DOWN:
touchEvent.type = TouchEvent.TOUCH_DOWN;
isTouched = true;
break;
case MotionEvent.ACTION_MOVE:
touchEvent.type = TouchEvent.TOUCH_DRAGGED;
isTouched = true;
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
touchEvent.type = TouchEvent.TOUCH_UP;
isTouched = false;
break;
}
touchEvent.x = touchX = (int) (@event.X*scaleX);
touchEvent.y = touchY = (int) (@event.Y*scaleY);
touchEventsBuffer.Add(touchEvent);
return true;
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:29,代码来源:SingleTouchHandler.cs
示例20: OnLongPress
public override void OnLongPress (MotionEvent e)
{
base.OnLongPress (e);
if (activity != null) {
activity.dismissOverlayView.Show ();
}
}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:7,代码来源:MainActivity.cs
注:本文中的Android.Views.MotionEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论