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:
Sebastian Zanoni
2023-04-21 18:54:57 +02:00
committed by GitHub
parent 3164e03ad4
commit 3a63a088ed
11 changed files with 328 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Settings.UI.Library.Enumerations;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
@@ -60,6 +61,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_svgRenderIsEnabled = Settings.Properties.EnableSvgPreview;
}
_svgBackgroundColorMode = Settings.Properties.SvgBackgroundColorMode.Value;
_svgBackgroundSolidColor = Settings.Properties.SvgBackgroundSolidColor.Value;
_svgBackgroundCheckeredShade = Settings.Properties.SvgBackgroundCheckeredShade.Value;
_svgThumbnailEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredSvgThumbnailsEnabledValue();
if (_svgThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _svgThumbnailEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled)
{
@@ -166,6 +171,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private GpoRuleConfigured _svgRenderEnabledGpoRuleConfiguration;
private bool _svgRenderEnabledStateIsGPOConfigured;
private bool _svgRenderIsEnabled;
private int _svgBackgroundColorMode;
private string _svgBackgroundSolidColor;
private int _svgBackgroundCheckeredShade;
private GpoRuleConfigured _mdRenderEnabledGpoRuleConfiguration;
private bool _mdRenderEnabledStateIsGPOConfigured;
@@ -227,6 +235,78 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
public int SVGRenderBackgroundColorMode
{
get
{
return _svgBackgroundColorMode;
}
set
{
if (value != _svgBackgroundColorMode)
{
_svgBackgroundColorMode = value;
Settings.Properties.SvgBackgroundColorMode.Value = value;
RaisePropertyChanged();
RaisePropertyChanged(nameof(IsSvgBackgroundColorVisible));
RaisePropertyChanged(nameof(IsSvgCheckeredShadeVisible));
}
}
}
public bool IsSvgBackgroundColorVisible
{
get
{
return (SvgPreviewColorMode)SVGRenderBackgroundColorMode == SvgPreviewColorMode.SolidColor;
}
}
public string SVGRenderBackgroundSolidColor
{
get
{
return _svgBackgroundSolidColor;
}
set
{
if (value != _svgBackgroundSolidColor)
{
_svgBackgroundSolidColor = value;
Settings.Properties.SvgBackgroundSolidColor = value;
RaisePropertyChanged();
}
}
}
public bool IsSvgCheckeredShadeVisible
{
get
{
return (SvgPreviewColorMode)SVGRenderBackgroundColorMode == SvgPreviewColorMode.Checkered;
}
}
public int SVGRenderBackgroundCheckeredShade
{
get
{
return _svgBackgroundCheckeredShade;
}
set
{
if (value != _svgBackgroundCheckeredShade)
{
_svgBackgroundCheckeredShade = value;
Settings.Properties.SvgBackgroundCheckeredShade.Value = value;
RaisePropertyChanged();
}
}
}
public bool IsSVGRenderEnabledGpoConfigured
{
get => _svgRenderEnabledStateIsGPOConfigured;