示例#1
0
 void HidePopup(object sender, Android.Views.View.TouchEventArgs e)
 {
     _popupBasePage.HidePopupAction();
 }
示例#2
0
        void OnTouch(object sender, Android.Views.View.TouchEventArgs args)
        {
            // Two object common to all the events
            Android.Views.View senderView  = sender as Android.Views.View;
            MotionEvent        motionEvent = args.Event;

            // Get the pointer index
            int pointerIndex = motionEvent.ActionIndex;

            // Get the id that identifies a finger over the course of its progress
            int id = motionEvent.GetPointerId(pointerIndex);


            senderView.GetLocationOnScreen(twoIntArray);
            Point screenPointerCoords = new Point(twoIntArray[0] + motionEvent.GetX(pointerIndex),
                                                  twoIntArray[1] + motionEvent.GetY(pointerIndex));


            // Use ActionMasked here rather than Action to reduce the number of possibilities
            switch (args.Event.ActionMasked)
            {
            case MotionEventActions.Down:
            case MotionEventActions.PointerDown:
                FireEvent(this, id, TouchActionType.Pressed, screenPointerCoords, true);

                idToEffectDictionary.Add(id, this);

                capture = pclTouchEffect.Capture;
                break;

            case MotionEventActions.Move:
                // Multiple Move events are bundled, so handle them in a loop
                for (pointerIndex = 0; pointerIndex < motionEvent.PointerCount; pointerIndex++)
                {
                    id = motionEvent.GetPointerId(pointerIndex);

                    if (capture)
                    {
                        senderView.GetLocationOnScreen(twoIntArray);

                        screenPointerCoords = new Point(twoIntArray[0] + motionEvent.GetX(pointerIndex),
                                                        twoIntArray[1] + motionEvent.GetY(pointerIndex));

                        FireEvent(this, id, TouchActionType.Moved, screenPointerCoords, true);
                    }
                    else
                    {
                        CheckForBoundaryHop(id, screenPointerCoords);

                        if (idToEffectDictionary[id] != null)
                        {
                            FireEvent(idToEffectDictionary[id], id, TouchActionType.Moved, screenPointerCoords, true);
                        }
                    }
                }
                break;

            case MotionEventActions.Up:
            case MotionEventActions.Pointer1Up:
                if (capture)
                {
                    FireEvent(this, id, TouchActionType.Released, screenPointerCoords, false);
                }
                else
                {
                    CheckForBoundaryHop(id, screenPointerCoords);

                    if (idToEffectDictionary[id] != null)
                    {
                        FireEvent(idToEffectDictionary[id], id, TouchActionType.Released, screenPointerCoords, false);
                    }
                }
                idToEffectDictionary.Remove(id);
                break;

            case MotionEventActions.Cancel:
                if (capture)
                {
                    FireEvent(this, id, TouchActionType.Cancelled, screenPointerCoords, false);
                }
                else
                {
                    if (idToEffectDictionary[id] != null)
                    {
                        FireEvent(idToEffectDictionary[id], id, TouchActionType.Cancelled, screenPointerCoords, false);
                    }
                }
                idToEffectDictionary.Remove(id);
                break;
            }
        }
示例#3
0
        void _view_Touch(object sender, Android.Views.View.TouchEventArgs e)
        {
            _gestureDetector.OnTouchEvent(e.Event);

            e.Handled = false;
        }
示例#4
0
 void HideMenu(object sender, Android.Views.View.TouchEventArgs e)
 {
     _basePage.HideMenuAction();
 }
 void TouchEvent(object sender, Android.Views.View.TouchEventArgs e)
 {
     NotifyTextPosition();
     e.Handled = false;
 }
 //Shared handler functions
 private Point GetPoint(Android.Views.View.TouchEventArgs args, int index)
 {
     MotionEvent.PointerCoords temp = new MotionEvent.PointerCoords();
     args.Event.GetPointerCoords(index, temp);
     return(new Point(temp.X, temp.Y));
 }
示例#7
0
        protected virtual void OnHeaderTouch(object sender, Android.Views.View.TouchEventArgs e)
        {
            Android.Widget.ListView listView = null;
            Android.Views.View      header   = null;

            try
            {
                var listViewRenderer = (Xamarin.Forms.Platform.Android.ViewRenderer <Xamarin.Forms.ListView, Android.Widget.ListView>)parallaxControl.CurrentListView.GetRenderer();
                listView = listViewRenderer.Control;
                header   = (Android.Views.View)parallaxControl.HeaderControl.GetRenderer();
                GenerateHeader(header);
            }
            catch (Exception ex)
            {
                return;
            }

            var evt = e.Event;

            //var eventConsumed = false;

            if (listView != null && header != null)
            {
                MotionEvent ev = MotionEvent.Obtain(
                    evt.DownTime,
                    evt.EventTime,
                    evt.Action,
                    evt.GetX(),
                    evt.GetY() + header.TranslationY,
                    evt.Pressure, evt.Size, evt.MetaState, evt.XPrecision, evt.YPrecision, evt.DeviceId, evt.EdgeFlags);
                var d = listView.DispatchTouchEvent(ev);
                //return;
                //switch (evt.Action)
                //{
                //    case MotionEventActions.Move:
                //        if (!downEventDispatched)
                //        {
                //            // if moving, create a fake down event for the scrollingView to start the scroll.
                //            // the y of the touch in the scrolling view is the y coordinate of the touch in the
                //            // header + the translation of the header
                //            MotionEvent downEvent = MotionEvent.Obtain(
                //                evt.DownTime - 1,
                //                evt.EventTime - 1,
                //                MotionEventActions.Down,
                //                evt.GetX(),
                //                evt.GetY() + header.TranslationY,
                //                evt.Pressure, evt.Size, evt.MetaState, evt.XPrecision, evt.YPrecision, evt.DeviceId, evt.EdgeFlags);
                //            //evt.Action = MotionEventActions.Down;
                //            listView.DispatchTouchEvent(downEvent);
                //            //  listView.DispatchTouchEvent(downEvent);
                //            downEventDispatched = true;
                //        }

                //        // dispatching the move event. we need to create a fake motionEvent using a different y
                //        // coordinate related to the scrolling view
                //        //MotionEvent moveEvent = MotionEvent.Obtain(
                //        //    evt.DownTime,
                //        //    evt.EventTime,
                //        //    MotionEventActions.Move,
                //        //    evt.GetX(),
                //        //    evt.GetY() + header.TranslationY,
                //        //    0);
                //        MotionEvent moveEvent = MotionEvent.Obtain(
                //               evt.DownTime,
                //               evt.EventTime,
                //               MotionEventActions.Move,
                //               evt.GetX(),
                //               evt.GetY() + header.TranslationY,
                //               evt.Pressure, evt.Size, evt.MetaState, evt.XPrecision, evt.YPrecision, evt.DeviceId, evt.EdgeFlags);
                //        //evt.Action = MotionEventActions.Down;
                //        listView.DispatchTouchEvent(moveEvent);
                //        //evt.Action = MotionEventActions.Move;
                //        //listView.DispatchTouchEvent(evt);
                //        //listView.DispatchTouchEvent(moveEvent);
                //        break;
                //    case MotionEventActions.Up:

                //        // when action up, dispatch an action cancel to avoid a possible click
                //        //MotionEvent cancelEvent = MotionEvent.Obtain(
                //        //    evt.DownTime,
                //        //    evt.EventTime,
                //        //    MotionEventActions.Cancel,
                //        //    evt.GetX(),
                //        //    evt.GetY(),
                //        //    0);
                //        evt.Action = MotionEventActions.Cancel;
                //        listView.DispatchTouchEvent(evt);
                //        //listView.DispatchTouchEvent(cancelEvent);
                //        downEventDispatched = false;
                //        break;
                //    case MotionEventActions.Cancel:
                //        listView.DispatchTouchEvent(evt);
                //        downEventDispatched = false;
                //        break;
                //}

                //eventConsumed = true;
            }

            // e.Handled = eventConsumed;
        }
示例#8
0
        private void OnTouch(object sender, Android.Views.View.TouchEventArgs args)
        {
            // Two object common to all the events
            Android.Views.View senderView  = sender as Android.Views.View;
            MotionEvent        motionEvent = args.Event;
            // Get the pointer index
            int pointerIndex = motionEvent.ActionIndex;

            // Get the id that identifies a finger over the course of its progress
            int id = motionEvent.GetPointerId(pointerIndex);

            senderView.GetLocationOnScreen(twoIntArray);
            Point screenPointerCoords = new Point(twoIntArray[0] + motionEvent.GetX(pointerIndex),
                                                  twoIntArray[1] + motionEvent.GetY(pointerIndex));

            // Use ActionMasked here rather than Action to reduce the number of possibilities
            switch (args.Event.ActionMasked)
            {
            case MotionEventActions.Down:
            case MotionEventActions.PointerDown:
                Console.WriteLine("GridBuuttonRenderer");

                //CrossWordDrawLineViewModel.touchPressed = new SKPoint(twoIntArray[0] + motionEvent.GetX(pointerIndex),
                //twoIntArray[1] + motionEvent.GetY(pointerIndex));

                CrossWordDrawLineViewModel.changeLineColor = false;
                CrossWordDrawLineViewModel.changeLineColorMethod();
                CrossWordDrawLineViewModel.touchPressed = GetPressedViewCenterPoint(senderView);

                FireEvent(this, id, TouchActionType.Pressed, screenPointerCoords, true);

                idToEffectDictionary.Add(id, this);

                capture = libTouchEffect.Capture;
                break;

            case MotionEventActions.Move:
                // Multiple Move events are bundled, so handle them in a loop
                for (pointerIndex = 0; pointerIndex < motionEvent.PointerCount; pointerIndex++)
                {
                    id = motionEvent.GetPointerId(pointerIndex);

                    if (capture)
                    {
                        senderView.GetLocationOnScreen(twoIntArray);


                        screenPointerCoords = new Point(twoIntArray[0] + motionEvent.GetX(pointerIndex),
                                                        twoIntArray[1] + motionEvent.GetY(pointerIndex));

                        FireEvent(this, id, TouchActionType.Moved, screenPointerCoords, true);
                    }
                    else
                    {
                        CrossWordDrawLineViewModel.changeLineColor = false;
                        CheckForBoundaryHop(id, screenPointerCoords);
                        new MessageCenterHelper().SendMessageMenu(null);

                        if (idToEffectDictionary[id] != null)
                        {
                            FireEvent(idToEffectDictionary[id], id, TouchActionType.Moved, screenPointerCoords, true);
                        }
                    }
                }
                break;

            case MotionEventActions.Up:
            case MotionEventActions.Pointer1Up:
                if (capture)
                {
                    FireEvent(this, id, TouchActionType.Released, screenPointerCoords, false);
                }
                else
                {
                    CheckForBoundaryHop(id, screenPointerCoords);
                    //CrossWordDrawLineViewModel.touchReleased = new SKPoint((float)screenPointerCoords.X, (float)screenPointerCoords.Y);

                    CrossWordDrawLineViewModel.changeLineColor = false;
                    new MessageCenterHelper().SendMessageMenu(null);

                    if (idToEffectDictionary[id] != null)
                    {
                        FireEvent(idToEffectDictionary[id], id, TouchActionType.Released, screenPointerCoords, false);
                    }
                }
                idToEffectDictionary.Remove(id);
                break;

            case MotionEventActions.Cancel:
                if (capture)
                {
                    FireEvent(this, id, TouchActionType.Cancelled, screenPointerCoords, false);
                }
                else
                {
                    if (idToEffectDictionary[id] != null)
                    {
                        FireEvent(idToEffectDictionary[id], id, TouchActionType.Cancelled, screenPointerCoords, false);
                    }
                }
                idToEffectDictionary.Remove(id);
                break;
            }
        }
示例#9
0
        private void OnTouch(object obj, Android.Views.View.TouchEventArgs ev)
        {
            Android.Views.View senderView = obj as Android.Views.View;
            senderView.GetLocationOnScreen(twoIntArray);

            // タップポインターのID
            int actID = ev.Event.ActionIndex;

            // タップした指を識別するID
            int pointID = ev.Event.GetPointerId(actID);

            // 相対座標を取得する場合
            float x = ev.Event.GetX(actID);
            float y = ev.Event.GetY(actID);

            // 絶対座標を取得する場合
            float x_Raw = ev.Event.RawX;
            float y_Raw = ev.Event.RawY;

            Point screenPointerCoords = new Point(x_Raw,
                                                  y_Raw);

            DragDrop.View.MyEffect.TouchEventArgs args;

            switch (ev.Event.Action)
            {
            case MotionEventActions.ButtonPress:
            case MotionEventActions.Down:
            case MotionEventActions.PointerDown:

                if (!idToEffectDictionary.ContainsKey(pointID))
                {
                    idToEffectDictionary.Add(pointID, this);
                    FireEvent(this, pointID, View.MyEffect.TouchEventArgs.TouchEventType.Pressed, screenPointerCoords, true);
                }

                break;

            case MotionEventActions.ButtonRelease:
            case MotionEventActions.Up:
            case MotionEventActions.Pointer1Up:

                if (idToEffectDictionary[pointID] != null)
                {
                    FireEvent(this, pointID, View.MyEffect.TouchEventArgs.TouchEventType.Released, screenPointerCoords, false);
                    idToEffectDictionary.Remove(pointID);
                }

                break;

            case MotionEventActions.Move:
                // Moveイベントは複数同時に取得されるため、ループで処理する
                for (var i = 0; i < ev.Event.PointerCount; i++)
                {
                    pointID = ev.Event.GetPointerId(actID);

                    if (idToEffectDictionary[pointID] != null)
                    {
                        FireEvent(this, pointID, View.MyEffect.TouchEventArgs.TouchEventType.Moved, screenPointerCoords, true);
                    }
                }

                break;

            case MotionEventActions.Cancel:

                if (idToEffectDictionary[pointID] != null)
                {
                    FireEvent(this, pointID, View.MyEffect.TouchEventArgs.TouchEventType.Released, screenPointerCoords, false);
                }

                idToEffectDictionary.Remove(pointID);

                break;
            }
        }
示例#10
0
 private void CustomDropDown_TouchIntercepted(object sender, Android.Views.View.TouchEventArgs e)
 {
     //if(e.Event.)
     throw new NotImplementedException();
 }
 private void ControlOnTouch(object sender, Android.Views.View.TouchEventArgs touchEventArgs)
 {
     gestureRecognizer?.OnTouchEvent(touchEventArgs.Event);
 }