Add theme toggle support to all WebView2-based image panels

Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-17 09:23:28 +00:00
parent 0844c7fe14
commit 2a8b71a89c
5 changed files with 16 additions and 4 deletions

View File

@@ -35,6 +35,10 @@ public class LottieImagePanel : SvgImagePanel
ObjectForScripting ??= new ScriptHandler(path);
_homePage = _resources["/lottie2html.html"];
// Update WebView2 background color based on current theme
UpdateWebViewBackgroundColor();
NavigateToUri(new Uri("file://quicklook/"));
}

View File

@@ -126,7 +126,7 @@ public partial class SvgImagePanel : UserControl, IWebImagePanel
UpdateWebViewBackgroundColor();
}
private void UpdateWebViewBackgroundColor()
protected void UpdateWebViewBackgroundColor()
{
if (_webView == null) return;

View File

@@ -34,6 +34,10 @@ public class SvgaImagePanel(IWebMetaProvider metaWeb) : SvgImagePanel()
ObjectForScripting ??= new ScriptHandler(path, _metaWeb);
_homePage = _resources["/svga2html.html"];
// Update WebView2 background color based on current theme
UpdateWebViewBackgroundColor();
NavigateToUri(new Uri("file://quicklook/"));
}
}

View File

@@ -35,6 +35,10 @@ public class TgsImagePanel : SvgImagePanel
ObjectForScripting ??= new TgsScriptHandler(path);
_homePage = _resources["/lottie2html.html"];
// Update WebView2 background color based on current theme
UpdateWebViewBackgroundColor();
NavigateToUri(new Uri("file://quicklook/"));
}

View File

@@ -103,9 +103,9 @@ internal static class WebHandler
ipWeb = ext switch
{
".svg" => new SvgImagePanel() { ContextObject = context },
".svga" => new SvgaImagePanel(metaWeb),
".lottie" or ".json" => new LottieImagePanel(),
".tgs" => new TgsImagePanel(),
".svga" => new SvgaImagePanel(metaWeb) { ContextObject = context },
".lottie" or ".json" => new LottieImagePanel() { ContextObject = context },
".tgs" => new TgsImagePanel() { ContextObject = context },
_ => throw new NotSupportedException($"Unsupported file type: {ext}")
};