/// <summary> /// 检测版本切换 /// </summary> private void SwitchVersion() { String url = web_bro.Url.ToString(); //如果是标准版 if (url.Contains("standard")) { web_bro.Navigate(Common.CommonApiLang.Alipay_Switch_Url); } }
private void ShowWebUri() { try { if (_winformWebBrowser == null) { //winform _winformWebBrowser = new System.Windows.Forms.WebBrowser() { Url = new Uri(BrowserUriTextBox.Text), AllowWebBrowserDrop = false, WebBrowserShortcutsEnabled = false, IsWebBrowserContextMenuEnabled = false }; _winformWebBrowser.NewWindow += (s, e1) => { e1.Cancel = true; }; _windowsFormsHost.Child = _winformWebBrowser; BrowserGrid.Children.Add(_windowsFormsHost); } _winformWebBrowser.Navigate(BrowserUriTextBox.Text); } catch (Exception exception) { Console.WriteLine(exception); } }
public async Task <string> GetAccessCode() { string result = string.Empty; HttpResponseMessage response = await GetAuthorizeResponse(Credential); string code = await GetAccessCodeInternal(response); if (!string.IsNullOrEmpty(code)) { return(code); } string content = await response.Content.ReadAsStringAsync(); wb.Navigated += Wb_Navigated; wb.Navigate(response.RequestMessage.RequestUri); using (System.Windows.Forms.Form form = new System.Windows.Forms.Form()) { form.Controls.Add(wb); wb.Dock = System.Windows.Forms.DockStyle.Fill; if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { return(form.Text); } } return(string.Empty); }
public AutomationBrowserForClickOnWebPage(string webInstanceVar) { InitializeComponent(); automation_browser = new System.Windows.Forms.WebBrowser { //disable the default context menu //IsWebBrowserContextMenuEnabled = false }; automation_browser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(web_DocumentCompleted); windowsFormsHost.Child = automation_browser; if (!string.IsNullOrEmpty(webInstanceVar)) { if (!string.IsNullOrEmpty(VariableStorage.Url_tracker[webInstanceVar])) { url_text.Text = VariableStorage.Url_tracker[webInstanceVar]; selenium_url = url_text.Text; automation_browser.Navigate(url_text.Text); } } }
private void AnalyticsTracking() { if (this.DoNotTrack()) { return; } var id = this.GetId(); var ver = ApplicationManager.AppVersion.EmptyToNull() ?? "dev"; this.Dispatcher.Invoke(new Action(() => { try { var wb = new System.Windows.Forms.WebBrowser { ScriptErrorsSuppressed = true }; var url = string.Format("https://bitbucket.org/alienlab/sitecore-instance-manager/wiki/Tracking?version={0}&id={1}", ver, id); wb.Navigate(url, null, null, "User-Agent: Sitecore Instance Manager"); } catch (Exception ex) { Log.Error("Failed to update statistics internal identifier", this, ex); } })); }
public Window1(OverlayStyle style) { InitializeComponent(); if (style == OverlayStyle.WPF) { WebBrowserOverlay wbo = new WebBrowserOverlay(_webBrowserPlacementTarget); WebBrowser wb = wbo.WebBrowser; wb.Navigate(new Uri("http://live.com")); _showOtherButton.Content = "Show WinForms-based overlay"; } else if (style == OverlayStyle.WinForms) { WebBrowserOverlayWF wbo = new WebBrowserOverlayWF(_webBrowserPlacementTarget); System.Windows.Forms.WebBrowser wb = wbo.WebBrowser; wb.Navigate(new Uri("http://live.com")); _showOtherButton.Content = "Show WPF-based overlay"; } _showOtherButton.Click += delegate { new Window1(style == OverlayStyle.WinForms ? OverlayStyle.WPF : OverlayStyle.WinForms).Show(); }; }
private void btn_baidu_login_Click(object sender, RoutedEventArgs a) { var b = new System.Windows.Forms.WebBrowser(); b.Width = 800; b.Height = 600; b.AllowNavigation = true; var w = new System.Windows.Window(); b.Navigated += (s, e) => { try { var m = new Regex("access_token=(.*?)&").Match(e.Url.ToString()); if (m.Success) { Global.AppSettings["baidu_access_token"] = m.Groups[1].Value; w.Close(); } else { } } catch (Exception ex) { Logger.Error(ex); } }; b.Navigate(new PCS_client().GetAccessTokenPage()); var h = new System.Windows.Forms.Integration.WindowsFormsHost(); h.Child = b; w.Content = h; w.ShowDialog(); }
public void UrlCall(Dictionary <string, EnumLib.ExchangeCurrencyCode> Temp, bool resize = false) { try { this.Dispatcher.BeginInvoke(new Action(() => { if (string.IsNullOrWhiteSpace(StringEnum.GetStringValue(Temp.Values.First()))) { return; } CoinType = Temp; int height = web.Height; int width = web.Width; //string marketNm = Temp.Keys.First().ToString(); //string marketCd = StringEnum.GetStringValue((EnumLib.ExchangeCurrencyCode)Enum.Parse(typeof(EnumLib.ExchangeCurrencyCode), marketNm)); string marketCd = Temp.Keys.First().ToString(); string Url = ConfigLib.WebUrl + "bt.chartInit.dp/proc.go?headViewYn=N&coinInfo=" + StringEnum.GetStringValue(Temp.Values.First()) + "&height=" + height + "px&width=" + width + "px&marketCd=" + marketCd; web.Navigate(Url); })); } catch (Exception ex) { SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace); } }
public ChatControl(ref System.Windows.Forms.WebBrowser browser, string pageurl) { wb = browser; wb.ObjectForScripting = this; wb.Navigate(pageurl); wb.AllowNavigation = false; }
public void search(String s, System.Windows.Forms.WebBrowser b) { if (String.IsNullOrEmpty(s)) { return; } if (s.Equals("about:blank")) { return; } if (!s.StartsWith("http://") && !s.StartsWith("https://")) { s = "http://" + s; } try { b.Navigate(new Uri(s)); } catch (System.UriFormatException) { return; } site_list.Add(s); }
/// <summary> /// Code to show browser based content, applicable for URL's /// If the Header value is not provided, the content is projected in full screen mode /// </summary> /// <param name="Content"></param> /// <param name="header"></param> private void ShowBrowser(String Content, String header) { try { //Check if header is null //Null - Show full screen content if (String.IsNullOrEmpty(header)) { //Show the full screen video control //Display HTML content host = new System.Windows.Forms.Integration.WindowsFormsHost(); browserElement = new System.Windows.Forms.WebBrowser(); browserElement.ScriptErrorsSuppressed = true; helper = new Utilities.ScriptingHelper(this); browserElement.ObjectForScripting = helper; host.Child = browserElement; helper.PropertyChanged += helper_PropertyChanged; FullScreenContentGrid.Children.Clear(); FullScreenContentGrid.Children.Add(host); FullScreenContentGrid.Visibility = Visibility.Visible; FullScreenVideoGrid.Visibility = Visibility.Collapsed; } else { TitleLabel.Text = header; host = new System.Windows.Forms.Integration.WindowsFormsHost(); browserElement = new System.Windows.Forms.WebBrowser(); browserElement.ScriptErrorsSuppressed = true; helper = new Utilities.ScriptingHelper(this); host.Child = browserElement; browserElement.ObjectForScripting = helper; helper.PropertyChanged += helper_PropertyChanged; ContentGrid.Children.Clear(); ContentGrid.Children.Add(host); ContentGrid.Visibility = Visibility.Visible; FullScreenContentGrid.Visibility = Visibility.Collapsed; FullScreenVideoGrid.Visibility = Visibility.Collapsed; VideoGrid.Visibility = Visibility.Collapsed; } String fileLocation = Helper.GetAssetURI(Content); String pageUri = String.Empty; //Local file if (File.Exists(fileLocation)) { String[] PathParts = fileLocation.Split(new char[] { ':' }); pageUri = "file://127.0.0.1/" + PathParts[0] + "$" + PathParts[1]; } //Web hosted file else { pageUri = Content; } browserElement.Navigate(pageUri); this.UpdateLayout(); } catch (Exception ex) { RippleCommonUtilities.LoggingHelper.LogTrace(1, "Went wrong in Show Browser {0}", ex.Message); } }
private async Task Navigate(String url) { NavigateWaitHandle handle = new NavigateWaitHandle(url); _waitHandles.Add(handle); WebBrowser.Navigate(url); await handle.Wait(); }
private void Page_Loaded(object sender, RoutedEventArgs e) { webOverlay = new WebBrowserOverlayWF(this.body_web); webForm = webOverlay.WebBrowser; webForm.Navigate(new Uri("http://59.173.8.184:20081/trace/wap/cs/home")); webForm.ScrollBarsEnabled = false; webForm.ObjectForScripting = new HandleScript(); }
private void btnDoc_Checked(object sender, RoutedEventArgs e) { RadioButton radioBtn = sender as RadioButton; if ((bool)radioBtn.IsChecked) { webBrowser1.Navigate(radioBtn.Tag.ToString()); } }
private void consultarPagina(string Url) { baseUrl = Url; browser = new System.Windows.Forms.WebBrowser(); browser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(DocumentCompleted); browser.ScriptErrorsSuppressed = true; browser.Visible = true; browser.Navigate(Url); }
public void navigate(string url) { if (wb.Url.AbsoluteUri == "about:blank") { wb.Navigate(url); } Minecraft.PAGE_STATES.MENU_GRID.Height = 0; }
public static void Init() { webBrowser = new System.Windows.Forms.WebBrowser(); var document = DynamicTableJavascript.Document; webBrowser.Navigate("about:blank"); webBrowser.Document.Write(document); }
public CameraAdapter(Uri cameraUri) { _cameraUri = cameraUri; _browser = new System.Windows.Forms.WebBrowser { ScrollBarsEnabled = false, MinimumSize = new System.Drawing.Size(1900, 1100) }; _browser.Navigate(cameraUri); }
public void UrlCall(Dictionary <string, EnumLib.ExchangeCurrencyCode> Temp, bool resize = false) { try { if (Temp == null) { return; } if (string.IsNullOrWhiteSpace(StringEnum.GetStringValue(Temp.Values.First()))) { NowCoin = StringEnum.GetStringValue(EnumLib.ExchangeCurrencyCode.BTC); } NowCoin = StringEnum.GetStringValue(Temp.Values.First()); NowDict = Temp; string marketCd = Temp.Keys.First().ToString(); string coinInfo = StringEnum.GetStringValue(Temp.Values.First()); if (resize) { if (20 > Math.Abs(webWidth - web.Width)) { return; } } webWidth = web.Width; webHeight = web.Height + 160; if (web.Url == null) { string Url = ConfigLib.WebUrl + "bt.chartInit.dp/proc.go?headViewYn=N&coinInfo=" + NowCoin + "&height=" + webHeight + "px&width=" + webWidth + "px&marketCd=" + marketCd; //string Url = ConfigLib.WebUrl + "bt.chartInit.dp/proc.go?headViewYn=N&marketCd=" + marketCd + "&coinInfo = " + NowCoin + "&width=" + webWidth + "px&height=" + webHeight + "px"; web.Navigate(Url); } else { object[] param = new object[4]; param[0] = marketCd; param[1] = coinInfo; param[2] = webWidth; param[3] = webHeight; web.Document.InvokeScript("htsChart", param); } } catch (Exception ex) { SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace); } }
/// <summary> /// Navigate the browser to the url in case the web browser is live, /// the url is ready and the same is not the same /// </summary> /// <param name="parameters"></param> private void WebBrowserNavigateTo(string url, bool navigateEnforced = false) { if (webBrowser == null || url == null) { return; } if (_currentPage != url || navigateEnforced == true) { _currentPage = url; webBrowser.Navigate(url); Database.GetInstance().LogInfo("Retrospection, navigated to: " + url); } }
public void UrlCall(string orderId, string userPhone, string payMtd) { try { int height = web.Height; int width = web.Width; string Url = ConfigLib.WebUrl + "bt.danal.htsDanal.dp/proc.go?param1=Y&userEmail=" + WebUtility.UrlEncode(MainViewModel.LoginDataModel.userEmail) + "&userNm=" + WebUtility.UrlEncode(MainViewModel.LoginDataModel.userNm) + "&user_mobile=" + WebUtility.UrlEncode(userPhone) + "&inMthCd=" + WebUtility.UrlEncode(payMtd) + "&orderId=" + WebUtility.UrlEncode(orderId) + "&height=" + height + "&width=" + width; web.Navigate(Url); } catch (Exception ex) { SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace); } }
public void UpdateHtml(string html) { browser.Navigate("about:blank"); try { if (browser.Document != null) { browser.Document.Write(string.Empty); } } catch (Exception) { } // do nothing with this browser.DocumentText = html; }
public void UrlCall(string userEmail, string userMobile, string userNm, string userBrithDay) { try { int height = web.Height; int width = web.Width; string Url = ConfigLib.WebUrl + "bt.front.mypage.danalUserHts.ds/proc.go?user_email=" + WebUtility.UrlEncode(userEmail) + "&user_mobile=" + WebUtility.UrlEncode(userMobile) + "&birth_day=" + WebUtility.UrlEncode(userBrithDay) + "&isUptYn=" + WebUtility.UrlEncode("Y") + "&htsYn=" + WebUtility.UrlEncode("Y"); //+ "&height=" + height + "&width=" + width; //"&user_nm=" + WebUtility.UrlEncode(userNm) MessageBox.Show(Url); web.Navigate(Url); } catch (Exception ex) { SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace); } }
private void btnPcbComponent_Checked(object sender, RoutedEventArgs e) { RadioButton radioBtn = sender as RadioButton; if ((bool)radioBtn.IsChecked) { if (File.Exists(radioBtn.Tag.ToString())) { webBrowser1.Navigate(radioBtn.Tag.ToString()); } pcbComponents.Children.Clear(); ModelBase model = new ModelBase(radioBtn.Content.ToString()); pcbComponents.Children.Add(model); } }
public void scrapData(string Url, int cantidad) { browser = new System.Windows.Forms.WebBrowser(); browser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(DocumentCompleted); HtmlDocument document = null; int contador = 0; HtmlWeb web = new HtmlWeb(); while (contador <= cantidad) { browser.Navigate(Url); browser.Visible = true; browser.Refresh(); while (completed) { System.Windows.Forms.Application.DoEvents(); Thread.Sleep(100); botonClik = browser.Document.GetElementById("btnMoreResults"); botonClik.InvokeMember("click"); document = (HtmlDocument)browser.Document.DomDocument; HtmlNode[] nodes = document.DocumentNode.SelectNodes(".//a/@href").ToArray(); Console.Write("Buscando Recetas....."); using (var progress = new ProgressBar()) { foreach (HtmlNode enlace in nodes) { foreach (HtmlAttribute atributo in enlace.Attributes) { if (RegexTool.isUrl(atributo.Value)) { HtmlDocument recipe = web.Load(atributo.Value); if (hasRecipe(recipe)) { contador++; progress.Report((double)contador / cantidad); Thread.Sleep(20); getMicroData(recipe); } } } } } } } Console.WriteLine("Listo."); Console.ReadLine(); }
public Webbrowser() { //WebBrowserHelper.FixBrowserVersion(); InitializeComponent(); wb = new System.Windows.Forms.WebBrowser(); FormsHost.Child = wb; wb.ScriptErrorsSuppressed = true; wb.Navigate("about:blank"); System.Windows.Forms.Button btn = button(); wb.Controls.Add(btn); btn.BringToFront(); }
private static string CreateTestHtml(string html, Dictionary <string, string> dic) { try { System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser(); wb.Navigate("about:blank"); var doc = wb.Document; doc.OpenNew(false); doc.Write(html); wb.Refresh(); var div = doc.CreateElement("div"); wb.Document.Body.InsertAdjacentElement(System.Windows.Forms.HtmlElementInsertionOrientation.AfterBegin, div); var table = doc.CreateElement("table"); div.AppendChild(table); { var tbody = doc.CreateElement("tbody"); table.AppendChild(tbody); { foreach (var keyv in dic) { var tr = doc.CreateElement("tr"); tbody.AppendChild(tr); var td1 = doc.CreateElement("td"); td1.Style = "font-weight:bold"; td1.InnerText = keyv.Key; var td2 = doc.CreateElement("td"); td2.InnerText = keyv.Value; td2.Style = "color:red"; tr.AppendChild(td1); tr.AppendChild(td2); } } } div.InsertAdjacentElement(System.Windows.Forms.HtmlElementInsertionOrientation.BeforeEnd, doc.CreateElement("hr")); return(wb.Document.Body.OuterHtml); } catch (Exception ex) { return(html); } }
/// <summary> /// 使用System.Windows.Forms.WebBrowser来抓取(支持动态跳转) /// 需要连续且快速抓取不是动态跳转的页面,推荐使用HttpWebRequest类 /// </summary> /// <param name="uIElement"></param> /// <param name="url"></param> /// <param name="timeout"></param> /// <returns></returns> public static async Task <string> GetDynamicHtmlSourceWithIE(System.Windows.UIElement uIElement, string url, int timeout = 6000) { System.Windows.Forms.WebBrowser webBrowser = new System.Windows.Forms.WebBrowser(); webBrowser.ScriptErrorsSuppressed = true; var source = ""; //这里注意几点 //System.Windows.Forms.WebBrowser需要UI线程调用,所以传入UIElement //动态网站会跳转多次,取最后一次DocumentText try { await Task.Run(() => { uIElement.Dispatcher.Invoke(() => { webBrowser.Navigated += WebBrowser_Navigated; webBrowser.Navigate(url); }); while (true) { var waitResult = ieAutoResetEvent.WaitOne(timeout); if (waitResult == true) { uIElement.Dispatcher.Invoke(() => { source = webBrowser.DocumentText; }); } else { //这里目前只能借助等待超时来做,因为不知道动态页面会跳转多少次 //正常访问时,跳转会比较快,最后一次需要等待设置的超时时间 //超时后直接返回 //如果不是需要多次跳转的页面,可以把while去掉,只等待一次 break; } } }); return(source); } catch { return(source); } }
public static void Translate(string sourceText, Languages sourceLanguage, Languages targetLanguage) { if (IsTranslating) { return; } string serverUri = "http://translate.google.com/#" + sourceLanguage.GetAbbreviatedCode() + "/" + targetLanguage.GetAbbreviatedCode() + "/" + EscapeUriString(sourceText); OriginalText = sourceText; IsTranslating = true; _navigated = false; webBrowser.Navigate(serverUri); }
private void KnowledgeChanged() { var myBrowser = new System.Windows.Forms.WebBrowser(); browserHost.Child = myBrowser; var filePath = _knowledge.GetContentLocalPath(); if (filePath != null) { myBrowser.Navigate(filePath); } else { myBrowser.DocumentText = _knowledge.GetKnowledgeHtml(); } }
/// <summary> /// 一个很BT的获取IE默认UserAgent的方法 /// </summary> private static string GetDefaultUserAgent() { System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser(); wb.Navigate("about:blank"); while (wb.IsBusy) { System.Windows.Forms.Application.DoEvents(); } object window = wb.Document.Window.DomWindow; Type wt = window.GetType(); object navigator = wt.InvokeMember("navigator", System.Reflection.BindingFlags.GetProperty, null, window, new object[] { }); Type nt = navigator.GetType(); object userAgent = nt.InvokeMember("userAgent", System.Reflection.BindingFlags.GetProperty, null, navigator, new object[] { }); return(userAgent.ToString()); }
public override void TryLogin(string UserId, SecureString Password) { this.UserId = UserId; this.Password = Password; if (UserId.Length == 0 || Password.Length == 0) { OnCompleted(LoginCode.WRONG_USER, string.Empty, UserId); return; } LoginAttemptNum = 0; if (Browser != null) Browser.Dispose(); Browser = new System.Windows.Forms.WebBrowser() { ScriptErrorsSuppressed = true }; Browser.DocumentCompleted += LoginDocumentCompleted; Browser.Navigate("http://member.imbc.com/Login/Login.aspx"); OnStateChanged(LoginState.LOGINNING); }
/// <summary> /// Handles the Loaded event of the Window control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void WindowLoaded(object sender, RoutedEventArgs e) { if (AeroGlassCompositionEnabled) { ExcludeElementFromAeroGlass(border); SetAeroGlassTransparency(); } Title = "Login to {0}".FormatWith((string)Engine.Name); urlTextBox.Text = Engine.Site; favicon.Source = new BitmapImage(new Uri("http://getfavicon.appspot.com/http://{0}/".FormatWith(new Uri(Engine.Site).DnsSafeHost))); _webBrowser = new WebBrowser { ScriptErrorsSuppressed = true }; _webBrowser.DocumentCompleted += WebBrowserDocumentCompleted; winFormsHost.Child = _webBrowser; _webBrowser.Navigate(Engine.Site); Utils.Win7Taskbar(state: TaskbarProgressBarState.Indeterminate); }
private void openBrowser(Uri url) { //SystemWindow browser = new SystemWindow(600,600); System.Windows.Forms.Form test = new System.Windows.Forms.Form(); test.Icon = new System.Drawing.Icon(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "application.ico")); test.Height = 480; test.Width = 640; test.Text = "MatterControl"; browser = new System.Windows.Forms.WebBrowser(); browser.DocumentCompleted += browser_DocumentCompleted; browser.Navigate(url); browser.Dock = System.Windows.Forms.DockStyle.Fill; test.Controls.Add(browser); test.Show(); //browser.AddChild(br); //browser.ShowAsSystemWindow(); }
private void webBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e) { FacebookOAuthResult oauthResult; if (_fb.TryParseOAuthCallbackUrl(e.Uri, out oauthResult)) { FacebookOAuthResult = oauthResult; this.Close(); } else if (e.Uri.AbsoluteUri.StartsWith("https://www.facebook.com/connect/login_success.html")) { // the last try on XP shadowBrowser = new System.Windows.Forms.WebBrowser(); shadowBrowser.Navigated += shadowBrowser_Navigated; shadowBrowser.Navigate(_loginUrl); } else { FacebookOAuthResult = null; } }
//Sends a modversion to the specified mod at the solder website public static void SendSolderModVersion(string solderUrl, string email, string password, string id, string version) { using (CookieAwareWebClient client = GetAuthenticatedWebClient(solderUrl, email, password)) { string getURL = solderUrl + "post.php?id=" + id + "&version=" + version; var cookies = client.CookieContainer.GetCookies(new Uri(solderUrl.Substring(0, solderUrl.Length - 1))); System.Windows.Forms.WebBrowser browser = new System.Windows.Forms.WebBrowser(); browser.Navigate(getURL, "", null, "Cookie: " + cookies[0].Value + Environment.NewLine + "Cookie: " + cookies[1].Value + Environment.NewLine); } }
private void GetValue(string productLink) { webBrowser = new System.Windows.Forms.WebBrowser {AllowNavigation = true}; webBrowser.DocumentCompleted += b_DocumentCompleted; webBrowser.Navigate(productLink); }