public void InvokeHandleEvent(Event evt) { Contract.Requires<ArgumentNullException>(evt != null); invoker.Invoke(() => handler.Value.HandleEvent(evt)); }
void IEventDefaultAction.DefaultAction(Event evt) { switch (evt.Type) { case DOMEvents.Events.DOMActivate: OnDOMActivate(); break; } }
public void HandleEvent(Event ev) { var handlers = Element .Elements() .SelectMany(i => i.Interfaces<IEventHandler>()); foreach (var handler in handlers) handler.HandleEvent(ev); }
void IEventDefaultAction.DefaultAction(Event evt) { switch (evt.Type) { case Events.Submit: OnSubmit(); break; } }
/// <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); }
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; }
public void HandleEvent(Event evt) { Contract.Requires<ArgumentNullException>(evt != null); throw new NotImplementedException(); }
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; } } }
void IEventListener.HandleEvent(Event @event) { action(@event); }
/// <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; }
/// <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)); } }
bool IEventTarget.DispatchEvent(Event evt) { evt.isTrusted = false; return Dispatch(evt); }
public void HandleEvent(Event ev) { }
public virtual void InitEvent(Event evt) { Contract.Requires<ArgumentNullException>(evt != null); evt.InitEvent(type, canBubble, cancelable); }
public void HandleEvent(Event ev) { Invoke(); }
void IEventDefaultAction.DefaultAction(Event evt) { if (evt.Type == DOMEvents.Events.DOMFocusIn) eventTarget.Value.Dispatch(Events.Focus); }
public void HandleEvent(Event ev) { throw new NotImplementedException(); }
void IEventListener.HandleEvent(Event evt) { if (evt.Type == DOMEvents.Events.DOMFocusIn) SetIndex(); }