PowerToys/src/settings-ui/Settings.UI.Library/EnabledModules.cs
Jaime Bernardo 21fd5092b3
[New utility]Sysinternals ZoomIt (#35880)
* ZoomIt initial code dump

* Change vcxproj to normalize dependency versions

* Fix code quality to build

* Add to PowerToys solution

* Clean out C-style casts

* Fix some more analyzer errors

* Constexpr a function

* Disable some warnings locally that it seemed better not to touch

* Add ZoomIt module interface

* Add GPO

* Add Settings page with Enable button

* Output as PowerToys.ZoomIt.exe

* Extract ZoomIt Settings definition to its own header

* Make ZoomItModuleInterface build with ZoomItSettings too

* WinRT C++ interop for ZoomItSettings

* From Registry To PowerToys Json

* Properly fix const_cast analyzer error

* Initial Settings page loading from registry

* Zoom mode settings

* Save settings

* Add file picker and DemoType file support

* Remaining DemoType settings

* Have ZoomIt properly reloading Settings and exiting

* Remove context menu entries for Options and Exit

* ZoomIt simple Break Options

* Break advanced options

* Simple Record settings

* Record Microphone setting

* Fix break background file picker title

* Font setting

* Fix build issues after merge

* Add ZoomIt conflict warning to Settings

* Exclude Eula from spell checking

* Fix spellcheck errors

* Fix spell check for accelerated menu items

* Remove cursor files from spellcheck. They're binary

* Fix forbidden patterns

* Fix XAML style

* Fix C# analyzers

* Fix signing

* Also sign module interface dll

* Use actual ZoomIt icon

* Add OOBE page for ZoomIt

* ZoomIt image for Settings

* Flyout and Dashboard entries

* Fix type speed slider labels

* Correctly load default Font

* Correctly register shortcuts on ZoomIt startup first run

* Fix modifier keys not changing until restart

* Show MsgBox on taken shortcut

* Start PowerToys Settings

* Normalize ZoomIt file properties with rest of PowerToys

* Add attribution

* Add ZoomIt team to Community.md

* More copyright adjustments

* Fix spellcheck

* Fix MsgBox simultaneous instance to the front

* Add mention of capturevideosample code use

* Add ZoomIt to process lists

* Add telemetry

* Add logging

* React to gpo

* Normalize code to space identation

* Fix installer build

* Localize percent setting

* Fix XAML styling

* Update src/settings-ui/Settings.UI/Strings/en-us/Resources.resw

Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>

* Fix spellcheck

* One more spellcheck fix

* Integrate LiveDraw feature changes from upstream

* Fix name reuse in same scope

* Fix c-style casts

* Also register LIVEDRAW_HOTKEY

* Fix newLiveZoomToggleKey

* Update LiveZoom description in Settings to take LiveDraw into account

* Fix spellcheck

* Fix more spellcheck

* Fix Sysinternals capitalization

* Fix ARM64 Debug build

* Support Sysinternals build (#36873)

* Remove unneeded files

* Make build compatible with Sysinternals

* Separate PowerToys ZoomIt product name (#36887)

* Separate PowerToys ZoomIt product name

To help maintain the Sysinternals branding in the standalone version.

* Clarify branding-related includes

* Remove ZoomIt.sln

* Add foxmsft to spell-check names

* Add ZoomIt to README

* Add ZoomIt to GH templates

* Add ZoomIt events to DATA_AND_PRIVACY.md

* Remove publish_config.json

* Remove publish_config.json from vcxproj too

---------

Co-authored-by: Mark Russinovich <markruss@microsoft.com>
Co-authored-by: Alex Mihaiuc <69110671+foxmsft@users.noreply.github.com>
Co-authored-by: John Stephens <johnstep@microsoft.com>
Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
2025-01-16 20:52:24 +00:00

526 lines
13 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;
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
{
public class EnabledModules
{
private Action notifyEnabledChangedAction;
// Default values for enabled modules should match their expected "enabled by default" values.
// Otherwise, a run of DSC on clean settings will not match the expected default result.
public EnabledModules()
{
}
private bool fancyZones = true;
[JsonPropertyName("FancyZones")]
public bool FancyZones
{
get => fancyZones;
set
{
if (fancyZones != value)
{
LogTelemetryEvent(value);
fancyZones = value;
NotifyChange();
}
}
}
private bool imageResizer = true;
[JsonPropertyName("Image Resizer")]
public bool ImageResizer
{
get => imageResizer;
set
{
if (imageResizer != value)
{
LogTelemetryEvent(value);
imageResizer = value;
}
}
}
private bool fileExplorerPreview = true;
[JsonPropertyName("File Explorer Preview")]
public bool PowerPreview
{
get => fileExplorerPreview;
set
{
if (fileExplorerPreview != value)
{
LogTelemetryEvent(value);
fileExplorerPreview = value;
}
}
}
private bool shortcutGuide = true;
[JsonPropertyName("Shortcut Guide")]
public bool ShortcutGuide
{
get => shortcutGuide;
set
{
if (shortcutGuide != value)
{
LogTelemetryEvent(value);
shortcutGuide = value;
NotifyChange();
}
}
}
private bool powerRename = true;
public bool PowerRename
{
get => powerRename;
set
{
if (powerRename != value)
{
LogTelemetryEvent(value);
powerRename = value;
}
}
}
private bool keyboardManager; // defaulting to off
[JsonPropertyName("Keyboard Manager")]
public bool KeyboardManager
{
get => keyboardManager;
set
{
if (keyboardManager != value)
{
LogTelemetryEvent(value);
keyboardManager = value;
}
}
}
private bool powerLauncher = true;
[JsonPropertyName("PowerToys Run")]
public bool PowerLauncher
{
get => powerLauncher;
set
{
if (powerLauncher != value)
{
LogTelemetryEvent(value);
powerLauncher = value;
NotifyChange();
}
}
}
private bool colorPicker = true;
[JsonPropertyName("ColorPicker")]
public bool ColorPicker
{
get => colorPicker;
set
{
if (colorPicker != value)
{
LogTelemetryEvent(value);
colorPicker = value;
NotifyChange();
}
}
}
private bool cropAndLock = true;
[JsonPropertyName("CropAndLock")]
public bool CropAndLock
{
get => cropAndLock;
set
{
if (cropAndLock != value)
{
LogTelemetryEvent(value);
cropAndLock = value;
NotifyChange();
}
}
}
private bool awake = true;
[JsonPropertyName("Awake")]
public bool Awake
{
get => awake;
set
{
if (awake != value)
{
LogTelemetryEvent(value);
awake = value;
}
}
}
private bool mouseWithoutBorders; // defaulting to off
[JsonPropertyName("MouseWithoutBorders")]
public bool MouseWithoutBorders
{
get => mouseWithoutBorders;
set
{
if (mouseWithoutBorders != value)
{
LogTelemetryEvent(value);
mouseWithoutBorders = value;
}
}
}
private bool findMyMouse = true;
[JsonPropertyName("FindMyMouse")]
public bool FindMyMouse
{
get => findMyMouse;
set
{
if (findMyMouse != value)
{
LogTelemetryEvent(value);
findMyMouse = value;
}
}
}
private bool mouseHighlighter = true;
[JsonPropertyName("MouseHighlighter")]
public bool MouseHighlighter
{
get => mouseHighlighter;
set
{
if (mouseHighlighter != value)
{
LogTelemetryEvent(value);
mouseHighlighter = value;
}
}
}
private bool mouseJump; // defaulting to off
[JsonPropertyName("MouseJump")]
public bool MouseJump
{
get => mouseJump;
set
{
if (mouseJump != value)
{
LogTelemetryEvent(value);
mouseJump = value;
}
}
}
private bool alwaysOnTop = true;
[JsonPropertyName("AlwaysOnTop")]
public bool AlwaysOnTop
{
get => alwaysOnTop;
set
{
if (alwaysOnTop != value)
{
LogTelemetryEvent(value);
alwaysOnTop = value;
}
}
}
private bool mousePointerCrosshairs; // defaulting to off
[JsonPropertyName("MousePointerCrosshairs")]
public bool MousePointerCrosshairs
{
get => mousePointerCrosshairs;
set
{
if (mousePointerCrosshairs != value)
{
LogTelemetryEvent(value);
mousePointerCrosshairs = value;
}
}
}
private bool powerAccent; // defaulting to off
[JsonPropertyName("QuickAccent")]
public bool PowerAccent
{
get => powerAccent;
set
{
if (powerAccent != value)
{
LogTelemetryEvent(value);
powerAccent = value;
}
}
}
private bool powerOCR; // defaulting to off
[JsonPropertyName("TextExtractor")]
public bool PowerOcr
{
get => powerOCR;
set
{
if (powerOCR != value)
{
LogTelemetryEvent(value);
powerOCR = value;
NotifyChange();
}
}
}
private bool advancedPaste = true;
[JsonPropertyName("AdvancedPaste")]
public bool AdvancedPaste
{
get => advancedPaste;
set
{
if (advancedPaste != value)
{
LogTelemetryEvent(value);
advancedPaste = value;
NotifyChange();
}
}
}
private bool measureTool = true;
[JsonPropertyName("Measure Tool")]
public bool MeasureTool
{
get => measureTool;
set
{
if (measureTool != value)
{
LogTelemetryEvent(value);
measureTool = value;
NotifyChange();
}
}
}
private bool hosts = true;
[JsonPropertyName("Hosts")]
public bool Hosts
{
get => hosts;
set
{
if (hosts != value)
{
LogTelemetryEvent(value);
hosts = value;
NotifyChange();
}
}
}
private bool fileLocksmith = true;
[JsonPropertyName("File Locksmith")]
public bool FileLocksmith
{
get => fileLocksmith;
set
{
if (fileLocksmith != value)
{
LogTelemetryEvent(value);
fileLocksmith = value;
}
}
}
private bool peek = true;
[JsonPropertyName("Peek")]
public bool Peek
{
get => peek;
set
{
if (peek != value)
{
LogTelemetryEvent(value);
peek = value;
}
}
}
private bool registryPreview = true;
[JsonPropertyName("RegistryPreview")]
public bool RegistryPreview
{
get => registryPreview;
set
{
if (registryPreview != value)
{
LogTelemetryEvent(value);
registryPreview = value;
}
}
}
private bool cmdNotFound = true;
[JsonPropertyName("CmdNotFound")]
public bool CmdNotFound
{
get => cmdNotFound;
set
{
if (cmdNotFound != value)
{
LogTelemetryEvent(value);
cmdNotFound = value;
NotifyChange();
}
}
}
private bool environmentVariables = true;
[JsonPropertyName("EnvironmentVariables")]
public bool EnvironmentVariables
{
get => environmentVariables;
set
{
if (environmentVariables != value)
{
LogTelemetryEvent(value);
environmentVariables = value;
}
}
}
private bool newPlus;
[JsonPropertyName("NewPlus")] // This key must match newplus::constants::non_localizable
public bool NewPlus
{
get => newPlus;
set
{
if (newPlus != value)
{
LogTelemetryEvent(value);
newPlus = value;
}
}
}
private bool workspaces = true;
[JsonPropertyName("Workspaces")]
public bool Workspaces
{
get => workspaces;
set
{
if (workspaces != value)
{
LogTelemetryEvent(value);
workspaces = value;
NotifyChange();
}
}
}
private bool zoomIt;
[JsonPropertyName("ZoomIt")]
public bool ZoomIt
{
get => zoomIt;
set
{
if (zoomIt != value)
{
LogTelemetryEvent(value);
zoomIt = value;
NotifyChange();
}
}
}
private void NotifyChange()
{
notifyEnabledChangedAction?.Invoke();
}
public string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
private static void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null)
{
var dataEvent = new SettingsEnabledEvent()
{
Value = value,
Name = moduleName,
};
PowerToysTelemetry.Log.WriteEvent(dataEvent);
}
internal void AddEnabledModuleChangeNotification(Action callBack)
{
notifyEnabledChangedAction = callBack;
}
}
}