private void MTouch_Release(object sender, TouchActionEventArgs args)
 {
     if (State == eControlInputState.ePressed)
     {
         OnClicked(this, EventArgs.Empty);
     }
     State = eControlInputState.eNone;
 }
Пример #2
0
        void RemoveCursor(TouchActionEventArgs args)
        {
            Cursors.Remove(args.ID);
            if (Mode == TouchMode.Pinch)
            {
                PinchProcessor.Clear();

                if (Cursors.Count == 1)
                {
                    Mode = TouchMode.Pan;
                }
            }
            if (Cursors.Count == 0)
            {
                Mode = TouchMode.Normal;
            }
        }
Пример #3
0
        public void OnTouchAction(Element e, TouchActionEventArgs a)
        {
            var type   = a.Location.TouchType;
            var change = type != PreviousType;

            switch (type)
            {
            case TouchPoint.eTouchType.eMoved:
                switch (PreviousType)
                {
                case TouchPoint.eTouchType.eReleased:
                    SafeHover(e, a);
                    break;

                case TouchPoint.eTouchType.ePressed:
                    SafePressedMove(e, a);
                    break;

                default:
                    throw (new Exception("Cannot determine previous state. It must be pressed or released"));
                }
                break;

            case TouchPoint.eTouchType.ePressed:
                if (change)
                {
                    SafePressed(e, a);
                }
                break;

            case TouchPoint.eTouchType.eReleased:
                SafeReleased(e, a);
                break;

            default:
                throw (new Exception("Do not issue commands other than pressed, released and move from a device."));
            }

            //Moved is not a state change
            if (type != TouchPoint.eTouchType.eMoved)
            {
                PreviousType = type;
            }
        }
Пример #4
0
 //Common handlers
 public void RaiseAction(TouchActionEventArgs Action)
 {
     OnTouchAction(Element, Action);
 }
Пример #5
0
 private void SafeReleased(Element element, TouchActionEventArgs args)
 {
     //Stop the tap timer
     RemoveCursor(args);
     PlainEvent(Released, element, args);
 }
Пример #6
0
 private void SafePressedMove(Element element, TouchActionEventArgs args)
 {
     ProcessCursor(args);
     SafeEvent(PressedMoved, element, args);
 }
Пример #7
0
 //Calls the safe event function for the event
 private void SafeHover(Element element, TouchActionEventArgs args)
 {
     PlainEvent(Hover, element, args);
 }
Пример #8
0
 private void SafePressed(Element element, TouchActionEventArgs args)
 {
     //Start the tap timer
     TapProcess();
     PlainEvent(Pressed, element, args);
 }
Пример #9
0
 //Triggers a threadsafe event
 private void SafeEvent(TouchActionEventHandler EventFunction, Element element, TouchActionEventArgs args)
 {
     if (EventFunction != null)
     {
         Device.BeginInvokeOnMainThread(() => {
             EventFunction?.Invoke(element, args);
         });
     }
 }
Пример #10
0
 private void PlainEvent(TouchActionEventHandler EventFunction, Element element, TouchActionEventArgs args)
 {
     if (Mode == TouchMode.Normal)
     {
         SafeEvent(EventFunction, element, args);
     }
 }
Пример #11
0
        void ProcessCursor(TouchActionEventArgs args)
        {
            if (!Cursors.ContainsKey(args.ID))
            {
                Cursors.Add(args.ID, new TouchCursor(args.Location));
                if (Cursors.Count >= 2)
                {
                    Mode = TouchMode.Pinch;
                }
            }
            else
            {
                var         item1 = Cursors[args.ID];
                TouchCursor item2 = item1;
                foreach (var cursor in Cursors)
                {
                    if (cursor.Key != args.ID)
                    {
                        item2 = cursor.Value;
                    }
                }

                var dx = args.Location.Position.X - item1.Position.X;
                var dy = args.Location.Position.Y - item1.Position.Y;

                item1.Position = args.Location.Position;
                switch (Cursors.Count)
                {
                case 0:
                    Mode = TouchMode.Normal;
                    break;

                case 1:
                {
                    var temp = new TouchPanActionEventArgs(dx, dy);
                    var dist = temp.Distance;
                    if (dist > 0)
                    {
                        if (Mode == TouchMode.Pan || temp.Distance > GestureThreshold)
                        {
                            TapCancel();
                            Debug.WriteLine("Pan Enabled");
                            Mode = TouchMode.Pan;
                            Pan?.Invoke(this, temp);
                        }
                    }
                }   break;

                case 2:
                {
                    var temp = new TouchPinchActionEventArgs(PinchProcessor);
                    if (temp.Pinch.DistanceDelta >= 0)
                    {
                        Mode = TouchMode.Pinch;
                        if (PinchProcessor.Set(item1.Position, item2.Position))
                        {
                            TapCancel();
                            Pinch?.Invoke(this, temp);
                        }
                    }
                }   break;

                default:
                    Debug.WriteLine("To many cursors.");
                    break;
                }
            }
        }
 private void MTouch_Press(object sender, TouchActionEventArgs args)
 {
 }
Пример #13
0
 private void MTouch_Release(object sender, TouchActionEventArgs args) => State = eControlInputState.eNone;
Пример #14
0
 private void MTouch_Hover(object sender, TouchActionEventArgs args) => State   = eControlInputState.eHover;
Пример #15
0
 private void MTouch_Pressed(object sender, TouchActionEventArgs args) => State = eControlInputState.ePressed;
 private void MTouch_Release(object sender, TouchActionEventArgs args)
 {
 }
 private void MTouch_Hover(object sender, TouchActionEventArgs args)
 {
 }