2020-04-08 01:19:14 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2020-08-18 01:00:56 +08:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2020-04-08 01:19:14 +08:00
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using System.Text.Json.Serialization;
|
2020-08-18 01:00:56 +08:00
|
|
|
|
using Microsoft.PowerToys.Settings.Telemetry;
|
|
|
|
|
using Microsoft.PowerToys.Telemetry;
|
2020-04-08 01:19:14 +08:00
|
|
|
|
|
2020-10-23 00:45:48 +08:00
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Library
|
2020-04-08 01:19:14 +08:00
|
|
|
|
{
|
|
|
|
|
public class PowerPreviewProperties
|
2020-08-18 01:00:56 +08:00
|
|
|
|
{
|
|
|
|
|
private bool enableSvgPreview = true;
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("svg-previewer-toggle-setting")]
|
|
|
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
|
|
|
public bool EnableSvgPreview
|
|
|
|
|
{
|
2020-08-20 06:59:10 +08:00
|
|
|
|
get => enableSvgPreview;
|
2020-08-18 01:00:56 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2020-08-20 06:59:10 +08:00
|
|
|
|
if (value != enableSvgPreview)
|
2020-08-18 01:00:56 +08:00
|
|
|
|
{
|
|
|
|
|
LogTelemetryEvent(value);
|
2020-08-20 06:59:10 +08:00
|
|
|
|
enableSvgPreview = value;
|
2020-08-18 01:00:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool enableSvgThumbnail = true;
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("svg-thumbnail-toggle-setting")]
|
|
|
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
|
|
|
public bool EnableSvgThumbnail
|
|
|
|
|
{
|
2020-08-20 06:59:10 +08:00
|
|
|
|
get => enableSvgThumbnail;
|
2020-08-18 01:00:56 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2020-08-20 06:59:10 +08:00
|
|
|
|
if (value != enableSvgThumbnail)
|
2020-08-18 01:00:56 +08:00
|
|
|
|
{
|
|
|
|
|
LogTelemetryEvent(value);
|
2020-08-20 06:59:10 +08:00
|
|
|
|
enableSvgThumbnail = value;
|
2020-08-18 01:00:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-09 07:12:37 +08:00
|
|
|
|
|
2020-07-22 07:27:12 +08:00
|
|
|
|
private bool enableMdPreview = true;
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
2020-05-03 18:17:06 +08:00
|
|
|
|
[JsonPropertyName("md-previewer-toggle-setting")]
|
2020-05-09 07:12:37 +08:00
|
|
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
2020-07-22 07:27:12 +08:00
|
|
|
|
public bool EnableMdPreview
|
2020-08-18 01:00:56 +08:00
|
|
|
|
{
|
2020-08-20 06:59:10 +08:00
|
|
|
|
get => enableMdPreview;
|
2020-08-18 01:00:56 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2020-08-20 06:59:10 +08:00
|
|
|
|
if (value != enableMdPreview)
|
2020-08-18 01:00:56 +08:00
|
|
|
|
{
|
|
|
|
|
LogTelemetryEvent(value);
|
2020-08-20 06:59:10 +08:00
|
|
|
|
enableMdPreview = value;
|
2020-08-18 01:00:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-09 07:12:37 +08:00
|
|
|
|
}
|
2020-04-08 01:19:14 +08:00
|
|
|
|
|
2022-01-26 04:02:10 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-26 01:29:33 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-27 05:43:26 +08:00
|
|
|
|
private bool enablePdfPreview = true;
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("pdf-previewer-toggle-setting")]
|
|
|
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
|
|
|
public bool EnablePdfPreview
|
|
|
|
|
{
|
|
|
|
|
get => enablePdfPreview;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != enablePdfPreview)
|
|
|
|
|
{
|
|
|
|
|
LogTelemetryEvent(value);
|
|
|
|
|
enablePdfPreview = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-15 00:01:45 +08:00
|
|
|
|
private bool enablePdfThumbnail = true;
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("pdf-thumbnail-toggle-setting")]
|
|
|
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
|
|
|
public bool EnablePdfThumbnail
|
|
|
|
|
{
|
|
|
|
|
get => enablePdfThumbnail;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != enablePdfThumbnail)
|
|
|
|
|
{
|
|
|
|
|
LogTelemetryEvent(value);
|
|
|
|
|
enablePdfThumbnail = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-10 19:53:01 +08:00
|
|
|
|
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 enableGcodeThumbnail = true;
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("gcode-thumbnail-toggle-setting")]
|
|
|
|
|
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
|
|
|
|
public bool EnableGcodeThumbnail
|
|
|
|
|
{
|
|
|
|
|
get => enableGcodeThumbnail;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != enableGcodeThumbnail)
|
|
|
|
|
{
|
|
|
|
|
LogTelemetryEvent(value);
|
|
|
|
|
enableGcodeThumbnail = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-25 19:51:37 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-08 01:19:14 +08:00
|
|
|
|
public PowerPreviewProperties()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return JsonSerializer.Serialize(this);
|
|
|
|
|
}
|
2020-05-09 07:12:37 +08:00
|
|
|
|
|
2020-10-10 08:58:52 +08:00
|
|
|
|
private static void LogTelemetryEvent(bool value, [CallerMemberName] string propertyName = null)
|
2020-05-09 07:12:37 +08:00
|
|
|
|
{
|
|
|
|
|
var dataEvent = new SettingsEnabledEvent()
|
|
|
|
|
{
|
|
|
|
|
Value = value,
|
|
|
|
|
Name = propertyName,
|
|
|
|
|
};
|
|
|
|
|
PowerToysTelemetry.Log.WriteEvent(dataEvent);
|
|
|
|
|
}
|
2020-04-08 01:19:14 +08:00
|
|
|
|
}
|
|
|
|
|
}
|