mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-15 20:52:40 +00:00
detect Office installation
This commit is contained in:
@@ -24,13 +24,14 @@ namespace QuickLook.Plugin.IPreviewHandlers
|
|||||||
case ".docx":
|
case ".docx":
|
||||||
case ".xls":
|
case ".xls":
|
||||||
case ".xlsx":
|
case ".xlsx":
|
||||||
|
case ".bbb":
|
||||||
case ".xlsm":
|
case ".xlsm":
|
||||||
// Visio Viewer will not quit after preview, which cause serious memory issue
|
// Visio Viewer will not quit after preview, which cause serious memory issue
|
||||||
//case ".vsd":
|
//case ".vsd":
|
||||||
//case ".vsdx":
|
//case ".vsdx":
|
||||||
case ".ppt":
|
case ".ppt":
|
||||||
case ".pptx":
|
case ".pptx":
|
||||||
return true;
|
return PreviewHandlerHost.GetPreviewHandlerGUID(path) != Guid.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -47,11 +48,7 @@ namespace QuickLook.Plugin.IPreviewHandlers
|
|||||||
context.ViewerContent = _panel;
|
context.ViewerContent = _panel;
|
||||||
context.Title = Path.GetFileName(path);
|
context.Title = Path.GetFileName(path);
|
||||||
|
|
||||||
_panel.Loaded += (sender, e) =>
|
_panel.PreviewFile(path, context);
|
||||||
{
|
|
||||||
_panel.PreviewFile(path);
|
|
||||||
SetForegroundWindow(new WindowInteropHelper(context.ViewerWindow).Handle);
|
|
||||||
};
|
|
||||||
|
|
||||||
context.IsBusy = false;
|
context.IsBusy = false;
|
||||||
}
|
}
|
||||||
@@ -64,11 +61,6 @@ namespace QuickLook.Plugin.IPreviewHandlers
|
|||||||
_panel = null;
|
_panel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
private static extern bool SetForegroundWindow(IntPtr hWnd);
|
|
||||||
|
|
||||||
~PluginInterface()
|
~PluginInterface()
|
||||||
{
|
{
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
@@ -61,7 +61,7 @@ namespace QuickLook.Plugin.IPreviewHandlers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename"></param>
|
/// <param name="filename"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private Guid GetPreviewHandlerGUID(string filename)
|
public static Guid GetPreviewHandlerGUID(string filename)
|
||||||
{
|
{
|
||||||
// open the registry key corresponding to the file extension
|
// open the registry key corresponding to the file extension
|
||||||
var ext = Registry.ClassesRoot.OpenSubKey(Path.GetExtension(filename));
|
var ext = Registry.ClassesRoot.OpenSubKey(Path.GetExtension(filename));
|
||||||
@@ -150,8 +150,4 @@ namespace QuickLook.Plugin.IPreviewHandlers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region COM Interop
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
|
||||||
namespace QuickLook.Plugin.IPreviewHandlers
|
namespace QuickLook.Plugin.IPreviewHandlers
|
||||||
{
|
{
|
||||||
@@ -9,7 +11,7 @@ namespace QuickLook.Plugin.IPreviewHandlers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class PreviewPanel : UserControl, IDisposable
|
public partial class PreviewPanel : UserControl, IDisposable
|
||||||
{
|
{
|
||||||
private PreviewHandlerHost _control = new PreviewHandlerHost();
|
private PreviewHandlerHost _control;
|
||||||
|
|
||||||
public PreviewPanel()
|
public PreviewPanel()
|
||||||
{
|
{
|
||||||
@@ -25,17 +27,23 @@ namespace QuickLook.Plugin.IPreviewHandlers
|
|||||||
_control = null;
|
_control = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PreviewFile(string file)
|
public void PreviewFile(string file, ContextObject context)
|
||||||
|
{
|
||||||
|
Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
_control = new PreviewHandlerHost();
|
_control = new PreviewHandlerHost();
|
||||||
|
|
||||||
presenter.Child = _control;
|
presenter.Child = _control;
|
||||||
|
|
||||||
_control.Open(file);
|
_control.Open(file);
|
||||||
|
}), DispatcherPriority.Render);
|
||||||
|
|
||||||
SetActiveWindow(presenter.Handle);
|
//SetForegroundWindow(new WindowInteropHelper(context.ViewerWindow).Handle);
|
||||||
|
//SetActiveWindow(presenter.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
private static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
private static extern bool SetActiveWindow(IntPtr hWnd);
|
private static extern bool SetActiveWindow(IntPtr hWnd);
|
||||||
|
Reference in New Issue
Block a user