Example #1
0
        private void OnNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            if (!e.IsSuccess)
            {
                var json = JObject.FromObject(new {
                    url       = e.Uri,
                    errorCode = e.WebErrorStatus,
                    errorText = e.WebErrorStatus.ToString(),
                    tab       = 0
                });
                Context.DispatchEvent(WebViewEvent.OnFail, json.ToString());
                return;
            }

            var browser = (WebView)sender;

            for (var index = 0; index < _tabs.Count; index++)
            {
                if (!_tabs[index].Equals(browser))
                {
                    continue;
                }
                var tabDetails = GetTabDetails(index);
                if (!tabDetails.IsLoading)
                {
                    return;
                }

                tabDetails.IsLoading = false;
                SendPropertyChange(@"isLoading", false, index);
            }
        }
Example #2
0
        private async void AssetControl_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            await InjectScript("pdfHelper.js");

            var pdfContent = Convert.ToBase64String(File.ReadAllBytes("test.pdf"));

            AssetControl.InvokeScript("openPdf", pdfContent, "", "");
        }
Example #3
0
 private void WebView1_OnNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
 {
     this.Url.Text = e.Uri?.ToString() ?? string.Empty;
     this.Title    = this.WebView1.DocumentTitle;
     if (!e.IsSuccess)
     {
         MessageBox.Show($"Could not navigate to {e.Uri?.ToString() ?? "NULL"}", $"Error: {e.WebErrorStatus}", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        private void OnFrameNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs args)
        {
            var handler = FrameNavigationCompleted;

            if (handler != null)
            {
                handler(this, args);
            }
        }
 private void webView1_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
 {
     url.Text = e.Uri?.ToString() ?? string.Empty;
     Text     = webView1.DocumentTitle;
     if (!e.IsSuccess)
     {
         MessageBox.Show($"Could not navigate to {e.Uri}", $"Error: {e.WebErrorStatus}",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private async void Webview_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            if (e.IsSuccess && !supportsInitializeScript)
            {
                string initScript = Resources.GetInitScript("Windows");
                await ExecuteScriptAsync(initScript);
            }

            PageLoaded?.Invoke(this, new PageLoadEventArgs(e.Uri, e.IsSuccess));
        }
Example #7
0
        private void SetMouseEvents(object sender, WebViewControlNavigationCompletedEventArgs e)
        {//.getElementById('video-playback') twitch
            webView1.InvokeScript("eval", "document.onmousedown = function(event){window.external.notify('mdn'+';'+event.clientX+';'+event.clientY);}");
            webView1.InvokeScript("eval", "document.onmouseup = function(event){window.external.notify('mup'+';'+event.clientX+';'+event.clientY);}");
            webView1.InvokeScript("eval", "document.onmousemove = function(event){window.external.notify('mmm'+';'+event.clientX+';'+event.clientY);}");
            webView1.InvokeScript("eval", "document.ondblclick = function(event){window.external.notify('dbl'+';'+event.clientX+';'+event.clientY);}");
            webView1.InvokeScript("eval", "document.onwheel = function(event){window.external.notify('whl'+';'+event.deltaY);}");

            webView1.InvokeScript("eval", "document.onkeydown = function(event){window.external.notify('kkk'+';'+event.keyCode);}");
        }
Example #8
0
        private async void Webview_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            if (e.IsSuccess && config.EnableScriptInterface)
            {
                string initScript = Resources.GetInitScript("Windows");
                await ExecuteScriptAsync(initScript);
            }

            PageLoaded?.Invoke(this, PageLoadEventArgs.GetFor(e.IsSuccess));
        }
 private void NavigateExecute(WebViewControlNavigationCompletedEventArgs e)
 {
     if (e?.Uri.Host == "wpf.local")
     {
         var    composedUrl = new Url(e.Uri?.AbsoluteUri);
         string code        = composedUrl.QueryParams["code"]?.ToString();
         _credentialService.SetCode(code);
         _eventAggregator.GetEvent <CodeEvent>().Publish();
         this.CloseDialogCommand.Execute($"{true}");
     }
 }
Example #10
0
        private void GPlayWebView_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            // Display error dialog if navigation fails
            if (!e.IsSuccess)
            {
                MessageBox.Show($"Navigation to {e.Uri?.ToString() ?? "NULL"}", $"Error: {e.WebErrorStatus}", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            // Synchronously call Update
            Update();
        }
Example #11
0
        private async void WebViewOnNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            if (_loadCompletion == null)
            {
                return;
            }

            var html = await _webView.InvokeScriptAsync("eval", "document.documentElement.outerHTML;");

            _loadCompletion.SetResult(html);
        }
Example #12
0
        private void Viewport_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            this.logger.Verbose("WebView navigation complete for {0}, checking if screen capture needed...", this.Config.PrettyName);

            if (!this.IsCaptureInProgress)
            {
                this.logger.Verbose("Screen capture not needed, screen capture not in progress for {0}", this.Config.PrettyName);
                return;
            }

            this.Viewport_NavigationCompletedImpl();
        }
Example #13
0
 private void Browser_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
 {
     if (e.IsSuccess == false)
     {
         btn_refresh.Visibility = Visibility.Visible;
         _canRefresh            = true;
         Logger.Error("Login", $"Navigation to {e.Uri.ToString()} failed with error: {e.WebErrorStatus.ToString()}");
     }
     else
     {
         btn_refresh.Visibility = Visibility.Collapsed;
     }
 }
 private void WebView_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
 {
     if (e.Uri.Fragment.Contains("access_token"))
     {
         Properties.Settings.Default.Token = e.Uri.Fragment.Split('&')[0].Substring(14);
         DialogResult = true;
         this.Close();
     }
     else if (!e.Uri.AbsoluteUri.Contains(@"oauth.vk.com/authorize"))
     {
         webView.Navigate(@"https://oauth.vk.com/authorize?client_id=7331234&display=page&redirect_uri=https://oauth.vk.com/blank.html&scope=0&response_type=token&v=5.52&revoke=1");
     }
 }
Example #15
0
        private void wv_nav2(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            string  html         = wv.InvokeScript("eval", new string[] { "document.documentElement.outerHTML;" });
            string  output       = "{" + html.Split('{', '}')[1] + "}";
            dynamic responseBody = JObject.Parse(output);

            var values = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(output);

            bearer = "Bearer " + values["access_token"];

            this.Close();
            exit = true;
        }
Example #16
0
        void WebBrowserOnNavigated(object sender, WebViewControlNavigationCompletedEventArgs navigationEventArgs)
        {
            if (navigationEventArgs.Uri == null)
            {
                return;
            }

            string url = navigationEventArgs.Uri.IsAbsoluteUri ? navigationEventArgs.Uri.AbsoluteUri : navigationEventArgs.Uri.OriginalString;

            SendNavigated(new UrlWebViewSource {
                Url = url
            }, _eventState, WebNavigationResult.Success);
            UpdateCanGoBackForward();
        }
        private void OnNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs args)
        {
            // We could have used
            // if (NavigationCompleted != null) NavigationCompleted(this, args);
            // However, if there is a subscriber and the moment the null check and the call to
            // the event handler by the method is invoked, the subscriber may unsubscribe
            // (e.g. on a different thread) and cause a NullReferenceException.
            // To work around this create a temporarly local variable to store the reference and check that
            var handler = NavigationCompleted;

            if (handler != null)
            {
                handler(this, args);
            }
        }
Example #18
0
        /*static void ResponseThread()
         * {
         *  while (true)
         *  {
         *      HttpListenerContext context = httpListener.GetContext();
         *      Console.WriteLine(context.Request.Url);
         *      byte[] responseArray = Encoding.UTF8.GetBytes("<html><head><title>Localhost Server</title></head><body>Hello world!</body>");
         *      context.Response.OutputStream.Write(responseArray, 0, responseArray.Length);
         *      context.Response.KeepAlive = false;
         *      context.Response.Close();
         *  }
         * }*/

        private void Web_TrigglehLogin_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            // string functionQuery = string.Format("document.body.innerText");
            // string queryResult = await web_TrigglehLogin.InvokeScriptAsync("eval", new string[] { functionQuery });
            // Console.WriteLine(queryResult);

            if (e.Uri.Host != Globals.HOST)
            {
                return;
            }

            NameValueCollection parameters = HttpUtility.ParseQueryString(e.Uri.Query);

            username = parameters.Get("user_name");
            user_id  = parameters.Get("user_id");
        }
        private async void BrowserOnNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            string html = await Browser.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" });

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(html);
            var mp4 = doc.DocumentNode.Descendants("source").First().GetAttributeValue("src", "no link");

            Debug.WriteLine(mp4);
            MainWindow mainWindow = (MainWindow)App.Current.MainWindow;

            mainWindow.StreamURL.Text = mp4;

            Browser.NavigationCompleted -= BrowserOnNavigationCompleted;
            Browser.GoBack();
        }
Example #20
0
 // ナビゲーション完了時に発生するイベント
 private void WebView1_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
 {
     if (e.IsSuccess)
     {
         // 表示に成功した
         // 例えば、e.Uriが、表示したWebページのURI
         // WebView1.DocumentTitleが、Webページのタイトル
         this.Title                = this.WebView1.DocumentTitle;
         this.UrlTextBox.Text      = e.Uri.ToString();
         this.MessageTextBox.Text += $"Completed: {e.Uri}\r\n";
     }
     else
     {
         // 表示に失敗した
         // e.WebErrorStatusでエラーが分かる
         this.MessageTextBox.Text += $"Failed: {e.WebErrorStatus} ({(int)e.WebErrorStatus})\r\n";
     }
 }
        private async void Webview_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            await webview.InvokeScriptAsync("eval", new[] { script });

            //如果进入视频页面,解锁刷课按钮
            btn_Start.IsEnabled = false;
            if (e.Uri.ToString().Contains("study"))
            {
                btn_Start.IsEnabled = true;
            }
            else
            {
                btn_Start.IsChecked = false;
            }

            if (isLoading == true)
            {
                PUMessageBox.CloseAwait();
                webview.Visibility = Visibility.Visible;
                isLoading          = false;
            }
        }
Example #22
0
        private void wv_nav(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            if (e.Uri.ToString().Contains("code"))
            {
                var query = HttpUtility.ParseQueryString(e.Uri.Query);
                code = query["code"];

                string url      = FORGE_BASE_URL + "/authentication/v1/gettoken";
                string postBody = string.Format(
                    "client_id={0}&client_secret={1}&grant_type=authorization_code&code={2}&redirect_uri={3}",
                    FORGE_CLIENT_ID, FORGE_CLIENT_SECRET, code, FORGE_CALLBACK_URL);
                IDictionary <string, string> headers = new Dictionary <string, string>();
                headers.Add("content-type", "application/x-www-form-urlencoded");
                headers.Add("client_id", FORGE_CLIENT_ID);
                headers.Add("client_secret", FORGE_CLIENT_SECRET);
                headers.Add("grant_type", "authorization_code");
                headers.Add("code", code);
                headers.Add("redirect_uri", FORGE_CALLBACK_URL);
                wv.NavigationCompleted += new EventHandler <WebViewControlNavigationCompletedEventArgs>(wv_nav2);
                wv.Navigate(new Uri(url), System.Net.Http.HttpMethod.Post, postBody, headers);
            }
        }
Example #23
0
        private void OnNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
        {
            /*Context.SendEvent("TRACE", e.IsSuccess
             *  ? $@"NavigationCompleted: {e.Uri}"
             *  : $@"WebErrorStatus: {e.WebErrorStatus}");*/

            var browser = (WebView)sender;

            for (var index = 0; index < _tabs.Count; index++)
            {
                if (!_tabs[index].Equals(browser))
                {
                    continue;
                }
                var tabDetails = GetTabDetails(index);
                if (!tabDetails.IsLoading)
                {
                    return;
                }

                tabDetails.IsLoading = false;
                SendPropertyChange(@"isLoading", false, index);
            }
        }
 private void Browser_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
 {
     Logger.InfoDelayed("Login", $"Navigation to {e.Uri} {e.WebErrorStatus}", TimeSpan.FromSeconds(5));
 }
 private void OnNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
 => ViewModel.OnNavigationCompleted(e);
Example #26
0
 private void AssetControl_Navigated(object sender, WebViewControlNavigationCompletedEventArgs e)
 {
     // throw new NotImplementedException();
 }
 private void OnNavigationCompleted(object o, WebViewControlNavigationCompletedEventArgs a)
 {
     WriteLine($"{WebView.GetType().Name}.{nameof(WebView.NavigationCompleted)}: Uri: {a.Uri?.ToString() ?? string.Empty}, Success: {a.IsSuccess}, Error: {a.WebErrorStatus}");
     Application.DoEvents();
 }
Example #28
0
 private void HandleNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
 {
     throw new NotImplementedException();
 }
Example #29
0
 private void Edge_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
 {
     this.DocumentTitle = ((WebView)this.webView).DocumentTitle + " (Edge)";
     this.DocumentCompleted?.Invoke(this, EventArgs.Empty);
 }
Example #30
0
 private void WebView_FrameNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
 {
     Debug.WriteLine(callerName());
     LMonitor.OnEndLoading(e.Uri.ToString(), true);
     UpdateHistory();
 }