Ejemplo n.º 1
0
            public bool OnEvent(BaseEvent baseEvent)
            {
                if (IgnoreAllEvents)
                    return true;

                if (baseEvent is TouchEvent)
                {
                    TouchEvent e = (TouchEvent)baseEvent;

                    if (e.EventMessage == 3)
                    {
                        // If the same position -- do nothing
                        if (wasMoveEvent && e.Touches[0].X == TouchX && e.Touches[0].Y == TouchY)
                        {
                            // Nothing
                        }
                        else
                        {
                            wasMoveEvent = true;
                            TouchX = e.Touches[0].X;
                            TouchY = e.Touches[0].Y;
                            RaiseTouchMoveEvent(this, new TouchEventArgs(e.Touches));
                        }
                    }
                    else if (e.EventMessage == 1)
                    {
                        wasMoveEvent = false;
                        RaiseTouchDownEvent(this, new TouchEventArgs(e.Touches));
                    }
                    else if (e.EventMessage == 2)
                    {
                        wasMoveEvent = false;
                        RaiseTouchUpEvent(this, new TouchEventArgs(e.Touches));
                    }
                }
                else if (baseEvent is GenericEvent)
                {
                    GenericEvent genericEvent = (GenericEvent)baseEvent;
                    if (genericEvent.EventCategory == (byte)EventCategory.Gesture)
                        RaiseTouchGestureEvent(this, new TouchGestureEventArgs((TouchGesture)genericEvent.EventMessage, genericEvent.X, genericEvent.Y, (ushort)genericEvent.EventData, genericEvent.Time));
                }

                return true;
            }
Ejemplo n.º 2
0
        bool IEventListener.OnEvent(BaseEvent ev)
        {
            /// Process known events, otherwise forward as generic to MainWindow.
            ///

            TouchEvent touchEvent = ev as TouchEvent;
            if (touchEvent != null)
            {
                // dispatch only when the event is in the active area
                for(int i = 0; i < _activeRegions.Length; ++i)
                {
                    ActiveRectangle ar = _activeRegions[i];

                    // only check the first
                    if(ar.Contains(touchEvent.Touches[0]))
                    {
                        TouchScreenEventArgs tea = new TouchScreenEventArgs(touchEvent.Time, touchEvent.Touches, ar.Target);

                        switch((TouchMessages)touchEvent.EventMessage)
                        {
                            case TouchMessages.Down:
                                if(OnTouchDown != null)
                                {
                                    OnTouchDown(this, tea);
                                }
                                break;
                            case TouchMessages.Up:
                                if(OnTouchUp != null)
                                {
                                    OnTouchUp(this, tea);
                                }
                                break;
                            case TouchMessages.Move:
                                if(OnTouchMove != null)
                                {
                                    OnTouchMove(this, tea);
                                }
                                break;
                        }
                    }
                }

                return true;
            }
            else if(ev is GenericEvent)
            {
                GenericEvent genericEvent = (GenericEvent)ev;
                switch (genericEvent.EventCategory)
                {
                    case (byte)EventCategory.Gesture:
                    {
                        TouchGestureEventArgs ge = new TouchGestureEventArgs();

                        ge.Gesture = (TouchGesture)genericEvent.EventMessage;
                        ge.X = genericEvent.X;
                        ge.Y = genericEvent.Y;
                        ge.Arguments = (ushort)genericEvent.EventData;

                        if (ge.Gesture == TouchGesture.Begin && OnGestureStarted != null)
                        {
                            OnGestureStarted(this, ge);
                        }
                        else if (ge.Gesture == TouchGesture.End && OnGestureEnded!= null)
                        {
                            OnGestureEnded(this, ge);
                        }
                        else if(OnGestureChanged != null)
                        {
                            OnGestureChanged(this, ge);
                        }

                        break;
                    }
                    default:
                       break;
                }
            }

            return false;
        }
Ejemplo n.º 3
0
        private void ProcessEvent(EventInfo eventInfo, BaseEvent ev)
        {
            if (eventInfo == null)
                return;

            if (eventInfo.EventFilter != null)
            {
                if (!eventInfo.EventFilter.OnEvent(ev))
                    return;
            }

            if (eventInfo.EventListener != null)
            {
                eventInfo.EventListener.OnEvent(ev);
            }
        }
Ejemplo n.º 4
0
        private static void GetEvent(uint data1, uint data2, DateTime time, ref EventInfo eventInfo, ref BaseEvent ev)
        {
            byte category = (byte)((data1 >> 8) & 0xFF);

            eventInfo = GetEventInfo((EventCategory)category);
            if (eventInfo.EventProcessor != null)
            {
                ev = eventInfo.EventProcessor.ProcessEvent(data1, data2, time);
            }
            else
            {
                GenericEvent genericEvent = new GenericEvent();
                genericEvent.Y = (int)(data2 & 0xFFFF);
                genericEvent.X = (int)((data2 >> 16) & 0xFFFF);
                genericEvent.Time = time;
                genericEvent.EventMessage = (byte)(data1 & 0xFF);
                genericEvent.EventCategory = category;
                genericEvent.EventData = (data1 >> 16) & 0xFFFF;

                ev = genericEvent;
            }
        }