public bool OnEvent(BaseEvent ev)
        {
            if (ev is StorageEvent)
            {
                RemovableMedia.PostEvent((StorageEvent)ev);
            }

            return true;
        }
Ejemplo n.º 2
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);
            }
        }
        public bool OnEvent(BaseEvent ev)
        {
            var pinEvent = (GpioPinEvent)ev;
            GpioPin pin = null;

            lock (m_pinMap)
            {
                if (m_pinMap.Contains(pinEvent.PinNumber))
                {
                    pin = (GpioPin)m_pinMap[pinEvent.PinNumber];
                }
            }

            // Avoid calling this under a lock to prevent a potential lock inversion.
            if (pin != null)
            {
                pin.OnPinChangedInternal(pinEvent.Edge);
            }

            return true;
        }
Ejemplo n.º 4
0
            public bool OnEvent(BaseEvent baseEvent)
            {
                if (baseEvent is TouchEvent)
                {
                    TouchEvent e = (TouchEvent)baseEvent;
                    switch (e.EventMessage)
                    {
                        case (byte)TouchMessages.Down: HandleTouchDownEvent(e); break;
                        case (byte)TouchMessages.Move: HandleTouchMoveEvent(e); break;
                        case (byte)TouchMessages.Up: HandleTouchUpEvent(e); break;
                    }
                }
                else if (baseEvent is GenericEvent)
                {
                    GenericEvent e = (GenericEvent)baseEvent;
                    if (e.EventCategory == (byte)EventCategory.Gesture)
                    {
                        TouchGestureEventArgs args = new TouchGestureEventArgs((TouchGesture)e.EventMessage, e.X, e.Y, (ushort)e.EventData, e.Time);
                        switch (args.Gesture)
                        {
                            case TouchGesture.Begin: NotifyTouchGestureStarted(args); break;
                            case TouchGesture.End: NotifyTouchGestureEnded(args); break;
                            default: NotifyTouchGestureChanged(args); break;
                        }
                    }
                }

                return true;
            }
Ejemplo n.º 5
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;
            }
        }
Ejemplo n.º 6
0
 static internal void PostEvent(BaseEvent ev)
 {
     Timer messagePseudoThread = new Timer(MessageHandler, ev, 1, Timeout.Infinite);
 }
Ejemplo n.º 7
0
        public bool OnEvent(BaseEvent ev)
        {
            if (ev is SleepEvent)
            {
                PowerState.PostEvent((SleepEvent)ev);
            }
            else if (ev is PowerEvent)
            {
                PowerState.PostEvent((PowerEvent)ev);
            }

            return true;
        }
Ejemplo n.º 8
0
        public bool OnEvent(BaseEvent ev)
        {
            InputReport ir = null;
            InputDevice dev = null;

            /// Process known events, otherwise forward as generic to MainWindow.
            ///

            TouchEvent touchEvent = ev as TouchEvent;
            if (touchEvent != null)
            {
                Microsoft.SPOT.Presentation.UIElement targetWindow = TouchCapture.Captured;

                ///
                ///  Make sure the current event's coordinates are contained in the current
                ///  stylus/touch window, if not then search for the appropriate window
                ///
                if (targetWindow != null && touchEvent.EventMessage == (byte)TouchMessages.Down)
                {
                    int x = 0, y = 0, w, h;
                    int xSrc = touchEvent.Touches[0].X;
                    int ySrc = touchEvent.Touches[0].Y;

                    targetWindow.PointToScreen(ref x, ref y);
                    targetWindow.GetRenderSize(out w, out h);

                    if (!(x <= xSrc && xSrc <= (x + w) &&
                        y <= ySrc && ySrc <= (y + h)))
                    {
                        // only look for different target window if the touch point is inside 
                        // the system metrics, otherwise, it may be a touch calibration point
                        // which is translated in the application layer.
                        if(xSrc <= SystemMetrics.ScreenWidth &&
                           ySrc <= SystemMetrics.ScreenHeight)
                        {
                            targetWindow = null;
                        }
                    }
                }

                if (targetWindow == null)
                {
                    //If we can enforce that the first event in the array is always the primary touch, we don't have to
                    //search.
                    targetWindow = WindowManager.Instance.GetPointerTarget(touchEvent.Touches[0].X, touchEvent.Touches[0].Y);
                }

                if (targetWindow != null)
                {
                    _inputManager.TouchDevice.SetTarget(targetWindow);
                }
                else
                {
                    _inputManager.TouchDevice.SetTarget(MainWindow);
                }

                ir =
                   new RawTouchInputReport(
                       null,
                       touchEvent.Time,
                       touchEvent.EventMessage,
                       touchEvent.Touches
                       );

                dev = _inputManager._touchDevice;

            }
            else if (ev is GenericEvent)
            {
                GenericEvent genericEvent = (GenericEvent)ev;

                    Microsoft.SPOT.Presentation.UIElement targetWindow = TouchCapture.Captured;

                    if (targetWindow == null)
                    {
                        targetWindow = WindowManager.Instance.GetPointerTarget(genericEvent.X, genericEvent.Y);
                    }

                    if (targetWindow != null)
                    {
                        _inputManager.GenericDevice.SetTarget(targetWindow);
                    }
                    else
                    {
                        _inputManager.GenericDevice.SetTarget(MainWindow);
                    }

                    ir = new RawGenericInputReport(
                           null,
                           genericEvent
                           );

                    dev = _inputManager._genericDevice;

            }
            else
            {
                /// Unkown event.
            }

            this.Dispatcher.BeginInvoke(_reportInputMethod, new InputReportArgs(dev, ir));

            return true;
        }
Ejemplo n.º 9
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;
            }
        }
Ejemplo n.º 10
0
 public bool OnEvent(BaseEvent baseEvent)
 { return true; }