[File Explorer Add-ons] Fix file preview pane flickering on file selection and resizing (#26660)

* Move color values to constant

* Fix MonacoPreview flickering on file selection and resizing

* Fix MarkdownPreview flickering on file selection and resizing

* Fix SvgPreview flickering on file selection and resizing

* Create Settings class and standardize background setting for MarkdownPreview

* Replace ColorTranslator.FromHtml with Color.FromArgb for constant color settings

* Use existing SetBackground

* Remove duplicate GetTheme function

* Update src/modules/previewpane/MarkdownPreviewHandler/Settings.cs
This commit is contained in:
Chek Wei Tan
2023-06-14 21:15:17 +08:00
committed by GitHub
parent 6ece812103
commit 9581cd7a27
13 changed files with 97 additions and 10 deletions

View File

@@ -47,7 +47,7 @@ namespace SvgPreviewHandler
{
if (Common.UI.ThemeManager.GetWindowsBaseColor().ToLowerInvariant() == "dark")
{
return ColorTranslator.FromHtml("#1e1e1e");
return Color.FromArgb(30, 30, 30); // #1e1e1e
}
else
{

View File

@@ -20,6 +20,11 @@ namespace Microsoft.PowerToys.PreviewHandler.Svg
/// </summary>
public class SvgPreviewControl : FormHandlerControl
{
/// <summary>
/// Settings class
/// </summary>
private readonly SvgPreviewHandler.Settings _settings = new();
/// <summary>
/// Generator for the actual preview file
/// </summary>
@@ -78,6 +83,11 @@ namespace Microsoft.PowerToys.PreviewHandler.Svg
private string _webView2UserDataFolder = System.Environment.GetEnvironmentVariable("USERPROFILE") +
"\\AppData\\LocalLow\\Microsoft\\PowerToys\\SvgPreview-Temp";
public SvgPreviewControl()
{
this.SetBackgroundColor(_settings.ThemeColor);
}
/// <summary>
/// Start the preview on the Control.
/// </summary>
@@ -199,6 +209,7 @@ namespace Microsoft.PowerToys.PreviewHandler.Svg
private void AddWebViewControl(string svgData)
{
_browser = new WebView2();
_browser.DefaultBackgroundColor = Color.Transparent;
_browser.Dock = DockStyle.Fill;
// Prevent new windows from being opened.