[FileExplorer]Stl Thumbnails color customization (#19928)

This commit is contained in:
Pedro Lamas
2022-08-23 21:45:27 +01:00
committed by GitHub
parent 5c431b5ac5
commit c26e23b904
6 changed files with 78 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ using System.Windows.Media.Media3D;
using Common.ComInterlop;
using Common.Utilities;
using HelixToolkit.Wpf;
using Microsoft.PowerToys.Settings.UI.Library;
using Bitmap = System.Drawing.Bitmap;
namespace Microsoft.PowerToys.ThumbnailHandler.Stl
@@ -50,7 +51,7 @@ namespace Microsoft.PowerToys.ThumbnailHandler.Stl
var stlReader = new StLReader
{
DefaultMaterial = new DiffuseMaterial(new SolidColorBrush(Color.FromRgb(255, 201, 36))),
DefaultMaterial = new DiffuseMaterial(new SolidColorBrush(DefaultMaterialColor)),
};
var model = stlReader.Read(stream);
@@ -141,5 +142,29 @@ namespace Microsoft.PowerToys.ThumbnailHandler.Stl
}
}
}
/// <summary>
/// Gets a value indicating what color to use.
/// </summary>
public static Color DefaultMaterialColor
{
get
{
try
{
var moduleSettings = new SettingsUtils();
var colorString = moduleSettings.GetSettings<PowerPreviewSettings>(PowerPreviewSettings.ModuleName).Properties.StlThumbnailColor.Value;
return (Color)ColorConverter.ConvertFromString(colorString);
}
catch (FileNotFoundException)
{
// Couldn't read the settings.
// Assume default color value.
return Color.FromRgb(255, 201, 36);
}
}
}
}
}