Exemplo n.º 1
0
 private void OnCoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     if (!e.IsSuccess)
     {
         if (e.InitializationException != null)
         {
             // save this error someplace so we can show it to the user later when they try and enable WebView2.
             RaiseBrowserException(new WebView2Exception(e.InitializationException.Message));
         }
     }
     if (this.webBrowser2.CoreWebView2 != null)
     {
         this.webBrowser2.CoreWebView2.DOMContentLoaded    += CoreWebView2_DOMContentLoaded;
         this.webBrowser2.CoreWebView2.NavigationCompleted += CoreWebView2_NavigationCompleted;
         this.webBrowser2.Visible    = true;
         this.webBrowser1.Visible    = false;
         this.webBrowser2.ZoomFactor = 1.25;
         this._webView2Supported     = true;
     }
     else
     {
         WebBrowserFallback();
     }
     _webInitialized = true;
 }
Exemplo n.º 2
0
        private void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
        {
            webView.CoreWebView2.Settings.IsZoomControlEnabled          = false;
            webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = true;
            webView.CoreWebView2.Settings.AreDevToolsEnabled            = true;

            webView.CoreWebView2.NavigationStarting += (s, e) =>
            {
                Console.WriteLine("URI = " + e.Uri);
                if (!e.IsUserInitiated)
                {
                    //webView.CoreWebView2.Stop();
                    //webView.Source = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, @"assest\initf.html"));
                }
            };

            webView.CoreWebView2.ProcessFailed += (s, e) =>
            {
                System.Diagnostics.Trace.WriteLine("Stock shit!");
            };
            webView.CoreWebView2.PermissionRequested += (s, e) =>
            {
                e.State = e.PermissionKind == CoreWebView2PermissionKind.UnknownPermission ? CoreWebView2PermissionState.Deny : CoreWebView2PermissionState.Allow;
            };
        }
        private void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
        {
            // in case i want to run some scripts...
            //webView.CoreWebView2.ExecuteScriptAsync($"alert('Initialized successfuly')");
            //loading_label.Visibility = Visibility.Hidden;
            webView.CoreWebView2.Settings.IsZoomControlEnabled          = false;
            webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = true;
            webView.CoreWebView2.Settings.AreDevToolsEnabled            = true;

            webView.CoreWebView2.NewWindowRequested += (s, e) =>
            {
                e.Handled = true;
            };
            webView.CoreWebView2.NavigationStarting += (s, e) =>
            {
                if (!e.IsUserInitiated)
                {
                    webView.CoreWebView2.Stop();
                    webView.CoreWebView2.NavigateToString("<html><body><button>Click here..</button></body></html>");
                    //webView.CoreWebView2.ExecuteScriptAsync($"alert('No shit!!')");
                }
                //else
                //webView.CoreWebView2.ExecuteScriptAsync($"alert('{e.Uri}  is mine :)')");
            };
            webView.CoreWebView2.ProcessFailed += (s, e) =>
            {
                System.Diagnostics.Trace.WriteLine("Stock shit!");
            };
            webView.CoreWebView2.PermissionRequested += (s, e) =>
            {
                e.State = e.PermissionKind == CoreWebView2PermissionKind.UnknownPermission ? CoreWebView2PermissionState.Deny : CoreWebView2PermissionState.Allow;
            };
        }
Exemplo n.º 4
0
        void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
        {
            if (e.IsSuccess)
            {
                return;
            }

            MessageBox.Show($"WebView2 creation failed with exception = {e.InitializationException}");
        }
 private void Browser_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     if (e.IsSuccess)
     {
         _appFunc = ((App)Application.Current).AppFunc;
         Browser.CoreWebView2.WebResourceRequested += BrowserWebResourceRequestedAsync;
         Browser.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All);
     }
 }
Exemplo n.º 6
0
        private void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
        {
            if (!e.IsSuccess)
            {
                throw e.InitializationException;
            }

            this.WebView.CoreWebView2.Navigate(Arguments.LoginRedirectUrl);
        }
Exemplo n.º 7
0
        void Control_CoreWebView2Ready(object sender, CoreWebView2InitializationCompletedEventArgs e)
        {
            if (!e.IsSuccess)
            {
                throw new WebView2InitializationException("Failed to initialze WebView2", e.InitializationException);
            }

            // can't actually do anything here, so execute them in the main loop
            Application.Instance.AsyncInvoke(RunDelayedActions);
        }
Exemplo n.º 8
0
        private void Browser_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
        {
            var coreWebView = Browser.CoreWebView2;

            coreWebView.NewWindowRequested += CoreWebView2_NewWindowRequested;
            coreWebView.AddHostObjectToScript("zreSpider", bridge);
            coreWebView.AddScriptToExecuteOnDocumentCreatedAsync("var zreSpider = window.chrome.webview.hostObjects.zreSpider;");
            coreWebView.DocumentTitleChanged += CoreWebView2_DocumentTitleChanged;
            coreWebView.DownloadStarting     += CoreWebView_DownloadStarting;
            // coreWebView.DOMContentLoaded += CoreWebView_DOMContentLoaded;
        }
Exemplo n.º 9
0
 private void CoreWebView2Ready(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     try
     {
         ((WebView2)sender).CoreWebView2.ProcessFailed += ProcessFailed;
     }
     catch (Exception ex)
     {
         // Note that in testing, this pretty much came down to the browser being in a disposed state (happened during testing) - but a catch is enough to handle this!
         Debug.Print($"Error attaching ProcessFailed event to CoreWebView2: {ex.Message}");
     }
 }
        private void Browser_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
        {
            if (e.IsSuccess)
            {
                _appFunc = ((App)Application.Current).AppFunc;
                Browser.CoreWebView2.WebResourceRequested += BrowserWebResourceRequestedAsync;
                Browser.NavigationStarting += Browser_NavigationStarting;
                Browser.SourceChanged      += Browser_SourceChanged;
                Browser.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All);

                _owinResourceHandler = new OwinResourceHandler(_appFunc);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// What to do when WebView is initialized.(Navigate to the source, and add the any JS scripts/functions
 /// which need to be defined at startup)
 /// </summary>
 private void OnWebViewInitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     if (_webView?.CoreWebView2 == null)
     {
         return;
     }
     _webView.Source = new Uri(_htmlPath);
     _webView.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(
         Properties.Resources.AddDocumentClickListener);
     _webView.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(Properties.Resources
                                                                    .QueryInputElementsInDOM);
     _webView.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(Properties.Resources.SetValuesInDom);
 }
Exemplo n.º 12
0
 private void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     if (!e.IsSuccess)
     {
         MessageBox.Show("CoreWebView2InitializationFailed");
         return;
     }
     if (!(sender is WebView2 webViewSender))
     {
         MessageBox.Show("CoreWebView2InitializationFailed, sender is not a WebView2");
         return;
     }
     webViewSender.CoreWebView2.ProcessFailed += CoreWebView2_ProcessFailed;
 }
Exemplo n.º 13
0
 private void Browser_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     try
     {
         var webView = sender as WebView2;
         if (webView.CoreWebView2 != null)
         {
             webView.CoreWebView2.AddHostObjectToScript("authService", _authService);
         }
     }
     catch (Exception ex)
     {
         // throw;
     }
 }
Exemplo n.º 14
0
 private void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     webView2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
     webView2.CoreWebView2.Settings.IsStatusBarEnabled            = false;
     webView2.CoreWebView2.Settings.AreDevToolsEnabled            = Debugger.IsAttached;
     webView2.Show();
     webView2.BringToFront();
     if (null != AutoUpdater.BasicAuthChangeLog)
     {
         var resourceRequest = webView2.CoreWebView2.Environment.CreateWebResourceRequest(_args.ChangelogURL, "GET", Stream.Null, $"Authorization: {AutoUpdater.BasicAuthChangeLog}");
         webView2.CoreWebView2.NavigateWithWebResourceRequest(resourceRequest);
     }
     else
     {
         webView2.CoreWebView2.Navigate(_args.ChangelogURL);
     }
 }
Exemplo n.º 15
0
 private void ProctoringControl_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     if (e.IsSuccess)
     {
         CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
         CoreWebView2.Settings.AreDevToolsEnabled            = false;
         CoreWebView2.Settings.IsStatusBarEnabled            = false;
         CoreWebView2.ContainsFullScreenElementChanged      += CoreWebView2_ContainsFullScreenElementChanged;
         CoreWebView2.PermissionRequested += CoreWebView2_PermissionRequested;
         logger.Info("Successfully initialized.");
     }
     else
     {
         logger.Error("Failed to initialize!", e.InitializationException);
     }
 }
Exemplo n.º 16
0
 // Token: 0x0600000F RID: 15 RVA: 0x00002149 File Offset: 0x00000349
 private void WebView2_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     this.webView2.CoreWebView2.Navigate("https://discord.com/login");
 }
Exemplo n.º 17
0
    private void MainBrowserOnCoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
    {
        var wv = MainBrowser.CoreWebView2;

        wv?.Navigate(Site.LoginPageUrl);
    }
Exemplo n.º 18
0
        private void WebView2Control_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
        {
            if (!e.IsSuccess)
            {
                MessageBox.Show($"WebView2 creation failed with exception = {e.InitializationException}");
                UpdateTitleWithEvent("CoreWebView2InitializationCompleted failed");
                return;
            }

            this.webView2Control.CoreWebView2.SourceChanged        += CoreWebView2_SourceChanged;
            this.webView2Control.CoreWebView2.HistoryChanged       += CoreWebView2_HistoryChanged;
            this.webView2Control.CoreWebView2.DocumentTitleChanged += CoreWebView2_DocumentTitleChanged;
            this.webView2Control.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.Image);
            UpdateTitleWithEvent("CoreWebView2InitializationCompleted succeeded");
        }
 private void ProctoringControl_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     if (e.IsSuccess)
     {
         CoreWebView2.ContainsFullScreenElementChanged += CoreWebView2_ContainsFullScreenElementChanged;
         CoreWebView2.PermissionRequested += CoreWebView2_PermissionRequested;
         logger.Info("Successfully initialized.");
     }
     else
     {
         logger.Error("Failed to initialize!", e.InitializationException);
     }
 }
Exemplo n.º 20
0
 private void WebView2Control_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     _logger.Verbose("[WebView2Control] CoreWebView2InitializationCompleted ");
     _webView2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
     _webView2.CoreWebView2.Settings.AreDevToolsEnabled            = false;
     _webView2.CoreWebView2.Settings.AreHostObjectsAllowed         = false;
     _webView2.CoreWebView2.Settings.IsScriptEnabled      = true;
     _webView2.CoreWebView2.Settings.IsZoomControlEnabled = false;
     _webView2.CoreWebView2.Settings.IsStatusBarEnabled   = true;
     _webView2.CoreWebView2.DocumentTitleChanged         += CoreWebView2_DocumentTitleChanged;
 }
Exemplo n.º 21
0
 private void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
 {
     this.WebView.CoreWebView2.ContentLoading   += new EventHandler <CoreWebView2ContentLoadingEventArgs>(this.OnContentLoagind);
     this.WebView.CoreWebView2.DOMContentLoaded += CoreWebView2_DOMContentLoaded;
     this._tiempos = new TableOfTime(this.WebView.CoreWebView2, this.CHTiempos, this.GRVPeticiones);
 }
Exemplo n.º 22
0
        private void WebView2Control_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
        {
            if (!e.IsSuccess)
            {
                MessageBox.Show($"WebView2 creation failed with exception = {e.InitializationException}");
                UpdateTitleWithEvent("CoreWebView2InitializationCompleted failed");
                return;
            }

            this.webView2Control.CoreWebView2.SourceChanged        += CoreWebView2_SourceChanged;
            this.webView2Control.CoreWebView2.HistoryChanged       += CoreWebView2_HistoryChanged;
            this.webView2Control.CoreWebView2.DocumentTitleChanged += CoreWebView2_DocumentTitleChanged;
            this.webView2Control.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.Image);

            // add a host object
            this.webView2Control.CoreWebView2.AddHostObjectToScript("counter", new ConnectionHost());

            //this.webView2Control.CoreWebView2.OpenDevToolsWindow();

            this.webView2Control.CoreWebView2.Navigate("http://localhost/webview2test/Content/test.html");

            UpdateTitleWithEvent("CoreWebView2InitializationCompleted succeeded");
        }