From 302aad41ead6a47c5ddfbd9613d8801638557673 Mon Sep 17 00:00:00 2001 From: ema Date: Fri, 13 Dec 2024 15:35:15 +0800 Subject: [PATCH] Merge InvokePluginPreview from emako/QuickLook --- QuickLook/ViewWindowManager.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/QuickLook/ViewWindowManager.cs b/QuickLook/ViewWindowManager.cs index fbfabe47..ac9cb14e 100644 --- a/QuickLook/ViewWindowManager.cs +++ b/QuickLook/ViewWindowManager.cs @@ -140,6 +140,30 @@ public void InvokePreview(string path = null) BeginShowNewWindow(path, matchedPlugin); } + public void InvokePluginPreview(string plugin, string path = null) + { + if (string.IsNullOrEmpty(path)) + path = _invokedPath; + + if (string.IsNullOrEmpty(path)) + return; + + if (!Directory.Exists(path) && !File.Exists(path)) + return; + + RunFocusMonitor(); + + var matchedPlugin = PluginManager.GetInstance().LoadedPlugins.Find(p => + { + return p.GetType().Assembly.GetName().Name == plugin; + }); + + if (matchedPlugin != null) + { + BeginShowNewWindow(path, matchedPlugin); + } + } + private void BeginShowNewWindow(string path, IViewer matchedPlugin) { _viewerWindow.UnloadPlugin();