mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 02:06:36 +02:00
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [X] **Closes:** #30352 - [X] **Communication:** I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected - [X] **Tests:** Added/updated and all pass - [X] **Localization:** All end user facing strings can be localized - [ ] **Dev docs:** Added/updated - [X] **New binaries:** Added on the required places - [X] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [X] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments   <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed - Close PowerToys if installed in your machine - Full build the solution: PowerToys.sln - Start PowerToys from PowerToys\x64\Debug\PowerToys.exe or PowerToys\x64\Release\PowerToys.exe - Toggle the "Binary G-code thumbnail previewer" setting to enable - Open HelperFiles folder on the tests and check if the icon changes to an image - Check explorer preview to see if image is also shown there --------- Co-authored-by: leileizhang <leilzh@microsoft.com>
357 lines
11 KiB
C#
357 lines
11 KiB
C#
// 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 System.Runtime.CompilerServices;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
using Microsoft.PowerToys.Settings.Telemetry;
|
|
using Microsoft.PowerToys.Telemetry;
|
|
using Settings.UI.Library.Enumerations;
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Library
|
|
{
|
|
public class PowerPreviewProperties
|
|
{
|
|
public const string DefaultStlThumbnailColor = "#FFC924";
|
|
public const int DefaultMonacoMaxFileSize = 50;
|
|
public const int DefaultMonacoFontSize = 14;
|
|
public const int DefaultSvgBackgroundColorMode = (int)SvgPreviewColorMode.Default;
|
|
public const string DefaultSvgBackgroundSolidColor = "#FFFFFF";
|
|
public const int DefaultSvgBackgroundCheckeredShade = (int)SvgPreviewCheckeredShade.Light;
|
|
|
|
private bool enableSvgPreview = true;
|
|
|
|
[JsonPropertyName("svg-previewer-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableSvgPreview
|
|
{
|
|
get => enableSvgPreview;
|
|
set
|
|
{
|
|
if (value != enableSvgPreview)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableSvgPreview = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
[JsonPropertyName("svg-previewer-background-color-mode")]
|
|
public IntProperty SvgBackgroundColorMode { get; set; }
|
|
|
|
[JsonPropertyName("svg-previewer-background-solid-color")]
|
|
public StringProperty SvgBackgroundSolidColor { get; set; }
|
|
|
|
[JsonPropertyName("svg-previewer-background-checkered-shade")]
|
|
public IntProperty SvgBackgroundCheckeredShade { get; set; }
|
|
|
|
private bool enableSvgThumbnail = true;
|
|
|
|
[JsonPropertyName("svg-thumbnail-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableSvgThumbnail
|
|
{
|
|
get => enableSvgThumbnail;
|
|
set
|
|
{
|
|
if (value != enableSvgThumbnail)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableSvgThumbnail = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool enableMdPreview = true;
|
|
|
|
[JsonPropertyName("md-previewer-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableMdPreview
|
|
{
|
|
get => enableMdPreview;
|
|
set
|
|
{
|
|
if (value != enableMdPreview)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableMdPreview = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool enableMonacoPreview = true;
|
|
|
|
[JsonPropertyName("monaco-previewer-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableMonacoPreview
|
|
{
|
|
get => enableMonacoPreview;
|
|
set
|
|
{
|
|
if (value != enableMonacoPreview)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableMonacoPreview = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool monacoPreviewWordWrap = true;
|
|
|
|
[JsonPropertyName("monaco-previewer-toggle-setting-word-wrap")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableMonacoPreviewWordWrap
|
|
{
|
|
get => monacoPreviewWordWrap;
|
|
set
|
|
{
|
|
if (value != monacoPreviewWordWrap)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
monacoPreviewWordWrap = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool monacoPreviewTryFormat;
|
|
|
|
[JsonPropertyName("monaco-previewer-toggle-try-format")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool MonacoPreviewTryFormat
|
|
{
|
|
get => monacoPreviewTryFormat;
|
|
set
|
|
{
|
|
if (value != monacoPreviewTryFormat)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
monacoPreviewTryFormat = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
[JsonPropertyName("monaco-previewer-max-file-size")]
|
|
public IntProperty MonacoPreviewMaxFileSize { get; set; }
|
|
|
|
[JsonPropertyName("monaco-previewer-font-size")]
|
|
public IntProperty MonacoPreviewFontSize { get; set; }
|
|
|
|
private bool monacoPreviewStickyScroll = true;
|
|
|
|
[JsonPropertyName("monaco-previewer-sticky-scroll")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool MonacoPreviewStickyScroll
|
|
{
|
|
get => monacoPreviewStickyScroll;
|
|
set
|
|
{
|
|
if (value != monacoPreviewStickyScroll)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
monacoPreviewStickyScroll = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool monacoPreviewMinimap;
|
|
|
|
[JsonPropertyName("monaco-previewer-minimap")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool MonacoPreviewMinimap
|
|
{
|
|
get => monacoPreviewMinimap;
|
|
set
|
|
{
|
|
if (value != monacoPreviewMinimap)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
monacoPreviewMinimap = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool enablePdfPreview;
|
|
|
|
[JsonPropertyName("pdf-previewer-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnablePdfPreview
|
|
{
|
|
get => enablePdfPreview;
|
|
set
|
|
{
|
|
if (value != enablePdfPreview)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enablePdfPreview = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool enablePdfThumbnail;
|
|
|
|
[JsonPropertyName("pdf-thumbnail-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnablePdfThumbnail
|
|
{
|
|
get => enablePdfThumbnail;
|
|
set
|
|
{
|
|
if (value != enablePdfThumbnail)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enablePdfThumbnail = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool enableGcodePreview = true;
|
|
|
|
[JsonPropertyName("gcode-previewer-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableGcodePreview
|
|
{
|
|
get => enableGcodePreview;
|
|
set
|
|
{
|
|
if (value != enableGcodePreview)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableGcodePreview = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool enableBgcodePreview = true;
|
|
|
|
[JsonPropertyName("bgcode-previewer-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableBgcodePreview
|
|
{
|
|
get => enableBgcodePreview;
|
|
set
|
|
{
|
|
if (value != enableBgcodePreview)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableBgcodePreview = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool enableGcodeThumbnail = true;
|
|
|
|
[JsonPropertyName("gcode-thumbnail-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableGcodeThumbnail
|
|
{
|
|
get => enableGcodeThumbnail;
|
|
set
|
|
{
|
|
if (value != enableGcodeThumbnail)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableGcodeThumbnail = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool enableBgcodeThumbnail = true;
|
|
|
|
[JsonPropertyName("bgcode-thumbnail-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableBgcodeThumbnail
|
|
{
|
|
get => enableBgcodeThumbnail;
|
|
set
|
|
{
|
|
if (value != enableBgcodeThumbnail)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableBgcodeThumbnail = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool enableStlThumbnail = true;
|
|
|
|
[JsonPropertyName("stl-thumbnail-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableStlThumbnail
|
|
{
|
|
get => enableStlThumbnail;
|
|
set
|
|
{
|
|
if (value != enableStlThumbnail)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableStlThumbnail = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
[JsonPropertyName("stl-thumbnail-color-setting")]
|
|
public StringProperty StlThumbnailColor { get; set; }
|
|
|
|
private bool enableQoiPreview = true;
|
|
|
|
[JsonPropertyName("qoi-previewer-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableQoiPreview
|
|
{
|
|
get => enableQoiPreview;
|
|
set
|
|
{
|
|
if (value != enableQoiPreview)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableQoiPreview = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool enableQoiThumbnail = true;
|
|
|
|
[JsonPropertyName("qoi-thumbnail-toggle-setting")]
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
public bool EnableQoiThumbnail
|
|
{
|
|
get => enableQoiThumbnail;
|
|
set
|
|
{
|
|
if (value != enableQoiThumbnail)
|
|
{
|
|
LogTelemetryEvent(value);
|
|
enableQoiThumbnail = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public PowerPreviewProperties()
|
|
{
|
|
SvgBackgroundColorMode = new IntProperty(DefaultSvgBackgroundColorMode);
|
|
SvgBackgroundSolidColor = new StringProperty(DefaultSvgBackgroundSolidColor);
|
|
SvgBackgroundCheckeredShade = new IntProperty(DefaultSvgBackgroundCheckeredShade);
|
|
StlThumbnailColor = new StringProperty(DefaultStlThumbnailColor);
|
|
MonacoPreviewMaxFileSize = new IntProperty(DefaultMonacoMaxFileSize);
|
|
MonacoPreviewFontSize = new IntProperty(DefaultMonacoFontSize);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return JsonSerializer.Serialize(this);
|
|
}
|
|
|
|
private static void LogTelemetryEvent(bool value, [CallerMemberName] string propertyName = null)
|
|
{
|
|
var dataEvent = new SettingsEnabledEvent()
|
|
{
|
|
Value = value,
|
|
Name = propertyName,
|
|
};
|
|
PowerToysTelemetry.Log.WriteEvent(dataEvent);
|
|
}
|
|
}
|
|
}
|