Beispiel #1
0
 /// <summary>
 /// 打开文件
 /// </summary>
 /// <param name="args">打开文件参数</param>
 public void Open(IFileViewerArgs args)
 {
     if (args is IFileViewerHighlightArgs)
     {
         IFileViewerHighlightArgs ifvha = args as IFileViewerHighlightArgs;
         this.PART_TextBox.IsAutoUpdateHighlight = false;
         if (args.Encoding != null)
         {
             this.DoOpen(args.Path, args.Encoding);
             this.PART_TextBox.HighlightMode   = ifvha.HighlightMode;
             this.PART_TextBox.HighlightText   = ifvha.HighlightText;
             this.PART_TextBox.HighlightOffset = ifvha.HighlightOffset;
             this.PART_TextBox.HighlightLength = ifvha.HighlightLength;
             this.PART_TextBox.UpdateHighlight();
             return;
         }
     }
     if (args.Type == FileViewerArgsType.Path)
     {
         this.Open(args.Path);
     }
     else if (args.Type == FileViewerArgsType.Stream)
     {
         this.Open(args.Stream, args.Extension);
     }
     else if (args.Type == FileViewerArgsType.Buffer)
     {
         this.Open(args.Buffer, args.Extension);
     }
     this.OpenArgs = args;
 }
Beispiel #2
0
 /// <summary>
 /// 打开文件
 /// </summary>
 /// <param name="args">打开文件参数</param>
 public void Open(IFileViewerArgs args)
 {
     if (args.Type == FileViewerArgsType.Path)
     {
         this.Open(args.Path);
     }
     else if (args.Type == FileViewerArgsType.Stream)
     {
         this.Open(args.Stream, args.Extension);
     }
     else if (args.Type == FileViewerArgsType.Buffer)
     {
         this.Open(args.Buffer, args.Extension);
     }
     this.OpenArgs = args;
 }
 /// <summary>
 /// 打开文件
 /// </summary>
 /// <param name="args">打开文件参数</param>
 public void Open(IFileViewerArgs args)
 {
     if (this.FileViewer == null)
     {
         return;
     }
     if (!this.IsDelayOpen)
     {
         this.FileViewer.Open(args);
     }
     else
     {
         this.lastArgs   = args;
         this.IsDelaying = true;
         this.ResetTimer(false);
     }
     this.OpenArgs = args;
 }
        /// <summary>
        /// 打开文件
        /// </summary>
        /// <param name="args">打开文件参数</param>
        public void Open(IFileViewerArgs args)
        {
            string      extension = args.Extension;
            IFileViewer viewer    = null;

            if (args.Buffer == null && string.IsNullOrEmpty(args.Path) && args.Stream == null)
            {
                viewer = this.FileViewers.Where(c => c.ViewerType == FileViewerType.None).FirstOrDefault();
            }
            else
            {
                viewer = this._Open(extension, args.Type);
            }
            if (viewer != null)
            {
                viewer.Open(args);
            }
            this.OpenArgs = args;
        }
 /// <summary>
 /// 打开文件
 /// </summary>
 /// <param name="path">文件路径</param>
 public void Open(string path)
 {
     if (this.FileViewer == null)
     {
         return;
     }
     if (!this.IsDelayOpen)
     {
         this.FileViewer.Open(path);
     }
     else
     {
         FileViewerArgs args = new FileViewerArgs();
         args.Path       = path;
         args.Type       = FileViewerArgsType.Path;
         this.lastArgs   = args;
         this.IsDelaying = true;
         this.ResetTimer(false);
     }
     this.OpenArgs = path;
 }
 /// <summary>
 /// 打开文件
 /// </summary>
 /// <param name="buffer">文件Buffer</param>
 /// <param name="extension">要打开的文件扩展名</param>
 public void Open(byte[] buffer, string extension)
 {
     if (this.FileViewer == null)
     {
         return;
     }
     if (!this.IsDelayOpen)
     {
         this.FileViewer.Open(buffer, extension);
     }
     else
     {
         FileViewerArgs args = new FileViewerArgs();
         args.Buffer     = buffer;
         args.Extension  = extension;
         args.Type       = FileViewerArgsType.Buffer;
         this.lastArgs   = args;
         this.IsDelaying = true;
         this.ResetTimer(false);
     }
     this.OpenArgs = buffer;
 }
 /// <summary>
 /// 打开文件
 /// </summary>
 /// <param name="stream">文件流</param>
 /// <param name="extension">要打开的文件扩展名</param>
 public void Open(System.IO.Stream stream, string extension)
 {
     if (this.FileViewer == null)
     {
         return;
     }
     if (!this.IsDelayOpen)
     {
         this.FileViewer.Open(stream, extension);
     }
     else
     {
         FileViewerArgs args = new FileViewerArgs();
         args.Stream     = stream;
         args.Extension  = extension;
         args.Type       = FileViewerArgsType.Stream;
         this.lastArgs   = args;
         this.IsDelaying = true;
         this.ResetTimer(false);
     }
     this.OpenArgs = stream;
 }
 /// <summary>
 /// 执行打开文件
 /// </summary>
 private void DoOpen()
 {
     if (this.lastArgs == null || this.IsVisible == false || this.FileViewer == null)
     {
         return;
     }
     lock (this.lastArgs)
     {
         IFileViewerArgs temp = this.lastArgs;
         this.lastArgs = null;
         try
         {
             this.FileViewer.Open(temp);
             this.timer.Stop();
             this.IsDelaying = false;
         }
         catch
         {
             this.timer.Stop();
             this.IsDelaying = false;
         }
     }
 }