Exemplo n.º 1
0
        public void EventTriggered(MHRoot pSource, int ev, MHUnion evData)
        {
            Logging.Log(Logging.MHLogLinks, "Event - " + MHLink.EventTypeToString(ev) + " from " + pSource.ObjectIdentifier.Printable());

            switch (ev)
            {
            case MHRoot.EventFirstItemPresented:
            case MHRoot.EventHeadItems:
            case MHRoot.EventHighlightOff:
            case MHRoot.EventHighlightOn:
            case MHRoot.EventIsAvailable:
            case MHRoot.EventIsDeleted:
            case MHRoot.EventIsDeselected:
            case MHRoot.EventIsRunning:
            case MHRoot.EventIsSelected:
            case MHRoot.EventIsStopped:
            case MHRoot.EventItemDeselected:
            case MHRoot.EventItemSelected:
            case MHRoot.EventLastItemPresented:
            case MHRoot.EventTailItems:
            case MHRoot.EventTestEvent:
            case MHRoot.EventTokenMovedFrom:
            case MHRoot.EventTokenMovedTo:
                // Synchronous events.  Fire any links that are waiting.
                // The UK MHEG describes this as the preferred interpretation.  We are checking the link
                // at the time we generate the event rather than queuing the synchronous events until
                // this elementary action is complete.  That matters if we are processing an elementary action
                // which will activate or deactivate links.
                CheckLinks(pSource.ObjectIdentifier, ev, evData);
                break;

            case MHRoot.EventAnchorFired:
            case MHRoot.EventAsyncStopped:
            case MHRoot.EventContentAvailable:
            case MHRoot.EventCounterTrigger:
            case MHRoot.EventCursorEnter:
            case MHRoot.EventCursorLeave:
            case MHRoot.EventEngineEvent:
            case MHRoot.EventEntryFieldFull:
            case MHRoot.EventInteractionCompleted:
            case MHRoot.EventStreamEvent:
            case MHRoot.EventStreamPlaying:
            case MHRoot.EventStreamStopped:
            case MHRoot.EventTimerFired:
            case MHRoot.EventUserInput:
            case MHRoot.EventFocusMoved:         // UK MHEG.  Generated by HyperText class
            case MHRoot.EventSliderValueChanged: // UK MHEG.  Generated by Slider class
            {
                // Asynchronous events.  Add to the event queue.
                MHAsynchEvent pEvent = new MHAsynchEvent();
                pEvent.EventSource = pSource;
                pEvent.EventType   = ev;
                pEvent.EventData   = evData;
                m_EventQueue.Add(pEvent);
            } break;
            }
        }
Exemplo n.º 2
0
        public int RunAll()
        {
            // Request to boot or reboot
            if (m_fBooting)
            {
                // Reset everything
                m_ApplicationStack.Clear();
                m_EventQueue.Clear();
                m_ExternContentTable.Clear();
                m_LinkTable.Clear();

                // UK MHEG applications boot from ~//a or ~//startup.  Actually the initial
                // object can also be explicitly given in the
                MHObjectRef startObj = new MHObjectRef();
                startObj.ObjectNo = 0;
                startObj.GroupId.Copy(new MHOctetString("~//a"));
                // Launch will block until either it finds the appropriate object and
                // begins the application or discovers that the file definitely isn't
                // present in the carousel.  It is possible that the object might appear
                // if one of the containing directories is updated.
                if (!Launch(startObj))
                {
                    startObj.GroupId.Copy(new MHOctetString("~//startup"));
                    if (!Launch(startObj))
                    {
                        //Logging.Log(Logging.MHLogError, "Unable to launch application");
                        return(-1);
                    }
                }
                m_fBooting = false;
            }

            int nNextTime = 0;

            do
            {
                // Check to see if we need to close.
                if (m_Context.CheckStop())
                {
                    return(0);
                }

                // Run queued actions.
                RunActions();
                // Now the action stack is empty process the next asynchronous event.
                // Processing one event may affect how subsequent events are handled.

                // Check to see if some files we're waiting for have arrived.
                // This could result in ContentAvailable events.
                CheckContentRequests();

                // Check the timers.  This may result in timer events being raised.
                if (CurrentScene() != null)
                {
                    int next = CurrentScene().CheckTimers(this);
                    if (nNextTime == 0 || nNextTime > next)
                    {
                        nNextTime = next;
                    }
                }
                if (CurrentApp() != null)
                {
                    // The UK MHEG profile allows applications to have timers.
                    int nAppTime = CurrentApp().CheckTimers(this);
                    if (nAppTime != 0 && (nNextTime == 0 || nAppTime < nNextTime))
                    {
                        nNextTime = nAppTime;
                    }
                }
                if (m_ExternContentTable.Count != 0)
                {
                    // If we have an outstanding request for external content we need to set a timer.
                    if (nNextTime == 0 || nNextTime > CONTENT_CHECK_TIME)
                    {
                        nNextTime = CONTENT_CHECK_TIME;
                    }
                }

                if (m_EventQueue.Count != 0)
                {
                    MHAsynchEvent pEvent = m_EventQueue[0];
                    Logging.Log(Logging.MHLogLinks, "Asynchronous event dequeued - " + MHLink.EventTypeToString(pEvent.EventType)
                                + " from " + pEvent.EventSource.ObjectIdentifier.Printable());
                    CheckLinks(pEvent.EventSource.ObjectIdentifier, pEvent.EventType, pEvent.EventData);
                    m_EventQueue.Remove(pEvent);
                }
            } while (m_EventQueue.Count != 0 || m_ActionStack.Count != 0);

            // Redraw the display if necessary.
            if (!IsRegionEmpty(m_redrawRegion))
            {
                m_Context.RequireRedraw(m_redrawRegion);
                m_redrawRegion = new Region();
                m_redrawRegion.MakeEmpty();
            }

            return(nNextTime);
        }