void Resized(Object sender, Event ev) { var window = (IWindow)sender; var matched = ComputeMatched(window); if (matched != _matched) { var eventData = new MediaQueryListEvent(EventNames.Change, false, false, _media.MediaText, matched); Dispatch(eventData); } _matched = matched; }
private void TrackParsedFilesSize(object sender, AngleSharp.Dom.Events.Event ev) { if (ev is HtmlParseEvent) { var textSize = ((HtmlParseEvent)ev).Document.Source.Length; Perfs.AddDownloadSize(textSize); } else if (ev is CssParseEvent) { var textSize = ((CssParseEvent)ev).StyleSheet.SourceCode.Text.Length; Perfs.AddDownloadSize(textSize); } }
void Resized(Object sender, Event ev) { var window = (IWindow)sender; var matched = ComputeMatched(window); //TODO use MediaQueryListEvent if (matched != _matched) { Dispatch(new Event(EventNames.Change, false, false)); } _matched = matched; }
private void HtmlParser_Parsed(object sender, AngleSharp.Dom.Events.Event ev) { if (ev is HtmlParseEvent) { Console.WriteLine("AngleSharp-Parsed: " + ((HtmlParseEvent)ev).Document.Source.Length + " HTML chars (" + ((HtmlParseEvent)ev).Document.Url + ")"); } else if (ev is CssParseEvent) { var cssSource = ((CssParseEvent)ev).StyleSheet.Href; if (String.IsNullOrEmpty(cssSource)) { cssSource = ((CssParseEvent)ev).StyleSheet.OwnerNode.LocalName; } Console.WriteLine("AngleSharp-Parsed: " + ((CssParseEvent)ev).StyleSheet.Children.Count() + " CSS rules (" + cssSource + ")"); } }
private void HtmlParser_Parsing(object sender, AngleSharp.Dom.Events.Event ev) { if (ev is HtmlParseEvent) { Console.WriteLine("AngleSharp-Parsing: " + ((HtmlParseEvent)ev).Document.Url); } else if (ev is CssParseEvent) { var cssSource = ((CssParseEvent)ev).StyleSheet.Href; if (String.IsNullOrEmpty(cssSource)) { cssSource = ((CssParseEvent)ev).StyleSheet.OwnerNode.LocalName; } Console.WriteLine("AngleSharp-Parsing: " + cssSource); } }
public Boolean Dispatch(Event ev) { return _host.Dispatch(ev); }
void Fire(String eventName) { var evt = new Event(eventName); Dispatch(evt); }
private void OnConnected() { var evt = new Event(); evt.Init(OpenEvent, false, false); this.Dispatch(evt); }
private void OnDisconnected() { var evt = new Event(); evt.Init(CloseEvent, false, false); this.Dispatch(evt); }
private void OnUnload(Object sender, Event ev) { RemoveEventListeners(); if (_state != WebSocketReadyState.Closed && _state != WebSocketReadyState.Closing) { CloseAsync().Wait(); _ws.Dispose(); } }
/// <summary> /// Calls the listener registered for the given event. /// </summary> /// <param name="ev">The event that asks for the listeners.</param> internal void CallEventListener(Event ev) { var type = ev.Type; var listeners = _listeners.ToArray(); var target = ev.CurrentTarget; var phase = ev.Phase; foreach (var listener in listeners) { if (!_listeners.Contains(listener) || listener.Type != type) continue; if (ev.Flags.HasFlag(EventFlags.StopImmediatePropagation)) break; if ((listener.IsCaptured && phase == EventPhase.Bubbling) || (!listener.IsCaptured && phase == EventPhase.Capturing)) continue; listener.Callback(target, ev); } }
/// <summary> /// Dispatch an event to this Node. /// </summary> /// <param name="ev">The event to dispatch.</param> /// <returns> /// False if at least one of the event handlers, which handled this /// event called preventDefault(). Otherwise true. /// </returns> public Boolean Dispatch(Event ev) { if (ev == null || ev.Flags.HasFlag(EventFlags.Dispatch) || !ev.Flags.HasFlag(EventFlags.Initialized)) throw new DomException(DomError.InvalidState); ev.IsTrusted = false; return ev.Dispatch(this); }
private static void Context_ParseError(object sender, AngleSharp.Dom.Events.Event ev) { Console.WriteLine(((HtmlErrorEvent)ev).Message); }
public Boolean Dispatch(Event ev) { return _window.Dispatch(ev); }
/// <summary> /// Calls the listener registered for the given event. /// </summary> /// <param name="ev">The event that asks for the listeners.</param> public void InvokeEventListener(Event ev) { if (_listeners != null) { var type = ev.Type; var listeners = _listeners.ToArray(); var target = ev.CurrentTarget; var phase = ev.Phase; foreach (var listener in listeners) { if (_listeners.Contains(listener) && listener.Type.Is(type)) { if ((ev.Flags & EventFlags.StopImmediatePropagation) == EventFlags.StopImmediatePropagation) { break; } if ((!listener.IsCaptured || phase != EventPhase.Bubbling) && (listener.IsCaptured || phase != EventPhase.Capturing)) { listener.Callback(target, ev); } } } } }
public void InvokeEventListener(Event ev) { _host.InvokeEventListener(ev); }