using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web;
using System.Net;
using Sanzond;
using System.Text.RegularExpressions;
using mshtml;
namespace HttpPostGet
{
public partial class jond : Form
{
public jond()
{
InitializeComponent();
}
private void btnDisplay_Click(object sender, EventArgs e)
{
Cmd.CreateDirectory("c:\\xj");
string url;
url = txtURL.Text;
lbPage.Text = "0";
if (url.Length > 0)
{
webBrowserPreview.Navigate(url);
//等待加载完毕
//while (webBrowserPreview.ReadyState < WebBrowserReadyState.Complete) Application.DoEvents();
}
else
{
MessageBox.Show("请输入网址!");
}
}
private void jond_Load(object sender, EventArgs e)
{
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
txtURL.Text = "http://www.sanzond.com/tools";
webBrowserPreview.Navigate("http://www.sanzond.com/tools");
}
private void webBrowserPreview_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//listBox1.Items.Add(webBrowserPreview.ReadyState);
while (webBrowserPreview.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
//if (webBrowser1.ReadyState < WebBrowserReadyState.Complete || webBrowser1.Url.ToString() == LastUrl) return;
//LastUrl = webBrowser1.Url.ToString();
if (webBrowserPreview.ReadyState == WebBrowserReadyState.Complete)
{
HtmlElement link = webBrowserPreview.Document.GetElementById("pager");
link.SetAttribute("selectedindex", (Convert.ToInt32(link.GetAttribute("selectedindex"))+1).ToString());
lbPage.Text = link.GetAttribute("selectedindex").ToString();
link.InvokeMember("onchange");
HTMLDocument html = (HTMLDocument)webBrowserPreview.Document.DomDocument;
IHTMLControlElement img = (IHTMLControlElement)webBrowserPreview.Document.Images["Image1"].DomElement;
IHTMLControlRange range = (IHTMLControlRange)((HTMLBody)html.body).createControlRange();
range.add(img);
range.execCommand("Copy", false, null);
img = null;
range = null;
html = null;
if (Clipboard.ContainsImage())
{
this.pictureBox1.Image = Clipboard.GetImage();
//if (Clipboard.GetImage().)
pictureBox1.Image.Save("c:\\xj\\" + link.GetAttribute("selectedindex").ToString() + ".jpg");
//pictureBox1.
lbPage.Text = Convert.ToString(Convert.ToInt32(lbPage.Text) + 1);
Clipboard.SetImage(null);
}
else
{
MessageBox.Show("执行不成功");
}
Clipboard.Clear();
}
}
}
}