Esempio n. 1
0
 private void CaptureEvent(List<IEventTarget> nodes, Event e, List<IEventTarget> avoidNodes)
 {
     e.eventPhase = EventPhases.CAPTURING_PHASE;
     //reverse of the chain make it sorted in order to execute
     nodes.Reverse();
     BroadcastEvent(e, nodes, avoidNodes);
 }
Esempio n. 2
0
 private void BroadcastEventFromNode(INode sender, Event e, List<IEventTarget> avoidTargets)
 {
     //Build event targets chain
     List<IEventTarget> targets = new List<IEventTarget>();
     BuildEventTargetsChain(sender, targets);
     //Capture Event
     CaptureEvent(targets, e, avoidTargets);
     //Bubble Event
     BubbleEvent(targets, e, avoidTargets);
 }
Esempio n. 3
0
 /// <summary>
 /// Trigger some javascript event on the object
 /// </summary>
 /// <param name="sender"></param> 
 /// <param name="e"></param>
 /// <param name="eventName"></param>
 public bool FireEvent(ScriptFunction sf, Event e, object scope)
 {
     object result = sf.Invoke(scope, new object[] {e});
     //todo: check whether result is NULL?
     return result is bool ? (bool)result : false;
 }
Esempio n. 4
0
 private void BroadcastEvent(Event e, List<IEventTarget> nodes, List<IEventTarget> avoidNodes)
 {
     foreach (IEventTarget node in nodes)
     {
         if(avoidNodes != null && avoidNodes.Contains(node))
         {
             continue;//skip nodes which are marked as avoided. Generally nodes which already handled the event are marked as avoided.
         }
         Dictionary<string, List<IEventRegistration>> events = node.GetEventsCollection();
         //process event in current node
         if (events.ContainsKey(e.type) && events[e.type].Count > 0)
             //if there is at least one listener of this type of event
         {
             List<IEventRegistration> eventRegistrations = events[e.type];
             foreach (IEventRegistration eventRegistration in eventRegistrations)
             {
                 if (eventRegistration.ApplyToPhase == e.eventPhase) //if listener has correct type of eventPahse
                 {
                     FireEvent(eventRegistration.Listener, e, node);
                 }
             }
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Bubbles event to the document object directly
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <param name="eventName"></param>
 public void BubbleEvent(List<IEventTarget> nodes, Event e, List<IEventTarget> avoidNodes)
 {
     e.eventPhase = EventPhases.BUBBLING_PHASE;
     //reverse of the chain make it sorted in order to execute
     nodes.Reverse();
     BroadcastEvent(e, nodes, avoidNodes);
 }