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