mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
[FileExplorer]Stl Thumbnails color customization (#19928)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user