/// <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); }
/// <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); }
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); }
/// <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); }
/// <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; }
/// <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))); }
public static string EnumToString(this CefEventKey key) { return(Enum.GetName(key.GetType(), key)); }
private void RegisterEventHandler <T>(IChromelyContainer container, CefEventKey key, ChromelyEventHandler <T> handler) { var service = CefEventHandlerTypes.GetHandlerType(key); container.RegisterInstance(service, handler.Key, handler); }