mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-15 12:49:13 +00:00
Show office exception instead of crash
This commit is contained in:
@@ -134,11 +134,22 @@ public class Plugin : IViewer
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_panel = new PreviewPanel();
|
||||
context.ViewerContent = _panel;
|
||||
context.Title = Path.GetFileName(path);
|
||||
|
||||
_panel.PreviewFile(path, context);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
context.ViewerContent = new Label()
|
||||
{
|
||||
Content = e.ToString(),
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
};
|
||||
}
|
||||
|
||||
context.IsBusy = false;
|
||||
}
|
||||
|
@@ -102,9 +102,7 @@ public class PreviewHandlerHost : Control
|
||||
CurrentPreviewHandler = guid;
|
||||
var o = Activator.CreateInstance(Type.GetTypeFromCLSID(CurrentPreviewHandler, true));
|
||||
|
||||
var fileInit = o as IInitializeWithFile;
|
||||
|
||||
if (fileInit == null)
|
||||
if (o is not IInitializeWithFile fileInit)
|
||||
return false;
|
||||
|
||||
fileInit.Initialize(path, 0);
|
||||
|
@@ -44,9 +44,6 @@ public class PreviewPanel : WindowsFormsHost, IDisposable
|
||||
_control = new PreviewHandlerHost();
|
||||
Child = _control;
|
||||
_control.Open(file);
|
||||
|
||||
//SetForegroundWindow(new WindowInteropHelper(context.ViewerWindow).Handle);
|
||||
//SetActiveWindow(presenter.Handle);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
|
Reference in New Issue
Block a user