private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { SetCanGoBack(args.CanGoBack); SetCanGoForward(args.CanGoForward); this.InvokeOnUiThreadIfRequired(() => SetIsLoading(!args.CanReload)); }
/// <summary> /// Sets the loading state change. /// </summary> /// <param name="args">The <see cref="LoadingStateChangedEventArgs"/> instance containing the event data.</param> void IWebBrowserInternal.SetLoadingStateChange(LoadingStateChangedEventArgs args) { CanGoBack = args.CanGoBack; CanGoForward = args.CanGoForward; IsLoading = args.IsLoading; var handler = LoadingStateChanged; if (handler != null) { handler(this, args); } }
private void ChromeBrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { if (WidgetData.liveyPropertiesData == null || e.IsLoading) { return; } try { if (chromeBrowser.CanExecuteJavascriptInMainFrame) //if js context ready { foreach (var item in WidgetData.liveyPropertiesData) { string uiElementType = item.Value["type"].ToString(); if (!uiElementType.Equals("button", StringComparison.OrdinalIgnoreCase) && !uiElementType.Equals("label", StringComparison.OrdinalIgnoreCase)) { if (uiElementType.Equals("slider", StringComparison.OrdinalIgnoreCase) || uiElementType.Equals("dropdown", StringComparison.OrdinalIgnoreCase)) { Form1.chromeBrowser.ExecuteScriptAsync("livelyPropertyListener", item.Key, (int)item.Value["value"]); } else if (uiElementType.Equals("folderDropdown", StringComparison.OrdinalIgnoreCase)) { var filePath = Path.Combine(Path.GetDirectoryName(htmlPath), item.Value["folder"].ToString(), item.Value["value"].ToString()); if (File.Exists(filePath)) { Form1.chromeBrowser.ExecuteScriptAsync("livelyPropertyListener", item.Key, Path.Combine(item.Value["folder"].ToString(), item.Value["value"].ToString())); } else { Form1.chromeBrowser.ExecuteScriptAsync("livelyPropertyListener", item.Key, null); //or custom msg } } else if (uiElementType.Equals("checkbox", StringComparison.OrdinalIgnoreCase)) { Form1.chromeBrowser.ExecuteScriptAsync("livelyPropertyListener", item.Key, (bool)item.Value["value"]); } else if (uiElementType.Equals("color", StringComparison.OrdinalIgnoreCase) || uiElementType.Equals("textbox", StringComparison.OrdinalIgnoreCase)) { Form1.chromeBrowser.ExecuteScriptAsync("livelyPropertyListener", item.Key, (string)item.Value["value"]); } } } } } catch { } }
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { //Wait for the page to finish loading if (args.IsLoading == false) { StartAsync(); } //SetCanGoBack(args.CanGoBack); //SetCanGoForward(args.CanGoForward); //this.InvokeOnUiThreadIfRequired(() => SetIsLoading(!args.CanReload)); }
private void LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { if (e.Browser.IsLoading) { return; } #if DEBUG _browser.ShowDevTools(); #endif _browser.LoadingStateChanged -= LoadingStateChanged; OnPageLoadded(); }
// active event handlers private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { if (!e.IsLoading) { browser.AddWordToDictionary("tweetdeck"); browser.AddWordToDictionary("TweetDeck"); browser.AddWordToDictionary("tweetduck"); browser.AddWordToDictionary("TweetDuck"); browser.AddWordToDictionary("TD"); Invoke(new Action(SetupWindow)); browser.LoadingStateChanged -= Browser_LoadingStateChanged; } }
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { //Wait for while page to finish loading not just the first frame //LogManager.AddLogMessage(Name, "OnLoadingStateChanged", sender.ToString() + " | " + args.IsLoading, LogManager.LogMessageType.DEBUG); if (!args.IsLoading) { browser.LoadingStateChanged -= OnLoadingStateChanged; //LogManager.AddLogMessage(Name, "OnLoadingStateChanged", "LOADED!!!", LogManager.LogMessageType.DEBUG); //This is required when using a standard TaskCompletionSource //Extension method found in the CefSharp.Internals namespace //tcs.TrySetResultAsync(true); } }
private static void BrowserLoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { // Check to see if loading is complete - this event is called twice, one when loading starts // second time when it's finished // (rather than an iframe within the main frame). if (e.IsLoading) { // Remove the load event handler, because we only want one snapshot of the initial page. browser.LoadingStateChanged -= BrowserLoadingStateChanged; var scriptTask = browser.EvaluateScriptAsync("document.getElementById('lst-ib').value = 'CefSharp Was Here!'"); scriptTask.ContinueWith(t => { //Give the browser a little time to render Thread.Sleep(500); // Wait for the screenshot to be taken. var task = _browser.ScreenshotAsync(); task.ContinueWith( x => { // Make a file to save it to (e.g. C:\Users\jan\Desktop\CefSharp screenshot.png) var screenshotsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "CefSharp screenshot.png"); Console.WriteLine(); Console.WriteLine("Screenshot ready. Saving to {0}", screenshotsPath); // Save the Bitmap to the path. // The image type is auto-detected via the ".png" extension. task.Result.Save(screenshotsPath); // We no longer need the Bitmap. // Dispose it to avoid keeping the memory alive. Especially important in 32-bit applications. task.Result.Dispose(); Console.WriteLine("Screenshot saved. Launching your default image viewer..."); // Tell Windows to launch the saved image. Process.Start( new ProcessStartInfo(screenshotsPath) { // UseShellExecute is false by default on .NET Core. UseShellExecute = true }); Console.WriteLine("Image viewer launched. Press any key to exit."); }, TaskScheduler.Default); }); } #endregion }
public void OnDownloadUpdated(IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback) { var handler = OnDownloadUpdatedFired; if (handler != null) { handler(this, downloadItem); } if (downloadItem != null && browser != null && downloadItem.IsComplete) { CefSharp.LoadingStateChangedEventArgs e = new LoadingStateChangedEventArgs(browser, true, false, false); OnLoadingStateChanged(e); } }
private async void chromiumBrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { Address_textBox.Text = chromiumBrowser.Address; if (e.IsLoading) { await Task.Delay(50); int val = siteLoading.Value + siteLoading.Value / 2; if (val <= 100) { siteLoading.Value = val; } } }
private void chromiumWebBrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { try { string sMsg = (e.IsLoading ? "Loading..." : chromiumWebBrowser.Address); Console.WriteLine(sMsg); if (e.IsLoading == false) { //브라우저 로드 완료시 해야할 일을 실행 } } catch { } }
protected async Task <bool> IsPageLoading(ChromiumWebBrowser wb, LoadingStateChangedEventArgs e) { if (e.IsLoading) { return(true); } var html = await wb.GetSourceAsync(); if (html == "<html><head></head><body></body></html>") { return(true); } return(false); }
public void LoadingStateChangedEvent(object sender, LoadingStateChangedEventArgs e) { if (e.IsLoading == false) { if (site.Equals("mitele")) { myBrowser.ExecuteScriptAsync("$('div').eq(0).css({ position:'absolute', top:0, left:0, width:'100%', height:'100%'});"); } else if (site.Equals("youtube")) { myBrowser.ExecuteScriptAsync("$('.ytp-iv-video-content').css({ position:'absolute', top:0, left:0, width:'100%', height:'100%'});"); } } }
/// <summary> /// listens for page to be loaded /// </summary> private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { if (!args.IsLoading) { // Page has finished loading, do whatever you want here /*MainView.mainGrid.Dispatcher.Invoke(() => * { * MainView.mainGrid.RowDefinitions[0].Height = new GridLength(0); * MainView.mainGrid.Children.RemoveAt(0); * MainView.mainGrid.RowDefinitions[1].Height = new GridLength(1.0, GridUnitType.Star); * });*/ } }
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { if (!args.IsLoading) { this.SetBrowserLoadingOverlayVisiblity(false); this.SetLoaderVisiblity(false); this.SetLoader2Visiblity(false); } else { this.SetBrowserLoadingOverlayVisiblity(true); this.SetLoaderVisiblity(true); this.SetLoader2Visiblity(true); } }
void wbDict_LoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { if (args.IsLoading) { return; } Dispatcher.Invoke(async() => { var s = args.Browser.MainFrame.Url; if (!s.StartsWith("data")) { tbURL.Text = s; } await vmDict.OnNavigationFinished(); }); }
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { if (!args.IsLoading) { var iconURL = "http://www.google.com/s2/favicons?domain=" + XENGINE; WebRequest request = HttpWebRequest.Create(iconURL); WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); dynamic favicon = Image.FromStream(stream); string i = Convert.ToString(myimg.Images.Count); myimg.Images.Add(i, favicon); tabControl.ImageList = myimg; tabControl.SelectedTab.ImageIndex = myimg.Images.Count - 1; } }
/// <summary> /// Manage the IsLoading parameter /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PageLoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { if (!e.IsLoading) { Dispatcher.Invoke(new System.Action(() => { if (currentURL != Browser.Address) { Browser.ExecuteScriptAsync(s); currentURL = (string)Browser.Address.Clone(); } })); } }
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { /* if (formBegin != null) * { * Thread.Sleep(1000); * Thread thread = new Thread(new ThreadStart(delegate () // thread 생성 * { * this.Invoke(new Action(delegate () // this == Form 이다. Form이 아닌 컨트롤의 Invoke를 직접호출해도 무방하다. * { * this.formBegin.load2(0, callcenter_idx); * })); * })); * thread.Start(); * }*/ }
private void OnBrowserLoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { try { this.InvokeOnUiThreadIfRequired(() => SetchromeBrowserVisible(!args.CanReload)); this.InvokeOnUiThreadIfRequired(BuildContextMenuFromHistory); this.InvokeOnUiThreadIfRequired(IsUrlInBookmarks); BuildContextMenuFromHistory(); } catch (Exception ex) { Log.ErrorFormat("[whlBrowser.OnBrowserLoadingStateChanged] Critical error. Exception {0}", ex); } }
private async void Dashboard(object s, LoadingStateChangedEventArgs e) { var wb = s as ChromiumWebBrowser; if (e.IsLoading || wb == null) { return; } Log.Info("Logged in"); var scriptTask = await wb.EvaluateScriptAsync( $"getTransactionHistory('INDEX_1','0011')"); wb.LoadingStateChanged -= Dashboard; wb.LoadingStateChanged += Monitor; }
private async void Monitor(object s, LoadingStateChangedEventArgs e) { var wb = s as ChromiumWebBrowser; if (e.IsLoading || wb == null) { return; } await wb.SavePageScreenShot(@"C:\Users\killjaeden\Desktop\a.png"); Log.Info("Enter Otp for Ibanking"); var otp = WaitForInput("Enter OTP for IBanking Logging in"); PageAnalyzeFinished.Set(); }
private void MainBrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { Dispatcher.Invoke(() => { try { urlTextbox.Text = MainBrowser.Address; titleLabel.Content = MainBrowser.Title; titleLabel.ToolTip = MainBrowser.Title; if (MainBrowser == null) { } else if (MainBrowser.Title == string.Empty) { } else if (MainBrowser.Address.StartsWith("data")) { } else { // debounce creation of history for 2s, so that it doesn't log history for unnecessary redirects debounceDispatcher.Debounce(2000, _ => { History.CreateHistory(new History { Url = MainBrowser.Address, Title = MainBrowser.Title, Timestamp = DateTime.Now }); }); } if (IsUrlYoutubeVideo(MainBrowser.Address)) { YoutubeModeMenuItem.IsEnabled = true; } else { YoutubeModeMenuItem.IsEnabled = false; } } catch (Exception exc) { //MessageBox.Show(exc.ToString()); } }); }
//logging public async void LoginPageLoaded(object sender, LoadingStateChangedEventArgs e) { CefWebBrowser.LoadingStateChanged -= LoginPageLoaded; //TODO Check if user entered all req data var script = "(function(){ var field = document.getElementById(\"user\"); if(field){return true}else return field; })();"; var response = await CefWebBrowser.EvaluateScriptAsync(script); if (response.Result != null) { if ((bool)response.Result) { tryagain: script = $@"(function(){{ document.getElementById(""user"").value = ""{loginbox.Text}""; document.getElementById(""password"").value = ""{passwordbox.Text}""; document.getElementsByClassName(""btn-login"")[0].click(); }})();"; response = await CefWebBrowser.EvaluateScriptAsync(script); script = $@" document.getElementsByClassName(""world-select"").length > 0"; response = await CefWebBrowser.EvaluateScriptAsync(script); if (response.Result != null) { if ((bool)response.Result) { script = $@"(function(){{ var worlds = document.getElementsByClassName(""world-select""); for (i = 0; i < worlds.length; i++) {{ if (worlds[i].getAttribute(""href"").includes(""{worldbox.Text}"")) {{ window.location.href = worlds[i].getAttribute(""href""); }} }} }})();"; response = await CefWebBrowser.EvaluateScriptAsync(script); } else { System.Threading.Thread.Sleep(1000); goto tryagain; } } } } return; }
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { setCanGoBack(args.CanGoBack); setCanGoForward(args.CanGoForward); setIsLoading(args.IsLoading); if (!args.IsLoading) { Tools.Logger.Log("Finished loading of " + args.Browser.MainFrame.Url, Logger.LogLevel.debug); string mainControllerName = Arguments.GetArgument("browser-js-mainController_name", "ScChrom"); string postInitScript = Tools.Arguments.GetArgument("injected-javascript", ""); MainController.Instance.BrowserJsController.InitBrowser(browser, mainControllerName, postInitScript); } }
private void BrowserLoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { if (!e.Browser.IsLoading) { this.InvokeOnUiThreadIfRequired(ShowBrowserControl); } if (!e.CanReload) { return; } var overridePostMessage = "window.postMessage = function(data, origin){ postMessageListener.received(JSON.stringify(data), origin); }"; Browser.ExecuteScriptAsync(overridePostMessage); }
private async void Renderer_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { if (e.IsLoading == false && isRenderable) { try { var uri = new System.Uri(Path); var converted = uri.AbsoluteUri; var fix = converted.Replace("'", "%27").Replace("file://", "localfiles://"); var result = await Renderer.EvaluateScriptAsync("SetSkin", new object[] { fix }); } catch (Exception ex) { } } }
/// <summary> /// Invoked when the browser starts or finishes loading /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void BrowserLoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { // Done loading? if (!e.IsLoading) { // Find a better way to modify the UI than to invoke dispatcher Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { // Find the loading fade out Storyboard Storyboard fadeOut = (Storyboard)this.FindResource("FadeOutLoading"); // Fade out the loading image fadeOut.Begin(); })); } }
private async void Browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { if (!e.IsLoading) { var html = await browser.GetSourceAsync(); if (this.triger == null) { this.Invoke((Action) delegate { OnComplete?.Invoke(new Kuto(html), new EventArgs()); this.Close(); }); } } }
private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { // DocumentCompleted に相当? // note: 非 UI thread からコールされるので、何かしら UI に触る場合は適切な処置が必要 if (e.IsLoading) return; BeginInvoke((Action)(() => { ApplyStyleSheet(); ApplyZoom(); DestroyDMMreloadDialog(); })); }
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args) { ChromiumWebBrowser browser = (ChromiumWebBrowser)sender; try { string sMsg = (args.IsLoading ? "Loading..." : browser.Address); if (args.IsLoading == false) { //브라우저 로드 완료시 해야할 일을 실행 //browser.ExecuteScriptAsync("setTimeout(function(){console.log('action:redirect');},3000);"); } } catch { } }
private static void BrowserLoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { // Check to see if loading is complete - this event is called twice, one when loading starts // second time when it's finished // (rather than an iframe within the main frame). if (!e.IsLoading) { // Remove the load event handler, because we only want one snapshot of the initial page. browser.LoadingStateChanged -= BrowserLoadingStateChanged; var scriptTask = browser.EvaluateScriptAsync("document.getElementById('lst-ib').value = 'CefSharp Was Here!'"); scriptTask.ContinueWith(t => { //Give the browser a little time to render Thread.Sleep(500); // Wait for the screenshot to be taken. var task = browser.ScreenshotAsync(); task.ContinueWith(x => { // Make a file to save it to (e.g. C:\Users\jan\Desktop\CefSharp screenshot.png) var screenshotPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "CefSharp screenshot.png"); Console.WriteLine(); Console.WriteLine("Screenshot ready. Saving to {0}", screenshotPath); // Save the Bitmap to the path. // The image type is auto-detected via the ".png" extension. task.Result.Save(screenshotPath); // We no longer need the Bitmap. // Dispose it to avoid keeping the memory alive. Especially important in 32-bit applications. task.Result.Dispose(); Console.WriteLine("Screenshot saved. Launching your default image viewer..."); // Tell Windows to launch the saved image. Process.Start(screenshotPath); Console.WriteLine("Image viewer launched. Press any key to exit."); }); }); } }
void IWebBrowserInternal.SetLoadingStateChange(LoadingStateChangedEventArgs args) { UiThreadRunAsync(() => { SetCurrentValue(CanGoBackProperty, args.CanGoBack); SetCurrentValue(CanGoForwardProperty, args.CanGoForward); SetCurrentValue(IsLoadingProperty, args.IsLoading); ((DelegateCommand)BackCommand).RaiseCanExecuteChanged(); ((DelegateCommand)ForwardCommand).RaiseCanExecuteChanged(); ((DelegateCommand)ReloadCommand).RaiseCanExecuteChanged(); }); var handler = LoadingStateChanged; if (handler != null) { handler(this, args); } }
protected internal virtual void OnLoadingStateChanged(LoadingStateChangedEventArgs e) { var handler = LoadingStateChanged; if (handler != null) { handler(this, e); } }
private void OnWebBrowserLoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { if (e.CanReload && (Title.CompareTo("淘宝网 - 淘!我喜欢") == 0) && Address.Contains("www.taobao.com")) { if (Title.CompareTo("已卖出的宝贝") != 0) { Thread.Sleep(1000); WebBrowser.Load("https://trade.taobao.com/trade/itemlist/list_sold_items.htm"); StatusMsg += "Load 已卖出的宝贝"; isGetList = false; } } if (e.CanReload && (Title.CompareTo("已卖出的宝贝") == 0) && !isGetList) { StatusMsg += "get inneHTML"; isGetList = true; GetInnerHTML(); // string input = (string)evaluateJavaScriptResult; } }
private void OnLoadingStateChange(IntPtr self, IntPtr browser, int isloading, int cangoback, int cangoforward) { var e = new LoadingStateChangedEventArgs { Browser = Browser.FromHandle(browser), IsLoading = Convert.ToBoolean(isloading), CanGoBack = Convert.ToBoolean(cangoback), CanGoForward = Convert.ToBoolean(cangoforward) }; _delegate.OnLoadingStateChanged(e); }