[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

@@ -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()

View File

@@ -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;

View File

@@ -684,6 +684,9 @@
<value>.stl</value>
<comment>File extension, should not be altered</comment>
</data>
<data name="FileExplorerPreview_Color_Thumbnail_STL.Header" xml:space="preserve">
<value>Color</value>
</data>
<data name="FileExplorerPreview_ToggleSwitch_Thumbnail_PDF.Header" xml:space="preserve">
<value>Portable Document Format</value>
<comment>File type, do not translate</comment>

View File

@@ -110,14 +110,29 @@
</controls:Setting.ActionContent>
</controls:Setting>
<controls:Setting x:Uid="FileExplorerPreview_ToggleSwitch_Thumbnail_STL" Icon="&#xE914;">
<controls:Setting.ActionContent>
<ToggleSwitch IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.STLThumbnailIsEnabled}"
x:Uid="ToggleSwitch"/>
</controls:Setting.ActionContent>
</controls:Setting>
<controls:SettingExpander IsExpanded="False">
<controls:SettingExpander.Header>
<controls:Setting x:Uid="FileExplorerPreview_ToggleSwitch_Thumbnail_STL" Icon="&#xE914;">
<controls:Setting.ActionContent>
<ToggleSwitch IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.STLThumbnailIsEnabled}"
x:Uid="ToggleSwitch"/>
</controls:Setting.ActionContent>
</controls:Setting>
</controls:SettingExpander.Header>
<controls:SettingExpander.Content>
<StackPanel>
<controls:Setting x:Uid="FileExplorerPreview_Color_Thumbnail_STL" Style="{StaticResource ExpanderContentSettingStyle}">
<controls:Setting.ActionContent>
<controls:ColorPickerButton SelectedColor="{x:Bind Path=ViewModel.STLThumbnailColor, Mode=TwoWay}"
IsEnabled="{x:Bind ViewModel.STLThumbnailIsEnabled, Mode=OneWay}"/>
</controls:Setting.ActionContent>
</controls:Setting>
</StackPanel>
</controls:SettingExpander.Content>
</controls:SettingExpander>
</controls:SettingsGroup>
</StackPanel>
</controls:SettingsPageControl.ModuleContent>