av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

偷天換日讓Silverlight支持圖表轉(zhuǎn)圖片

 所以實(shí)現(xiàn)圖表轉(zhuǎn)圖片可以分一下幾步走.

網(wǎng)站建設(shè)公司,為您提供網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)頁(yè)設(shè)計(jì)及定制網(wǎng)站建設(shè)服務(wù),專注于企業(yè)網(wǎng)站建設(shè),高端網(wǎng)頁(yè)制作,對(duì)成都資質(zhì)代辦等多個(gè)行業(yè)擁有豐富的網(wǎng)站建設(shè)經(jīng)驗(yàn)的網(wǎng)站建設(shè)公司。專業(yè)網(wǎng)站設(shè)計(jì),網(wǎng)站優(yōu)化推廣哪家好,專業(yè)seo優(yōu)化優(yōu)化,H5建站,響應(yīng)式網(wǎng)站。

一.寫一份WPF客戶端程序

思路很簡(jiǎn)單

1.1定義一個(gè)定時(shí)器,然后檢測(cè)某目錄的xml文件,這里暫定目錄名字為chart

 
 
 
 
  1. timer = new DispatcherTimer();
  2. timer.Interval = new TimeSpan(0, 0, 2);
  3. timer.Tick += new EventHandler(timer_Tick);
  4. timer.Start();
  5. void timer_Tick(object sender, EventArgs e)
  6. {
  7. string[] files = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "chart");
  8. if (files.Length > 0)
  9. {
  10. }
  11. }

1.2如果有的話,則進(jìn)行反序列化成Chart對(duì)象進(jìn)行呈現(xiàn)

 
 
 
 
  1. void timer_Tick(object sender, EventArgs e)
  2. {
  3. string[] files = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "chart");
  4. if (files.Length > 0)
  5. {
  6. LoadXml(files[0]);
  7. }
  8. }
  9. private void LoadXml(string xmlFile)
  10. {
  11. XmlDocument doc = new XmlDocument();
  12. doc.Load(xmlFile);
  13. StringReader stringReader = new StringReader(doc.InnerXml);
  14. XmlReader xmlReader = XmlReader.Create(stringReader);
  15. Chart chart = XamlReader.Load(xmlReader) as Chart;
  16. chart.AnimationEnabled = false;
  17. stringReader.Close();
  18. xmlReader.Close();
  19. this.Content=chart;
  20. }

1.3呈現(xiàn)好以后進(jìn)行截圖

 
 
 
 
  1. void timer_Tick(object sender, EventArgs e)
  2. {
  3. string[] files = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "chart");
  4. if (files.Length > 0)
  5. {
  6. LoadXml(files[0]);
  7. PrintPicture(files[0]);
  8. }
  9. }
  10. private void PrintPicture(string fileName)
  11. {
  12. this.Dispatcher.BeginInvoke(new Action(() =>
  13. {
  14. int Height = (int)this.ActualHeight;
  15. int Width = (int)this.ActualWidth;
  16. RenderTargetBitmap bmp = new RenderTargetBitmap(Width, Height, 96, 96, PixelFormats.Pbgra32);
  17. bmp.Render(this);
  18. string file = "C:\\temp\\a.jpg";
  19. BitmapEncoder encoder;
  20. encoder = new JpegBitmapEncoder();
  21. encoder.Frames.Add(BitmapFrame.Create(bmp));
  22. using (Stream stm = File.Create(file))
  23. {
  24. encoder.Save(stm);
  25. }
  26. File.Delete(fileName);
  27. }), System.Windows.Threading.DispatcherPriority.Render);
  28. }

1.4轉(zhuǎn)換成圖片完畢則刪除此xml文件

二.將編譯好的wpf程序放置在web根目錄,然后啟動(dòng)此程序

三.使用ajax交互將當(dāng)前顯示出來(lái)的xml傳送到chart目錄下

前端

 
 
 
 
  1. $.ajax({
  2. type: "POST",
  3. url: "ajaxServer.aspx",
  4. data: "name=" + vChart.dataUri,
  5. success: function(msg) {
  6. alert("Success");
  7. }
  8. });

后端

拷貝xml文件或者其他處理方式把xml弄到chart目錄下

 
 
 
 
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. File.Copy(Server.MapPath(this.Request["name"]), Server.MapPath("../chart/" + this.Request["name"]));
  4. }

注意點(diǎn):轉(zhuǎn)換的時(shí)候注意wpf和silverlight的命名空間.也算是一個(gè)方法,對(duì)付圖表生成圖片是綽綽有余的.小技巧分享一下


分享題目:偷天換日讓Silverlight支持圖表轉(zhuǎn)圖片
網(wǎng)站地址:http://uogjgqi.cn/article/dhijhhc.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流