Example #1
1
        // 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;
        }
        private void AndroidMap_MapSingleTap(object sender, Android.Views.MotionEvent e)
        {
            PointF     location = new PointF(e.GetX(), e.GetY());
            PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X,
                                                                 location.Y, androidMap.Width, androidMap.Height);

            longitudeLabelView.Text = string.Format("Longitude : {0:N4}", position.X);
            latitudeLabelView.Text  = string.Format("Latitude : {0:N4}", position.Y);

            LayerOverlay         worldOverlay     = (LayerOverlay)androidMap.Overlays["WorldOverlay"];
            FeatureLayer         worldLayer       = (FeatureLayer)worldOverlay.Layers["WorldLayer"];
            LayerOverlay         highlightOverlay = (LayerOverlay)androidMap.Overlays["HighlightOverlay"];
            InMemoryFeatureLayer highlightLayer   = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"];

            worldLayer.Open();
            Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(position, new string[1] {
                "CNTRY_NAME"
            });

            worldLayer.Close();

            highlightLayer.Open();
            highlightLayer.InternalFeatures.Clear();
            if (selectedFeatures.Count > 0)
            {
                highlightLayer.InternalFeatures.Add(selectedFeatures[0]);
            }

            highlightLayer.Close();
            highlightOverlay.Refresh();
        }
			public override void OnLongPress (MotionEvent e)
			{
				base.OnLongPress (e);
				if (activity != null) {
					activity.dismissOverlayView.Show ();
				}
			}
        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;
        }
Example #5
0
        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);
        }
		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;
		}
		public override bool OnInterceptTouchEvent (MotionEvent ev)
		{
			TouchEventArgs eventArgs = new TouchEventArgs (true, ev);
			HandleGenericMotion (this, eventArgs);

			return base.OnInterceptTouchEvent(ev);
		}
        public override bool OnDoubleTap(MotionEvent e)
        {
			Console.WriteLine("sadfssdf");
            m_ScaleImageView.MaxZoomTo((int)e.GetX(), (int)e.GetY());
            m_ScaleImageView.Cutting();
            return true;
        }
Example #9
0
        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);
        }
        public override bool OnTouchEvent(MotionEvent e)
        {
            if (PagerEnabled)
                return base.OnTouchEvent(e);

            return false;
        }
		public override bool OnGenericMotionEvent (MotionEvent e)
		{
			AmazonFireGameController.SetDPad(e.GetAxisValue(Axis.HatX));
			AmazonFireGameController.SetLeftAnalogStick (e.GetAxisValue (Axis.X));

			return true;
		}
Example #12
0
        private void AndroidMapMapSingleTap(object sender, Android.Views.MotionEvent e)
        {
            PointF     location = new PointF(e.GetX(), e.GetY());
            PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X,
                                                                 location.Y, androidMap.Width, androidMap.Height);

            LayerOverlay overlay   = androidMap.Overlays["RoadOverlay"] as LayerOverlay;
            FeatureLayer roadLayer = overlay.Layers["TXlkaA40"] as FeatureLayer;

            LayerOverlay         highlightOverlay = androidMap.Overlays["HighlightOverlay"] as LayerOverlay;
            InMemoryFeatureLayer highlightLayer   = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"];

            roadLayer.Open();
            Collection <Feature> selectedFeatures = roadLayer.QueryTools.GetFeaturesNearestTo(position, GeographyUnit.DecimalDegree, 1, new string[1] {
                "fename"
            });

            roadLayer.Close();

            if (selectedFeatures.Count > 0)
            {
                LineBaseShape lineShape = (LineBaseShape)selectedFeatures[0].GetShape();
                highlightLayer.Open();
                highlightLayer.InternalFeatures.Clear();
                highlightLayer.InternalFeatures.Add(new Feature(lineShape));
                highlightLayer.Close();

                double length        = lineShape.GetLength(GeographyUnit.DecimalDegree, DistanceUnit.Meter);
                string lengthMessage = string.Format(CultureInfo.InvariantCulture, "{0} has a length of {1:F2} meters.", selectedFeatures[0].ColumnValues["fename"].Trim(), length);

                messageLabel.Text = lengthMessage;
                highlightOverlay.Refresh();
            }
        }
        public override bool OnTouchEvent(MotionEvent e)
        {
            //detect any flings
            this.mDetector.OnTouchEvent(e);

            //find the action, get the percent and send to the right master detail
            int action = MotionEventCompat.GetActionMasked(e);
            float percent = 1 - ((Width - e.GetX()) / Width);
            switch (e.Action)
            {
                case MotionEventActions.Down:
                    ((MyMasterDetailPage)Element).doDown(percent);
                    break;
                case MotionEventActions.Up:
                    ((MyMasterDetailPage)Element).doUp(percent);
                    break;
                case MotionEventActions.Move:
                    ((MyMasterDetailPage)Element).doMove(percent);
                    break;
                default:
                    break;
            }

            return base.OnTouchEvent(e);
        }
		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;
		}
Example #15
0
        private void AndroidMap_MapSingleTap(object sender, Android.Views.MotionEvent e)
        {
            PointF     location = new PointF(e.GetX(), e.GetY());
            PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X,
                                                                 location.Y, androidMap.Width, androidMap.Height);

            LayerOverlay worldOverlay = (LayerOverlay)androidMap.Overlays["WorldOverlay"];
            FeatureLayer worldLayer   = (FeatureLayer)worldOverlay.Layers["WorldLayer"];

            LayerOverlay         highlightOverlay = (LayerOverlay)androidMap.Overlays["HighlightOverlay"];
            InMemoryFeatureLayer highlightLayer   = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"];

            worldLayer.Open();
            Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(position, new string[1] {
                "CNTRY_NAME"
            });

            worldLayer.Close();

            highlightLayer.Open();
            highlightLayer.InternalFeatures.Clear();
            if (selectedFeatures.Count > 0)
            {
                AreaBaseShape areaShape = (AreaBaseShape)selectedFeatures[0].GetShape();
                double        area      = areaShape.GetArea(GeographyUnit.DecimalDegree, AreaUnit.SquareKilometers);
                messageTextView.Text = string.Format(CultureInfo.InvariantCulture, "{0} has an area of {1:N0} square kilometers.", selectedFeatures[0].ColumnValues["CNTRY_NAME"].Trim(), area);

                highlightLayer.InternalFeatures.Add(selectedFeatures[0]);
            }
            highlightLayer.Close();
            highlightOverlay.Refresh();
        }
Example #16
0
        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;
        }
Example #17
0
		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;
		}
        public override bool OnInterceptHoverEvent(MotionEvent e)
        {
            if (PagerEnabled)
                return base.OnInterceptHoverEvent(e);

            return false;
        }
Example #19
0
        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;
        }
        public override bool OnInterceptTouchEvent(MotionEvent ev)
        {
            if (PagerEnabled)
                return base.OnInterceptTouchEvent(ev);

            return false;
        }
Example #21
0
 public override bool DispatchTouchEvent(MotionEvent ev)
 {
     var didConsumeTouch = _gestureTouchDispatcher.DispatchTouchEvent (ev);
     //TODO - consider not passing this along?
     var isHandledByNormalRouting = base.DispatchTouchEvent (ev);
     return isHandledByNormalRouting;
 }
        // ---------------------------------------------------------

        #region Private Methods

        private void HandleTouchDown(Android.Views.MotionEvent e)
        {
            // Set values from settings
            _currentPaint.Color       = _formsView.PaintColor.ToAndroid();
            _currentPaint.StrokeWidth = _formsView.LineWidth * _deviceDensity;

            // Init storage for pointers and historical coords
            _pointerIds   = new List <int>();
            _lastPointers = new List <PaintPointer>();

            // Loop all pointers
            for (int i = 0; i < e.PointerCount; i++)
            {
                // Get and store the pointer
                var pointerId = e.GetPointerId(i);

                _pointerIds.Add(pointerId);

                // Get the pointer coords
                var currentPoint = GetPointerCoords(e, pointerId);

                // Store the coord in the historical list
                _lastPointers.Add(new PaintPointer()
                {
                    PointerId = pointerId, Coords = currentPoint
                });

                // Draw the line
                DrawLine(currentPoint, currentPoint);
            }
        }
Example #23
0
        public override bool OnTouchEvent(MotionEvent e)
        {
            //We must tell easter about the touche events
            easter.OnTouchEvent (e);

            return base.OnTouchEvent (e);
        }
Example #24
0
 public override bool DispatchTouchEvent(MotionEvent e)
 {
     TouchingEvent.Execute(this, e);
     base.DispatchTouchEvent(e);
     TouchEvent.Execute(this, e);
     return true;
 }
Example #25
0
 public override bool OnTouchEvent(MotionEvent e)
 {
     var result = base.OnTouchEvent (e);
     if (e.Action == MotionEventActions.Up || e.Action == MotionEventActions.Cancel)
         ApplySnappingRule ();
     return result;
 }
		public override bool OnInterceptTouchEvent(MotionEvent ev)
		{
			bool isShowingPopover = _parent.IsPresented && !MasterDetailPageController.ShouldShowSplitMode;
			if (!_isMaster && isShowingPopover)
				return true;
			return base.OnInterceptTouchEvent(ev);
		}
Example #27
0
 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;
 }
			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;
			}
Example #29
0
		/// <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;
			}
		}
        public override bool OnInterceptTouchEvent(MotionEvent ev)
        {
            if (!allowed) return false;

            switch (ev.Action) 
            {
                case MotionEventActions.Down:
                    mPrevX = MotionEvent.Obtain(ev).RawX;
                    declined = false;
                    break;

                case MotionEventActions.Move:
                    float eventX = ev.RawX;
                    float xDiff = Math.Abs(eventX - mPrevX);

                    if (declined || xDiff > mTouchSlop) 
                    {
                        declined = true;
                        return false;
                    }
                    break;
            }

            return base.OnInterceptTouchEvent(ev);
        }
		public bool OnTouch(View view, MotionEvent motion_event)
		{
			if (FullScreenActivity.AUTO_HIDE) 
				activity.DelayedHide(FullScreenActivity.AUTO_HIDE_DELAY_MILLIS);

			return false;
		}
 public bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
 {
     Console.WriteLine ("Pinch");
     OnGesture ();
     //TODO set the scale
     return true;
 }
Example #33
0
        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;
            }
        }
 public GestureMotionEvent(MotionEvent e)
 {
     _cachedAction = e.Action;
     _cachedX = e.GetX ();
     _cachedY = e.GetY ();
     MotionEvent = e;
 }
Example #35
0
 public static MouseEventArgs ToEto(av.MotionEvent e)
 {
     if (e.Action == av.MotionEventActions.Down)
     {
         return(new MouseEventArgs(MouseButtons.Primary, Keys.None, new PointF(e.GetX(), e.GetY())));
     }
     // Is this correct? It generates a mouse event for pointer-up and cancel actions
     // See the iOS handler as well, which does something similar
     return(new MouseEventArgs(MouseButtons.Primary, Keys.None, Point.Empty));
 }
Example #36
0
        public override bool OnTouchEvent(MotionEvent @event)
        {
            switch (@event.Action)
            {
            case  MotionEventActions.Down:
                touchTime = (DateTime.Now).Ticks;
                float textX        = @event.RawX;
                float textY        = @event.RawY;
                int   distanceLine = (int)GetDisForTwoSpot(coreX, coreY, textX, textY);   //距离中心点之间的直线距离
                if (distanceLine <= roundRadius)
                {
                    //点击的是中心圆;按下点到中心点的距离小于中心园半径,那就是点击中心园了
                    onClickState = -1;
                }
                else if (distanceLine <= Width / 2)
                {
                    //点击的是某个扇形;按下点到中心点的距离大于中心圆半径小于大圆半径,那就是点击某个扇形了
                    float sweepAngle = 360 / roundMenus.Count;     //每个弧形的角度
                    int   angle      = GetRotationBetweenLines(coreX, coreY, textX, textY);
                    //这个angle的角度是从正Y轴开始,而我们的扇形是从正X轴开始,再加上偏移角度,所以需要计算一下
                    angle        = (angle + 360 - 90 - (int)deviationDegree) % 360;
                    onClickState = (int)(angle / sweepAngle);     //根据角度得出点击的是那个扇形
                }
                else
                {
                    //点击了外面
                    onClickState = -2;
                }
                Invalidate();
                break;

            case  MotionEventActions.Up:
                if (((DateTime.Now).Ticks - touchTime) < 300)
                {
                    //点击小于300毫秒算点击
                    IOnClickListener onClickListener = null;
                    if (onClickState == -1)
                    {
                        onClickListener = onCoreClickListener;
                    }
                    else if (onClickState >= 0 && onClickState < roundMenus.Count)
                    {
                        onClickListener = roundMenus[onClickState].onClickListener;
                    }
                    if (onClickListener != null)
                    {
                        onClickListener.OnClick(this);
                    }
                }
                onClickState = -2;
                Invalidate();
                break;
            }
            return(true);
        }
Example #37
0
        public override bool DispatchTouchEvent(Android.Views.MotionEvent e)
        {
            int action = MotionEventCompat.GetActionMasked(e);

            if (StopScrollWhenTouch)
            {
                if ((action == (int)MotionEventActions.Down) && isAutoScroll)
                {
                    isStopByTouch = true;
                    StopAutoScroll();
                }
                else if (e.Action == MotionEventActions.Up && isStopByTouch)
                {
                    StartAutoScroll();
                }
            }

            if (SlideBorderMode == SLIDE_BORDER_MODE_TO_PARENT || SlideBorderMode == SLIDE_BORDER_MODE_CYCLE)
            {
                touchX = e.GetX();
                if (e.Action == MotionEventActions.Down)
                {
                    downX = touchX;
                }
                int          currentItem = CurrentItem;
                PagerAdapter adapter     = Adapter;
                int          pageCount   = adapter == null ? 0 : adapter.Count;
                //current index is first one and slide to right or current index is last one and slide to left.
                //if slide border mode is to parent, then requestDisallowInterceptTouchEvent false.
                //else scroll to last one when current item is first one, scroll to first one when current item is last one.
                if ((currentItem == 0 && downX <= touchX) || (currentItem == pageCount - 1 && downX >= touchX))
                {
                    if (SlideBorderMode == SLIDE_BORDER_MODE_TO_PARENT)
                    {
                        Parent.RequestDisallowInterceptTouchEvent(false);
                    }
                    else
                    {
                        if (pageCount > 1)
                        {
                            SetCurrentItem(pageCount - currentItem - 1, IsBorderAnimation);
                        }
                        Parent.RequestDisallowInterceptTouchEvent(true);
                    }
                    return(base.DispatchTouchEvent(e));
                }
            }
            Parent.RequestDisallowInterceptTouchEvent(true);

            return(base.DispatchTouchEvent(e));
        }
            public bool OnTouch(Views.View v, Views.MotionEvent e)
            {
                if (v is EditText && e.Action == MotionEventActions.Up)
                {
                    EditText editText = (EditText)v;
                    if (e.RawX >= (editText.Right - editText.GetCompoundDrawables()[2].Bounds.Width()))
                    {
                        editText.Text = string.Empty;
                        return(true);
                    }
                }

                return(false);
            }
        private MotionEvent.PointerCoords GetPointerCoords(Android.Views.MotionEvent e, int pointerId)
        {
            // Get the pointer coords
            var pointerIndex = e.FindPointerIndex(pointerId);

            if (pointerIndex < 0)
            {
                return(null);
            }

            var point = new MotionEvent.PointerCoords();

            e.GetPointerCoords(pointerIndex, point);

            return(point);
        }
Example #40
0
 public override bool OnTouchEvent(Android.Views.MotionEvent e)
 {
     if (GetCompoundDrawables() [2] != null)
     {
         if (e.Action == MotionEventActions.Up)
         {
             bool touchable = e.GetX() > (Width
                                          - PaddingRight - mClearDrawable.IntrinsicWidth) &&
                              (e.GetX() < ((Width - PaddingRight)));
             if (touchable)
             {
                 this.Text = "";
             }
         }
     }
     return(base.OnTouchEvent(e));
 }
Example #41
0
 public override bool OnFling(Android.Views.MotionEvent e1, Android.Views.MotionEvent e2, float velocityX, float velocityY)
 {
     if (isScrollingLeft(e1, e2))
     {
         OnKeyDown(Keycode.DpadLeft, null);
     }
     else
     {
         OnKeyDown(Keycode.DpadRight, null);
     }
     if (this.SelectedItemPosition == 0)
     {
         //// 实现后退功能
         this.SetSelection(MainActivity.picture.Length);
     }
     return(false);
 }
        public override bool OnTouchEvent(Android.Views.MotionEvent e)
        {
            if (e.Action == MotionEventActions.Down ||
                e.Action == MotionEventActions.PointerDown ||
                e.Action == MotionEventActions.Pointer1Down ||
                e.Action == MotionEventActions.Pointer2Down ||
                e.Action == MotionEventActions.Pointer3Down)
            {
                HandleTouchDown(e);
            }

            if (e.Action == MotionEventActions.Move)
            {
                HandleTouchMove(e);
            }

            return(true);
        }
Example #43
0
        void HandleUpAction(Android.Views.MotionEvent e)
        {
            int id         = e.GetPointerId(e.ActionIndex);
            var touchIndex = Array.IndexOf(pointerIds, id);

            if (touchIndex < 0)
            {
                return;
            }
            pointerIds[touchIndex] = -1;
            if (touchIndex == 0)
            {
                input.SetKeyState(Key.Mouse0, false);
            }
            var key = (Key)((int)Key.Touch0 + touchIndex);

            input.SetKeyState(key, false);
        }
Example #44
0
        void HandleDownAction(Android.Views.MotionEvent e)
        {
            var touchIndex = Array.IndexOf(pointerIds, -1);

            if (touchIndex < 0)
            {
                return;
            }
            int i = e.ActionIndex;

            pointerIds[touchIndex] = e.GetPointerId(i);
            if (touchIndex == 0)
            {
                input.SetKeyState(Key.Mouse0, true);
            }
            var key = (Key)((int)Key.Touch0 + touchIndex);

            input.SetKeyState(key, true);
        }
Example #45
0
        public override bool OnTouchEvent(Android.Views.MotionEvent e)
        {
            var action = e.ActionMasked;
            var index  = e.ActionIndex;

            Debug.WriteLine($"ACTION:{action}");
            var coords = new MotionEvent.PointerCoords();

            e.GetPointerCoords(index, coords);
            var position = new SKPoint(coords.X, coords.Y);

            if (action == MotionEventActions.Down)
            {
                var current = new Touch()
                {
                    StartPosition = position,
                    Position      = position,
                    State         = TouchState.Began,
                };
                this.touches[index] = current;
                this.view.Touch(new [] { current });
                return(true);
            }
            else if (action == MotionEventActions.Move)
            {
                var current = this.touches[index];
                current.Position = position;
                current.State    = TouchState.Moved;
                this.view.Touch(new[] { current });
                return(true);
            }
            else if (action == MotionEventActions.Cancel || action == MotionEventActions.Up)
            {
                var current = this.touches[index];
                this.touches.Remove(index);
                current.Position = position;
                current.State    = TouchState.Ended;
                this.view.Touch(new[] { current });
                return(true);
            }

            return(base.OnTouchEvent(e));
        }
        public override bool OnTouchEvent(Android.Views.MotionEvent e)
        {
            switch (e.Action)
            {
            case (int)MotionEventActions.Down:
            {
                _lastPoint = new Point(e.RawX, e.RawY);
                break;
            }

            case MotionEventActions.Move:
            {
                Element.UpdateGrid(Context.FromPixels(e.RawX - _lastPoint.X), Context.FromPixels(e.RawY - _lastPoint.Y));
                _lastPoint = new Point(e.RawX, e.RawY);
                break;
            }
            }

            return(true);
        }
Example #47
0
        public override bool OnTouchEvent(Android.Views.MotionEvent e)
        {
            switch (e.Action)
            {
            case MotionEventActions.Down:
                Pressed = true;
                Animate().ScaleX(0.98f).ScaleY(0.98f).Alpha(0.8f).SetDuration(100).SetInterpolator(new DecelerateInterpolator());
                break;

            case MotionEventActions.Up:
                Animate().ScaleX(1.0f).ScaleY(1.0f).Alpha(1.0f).SetDuration(50).SetInterpolator(new BounceInterpolator());
                break;

            case MotionEventActions.Cancel:
                Animate().ScaleX(1.0f).ScaleY(1.0f).Alpha(1.0f).SetDuration(50).
                SetInterpolator(new BounceInterpolator());
                break;
            }
            return(base.OnTouchEvent(e));
        }
Example #48
0
        void HandleMoveActions(Android.Views.MotionEvent e)
        {
            var pc = new Android.Views.MotionEvent.PointerCoords();

            for (int i = 0; i < e.PointerCount; i++)
            {
                int id         = e.GetPointerId(i);
                int touchIndex = Array.IndexOf(pointerIds, id);
                if (touchIndex < 0)
                {
                    continue;
                }
                e.GetPointerCoords(i, pc);
                var position = new Vector2(pc.X, pc.Y);
                input.SetDesktopTouchPosition(touchIndex, position);
                if (touchIndex == 0)
                {
                    input.DesktopMousePosition = position;
                }
            }
        }
        public override bool OnTouchEvent(Android.Views.MotionEvent e)
        {
            int action = MotionEventCompat.GetActionMasked(e);

            switch (action)
            {
            case (int)Android.Views.MotionEventActions.Down:
            {
                _lastPoint = new Point(e.RawX, e.RawY);
                break;
            }

            case (int)Android.Views.MotionEventActions.Move:
            {
                Element.UpdateGrid(Context.FromPixels(e.RawX - _lastPoint.X), Context.FromPixels(e.RawY - _lastPoint.Y));
                _lastPoint = new Point(e.RawX, e.RawY);
                break;
            }
            }
            return(base.OnTouchEvent(e));
        }
Example #50
0
        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);
        }
Example #51
0
        void HandleMoveActions(Android.Views.MotionEvent e)
        {
            var pc = new Android.Views.MotionEvent.PointerCoords();

            for (int i = 0; i < e.PointerCount; i++)
            {
                int id         = e.GetPointerId(i);
                int touchIndex = Array.IndexOf(pointerIds, id);
                if (touchIndex < 0)
                {
                    continue;
                }
                e.GetPointerCoords(i, pc);
                var position = new Vector2(pc.X, pc.Y) * input.ScreenToWorldTransform / Window.Current.PixelScale;
                input.SetTouchPosition(touchIndex, position);
                if (touchIndex == 0)
                {
                    input.MousePosition = position;
                }
            }
        }
        public override bool OnTouchEvent(Android.Views.MotionEvent e)
        {
            switch (e.Action)
            {
            case MotionEventActions.Down:
            case MotionEventActions.Move:
                SetColorFilter(TINT_SELECTOR_COLOR, PorterDuff.Mode.SrcOver);
                PostInvalidate();
                break;

            case MotionEventActions.Up:
            case MotionEventActions.Cancel:
            case MotionEventActions.Outside:
            default:
                ClearColorFilter();
                PostInvalidate();
                break;
            }

            return(base.OnTouchEvent(e));
        }
Example #53
0
        public override bool DispatchTouchEvent(Android.Views.MotionEvent e)
        {
            switch (e.Action)
            {
            case MotionEventActions.Down:
                StartX = e.RawX;
                StartY = e.RawY;
                this.Parent.RequestDisallowInterceptTouchEvent(true);
                break;

            case MotionEventActions.Move:
                if (IsHorizontal * Math.Abs(StartX - e.RawX) < IsHorizontal * Math.Abs(StartY - e.RawY))
                {
                    this.Parent.RequestDisallowInterceptTouchEvent(false);
                }
                break;

            case MotionEventActions.Up:
                this.Parent.RequestDisallowInterceptTouchEvent(false);
                break;
            }
            return(base.DispatchTouchEvent(e));
        }
        private void HandleTouchMove(Android.Views.MotionEvent e)
        {
            // Clone the historical coords
            var lastPointers = _lastPointers.Clone();

            // Reset the historical coords
            _lastPointers = new List <PaintPointer>();

            // Loop all pointers
            foreach (var pointerId in _pointerIds)
            {
                // Get the pointer coords
                var currentPoint = GetPointerCoords(e, pointerId);

                if (currentPoint == null)
                {
                    continue;
                }

                // Get the last (historical) pointer coords
                var lastPoint = lastPointers.FirstOrDefault(l => l.PointerId == pointerId).Coords;

                if (lastPoint == null)
                {
                    lastPoint = currentPoint;
                }

                // Store the coord in the historical list
                _lastPointers.Add(new PaintPointer()
                {
                    PointerId = pointerId, Coords = currentPoint
                });

                // Draw the line
                DrawLine(lastPoint, currentPoint);
            }
        }
Example #55
0
        public override bool OnTouchEvent(Android.Views.MotionEvent e)
        {
            switch (e.ActionMasked)
            {
            case MotionEventActions.Down:
            case MotionEventActions.PointerDown:
                HandleDownAction(e);
                break;

            case MotionEventActions.Up:
            case MotionEventActions.PointerUp:
                HandleUpAction(e);
                break;

            case MotionEventActions.Cancel:
                CancelGesture();
                break;

            case MotionEventActions.Move:
                break;
            }
            HandleMoveActions(e);
            return(true);
        }
        public virtual bool OnTouchEvent(Android.Views.MotionEvent ev)
        {
            switch (ev.Action)
            {
            case MotionEventActions.Down:
            {
                mVelocityTracker = VelocityTracker.Obtain();
                if (null != mVelocityTracker)
                {
                    mVelocityTracker.AddMovement(ev);
                }
                else
                {
                    Log.Info(LOG_TAG, "Velocity tracker is null");
                }

                mLastTouchX = GetActiveX(ev);
                mLastTouchY = GetActiveY(ev);
                mIsDragging = false;
                break;
            }

            case MotionEventActions.Move: {
                float x = GetActiveX(ev);
                float y = GetActiveY(ev);
                float dx = x - mLastTouchX, dy = y - mLastTouchY;

                if (!mIsDragging)
                {
                    // Use Pythagoras to see if drag length is larger than
                    // touch slop
                    mIsDragging = FloatMath.Sqrt((dx * dx) + (dy * dy)) >= mTouchSlop;
                }

                if (mIsDragging)
                {
                    mListener.OnDrag(dx, dy);
                    mLastTouchX = x;
                    mLastTouchY = y;

                    if (null != mVelocityTracker)
                    {
                        mVelocityTracker.AddMovement(ev);
                    }
                }
                break;
            }

            case MotionEventActions.Cancel: {
                // Recycle Velocity Tracker
                if (null != mVelocityTracker)
                {
                    mVelocityTracker.Recycle();
                    mVelocityTracker = null;
                }
                break;
            }

            case MotionEventActions.Up: {
                if (mIsDragging)
                {
                    if (null != mVelocityTracker)
                    {
                        mLastTouchX = GetActiveX(ev);
                        mLastTouchY = GetActiveY(ev);

                        // Compute velocity within the last 1000ms
                        mVelocityTracker.AddMovement(ev);
                        mVelocityTracker.ComputeCurrentVelocity(1000);

                        float vX = mVelocityTracker.GetXVelocity(0), vY = mVelocityTracker
                                                                          .GetYVelocity(0);

                        // If the velocity is greater than minVelocity, call
                        // listener
                        if (Math.Max(Math.Abs(vX), Math.Abs(vY)) >= mMinimumVelocity)
                        {
                            mListener.OnFling(mLastTouchX, mLastTouchY, -vX,
                                              -vY);
                        }
                    }
                }

                // Recycle Velocity Tracker
                if (null != mVelocityTracker)
                {
                    mVelocityTracker.Recycle();
                    mVelocityTracker = null;
                }
                break;
            }
            }

            return(true);
        }
 public override bool OnInterceptTouchEvent(Android.Views.MotionEvent ev)
 {
     return(false);   // base.OnInterceptTouchEvent(ev);
 }
Example #58
0
        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);
//			}
        }
 public override bool OnTouchEvent(Android.Views.MotionEvent e)
 {
     _TapDetector.Detect(e);
     return(base.OnTouchEvent(e));
 }
Example #60
0
 public override bool OnTouchEvent(Views.MotionEvent e)
 {
     Parent.RequestDisallowInterceptTouchEvent(true);
     return(base.OnTouchEvent(e));
 }