mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Move Settings deep link logic to Microsoft.PowerToys.Common.UI (#13749)
* Move Settings deep link logic to Microsoft.PowerToys.Common.UI * Spellcheck * Introduce enum * Remove PT path arg
This commit is contained in:
1
.github/actions/spell-check/expect.txt
vendored
1
.github/actions/spell-check/expect.txt
vendored
@@ -2009,6 +2009,7 @@ stdlib
|
|||||||
STDMETHODCALLTYPE
|
STDMETHODCALLTYPE
|
||||||
STDMETHODIMP
|
STDMETHODIMP
|
||||||
stdout
|
stdout
|
||||||
|
stefan
|
||||||
STEPIT
|
STEPIT
|
||||||
stgm
|
stgm
|
||||||
STGMEDIUM
|
STGMEDIUM
|
||||||
|
|||||||
74
src/common/Microsoft.PowerToys.Common.UI/SettingsDeepLink.cs
Normal file
74
src/common/Microsoft.PowerToys.Common.UI/SettingsDeepLink.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
// 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.Diagnostics;
|
||||||
|
|
||||||
|
namespace Microsoft.PowerToys.Common.UI
|
||||||
|
{
|
||||||
|
public static class SettingsDeepLink
|
||||||
|
{
|
||||||
|
public enum SettingsWindow
|
||||||
|
{
|
||||||
|
Overview = 0,
|
||||||
|
Awake,
|
||||||
|
ColorPicker,
|
||||||
|
FancyZones,
|
||||||
|
Run,
|
||||||
|
ImageResizer,
|
||||||
|
KBM,
|
||||||
|
PowerRename,
|
||||||
|
FileExplorer,
|
||||||
|
ShortcutGuide,
|
||||||
|
VideoConference,
|
||||||
|
}
|
||||||
|
|
||||||
|
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.PowerRename:
|
||||||
|
return "PowerRename";
|
||||||
|
case SettingsWindow.FileExplorer:
|
||||||
|
return "FileExplorer";
|
||||||
|
case SettingsWindow.ShortcutGuide:
|
||||||
|
return "ShortcutGuide";
|
||||||
|
case SettingsWindow.VideoConference:
|
||||||
|
return "VideoConference";
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OpenSettings(SettingsWindow window)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo(Environment.CurrentDirectory + "\\PowerToys.exe") { Arguments = "--open-settings=" + SettingsWindowNameToString(window) });
|
||||||
|
}
|
||||||
|
#pragma warning disable CA1031 // Do not catch general exception types
|
||||||
|
catch
|
||||||
|
#pragma warning restore CA1031 // Do not catch general exception types
|
||||||
|
{
|
||||||
|
// TODO(stefan): Log exception once unified logging is implemented
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,11 +4,10 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using ColorPicker.Settings;
|
using ColorPicker.Settings;
|
||||||
using ColorPicker.ViewModelContracts;
|
using ColorPicker.ViewModelContracts;
|
||||||
|
using Microsoft.PowerToys.Common.UI;
|
||||||
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
|
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
|
||||||
|
|
||||||
namespace ColorPicker.Helpers
|
namespace ColorPicker.Helpers
|
||||||
@@ -189,17 +188,7 @@ namespace ColorPicker.Helpers
|
|||||||
|
|
||||||
private void ColorEditorViewModel_OpenSettingsRequested(object sender, EventArgs e)
|
private void ColorEditorViewModel_OpenSettingsRequested(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
SettingsDeepLink.OpenSettings(SettingsDeepLink.SettingsWindow.ColorPicker);
|
||||||
{
|
|
||||||
var assemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
|
||||||
var fullPath = Directory.GetParent(assemblyPath).FullName;
|
|
||||||
Process.Start(new ProcessStartInfo(fullPath + "\\..\\PowerToys.exe") { Arguments = "--open-settings=ColorPicker" });
|
|
||||||
}
|
|
||||||
#pragma warning disable CA1031 // Do not catch general exception types
|
|
||||||
catch
|
|
||||||
#pragma warning restore CA1031 // Do not catch general exception types
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using System.Windows.Controls;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using FancyZonesEditor.Models;
|
using FancyZonesEditor.Models;
|
||||||
using FancyZonesEditor.Utils;
|
using FancyZonesEditor.Utils;
|
||||||
|
using Microsoft.PowerToys.Common.UI;
|
||||||
using ModernWpf.Controls;
|
using ModernWpf.Controls;
|
||||||
|
|
||||||
namespace FancyZonesEditor
|
namespace FancyZonesEditor
|
||||||
@@ -521,15 +522,7 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
private void SettingsBtn_Click(object sender, RoutedEventArgs e)
|
private void SettingsBtn_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
SettingsDeepLink.OpenSettings(SettingsDeepLink.SettingsWindow.FancyZones);
|
||||||
{
|
|
||||||
var assemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
|
||||||
var fullPath = Directory.GetParent(assemblyPath).FullName;
|
|
||||||
Process.Start(new ProcessStartInfo(fullPath + "\\..\\PowerToys.exe") { Arguments = "--open-settings=FancyZones" });
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user