예제 #1
0
        //--//
        
        public TouchScreen(ActiveRectangle[] activeRectangles)
        {
            int bpp, orientation;
            Microsoft.SPOT.Hardware.HardwareProvider hwProvider = Microsoft.SPOT.Hardware.HardwareProvider.HwProvider;
            hwProvider.GetLCDMetrics(out _maxWidth, out _maxHeight, out bpp, out orientation);

            if (activeRectangles == null || activeRectangles.Length == 0)
            {
                this.ActiveRegions = new ActiveRectangle[] { new ActiveRectangle(0, 0, _maxWidth, _maxHeight, null) };
            }
            else
            {
                this.ActiveRegions = activeRectangles;
            }
        }
예제 #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);
        }