private void Button_Click(object sender, RoutedEventArgs e) { if (webBrowser != null) { webBrowser.Dispose(); } if (kitBrowser != null) { kitBrowser.Dispose(); } GC.Collect(); this.Close(); }
private void Getdata() { WebKit.DOM.Element element; WebKit.DOM.Element element2; WebKit.DOM.Element element3; element = browser.Document.GetElementById("gz_gsz"); element2 = browser.Document.GetElementById("gz_gszze"); element3 = browser.Document.GetElementById("gz_gszzl"); price.Text = Convert.ToDouble(element.TextContent) * 285 + " per/g"; percent.Text = element2.TextContent; ppercent.Text = element3.TextContent; if (min != 0) { if (Convert.ToDouble(element.TextContent) * 285 < min) { min = Convert.ToDouble(element.TextContent) * 285; } if (Convert.ToDouble(element.TextContent) * 285 > max && min != 0 && Convert.ToDouble(element.TextContent) * 285 > min) { max = Convert.ToDouble(element.TextContent) * 285; } } else { min = Convert.ToDouble(element.TextContent) * 285; nowprice = min; } if (min != 0 && max != 0) { chart1.ChartAreas[0].AxisY.Minimum = min; chart1.ChartAreas[0].AxisY.Maximum = max; } if (first) { first = false; string tmp = File.ReadAllText("PriceList.txt"); File.WriteAllText("PriceList.txt", tmp + (Convert.ToDouble(element.TextContent) * 285).ToString() + "\r\n"); } if (nowprice != Convert.ToDouble(element.TextContent) * 285) { chart1.Series[0].Points.Add(Convert.ToDouble(Convert.ToDouble(element.TextContent) * 285)); string tmp = File.ReadAllText("PriceList.txt"); File.WriteAllText("PriceList.txt", tmp + (Convert.ToDouble(element.TextContent) * 285).ToString() + "\r\n"); nowprice = Convert.ToDouble(element.TextContent) * 285; } browser.Dispose(); browser.Url = new Uri("http://fund.eastmoney.com/002611.html?spm=aladin"); browser.DocumentCompleted += Browser_DocumentCompleted; }