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


C# Android.GetY方法代码示例

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


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

示例1: OnSingleTapConfirmed

        public bool OnSingleTapConfirmed(Android.Views.MotionEvent e)
        {
            if (this.photoViewAttacher == null)
                return false;
            ImageView imageView = photoViewAttacher.GetImageView();
            if (null != photoViewAttacher.GetOnPhotoTapListener ()) {
                RectF displayRect = photoViewAttacher.GetDisplayRect();
                if (null != displayRect) {
                    float x = e.GetX(), y = e.GetY();

                    if (displayRect.Contains(x, y)) {

                        float xResult = (x - displayRect.Left)
                            / displayRect.Width();
                        float yResult = (y - displayRect.Top)
                            / displayRect.Height();

                        photoViewAttacher.GetOnPhotoTapListener().OnPhotoTap(imageView, xResult, yResult);
                        return true;
                    }
                }
            }
            if (null != photoViewAttacher.GetOnViewTapListener()) {
                photoViewAttacher.GetOnViewTapListener().OnViewTap(imageView, e.GetX(), e.GetY());
            }

            return false;
        }
开发者ID:Manne990,项目名称:PhotoViewerTest,代码行数:28,代码来源:DefaultOnDoubleTapListener.cs

示例2: OnDoubleTap

        public bool OnDoubleTap(Android.Views.MotionEvent ev)
        {
            if (photoViewAttacher == null)
                return false;
            try {
                float scale = photoViewAttacher.GetScale();
                float x = ev.GetX();
                float y = ev.GetY();

                if (scale > photoViewAttacher.GetMinimumScale())
                {
                    photoViewAttacher.SetScale(photoViewAttacher.GetMinimumScale(), x, y, true);
                }
                else
                {
                    photoViewAttacher.SetScale(photoViewAttacher.GetMediumScale(), x, y, true);
                }

                /*
                if (scale < photoViewAttacher.GetMediumScale()) {
                    photoViewAttacher.SetScale(photoViewAttacher.GetMediumScale(), x, y, true);
                } else if (scale >= photoViewAttacher.GetMediumScale() && scale < photoViewAttacher.GetMaximumScale()) {
                    photoViewAttacher.SetScale(photoViewAttacher.GetMaximumScale(), x, y, true);
                } else {
                    photoViewAttacher.SetScale(photoViewAttacher.GetMinimumScale(), x, y, true);
                }*/
            } catch (Java.Lang.ArrayIndexOutOfBoundsException e) {
                // Can sometimes happen when getX() and getY() is called
            }

            return true;
        }
开发者ID:Manne990,项目名称:PhotoViewerTest,代码行数:32,代码来源:DefaultOnDoubleTapListener.cs

示例3: OnTouchEvent

		public override bool OnTouchEvent (Android.Views.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;
				default:
					return false;
			}
			Invalidate();
			return true;
		}
开发者ID:CrossGeeks,项目名称:Xamarin.Samples,代码行数:18,代码来源:NativeDrawView.cs

示例4: OnInterceptTouchEvent

		public override bool OnInterceptTouchEvent (Android.Views.MotionEvent ev)
		{
//			
			switch (ev.Action) {
			case MotionEventActions.Down:
				deltaX = 0;
				deltaY = 0;

				lastX = ev.GetX ();
				lastY = ev.GetY ();

				return false;
				break;
			case MotionEventActions.Move:
				float moveX = ev.GetX ();
				float moveY = ev.GetY ();
		
				deltaX += Math.Abs (moveX - lastX);
				deltaY += Math.Abs (moveY - lastY);

				lastX = moveX;
				lastY = moveY;

				if (deltaX > deltaY) {
					return false;
				}
				break;
			case MotionEventActions.Up:
				if (deltaX > deltaY) {
					return false;
				}
				break;
			}

			var test = base.OnInterceptTouchEvent (ev);

			return test;

//			if (x1 == 0)
//				x1 = ev.GetX ();
//
//			if (ev.Action == Android.Views.MotionEventActions.Move) {
//				Console.WriteLine ("x1 = {0}, x2 = {1}", x1, ev.GetX ());
//				x2 = ev.GetX ();
//				counter = counter + Math.Abs (x2 - x1);
//				Console.WriteLine ("New Counter Value = {0}", counter);
//				x1 = x2;
//			}
//
//			if (counter > 100 && ev.Action == Android.Views.MotionEventActions.Up) {
//				Console.WriteLine (ev.Action);
//				Console.WriteLine ("Reset Counter and Return True");
//				counter = 0;
//			}
//
//			Console.WriteLine (ev.Action);
//			Console.WriteLine ("Get X: {0}", ev.GetX());
//
//			if (counter == 0) {
//				return true;
//			} else {
//				return base.OnInterceptTouchEvent (ev);
//			}
		}
开发者ID:ChandrakanthBCK,项目名称:customer-success-samples,代码行数:64,代码来源:ListViewCustomRenderer.cs

示例5: OnTouch

            public bool OnTouch( Android.Views.View v, Android.Views.MotionEvent e )
            {
                Android.Views.MotionEventActions action = e.Action;

                if ( ( action & Android.Views.MotionEventActions.Mask ) != Android.Views.MotionEventActions.Move )
                {
                    TouchPointer tec = new TouchPointer ();

                    switch ( action & Android.Views.MotionEventActions.Mask )
                    {
                        case Android.Views.MotionEventActions.Down:
                            tec = new TouchPointer ( new IntPtr ( e.GetPointerId ( 0 ) ), new Vector2 ( e.GetX (), e.GetY () ), PointerMode.Pressed );
                            break;
                        case Android.Views.MotionEventActions.PointerDown:
                            tec = new TouchPointer ( new IntPtr ( e.GetPointerId ( ( int ) ( action & Android.Views.MotionEventActions.PointerIdMask ) >> ( int ) Android.Views.MotionEventActions.PointerIdShift ) ),
                                                     new Vector2 ( e.GetX (), e.GetY () ), PointerMode.Pressed );
                            break;
                        case Android.Views.MotionEventActions.Up:
                            tec = new TouchPointer ( new IntPtr ( e.GetPointerId ( 0 ) ), new Vector2 ( e.GetX (), e.GetY () ), PointerMode.Released );
                            break;
                        case Android.Views.MotionEventActions.PointerUp:
                            tec = new TouchPointer ( new IntPtr ( e.GetPointerId ( ( int ) ( action & Android.Views.MotionEventActions.PointerIdMask ) >> ( int ) Android.Views.MotionEventActions.PointerIdShift ) ),
                                                    new Vector2 ( e.GetX (), e.GetY () ), PointerMode.Released );
                            break;
                    }

                    bool isChanged = false;
                    for ( int i = 0; i < touchPointers.Count; i++ )
                    {
                        if ( touchPointers [ i ].Id == tec.Id )
                        {
                            touchPointers [ i ] = tec;
                            isChanged = true;
                            break;
                        }
                    }

                    if ( !isChanged )
                        touchPointers.Add ( tec );
                }
                else if ( ( action & Android.Views.MotionEventActions.Mask ) == Android.Views.MotionEventActions.Move )
                {
                    for ( int i = 0; i < e.PointerCount; i++ )
                    {
                        TouchPointer tec = new TouchPointer ( new IntPtr ( e.GetPointerId ( i ) ), new Vector2 ( e.GetX (), e.GetY () ), PointerMode.Moved );
                        touchPointers [ i ] = tec;
                    }
                }

                return true;
            }
开发者ID:Daramkun,项目名称:ProjectLiqueur,代码行数:51,代码来源:TouchPanel.cs


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