自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

silverlight仿“百度文庫”的文檔控件

開發(fā) 后端
通用的FlashPaper支持Word/Excel/PDF,到時對于Silverlight的XPS的文檔支持問題比較多,本控件提供了一個可視化的XPS文檔展示,提供放大縮小/打印/搜索/分頁等功能,主要整合了開源的Document Toolkit。

通用的FlashPaper支持Word/Excel/PDF,到時對于Silverlight的XPS的文檔支持問題比較多,本控件提供了一個可視化的XPS文檔展示,提供放大縮小/打印/搜索/分頁等功能,主要整合了開源的Document Toolkit。

1. 使用Document Toolkit,DocumentDataSource提供數(shù)據(jù)源,PageNvaigator提供分頁 :

  1. <doc:DocumentDataSource x:Name="dataSource"/>  
  2.  
  3.         <doc:DocumentViewer Grid.Row="1" x:Name="viewer" DocumentDataSource="{Binding ElementName=dataSource}" ViewMode="{Binding SelectedViewMode, ElementName=viewModePicker}" BorderBrush="#9fa9a4" BorderThickness="1"/>  
  4.  
  5.         <doc:PageNavigator x:Name="navigator" HorizontalAlignment="Center"   
  6.                     PageCount="{Binding PageCount, ElementName=viewer}" 
  7.                     PageIndex="{Binding PageIndex, ElementName=viewer, Mode=TwoWay}" 
  8.                     />  
  9.                   
  10.         <doc:ViewModePicker Grid.Column="1" x:Name="viewModePicker" Visibility="Collapsed"/> 

2. WebPackageReader讀取本地xps或遠(yuǎn)程xps文件作為數(shù)據(jù)源

DotNetZipPackageReader 根據(jù)分頁延遲加載文檔

  1. // loads the sample XPS document from the web  
  2.             var url = string.Format("/DocumentService.ashx?id={0}", HtmlPage.Document.GetElementById("documentId").GetProperty("value"));  
  3.             webClient.OpenReadAsync(new Uri(HtmlPage.Document.DocumentUri, url));   
  4.             var reader = new WebPackageReader(new Uri(HtmlPage.Document.DocumentUri, url + "&part="));  
  5.             this.dataSource.PackageReader = reader;  
  6.             var xpsClient = new XpsClient();  
  7.             xpsClient.LoadXpsDocumentAsync(reader); 

3. 服務(wù)端根據(jù)請求的文件ID和當(dāng)前頁碼返回指定的文件流

  1. private void Response(HttpContext context, string xpsFileName, string partName)  
  2.         {  
  3.             using (FileStream stream = File.OpenRead(xpsFileName))  
  4.             {  
  5.                 ZipFile file = new ZipFile(stream);  
  6.                 ZipEntry entry = file.GetEntry(partName);  
  7.                 if (entry != null)  
  8.                 {  
  9.                     using (Stream entryStream = file.GetInputStream(entry))  
  10.                     {  
  11.                         // TODO: set mime-type as defined in XPS package  
  12.                         context.Response.ContentType = "application/octet-stream";  
  13.                         byte[] buffer = new byte[2 << 14];    // write blocks of 32768 bytes  
  14.                         int read;  
  15.                         while ((read = entryStream.Read(buffer, 0, buffer.Length)) > 0)  
  16.                         {  
  17.                             context.Response.OutputStream.Write(buffer, 0, read);  
  18.                         }  
  19.                     }  
  20.                 }  
  21.                 else 
  22.                 {  
  23.                     // return 404 Not Found  
  24.                     context.Response.StatusCode = (int)HttpStatusCode.NotFound;  
  25.                 }  
  26.             }  
  27.  
  28.         } 

4. 源代碼下載

點擊

5. 在線預(yù)覽

http://rapidsl2.guozili.25u.com/  (admin/admin  點左邊菜單 控件展示 - 文檔查看器)

6. 截圖

 

 

原文鏈接:http://www.cnblogs.com/guozili/archive/2012/07/16/2593437.html

【編輯推薦】

責(zé)任編輯:張偉 來源: guozili的博客
相關(guān)推薦

2012-06-18 16:29:48

Web

2012-06-19 13:25:15

Web

2012-06-19 13:32:23

Web

2012-06-18 16:37:41

Web

2015-10-28 13:40:28

高仿百度糯米源碼

2012-06-19 13:45:57

Web

2012-10-19 09:47:30

百度云百度音樂云計算

2012-06-19 13:42:08

Web

2011-05-24 10:40:12

SEO

2011-06-29 16:02:40

jQuery

2014-07-25 17:12:39

數(shù)據(jù)庫WOT2014MongoDB

2013-08-22 17:08:50

2025-01-21 18:37:07

2023-10-12 17:37:50

百度文庫百度世界大會

2017-09-12 17:05:02

AndroidLoading客戶端

2014-09-04 02:25:24

百度世界大會2014直達(dá)號BaiduEye
點贊
收藏

51CTO技術(shù)棧公眾號