public void downQRcode(string url, qrcode qc)//生成二维码--------------------------------------------------------------- { WebBrowser web = new WebBrowser(); web.ScriptErrorsSuppressed = true; web.Navigate("http://www.wwei.cn/"); web.DocumentCompleted += (sender, e) => Web_DocumentCompleted(web, url, qc); }
private void Web_DocumentCompleted(WebBrowser web, string url, qrcode qc) { web.Document.GetElementById("text_qrtext").SetAttribute("value", url); //panel1.Controls.Add(web); web.Document.GetElementById("wwei_qrcode_create").InvokeMember("Click"); timer1.Enabled = true; timer1.Tick += (sender, e) => timer1_Tick(web, qc); }
private void timer1_Tick(WebBrowser web, qrcode qc) { timer1.Enabled = false; // string imgpath = "data//img.png"; // if (File.Exists(imgpath)) File.Delete(imgpath); string url = web.Document.GetElementById("view-qrcode-img").Children[0].GetAttribute("src"); // WebClient wc = new WebClient(); // wc.DownloadFile(url, imgpath); // wc.Dispose(); qc.set(url); }//------------------------------------------------------------------------------------------------------
private void button7_Click(object sender, EventArgs e) { string url = textBox1.Text; string Url = @"^http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?$"; if (url != null) { if (Regex.IsMatch(url, Url)) { qrcode qc = new qrcode(PointToScreen(button7.Location), mf); qc.Show(); downQRcode(url, qc); } } }