mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
SvgPreviewControl: Add Background so that white .svg are visible (#25397)
* SvgPreviewControl: Add checkered background so that white .svg are visible * SvgPreviewControl: Move preview generation logic into own class * SvgPreviewControl: Add possibility to configure background of svg preview pane via the settings ui * SvgPreviewControl: Take user configuration into consideration when generating svg preview * SvgPreviewControl: Do not generate preview file, if the actual size is under the 2mb limiation of WebView2 * SvgPreviewControl: Introduce SvgPreviewColorMode enumeration instead of using magic values * SvgPreviewControl: Add additional checkered pattern shades * SvgPreviewControl: Use newly introduced enums as default values
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Settings.UI.Library.Enumerations
|
||||
{
|
||||
public enum SvgPreviewCheckeredShade
|
||||
{
|
||||
Light,
|
||||
Medium,
|
||||
Dark,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Settings.UI.Library.Enumerations
|
||||
{
|
||||
public enum SvgPreviewColorMode
|
||||
{
|
||||
Default,
|
||||
SolidColor,
|
||||
Checkered,
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.PowerToys.Settings.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Settings.UI.Library.Enumerations;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
@@ -14,6 +15,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
public const string DefaultStlThumbnailColor = "#FFC924";
|
||||
public const int DefaultMonacoMaxFileSize = 50;
|
||||
public const int DefaultSvgBackgroundColorMode = (int)SvgPreviewColorMode.Default;
|
||||
public const string DefaultSvgBackgroundSolidColor = "#FFFFFF";
|
||||
public const int DefaultSvgBackgroundCheckeredShade = (int)SvgPreviewCheckeredShade.Light;
|
||||
|
||||
private bool enableSvgPreview = true;
|
||||
|
||||
@@ -32,6 +36,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
}
|
||||
}
|
||||
|
||||
[JsonPropertyName("svg-previewer-background-color-mode")]
|
||||
public IntProperty SvgBackgroundColorMode { get; set; }
|
||||
|
||||
[JsonPropertyName("svg-previewer-background-solid-color")]
|
||||
public StringProperty SvgBackgroundSolidColor { get; set; }
|
||||
|
||||
[JsonPropertyName("svg-previewer-background-checkered-shade")]
|
||||
public IntProperty SvgBackgroundCheckeredShade { get; set; }
|
||||
|
||||
private bool enableSvgThumbnail = true;
|
||||
|
||||
[JsonPropertyName("svg-thumbnail-toggle-setting")]
|
||||
@@ -210,6 +223,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
|
||||
public PowerPreviewProperties()
|
||||
{
|
||||
SvgBackgroundColorMode = new IntProperty(DefaultSvgBackgroundColorMode);
|
||||
SvgBackgroundSolidColor = new StringProperty(DefaultSvgBackgroundSolidColor);
|
||||
SvgBackgroundCheckeredShade = new IntProperty(DefaultSvgBackgroundCheckeredShade);
|
||||
StlThumbnailColor = new StringProperty(DefaultStlThumbnailColor);
|
||||
MonacoPreviewMaxFileSize = new IntProperty(DefaultMonacoMaxFileSize);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user