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();
|
_panel = new PreviewPanel();
|
||||||
context.ViewerContent = _panel;
|
context.ViewerContent = _panel;
|
||||||
context.Title = Path.GetFileName(path);
|
context.Title = Path.GetFileName(path);
|
||||||
|
|
||||||
_panel.PreviewFile(path, context);
|
_panel.PreviewFile(path, context);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
context.ViewerContent = new Label()
|
||||||
|
{
|
||||||
|
Content = e.ToString(),
|
||||||
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Center,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
context.IsBusy = false;
|
context.IsBusy = false;
|
||||||
}
|
}
|
||||||
|
@@ -102,9 +102,7 @@ public class PreviewHandlerHost : Control
|
|||||||
CurrentPreviewHandler = guid;
|
CurrentPreviewHandler = guid;
|
||||||
var o = Activator.CreateInstance(Type.GetTypeFromCLSID(CurrentPreviewHandler, true));
|
var o = Activator.CreateInstance(Type.GetTypeFromCLSID(CurrentPreviewHandler, true));
|
||||||
|
|
||||||
var fileInit = o as IInitializeWithFile;
|
if (o is not IInitializeWithFile fileInit)
|
||||||
|
|
||||||
if (fileInit == null)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fileInit.Initialize(path, 0);
|
fileInit.Initialize(path, 0);
|
||||||
|
@@ -44,9 +44,6 @@ public class PreviewPanel : WindowsFormsHost, IDisposable
|
|||||||
_control = new PreviewHandlerHost();
|
_control = new PreviewHandlerHost();
|
||||||
Child = _control;
|
Child = _control;
|
||||||
_control.Open(file);
|
_control.Open(file);
|
||||||
|
|
||||||
//SetForegroundWindow(new WindowInteropHelper(context.ViewerWindow).Handle);
|
|
||||||
//SetActiveWindow(presenter.Handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
|
Reference in New Issue
Block a user