예제 #1
0
        /// <summary>
        /// The register event handler.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <param name="handler">
        /// The handler.
        /// </param>
        /// <typeparam name="T">
        /// </typeparam>
        /// <returns>
        /// The <see cref="ChromelyConfiguration"/>.
        /// </returns>
        public virtual ChromelyConfiguration RegisterEventHandler <T>(CefEventKey key, ChromelyEventHandler <T> handler)
        {
            var service = CefEventHandlerFakeTypes.GetHandlerType(key);

            IoC.RegisterInstance(service, handler.Key, handler);
            return(this);
        }
예제 #2
0
        /// <summary>
        /// The register event handler.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <param name="handler">
        /// The handler.
        /// </param>
        /// <typeparam name="T">
        /// This is the event argument classe - e,g - LoadErrorEventArgs, FrameLoadStartEventArgs.
        /// </typeparam>
        public void RegisterEventHandler <T>(CefEventKey key, ChromelyEventHandler <T> handler)
        {
            if (_windowCreated)
            {
                throw new Exception("\"RegisterEventHandler\" method must be called before \"Run\" method.");
            }

            HostConfig?.RegisterEventHandler(key, handler);
        }
예제 #3
0
        private void RegisterEventHandler <TEventArgs>(
            IChromelyContainer container,
            CefEventKey key,
            Action <object, TEventArgs, IChromelyContainer> handler)
        {
            var service      = CefEventHandlerTypes.GetHandlerType(key);
            var eventHandler = new ChromelyEventHandler <TEventArgs>(key, (s, e) => handler(s, e, container));

            container.RegisterInstance(service, eventHandler.Key, eventHandler);
        }
예제 #4
0
        /// <summary>
        /// The get custom handler type.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="Type"/>.
        /// </returns>
        public static Type GetHandlerType(CefEventKey key)
        {
            switch (key)
            {
            case CefEventKey.None:
                return(typeof(INoneHandler));

            case CefEventKey.FrameLoadStart:
                return(typeof(IFrameLoadStartHandler));

            case CefEventKey.AddressChanged:
                return(typeof(IAddressChangedHandler));

            case CefEventKey.TitleChanged:
                return(typeof(ITitleChangedHandler));

            case CefEventKey.FrameLoadEnd:
                return(typeof(IFrameLoadEndHandler));

            case CefEventKey.LoadingStateChanged:
                return(typeof(ILoadingStateChangedHandler));

            case CefEventKey.ConsoleMessage:
                return(typeof(IConsoleMessageHandler));

            case CefEventKey.StatusMessage:
                return(typeof(IStatusMessageHandler));

            case CefEventKey.LoadError:
                return(typeof(ILoadErrorHandler));

            case CefEventKey.TooltipChanged:
                return(typeof(ITooltipChangedHandler));

            case CefEventKey.BeforeClose:
                return(typeof(IBeforeCloseHandler));

            case CefEventKey.BeforePopup:
                return(typeof(IBeforePopupHandler));

            case CefEventKey.PluginCrashed:
                return(typeof(IPluginCrashedHandler));

            case CefEventKey.RenderProcessTerminated:
                return(typeof(IRenderProcessTerminatedHandler));
            }

            return(null);
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChromelyEventHandler{T}"/> class.
 /// </summary>
 /// <param name="eventKey">
 /// The event key.
 /// </param>
 /// <param name="handler">
 /// The handler.
 /// </param>
 public ChromelyEventHandler(CefEventKey eventKey, EventHandler <T> handler)
 {
     Key     = eventKey.EnumToString();
     Handler = handler;
 }
예제 #6
0
 /// <summary>
 /// The register event handler.
 /// </summary>
 /// <param name="key">
 /// The key.
 /// </param>
 /// <param name="handler">
 /// The handler.
 /// </param>
 /// <typeparam name="T">
 /// </typeparam>
 /// <returns>
 /// The <see cref="ChromelyConfiguration"/>.
 /// </returns>
 public virtual ChromelyConfiguration RegisterEventHandler <T>(CefEventKey key, EventHandler <T> handler)
 {
     return(RegisterEventHandler <T>(key, new ChromelyEventHandler <T>(key, handler)));
 }
예제 #7
0
 public static string EnumToString(this CefEventKey key)
 {
     return(Enum.GetName(key.GetType(), key));
 }
예제 #8
0
        private void RegisterEventHandler <T>(IChromelyContainer container, CefEventKey key, ChromelyEventHandler <T> handler)
        {
            var service = CefEventHandlerTypes.GetHandlerType(key);

            container.RegisterInstance(service, handler.Key, handler);
        }