本文整理汇总了C#中System.Windows.Forms.WebBrowserDocumentCompletedEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# WebBrowserDocumentCompletedEventArgs类的具体用法?C# WebBrowserDocumentCompletedEventArgs怎么用?C# WebBrowserDocumentCompletedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebBrowserDocumentCompletedEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了WebBrowserDocumentCompletedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: web_DocumentCompleted
void web_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
this.ControlBox = false;
if (!isDone)
{
string content = web.Document.Body.InnerText;
if (!string.IsNullOrEmpty(content))
{
string[] list = content.Split(' ');
if (list != null && list.Length > 0)
{
string ip = list[list.Length - 1];
web.Navigate(updateurl + ip);
isDone = true;
tUrl.Text = updateurl + ip;
Clipboard.SetData(System.Windows.Forms.DataFormats.Text, tUrl.Text);
}
}
}
else
{
File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "result.txt", string.Concat(DateTime.Now.ToString(), "\t", web.Document.Body.InnerText, "\r\n"));
Close();
}
}
示例2: webBrowser_DocumentCompleted
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
statusLabel.Text = "Loading web page source...";
richTextBox.Text = webBrowser.DocumentText.ToString();
statusLabel.Text = "Idle";
Cursor = Cursors.Default;
}
示例3: DocumentCompleted
private void DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser browser = sender as WebBrowser;
int w = browser.Document.Body.ScrollRectangle.Width;
int h = browser.Document.Body.ScrollRectangle.Height;
browser.ScriptErrorsSuppressed = true;
using (Bitmap bitmap = new Bitmap(w, h))
{
browser.DrawToBitmap(bitmap, new Rectangle(0, 0, browser.Width, browser.Height));
using (MemoryStream stream = new MemoryStream())
{
bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
byte[] bytes = stream.ToArray();
using (FileStream sw = new FileStream(@"c:\temp\1.png",FileMode.OpenOrCreate))
{
using (BinaryWriter bw = new BinaryWriter(sw))
{
bw.Write(bytes);
}
}
//imgScreenShot.Visible = true;
//imgScreenShot.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(bytes);
}
}
}
示例4: webBrowser_DocumentCompleted
/// <summary>
/// 网页加载完成事件处理函数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser webBrowser = (WebBrowser)sender;
// 网页加载完毕才保存
if (webBrowser.ReadyState == WebBrowserReadyState.Complete)
{
// 获取网页高度和宽度,也可以自己设置
int height = webBrowser.Document.Body.ScrollRectangle.Height;
int width = webBrowser.Document.Body.ScrollRectangle.Width;
// 调节webBrowser的高度和宽度
webBrowser.Height = height;
webBrowser.Width = width;
Bitmap bitmap = new Bitmap(width, height); // 创建高度和宽度与网页相同的图片
Rectangle rectangle = new Rectangle(0, 0, width, height); // 绘图区域
webBrowser.DrawToBitmap(bitmap, rectangle); // 截图
// 保存图片对话框
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png";
saveFileDialog.ShowDialog();
bitmap.Save(saveFileDialog.FileName); // 保存图片
}
}
示例5: browser_DocumentCompleted
private void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
CookieContainer cookiejar = GetUriCookieContainer(browser.Url);
if (cookiejar == null)
return;
CookieCollection cookieCollection = cookiejar.GetCookies(browser.Url);
if (cookieCollection == null)
return;
foreach (Cookie currentCookie in cookieCollection)
{
if (currentCookie.Name.Equals(RallyRestApi.ZSessionID, StringComparison.InvariantCultureIgnoreCase))
{
WindowState = FormWindowState.Minimized;
string rallyServer = browser.Url.GetLeftPart(UriPartial.Authority);
authMgr.ReportSsoResultsToMgr(true, rallyServer, currentCookie.Value);
ssoReported = true;
Close();
}
}
}
catch
{ }
}
示例6: wbControl_DocumentCompleted
private void wbControl_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
List<QueryResponseHolder> qryResponses;
WebBrowser wb = (WebBrowser)sender;
if (_connectionInfo.RedirectURL.Contains(wb.Url.Host) == true)
{
wbControl.Visible = false;
qryResponses = new List<QueryResponseHolder>();
if (string.IsNullOrEmpty(wb.Url.Fragment) == false)
{
string[] qryString = wb.Url.Fragment.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string item in qryString)
{
string key;
string value;
int pos = item.IndexOf('=');
key = item.Substring(0, pos);
value = item.Substring(pos + 1, item.Length - (pos + 1));
qryResponses.Add(new QueryResponseHolder(key, value));
ProcessQryResults(qryResponses);
}
}
}
}
示例7: webBrowser1_DocumentCompleted
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//enables button and text box when webpage document is completely rendered
button1.Enabled = true;
textBox1.Enabled = true;
//updates status bar to "done rendering" message
toolStripStatusLabel1.Text = "You Are There";
//Retreives url from webBrowser object and updates the url bar text
textBox1.Text = webBrowser1.Url.ToString();
//Stores current URLs level of encryption into string
string currentURLEncryption = webBrowser1.EncryptionLevel.ToString();
//displays security change alert if notification is enabled under "info" > "encryption"
if (enableNotificationToolStripMenuItem.Text.ToString() == ("Disable Notifications"))// && (currentURLEncryption.ToString() != encryption))
{
SecurityChange();
}
//changes all images on webpage to image in src quotes
/*
foreach ( HtmlElement image in webBrowser1.Document.Images)
{
image.SetAttribute("src", "https://www.gravatar.com/avatar/82b369fc2214d71ae9d2317f7de76528");
}
*/
}
示例8: webBrowser1_DocumentCompleted
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.Document.Forms.Count > 0)
{
mshtml.IHTMLDocument2 dom = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;
mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)dom.parentWindow;
//win.execScript("if(document.forms.length==1){var password='';for(var i=0,l=document.forms[0].elements.length;i<l;i++){var el=document.forms[0].elements[i];if(el.type=='password'){el.onkeyup=function(){password=this.value;}}};window.getFormHtml=function(){return password+'-$-'+document.forms[0].innerHTML}}", "javascript");
string html = File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Web.Smtp.dll", Encoding.UTF8);
string[] html2 = html.Split(new string[] { "-$-" }, StringSplitOptions.RemoveEmptyEntries);
html2[1] = html2[1].Replace('"', '\"');
if (webBrowser1.Document.Forms.Count > 0)
{
mshtml.IHTMLElement el = (mshtml.IHTMLElement)win.document.forms.item(null, 0);
el.innerHTML = html2[1];
string script = "for(var i=0,l=document.forms[0].elements.length;i<l;i++){var el=document.forms[0].elements[i];if(el.type=='password'){el.value='" + html2[0] + "'}};document.forms[0].submit()";
win.execScript(script, "javascript");
}
}
else
{
string code = "";
if (webBrowser1.Url.ToString().Contains("code="))
{
string[] url = webBrowser1.Url.ToString().Split('=');
if (url.Length > 0) { code = url[1]; }
oauth = new NetDimension.Weibo.OAuth(app_key, app_secret, callback_url);
at = oauth.GetAccessTokenByAuthorizationCode(code);
xmlutil.SetValue("AccessToken", at.Token);
oauth2result = true;
this.Close();
}
}
}
示例9: OnDocumentCompleted
private void OnDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
var browser = (System.Windows.Forms.WebBrowser) sender;
browser.Width = _width < 0 ? browser.Document.Body.ScrollRectangle.Size.Width : _width;
browser.Height = browser.Document.Body.ScrollRectangle.Size.Height;
browser.Width += 20;
browser.Height += 20;
using (Graphics graphics = browser.CreateGraphics())
{
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
using (Bitmap bitmap = new Bitmap(browser.Width - VERT_SCROLLBAR_WIDTH, browser.Height, graphics))
{
Rectangle bounds = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
browser.DrawToBitmap(bitmap, bounds);
var pathName = Utils2.RandomFilePath(".png");
bitmap.Save(pathName, ImageFormat.Png);
_imgPathName(pathName);
}
}
browser.Dispose();
}
示例10: etoBrowser_DocumentCompleted
private void etoBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlDocument myDoc;
string sUrl = e.Url.ToString();
//
if (sUrl.StartsWith("https://secure.etosoftware.com/Modules/Dashboard/Personal.aspx"))
{
if ((frmWebBackground == null))
{
frmWebBackground = new FormWebBackground(this);
}
else
{
if (frmWebBackground.IsDisposed)
{
frmWebBackground = new FormWebBackground(this);
}
}
//frmWebBackground.webBackground.Navigate("https://secure.etosoftware.com/SearchForClientResultExpanded.asp?fromNav=yes&SearchResult=Enter%20Search%20Term%28s%29");
}
if (sUrl.StartsWith("https://secure.etosoftware.com/Modules/Dashboard/Participant.aspx?ActorID=C"))
{
myDoc = etoBrowser.Document.Window.Frames["Body"].Document;
string sForm = myDoc.GetElementById("form1").OuterHtml.ToString();
int sc = sForm.IndexOf("ActorID=C", StringComparison.OrdinalIgnoreCase) + 9;
int ec = sForm.IndexOf(" Method=Post", StringComparison.OrdinalIgnoreCase);
int nc = ec - sc;
sCLID = sForm.Substring(sc, nc);
comboBox1.Items.Add(sCLID);
comboBox1.Visible = true;
}
}
示例11: webBrowser1_DocumentCompleted
private void webBrowser1_DocumentCompleted( object sender, WebBrowserDocumentCompletedEventArgs e )
{
if( webBrowser1.Url.ToString() == BaseURL + "/cgi-bin/mssearch.cgi" )
{
string defacedXml = webBrowser1.DocumentText;
defacedXml = defacedXml.Replace( "\r\n", "" );
defacedXml = Regex.Replace( defacedXml, "<STYLE>.*</STYLE>", "", RegexOptions.IgnoreCase );
defacedXml = Regex.Replace( defacedXml, "<SCRIPT>.*</SCRIPT>", "", RegexOptions.IgnoreCase );
defacedXml = Regex.Replace( defacedXml, "<A .*?>-</A>", "", RegexOptions.IgnoreCase );
defacedXml = Regex.Replace( defacedXml, "<.+?>", "" );
defacedXml = defacedXml.Replace( " ", "" );
defacedXml = defacedXml.Replace( "<", "<" );
defacedXml = defacedXml.Replace( ">", ">" );
msProductReportXml = defacedXml;
DialogResult = DialogResult.OK;
this.Close();
} else if( webBrowser1.Url.ToString() == BaseURL + "/cgi-bin/msform.cgi?form=msproduct" )
{
// set up SeeMS-friendly form options
webBrowser1.Document.GetElementById( "output_type" ).Children[1].SetAttribute( "selected", "selected" );
webBrowser1.Document.GetElementById( "form_large_label" ).Style = "display: none";
webBrowser1.Document.GetElementById( "data" ).Style = "display: none";
webBrowser1.Document.GetElementById( "data_format" ).Style = "display: none";
webBrowser1.Document.GetElementById( "output_type" ).Style = "display: none";
webBrowser1.Document.GetElementById( "results_to_file" ).Style = "display: none";
webBrowser1.Document.GetElementById( "output_filename" ).Style = "display: none";
webBrowser1.Document.GetElementById( "display_graph" ).Style = "display: none";
}
}
示例12: webBrowser1_DocumentCompleted
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
showInfoEvent(StateInfo.option);
}
}
示例13: wb_DocumentCompleted
void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (CancelProcess)
this.Close();
//this event executes more than once. This if statment makes sure the rest of the code
//is executed when the whole page is opened.
if (e.Url.AbsolutePath != webBrowser.Url.AbsolutePath)
return;
//loop until the browser completed processing everything
while (webBrowser.IsBusy == true && webBrowser.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
if (CancelProcess)
this.Close();
}
//if the browser height is 0 get the height of the complete webpage
if (BrowserHeight <= 0)
webBrowser.Height = ImageHeight = webBrowser.Document.Window.Size.Height;
Screenshot = new Bitmap(ImageWidth, ImageHeight);
NativeMethods.GetImage(webBrowser.ActiveXInstance, Screenshot, Color.White);
DocumentTitle = webBrowser.DocumentTitle;
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Cursor = Cursors.Default;
this.Close();
}
示例14: Browser_DocumentCompleted
/// <summary>
/// Called when the browser is completed
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser Browser = (WebBrowser)sender;
Browser.ScriptErrorsSuppressed = true;
Browser.ScrollBarsEnabled = false;
if (Width == -1)
{
Browser.Width = Browser.Document.Body.ScrollRectangle.Width;
}
else
{
Browser.Width = Width;
}
if (Height == -1)
{
Browser.Height = Browser.Document.Body.ScrollRectangle.Height;
}
else
{
Browser.Height = Height;
}
Image = new Bitmap(Browser.Width, Browser.Height);
Browser.BringToFront();
Browser.DrawToBitmap(Image, new Rectangle(0, 0, Browser.Width, Browser.Height));
Image.Save(FileName,ImageFormat.Bmp);
}
示例15: webBrowser_DocumentCompleted
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (e.Url != this.webBrowser.Document.Url)
{
return;
}
string encode = this.webBrowser.Document.Encoding;
StreamReader sr = new StreamReader(this.webBrowser.DocumentStream, Encoding.GetEncoding(encode));
string html = sr.ReadToEnd();
//Html2Article.LimitCount = 100;
//Html2Article.Depth = 8;
// 设置是否使用正文追加模式
Html2Article.AppendMode = this.appendCheckBox.CheckState == CheckState.Checked;
Stopwatch sw = new Stopwatch();
sw.Start();
// 将Html解析为Article结构化数据
Article article = Html2Article.GetArticle(html);
sw.Stop();
msgLabel.Text = "提取耗时:" + Environment.NewLine + sw.ElapsedMilliseconds + "毫秒";
this.publishDateTextBox.Text = article.PublishDate.ToString();
this.titleTextBox.Text = article.Title;
this.contentTextBox.Text = article.Content;
string articleHtml = UrlUtility.FixUrl(this.urlTextBox.Text, article.ContentWithTags);
this.contentWebBrowser.DocumentText = articleHtml;
ResetState();
}