Exemplo n.º 1
0
        public void InvokeHandleEvent(Event evt)
        {
            Contract.Requires<ArgumentNullException>(evt != null);

            invoker.Invoke(() =>
                handler.Value.HandleEvent(evt));
        }
Exemplo n.º 2
0
 void IEventDefaultAction.DefaultAction(Event evt)
 {
     switch (evt.Type)
     {
         case DOMEvents.Events.DOMActivate:
             OnDOMActivate();
             break;
     }
 }
Exemplo n.º 3
0
        public void HandleEvent(Event ev)
        {
            var handlers = Element
                .Elements()
                .SelectMany(i => i.Interfaces<IEventHandler>());

            foreach (var handler in handlers)
                handler.HandleEvent(ev);
        }
Exemplo n.º 4
0
 void IEventDefaultAction.DefaultAction(Event evt)
 {
     switch (evt.Type)
     {
         case Events.Submit:
             OnSubmit();
             break;
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Dispatches the event to this <see cref="XElement"/>.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="evt"></param>
        public static void DispatchEvent(this XElement element, Event evt)
        {
            Contract.Requires<ArgumentNullException>(element != null);
            Contract.Requires<ArgumentNullException>(evt != null);

            var target = element.InterfaceOrDefault<EventTarget>();
            if (target == null)
                throw new NullReferenceException();

            target.Dispatch(evt);
        }
Exemplo n.º 6
0
        public void HandleEvent(Event ev)
        {
            var context = GetContext();
            if (context == null)
                return;

            var sequenceBindingNodeSequence = GetSequenceBindingNodeSequence(context);
            if (sequenceBindingNodeSequence.Length == 0)
                return;

            var insertNode = sequenceBindingNodeSequence[0];
            var insertItem = ModelItem.Get(insertNode);
            if (insertItem.ReadOnly)
                return;

            if (insertNode is XElement)
                if (((XElement)insertNode).HasElements)
                    throw new DOMTargetEventException(Element, Events.BindingException);

            insertItem.Value = Element.Value;
            insertItem.Model.State.Recalculate = true;
            insertItem.Model.State.Revalidate = true;
            insertItem.Model.State.Refresh = true;
        }
Exemplo n.º 7
0
 public void HandleEvent(Event evt)
 {
     Contract.Requires<ArgumentNullException>(evt != null);
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
        public void HandleEvent(Event evt)
        {
            // resolve target object
            var handler = evt.Host.Xml.ResolveObjectId(handlerId);
            if (handler == null)
                return;

            // resolve each interface
            foreach (var h in handler.Interfaces(interfaceType))
            {
                if (methodInfo.DeclaringType.IsInstanceOfType(h) &&
                    methodInfo.GetParameters().Length == 0)
                {
                    methodInfo.Invoke(h, new object[0]);
                    continue;
                }

                if (methodInfo.DeclaringType.IsInstanceOfType(h) &&
                    methodInfo.GetParameters().Length == 1)
                {
                    methodInfo.Invoke(h, new object[] { evt });
                    continue;
                }
            }
        }
Exemplo n.º 9
0
 void IEventListener.HandleEvent(Event @event)
 {
     action(@event);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Dispatches the event to this <see cref="XNode"/>.
        /// </summary>
        /// <param name="evt"></param>
        /// <returns></returns>
        public bool Dispatch(Event evt)
        {
            Contract.Requires<ArgumentNullException>(evt != null);

            trace.Information("EventDispatcher.DispatchEvent: {0} to {1}", evt.Type, node);

            if (evt.dispatch ||
                evt.initialized == false ||
                evt.type == null)
                throw new DOMException(DOMException.INVALID_STATE_ERR);

            evt.dispatch = true;
            evt.target = node;

            // path to root from root
            var path = node.Ancestors()
                .Cast<XNode>()
                .Append(node.Document)
                .ToLinkedList();

            evt.eventPhase = EventPhase.Capturing;

            // capture phase moves from root to target
            foreach (var currentTarget in path.Backwards())
            {
                if (evt.stopPropagation)
                    break;

                InvokeListeners(currentTarget, evt);
            }

            // at-target phase
            evt.eventPhase = EventPhase.AtTarget;

            if (!evt.stopPropagation)
                InvokeListeners(node, evt);

            // bubbling phase
            if (evt.bubbles)
            {
                evt.eventPhase = EventPhase.Bubbling;

                // bubbling phase moves from target to root
                foreach (var currentTarget in path.Forwards())
                {
                    if (evt.stopPropagation)
                        break;

                    InvokeListeners(currentTarget, evt);
                }
            }

            evt.dispatch = false;
            evt.eventPhase = EventPhase.None;
            evt.currentTarget = null;

            if (evt.canceled)
                return false;

            // handle default action
            foreach (var da in node.Interfaces<IEventDefaultAction>())
                if (da != null)
                    da.DefaultAction(evt);

            return true;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Invokes the applicable listeners for this node.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="evt"></param>
        void InvokeListeners(XNode node, Event evt)
        {
            Contract.Requires<ArgumentNullException>(node != null);
            Contract.Requires<ArgumentNullException>(evt != null);

            // Initialize event's currentTarget attribute to the object for which these steps are run.
            evt.currentTarget = node;

            // invoke registered listeners
            foreach (var registration in node.Interface<EventTarget>().state.registrations)
            {
                // If event's stop immediate propagation flag is set, terminate the invoke algorithm.
                if (evt.stopImmediatePropagation)
                    return;

                // If event's type attribute value is not listener's type, terminate these substeps (and run them for
                // the next event listener).
                if (evt.type != registration.EventType)
                    continue;

                // If event's eventPhase attribute value is CAPTURING_PHASE and listener's capture is false, terminate
                // these substeps (and run them for the next event listener).
                if (evt.eventPhase == EventPhase.Capturing && registration.Capture == false)
                    continue;

                // If event's eventPhase attribute value is BUBBLING_PHASE and listener's capture is true, terminate
                // these substeps (and run them for the next event listener).
                if (evt.eventPhase == EventPhase.Bubbling && registration.Capture == true)
                    continue;

                // Call listener's callback's handleEvent, with the event passed to this algorithm as the first
                // argument and event's currentTarget attribute value as callback this value.
                invoker.Invoke(() =>
                    registration.Listener.HandleEvent(evt));
            }

            // invoke listeners available directly as interfaces
            foreach (var listener in node.Interfaces<IEventListener>())
            {
                // If event's stop immediate propagation flag is set, terminate the invoke algorithm.
                if (evt.stopImmediatePropagation)
                    return;

                invoker.Invoke(() =>
                    listener.HandleEvent(evt));
            }
        }
Exemplo n.º 12
0
 bool IEventTarget.DispatchEvent(Event evt)
 {
     evt.isTrusted = false;
     return Dispatch(evt);
 }
Exemplo n.º 13
0
 public void HandleEvent(Event ev)
 {
 }
Exemplo n.º 14
0
        public virtual void InitEvent(Event evt)
        {
            Contract.Requires<ArgumentNullException>(evt != null);

            evt.InitEvent(type, canBubble, cancelable);
        }
Exemplo n.º 15
0
 public void HandleEvent(Event ev)
 {
     Invoke();
 }
Exemplo n.º 16
0
Arquivo: Input.cs Projeto: nxkit/nxkit
 void IEventDefaultAction.DefaultAction(Event evt)
 {
     if (evt.Type == DOMEvents.Events.DOMFocusIn)
         eventTarget.Value.Dispatch(Events.Focus);
 }
Exemplo n.º 17
0
Arquivo: Load.cs Projeto: nxkit/nxkit
 public void HandleEvent(Event ev)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 18
0
 void IEventListener.HandleEvent(Event evt)
 {
     if (evt.Type == DOMEvents.Events.DOMFocusIn)
         SetIndex();
 }