WEB开发网
开发学院操作系统Windows Vista Windows Vista 和 Office: 使用托管预览处理程序框... 阅读

Windows Vista 和 Office: 使用托管预览处理程序框架以自己的方式查看数据

 2009-02-09 17:43:48 来源:WEB开发网   
核心提示: [PreviewHandler("ZIP Preview Handler", ".zip","{c0a64ec6-729b-442d-88ce-d76a9fc69e44}")][ProgId("MsdnMag.ZipPr

[PreviewHandler("ZIP Preview Handler", ".zip",
        "{c0a64ec6-729b-442d-88ce-d76a9fc69e44}")]
[ProgId("MsdnMag.ZipPreviewHandler")]
[Guid("853f35e3-bd13-417b-b859-1df25be6c834")]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public sealed class ZipPreviewHandler : FileBasedPreviewHandler
{
  protected override PreviewHandlerControl CreatePreviewHandlerControl()
  {
    return new ZipPreviewHandlerControl();
  }
  private sealed class ZipPreviewHandlerControl :
    FileBasedPreviewHandlerControl
  {
    public override void Load(FileInfo file)
    {
      ListView listView = new ListView();
      listView.Dock = DockStyle.Fill;
      listView.BorderStyle = BorderStyle.None;
        
      listView.FullRowSelect = true;
      listView.HeaderStyle = ColumnHeaderStyle.Nonclickable;
      listView.MultiSelect = false;
      listView.View = View.Details;
        
      listView.Columns.Add("File Name", -2);
      listView.Columns.Add("Size", -2);
      listView.Columns.Add("Comment", -2);
      ZipFile zip = new ZipFile(file.FullName);
      Enumeration entryEnum = zip.entries();
      while (entryEnum.hasMoreElements())
      {
        ZipEntry entry = (ZipEntry)entryEnum.nextElement();
        if (!entry.isDirectory())
        {
          listView.Items.Add(new ListViewItem(new string[] {
            entry.getName(), entry.getSize().ToString(),
            entry.getComment() }));
        }
      }
      zip.close();
      Controls.Add(listView);
    }
  }
}

Windows Vista 和 Office: 使用托管预览处理程序框架以自己的方式查看数据

上一页  2 3 4 5 6 7 8 9 10  下一页

Tags:Windows Vista Office

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接