mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +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:
74
src/modules/previewpane/SvgPreviewHandler/Settings.cs
Normal file
74
src/modules/previewpane/SvgPreviewHandler/Settings.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
// 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.
|
||||
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
|
||||
namespace SvgPreviewHandler
|
||||
{
|
||||
internal sealed class Settings
|
||||
{
|
||||
private static readonly SettingsUtils ModuleSettings = new SettingsUtils();
|
||||
|
||||
public int ColorMode
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return ModuleSettings.GetSettings<PowerPreviewSettings>(PowerPreviewSettings.ModuleName).Properties.SvgBackgroundColorMode.Value;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
return PowerPreviewProperties.DefaultSvgBackgroundColorMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Color SolidColor
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
var colorString = ModuleSettings.GetSettings<PowerPreviewSettings>(PowerPreviewSettings.ModuleName).Properties.SvgBackgroundSolidColor.Value;
|
||||
return ColorTranslator.FromHtml(colorString);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
return ColorTranslator.FromHtml(PowerPreviewProperties.DefaultSvgBackgroundSolidColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Color ThemeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Common.UI.ThemeManager.GetWindowsBaseColor().ToLowerInvariant() == "dark")
|
||||
{
|
||||
return ColorTranslator.FromHtml("#1e1e1e");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Color.White;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int CheckeredShade
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return ModuleSettings.GetSettings<PowerPreviewSettings>(PowerPreviewSettings.ModuleName).Properties.SvgBackgroundCheckeredShade.Value;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
return PowerPreviewProperties.DefaultSvgBackgroundCheckeredShade;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user