예제 #1
0
        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;
        }
예제 #2
0
 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);
     }
 }
예제 #3
0
        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;
        }
예제 #4
0
 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 + ")");
     }
 }
예제 #5
0
 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);
     }
 }
예제 #6
0
 public Boolean Dispatch(Event ev)
 {
     return _host.Dispatch(ev);
 }
 void Fire(String eventName)
 {
     var evt = new Event(eventName);
     Dispatch(evt);
 }
예제 #8
0
 private void OnConnected()
 {
     var evt = new Event();
     evt.Init(OpenEvent, false, false);
     this.Dispatch(evt);
 }
예제 #9
0
 private void OnDisconnected()
 {
     var evt = new Event();
     evt.Init(CloseEvent, false, false);
     this.Dispatch(evt);
 }
예제 #10
0
        private void OnUnload(Object sender, Event ev)
        {
            RemoveEventListeners();

            if (_state != WebSocketReadyState.Closed && _state != WebSocketReadyState.Closing)
            {
                CloseAsync().Wait();
                _ws.Dispose();
            }
        }
예제 #11
0
        /// <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);
            }
        }
예제 #12
0
        /// <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);
        }
예제 #13
0
 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);
 }
예제 #15
0
        /// <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);
                        }
                    }
                }
            }
        }
예제 #16
0
 public void InvokeEventListener(Event ev)
 {
     _host.InvokeEventListener(ev);
 }