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


C# MotionEvent.GetY方法代码示例

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


在下文中一共展示了MotionEvent.GetY方法的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;
        }
开发者ID:Blahfargl,项目名称:Glubenheim,代码行数:34,代码来源:MainActivity.cs

示例2: OnFling

			public bool OnFling (MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
			{
				// Right to left swipe
				if (e1.GetX() - e2.GetX() > MinSwipeDistance
					&& Math.Abs(velocityX) > SwipeThreadsholdVelocity) {
					if (_page.CaptureSwipeRightToLeft)
						_page.OnSwipeRightToLeft ();
				} 
				// Left to right swipe
				else if (e2.GetX() - e1.GetX() > MinSwipeDistance
					&& Math.Abs(velocityX) > SwipeThreadsholdVelocity) {
					if (_page.CaptureSwipeLeftToRight)
						_page.OnSwipeLeftToRight ();
				}

				if (e1.GetY() - e2.GetY() > MinSwipeDistance
					&& Math.Abs(velocityY) > SwipeThreadsholdVelocity) {
					if (_page.CaptureSwipeBottomToTop)
						_page.OnSwipeBottomToTop ();
				} 
				// Left to right swipe
				else if (e2.GetY() - e1.GetY() > MinSwipeDistance
					&& Math.Abs(velocityY) > SwipeThreadsholdVelocity) {
					if (_page.CaptureSwipeTopToBottom)
						_page.OnSwipeTopToBottom ();
				}

				return true;
			}
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:29,代码来源:GesturedPageRenderer.cs

示例3: 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

示例4: CalculateRotation

 private static float CalculateRotation(MotionEvent motionEvent)
 {
     double deltaX = (motionEvent.GetX(0) - motionEvent.GetX(1));
     double deltaY = (motionEvent.GetY(0) - motionEvent.GetY(1));
     var radians = Math.Atan2(deltaY, deltaX);
     return (float) ToDegrees(radians);
 }
开发者ID:JohnPilczak,项目名称:OsmdroidXamarin,代码行数:7,代码来源:RotationGestureDetector.cs

示例5: OnTouchEvent

		public override bool OnTouchEvent (MotionEvent e)
		{
			if (e.Action == MotionEventActions.Move) {
				if (oldX == 0) {
					oldX = (int)e.GetX ();
				}
				if (oldY == 0) {
					oldY = (int)e.GetY ();
				}
				newX = (int)e.GetX ();
				newY = (int)e.GetY ();

				if (newY > oldY + buffer) {
					CurrentDirection = DirectionUp;
				} else if (newY + buffer < oldY) {
					CurrentDirection = DirectionDown;
				} else {
					CurrentDirection = DirectionNone;
				}

				if (newY > oldY + buffer) {
					oldY = (int)e.GetY ();
				} 
				if (newY + buffer < oldY) {
					oldY = (int)e.GetY ();
				}
				oldX = (int)e.GetX ();
			} else if (e.Action == MotionEventActions.Up) {
				oldX = 0;
				oldY = 0;
			}
			return base.OnTouchEvent (e);
		}
开发者ID:Gerhic,项目名称:Need2Park,代码行数:33,代码来源:UIListView.cs

示例6: Detect

 public bool Detect(MotionEvent e)
 {
     switch (e.Action)
     {
         case MotionEventActions.Down:
             this.startX = e.GetX();
             this.startY = e.GetY();
             this.tapPossiable = true;
             break;
         case MotionEventActions.Move:
             if (this.tapPossiable)
             {
                 if (Math.Abs(e.GetX() - this.startX) > this.slop || Math.Abs(e.GetY() - this.startY) > this.slop)
                 {
                     this.tapPossiable = false;
                 }
             }
             break;
         case MotionEventActions.Up:
             if (this.tapPossiable && e.EventTime - e.DownTime < tapTimeout)
             {
                 ((ITapableView)this.owner).WrapedNativeRaiseTap();
             }
             break;
     }
     return false;
 }
开发者ID:evnik,项目名称:UIFramework,代码行数:27,代码来源:TapDetector.cs

示例7: 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

示例8: OnTouchEvent

        public override bool OnTouchEvent(MotionEvent e)
        {
            var action = e.Action;
            switch (action) {
            case MotionEventActions.Down:
                if (e.GetX() < handle.GetX())
                    return false;
                if (currentAnimator != null)
                    currentAnimator.Cancel();
                if (bubble.Visibility == ViewStates.Invisible)
                    showBubble();
                handle.Selected = true;
                setPosition(e.GetY());
                setRecyclerViewPosition(e.GetY());
                return true;

            case MotionEventActions.Move:
                setPosition(e.GetY());
                setRecyclerViewPosition(e.GetY());
                return true;

            case MotionEventActions.Up:
            case MotionEventActions.Cancel:
                handle.Selected = false;
                hideBubble();
                return true;
            }

            return base.OnTouchEvent(e);
        }
开发者ID:dbeattie71,项目名称:FastScroll,代码行数:30,代码来源:FastScroller.cs

示例9: update

        public void update(MotionEvent events)
        {
            if (events == null && lastEvent == null)
                return;

            else if(events == null && lastEvent != null)
                events = lastEvent;
            else
                lastEvent = events;

            //drag drop
            if (events.Action == MotionEventActions.Down)
                _dragging = true;

            else if (events.Action == MotionEventActions.Up)
                _dragging = false;

            if ( _dragging )
            {
                // get the position
                _touchingPoint.X = INIT_X;

                if ((int)events.GetY() < 0)
                    _touchingPoint.Y = 0;
                else if((int)events.GetY() > 179)
                    _touchingPoint.Y = 179;
                else
                    _touchingPoint.Y = (int)events.GetY();
            }

            //determine the percentage of power
            percentage = ((Math.Abs(_touchingPoint.Y - 179) / 179) * 100);
        }
开发者ID:OML,项目名称:OML_Controller,代码行数:33,代码来源:SliderControls.cs

示例10: GetActiveY

 public override float GetActiveY(MotionEvent ev)
 {
     try {
         return ev.GetY(mActivePointerIndex);
     } catch (Exception e) {
         return ev.GetY();
     }
 }
开发者ID:Manne990,项目名称:PhotoViewerTest,代码行数:8,代码来源:EclairGestureDetector.cs

示例11: GetRotation

        private static float GetRotation(MotionEvent e)
        {
            var deltaX = e.GetX(0) - e.GetX(1);
            var deltaY = e.GetY(0) - e.GetY(1);
            var radians = (float)Math.Atan2(deltaY, deltaX);

            return MathHelper.RadiansToDegrees(radians);
        }
开发者ID:mattleibow,项目名称:OpenGlobe,代码行数:8,代码来源:GlobeSurfaceView.cs

示例12: OnDown

 public bool OnDown(MotionEvent e)
 {
     State = GestureRecognizerState.Began;
     _currentTranslation = new Xamarin.Forms.Point (e.GetX (), e.GetY ());
     _currentPoint = new Xamarin.Forms.Point (e.GetX (), e.GetY ());
     _previousPoint = new Xamarin.Forms.Point (e.GetX (), e.GetY ());
     OnGesture ();
     return true;
 }
开发者ID:Pizzajongen,项目名称:TwinTechsFormsLib,代码行数:9,代码来源:NativePanGestureRecognizer.cs

示例13: OnTouchEvent

		public override bool OnTouchEvent (MotionEvent ev)
		{
			_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;
			}
			return true;
		}
开发者ID:Appercode,项目名称:monodroid-samples,代码行数:56,代码来源:GestureRecognizerView.cs

示例14: OnTouchEvent

        public override bool OnTouchEvent(MotionEvent e)
        {
            switch (e.Action) {
            case MotionEventActions.Down:
                lastX = e.GetX ();
                lastY = e.GetY ();
                break;
            case MotionEventActions.Up:
                var diffX = Math.Abs (e.GetX () - lastX);
                var diffY = Math.Abs (e.GetY () - lastY);

                if (diffX > diffY) {
                    if (diffX > 100) {
                        if (ScaleX == 1.0f) {
                            this.Animate ().ScaleX (0.0f).WithEndAction (new Java.Lang.Runnable (() => {
                                textView.Text = cards.Card[counter].Foreign[0].ItemElement.Text;
                                this.Animate ().ScaleX (0.999f);
                            }));
                        } else
                            this.Animate ().ScaleX (0.0f).WithEndAction (new Java.Lang.Runnable (() => {
                                textView.Text = cards.Card[counter].Native[0].ItemElement.Text;
                                this.Animate ().ScaleX (1.00f);
                            }));
                    }
                } else {
                    this.Animate ().ScaleX (0f);
                    this.Animate ().ScaleY (0f);
                    this.Animate ().Alpha (0f).WithEndAction (new Java.Lang.Runnable (() => {
                        counter++;
                        if (counter < cards.Card.Count) {
                            levelView.Level = cards.Card [counter].Level;
                            textView.Text = cards.Card[counter].Native[0].ItemElement.Text;
                            this.TranslationY = 0.0f;
                            this.ScaleX = 0.0f;
                            this.ScaleY = 0.0f;
                            this.Alpha = 1.0f;
                            this.Animate ().ScaleX (1.0f);
                            this.Animate ().ScaleY (1.0f);
                        }
                    }));

                    if (e.GetY () - lastY > 0) {
                        cards.Card [counter].Level++;
                        this.Animate ().TranslationYBy (1000f);
                    } else {
                        cards.Card [counter].Level = 0;
                        this.Animate ().TranslationYBy (-1000f);
                    }
                }
                break;
            default:
                break;
            }

            return true;// base.OnTouchEvent (e);
        }
开发者ID:orzech85,项目名称:Cards,代码行数:56,代码来源:CardLayout.cs

示例15: DispatchTouchEvent

		/**
     * When the user swipes their finger horizontally, dispatch
     * those touch events to the ViewPager. When they swipe
     * vertically, dispatch those touch events to the date or
     * time picker (depending on which page we're currently on).
     *
     * @param event
     */
		public override bool DispatchTouchEvent (MotionEvent e)
		{
			switch (e.Action)
			{
			case MotionEventActions.Down:
				_x1 = e.GetX();
				_y1 = e.GetY();

				break;

			case MotionEventActions.Move:
				_x2 = e.GetX();
				_y2 = e.GetY();

				if (isScrollingHorizontal(_x1, _y1, _x2, _y2))
				{
					// When the user is scrolling the ViewPager horizontally,
					// block the pickers from scrolling vertically.
					return base.DispatchTouchEvent(e);
				}

				break;
			}

			// As long as the ViewPager isn't scrolling horizontally,
			// dispatch the event to the DatePicker or TimePicker,
			// depending on which page the ViewPager is currently on.

			switch (CurrentItem)
			{
			case 0:

				if (_datePicker != null)
					_datePicker.DispatchTouchEvent(e);

				break;

			case 1:

				if (_timePicker != null)
					_timePicker.DispatchTouchEvent(e);

				break;
			}

			// need this for the ViewPager to scroll horizontally at all
			return base.DispatchTouchEvent (e);
		}
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:56,代码来源:CustomViewPager.cs


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