mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-15 07:40:18 +01:00
Compare commits
14 Commits
shawn/Sett
...
async-cpp-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43c89141a4 | ||
|
|
f2f17eb0f0 | ||
|
|
13cc6fd13e | ||
|
|
eedc6ceccc | ||
|
|
3b53810727 | ||
|
|
b1f933c0b3 | ||
|
|
876b03595f | ||
|
|
2f829a0a15 | ||
|
|
ac1a551605 | ||
|
|
9194bae1ee | ||
|
|
8f57522228 | ||
|
|
7578c77877 | ||
|
|
64ac14faa6 | ||
|
|
1a396dfd85 |
@@ -64,7 +64,6 @@
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<BuildStlModules>false</BuildStlModules>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<!-- TODO: _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING for compatibility with VS 17.8. Check if we can remove. -->
|
||||
<PreprocessorDefinitions>_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<!-- CLR + CFG are not compatible >:{ -->
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>inc;..\..\src\;..\..\src\common\Telemetry;telemetry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/await /Zc:twoPhase- /Wv:18 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions>/Zc:twoPhase- /Wv:18 %(AdditionalOptions)</AdditionalOptions>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
|
||||
@@ -57,7 +57,7 @@ std::optional<fs::path> ObtainInstaller(bool& isUpToDate)
|
||||
|
||||
auto state = UpdateState::read();
|
||||
|
||||
const auto new_version_info = get_github_version_info_async().get();
|
||||
const auto new_version_info = std::move(get_github_version_info_async()).get();
|
||||
if (std::holds_alternative<version_up_to_date>(*new_version_info))
|
||||
{
|
||||
isUpToDate = true;
|
||||
@@ -76,7 +76,7 @@ std::optional<fs::path> ObtainInstaller(bool& isUpToDate)
|
||||
// Cleanup old updates before downloading the latest
|
||||
updating::cleanup_updates();
|
||||
|
||||
auto downloaded_installer = download_new_version(std::get<new_version_download_info>(*new_version_info)).get();
|
||||
auto downloaded_installer = std::move(download_new_version_async(std::get<new_version_download_info>(*new_version_info))).get();
|
||||
if (!downloaded_installer)
|
||||
{
|
||||
Logger::error("Couldn't download new installer");
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace ManagedCommon
|
||||
{
|
||||
public static void WaitForPowerToysRunner(int powerToysPID, Action act, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "")
|
||||
{
|
||||
// AOT-compatible: Use GetExecutingAssembly instead of GetCallingAssembly (not supported in AOT)
|
||||
var assembly = Assembly.GetExecutingAssembly().GetName();
|
||||
var stackTrace = new StackTrace();
|
||||
var assembly = Assembly.GetCallingAssembly().GetName();
|
||||
PowerToysTelemetry.Log.WriteEvent(new DebugEvent() { Message = $"[{assembly}][{memberName}]WaitForPowerToysRunner waiting for Event powerToysPID={powerToysPID}" });
|
||||
Task.Run(() =>
|
||||
{
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace Microsoft.PowerToys.UITest
|
||||
Rectangle bounds = new Rectangle(0, 0, screenWidth, screenHeight);
|
||||
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format24bppRgb))
|
||||
{
|
||||
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap))
|
||||
using (Graphics g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
g.CopyFromScreen(bounds.Location, Point.Empty, bounds.Size);
|
||||
|
||||
|
||||
@@ -6,14 +6,11 @@
|
||||
<OutputType>Library</OutputType>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<!-- UITestAutomation is a test library and should not use AOT -->
|
||||
<PublishAot>false</PublishAot>
|
||||
<InvariantGlobalization>false</InvariantGlobalization>
|
||||
<PublishAot>true</PublishAot>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<PublishTrimmed>false</PublishTrimmed>
|
||||
<!-- Suppress code analysis warnings for test library -->
|
||||
<NoWarn>$(NoWarn);CA1305;CA1310;CA2101</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -22,7 +19,6 @@
|
||||
<PackageReference Include="System.IO.Abstractions" />
|
||||
<PackageReference Include="System.Text.RegularExpressions" />
|
||||
<PackageReference Include="CoenM.ImageSharp.ImageHash" />
|
||||
<PackageReference Include="System.Drawing.Common" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace // Strings in this namespace should not be localized
|
||||
|
||||
namespace updating
|
||||
{
|
||||
std::future<bool> uninstall_previous_msix_version_async()
|
||||
winrt::Windows::Foundation::IAsyncOperation<bool> uninstall_previous_msix_version_async()
|
||||
{
|
||||
winrt::Windows::Management::Deployment::PackageManager package_manager;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <future>
|
||||
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <common/version/helper.h>
|
||||
|
||||
namespace updating
|
||||
{
|
||||
std::future<bool> uninstall_previous_msix_version_async();
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<bool> uninstall_previous_msix_version_async();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <winrt/Windows.System.h>
|
||||
|
||||
#include <wil/resource.h>
|
||||
#include <wil/coroutine.h>
|
||||
|
||||
#endif //PCH_H
|
||||
|
||||
|
||||
@@ -82,11 +82,7 @@ namespace updating
|
||||
// prevent the warning that may show up depend on the value of the constants (#defines)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4702)
|
||||
#if USE_STD_EXPECTED
|
||||
std::future<std::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease)
|
||||
#else
|
||||
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease)
|
||||
#endif
|
||||
wil::task<github_version_result> get_github_version_info_async(const bool prerelease)
|
||||
{
|
||||
// If the current version starts with 0.0.*, it means we're on a local build from a farm and shouldn't check for updates.
|
||||
if constexpr (VERSION_MAJOR == 0 && VERSION_MINOR == 0)
|
||||
@@ -170,7 +166,7 @@ namespace updating
|
||||
return !ec ? std::optional{ installer_download_path } : std::nullopt;
|
||||
}
|
||||
|
||||
std::future<std::optional<std::filesystem::path>> download_new_version(const new_version_download_info& new_version)
|
||||
wil::task<std::optional<std::filesystem::path>> download_new_version_async(new_version_download_info new_version)
|
||||
{
|
||||
auto installer_download_path = create_download_path();
|
||||
if (!installer_download_path)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <future>
|
||||
#include <filesystem>
|
||||
#include <variant>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
@@ -16,6 +15,7 @@
|
||||
#endif
|
||||
|
||||
#include <common/version/helper.h>
|
||||
#include <wil/coroutine.h>
|
||||
|
||||
namespace updating
|
||||
{
|
||||
@@ -32,13 +32,15 @@ namespace updating
|
||||
};
|
||||
using github_version_info = std::variant<new_version_download_info, version_up_to_date>;
|
||||
|
||||
std::future<std::optional<std::filesystem::path>> download_new_version(const new_version_download_info& new_version);
|
||||
std::filesystem::path get_pending_updates_path();
|
||||
#if USE_STD_EXPECTED
|
||||
std::future<std::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease = false);
|
||||
using github_version_result = std::expected<github_version_info, std::wstring>;
|
||||
#else
|
||||
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease = false);
|
||||
using github_version_result = nonstd::expected<github_version_info, std::wstring>;
|
||||
#endif
|
||||
|
||||
wil::task<github_version_result> get_github_version_info_async(bool prerelease = false);
|
||||
wil::task<std::optional<std::filesystem::path>> download_new_version_async(new_version_download_info new_version);
|
||||
std::filesystem::path get_pending_updates_path();
|
||||
void cleanup_updates();
|
||||
|
||||
// non-localized
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <future>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Storage.Streams.h>
|
||||
#include <winrt/Windows.Web.Http.h>
|
||||
@@ -21,15 +22,15 @@ namespace http
|
||||
headers.UserAgent().TryParseAdd(USER_AGENT);
|
||||
}
|
||||
|
||||
std::future<std::wstring> request(const winrt::Windows::Foundation::Uri& url)
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> request(winrt::Windows::Foundation::Uri url)
|
||||
{
|
||||
auto response = co_await m_client.GetAsync(url);
|
||||
(void)response.EnsureSuccessStatusCode();
|
||||
auto body = co_await response.Content().ReadAsStringAsync();
|
||||
co_return std::wstring(body);
|
||||
co_return body;
|
||||
}
|
||||
|
||||
std::future<void> download(const winrt::Windows::Foundation::Uri& url, const std::wstring& dstFilePath)
|
||||
winrt::Windows::Foundation::IAsyncAction download(winrt::Windows::Foundation::Uri url, std::wstring dstFilePath)
|
||||
{
|
||||
auto response = co_await m_client.GetAsync(url);
|
||||
(void)response.EnsureSuccessStatusCode();
|
||||
@@ -38,7 +39,7 @@ namespace http
|
||||
file_stream.Close();
|
||||
}
|
||||
|
||||
std::future<void> download(const winrt::Windows::Foundation::Uri& url, const std::wstring& dstFilePath, const std::function<void(float)>& progressUpdateCallback)
|
||||
winrt::Windows::Foundation::IAsyncAction download(winrt::Windows::Foundation::Uri url, std::wstring dstFilePath, std::function<void(float)> progressUpdateCallback)
|
||||
{
|
||||
auto response = co_await m_client.GetAsync(url, HttpCompletionOption::ResponseHeadersRead);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -5140,7 +5140,7 @@ bool IsPenInverted( WPARAM wParam )
|
||||
// Captures the specified screen using the capture APIs
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
std::future<winrt::com_ptr<ID3D11Texture2D>> CaptureScreenshotAsync(winrt::IDirect3DDevice const& device, winrt::GraphicsCaptureItem const& item, winrt::DirectXPixelFormat const& pixelFormat)
|
||||
wil::task<winrt::com_ptr<ID3D11Texture2D>> CaptureScreenshotAsync(winrt::IDirect3DDevice const& device, winrt::GraphicsCaptureItem const& item, winrt::DirectXPixelFormat const& pixelFormat)
|
||||
{
|
||||
auto d3dDevice = GetDXGIInterfaceFromObject<ID3D11Device>(device);
|
||||
winrt::com_ptr<ID3D11DeviceContext> d3dContext;
|
||||
@@ -5176,9 +5176,7 @@ std::future<winrt::com_ptr<ID3D11Texture2D>> CaptureScreenshotAsync(winrt::IDire
|
||||
framePool.Close();
|
||||
|
||||
auto texture = GetDXGIInterfaceFromObject<ID3D11Texture2D>(frame.Surface());
|
||||
auto result = util::CopyD3DTexture(d3dDevice, texture, true);
|
||||
|
||||
co_return result;
|
||||
co_return util::CopyD3DTexture(d3dDevice, texture, true);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -5205,10 +5203,7 @@ winrt::com_ptr<ID3D11Texture2D>CaptureScreenshot(winrt::DirectXPixelFormat const
|
||||
|
||||
auto item = util::CreateCaptureItemForMonitor(hMon);
|
||||
|
||||
auto capture = CaptureScreenshotAsync(device, item, pixelFormat);
|
||||
capture.wait();
|
||||
|
||||
return capture.get();
|
||||
return CaptureScreenshotAsync(device, item, pixelFormat).get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
// WIL
|
||||
#include <wil/com.h>
|
||||
#include <wil/resource.h>
|
||||
#include <wil/coroutine.h>
|
||||
|
||||
// DirectX
|
||||
#include <d3d11_4.h>
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
<None Include="Microsoft.Terminal.UI.def" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\CmdPal\</OutDir>
|
||||
<OutDir>$(RepoRoot)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal\</OutDir>
|
||||
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@@ -62,12 +62,11 @@
|
||||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Temporarily disable Native AOT until C++ Desktop Development workload is installed -->
|
||||
<!-- TODO: Re-enable after installing Desktop Development for C++ in Visual Studio -->
|
||||
<!-- Only enable Native AOT for Release builds to avoid System.Private.CoreLib.dll version conflicts during development -->
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<PublishTrimmed>false</PublishTrimmed>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
<PublishAot>false</PublishAot>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishAot>true</PublishAot>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- For Debug builds, use standard JIT compilation -->
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalOptions>/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -3,13 +3,6 @@
|
||||
<Import Project="$(RepoRoot)src\Common.Dotnet.CsWinRT.props" />
|
||||
<Import Project="$(RepoRoot)src\Common.SelfContained.props" />
|
||||
|
||||
<!-- Force WebView2 to use Win32/WinForms mode instead of WinRT mode -->
|
||||
<!-- Required because Settings.UI.Library has UseWinUI=true which triggers WebView2UseWinRT -->
|
||||
<PropertyGroup>
|
||||
<WebView2UseWinRT>false</WebView2UseWinRT>
|
||||
<WebView2EnableCsWinRTProjection>false</WebView2EnableCsWinRTProjection>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
|
||||
@@ -3,13 +3,6 @@
|
||||
<Import Project="$(RepoRoot)src\Common.Dotnet.CsWinRT.props" />
|
||||
<Import Project="$(RepoRoot)src\Common.SelfContained.props" />
|
||||
|
||||
<!-- Force WebView2 to use Win32/WinForms mode instead of WinRT mode -->
|
||||
<!-- Required because Settings.UI.Library has UseWinUI=true which triggers WebView2UseWinRT -->
|
||||
<PropertyGroup>
|
||||
<WebView2UseWinRT>false</WebView2UseWinRT>
|
||||
<WebView2EnableCsWinRTProjection>false</WebView2EnableCsWinRTProjection>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
<!-- Look at Directory.Build.props in root for common stuff as well -->
|
||||
<Import Project="$(RepoRoot)src\Common.Dotnet.CsWinRT.props" />
|
||||
|
||||
<!-- Force WebView2 to use Win32/WinForms mode for unit tests -->
|
||||
<PropertyGroup>
|
||||
<WebView2UseWinRT>false</WebView2UseWinRT>
|
||||
<WebView2EnableCsWinRTProjection>false</WebView2EnableCsWinRTProjection>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyTitle>UnitTests-SvgPreviewHandler</AssemblyTitle>
|
||||
<AssemblyDescription>PowerToys UnitTests-SvgPreviewHandler</AssemblyDescription>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ProjectGuid>{AF2349B8-E5B6-4004-9502-687C1C7730B1}</ProjectGuid>
|
||||
<AssemblyName>PowerToys.PreviewHandlerCommon</AssemblyName>
|
||||
<!-- AutoUnify resolves WindowsBase version conflict (WebView2.Wpf refs .NET 5 version, we target .NET 9) -->
|
||||
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -173,7 +173,8 @@ void ProcessNewVersionInfo(const github_version_info& version_info,
|
||||
// Cleanup old updates before downloading the latest
|
||||
updating::cleanup_updates();
|
||||
|
||||
if (download_new_version(new_version_info).get())
|
||||
auto downloaded_installer = std::move(download_new_version_async(new_version_info)).get();
|
||||
if (downloaded_installer)
|
||||
{
|
||||
state.state = UpdateState::readyToInstall;
|
||||
state.downloadedInstallerFilename = new_version_info.installer_filename;
|
||||
@@ -232,7 +233,7 @@ void PeriodicUpdateWorker()
|
||||
bool version_info_obtained = false;
|
||||
try
|
||||
{
|
||||
const auto new_version_info = get_github_version_info_async().get();
|
||||
const auto new_version_info = std::move(get_github_version_info_async()).get();
|
||||
if (new_version_info.has_value())
|
||||
{
|
||||
version_info_obtained = true;
|
||||
@@ -272,7 +273,7 @@ void CheckForUpdatesCallback()
|
||||
auto state = UpdateState::read();
|
||||
try
|
||||
{
|
||||
auto new_version_info = get_github_version_info_async().get();
|
||||
auto new_version_info = std::move(get_github_version_info_async()).get();
|
||||
if (!new_version_info)
|
||||
{
|
||||
// We couldn't get a new version from github for some reason, log error
|
||||
|
||||
@@ -32,3 +32,4 @@
|
||||
#include <winrt/Windows.Storage.h>
|
||||
|
||||
#include <wil/resource.h>
|
||||
#include <wil/coroutine.h>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
using System; // For Action
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Controls
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
<DataTemplate x:DataType="local:QuickAccessItem">
|
||||
<local:FlyoutMenuButton
|
||||
AutomationProperties.Name="{x:Bind Title}"
|
||||
Click="FlyoutMenuButton_Click"
|
||||
Tag="{x:Bind}"
|
||||
Command="{x:Bind Command}"
|
||||
CommandParameter="{x:Bind CommandParameter}"
|
||||
Visibility="{x:Bind Visible, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<local:FlyoutMenuButton.Content>
|
||||
<TextBlock
|
||||
|
||||
@@ -22,13 +22,5 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(nameof(ItemsSource), typeof(object), typeof(QuickAccessList), new PropertyMetadata(null));
|
||||
|
||||
private void FlyoutMenuButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button button && button.Tag is QuickAccessItem item)
|
||||
{
|
||||
item.Command?.Execute(item.CommandParameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,58 +3,21 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library.HotkeyConflicts
|
||||
{
|
||||
public partial class HotkeyConflictGroupData : INotifyPropertyChanged
|
||||
public class HotkeyConflictGroupData
|
||||
{
|
||||
private bool _conflictIgnored;
|
||||
private bool _isSystemConflict;
|
||||
|
||||
public HotkeyData Hotkey { get; set; }
|
||||
|
||||
public bool IsSystemConflict
|
||||
{
|
||||
get => _isSystemConflict;
|
||||
set
|
||||
{
|
||||
if (_isSystemConflict != value)
|
||||
{
|
||||
_isSystemConflict = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(ShouldShowSysConflict));
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool IsSystemConflict { get; set; }
|
||||
|
||||
public bool ConflictIgnored
|
||||
{
|
||||
get => _conflictIgnored;
|
||||
set
|
||||
{
|
||||
if (_conflictIgnored != value)
|
||||
{
|
||||
_conflictIgnored = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(ConflictVisible));
|
||||
OnPropertyChanged(nameof(ShouldShowSysConflict));
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool ConflictIgnored { get; set; }
|
||||
|
||||
public bool ConflictVisible => !ConflictIgnored;
|
||||
|
||||
public bool ShouldShowSysConflict => !ConflictIgnored && IsSystemConflict;
|
||||
|
||||
public List<ModuleHotkeyData> Modules { get; set; }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
// 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.
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// ICommand interface for WinUI 3 applications, compatible with Native AOT.
|
||||
/// Extends System.Windows.Input.ICommand which is also recognized by WinUI3 XAML bindings.
|
||||
/// </summary>
|
||||
public interface ICommand : System.Windows.Input.ICommand
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ using System.Management;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading;
|
||||
using System.Windows.Input;
|
||||
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
<PropertyGroup>
|
||||
<Description>PowerToys Settings UI Library</Description>
|
||||
<AssemblyName>PowerToys.Settings.UI.Lib</AssemblyName>
|
||||
<!-- Enable WinUI to access Microsoft.UI.Xaml.Input.ICommand for AOT-compatible command binding -->
|
||||
<UseWinUI>true</UseWinUI>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -17,7 +15,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.IO.Abstractions" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -153,11 +153,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
[JsonSerializable(typeof(List<VcpValueInfo>))]
|
||||
[JsonSerializable(typeof(SettingsUILibraryHelpers.SearchLocation))]
|
||||
|
||||
// Search Index Types (for AOT compatibility)
|
||||
[JsonSerializable(typeof(SettingsUILibrary.SettingEntry))]
|
||||
[JsonSerializable(typeof(SettingsUILibrary.SettingEntry[]))]
|
||||
[JsonSerializable(typeof(SettingsUILibrary.EntryType))]
|
||||
|
||||
// AdvancedPaste AI Provider Types (for AOT compatibility)
|
||||
[JsonSerializable(typeof(PasteAIConfiguration))]
|
||||
[JsonSerializable(typeof(PasteAIProviderDefinition))]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands
|
||||
{
|
||||
|
||||
@@ -2,36 +2,32 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands
|
||||
{
|
||||
// Preserve for AOT - ensure command execution methods are not trimmed
|
||||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicProperties)]
|
||||
public class RelayCommand : Microsoft.PowerToys.Settings.UI.Library.ICommand
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
private readonly Action _execute;
|
||||
private readonly Func<bool>? _canExecute;
|
||||
private readonly Func<bool> _canExecute;
|
||||
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public RelayCommand(Action execute)
|
||||
: this(execute, null)
|
||||
{
|
||||
}
|
||||
|
||||
public RelayCommand(Action execute, Func<bool>? canExecute)
|
||||
public RelayCommand(Action execute, Func<bool> canExecute)
|
||||
{
|
||||
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object? parameter) => _canExecute == null || _canExecute();
|
||||
public bool CanExecute(object parameter) => _canExecute == null || _canExecute();
|
||||
|
||||
public void Execute(object? parameter) => _execute();
|
||||
public void Execute(object parameter) => _execute();
|
||||
|
||||
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
@@ -2,47 +2,33 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands
|
||||
{
|
||||
// Preserve for AOT - ensure command execution methods are not trimmed
|
||||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicProperties)]
|
||||
public class RelayCommand<T> : Microsoft.PowerToys.Settings.UI.Library.ICommand
|
||||
public class RelayCommand<T> : ICommand
|
||||
{
|
||||
private readonly Action<T> execute;
|
||||
|
||||
private readonly Func<T, bool>? canExecute;
|
||||
private readonly Func<T, bool> canExecute;
|
||||
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public RelayCommand(Action<T> execute)
|
||||
: this(execute, null)
|
||||
{
|
||||
}
|
||||
|
||||
public RelayCommand(Action<T> execute, Func<T, bool>? canExecute)
|
||||
public RelayCommand(Action<T> execute, Func<T, bool> canExecute)
|
||||
{
|
||||
this.execute = execute ?? throw new ArgumentNullException(nameof(execute));
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object? parameter)
|
||||
{
|
||||
// AOT-friendly: no reflection, just direct cast
|
||||
// The null-forgiving operator is safe here because we're just checking CanExecute
|
||||
return canExecute == null || canExecute((T)parameter!);
|
||||
}
|
||||
public bool CanExecute(object parameter) => canExecute == null || canExecute((T)parameter);
|
||||
|
||||
public void Execute(object? parameter)
|
||||
{
|
||||
// AOT-friendly: simple cast, no reflection or type checking
|
||||
// This matches the original main branch behavior exactly
|
||||
execute((T)parameter!);
|
||||
}
|
||||
public void Execute(object parameter) => execute((T)parameter);
|
||||
|
||||
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
@@ -29,7 +30,7 @@ public sealed partial class ImageResizerFitToStringConverter : IValueConverter
|
||||
fitText;
|
||||
}
|
||||
|
||||
return Microsoft.UI.Xaml.DependencyProperty.UnsetValue;
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
@@ -37,7 +38,7 @@ public sealed partial class ImageResizerSizeToAccessibleTextConverter : IValueCo
|
||||
{
|
||||
(string presetName, string nameId) => FormatNameText(presetName, nameId),
|
||||
(ImageSize preset, string _) => FormatDescriptionText(preset),
|
||||
_ => Microsoft.UI.Xaml.DependencyProperty.UnsetValue,
|
||||
_ => DependencyProperty.UnsetValue,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -45,14 +46,14 @@ public sealed partial class ImageResizerSizeToAccessibleTextConverter : IValueCo
|
||||
{
|
||||
return AccessibilityFormats.TryGetValue(nameId, out string format) ?
|
||||
string.Format(CultureInfo.CurrentCulture, format, presetName) :
|
||||
Microsoft.UI.Xaml.DependencyProperty.UnsetValue;
|
||||
DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
private object FormatDescriptionText(ImageSize preset)
|
||||
{
|
||||
if (preset == null)
|
||||
{
|
||||
return Microsoft.UI.Xaml.DependencyProperty.UnsetValue;
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
string fitText = _fitConverter.Convert(preset.Fit, typeof(string), null, null) as string;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
@@ -30,7 +31,7 @@ public sealed partial class ImageResizerUnitToStringConverter : IValueConverter
|
||||
unitText;
|
||||
}
|
||||
|
||||
return Microsoft.UI.Xaml.DependencyProperty.UnsetValue;
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
|
||||
@@ -20,8 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.Converters
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use generic overload for AOT compatibility (IL2026)
|
||||
return Enum.Parse<Microsoft.UI.Xaml.Controls.InfoBarSeverity>((string)value, ignoreCase: true);
|
||||
return (Microsoft.UI.Xaml.Controls.InfoBarSeverity)Enum.Parse(typeof(Microsoft.UI.Xaml.Controls.InfoBarSeverity), (string)value, true);
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -2,35 +2,34 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
{
|
||||
internal sealed partial class AsyncCommand : Microsoft.PowerToys.Settings.UI.Library.ICommand
|
||||
internal sealed partial class AsyncCommand : ICommand
|
||||
{
|
||||
private readonly Func<Task> _execute;
|
||||
private readonly Func<bool>? _canExecute;
|
||||
private readonly Func<bool> _canExecute;
|
||||
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public AsyncCommand(Func<Task> execute, Func<bool>? canExecute = null)
|
||||
public AsyncCommand(Func<Task> execute, Func<bool> canExecute = null)
|
||||
{
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object? parameter)
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return _canExecute == null || _canExecute();
|
||||
}
|
||||
|
||||
public async void Execute(object? parameter)
|
||||
public async void Execute(object parameter)
|
||||
{
|
||||
await _execute();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
public class CHOOSEFONT
|
||||
{
|
||||
// Use generic overload for AOT compatibility (IL3050)
|
||||
public int lStructSize = Marshal.SizeOf<CHOOSEFONT>();
|
||||
public int lStructSize = Marshal.SizeOf(typeof(CHOOSEFONT));
|
||||
public IntPtr hwndOwner = IntPtr.Zero;
|
||||
public IntPtr hDC = IntPtr.Zero;
|
||||
public IntPtr lpLogFont = IntPtr.Zero;
|
||||
|
||||
@@ -2,60 +2,59 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
{
|
||||
public partial class RelayCommand : Microsoft.PowerToys.Settings.UI.Library.ICommand
|
||||
public partial class RelayCommand : ICommand
|
||||
{
|
||||
private readonly Action _execute;
|
||||
private readonly Func<bool>? _canExecute;
|
||||
private readonly Func<bool> _canExecute;
|
||||
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public RelayCommand(Action execute)
|
||||
: this(execute, null)
|
||||
{
|
||||
}
|
||||
|
||||
public RelayCommand(Action execute, Func<bool>? canExecute)
|
||||
public RelayCommand(Action execute, Func<bool> canExecute)
|
||||
{
|
||||
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object? parameter) => _canExecute == null || _canExecute();
|
||||
public bool CanExecute(object parameter) => _canExecute == null || _canExecute();
|
||||
|
||||
public void Execute(object? parameter) => _execute();
|
||||
public void Execute(object parameter) => _execute();
|
||||
|
||||
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "abstract T and abstract")]
|
||||
public partial class RelayCommand<T> : Microsoft.PowerToys.Settings.UI.Library.ICommand
|
||||
public partial class RelayCommand<T> : ICommand
|
||||
{
|
||||
private readonly Action<T> execute;
|
||||
|
||||
private readonly Func<T, bool>? canExecute;
|
||||
private readonly Func<T, bool> canExecute;
|
||||
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public RelayCommand(Action<T> execute)
|
||||
: this(execute, null)
|
||||
{
|
||||
}
|
||||
|
||||
public RelayCommand(Action<T> execute, Func<T, bool>? canExecute)
|
||||
public RelayCommand(Action<T> execute, Func<T, bool> canExecute)
|
||||
{
|
||||
this.execute = execute ?? throw new ArgumentNullException(nameof(execute));
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object? parameter) => canExecute == null || canExecute((T)parameter!);
|
||||
public bool CanExecute(object parameter) => canExecute == null || canExecute((T)parameter);
|
||||
|
||||
public void Execute(object? parameter) => execute((T)parameter!);
|
||||
public void Execute(object parameter) => execute((T)parameter);
|
||||
|
||||
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// This is a local copy of Common.UI.SettingsDeepLink for AOT compatibility.
|
||||
// Common.UI cannot be referenced in AOT builds because it depends on WPF.
|
||||
#if BUILD_INFO_PUBLISH_AOT
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using ManagedCommon;
|
||||
|
||||
namespace Common.UI
|
||||
{
|
||||
public static class SettingsDeepLink
|
||||
{
|
||||
public enum SettingsWindow
|
||||
{
|
||||
Dashboard = 0,
|
||||
Overview,
|
||||
AlwaysOnTop,
|
||||
Awake,
|
||||
ColorPicker,
|
||||
CmdNotFound,
|
||||
LightSwitch,
|
||||
FancyZones,
|
||||
FileLocksmith,
|
||||
Run,
|
||||
ImageResizer,
|
||||
KBM,
|
||||
MouseUtils,
|
||||
MouseWithoutBorders,
|
||||
Peek,
|
||||
PowerAccent,
|
||||
PowerLauncher,
|
||||
PowerPreview,
|
||||
PowerRename,
|
||||
FileExplorer,
|
||||
ShortcutGuide,
|
||||
Hosts,
|
||||
MeasureTool,
|
||||
PowerOCR,
|
||||
Workspaces,
|
||||
RegistryPreview,
|
||||
CropAndLock,
|
||||
EnvironmentVariables,
|
||||
AdvancedPaste,
|
||||
NewPlus,
|
||||
CmdPal,
|
||||
ZoomIt,
|
||||
PowerDisplay,
|
||||
}
|
||||
|
||||
private static string SettingsWindowNameToString(SettingsWindow value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case SettingsWindow.Dashboard:
|
||||
return "Dashboard";
|
||||
case SettingsWindow.Overview:
|
||||
return "Overview";
|
||||
case SettingsWindow.AlwaysOnTop:
|
||||
return "AlwaysOnTop";
|
||||
case SettingsWindow.Awake:
|
||||
return "Awake";
|
||||
case SettingsWindow.ColorPicker:
|
||||
return "ColorPicker";
|
||||
case SettingsWindow.CmdNotFound:
|
||||
return "CmdNotFound";
|
||||
case SettingsWindow.LightSwitch:
|
||||
return "LightSwitch";
|
||||
case SettingsWindow.FancyZones:
|
||||
return "FancyZones";
|
||||
case SettingsWindow.FileLocksmith:
|
||||
return "FileLocksmith";
|
||||
case SettingsWindow.Run:
|
||||
return "Run";
|
||||
case SettingsWindow.ImageResizer:
|
||||
return "ImageResizer";
|
||||
case SettingsWindow.KBM:
|
||||
return "KBM";
|
||||
case SettingsWindow.MouseUtils:
|
||||
return "MouseUtils";
|
||||
case SettingsWindow.MouseWithoutBorders:
|
||||
return "MouseWithoutBorders";
|
||||
case SettingsWindow.Peek:
|
||||
return "Peek";
|
||||
case SettingsWindow.PowerAccent:
|
||||
return "PowerAccent";
|
||||
case SettingsWindow.PowerLauncher:
|
||||
return "PowerLauncher";
|
||||
case SettingsWindow.PowerPreview:
|
||||
return "PowerPreview";
|
||||
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.Workspaces:
|
||||
return "Workspaces";
|
||||
case SettingsWindow.RegistryPreview:
|
||||
return "RegistryPreview";
|
||||
case SettingsWindow.CropAndLock:
|
||||
return "CropAndLock";
|
||||
case SettingsWindow.EnvironmentVariables:
|
||||
return "EnvironmentVariables";
|
||||
case SettingsWindow.AdvancedPaste:
|
||||
return "AdvancedPaste";
|
||||
case SettingsWindow.NewPlus:
|
||||
return "NewPlus";
|
||||
case SettingsWindow.CmdPal:
|
||||
return "CmdPal";
|
||||
case SettingsWindow.ZoomIt:
|
||||
return "ZoomIt";
|
||||
case SettingsWindow.PowerDisplay:
|
||||
return "PowerDisplay";
|
||||
default:
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenSettings(SettingsWindow window)
|
||||
{
|
||||
try
|
||||
{
|
||||
var exePath = Path.Combine(
|
||||
PowerToysPathResolver.GetPowerToysInstallPath(),
|
||||
"PowerToys.exe");
|
||||
|
||||
if (exePath == null || !File.Exists(exePath))
|
||||
{
|
||||
Logger.LogError($"Failed to find powertoys exe path, {exePath}");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = "--open-settings=" + SettingsWindowNameToString(window);
|
||||
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = exePath,
|
||||
Arguments = args,
|
||||
UseShellExecute = false,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -6,9 +6,8 @@ using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Windows.Management.Deployment;
|
||||
using Windows.System;
|
||||
|
||||
@@ -17,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
/// <summary>
|
||||
/// Helper class to manage installation status and installation command for a Microsoft Store extension.
|
||||
/// </summary>
|
||||
public partial class StoreExtensionHelper : INotifyPropertyChanged
|
||||
public class StoreExtensionHelper : INotifyPropertyChanged
|
||||
{
|
||||
private readonly string _packageFamilyName;
|
||||
private readonly string _storeUri;
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<!-- Look at Directory.Build.props in root for common stuff as well -->
|
||||
<Import Project="$(RepoRoot)src\Common.Dotnet.CsWinRT.props" />
|
||||
<Import Project="$(RepoRoot)src\Common.Dotnet.AotCompatibility.props" />
|
||||
<Import Project="$(RepoRoot)src\Common.SelfContained.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Microsoft.PowerToys.Settings.UI</RootNamespace>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
|
||||
<WindowsPackageType>None</WindowsPackageType>
|
||||
@@ -21,25 +19,6 @@
|
||||
<!-- MRT from windows app sdk will search for a pri file with the same name of the module before defaulting to resources.pri -->
|
||||
<ProjectPriFileName>PowerToys.Settings.pri</ProjectPriFileName>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- For debugging purposes, uncomment this block to enable AOT builds -->
|
||||
<PropertyGroup>
|
||||
<EnableSettingsAOT>true</EnableSettingsAOT>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(EnableSettingsAOT)' == 'true'">
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
<DisableRuntimeMarshalling>false</DisableRuntimeMarshalling>
|
||||
<PublishAot>true</PublishAot>
|
||||
<!-- Use environmental tools to bypass VS version detection issue with VS 2026 -->
|
||||
<IlcUseEnvironmentalTools>true</IlcUseEnvironmentalTools>
|
||||
<!-- Trim is mandatory for AOT, but disable reflection removal to preserve WPF compatibility -->
|
||||
<IlcDisableReflection>false</IlcDisableReflection>
|
||||
<!-- Suppress trim/AOT warnings from third-party assemblies and XAML Command binding type checks -->
|
||||
<NoWarn>$(NoWarn);IL2026;IL2060;IL2070;IL2071;IL2072;IL2075;IL2076;IL2104;IL3000;IL3002;IL3050;IL3053;WMC1121</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\Settings\Icons\Models\Azure.svg" />
|
||||
<None Remove="Assets\Settings\Icons\Models\FoundryLocal.svg" />
|
||||
@@ -83,14 +62,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Navigation Icons - PNG files (required for AOT publish) -->
|
||||
<Content Include="Assets\Settings\Icons\*.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<!-- Module Images - PNG files (required for AOT publish) -->
|
||||
<Content Include="Assets\Settings\Modules\*.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<!-- AI Model Provider Icons - SVG files -->
|
||||
<Content Include="Assets\Settings\Icons\Models\*.svg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@@ -143,7 +114,7 @@
|
||||
<ItemGroup>
|
||||
<!-- HACK: Common.UI is referenced, even if it is not used, to force dll versions to be the same as in other projects that use it. It's still unclear why this is the case, but this is need for flattening the install directory. -->
|
||||
<ProjectReference Include="..\..\common\Common.Search\Common.Search.csproj" />
|
||||
<ProjectReference Condition="'$(EnableSettingsAOT)' != 'true'" Include="..\..\common\Common.UI\Common.UI.csproj" />
|
||||
<ProjectReference Include="..\..\common\Common.UI\Common.UI.csproj" />
|
||||
<ProjectReference Include="..\..\common\AllExperiments\AllExperiments.csproj" />
|
||||
<ProjectReference Include="..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\common\interop\PowerToys.Interop.vcxproj" />
|
||||
@@ -168,7 +139,7 @@
|
||||
<!-- TODO: fix issues and reenable -->
|
||||
<!-- These are caused by streamjsonrpc dependency on Microsoft.VisualStudio.Threading.Analyzers -->
|
||||
<!-- We might want to add that to the project and fix the issues as well -->
|
||||
<NoWarn>$(NoWarn);VSTHRD002;VSTHRD110;VSTHRD100;VSTHRD200;VSTHRD101</NoWarn>
|
||||
<NoWarn>VSTHRD002;VSTHRD110;VSTHRD100;VSTHRD200;VSTHRD101</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Removed hard-coded resource exclusion. -->
|
||||
@@ -248,15 +219,4 @@
|
||||
<Message Importance="high" Text="[Settings] Building XamlIndexBuilder prior to compile. Views='$(MSBuildProjectDirectory)\SettingsXAML\Views' Out='$(GeneratedJsonFile)'" />
|
||||
<MSBuild Projects="..\Settings.UI.XamlIndexBuilder\Settings.UI.XamlIndexBuilder.csproj" Targets="Build" Properties="Configuration=$(Configuration);Platform=Any CPU;TargetFramework=net9.0;XamlViewsDir=$(MSBuildProjectDirectory)\SettingsXAML\Views;GeneratedJsonFile=$(GeneratedJsonFile)" />
|
||||
</Target>
|
||||
|
||||
<!-- Build information for AOT -->
|
||||
<PropertyGroup Condition=" '$(PublishAot)' == 'true' ">
|
||||
<DefineConstants>$(DefineConstants);BUILD_INFO_PUBLISH_AOT</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(PublishTrimmed)' == 'true' ">
|
||||
<DefineConstants>$(DefineConstants);BUILD_INFO_PUBLISH_TRIMMED</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(CIBuild)' == 'true' ">
|
||||
<DefineConstants>$(DefineConstants);BUILD_INFO_CIBUILD</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -17,7 +17,6 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Common.Search.FuzzSearch;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Views;
|
||||
using Microsoft.Windows.ApplicationModel.Resources;
|
||||
using Settings.UI.Library;
|
||||
@@ -34,6 +33,7 @@ namespace Microsoft.PowerToys.Settings.UI.Services
|
||||
private static bool _isIndexBuilt;
|
||||
private static bool _isIndexBuilding;
|
||||
private const string PrebuiltIndexResourceName = "Microsoft.PowerToys.Settings.UI.Assets.search.index.json";
|
||||
private static JsonSerializerOptions _serializerOptions = new() { PropertyNameCaseInsensitive = true };
|
||||
|
||||
public static ImmutableArray<SettingEntry> Index
|
||||
{
|
||||
@@ -121,8 +121,7 @@ namespace Microsoft.PowerToys.Settings.UI.Services
|
||||
return;
|
||||
}
|
||||
|
||||
// Use source-generated deserializer for AOT compatibility (IL2026/IL3050)
|
||||
metadataList = JsonSerializer.Deserialize(json, SettingsSerializationContext.Default.SettingEntryArray);
|
||||
metadataList = JsonSerializer.Deserialize<SettingEntry[]>(json, _serializerOptions);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -263,7 +262,6 @@ namespace Microsoft.PowerToys.Settings.UI.Services
|
||||
.ToList();
|
||||
}
|
||||
|
||||
// AOT-compatible type lookup using switch expression instead of reflection (IL2026)
|
||||
private static Type GetPageTypeFromName(string pageTypeName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pageTypeName))
|
||||
@@ -278,43 +276,8 @@ namespace Microsoft.PowerToys.Settings.UI.Services
|
||||
return cached;
|
||||
}
|
||||
|
||||
// Use compile-time known types instead of Assembly.GetType for AOT compatibility
|
||||
var type = pageTypeName switch
|
||||
{
|
||||
nameof(DashboardPage) => typeof(DashboardPage),
|
||||
nameof(GeneralPage) => typeof(GeneralPage),
|
||||
nameof(AdvancedPastePage) => typeof(AdvancedPastePage),
|
||||
nameof(AlwaysOnTopPage) => typeof(AlwaysOnTopPage),
|
||||
nameof(AwakePage) => typeof(AwakePage),
|
||||
nameof(CmdNotFoundPage) => typeof(CmdNotFoundPage),
|
||||
nameof(CmdPalPage) => typeof(CmdPalPage),
|
||||
nameof(ColorPickerPage) => typeof(ColorPickerPage),
|
||||
nameof(CropAndLockPage) => typeof(CropAndLockPage),
|
||||
nameof(EnvironmentVariablesPage) => typeof(EnvironmentVariablesPage),
|
||||
nameof(FancyZonesPage) => typeof(FancyZonesPage),
|
||||
nameof(FileLocksmithPage) => typeof(FileLocksmithPage),
|
||||
nameof(HostsPage) => typeof(HostsPage),
|
||||
nameof(ImageResizerPage) => typeof(ImageResizerPage),
|
||||
nameof(KeyboardManagerPage) => typeof(KeyboardManagerPage),
|
||||
nameof(LightSwitchPage) => typeof(LightSwitchPage),
|
||||
nameof(MeasureToolPage) => typeof(MeasureToolPage),
|
||||
nameof(MouseUtilsPage) => typeof(MouseUtilsPage),
|
||||
nameof(MouseWithoutBordersPage) => typeof(MouseWithoutBordersPage),
|
||||
nameof(NewPlusPage) => typeof(NewPlusPage),
|
||||
nameof(PeekPage) => typeof(PeekPage),
|
||||
nameof(PowerAccentPage) => typeof(PowerAccentPage),
|
||||
nameof(PowerLauncherPage) => typeof(PowerLauncherPage),
|
||||
nameof(PowerOcrPage) => typeof(PowerOcrPage),
|
||||
nameof(PowerPreviewPage) => typeof(PowerPreviewPage),
|
||||
nameof(PowerRenamePage) => typeof(PowerRenamePage),
|
||||
nameof(PowerDisplayPage) => typeof(PowerDisplayPage),
|
||||
nameof(RegistryPreviewPage) => typeof(RegistryPreviewPage),
|
||||
nameof(ShortcutGuidePage) => typeof(ShortcutGuidePage),
|
||||
nameof(WorkspacesPage) => typeof(WorkspacesPage),
|
||||
nameof(ZoomItPage) => typeof(ZoomItPage),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
var assembly = typeof(GeneralPage).Assembly;
|
||||
var type = assembly.GetType($"Microsoft.PowerToys.Settings.UI.Views.{pageTypeName}");
|
||||
_pageTypeCache[pageTypeName] = type;
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Security.Cryptography;
|
||||
using System.Windows.Input;
|
||||
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Services;
|
||||
using Microsoft.PowerToys.Settings.UI.Views;
|
||||
@@ -11,36 +9,11 @@ using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Controls
|
||||
{
|
||||
public sealed partial class CheckUpdateControl : UserControl, INotifyPropertyChanged
|
||||
public sealed partial class CheckUpdateControl : UserControl
|
||||
{
|
||||
private bool _updateAvailable;
|
||||
private UpdatingSettings _updateSettingsConfig;
|
||||
public bool UpdateAvailable { get; set; }
|
||||
|
||||
public bool UpdateAvailable
|
||||
{
|
||||
get => _updateAvailable;
|
||||
set
|
||||
{
|
||||
if (_updateAvailable != value)
|
||||
{
|
||||
_updateAvailable = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UpdatingSettings UpdateSettingsConfig
|
||||
{
|
||||
get => _updateSettingsConfig;
|
||||
set
|
||||
{
|
||||
if (_updateSettingsConfig != value)
|
||||
{
|
||||
_updateSettingsConfig = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
public UpdatingSettings UpdateSettingsConfig { get; set; }
|
||||
|
||||
public CheckUpdateControl()
|
||||
{
|
||||
@@ -53,12 +26,5 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
|
||||
{
|
||||
NavigationService.Navigate(typeof(GeneralPage));
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,8 +230,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
|
||||
NavigationViewItem selectedItem = this.navigationView.SelectedItem as NavigationViewItem;
|
||||
if (selectedItem != null)
|
||||
{
|
||||
// Use generic overload for AOT compatibility (IL2026)
|
||||
Modules[(int)Enum.Parse<PowerToysModules>((string)selectedItem.Tag, ignoreCase: true)].LogClosingModuleEvent();
|
||||
Modules[(int)(PowerToysModules)Enum.Parse(typeof(PowerToysModules), (string)selectedItem.Tag, true)].LogClosingModuleEvent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
using LanguageModelProvider;
|
||||
using Microsoft.PowerToys.Settings.UI.Controls;
|
||||
@@ -680,7 +681,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
await LoadFoundryLocalModelsAsync();
|
||||
}
|
||||
|
||||
private sealed partial class FoundryDownloadableModel : INotifyPropertyChanged
|
||||
private sealed class FoundryDownloadableModel : INotifyPropertyChanged
|
||||
{
|
||||
private readonly List<string> _deviceTags;
|
||||
private double _progress;
|
||||
|
||||
@@ -55,14 +55,14 @@
|
||||
Glyph="" />
|
||||
<HyperlinkButton
|
||||
x:Uid="CmdNotFound_UninstallButton"
|
||||
Click="UninstallButton_Click"
|
||||
Command="{x:Bind ViewModel.UninstallModuleEventHandler}"
|
||||
IsEnabled="{x:Bind ViewModel.IsModuleGpoEnabled, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}" />
|
||||
</StackPanel>
|
||||
</tkcontrols:Case>
|
||||
<tkcontrols:Case Value="False">
|
||||
<Button
|
||||
x:Uid="CmdNotFound_InstallButton"
|
||||
Click="InstallButton_Click"
|
||||
Command="{x:Bind ViewModel.InstallModuleEventHandler}"
|
||||
IsEnabled="{x:Bind ViewModel.IsModuleGpoDisabled, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
|
||||
Style="{StaticResource AccentButtonStyle}" />
|
||||
</tkcontrols:Case>
|
||||
@@ -76,7 +76,7 @@
|
||||
IsClosable="False"
|
||||
IsOpen="True">
|
||||
<InfoBar.ActionButton>
|
||||
<HyperlinkButton x:Uid="CmdNotFound_CheckCompatibility" Click="CheckRequirementsButton_Click">
|
||||
<HyperlinkButton x:Uid="CmdNotFound_CheckCompatibility" Command="{x:Bind ViewModel.CheckRequirementsEventHandler}">
|
||||
<ToolTipService.ToolTip>
|
||||
<TextBlock x:Uid="CmdNotFound_CheckCompatibilityTooltip" TextWrapping="Wrap" />
|
||||
</ToolTipService.ToolTip>
|
||||
@@ -112,7 +112,7 @@
|
||||
Glyph="" />
|
||||
<Button
|
||||
x:Uid="CmdNotFound_InstallButton"
|
||||
Click="InstallPowerShell7Button_Click"
|
||||
Command="{x:Bind ViewModel.InstallPowerShell7EventHandler}"
|
||||
IsEnabled="{x:Bind ViewModel.IsModuleGpoDisabled, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}" />
|
||||
</StackPanel>
|
||||
</tkcontrols:Case>
|
||||
@@ -145,7 +145,7 @@
|
||||
Glyph="" />
|
||||
<Button
|
||||
x:Uid="CmdNotFound_InstallButton"
|
||||
Click="InstallWinGetButton_Click"
|
||||
Command="{x:Bind ViewModel.InstallWinGetClientModuleEventHandler}"
|
||||
IsEnabled="{x:Bind ViewModel.IsModuleGpoDisabled, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}" />
|
||||
</StackPanel>
|
||||
</tkcontrols:Case>
|
||||
|
||||
@@ -18,30 +18,5 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
DataContext = ViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void UninstallButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.UninstallModuleEventHandler?.Execute(null);
|
||||
}
|
||||
|
||||
private void InstallButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.InstallModuleEventHandler?.Execute(null);
|
||||
}
|
||||
|
||||
private void CheckRequirementsButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.CheckRequirementsEventHandler?.Execute(null);
|
||||
}
|
||||
|
||||
private void InstallPowerShell7Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.InstallPowerShell7EventHandler?.Execute(null);
|
||||
}
|
||||
|
||||
private void InstallWinGetButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.InstallWinGetClientModuleEventHandler?.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,6 @@
|
||||
x:Name="ColorFormatDialog"
|
||||
x:Uid="ColorFormatDialog"
|
||||
Closed="ColorFormatDialog_Closed"
|
||||
PrimaryButtonClick="ColorFormatDialog_PrimaryButtonClick"
|
||||
IsPrimaryButtonEnabled="{Binding IsValid, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
PrimaryButtonStyle="{ThemeResource AccentButtonStyle}">
|
||||
<ContentDialog.DataContext>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Input;
|
||||
|
||||
using CommunityToolkit.WinUI.Controls;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
@@ -24,15 +25,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
|
||||
private ResourceLoader resourceLoader = ResourceLoaderInstance.ResourceLoader;
|
||||
|
||||
private enum DialogActionMode
|
||||
{
|
||||
None,
|
||||
Add,
|
||||
Update,
|
||||
}
|
||||
|
||||
private DialogActionMode _dialogActionMode = DialogActionMode.None;
|
||||
|
||||
public ColorPickerPage()
|
||||
{
|
||||
var settingsUtils = SettingsUtils.Default;
|
||||
@@ -137,9 +129,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
ColorFormatDialog.Tag = string.Empty;
|
||||
|
||||
ColorFormatDialog.PrimaryButtonText = resourceLoader.GetString("ColorFormatSave");
|
||||
|
||||
// Use Click event instead of Command for AOT compatibility
|
||||
_dialogActionMode = DialogActionMode.Add;
|
||||
ColorFormatDialog.PrimaryButtonCommand = AddCommand;
|
||||
await ColorFormatDialog.ShowAsync();
|
||||
}
|
||||
|
||||
@@ -152,9 +142,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
ColorFormatDialog.Tag = new KeyValuePair<string, string>(colorFormatModel.Name, colorFormatModel.Format);
|
||||
|
||||
ColorFormatDialog.PrimaryButtonText = resourceLoader.GetString("ColorFormatUpdate");
|
||||
|
||||
// Use Click event instead of Command for AOT compatibility
|
||||
_dialogActionMode = DialogActionMode.Update;
|
||||
ColorFormatDialog.PrimaryButtonCommand = UpdateCommand;
|
||||
await ColorFormatDialog.ShowAsync();
|
||||
}
|
||||
|
||||
@@ -168,18 +156,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
ViewModel.RefreshEnabledState();
|
||||
}
|
||||
|
||||
private void ColorFormatDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
if (_dialogActionMode == DialogActionMode.Add)
|
||||
{
|
||||
Add();
|
||||
}
|
||||
else if (_dialogActionMode == DialogActionMode.Update)
|
||||
{
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
private void ColorFormatDialog_Closed(ContentDialog sender, ContentDialogClosedEventArgs args)
|
||||
{
|
||||
if (args.Result != ContentDialogResult.Primary && ColorFormatDialog.Tag is KeyValuePair<string, string>)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
Name="EnvironmentVariablesLaunchButtonControl"
|
||||
x:Uid="EnvironmentVariables_LaunchButtonControl"
|
||||
ActionIcon="{ui:FontIcon Glyph=}"
|
||||
Click="LaunchButton_Click"
|
||||
Command="{x:Bind ViewModel.LaunchEventHandler}"
|
||||
HeaderIcon="{ui:FontIcon Glyph=}"
|
||||
IsClickEnabled="True" />
|
||||
<tkcontrols:SettingsCard
|
||||
|
||||
@@ -24,10 +24,5 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
{
|
||||
ViewModel.RefreshEnabledState();
|
||||
}
|
||||
|
||||
private void LaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.LaunchEventHandler?.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
x:Uid="FancyZones_LaunchEditorButtonControl"
|
||||
ActionIcon="{ui:FontIcon Glyph=}"
|
||||
AutomationProperties.AutomationId="LaunchLayoutEditorButton"
|
||||
Click="LaunchEditorButton_Click"
|
||||
Command="{x:Bind ViewModel.LaunchEditorEventHandler}"
|
||||
HeaderIcon="{ui:FontIcon Glyph=}"
|
||||
IsClickEnabled="True" />
|
||||
|
||||
|
||||
@@ -31,10 +31,5 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
{
|
||||
ViewModel.RefreshEnabledState();
|
||||
}
|
||||
|
||||
private void LaunchEditorButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.LaunchEditorEventHandler?.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
Name="HostsLaunchButtonControl"
|
||||
x:Uid="Hosts_LaunchButtonControl"
|
||||
ActionIcon="{ui:FontIcon Glyph=}"
|
||||
Click="LaunchButton_Click"
|
||||
Command="{x:Bind ViewModel.LaunchEventHandler}"
|
||||
HeaderIcon="{ui:FontIcon Glyph=}"
|
||||
IsClickEnabled="True" />
|
||||
<tkcontrols:SettingsCard
|
||||
@@ -115,7 +115,7 @@
|
||||
</TextBlock>
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Click="SelectBackupPathButton_Click"
|
||||
Command="{x:Bind ViewModel.SelectBackupPathEventHandler}"
|
||||
Content=""
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}">
|
||||
<ToolTipService.ToolTip>
|
||||
|
||||
@@ -28,15 +28,5 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
{
|
||||
ViewModel.RefreshEnabledState();
|
||||
}
|
||||
|
||||
private void LaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.LaunchEventHandler?.Execute(null);
|
||||
}
|
||||
|
||||
private void SelectBackupPathButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.SelectBackupPathEventHandler?.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Common.UI;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
Width="248" />
|
||||
<Button
|
||||
x:Uid="MouseWithoutBorders_Connect"
|
||||
Click="ConnectButton_Click"
|
||||
Command="{x:Bind ConnectCommand, Mode=OneTime}"
|
||||
Style="{StaticResource AccentButtonStyle}" />
|
||||
</StackPanel>
|
||||
</tkcontrols:SettingsCard>
|
||||
@@ -65,11 +65,11 @@
|
||||
<TextBox IsReadOnly="True" Text="{x:Bind ViewModel.SecurityKey, Mode=TwoWay}" />
|
||||
<Button
|
||||
x:Uid="MouseWithoutBorders_NewKey"
|
||||
Click="GenerateNewKeyButton_Click"
|
||||
Command="{x:Bind GenerateNewKeyCommand, Mode=OneTime}"
|
||||
Style="{StaticResource AccentButtonStyle}" />
|
||||
<Button
|
||||
x:Uid="MouseWithoutBorders_Connect"
|
||||
Click="ShowConnectFieldsButton_Click"
|
||||
Command="{x:Bind ShowConnectFieldsCommand, Mode=OneTime}"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
Visibility="{x:Bind Path=ViewModel.ConnectFieldsVisible, Mode=OneWay, Converter={StaticResource ReverseBoolToVisibilityConverter}, ConverterParameter=True}" />
|
||||
</StackPanel>
|
||||
@@ -86,7 +86,7 @@
|
||||
Width="32"
|
||||
Height="32"
|
||||
Padding="4"
|
||||
Click="CopyPCNameButton_Click"
|
||||
Command="{x:Bind CopyPCNameCommand, Mode=OneTime}"
|
||||
Content=""
|
||||
FontFamily="{StaticResource SymbolThemeFontFamily}">
|
||||
<ToolTipService.ToolTip>
|
||||
@@ -160,7 +160,7 @@
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<Button HorizontalAlignment="Right" Click="ReconnectButton_Click">
|
||||
<Button HorizontalAlignment="Right" Command="{x:Bind ReconnectCommand, Mode=OneTime}">
|
||||
<ToolTipService.ToolTip>
|
||||
<TextBlock x:Uid="MouseWithoutBorders_ReconnectTooltip" TextWrapping="Wrap" />
|
||||
</ToolTipService.ToolTip>
|
||||
@@ -210,7 +210,7 @@
|
||||
Name="MouseWithoutBordersUninstallService"
|
||||
x:Uid="MouseWithoutBorders_UninstallService"
|
||||
ActionIcon="{ui:FontIcon Glyph=}"
|
||||
Click="UninstallServiceButton_Click"
|
||||
Command="{x:Bind ViewModel.UninstallServiceEventHandler}"
|
||||
IsClickEnabled="{x:Bind ViewModel.CanUninstallService, Mode=OneWay}"
|
||||
IsEnabled="{x:Bind ViewModel.CanUninstallService, Mode=OneWay}" />
|
||||
</controls:SettingsGroup>
|
||||
@@ -476,7 +476,7 @@
|
||||
Name="MouseWithoutBordersAddFirewallRuleButtonControl"
|
||||
x:Uid="MouseWithoutBorders_AddFirewallRuleButtonControl"
|
||||
ActionIcon="{ui:FontIcon Glyph=}"
|
||||
Click="AddFirewallRuleButton_Click"
|
||||
Command="{x:Bind ViewModel.AddFirewallRuleEventHandler}"
|
||||
IsClickEnabled="True" />
|
||||
<controls:GPOInfoControl ShowWarning="{x:Bind ViewModel.ShowPolicyConfiguredInfoForOriginalUiSetting, Mode=OneWay}">
|
||||
<tkcontrols:SettingsCard
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
using System;
|
||||
using System.IO.Abstractions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
||||
@@ -170,40 +171,5 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
{
|
||||
ViewModel.RefreshEnabledState();
|
||||
}
|
||||
|
||||
private void ConnectButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ConnectCommand?.Execute(null);
|
||||
}
|
||||
|
||||
private void GenerateNewKeyButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
GenerateNewKeyCommand?.Execute(null);
|
||||
}
|
||||
|
||||
private void ShowConnectFieldsButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ShowConnectFieldsCommand?.Execute(null);
|
||||
}
|
||||
|
||||
private void CopyPCNameButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
CopyPCNameCommand?.Execute(null);
|
||||
}
|
||||
|
||||
private void ReconnectButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ReconnectCommand?.Execute(null);
|
||||
}
|
||||
|
||||
private void UninstallServiceButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.UninstallServiceEventHandler?.Execute(null);
|
||||
}
|
||||
|
||||
private void AddFirewallRuleButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.AddFirewallRuleEventHandler?.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,15 +25,5 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
{
|
||||
ViewModel.RefreshEnabledState();
|
||||
}
|
||||
|
||||
private void InstallTemplatePackageButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.OpenCurrentNewTemplateFolder?.Execute(null);
|
||||
}
|
||||
|
||||
private void UninstallTemplatePackageButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.PickAnotherNewTemplateFolder?.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
}
|
||||
}
|
||||
|
||||
// AOT-compatible type lookup using switch expression instead of reflection (IL2026)
|
||||
private Type GetPageTypeFromName(string pageTypeName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pageTypeName))
|
||||
@@ -88,41 +87,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
return null;
|
||||
}
|
||||
|
||||
return pageTypeName switch
|
||||
{
|
||||
nameof(DashboardPage) => typeof(DashboardPage),
|
||||
nameof(GeneralPage) => typeof(GeneralPage),
|
||||
nameof(AdvancedPastePage) => typeof(AdvancedPastePage),
|
||||
nameof(AlwaysOnTopPage) => typeof(AlwaysOnTopPage),
|
||||
nameof(AwakePage) => typeof(AwakePage),
|
||||
nameof(CmdNotFoundPage) => typeof(CmdNotFoundPage),
|
||||
nameof(CmdPalPage) => typeof(CmdPalPage),
|
||||
nameof(ColorPickerPage) => typeof(ColorPickerPage),
|
||||
nameof(CropAndLockPage) => typeof(CropAndLockPage),
|
||||
nameof(EnvironmentVariablesPage) => typeof(EnvironmentVariablesPage),
|
||||
nameof(FancyZonesPage) => typeof(FancyZonesPage),
|
||||
nameof(FileLocksmithPage) => typeof(FileLocksmithPage),
|
||||
nameof(HostsPage) => typeof(HostsPage),
|
||||
nameof(ImageResizerPage) => typeof(ImageResizerPage),
|
||||
nameof(KeyboardManagerPage) => typeof(KeyboardManagerPage),
|
||||
nameof(LightSwitchPage) => typeof(LightSwitchPage),
|
||||
nameof(MeasureToolPage) => typeof(MeasureToolPage),
|
||||
nameof(MouseUtilsPage) => typeof(MouseUtilsPage),
|
||||
nameof(MouseWithoutBordersPage) => typeof(MouseWithoutBordersPage),
|
||||
nameof(NewPlusPage) => typeof(NewPlusPage),
|
||||
nameof(PeekPage) => typeof(PeekPage),
|
||||
nameof(PowerAccentPage) => typeof(PowerAccentPage),
|
||||
nameof(PowerLauncherPage) => typeof(PowerLauncherPage),
|
||||
nameof(PowerOcrPage) => typeof(PowerOcrPage),
|
||||
nameof(PowerPreviewPage) => typeof(PowerPreviewPage),
|
||||
nameof(PowerRenamePage) => typeof(PowerRenamePage),
|
||||
nameof(PowerDisplayPage) => typeof(PowerDisplayPage),
|
||||
nameof(RegistryPreviewPage) => typeof(RegistryPreviewPage),
|
||||
nameof(ShortcutGuidePage) => typeof(ShortcutGuidePage),
|
||||
nameof(WorkspacesPage) => typeof(WorkspacesPage),
|
||||
nameof(ZoomItPage) => typeof(ZoomItPage),
|
||||
_ => null,
|
||||
};
|
||||
var assembly = typeof(GeneralPage).Assembly;
|
||||
return assembly.GetType($"Microsoft.PowerToys.Settings.UI.Views.{pageTypeName}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,6 @@
|
||||
IsPaneToggleButtonVisible="False"
|
||||
IsSettingsVisible="False"
|
||||
IsTitleBarAutoPaddingEnabled="False"
|
||||
ItemInvoked="NavigationView_ItemInvoked"
|
||||
PaneClosed="NavigationView_PaneClosed"
|
||||
PaneOpened="NavigationView_PaneOpened"
|
||||
SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}"
|
||||
@@ -448,7 +447,11 @@
|
||||
Visibility="{x:Bind ViewModel.ShowCloseMenu, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</NavigationView.PaneFooter>
|
||||
<!-- Direct event handler instead of InvokeCommandAction for AOT compatibility -->
|
||||
<i:Interaction.Behaviors>
|
||||
<ic:EventTriggerBehavior EventName="ItemInvoked">
|
||||
<ic:InvokeCommandAction Command="{x:Bind ViewModel.ItemInvokedCommand}" />
|
||||
</ic:EventTriggerBehavior>
|
||||
</i:Interaction.Behaviors>
|
||||
<Frame x:Name="shellFrame" />
|
||||
</NavigationView>
|
||||
<ContentDialog
|
||||
|
||||
@@ -338,19 +338,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
OpenWhatIsNewWindowCallback();
|
||||
}
|
||||
|
||||
private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
|
||||
{
|
||||
// Direct event handler for AOT compatibility (InvokeCommandAction doesn't work reliably with AOT)
|
||||
if (args?.InvokedItemContainer != null)
|
||||
{
|
||||
var pageType = args.InvokedItemContainer.GetValue(NavHelper.NavigateToProperty) as Type;
|
||||
if (pageType != null)
|
||||
{
|
||||
NavigationService.Navigate(pageType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
||||
{
|
||||
NavigationViewItem selectedItem = args.SelectedItem as NavigationViewItem;
|
||||
@@ -548,7 +535,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
}
|
||||
}
|
||||
|
||||
// AOT-compatible type lookup using switch expression instead of reflection (IL2026)
|
||||
private static Type GetPageTypeFromName(string pageTypeName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pageTypeName))
|
||||
@@ -556,41 +542,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
return null;
|
||||
}
|
||||
|
||||
return pageTypeName switch
|
||||
{
|
||||
nameof(DashboardPage) => typeof(DashboardPage),
|
||||
nameof(GeneralPage) => typeof(GeneralPage),
|
||||
nameof(AdvancedPastePage) => typeof(AdvancedPastePage),
|
||||
nameof(AlwaysOnTopPage) => typeof(AlwaysOnTopPage),
|
||||
nameof(AwakePage) => typeof(AwakePage),
|
||||
nameof(CmdNotFoundPage) => typeof(CmdNotFoundPage),
|
||||
nameof(CmdPalPage) => typeof(CmdPalPage),
|
||||
nameof(ColorPickerPage) => typeof(ColorPickerPage),
|
||||
nameof(CropAndLockPage) => typeof(CropAndLockPage),
|
||||
nameof(EnvironmentVariablesPage) => typeof(EnvironmentVariablesPage),
|
||||
nameof(FancyZonesPage) => typeof(FancyZonesPage),
|
||||
nameof(FileLocksmithPage) => typeof(FileLocksmithPage),
|
||||
nameof(HostsPage) => typeof(HostsPage),
|
||||
nameof(ImageResizerPage) => typeof(ImageResizerPage),
|
||||
nameof(KeyboardManagerPage) => typeof(KeyboardManagerPage),
|
||||
nameof(LightSwitchPage) => typeof(LightSwitchPage),
|
||||
nameof(MeasureToolPage) => typeof(MeasureToolPage),
|
||||
nameof(MouseUtilsPage) => typeof(MouseUtilsPage),
|
||||
nameof(MouseWithoutBordersPage) => typeof(MouseWithoutBordersPage),
|
||||
nameof(NewPlusPage) => typeof(NewPlusPage),
|
||||
nameof(PeekPage) => typeof(PeekPage),
|
||||
nameof(PowerAccentPage) => typeof(PowerAccentPage),
|
||||
nameof(PowerLauncherPage) => typeof(PowerLauncherPage),
|
||||
nameof(PowerOcrPage) => typeof(PowerOcrPage),
|
||||
nameof(PowerPreviewPage) => typeof(PowerPreviewPage),
|
||||
nameof(PowerRenamePage) => typeof(PowerRenamePage),
|
||||
nameof(PowerDisplayPage) => typeof(PowerDisplayPage),
|
||||
nameof(RegistryPreviewPage) => typeof(RegistryPreviewPage),
|
||||
nameof(ShortcutGuidePage) => typeof(ShortcutGuidePage),
|
||||
nameof(WorkspacesPage) => typeof(WorkspacesPage),
|
||||
nameof(ZoomItPage) => typeof(ZoomItPage),
|
||||
_ => null,
|
||||
};
|
||||
var assembly = typeof(GeneralPage).Assembly;
|
||||
return assembly.GetType($"Microsoft.PowerToys.Settings.UI.Views.{pageTypeName}");
|
||||
}
|
||||
|
||||
private void CtrlF_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
|
||||
|
||||
@@ -50,8 +50,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
|
||||
private static LOGFONT PickFontDialog(LOGFONT font)
|
||||
{
|
||||
// Use generic overload for AOT compatibility (IL3050)
|
||||
IntPtr pLogFont = Marshal.AllocHGlobal(Marshal.SizeOf<LOGFONT>());
|
||||
IntPtr pLogFont = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LOGFONT)));
|
||||
if (font != null)
|
||||
{
|
||||
font.lfHeight = -21;
|
||||
@@ -73,16 +72,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
chooseFont.nSizeMin = 16;
|
||||
chooseFont.nSizeMax = 16;
|
||||
chooseFont.nFontType = 0x2000; // SCREEN_FONTTYPE as in the original ZoomIt source.
|
||||
|
||||
// Use IntPtr.Zero instead of Marshal.GetHINSTANCE for AOT compatibility (IL3002)
|
||||
// This works fine for ChooseFont dialog as the system will use the process HINSTANCE
|
||||
chooseFont.hInstance = IntPtr.Zero;
|
||||
chooseFont.hInstance = Marshal.GetHINSTANCE(typeof(ZoomItPage).Module);
|
||||
|
||||
// TODO: chooseFont.lpTemplateName = FORMATDLGORD31; and CHOOSE_FONT_FLAGS.CF_ENABLETEMPLATE
|
||||
chooseFont.lpLogFont = pLogFont;
|
||||
|
||||
// Use generic overload for AOT compatibility (IL3050)
|
||||
IntPtr pChooseFont = Marshal.AllocHGlobal(Marshal.SizeOf<CHOOSEFONT>());
|
||||
IntPtr pChooseFont = Marshal.AllocHGlobal(Marshal.SizeOf(chooseFont));
|
||||
Marshal.StructureToPtr(chooseFont, pChooseFont, false);
|
||||
|
||||
bool callResult = NativeMethods.ChooseFont(pChooseFont);
|
||||
|
||||
@@ -23,7 +23,7 @@ using Windows.Management.Deployment;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
public partial class CmdPalViewModel : PageViewModelBase
|
||||
public class CmdPalViewModel : PageViewModelBase
|
||||
{
|
||||
protected override string ModuleName => "CmdPal";
|
||||
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels.Commands
|
||||
{
|
||||
public partial class ButtonClickCommand : Microsoft.PowerToys.Settings.UI.Library.ICommand
|
||||
public partial class ButtonClickCommand : ICommand
|
||||
{
|
||||
private readonly Action _execute;
|
||||
|
||||
@@ -19,16 +17,16 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Commands
|
||||
}
|
||||
|
||||
// Occurs when changes occur that affect whether or not the command should execute.
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
// Defines the method that determines whether the command can execute in its current state.
|
||||
public bool CanExecute(object? parameter)
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Defines the method to be called when the command is invoked.
|
||||
public void Execute(object? parameter)
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
_execute();
|
||||
}
|
||||
|
||||
@@ -10,17 +10,16 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
|
||||
using Microsoft.PowerToys.Settings.Utilities;
|
||||
using Microsoft.Win32;
|
||||
using LibraryRelayCommand = Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands.RelayCommand;
|
||||
using NativeMethods = Microsoft.PowerToys.Settings.Utilities.NativeMethods;
|
||||
using RelayCommand = Microsoft.PowerToys.Settings.UI.Helpers.RelayCommand;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
using System.Windows.Input;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
/// <summary>
|
||||
/// ViewModel for monitor selection in profile editor
|
||||
/// </summary>
|
||||
public partial class MonitorSelectionItem : INotifyPropertyChanged
|
||||
public class MonitorSelectionItem : INotifyPropertyChanged
|
||||
{
|
||||
private bool _isSelected;
|
||||
private int _brightness = 100;
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
|
||||
@@ -21,7 +21,7 @@ using Settings.UI.Library;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
public partial class PeekViewModel : PageViewModelBase
|
||||
public class PeekViewModel : PageViewModelBase
|
||||
{
|
||||
protected override string ModuleName => PeekSettings.ModuleName;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
using System.Windows.Input;
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using ManagedCommon;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
/// <summary>
|
||||
/// ViewModel for Profile Editor Dialog
|
||||
/// </summary>
|
||||
public partial class ProfileEditorViewModel : INotifyPropertyChanged
|
||||
public class ProfileEditorViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private string _profileName = string.Empty;
|
||||
private ObservableCollection<MonitorSelectionItem> _monitors;
|
||||
|
||||
@@ -12,7 +12,7 @@ using Settings.UI.Library;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
public partial class SearchResultsViewModel : INotifyPropertyChanged
|
||||
public class SearchResultsViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private ObservableCollection<SettingEntry> _moduleResults = new();
|
||||
private ObservableCollection<SettingsGroup> _groupedSettingsResults = new();
|
||||
@@ -97,7 +97,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
|
||||
#pragma warning disable SA1402 // File may only contain a single type
|
||||
public partial class SettingsGroup : INotifyPropertyChanged
|
||||
public class SettingsGroup : INotifyPropertyChanged
|
||||
#pragma warning restore SA1402 // File may only contain a single type
|
||||
{
|
||||
private string _groupName;
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -14,6 +12,7 @@ using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json.Serialization.Metadata;
|
||||
using System.Windows.Threading;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
@@ -26,11 +25,11 @@ using Microsoft.Windows.ApplicationModel.Resources;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
public partial class ShortcutConflictViewModel : PageViewModelBase
|
||||
public class ShortcutConflictViewModel : PageViewModelBase
|
||||
{
|
||||
private readonly SettingsFactory _settingsFactory;
|
||||
private readonly Func<string, int> _ipcMSGCallBackFunc;
|
||||
private readonly Microsoft.UI.Dispatching.DispatcherQueue? _dispatcherQueue;
|
||||
private readonly Dispatcher _dispatcher;
|
||||
|
||||
private bool _disposed;
|
||||
private AllHotkeyConflictsData _conflictsData = new();
|
||||
@@ -42,8 +41,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
ISettingsRepository<GeneralSettings> settingsRepository,
|
||||
Func<string, int> ipcMSGCallBackFunc)
|
||||
{
|
||||
// Use WinUI 3 DispatcherQueue instead of WPF Dispatcher for AOT compatibility
|
||||
_dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
|
||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||
_ipcMSGCallBackFunc = ipcMSGCallBackFunc ?? throw new ArgumentNullException(nameof(ipcMSGCallBackFunc));
|
||||
resourceLoader = ResourceLoaderInstance.ResourceLoader;
|
||||
|
||||
@@ -65,7 +63,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
public ObservableCollection<HotkeyConflictGroupData> ConflictItems
|
||||
{
|
||||
get => _conflictItems ?? new ObservableCollection<HotkeyConflictGroupData>();
|
||||
get => _conflictItems;
|
||||
private set => Set(ref _conflictItems, value);
|
||||
}
|
||||
|
||||
@@ -119,14 +117,13 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error loading settings for {moduleKey}: {ex.Message}");
|
||||
return null!; // Suppress nullable warning - caller handles null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnConflictsUpdated(object sender, AllHotkeyConflictsEventArgs e)
|
||||
{
|
||||
// WinUI 3 DispatcherQueue uses TryEnqueue instead of BeginInvoke
|
||||
_dispatcherQueue?.TryEnqueue(() =>
|
||||
_dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
ConflictsData = e.Conflicts ?? new AllHotkeyConflictsData();
|
||||
});
|
||||
@@ -136,8 +133,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
var items = new ObservableCollection<HotkeyConflictGroupData>();
|
||||
|
||||
ProcessConflicts(ConflictsData?.InAppConflicts ?? Enumerable.Empty<HotkeyConflictGroupData>(), false, items);
|
||||
ProcessConflicts(ConflictsData?.SystemConflicts ?? Enumerable.Empty<HotkeyConflictGroupData>(), true, items);
|
||||
ProcessConflicts(ConflictsData?.InAppConflicts, false, items);
|
||||
ProcessConflicts(ConflictsData?.SystemConflicts, true, items);
|
||||
|
||||
ConflictItems = items;
|
||||
OnPropertyChanged(nameof(ConflictItems));
|
||||
@@ -221,7 +218,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
settings.IsSystemConflict = isSystemConflict;
|
||||
}
|
||||
|
||||
private void OnModuleHotkeyDataPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
private void OnModuleHotkeyDataPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is ModuleHotkeyData moduleData && e.PropertyName == nameof(ModuleHotkeyData.HotkeySettings))
|
||||
{
|
||||
@@ -275,8 +272,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
// Use source-generated serializer for AOT compatibility (IL2026/IL3050)
|
||||
var serializedSettings = SerializeSettings(settingsConfig);
|
||||
var jsonTypeInfo = GetJsonTypeInfo(settingsConfig.GetType());
|
||||
var serializedSettings = jsonTypeInfo != null
|
||||
? JsonSerializer.Serialize(settingsConfig, jsonTypeInfo)
|
||||
: JsonSerializer.Serialize(settingsConfig);
|
||||
|
||||
string ipcMessage;
|
||||
if (string.Equals(moduleName, "GeneralSettings", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -304,43 +303,30 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
// AOT-compatible serialization using source-generated context
|
||||
private string SerializeSettings(ISettingsConfig settingsConfig)
|
||||
private JsonTypeInfo GetJsonTypeInfo(Type settingsType)
|
||||
{
|
||||
return settingsConfig switch
|
||||
try
|
||||
{
|
||||
GeneralSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.GeneralSettings),
|
||||
AdvancedPasteSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.AdvancedPasteSettings),
|
||||
AlwaysOnTopSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.AlwaysOnTopSettings),
|
||||
AwakeSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.AwakeSettings),
|
||||
CmdNotFoundSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.CmdNotFoundSettings),
|
||||
ColorPickerSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.ColorPickerSettings),
|
||||
CropAndLockSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.CropAndLockSettings),
|
||||
EnvironmentVariablesSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.EnvironmentVariablesSettings),
|
||||
FancyZonesSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.FancyZonesSettings),
|
||||
FileLocksmithSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.FileLocksmithSettings),
|
||||
HostsSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.HostsSettings),
|
||||
ImageResizerSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.ImageResizerSettings),
|
||||
KeyboardManagerSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.KeyboardManagerSettings),
|
||||
LightSwitchSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.LightSwitchSettings),
|
||||
MeasureToolSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.MeasureToolSettings),
|
||||
MouseWithoutBordersSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.MouseWithoutBordersSettings),
|
||||
NewPlusSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.NewPlusSettings),
|
||||
PeekSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.PeekSettings),
|
||||
PowerAccentSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.PowerAccentSettings),
|
||||
PowerDisplaySettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.PowerDisplaySettings),
|
||||
PowerLauncherSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.PowerLauncherSettings),
|
||||
PowerOcrSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.PowerOcrSettings),
|
||||
PowerPreviewSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.PowerPreviewSettings),
|
||||
PowerRenameSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.PowerRenameSettings),
|
||||
RegistryPreviewSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.RegistryPreviewSettings),
|
||||
ShortcutGuideSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.ShortcutGuideSettings),
|
||||
WorkspacesSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.WorkspacesSettings),
|
||||
ZoomItSettings s => JsonSerializer.Serialize(s, SettingsSerializationContext.Default.ZoomItSettings),
|
||||
var contextType = typeof(SourceGenerationContextContext);
|
||||
var defaultProperty = contextType.GetProperty("Default", BindingFlags.Public | BindingFlags.Static);
|
||||
var defaultContext = defaultProperty?.GetValue(null) as JsonSerializerContext;
|
||||
|
||||
// If we hit this case, SettingsSerializationContext is incomplete - this should be caught in development
|
||||
_ => throw new InvalidOperationException($"Settings type {settingsConfig.GetType().Name} is not registered in SettingsSerializationContext. Please add [JsonSerializable(typeof({settingsConfig.GetType().Name}))] to the context."),
|
||||
};
|
||||
if (defaultContext != null)
|
||||
{
|
||||
var typeInfoProperty = contextType.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||
.FirstOrDefault(p => p.PropertyType.IsGenericType &&
|
||||
p.PropertyType.GetGenericTypeDefinition() == typeof(JsonTypeInfo<>) &&
|
||||
p.PropertyType.GetGenericArguments()[0] == settingsType);
|
||||
|
||||
return typeInfoProperty?.GetValue(defaultContext) as JsonTypeInfo;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error getting JsonTypeInfo for {settingsType.Name}: {ex.Message}");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetHotkeyLocalizationHeader(string moduleName, int hotkeyID, string headerKey)
|
||||
|
||||
@@ -22,7 +22,7 @@ using Windows.Devices.Enumeration;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
public partial class ZoomItViewModel : Observable
|
||||
public class ZoomItViewModel : Observable
|
||||
{
|
||||
private const string FormatGif = "GIF";
|
||||
private const string FormatMp4 = "MP4";
|
||||
@@ -66,6 +66,12 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||
{
|
||||
MaxDepth = 0,
|
||||
IncludeFields = true,
|
||||
};
|
||||
|
||||
public ZoomItViewModel(SettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, Func<string, int> ipcMSGCallBackFunc, Func<string, string, string, int, string> pickFileDialog, Func<LOGFONT, LOGFONT> pickFontDialog)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(settingsUtils);
|
||||
@@ -78,9 +84,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
||||
|
||||
var zoomItSettings = global::PowerToys.ZoomItSettingsInterop.ZoomItSettings.LoadSettingsJson();
|
||||
|
||||
// Use source-generated deserializer for AOT compatibility (IL2026/IL3050)
|
||||
_zoomItSettings = JsonSerializer.Deserialize(zoomItSettings, SettingsSerializationContext.Default.ZoomItSettings);
|
||||
_zoomItSettings = JsonSerializer.Deserialize<ZoomItSettings>(zoomItSettings, _serializerOptions);
|
||||
|
||||
InitializeEnabledValue();
|
||||
|
||||
@@ -420,7 +424,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
var encodedFont = _zoomItSettings.Properties.Font.Value;
|
||||
byte[] decodedFont = Convert.FromBase64String(encodedFont);
|
||||
int size = Marshal.SizeOf<LOGFONT>();
|
||||
int size = Marshal.SizeOf(typeof(LOGFONT));
|
||||
if (size != decodedFont.Length)
|
||||
{
|
||||
throw new InvalidOperationException("Expected byte array from saved Settings doesn't match the LOGFONT structure size");
|
||||
@@ -434,8 +438,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
Marshal.Copy(decodedFont, 0, ptr, size);
|
||||
|
||||
// Marshal the unmanaged memory back to a LOGFONT structure
|
||||
// Use generic overload for AOT compatibility
|
||||
return Marshal.PtrToStructure<LOGFONT>(ptr);
|
||||
return (LOGFONT)Marshal.PtrToStructure(ptr, typeof(LOGFONT));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -447,7 +450,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
set
|
||||
{
|
||||
_typeFont = value;
|
||||
int size = Marshal.SizeOf<LOGFONT>();
|
||||
int size = Marshal.SizeOf(typeof(LOGFONT));
|
||||
byte[] bytes = new byte[size];
|
||||
|
||||
// Allocate unmanaged memory for the LOGFONT structure
|
||||
@@ -837,9 +840,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
// Reload settings to get the new format's scaling value
|
||||
var reloadedSettings = global::PowerToys.ZoomItSettingsInterop.ZoomItSettings.LoadSettingsJson();
|
||||
|
||||
// Use source-generated deserializer for AOT compatibility (IL2026/IL3050)
|
||||
var reloaded = JsonSerializer.Deserialize(reloadedSettings, SettingsSerializationContext.Default.ZoomItSettings);
|
||||
var reloaded = JsonSerializer.Deserialize<ZoomItSettings>(reloadedSettings, _serializerOptions);
|
||||
if (reloaded != null && reloaded.Properties != null)
|
||||
{
|
||||
_zoomItSettings.Properties.RecordScaling.Value = reloaded.Properties.RecordScaling.Value;
|
||||
@@ -893,9 +894,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
private void NotifySettingsChanged()
|
||||
{
|
||||
// Use source-generated serializer for AOT compatibility (IL2026/IL3050)
|
||||
global::PowerToys.ZoomItSettingsInterop.ZoomItSettings.SaveSettingsJson(
|
||||
JsonSerializer.Serialize(_zoomItSettings, SettingsSerializationContext.Default.ZoomItSettings));
|
||||
JsonSerializer.Serialize(_zoomItSettings));
|
||||
SendCustomAction("refresh_settings");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user