PowerToys/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs

162 lines
4.1 KiB
C#
Raw Normal View History

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