ShellFilePreviewLoadPreview Event |
Namespace: Jam.Shell.WPF.Controls
private static Guid MS_HTML_PREVIEW = new Guid("F8B8412B-DEA3-4130-B36C-5E8BE73106AC"); private void ShellFilePreview1_LoadPreview(object sender, LoadPreviewEventArgs e) { if (string.IsNullOrEmpty(e.Path)) return; if (".cms".Equals(System.IO.Path.GetExtension(e.Path), StringComparison.OrdinalIgnoreCase)) e.PreviewHandlerGuid = MS_HTML_PREVIEW; }
private void ShellFilePreview_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. } } #region ShellFilePreview_LoadPreview private static Guid MS_HTML_PREVIEW = new Guid("F8B8412B-DEA3-4130-B36C-5E8BE73106AC"); private void ShellFilePreview1_LoadPreview(object sender, LoadPreviewEventArgs e) { if (string.IsNullOrEmpty(e.Path)) return; if (".cms".Equals(System.IO.Path.GetExtension(e.Path), StringComparison.OrdinalIgnoreCase)) e.PreviewHandlerGuid = MS_HTML_PREVIEW; } #endregion private class CustomPreviewHandler : IShellPreviewHandler { private ShellFilePreview m_Parent; public bool Load(ICommonPreviewHandlerHost p_Parent, string p_Path, ItemIdList p_AbsolutePidl) { m_Parent = (p_Parent as ShellFilePreview); ScrollViewer lScroll = new ScrollViewer(); TextBox lTextBox = new TextBox(); lTextBox.Text = System.IO.File.ReadAllText(p_Path); lScroll.Content = lTextBox; m_Parent.SetCustomPreviewHandler(lScroll); return true; } public void Resize() { } public void Show() { } public void Unload() { m_Parent.RemoveCustomPreviewHandler(); } } public void Dispose() { shellFilePreview.Dispose(); }