Click or drag to resize

LoadPreviewEventArgsCustomPreviewHandler Property

Set your own IShellPreviewHandler implementation to custom preview files.

Namespace:  Jam.Shell
Assembly:  ShellBrowser.Core (in ShellBrowser.Core.dll) Version: 6.3.1
Syntax
public IShellPreviewHandler CustomPreviewHandler { get; set; }

Property Value

Type: IShellPreviewHandler
An object implementing IShellPreviewHandler
Examples
The following example loads cs files into a textbox.
class CustomPreviewHandler : IShellPreviewHandler
{
 private TextBox m_TextBox;

 public bool Load(ShellFilePreview parent, string p_Path, ItemIdList p_AbsolutePidl)
 {
   m_TextBox = new TextBox();
   m_TextBox.Dock = DockStyle.Fill;
   m_TextBox.Parent = parent;
   m_TextBox.WordWrap = false;
   m_TextBox.ScrollBars = ScrollBars.Both;
   m_TextBox.Multiline = true;
   m_TextBox.Text = System.IO.File.ReadAllText(p_Path);
   parent.Controls.Add(m_TextBox);
   return true;
 }

 public void Show()
 {
 }

 public void Unload()
 {
   m_TextBox.Dispose();
 }

 public void Resize()
 {
  //nothing to do.
 }
}

private void shellFilePreview1_LoadPreview(object sender, LoadPreviewEventArgs e)
{
 string file = e.Path;
 if (String.IsNullOrEmpty(file))
 {
   return;
 }
 if (".cs".Equals(System.IO.Path.GetExtension(file), StringComparison.OrdinalIgnoreCase))
 {
   e.CustomPreviewHandler = new CustomPreviewHandler();
 }
 else if (e.PreviewHandlerGuid == null)
 {
   //add actions to take if no registered PreviewHandler is available.
 }
}
See Also