Beautify the background color of Svg Web2

This commit is contained in:
ema
2025-06-30 06:00:29 +08:00
parent 98dd96283d
commit 7ca7d2783e
4 changed files with 29 additions and 55 deletions

View File

@@ -45,24 +45,27 @@ public class WebpagePanel : UserControl
public WebpagePanel()
{
if (!Helper.IsWebView2Available())
{
Content = CreateDownloadButton();
}
else
InitializeComponent();
}
protected virtual void InitializeComponent()
{
_webView = new WebView2
{
_webView = new WebView2
CreationProperties = new CoreWebView2CreationProperties
{
CreationProperties = new CoreWebView2CreationProperties
{
UserDataFolder = Path.Combine(SettingHelper.LocalDataPath, @"WebView2_Data\"),
},
DefaultBackgroundColor = OSThemeHelper.AppsUseDarkTheme() ? Color.FromArgb(255, 32, 32, 32) : Color.White, // Prevent white flash in dark mode
};
_webView.NavigationStarting += Webview_NavigationStarting;
_webView.NavigationCompleted += WebView_NavigationCompleted;
_webView.CoreWebView2InitializationCompleted += WebView_CoreWebView2InitializationCompleted;
Content = _webView;
}
UserDataFolder = Path.Combine(SettingHelper.LocalDataPath, @"WebView2_Data\"),
},
// Prevent white flash in dark mode
DefaultBackgroundColor = OSThemeHelper.AppsUseDarkTheme() ? Color.FromArgb(255, 32, 32, 32) : Color.White,
};
_webView.NavigationStarting += Webview_NavigationStarting;
_webView.NavigationCompleted += WebView_NavigationCompleted;
_webView.CoreWebView2InitializationCompleted += WebView_CoreWebView2InitializationCompleted;
Content = _webView;
}
public void NavigateToFile(string path)