diff --git a/src/modules/previewpane/StlThumbnailProvider/StlThumbnailProvider.cs b/src/modules/previewpane/StlThumbnailProvider/StlThumbnailProvider.cs
index ca3d7dcffb..f79812bb9a 100644
--- a/src/modules/previewpane/StlThumbnailProvider/StlThumbnailProvider.cs
+++ b/src/modules/previewpane/StlThumbnailProvider/StlThumbnailProvider.cs
@@ -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
}
}
}
+
+ ///
+ /// Gets a value indicating what color to use.
+ ///
+ public static Color DefaultMaterialColor
+ {
+ get
+ {
+ try
+ {
+ var moduleSettings = new SettingsUtils();
+
+ var colorString = moduleSettings.GetSettings(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);
+ }
+ }
+ }
}
}
diff --git a/src/modules/previewpane/StlThumbnailProvider/StlThumbnailProvider.csproj b/src/modules/previewpane/StlThumbnailProvider/StlThumbnailProvider.csproj
index 4aacbe8090..2e22e631be 100644
--- a/src/modules/previewpane/StlThumbnailProvider/StlThumbnailProvider.csproj
+++ b/src/modules/previewpane/StlThumbnailProvider/StlThumbnailProvider.csproj
@@ -26,5 +26,6 @@
+
\ No newline at end of file
diff --git a/src/settings-ui/Settings.UI.Library/PowerPreviewProperties.cs b/src/settings-ui/Settings.UI.Library/PowerPreviewProperties.cs
index 004c34af03..67cb96ae34 100644
--- a/src/settings-ui/Settings.UI.Library/PowerPreviewProperties.cs
+++ b/src/settings-ui/Settings.UI.Library/PowerPreviewProperties.cs
@@ -12,6 +12,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library
{
public class PowerPreviewProperties
{
+ public const string DefaultStlThumbnailColor = "#FFC924";
+
private bool enableSvgPreview = true;
[JsonPropertyName("svg-previewer-toggle-setting")]
@@ -182,8 +184,12 @@ namespace Microsoft.PowerToys.Settings.UI.Library
}
}
+ [JsonPropertyName("stl-thumbnail-color-setting")]
+ public StringProperty StlThumbnailColor { get; set; }
+
public PowerPreviewProperties()
{
+ StlThumbnailColor = new StringProperty(DefaultStlThumbnailColor);
}
public override string ToString()
diff --git a/src/settings-ui/Settings.UI.Library/ViewModels/PowerPreviewViewModel.cs b/src/settings-ui/Settings.UI.Library/ViewModels/PowerPreviewViewModel.cs
index 17ec7e6bab..7e4833dfcc 100644
--- a/src/settings-ui/Settings.UI.Library/ViewModels/PowerPreviewViewModel.cs
+++ b/src/settings-ui/Settings.UI.Library/ViewModels/PowerPreviewViewModel.cs
@@ -56,6 +56,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
_pdfThumbnailIsEnabled = Settings.Properties.EnablePdfThumbnail;
_gcodeThumbnailIsEnabled = Settings.Properties.EnableGcodeThumbnail;
_stlThumbnailIsEnabled = Settings.Properties.EnableStlThumbnail;
+ _stlThumbnailColor = Settings.Properties.StlThumbnailColor.Value;
}
private bool _svgRenderIsEnabled;
@@ -68,6 +69,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private bool _pdfThumbnailIsEnabled;
private bool _gcodeThumbnailIsEnabled;
private bool _stlThumbnailIsEnabled;
+ private string _stlThumbnailColor;
public bool SVGRenderIsEnabled
{
@@ -249,6 +251,24 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
+ public string STLThumbnailColor
+ {
+ get
+ {
+ return _stlThumbnailColor;
+ }
+
+ set
+ {
+ if (value != _stlThumbnailColor)
+ {
+ _stlThumbnailColor = value;
+ Settings.Properties.StlThumbnailColor.Value = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
public string GetSettingsSubPath()
{
return _settingsConfigFileFolder + "\\" + ModuleName;
diff --git a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
index c7fd6dd149..04ecd5fc6d 100644
--- a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
+++ b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
@@ -684,6 +684,9 @@
.stl
File extension, should not be altered
+
+ Color
+
Portable Document Format
File type, do not translate
diff --git a/src/settings-ui/Settings.UI/Views/PowerPreviewPage.xaml b/src/settings-ui/Settings.UI/Views/PowerPreviewPage.xaml
index 7832849103..93b82a92d2 100644
--- a/src/settings-ui/Settings.UI/Views/PowerPreviewPage.xaml
+++ b/src/settings-ui/Settings.UI/Views/PowerPreviewPage.xaml
@@ -110,14 +110,29 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+