PowerToys/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/EnabledModules.cs

162 lines
3.9 KiB
C#
Raw Normal View History

2020-08-18 01:00:56 +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.
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.PowerToys.Settings.Telemetry;
using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerToys.Settings.UI.Library
2020-08-18 01:00:56 +08:00
{
public class EnabledModules
{
public EnabledModules()
{
}
private bool fancyZones = true;
[JsonPropertyName("FancyZones")]
public bool FancyZones
2020-04-17 02:45:27 +08:00
{
get => fancyZones;
set
{
if (fancyZones != value)
{
LogTelemetryEvent(value);
fancyZones = value;
}
}
2020-04-17 02:45:27 +08:00
}
private bool imageResizer = true;
2020-04-17 02:45:27 +08:00
[JsonPropertyName("Image Resizer")]
public bool ImageResizer
{
get => imageResizer;
set
{
if (imageResizer != value)
{
LogTelemetryEvent(value);
imageResizer = value;
}
}
}
private bool fileExplorerPreview = true;
2020-04-17 02:45:27 +08:00
[JsonPropertyName("File Explorer Preview")]
public bool FileExplorerPreview
{
get => fileExplorerPreview;
set
{
if (fileExplorerPreview != value)
{
LogTelemetryEvent(value);
fileExplorerPreview = value;
}
}
}
private bool shortcutGuide = true;
2020-04-17 02:45:27 +08:00
[JsonPropertyName("Shortcut Guide")]
public bool ShortcutGuide
{
get => shortcutGuide;
set
{
if (shortcutGuide != value)
{
LogTelemetryEvent(value);
shortcutGuide = value;
}
}
}
2020-04-17 02:45:27 +08:00
private bool powerRename = true;
2020-04-20 21:03:26 +08:00
public bool PowerRename
{
get => powerRename;
set
{
if (powerRename != value)
{
LogTelemetryEvent(value);
powerRename = value;
}
}
}
private bool keyboardManager = true;
2020-08-18 01:00:56 +08:00
[JsonPropertyName("Keyboard Manager")]
public bool KeyboardManager
2020-04-20 21:03:26 +08:00
{
get => keyboardManager;
set
{
if (keyboardManager != value)
{
LogTelemetryEvent(value);
keyboardManager = value;
}
}
2020-04-20 21:03:26 +08:00
}
private bool powerLauncher = true;
[JsonPropertyName("PowerToys Run")]
public bool PowerLauncher
{
get => powerLauncher;
set
{
if (powerLauncher != value)
{
LogTelemetryEvent(value);
powerLauncher = value;
}
2020-08-18 01:00:56 +08:00
}
}
private bool colorPicker = true;
[JsonPropertyName("ColorPicker")]
2020-08-18 01:00:56 +08:00
public bool ColorPicker
{
get => colorPicker;
2020-08-18 01:00:56 +08:00
set
{
if (colorPicker != value)
2020-08-18 01:00:56 +08:00
{
LogTelemetryEvent(value);
colorPicker = value;
2020-08-18 01:00:56 +08:00
}
}
}
public string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
private static void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null)
2020-08-18 01:00:56 +08:00
{
var dataEvent = new SettingsEnabledEvent()
{
Value = value,
Name = moduleName,
};
PowerToysTelemetry.Log.WriteEvent(dataEvent);
}
2020-08-18 01:00:56 +08:00
}
}