PowerToys/src/common/Common.UI/SettingsDeepLink.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

116 lines
4.0 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.Diagnostics;
using System.IO;
namespace Common.UI
{
public static class SettingsDeepLink
{
public enum SettingsWindow
{
Overview = 0,
Awake,
ColorPicker,
FancyZones,
Run,
ImageResizer,
KBM,
MouseUtils,
PowerRename,
FileExplorer,
ShortcutGuide,
Hosts,
MeasureTool,
PowerOCR,
RegistryPreview,
CropAndLock,
EnvironmentVariables,
Dashboard,
AdvancedPaste,
Workspaces,
ZoomIt,
}
private static string SettingsWindowNameToString(SettingsWindow value)
{
switch (value)
{
case SettingsWindow.Overview:
return "Overview";
case SettingsWindow.Awake:
return "Awake";
case SettingsWindow.ColorPicker:
return "ColorPicker";
case SettingsWindow.FancyZones:
return "FancyZones";
case SettingsWindow.Run:
return "Run";
case SettingsWindow.ImageResizer:
return "ImageResizer";
case SettingsWindow.KBM:
return "KBM";
case SettingsWindow.MouseUtils:
return "MouseUtils";
case SettingsWindow.PowerRename:
return "PowerRename";
case SettingsWindow.FileExplorer:
return "FileExplorer";
case SettingsWindow.ShortcutGuide:
return "ShortcutGuide";
case SettingsWindow.Hosts:
return "Hosts";
case SettingsWindow.MeasureTool:
return "MeasureTool";
case SettingsWindow.PowerOCR:
return "PowerOcr";
case SettingsWindow.RegistryPreview:
return "RegistryPreview";
case SettingsWindow.CropAndLock:
return "CropAndLock";
case SettingsWindow.EnvironmentVariables:
return "EnvironmentVariables";
case SettingsWindow.Dashboard:
return "Dashboard";
case SettingsWindow.AdvancedPaste:
return "AdvancedPaste";
case SettingsWindow.Workspaces:
return "Workspaces";
case SettingsWindow.ZoomIt:
return "ZoomIt";
default:
{
return string.Empty;
}
}
}
public static void OpenSettings(SettingsWindow window, bool mainExecutableIsOnTheParentFolder)
{
try
{
var assemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
var fullPath = new DirectoryInfo(assemblyPath).FullName;
if (mainExecutableIsOnTheParentFolder)
{
// Need to go into parent folder for PowerToys.exe. Likely a WinUI3 App SDK application.
fullPath = fullPath + "\\..\\PowerToys.exe";
}
else
{
// PowerToys.exe is in the same path as the application.
fullPath = fullPath + "\\PowerToys.exe";
}
Process.Start(new ProcessStartInfo(fullPath) { Arguments = "--open-settings=" + SettingsWindowNameToString(window) });
}
catch
{
// TODO(stefan): Log exception once unified logging is implemented
}
}
}
}