public Bitmap DrawBitmap(int theight, int twidth) { Bitmap bitmap3; Bitmap bitmap = new Bitmap(this.Width, this.Height); Rectangle targetBounds = new Rectangle(0, 0, this.Width, this.Height); this.MyBrowser.DrawToBitmap(bitmap, targetBounds); Image image = bitmap; Bitmap bitmap2 = new Bitmap(twidth, theight, image.PixelFormat); Graphics graphics = Graphics.FromImage(bitmap2); graphics.CompositingQuality = CompositingQuality.HighSpeed; graphics.SmoothingMode = SmoothingMode.HighSpeed; graphics.InterpolationMode = InterpolationMode.HighQualityBilinear; Rectangle rect = new Rectangle(0, 0, twidth, theight); graphics.DrawImage(image, rect); try { bitmap3 = bitmap2; } catch { bitmap3 = null; } finally { image.Dispose(); image = null; this.MyBrowser.Dispose(); this.MyBrowser = null; } return bitmap3; }
public static void GetHTML(string url, Func <string, object> successFunc, Func <string, object> errorFunc) { System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser(); Timer timer = new Timer(); timer.Interval = 1000; int i = 0; string html = ""; timer.Tick += (o, a) => { html = wb.DocumentText; if (html.ToLower().Contains("</html>")) { successFunc(html); timer.Enabled = false; } else if (i++ > 100) { errorFunc(html); timer.Enabled = false; } }; wb.Navigated += (s, e) => timer.Enabled = true; wb.Navigate(url); }
public override void Initialize() { base.Initialize(); socket = new GTK.Socket(); Widget = socket; this.Widget.Realized += delegate { var size = new System.Drawing.Size(Widget.WidthRequest, Widget.HeightRequest); view = new SWF.WebBrowser(); view.Size = size; var browser_handle = view.Handle; IntPtr window_handle = (IntPtr)socket.Id; SetParent(browser_handle, window_handle); if (url != null) { view.Navigate(url); } //return false; }; Widget.Show(); }
/// <summary> /// Creates a Text display control /// </summary> /// <param name="options">Region Options for this control</param> public Text(RegionOptions options) : base(options.width, options.height, options.top, options.left) { // Collect some options from the Region Options passed in // and store them in member variables. _filePath = options.uri; _direction = options.direction; _backgroundImage = options.backgroundImage; _backgroundColor = options.backgroundColor; _scaleFactor = options.scaleFactor; _backgroundTop = options.backgroundTop + "px"; _backgroundLeft = options.backgroundLeft + "px"; _documentText = options.text; _scrollSpeed = options.scrollSpeed; _headJavaScript = options.javaScript; // Generate a temporary file to store the rendered object in. _tempHtml = new TemporaryHtml(); // Generate the Head Html and store to file. GenerateHeadHtml(); // Generate the Body Html and store to file. GenerateBodyHtml(); // Fire up a webBrowser control to display the completed file. _webBrowser = new WebBrowser(); _webBrowser.Size = this.Size; _webBrowser.ScrollBarsEnabled = false; _webBrowser.ScriptErrorsSuppressed = true; _webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted); // Navigate to temp file _webBrowser.Navigate(_tempHtml.Path); }
public static void SetIeCompatibility() { WebBrowser webBrowserInstance = new WebBrowser(); int iEnumber = webBrowserInstance.Version.Major; //reference: http://support.microsoft.com/kb/969393/en-us int compatibilityCode = iEnumber * 1000;//Reference:http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation webBrowserInstance.Dispose(); Trace.TraceInformation("Using Internet Explorer {0}", iEnumber); var fileName = Path.GetFileName(Application.ExecutablePath); try { //Note: write to HKCU (HKEY_CURRENT_USER) instead of HKLM (HKEY_LOCAL_MACHINE) because HKLM need admin privilege while HKCU do not. Ref:http://stackoverflow.com/questions/4612255/regarding-ie9-webbrowser-control Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", fileName, compatibilityCode); } catch (Exception ex) { Trace.TraceError(String.Format("Error setting IE compatibility: {0}", ex)); } try //for 32 bit IE on 64 bit windows { Registry.SetValue( @"HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", fileName, compatibilityCode); } catch (Exception ex) { Trace.TraceError(String.Format("Error setting IE compatibility: {0}", ex)); } }
public BrowserScriptRework(WebbrowserForm.BrowserTab browserTab, Utils.BasePlugin.Plugin ownerPlugin, WebBrowser webBrowser, Framework.Interfaces.ICore core) : base(browserTab, ownerPlugin, "Rework", webBrowser, core, true) { core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_REWORK)); webBrowser.Navigating += new WebBrowserNavigatingEventHandler(webBrowser_Navigating); webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted); }
public static void showFunctionBlocksInWebBrower(List<ControlFlowGraphBasicBlock> lcfgBasicBlocks, WebBrowser webBrowser) { if (lcfgBasicBlocks != null && lcfgBasicBlocks.Count > 0) { var blockXml = new StringBuilder(); foreach (ControlFlowGraphBasicBlock basicBlock in lcfgBasicBlocks) { //var tempFile = DI.o2CorLibConfig.TempFileNameInTempDirectory; string xmlContentOfBasicBlock = Serialize.createSerializedXmlStringFromObject(basicBlock,null); if (xmlContentOfBasicBlock != "") { blockXml.AppendLine("<BASICBLOCK>" + xmlContentOfBasicBlock + "</BASICBLOCK>"); } } // Hack to create Xml Doc (replace with proper viewer) var xmlDocument = new XmlDocument(); //var root = xmlDocument.DocumentElement; XmlElement childNode = xmlDocument.CreateElement("Content"); childNode.InnerXml = blockXml.ToString().Replace("<?xml version=\"1.0\"?>", ""); xmlDocument.AppendChild(childNode); string tempXmlFile = DI.config.TempFileNameInTempDirectory + ".xml"; xmlDocument.Save(tempXmlFile); webBrowser.Navigate(tempXmlFile); } }
public void SetUp() { var settings = new Settings(); if (!CEF.Initialize(settings)) { Assert.Fail(); } var thread = new Thread(() => { var form = new Form(); form.Shown += (sender, e) => { Browser = new WebBrowser() { Parent = form, Dock = DockStyle.Fill, }; createdEvent.Set(); }; Application.Run(form); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); createdEvent.WaitOne(); }
public void unInit() { isRunCheck = false; try { if (timeOutCheckThread != null)// && timeOutCheckThread.IsAlive) { timeOutCheckThread.Abort(); timeOutCheckThread = null; } } catch { } try { if (webBrowser != null) { webBrowser.StatusTextChanged -= this.webBrowser1_StatusTextChanged; this.webBrowser.DocumentCompleted -= this.webBrowser1_DocumentCompleted; this.webBrowser.Navigating -= this.webBrowser1_Navigating; } } catch { } webBrowser = null; }
////////////////////////////////////////////////////////////////////////// // Web Document 操作 処理関数 /// <summary> /// id = fileurl の filePathを取得する /// </summary> /// <param name="url"></param> /// <returns></returns> public static String GetPathByID(String url) { // create a hidden web browser, which will navigate to the page System.Windows.Forms.WebBrowser web = new System.Windows.Forms.WebBrowser(); web.ScrollBarsEnabled = false; // we don't want scrollbars on our image web.ScriptErrorsSuppressed = true; // don't let any errors shine through web.Navigate(url); // let's load up that page! // wait until the page is fully loaded while (web.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete) { System.Windows.Forms.Application.DoEvents(); } //System.Threading.Thread.Sleep(1500); // allow time for page scripts to update // the appearance of the page HtmlWindow currentWindow = web.Document.Window; String fileurl = ""; if (web.Document.GetElementById("fileurl") != null) { fileurl = web.Document.GetElementById("fileurl").InnerText; fileurl = Url2Path(fileurl); } web.Dispose(); return(fileurl); }
/// <summary> /// A method to capture a webpage as a System.Drawing.Bitmap /// </summary> /// <param name="URL">The URL of the webpage to capture</param> /// <returns>A System.Drawing.Bitmap of the entire page</returns> public static System.Drawing.Bitmap CaptureWebPage(string URL) { // create a hidden web browser, which will navigate to the page System.Windows.Forms.WebBrowser web = new System.Windows.Forms.WebBrowser(); web.ScrollBarsEnabled = false; // we don't want scrollbars on our image web.ScriptErrorsSuppressed = true; // don't let any errors shine through web.Navigate(URL); // let's load up that page! // wait until the page is fully loaded while (web.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete) { System.Windows.Forms.Application.DoEvents(); } System.Threading.Thread.Sleep(1500); // allow time for page scripts to update // the appearance of the page // set the size of our web browser to be the same size as the page int width = web.Document.Body.ScrollRectangle.Width; int height = web.Document.Body.ScrollRectangle.Height; web.Width = width; web.Height = height; // a bitmap that we will draw to System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, height); // draw the web browser to the bitmap web.DrawToBitmap(bmp, new System.Drawing.Rectangle(0, 0, width, height)); return(bmp); // return the bitmap for processing }
/// <summary> /// initialise browser /// </summary> /// <param name="i"></param> /// <returns></returns> public Browser(System.Windows.Forms.WebBrowser i) { Instance = i; Instance.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(SetBrowserCompleted); FullLoaded = true; UseNewIE(); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.webBrowser1 = new System.Windows.Forms.WebBrowser(); this.SuspendLayout(); // // webBrowser1 // this.webBrowser1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.webBrowser1.Location = new System.Drawing.Point(4, 4); this.webBrowser1.Name = "webBrowser1"; this.webBrowser1.Size = new System.Drawing.Size(387, 334); this.webBrowser1.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(this.WebBrowser1_Navigating); // // ScriptedWindow // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(397, 345); this.Controls.Add(this.webBrowser1); this.Name = "ScriptedWindow"; this.Text = "Scripted Window"; this.Load += new System.EventHandler(this.ScriptedWindow_Load); this.ResumeLayout(false); }
/// <summary> /// 等待页面加载完毕 /// </summary> /// <param name="webBrowser1"></param> /// <returns></returns> public static bool WaitWebPageLoad(System.Windows.Forms.WebBrowser webBrowser1) { int i = 0; string sUrl; while (true) { //系统延迟50毫秒 Delay(50); //先判断是否发生完成事件 if (webBrowser1.ReadyState == WebBrowserReadyState.Complete) { //再判断是浏览器是否繁忙 if (!webBrowser1.IsBusy) { i = i + 1; if (i == 2) { sUrl = webBrowser1.Url.ToString(); //判断没有网络的情况下 if (sUrl.Contains("res")) { return(false); } else { return(true); } } continue; } i = 0; } } }
public override void Initialize() { XmlDocument docInitString = new XmlDocument(); docInitString.LoadXml(_initString); XmlNode nodePortalUrl = docInitString.SelectSingleNode("initstring/CitrixIntegration/portalurl"); if (nodePortalUrl == null || String.IsNullOrEmpty(nodePortalUrl.InnerText)) { // connect using a configured ICA file tInitializeDelay = new System.Threading.Timer(new TimerCallback(InitializeDelay), null, TimeSpan.FromSeconds(10), TimeSpan.Zero); } else { XmlNode nodeAutoSelect = docInitString.SelectSingleNode("initstring/CitrixIntegration/autoselecturl"); if (nodeAutoSelect != null) { autoSelect = nodeAutoSelect.InnerText; } // connect using the Citrix web portal ICAClient.Visible = false; webBrowser1 = new System.Windows.Forms.WebBrowser(); this.Controls.Add(webBrowser1); webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill; webBrowser1.Visible = true; webBrowser1.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(webBrowser1_Navigating); webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); webBrowser1.Navigate(nodePortalUrl.InnerText); InitializeEx(); } }
internal static Image RequestSnapshot(Uri url) { Image result = null; using (var completed = new AutoResetEvent(false)) using (var browser = new WebBrowser()) { browser.ScrollBarsEnabled = false; browser.DocumentCompleted += delegate { result = ExtractSnapshot(browser); completed.Set(); }; browser.Navigate(url); //completed.WaitOne(); while (result == null) { Thread.Sleep(0); Application.DoEvents(); } } return result; }
/// <summary> /// initialise browser /// </summary> /// <param name="i"></param> /// <returns></returns> public Browser(System.Windows.Forms.WebBrowser i) { Instance = i; Instance.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(SetBrowserCompleted); FullLoaded = true; UseNewIE(); }
public WatiN_IE attachTo(System.Windows.Forms.WebBrowser webBrowser) { // need to do this or the attach is not going to work WatiN.Core.Settings.AutoStartDialogWatcher = false; attachTo(webBrowser.ActiveXInstance as InternetExplorer); return(this); }
//创建新tab控件 private TabItem newTab(string title, string url, string id) { TabItem ti = new TabItem(); TabControlPanel panel = new TabControlPanel(); WebBrowser tb = new WebBrowser(); panel.Dock = DockStyle.Fill; panel.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(179)))), ((int)(((byte)(231))))); panel.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(237)))), ((int)(((byte)(254))))); panel.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine; panel.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(97)))), ((int)(((byte)(156))))); panel.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right) | DevComponents.DotNetBar.eBorderSide.Bottom))); panel.Style.GradientAngle = 90; tb.Tag = id; tb.Dock = DockStyle.Fill; tb.ScrollBarsEnabled = false; tb.Navigate(url); tb.Visible = true; panel.Controls.Add(tb); panel.Tag = tb; tabControl1.Controls.Add(panel); ti.Text = title; ti.Tag = tb; panel.TabItem = ti; ti.AttachedControl = panel; tabControl1.Tabs.Add(ti); return (ti); }
private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(BalanceSheetForm)); this.webBrowser = new System.Windows.Forms.WebBrowser(); ((System.ComponentModel.ISupportInitialize)(this.webBrowser)).BeginInit(); this.SuspendLayout(); // // webBrowser // this.webBrowser.Dock = System.Windows.Forms.DockStyle.Fill; this.webBrowser.Enabled = true; //this.webBrowser.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("webBrowser.OcxState"))); this.webBrowser.Size = new System.Drawing.Size(592, 206); this.webBrowser.TabIndex = 0; // // BalanceSheetForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 12); this.ClientSize = new System.Drawing.Size(592, 206); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.webBrowser }); this.Name = "BalanceSheetForm"; this.Text = "Balance Sheet"; //! this.Text = "バランスシート"; ((System.ComponentModel.ISupportInitialize)(this.webBrowser)).EndInit(); this.ResumeLayout(false); }
private void OnEmulate(object sender, EventArgs e) { WebprogressBar.Value = 0; if (Invokes == (No_of_Invokes-1)) { MessageBox.Show("Can't Emulate futher"); } else { InvokeprogressBar.Value = (int)(((float)(Invokes + 1) / (float)No_of_Invokes) * 100); for (int i = 0; i < No_of_Instance; i++) { web[Invokes][i] = new WebBrowser(); web[Invokes][i].Navigate("http://10.75.15.120/webinstance.html"); WebprogressBar.Value = (int)(((float)(i+1) / (float)No_of_Instance) * 100); Thread.Sleep(500); } Invokes++; } }
/// <summary> /// Evento de carga de la pagina /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Loaded(object sender, RoutedEventArgs e) { ServicePointManager.UseNagleAlgorithm = true; ServicePointManager.Expect100Continue = false; ServicePointManager.CheckCertificateRevocationList = true; ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate); //Agregar valores a combobox de tipo exportar tipos_reporte.Add(new ComboBoxPares("0", "PDF")); tipos_reporte.Add(new ComboBoxPares("1", "CSV")); cboDownload.DisplayMemberPath = "_Value"; cboDownload.SelectedValuePath = "_key"; cboDownload.SelectedIndex = 0; cboDownload.ItemsSource = tipos_reporte; timer1.Interval = 15000; timer1.Elapsed += new ElapsedEventHandler(runWorkerTimer); // timer1.Start(); // btnExportar.IsEnabled = false; // btnGrabar.IsEnabled = false; webBrowser = new System.Windows.Forms.WebBrowser(); //webBrowser.Url = new Uri("http://www.sunat.gob.pe/ol-ti-itconsvalicpe/ConsValiCpe.htm", UriKind.Absolute); webBrowser.ScriptErrorsSuppressed = true; webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted); //cargar los docs del paso anterior buscar en bd los estados activos que aun no se han procesado cs_pxCargarDgvComprobanteselectronicos(); }
private static Image Capture(string url, Size size) { Image result = new Bitmap(size.Width, size.Height); var thread = new Thread(() => { using (var browser = new WebBrowser()) { browser.ScrollBarsEnabled = false; browser.AllowNavigation = true; browser.Navigate(url); browser.Width = size.Width; browser.Height = size.Height; browser.ScriptErrorsSuppressed = true; browser.DocumentCompleted += (sender,args) => DocumentCompleted(sender, args, ref result); while (browser.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); return result; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.UrlTxt = ((System.Windows.Controls.TextBox)(target)); return; case 2: this.NavBtn = ((System.Windows.Controls.Button)(target)); #line 10 "..\..\MainWindow.xaml" this.NavBtn.Click += new System.Windows.RoutedEventHandler(this.NavBtn_Click); #line default #line hidden return; case 3: this.TestBtn = ((System.Windows.Controls.Button)(target)); #line 11 "..\..\MainWindow.xaml" this.TestBtn.Click += new System.Windows.RoutedEventHandler(this.TestBtn_OnClick); #line default #line hidden return; case 4: this.PageBrowser = ((System.Windows.Forms.WebBrowser)(target)); return; } this._contentLoaded = true; }
void tabControl_TabItemAdded(object sender) //, TabItemEventArgs e) { // Add an Icon to the tabItem BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Test;component/Images/ie.ico")); Image img = new Image(); img.Source = image; img.Width = 16; img.Height = 16; img.Margin = new Thickness(2, 0, 2, 0); //e.TabItem.Icon = img; // wrap the header in a textblock, this gives us the character ellipsis (...) when trimmed TextBlock tb = new TextBlock(); tb.Text = "New Tab " + count++; tb.TextTrimming = TextTrimming.CharacterEllipsis; tb.TextWrapping = TextWrapping.NoWrap; //e.TabItem.Header = tb; // add a WebControl to the TAbItem WindowsFormsHost host = new WindowsFormsHost(); host.Margin = new Thickness(2); System.Windows.Forms.WebBrowser browser = new System.Windows.Forms.WebBrowser(); browser.DocumentTitleChanged += Browser_DocumentTitleChanged; browser.Navigated += Browser_Navigated; host.Child = browser; //e.TabItem.Content = host; }
public ViewDocumentBrowser(string urlDocument) { InitializeComponent(); webbrowserOne = new WebBrowser(); windowsFormsHost1.Child = webbrowserOne; webbrowserOne.Url = new Uri(urlDocument); }
private void InitializeComponent() { ComponentResourceManager resources = new ComponentResourceManager(typeof(HelpForm)); this.docViewer = new WebBrowser(); base.SuspendLayout(); this.docViewer.AllowWebBrowserDrop = false; this.docViewer.Dock = DockStyle.Fill; this.docViewer.IsWebBrowserContextMenuEnabled = false; this.docViewer.Location = new Point(0, 0); this.docViewer.MinimumSize = new Size(20, 20); this.docViewer.Name = "docViewer"; this.docViewer.Size = new Size(0x124, 0x252); this.docViewer.TabIndex = 2; this.docViewer.TabStop = false; this.docViewer.Url = new Uri("", UriKind.Relative); this.docViewer.WebBrowserShortcutsEnabled = false; base.AutoScaleDimensions = new SizeF(6f, 13f); base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; base.ClientSize = new Size(0x124, 0x252); base.Controls.Add(this.docViewer); base.Icon = (Icon) resources.GetObject("$this.Icon"); base.Name = "HelpForm"; base.StartPosition = FormStartPosition.Manual; this.Text = "HelpForm"; base.ResumeLayout(false); }
public void show_path(System.Windows.Forms.WebBrowser webBrowser) { int end_node = 0; int start_node = int.Parse((this.webBrowser.Document.InvokeScript("getStart")).ToString()); this.webBrowser.Document.InvokeScript("removePath"); set_unsafety_node(); int[] nums = dijkstra(start_node, end_node); for (int i = 0; i < nums.Length - 1; i++) { this.webBrowser.Document.InvokeScript("addPath", new object[] { nums[i], nums[i + 1] }); } for (int i = nums.Length - 1; i > 0; i--) { int t = 100; double dx = (nodes[nums[i]].x - nodes[nums[i - 1]].x) / t; double dy = (nodes[nums[i]].y - nodes[nums[i - 1]].y) / t; double x = nodes[nums[i]].x; double y = nodes[nums[i]].y; for (int j = 0; j < t; j++) { x = x - dx; y = y - dy; this.webBrowser.Document.InvokeScript("robotMove", new object[] { x, y }); Delay(10); } } }
// https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms537182(v=vs.85)?redirectedfrom=MSDN public CustomSecurityManager(System.Windows.Forms.WebBrowser _WebBrowser) { InternetInterfaces.IServiceProvider webBrowserServiceProviderInterface = _WebBrowser.ActiveXInstance as InternetInterfaces.IServiceProvider; IntPtr profferServiceInterfacePointer = IntPtr.Zero; try { int err = webBrowserServiceProviderInterface.QueryService(ref InternetInterfaces.SID_SProfferService, ref InternetInterfaces.IID_IProfferService, out profferServiceInterfacePointer); if (err != S_OK) { throw new Win32Exception("Failed to query the Web Browser Service."); } if (!(Marshal.GetObjectForIUnknown(profferServiceInterfacePointer) is InternetInterfaces.IProfferService profferServiceInterface)) { throw new Win32Exception("Failed to get the Proffer Service Interface."); } err = profferServiceInterface.ProfferService(ref InternetInterfaces.IID_IInternetSecurityManager, this, out int cookie); if (err != S_OK) { throw new Win32Exception("Failed to proffer the Internet Security Manager Service."); } } catch (SEHException) { throw new Win32Exception("An SEH Exception was encountered while creating the Custom Security Manager."); } catch (ExternalException) { throw new Win32Exception("An External Exception was encountered while creating the Custom Security Manager."); } }
void Browser_DocumentTitleChanged(object sender, EventArgs e) { System.Windows.Forms.WebBrowser browser = sender as System.Windows.Forms.WebBrowser; if (browser == null) { return; } // update the TabItems's Header property TabItem item = tabControl.SelectedItem as TabItem; // Add an Icon to the tabItem BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Test;component/Images/ie.ico")); Image img = new Image(); img.Source = image; img.Width = 16; img.Height = 16; img.Margin = new Thickness(2, 0, 2, 0); //if (item != null) // item.Icon = img; // wrap the header in a textblock, this gives us the character ellipsis (...) when trimmed TextBlock tb = new TextBlock(); tb.Text = browser.DocumentTitle; tb.TextTrimming = TextTrimming.CharacterEllipsis; tb.TextWrapping = TextWrapping.NoWrap; if (item != null) { item.Header = tb; } }
private SHDocVw.WebBrowser CreateNewWebBrowser() { this.toolSource.Enabled = true; System.Windows.Forms.WebBrowser TmpWebBrowser = new System.Windows.Forms.WebBrowser(); if (this.WebBrowserTab.TabPages.Count == 1 && this.WebBrowserTab.TabPages[0].Controls.Count == 0) { this.WebBrowserTab.TabPages[0].Controls.Add(TmpWebBrowser); } else { this.WebBrowserTab.TabPages[0].Controls.Clear(); this.WebBrowserTab.TabPages[0].Controls.Add(TmpWebBrowser); } TmpWebBrowser.Dock = DockStyle.Fill; SHDocVw.WebBrowser wb = (SHDocVw.WebBrowser)TmpWebBrowser.ActiveXInstance; wb.CommandStateChange += new SHDocVw.DWebBrowserEvents2_CommandStateChangeEventHandler(this.wb_CommandStateChange); wb.BeforeNavigate2 += new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(this.wb_BeforeNavigate2); wb.ProgressChange += new SHDocVw.DWebBrowserEvents2_ProgressChangeEventHandler(this.wb_ProgressChange); wb.StatusTextChange += new SHDocVw.DWebBrowserEvents2_StatusTextChangeEventHandler(this.wb_StatusTextChange); wb.NavigateError += new SHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler(this.wb_NavigateError); wb.NavigateComplete2 += new SHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.wb_NavigateComplete2); wb.TitleChange += new SHDocVw.DWebBrowserEvents2_TitleChangeEventHandler(this.wb_TitleChange); wb.DocumentComplete += new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(this.wb_DocumentComplete); wb.NewWindow2 += new SHDocVw.DWebBrowserEvents2_NewWindow2EventHandler(this.wb_NewWindow2); return(wb); }
void tabControl_TabItemAdded(object sender) //, TabItemEventArgs e) { // Add an Icon to the tabItem BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Test;component/Images/ie.ico")); Image img = new Image(); img.Source = image; img.Width = 16; img.Height = 16; img.Margin = new Thickness(2, 0, 2, 0); //e.TabItem.Icon = img; // wrap the header in a textblock, this gives us the character ellipsis (...) when trimmed TextBlock tb = new TextBlock(); tb.Text = "New Tab " + count++; tb.TextTrimming = TextTrimming.CharacterEllipsis; tb.TextWrapping = TextWrapping.NoWrap; //e.TabItem.Header = tb; // add a WebControl to the TAbItem WindowsFormsHost host = new WindowsFormsHost(); host.Margin = new Thickness(2); System.Windows.Forms.WebBrowser browser = new System.Windows.Forms.WebBrowser(); browser.DocumentTitleChanged += Browser_DocumentTitleChanged; browser.Navigated += Browser_Navigated; host.Child = browser; //e.TabItem.Content = host; }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UpdatesWindow)); this.webBrowser1 = new System.Windows.Forms.WebBrowser(); this.SuspendLayout(); // // webBrowser1 // this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill; this.webBrowser1.Location = new System.Drawing.Point(0, 0); this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20); this.webBrowser1.Name = "webBrowser1"; this.webBrowser1.Size = new System.Drawing.Size(794, 572); this.webBrowser1.TabIndex = 0; this.webBrowser1.Url = new System.Uri("", System.UriKind.Relative); // // UpdatesWindow // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.SystemColors.Control; this.ClientSize = new System.Drawing.Size(794, 572); this.Controls.Add(this.webBrowser1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "UpdatesWindow"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Update Notice"; this.ResumeLayout(false); }
public static void TrackEvent(string msg) { // Unfortunate that this uses UI thread (moving it to background worker isn't as useful; perhaps undo that) System.ComponentModel.BackgroundWorker trackEventWorker = new BackgroundWorker(); trackEventWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(delegate { MuteFm.UiPackage.WinSoundServerSysTray.Instance.Invoke((System.Windows.Forms.MethodInvoker) delegate { try { _uri = "http://www.mutefm.com/track_" + msg.ToLower() + ".html?identity=" + Program.Identity; _browserControl = new System.Windows.Forms.WebBrowser(); _browserControl.ScriptErrorsSuppressed = true; _browserControl.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted); _browserControl.Url = new Uri(_uri); // TODO: use ie for this at least for now /* * _trackSession = Awesomium.Core.WebCore.CreateWebSession(new Awesomium.Core.WebPreferences()); * _webView = Awesomium.Core.WebCore.CreateWebView(100, 100, _trackSession, Awesomium.Core.WebViewType.Offscreen); * _webView.DocumentReady += new Awesomium.Core.UrlEventHandler(webView_DocumentReady); * _webView.Source = new Uri(_uri); */ } catch (Exception ex) { MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex); } }); }); trackEventWorker.RunWorkerAsync(); }
public static Bitmap GetScreenshot(Uri uri, int width, int height) { Bitmap bitmap; using (var webBrowser = new WebBrowser()) { webBrowser.ScrollBarsEnabled = false; webBrowser.ScriptErrorsSuppressed = true; webBrowser.Navigate(uri); while (webBrowser.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } webBrowser.Width = width > 0 ? width : webBrowser.Document.Body.ScrollRectangle.Width; webBrowser.Height = height > 0 ? height : webBrowser.Document.Body.ScrollRectangle.Height; if (webBrowser.Height <= 0) webBrowser.Height = 768; bitmap = new Bitmap(webBrowser.Width, webBrowser.Height); webBrowser.DrawToBitmap(bitmap, new Rectangle(0, 0, webBrowser.Width, webBrowser.Height)); } return bitmap; }
private void InitializeComponent() { this.wBrowser = new System.Windows.Forms.WebBrowser(); this.Load += new System.EventHandler(this.Announcement_Load); this.SuspendLayout(); // //wBrowser // this.wBrowser.AllowWebBrowserDrop = false; this.wBrowser.Dock = System.Windows.Forms.DockStyle.Fill; this.wBrowser.Location = new System.Drawing.Point(0, 0); this.wBrowser.MinimumSize = new System.Drawing.Size(20, 20); this.wBrowser.Name = "wBrowser"; this.wBrowser.Size = new System.Drawing.Size(549, 474); this.wBrowser.TabIndex = 0; // //Announcement // this.ClientSize = new System.Drawing.Size(549, 474); this.Controls.Add(this.wBrowser); this.Name = "Announcement"; this.TabText = "Announcement"; this.Text = "Announcement"; this.Icon = global::My.Resources.Resources.News_Icon; this.ResumeLayout(false); }
public Frame() { WindowState = FormWindowState.Maximized; Text = "Bootpad"; Font = new Font("Anonymous Pro", 10); Dock = DockStyle.Fill; he = new HtmlEditor(); wb = new WebBrowser { Dock = DockStyle.Fill, ScriptErrorsSuppressed = false }; ut = new System.Windows.Forms.Timer { Interval = 5000 }; ut.Tick += delegate { if (changed) { new Thread(new ThreadStart(delegate { wb.DocumentText = he.Text; changed = false; })).Start(); } }; he.TextChanged += delegate { changed = true; }; var sc0 = new SplitContainer { Parent = this, Dock = DockStyle.Fill, SplitterDistance = 100 }; sc0.Panel1.Controls.Add(he); sc0.Panel2.Controls.Add(wb); ut.Start(); }
// initialize the WebBrowser and the form private void Init(bool visible) { scriptCallback = new ScriptCallback(this); // create a WebBrowser control ieBrowser = new forms.WebBrowser(); // set the location of script callback functions ieBrowser.ObjectForScripting = scriptCallback; // set WebBrowser event handls ieBrowser.DocumentCompleted += new forms.WebBrowserDocumentCompletedEventHandler(IEBrowser_DocumentCompleted); ieBrowser.Navigating += new forms.WebBrowserNavigatingEventHandler(IEBrowser_Navigating); if (visible) { form = new System.Windows.Forms.Form(); ieBrowser.Dock = System.Windows.Forms.DockStyle.Fill; form.Controls.Add(ieBrowser); form.Visible = true; } loginCount = 0; // initialise the navigation counter navigationCounter = 0; ieBrowser.Navigate("https://google.com"); }
public Open(WebBrowser wb, Form father) { this.wb = wb; //wb.WebBrowserContent; InitializeComponent(); parent = father; }
private string GetJsVar(System.Windows.Forms.WebBrowser webBrowser1, string varname) { if (webBrowser1.Document == null) { return("No document"); } webBrowser1.Document.InvokeScript("eval", new[] { @" CreateHiddenInputForReturn = function(id, val) { var elm = document.getElementById(id); if(elm == null) { elm = document.createElement('INPUT'); elm.id = id; elm.type=""HIDDEN""; document.body.insertBefore(elm); } elm.value = eval('typeof('+val.split(/[\[\.]/)[0]+')')=='undefined' ? id : eval(val); } " }); webBrowser1.Document.InvokeScript("CreateHiddenInputForReturn", new[] { htmlid, varname }); HtmlElement obj = webBrowser1.Document.GetElementById(htmlid); if (obj != null) { string val = obj.GetAttribute("value"); if (val == htmlid) { return("no js var"); } return(val); } return("null"); }
public WebBowserEmulator() { InitializeComponent(); for(int i = 0 ;i< No_of_Invokes;i++) { web[i] = new WebBrowser[No_of_Instance]; } // Create a simple tray menu with only two item. trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Emulate", OnEmulate); trayMenu.MenuItems.Add("Exit", OnExit); // Create a tray icon. In this example we use a // standard system icon for simplicity, but you // can of course use your own custom icon too. trayIcon = new NotifyIcon(); trayIcon.Text = "Web Browser Emulator"; trayIcon.Icon = new Icon(SystemIcons.Application, 40, 40); // Add menu to tray icon and show it. trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; //InvokeprogressBar.BackColor = Color.Transparent; }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.WebBrowser1 = new System.Windows.Forms.WebBrowser(); this.SuspendLayout(); // // WebBrowser1 // this.WebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill; this.WebBrowser1.Location = new System.Drawing.Point(0, 0); this.WebBrowser1.Name = "WebBrowser1"; this.WebBrowser1.Size = new System.Drawing.Size(824, 440); this.WebBrowser1.TabIndex = 0; this.WebBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(824, 440); this.Controls.Add(this.WebBrowser1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); }
void gui () { SuspendLayout (); this.StartPosition = FormStartPosition.Manual; this.Left = 400; this.Top = 100; this.Size = new Size (650, 650); controls = new controls (this); controls.SuspendLayout (); controls.Top = 100; monitor = new monitor(this); monitor.SuspendLayout (); monitor.Top = 100; controls.Size = new Size(400, 400); monitor.Size = new Size(400, 400); controls.Left = this.Left - 400; monitor.Left = this.Right; webBrowser = new WebBrowser (); webBrowser.Navigating += delegate (object sender, WebBrowserNavigatingEventArgs args) { monitor.addEvent ("Navigating"); }; webBrowser.Navigated += delegate (object sender, WebBrowserNavigatedEventArgs args) { navigated++; monitor.addEvent ("Navigated"); }; webBrowser.CanGoBackChanged += delegate (object sender, EventArgs args) { monitor.addEvent ("CanGoBackChanged"); }; webBrowser.CanGoForwardChanged += delegate (object sender, EventArgs args) { monitor.addEvent ("CanGoForwardChanged"); }; webBrowser.DocumentCompleted += delegate (object sender, WebBrowserDocumentCompletedEventArgs args) { monitor.addEvent ("DocumentCompleted"); }; webBrowser.DocumentTitleChanged += delegate (object sender, EventArgs args) { monitor.addEvent ("DocumentTitleChanged"); }; webBrowser.EncryptionLevelChanged += delegate (object sender, EventArgs args) { monitor.addEvent ("EncryptionLevelChanged"); }; webBrowser.FileDownload += delegate (object sender, EventArgs args) { monitor.addEvent ("FileDownload"); }; webBrowser.NewWindow += delegate (object sender, CancelEventArgs args) { monitor.addEvent ("NewWindow"); }; webBrowser.ProgressChanged += delegate (object sender, WebBrowserProgressChangedEventArgs args) { monitor.addEvent ("ProgressChanged"); }; webBrowser.StatusTextChanged += delegate (object sender, EventArgs args) { monitor.addEvent ("StatusTextChanged"); }; webBrowser.Dock = DockStyle.Fill; this.Controls.Add (webBrowser); monitor.ResumeLayout (); controls.ResumeLayout (); this.ResumeLayout (); }
public void carpostfunc(WebBrowser webBrowser1, IList<com.unitedcarexchange.UsedCarsInfo> obUsedCarsInfo,bool a) { GeneralFunction.SetTextValue(webBrowser1, "login", "*****@*****.**"); GeneralFunction.SetTextValue(webBrowser1, "password", "reach123"); GeneralFunction.ButtonClickInvokeValue(webBrowser1, "Login"); GeneralFunction.SetTextValue(webBrowser1, "ZipCode", obUsedCarsInfo[0].Zipcode.ToString()); GeneralFunction.LinkInvokeOnMouseOver(webBrowser1, "Cars and Vehicles"); GeneralFunction.LinkInvoke(webBrowser1, "Cars"); GeneralFunction.ImgeButtonClickInvokeTypeandValue(webBrowser1, "2"); GeneralFunction.SetTextValue(webBrowser1, "dyn_tex_140", obUsedCarsInfo[0].Price.ToString()); GeneralFunction.SetDropDownValue(webBrowser1, "dyn_dro_116", obUsedCarsInfo[0].YearOfMake.ToString()); GeneralFunction.SetDropDownValue(webBrowser1, "dyn_dro_117", obUsedCarsInfo[0].Make.ToString()); GeneralFunction.SetDropDownName(webBrowser1, "dyn_dro_118", obUsedCarsInfo[0].Model.ToString()); GeneralFunction.SetDropDownNameandValue(webBrowser1, "dyn_dro_122", "755"); GeneralFunction.SetTextValue(webBrowser1, "dyn_phone", obUsedCarsInfo[0].Phone.ToString()); GeneralFunction.SetTextValue(webBrowser1, "title", obUsedCarsInfo[0].Title.ToString()); GeneralFunction.SetMultiTextValue(webBrowser1, "onlinetext", obUsedCarsInfo[0].Description.ToString()); GeneralFunction.ButtonClickInvoke(webBrowser1, "btn-next"); ////GeneralFunction.ButtonClickInvoke(webBrowser1, "btn-checkout"); }
public void BitmapThreadWorker(object url) { try { DateTime started = DateTime.Now; WebBrowser browser = new WebBrowser(); browser.ScrollBarsEnabled = false; browser.ClientSize = new Size(800, 600); browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted); browser.Navigate((string)url); while (bmp == null) { Thread.Sleep(1000); Application.DoEvents(); TimeSpan elapsed = DateTime.Now.Subtract(started); if (elapsed.TotalMilliseconds > s_RequestTimeout / 2) { browser.Dispose(); mre.Set(); break; } } } catch { mre.Set(); } }
/// <summary> /// 将浏览器中的Cookie清除 /// </summary> /// <param name="browser">浏览器</param> public static void ClearCookies(WebBrowser browser) { if (browser != null && browser.Document != null) { ClearCookies(browser.Document.Cookie, browser.Url.ToString()); } }
public static WebBrowser GetWebBrowser(string controller, string emailAddress, string applicationKey) { string url = MobileMinerWebUrl + "/" + controller + "/" + EmbedAction; WebBrowser embeddedBrowser; //maintain 1-browser-per-controller //for now we only have 2 and it provides a nicer UX //you don't see a different controller's contents if (embeddedBrowsers.ContainsKey(controller)) embeddedBrowser = embeddedBrowsers[controller]; else { embeddedBrowser = new WebBrowser(); embeddedBrowsers[controller] = embeddedBrowser; embeddedBrowser.Navigated += HandleBrowserNavigated; } bool postCredentials = !embeddedBrowserAuthenticated && !String.IsNullOrEmpty(emailAddress); if (postCredentials) { var postString = String.Format("email={0}&key={1}", emailAddress, applicationKey); byte[] data = Encoding.UTF8.GetBytes(postString); //use POST-Redirect-GET to login without leaving credentials in history embeddedBrowser.Navigate(url, null, data, FormUrlEncodedHeader); } else { //we're authenticated, just use GET for better performance embeddedBrowser.Navigate(url); } return embeddedBrowser; }
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { int tb = TabControls.SelectedIndex; if (tb == 2) { this.Dispatcher.BeginInvoke((Action) delegate() { Forms.WebBrowser browser = new Forms.WebBrowser(); browser.Name = "browser"; browser.ScriptErrorsSuppressed = true; browser.Navigate(new Uri("http://google.com")); new OverlayWindow(BrowserPanel, browser); }, DispatcherPriority.ApplicationIdle); } else { foreach (Window win in App.Current.Windows) { if (!win.IsFocused && win.Name.ToString() == "BrowserWindow") { WindowsFormsHost wh = (WindowsFormsHost)((Overlay.OverlayWindow)(win)).FindName("wfh"); Forms.WebBrowser wb = (Forms.WebBrowser)(wh.Child); wb.Navigate(new Uri("about:blank")); win.Close(); } } } }
/// <summary> /// This method creates a new form with a webbrowser of correct size on it, /// to make a fullsize website screenhot. /// </summary> /// <param name="navigatingArgs">The <see cref="WebBrowserNavigatingEventArgs"/> instance containing the event data, /// especially the url.</param> /// <param name="filename">The filename to save the screenshot to.</param> public static void DoScreenshot(WebBrowserNavigatingEventArgs navigatingArgs, string filename) { newTargetUrl = navigatingArgs.Url; newScreenshotFilename = filename; var tempBrowser = new WebBrowser(); var dummyForm = new Form { ClientSize = new Size(1, 1), FormBorderStyle = FormBorderStyle.None }; dummyForm.ShowInTaskbar = false; dummyForm.Controls.Add(tempBrowser); dummyForm.Show(); tempBrowser.ScrollBarsEnabled = true; tempBrowser.ScriptErrorsSuppressed = true; tempBrowser.DocumentCompleted += WebBrowserDocumentCompleted; if (navigatingArgs.TargetFrameName != string.Empty) { tempBrowser.Navigate(navigatingArgs.Url, navigatingArgs.TargetFrameName); } else { tempBrowser.Navigate(newTargetUrl); } while (tempBrowser.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } tempBrowser.Dispose(); }
/// <summary> /// Returns a SharePoint on-premises / SharePoint Online ClientContext object. Requires claims based authentication with FedAuth cookie. /// </summary> /// <param name="siteUrl">Site for which the ClientContext object will be instantiated</param> /// <param name="icon">Optional icon to use for the popup form</param> /// <returns>ClientContext to be used by CSOM code</returns> public ClientContext GetWebLoginClientContext(string siteUrl, System.Drawing.Icon icon = null) { var cookies = new CookieContainer(); var siteUri = new Uri(siteUrl); var thread = new Thread(() => { var form = new System.Windows.Forms.Form(); if (icon != null) { form.Icon = icon; } var browser = new System.Windows.Forms.WebBrowser { ScriptErrorsSuppressed = true, Dock = DockStyle.Fill }; form.SuspendLayout(); form.Width = 900; form.Height = 500; form.Text = string.Format("Log in to {0}", siteUrl); form.Controls.Add(browser); form.ResumeLayout(false); browser.Navigate(siteUri); browser.Navigated += (sender, args) => { if (siteUri.Host.Equals(args.Url.Host)) { var cookieString = CookieReader.GetCookie(siteUrl).Replace("; ", ",").Replace(";", ","); if (Regex.IsMatch(cookieString, "FedAuth", RegexOptions.IgnoreCase)) { var _cookies = cookieString.Split(',').Where(c => c.StartsWith("FedAuth", StringComparison.InvariantCultureIgnoreCase) || c.StartsWith("rtFa", StringComparison.InvariantCultureIgnoreCase)); cookies.SetCookies(siteUri, string.Join(",", _cookies)); form.Close(); } } }; form.Focus(); form.ShowDialog(); browser.Dispose(); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); if (cookies.Count > 0) { var ctx = new ClientContext(siteUrl); ctx.ExecutingWebRequest += (sender, e) => e.WebRequestExecutor.WebRequest.CookieContainer = cookies; return(ctx); } return(null); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.webBrowser = new System.Windows.Forms.WebBrowser(); this.SuspendLayout(); // // webBrowser // this.webBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.webBrowser.Location = new System.Drawing.Point(4, 3); this.webBrowser.Name = "webBrowser"; this.webBrowser.Size = new System.Drawing.Size(422, 341); this.webBrowser.TabIndex = 0; // // ScriptedMenu // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(429, 348); this.Controls.Add(this.webBrowser); this.Name = "ScriptedMenu"; this.Text = "Scripted Menu"; this.Load += new System.EventHandler(this.ScriptedMenu_Load); this.ResumeLayout(false); }
public BbMLB(DateTime today) : base(ESport.Baseball_MLB) { // 設定 this.AllianceID = 53; this.GameType = "BBUS"; //this.GameDate = GetUtcUsaEt(today).Date; // 只取日期 int diffTime = frmMain.GetGameSourceTime("EasternTime");//取得與當地時間差(包含日光節約時間) if (diffTime > 0) this.GameDate = today.AddHours(-diffTime); else this.GameDate = GetUtcUsaEt(today);//取得美東時間 if (string.IsNullOrWhiteSpace(this.sWebUrl)) { this.sWebUrl = @"http://www.cbssports.com/mlb/scoreboard"; } this.DownHome = new BasicDownload(this.Sport, this.sWebUrl); //this.DownHome = new BasicDownload(this.Sport, string.Format(@"http://mlb.mlb.com/gdcross/components/game/mlb/year_{0}/month_{1}/day_{2}/master_scoreboard.json", this.GameDate.ToString("yyyy"), this.GameDate.ToString("MM"), this.GameDate.ToString("dd"))); this.DownWeb = new WebBrowser(); this.DownWeb.AllowNavigation = false; this.DownWeb.AllowWebBrowserDrop = false; this.DownWeb.ScriptErrorsSuppressed = true; this.DownWeb.IsWebBrowserContextMenuEnabled = false; this.DownWeb.ScrollBarsEnabled = false; this.DownWeb.WebBrowserShortcutsEnabled = false; this.DownWeb.TabStop = false; this.DownWeb.Tag = this.sWebUrl; }
public void Start() { BrowserThread = new Thread(() => { Browser = new WebBrowser(); Browser.Width = Ballz.The().GraphicsDevice.Viewport.Width; Browser.Height = Ballz.The().GraphicsDevice.Viewport.Height; Browser.ScrollBarsEnabled = false; //Browser.IsWebBrowserContextMenuEnabled = false; LatestBitmap = new Bitmap(Browser.Width, Browser.Height); Browser.Validated += (s, e) => { lock (this) { Browser.DrawToBitmap(LatestBitmap, new Rectangle(0, 0, Browser.Width, Browser.Height)); } }; Browser.DocumentCompleted += (s, e) => { lock (this) { Browser.DrawToBitmap(LatestBitmap, new Rectangle(0, 0, Browser.Width, Browser.Height)); } }; Browser.Navigate("file://C:/Users/Lukas/Documents/gui.html"); var context = new ApplicationContext(); Application.Run(); }); BrowserThread.SetApartmentState(ApartmentState.STA); BrowserThread.Start(); }
public FbNFL(DateTime today) : base(ESport.Football_NFL) { // 設定 this.AllianceID = 1; this.GameType = "AFUS"; int diffTime = frmMain.GetGameSourceTime("EasternTime");//取得與當地時間差(包含日光節約時間) if (diffTime > 0) this.GameDate = today.AddHours(-diffTime); else this.GameDate = GetUtcUsaEt(today);//取得美東時間 if (string.IsNullOrWhiteSpace(this.sWebUrl)) { this.sWebUrl = @"http://www.cbssports.com/nfl/scoreboard"; } this.DownWeb = new WebBrowser(); this.DownWeb.AllowNavigation = false; this.DownWeb.AllowWebBrowserDrop = false; this.DownWeb.ScriptErrorsSuppressed = true; this.DownWeb.IsWebBrowserContextMenuEnabled = false; this.DownWeb.ScrollBarsEnabled = false; this.DownWeb.WebBrowserShortcutsEnabled = false; this.DownWeb.TabStop = false; this.DownWeb.Tag = this.sWebUrl; }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.webBrowser1 = new System.Windows.Forms.WebBrowser(); this.SuspendLayout(); // // webBrowser1 // this.webBrowser1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.webBrowser1.Location = new System.Drawing.Point(4, 4); this.webBrowser1.Name = "webBrowser1"; this.webBrowser1.Size = new System.Drawing.Size(387, 334); this.webBrowser1.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(this.WebBrowser1_Navigating); // // ScriptedWindow // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(397, 345); this.Controls.Add(this.webBrowser1); this.Name = "ScriptedWindow"; this.Text = "Scripted Window"; this.Load += new System.EventHandler(this.ScriptedWindow_Load); this.ResumeLayout(false); }
public static void SetHtmlContent(this System.Windows.Forms.WebBrowser webBrowser, string html, string baseUrl) { webBrowser.Navigate("about:blank"); var browser = (IWebBrowser2)webBrowser.ActiveXInstance; var result = CreateStreamOnHGlobal(Marshal.StringToHGlobalAuto(html), true, out IStream stream); if ((result != 0) || (stream == null)) { return; } var persistentMoniker = browser.Document as IPersistMoniker; if (persistentMoniker == null) { return; } IBindCtx bindContext = null; CreateBindCtx((uint)0, out bindContext); if (bindContext == null) { return; } var loader = new Moniker(baseUrl, html); persistentMoniker.Load(1, loader, bindContext, (uint)0); stream = null; }
public static String GetMshcTopicID(WebBrowser webBrowser1) { if (webBrowser1.Document != null && webBrowser1.Url != null) return GetMshcTopicID(webBrowser1.Url.AbsoluteUri); else return ""; }
//Method "Browse()" provided by assignment description private String Browse() { // Can't find System.Windows.Controls.WebBrowser, which might be nice. // See http://stackoverflow.com/questions/8645926/how-to-create-and-use-webbrowser-in-background-thread WebBrowser myWebBrowser = null; String innerHTML = ""; txtTitle.Text = "???"; txtValue.Text = "???"; Thread thread = new Thread(delegate() { int elapsedTime; DateTime startTime = new DateTime(), endTime = new DateTime(); startTime = DateTime.Now; System.Windows.Forms.HtmlElement htmlElement = null; //WebBrowser foo = new System.Net.HttpWebRequest(); // deprecated. Seems to work for Desktop Apps and .Net Framework 2.0 // This causes major crashing of the web server //foo.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DocumentComplete); myWebBrowser = new System.Windows.Forms.WebBrowser(); // Must be instantiated inside the Thread myWebBrowser.AllowNavigation = true; myWebBrowser.Navigate(txtURL.Text, false); while (myWebBrowser.ReadyState != WebBrowserReadyState.Complete) //while (foo.ReadyState != WebBrowserReadyState.Interactive) // We don't care if the graphics are loaded //while (foo.IsBusy == true) { txtValue.Text = myWebBrowser.ReadyState.ToString(); System.Windows.Forms.Application.DoEvents(); endTime = DateTime.Now; elapsedTime = (endTime - startTime).Seconds; if (elapsedTime > 30) { break; } } // When we get this far we have hopefully loaded the web page into the browser object try { txtTitle.Text = myWebBrowser.Document.Title; //System.Windows.Forms.HtmlElement x = foo.Document.GetElementById("yfs_l84_csco"); htmlElement = myWebBrowser.Document.Body; innerHTML = htmlElement.InnerHtml; } catch (Exception ex) { txtValue.Text += "<p> Exception: " + ex.ToString(); } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); // We won't get here until the Thread completes. // This might be interesting: http://www.charith.gunasekara.web-sphere.co.uk/2010/09/how-to-convert-html-page-to-image-using.html return(innerHTML); }
void HandleGtkRealized(object sender, EventArgs e) { var size = new System.Drawing.Size(Widget.WidthRequest, Widget.HeightRequest); var createView = view == null; if (createView) { view = new SWF.WebBrowser(); view.ScriptErrorsSuppressed = true; view.AllowWebBrowserDrop = false; view.Size = size; } var browser_handle = view.Handle; IntPtr window_handle = (IntPtr)socket.Id; SetParent(browser_handle, window_handle); if (createView) { view.ProgressChanged += HandleProgressChanged; view.Navigating += HandleNavigating; view.Navigated += HandleNavigated; view.DocumentTitleChanged += HandleDocumentTitleChanged; view.DocumentCompleted += (s, ev) => { var inFocus = false; view.Document.Focusing += (sD, eD) => { this.SetFocus(); inFocus = true; ApplicationContext.InvokeUserCode(delegate { EventSink.OnGotFocus(); }); }; view.Document.LosingFocus += (sD, eD) => { ApplicationContext.InvokeUserCode(delegate { EventSink.OnLostFocus(); }); inFocus = false; }; view.Document.MouseDown += (sD, eD) => { var a = new ButtonEventArgs { X = eD.MousePosition.X, Y = eD.MousePosition.Y }; ApplicationContext.InvokeUserCode(delegate { EventSink.OnButtonPressed(a); }); }; }; if (url != null) { view.Navigate(url); } } else { view.Size = size; Widget.QueueResize(); } }
/** * 생성자 * @param targetBrowser 파싱용 웹 브라우저 */ public Parser(System.Windows.Forms.WebBrowser targetBrowser) { this.webBrowser = targetBrowser; this.taskMutex = new Mutex(false, "Task"); this.watcher = new Watcher.Watcher(targetBrowser, taskMutex); this.webBrowser.ScriptErrorsSuppressed = true; }