public BrowserControl() { _loaded = false; InitializeComponent(); if (WebCore.IsInitialized) { WebCore.ResourceInterceptor = this; } else { // We could simply write this like that: //WebCore.Started += ( s, e ) => WebCore.ResourceInterceptor = this; // See below why we don't do it. CoreStartEventHandler handler = null; handler = (s, e) => { // Though this example shuts down the core when this // MainWindow closes, in a normal application scenario, // there could be many instances of MainWindow. We don't // want them all referenced by the WebCore singleton // and kept from garbage collection, so the handler // has to be removed. WebCore.Started -= handler; WebCore.ResourceInterceptor = this; }; WebCore.Started += handler; } // Assign our global ShowCreatedWebView handler. webControl.ShowCreatedWebView += StacicBrowser.OnShowNewView; _whitelist = new string[] { "asset", "youtube.com", "code.google.com", "webmaster442.hu" }; }
public MainWindow() { // Initialize the Core before InitializeComponent. // When the WebControl is created, it will automatically // initialize the Core with default configuration. WebCore.Initialize(new WebConfig() { HomeURL = new Uri("asset://local/web/index.html"), LogLevel = LogLevel.Verbose, }); InitializeComponent(); // Since we perform lazy initialization, this is a // safe way to assign the ResourceInterceptor, only when // the WebCore is initialized. if (WebCore.IsInitialized) { WebCore.ResourceInterceptor = this; } else { // We could simply write this like that: //WebCore.Started += ( s, e ) => WebCore.ResourceInterceptor = this; // See below why we don't do it. CoreStartEventHandler handler = null; handler = (s, e) => { // Though this example shuts down the core when this // MainWindow closes, in a normal application scenario, // there could be many instances of MainWindow. We don't // want them all referenced by the WebCore singleton // and kept from garbage collection, so the handler // has to be removed. WebCore.Started -= handler; WebCore.ResourceInterceptor = this; }; WebCore.Started += handler; } // Assign our global ShowCreatedWebView handler. webControl.ShowCreatedWebView += App.OnShowNewView; }