mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[GPO] Add policies for configuring utilities enabled states (#21411)
* Add GPOWrapper headers and C++/WinRT library * Check GPO before starting utilities * Show message on GPO having disabled preview panes. * Don't generate thumbnails if GPO disabled * Fix FancyZonesEditor unable to recognize GPOWrapper * Move settings view models to the settings project * Use GPO to block enabling utilities in Settings * Hide context menu entries when gpo disables utilities * Apply gpo policies when enabling PowerToys on runner * Add version and metadata to dll * Add GPOWrapper to the installer * Fix MSBuild errors on WPF apps by using Projection * Signing * Add gpo files and publish them * Add GPO policies to the bug report tool * Add some documentation for using GPO * Mention support to actual lowest supported version of Windows * Move PowerToys to the root of administrative templates tree * Save policies on Software\Policies\PowerToys * Support both machine and user scopes * Fix documentation to reference computer and user scopes * Mention incompatibility with outlook in gpo * Set a better folder structure for gpo assets * Move PDF Handler warning to the description * Update doc/gpo/README.md Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com> * Add actual minimum version of PowerToys to gpo files * Fix identation * Remove GPOWrapper Readme * Add Active Directory instructions to doc Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
This commit is contained in:
111
src/common/GPOWrapper/GPOWrapper.cpp
Normal file
111
src/common/GPOWrapper/GPOWrapper.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
#include "pch.h"
|
||||
#include "GPOWrapper.h"
|
||||
#include "GPOWrapper.g.cpp"
|
||||
|
||||
namespace winrt::PowerToys::GPOWrapper::implementation
|
||||
{
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredAlwaysOnTopEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredAlwaysOnTopEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredAwakeEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredAwakeEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredColorPickerEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredColorPickerEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredFancyZonesEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredFancyZonesEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredSvgPreviewEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredSvgPreviewEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredMarkdownPreviewEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredMarkdownPreviewEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredMonacoPreviewEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredMonacoPreviewEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredPdfPreviewEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredPdfPreviewEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredGcodePreviewEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredGcodePreviewEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredSvgThumbnailsEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredSvgThumbnailsEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredPdfThumbnailsEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredPdfThumbnailsEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredGcodeThumbnailsEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredGcodeThumbnailsEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredStlThumbnailsEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredStlThumbnailsEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredHostsFileEditorEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredHostsFileEditorEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredImageResizerEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredImageResizerEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredKeyboardManagerEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredKeyboardManagerEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredFindMyMouseEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredFindMyMouseEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredMouseHighlighterEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredMouseHightlighterEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredMousePointerCrosshairsEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredMousePointerCrosshairsEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredPowerRenameEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredPowerRenameEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredPowerLauncherEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredPowerLauncherEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredQuickAccentEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredQuickAccentEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredScreenRulerEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredScreenRulerEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredShortcutGuideEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredShortcutGuideEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredTextExtractorEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredTextExtractorEnabledValue();
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetConfiguredVideoConferenceMuteEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)powertoys_gpo::getConfiguredVideoConferenceMuteEnabledValue();
|
||||
}
|
||||
}
|
||||
3
src/common/GPOWrapper/GPOWrapper.def
Normal file
3
src/common/GPOWrapper/GPOWrapper.def
Normal file
@@ -0,0 +1,3 @@
|
||||
EXPORTS
|
||||
DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
|
||||
DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
|
||||
44
src/common/GPOWrapper/GPOWrapper.h
Normal file
44
src/common/GPOWrapper/GPOWrapper.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include "GPOWrapper.g.h"
|
||||
#include <common/utils/gpo.h>
|
||||
|
||||
namespace winrt::PowerToys::GPOWrapper::implementation
|
||||
{
|
||||
struct GPOWrapper : GPOWrapperT<GPOWrapper>
|
||||
{
|
||||
GPOWrapper() = default;
|
||||
static GpoRuleConfigured GetConfiguredAlwaysOnTopEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredAwakeEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredColorPickerEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredFancyZonesEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredSvgPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredMarkdownPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredMonacoPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPdfPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredGcodePreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredSvgThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPdfThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredGcodeThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredStlThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredHostsFileEditorEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredImageResizerEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredKeyboardManagerEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredFindMyMouseEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredMouseHighlighterEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredMousePointerCrosshairsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPowerRenameEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPowerLauncherEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredQuickAccentEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredScreenRulerEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredShortcutGuideEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredTextExtractorEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredVideoConferenceMuteEnabledValue();
|
||||
};
|
||||
}
|
||||
|
||||
namespace winrt::PowerToys::GPOWrapper::factory_implementation
|
||||
{
|
||||
struct GPOWrapper : GPOWrapperT<GPOWrapper, implementation::GPOWrapper>
|
||||
{
|
||||
};
|
||||
}
|
||||
42
src/common/GPOWrapper/GPOWrapper.idl
Normal file
42
src/common/GPOWrapper/GPOWrapper.idl
Normal file
@@ -0,0 +1,42 @@
|
||||
namespace PowerToys
|
||||
{
|
||||
namespace GPOWrapper
|
||||
{
|
||||
enum GpoRuleConfigured
|
||||
{
|
||||
WrongValue = -3,
|
||||
Unavailable = -2,
|
||||
NotConfigured = -1,
|
||||
Disabled = 0,
|
||||
Enabled = 1
|
||||
};
|
||||
[default_interface] static runtimeclass GPOWrapper {
|
||||
static GpoRuleConfigured GetConfiguredAlwaysOnTopEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredAwakeEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredColorPickerEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredFancyZonesEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredSvgPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredMarkdownPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredMonacoPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPdfPreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredGcodePreviewEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredSvgThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPdfThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredGcodeThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredStlThumbnailsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredHostsFileEditorEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredImageResizerEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredKeyboardManagerEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredFindMyMouseEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredMouseHighlighterEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredMousePointerCrosshairsEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPowerRenameEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredPowerLauncherEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredQuickAccentEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredScreenRulerEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredShortcutGuideEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredTextExtractorEnabledValue();
|
||||
static GpoRuleConfigured GetConfiguredVideoConferenceMuteEnabledValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
40
src/common/GPOWrapper/GPOWrapper.rc
Normal file
40
src/common/GPOWrapper/GPOWrapper.rc
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
#include "../../../common/version/version.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
#include "winres.h"
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
1 VERSIONINFO
|
||||
FILEVERSION FILE_VERSION
|
||||
PRODUCTVERSION PRODUCT_VERSION
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0" // US English (0x0409), Unicode (0x04B0) charset
|
||||
BEGIN
|
||||
VALUE "CompanyName", COMPANY_NAME
|
||||
VALUE "FileDescription", FILE_DESCRIPTION
|
||||
VALUE "FileVersion", FILE_VERSION_STRING
|
||||
VALUE "InternalName", INTERNAL_NAME
|
||||
VALUE "LegalCopyright", COPYRIGHT_NOTE
|
||||
VALUE "OriginalFilename", ORIGINAL_FILENAME
|
||||
VALUE "ProductName", PRODUCT_NAME
|
||||
VALUE "ProductVersion", PRODUCT_VERSION_STRING
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200 // US English (0x0409), Unicode (1200) charset
|
||||
END
|
||||
END
|
||||
127
src/common/GPOWrapper/GPOWrapper.vcxproj
Normal file
127
src/common/GPOWrapper/GPOWrapper.vcxproj
Normal file
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220929.3\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220929.3\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<CppWinRTOptimized>true</CppWinRTOptimized>
|
||||
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
|
||||
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
|
||||
<MinimalCoreWin>true</MinimalCoreWin>
|
||||
<ProjectGuid>{e599c30b-9dc8-4e5a-bf27-93d4ccede788}</ProjectGuid>
|
||||
<ProjectName>GPOWrapper</ProjectName>
|
||||
<RootNamespace>PowerToys.GPOWrapper</RootNamespace>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
<AppContainerApplication>false</AppContainerApplication>
|
||||
<AppxPackage>false</AppxPackage>
|
||||
<ApplicationType>Windows Store</ApplicationType>
|
||||
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
||||
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.20348.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<DesktopCompatible>true</DesktopCompatible>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="PropertySheet.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<TargetName>PowerToys.GPOWrapper</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
|
||||
<PreprocessorDefinitions>_WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
|
||||
<ModuleDefinitionFile>GPOWrapper.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="GPOWrapper.h">
|
||||
<DependentUpon>GPOWrapper.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GPOWrapper.cpp">
|
||||
<DependentUpon>GPOWrapper.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="GPOWrapper.idl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="GPOWrapper.def" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="PropertySheet.props" />
|
||||
<Text Include="readme.txt">
|
||||
<DeploymentContent>false</DeploymentContent>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="GPOWrapper.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220929.3\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220929.3\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220929.3\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220929.3\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220929.3\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.220929.3\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
39
src/common/GPOWrapper/GPOWrapper.vcxproj.filters
Normal file
39
src/common/GPOWrapper/GPOWrapper.vcxproj.filters
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Resources">
|
||||
<UniqueIdentifier>accd3aa8-1ba0-4223-9bbe-0c431709210b</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Generated Files">
|
||||
<UniqueIdentifier>{926ab91d-31b4-48c3-b9a4-e681349f27f0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="GPOWrapper.cpp" />
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="GPOWrapper.idl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="GPOWrapper.def" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="PropertySheet.props" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="readme.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="GPOWrapper.rc">
|
||||
<Filter>Resources</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
16
src/common/GPOWrapper/PropertySheet.props
Normal file
16
src/common/GPOWrapper/PropertySheet.props
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<!--
|
||||
To customize common C++/WinRT project properties:
|
||||
* right-click the project node
|
||||
* expand the Common Properties item
|
||||
* select the C++/WinRT property page
|
||||
|
||||
For more advanced scenarios, and complete documentation, please see:
|
||||
https://github.com/Microsoft/cppwinrt/tree/master/nuget
|
||||
-->
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup />
|
||||
</Project>
|
||||
4
src/common/GPOWrapper/packages.config
Normal file
4
src/common/GPOWrapper/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.220929.3" targetFramework="native" />
|
||||
</packages>
|
||||
1
src/common/GPOWrapper/pch.cpp
Normal file
1
src/common/GPOWrapper/pch.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "pch.h"
|
||||
4
src/common/GPOWrapper/pch.h
Normal file
4
src/common/GPOWrapper/pch.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
#include <unknwn.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
13
src/common/GPOWrapper/resource.h
Normal file
13
src/common/GPOWrapper/resource.h
Normal file
@@ -0,0 +1,13 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by PowerToys.MeasureToolCore.rc
|
||||
|
||||
//////////////////////////////
|
||||
// Non-localizable
|
||||
|
||||
#define FILE_DESCRIPTION "PowerToys GPOWrapper"
|
||||
#define INTERNAL_NAME "PowerToys.GPOWrapper"
|
||||
#define ORIGINAL_FILENAME "PowerToys.GPOWrapper.dll"
|
||||
|
||||
// Non-localizable
|
||||
//////////////////////////////
|
||||
45
src/common/GPOWrapperProjection/GPOWrapper.cs
Normal file
45
src/common/GPOWrapperProjection/GPOWrapper.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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 PowerToys.GPOWrapperProjection
|
||||
{
|
||||
public enum GpoRuleConfigured : int
|
||||
{
|
||||
WrongValue = PowerToys.GPOWrapper.GpoRuleConfigured.WrongValue,
|
||||
Unavailable = PowerToys.GPOWrapper.GpoRuleConfigured.Unavailable,
|
||||
NotConfigured = PowerToys.GPOWrapper.GpoRuleConfigured.NotConfigured,
|
||||
Disabled = PowerToys.GPOWrapper.GpoRuleConfigured.Disabled,
|
||||
Enabled = PowerToys.GPOWrapper.GpoRuleConfigured.Enabled,
|
||||
}
|
||||
|
||||
// Some WPF applications have trouble consuming WinRT/C++ projections, because WPF makes an intermediary _wpftmp.csproj which doesn't build projections correctly on MSBUILD.
|
||||
// This is a workaround to give access to GPOWrapper for WPF applications.
|
||||
public static class GPOWrapper
|
||||
{
|
||||
public static GpoRuleConfigured GetConfiguredPowerLauncherEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)PowerToys.GPOWrapper.GPOWrapper.GetConfiguredPowerLauncherEnabledValue();
|
||||
}
|
||||
|
||||
public static GpoRuleConfigured GetConfiguredFancyZonesEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)PowerToys.GPOWrapper.GPOWrapper.GetConfiguredFancyZonesEnabledValue();
|
||||
}
|
||||
|
||||
public static GpoRuleConfigured GetConfiguredColorPickerEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)PowerToys.GPOWrapper.GPOWrapper.GetConfiguredColorPickerEnabledValue();
|
||||
}
|
||||
|
||||
public static GpoRuleConfigured GetConfiguredImageResizerEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)PowerToys.GPOWrapper.GPOWrapper.GetConfiguredImageResizerEnabledValue();
|
||||
}
|
||||
|
||||
public static GpoRuleConfigured GetConfiguredTextExtractorEnabledValue()
|
||||
{
|
||||
return (GpoRuleConfigured)PowerToys.GPOWrapper.GPOWrapper.GetConfiguredTextExtractorEnabledValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
28
src/common/GPOWrapperProjection/GPOWrapperProjection.csproj
Normal file
28
src/common/GPOWrapperProjection/GPOWrapperProjection.csproj
Normal file
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\Version.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<TargetName>PowerToys.GPOWrapperProjection</TargetName>
|
||||
<RootNamespace>PowerToys.GPOWrapperProjection</RootNamespace>
|
||||
<AssemblyName>PowerToys.GPOWrapperProjection</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GPOWrapper\GPOWrapper.vcxproj">
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
232
src/common/utils/gpo.h
Normal file
232
src/common/utils/gpo.h
Normal file
@@ -0,0 +1,232 @@
|
||||
#pragma once
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
namespace powertoys_gpo {
|
||||
enum gpo_rule_configured_t {
|
||||
gpo_rule_configured_wrong_value = -3, // The policy is set to an unrecognized value
|
||||
gpo_rule_configured_unavailable = -2, // Couldn't access registry
|
||||
gpo_rule_configured_not_configured = -1, // Policy is not configured
|
||||
gpo_rule_configured_disabled = 0, // Policy is disabled
|
||||
gpo_rule_configured_enabled = 1, // Policy is enabled
|
||||
};
|
||||
|
||||
// Registry path where gpo policy values are stored.
|
||||
const std::wstring POLICIES_PATH = L"SOFTWARE\\Policies\\PowerToys";
|
||||
|
||||
// Registry scope where gpo policy values are stored.
|
||||
const HKEY POLICIES_SCOPE_MACHINE = HKEY_LOCAL_MACHINE;
|
||||
const HKEY POLICIES_SCOPE_USER = HKEY_CURRENT_USER;
|
||||
|
||||
// The registry value names for PowerToys utilities enabled and disabled policies.
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_ALWAYS_ON_TOP = L"ConfigureEnabledUtilityAlwaysOnTop";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_AWAKE = L"ConfigureEnabledUtilityAwake";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_COLOR_PICKER = L"ConfigureEnabledUtilityColorPicker";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_FANCYZONES = L"ConfigureEnabledUtilityFancyZones";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_SVG_PREVIEW = L"ConfigureEnabledUtilityFileExplorerSVGPreview";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_MARKDOWN_PREVIEW = L"ConfigureEnabledUtilityFileExplorerMarkdownPreview";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_MONACO_PREVIEW = L"ConfigureEnabledUtilityFileExplorerMonacoPreview";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_PDF_PREVIEW = L"ConfigureEnabledUtilityFileExplorerPDFPreview";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_GCODE_PREVIEW = L"ConfigureEnabledUtilityFileExplorerGcodePreview";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_SVG_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerSVGThumbnails";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_PDF_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerPDFThumbnails";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_GCODE_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerGcodeThumbnails";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_STL_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerSTLThumbnails";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_HOSTS_FILE_EDITOR = L"ConfigureEnabledUtilityHostsFileEditor";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_IMAGE_RESIZER = L"ConfigureEnabledUtilityImageResizer";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_KEYBOARD_MANAGER = L"ConfigureEnabledUtilityKeyboardManager";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_FIND_MY_MOUSE = L"ConfigureEnabledUtilityFindMyMouse";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_MOUSE_HIGHLIGHTER = L"ConfigureEnabledUtilityMouseHighlighter";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_MOUSE_POINTER_CROSSHAIRS = L"ConfigureEnabledUtilityMousePointerCrosshairs";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_POWER_RENAME = L"ConfigureEnabledUtilityPowerRename";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_POWER_LAUNCHER = L"ConfigureEnabledUtilityPowerLauncher";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_QUICK_ACCENT = L"ConfigureEnabledUtilityQuickAccent";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_SCREEN_RULER = L"ConfigureEnabledUtilityScreenRuler";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_SHORTCUT_GUIDE = L"ConfigureEnabledUtilityShortcutGuide";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_TEXT_EXTRACTOR = L"ConfigureEnabledUtilityTextExtractor";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_VIDEO_CONFERENCE_MUTE = L"ConfigureEnabledUtilityVideoConferenceMute";
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredValue(const std::wstring& registry_value_name)
|
||||
{
|
||||
HKEY key{};
|
||||
DWORD value = (DWORD) -2;
|
||||
DWORD valueSize = sizeof(value);
|
||||
|
||||
bool machine_key_found = true;
|
||||
if (auto res = RegOpenKeyExW(POLICIES_SCOPE_MACHINE, POLICIES_PATH.c_str(), 0, KEY_READ, &key); res != ERROR_SUCCESS)
|
||||
{
|
||||
machine_key_found = false;
|
||||
}
|
||||
|
||||
if(machine_key_found)
|
||||
{
|
||||
// If the path was found in the machine, we need to check if the value for the policy exists.
|
||||
auto res = RegQueryValueExW(key, registry_value_name.c_str(), nullptr, nullptr, (LPBYTE)&value, &valueSize);
|
||||
|
||||
RegCloseKey(key);
|
||||
|
||||
if (res != ERROR_SUCCESS) {
|
||||
// Value not found on the path.
|
||||
machine_key_found=false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!machine_key_found)
|
||||
{
|
||||
// If there's no value found on the machine scope, try to get it from the user scope.
|
||||
if (auto res = RegOpenKeyExW(POLICIES_SCOPE_USER, POLICIES_PATH.c_str(), 0, KEY_READ, &key); res != ERROR_SUCCESS)
|
||||
{
|
||||
if (res == ERROR_FILE_NOT_FOUND) {
|
||||
return gpo_rule_configured_not_configured;
|
||||
}
|
||||
return gpo_rule_configured_unavailable;
|
||||
}
|
||||
auto res = RegQueryValueExW(key, registry_value_name.c_str(), nullptr, nullptr, (LPBYTE)&value, &valueSize);
|
||||
RegCloseKey(key);
|
||||
|
||||
if (res != ERROR_SUCCESS) {
|
||||
return gpo_rule_configured_not_configured;
|
||||
}
|
||||
}
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
return gpo_rule_configured_disabled;
|
||||
case 1:
|
||||
return gpo_rule_configured_enabled;
|
||||
default:
|
||||
return gpo_rule_configured_wrong_value;
|
||||
}
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredAlwaysOnTopEnabledValue() {
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_ALWAYS_ON_TOP);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredAwakeEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_AWAKE);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredColorPickerEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_COLOR_PICKER);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredFancyZonesEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_FANCYZONES);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredSvgPreviewEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_SVG_PREVIEW);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredMarkdownPreviewEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_MARKDOWN_PREVIEW);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredMonacoPreviewEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_MONACO_PREVIEW);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredPdfPreviewEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_PDF_PREVIEW);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredGcodePreviewEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_GCODE_PREVIEW);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredSvgThumbnailsEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_SVG_THUMBNAILS);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredPdfThumbnailsEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_PDF_THUMBNAILS);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredGcodeThumbnailsEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_GCODE_THUMBNAILS);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredStlThumbnailsEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_STL_THUMBNAILS);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredHostsFileEditorEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_HOSTS_FILE_EDITOR);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredImageResizerEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_IMAGE_RESIZER);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredKeyboardManagerEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_KEYBOARD_MANAGER);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredFindMyMouseEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_FIND_MY_MOUSE);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredMouseHightlighterEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_MOUSE_HIGHLIGHTER);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredMousePointerCrosshairsEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_MOUSE_POINTER_CROSSHAIRS);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredPowerRenameEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_POWER_RENAME);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredPowerLauncherEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_POWER_LAUNCHER);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredQuickAccentEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_QUICK_ACCENT);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredScreenRulerEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_SCREEN_RULER);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredShortcutGuideEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_SHORTCUT_GUIDE);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredTextExtractorEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_TEXT_EXTRACTOR);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getConfiguredVideoConferenceMuteEnabledValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_VIDEO_CONFERENCE_MUTE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
|
||||
@@ -21,7 +21,13 @@
|
||||
<DefineConstants>DISABLE_XAML_GENERATED_MAIN,TRACE</DefineConstants>
|
||||
<ApplicationIcon>Assets/Hosts.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\AppList.scale-100.png" />
|
||||
<None Remove="Assets\AppList.scale-125.png" />
|
||||
@@ -31,6 +37,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||
@@ -47,6 +54,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\Common.UI\Common.UI.csproj" />
|
||||
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -16,6 +16,13 @@ namespace Hosts
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
WinRT.ComWrappersSupport.InitializeComWrappers();
|
||||
|
||||
if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredHostsFileEditorEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
return;
|
||||
}
|
||||
|
||||
var instanceKey = AppInstance.FindOrRegisterForKey("PowerToys_Hosts_Instance");
|
||||
|
||||
if (instanceKey.IsCurrent)
|
||||
|
||||
@@ -135,6 +135,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredHostsFileEditorEnabledValue();
|
||||
}
|
||||
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -174,6 +174,12 @@ public:
|
||||
return MODULE_NAME;
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredScreenRulerEnabledValue();
|
||||
}
|
||||
|
||||
// Return JSON with the configuration options.
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
|
||||
@@ -32,6 +32,13 @@ namespace MeasureToolUI
|
||||
/// <param name="args">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredScreenRulerEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
Environment.Exit(0); // Current.Exit won't work until there's a window opened.
|
||||
return;
|
||||
}
|
||||
|
||||
var cmdArgs = Environment.GetCommandLineArgs();
|
||||
if (cmdArgs?.Length > 1)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.MeasureToolCore</CsWinRTIncludes>
|
||||
<CsWinRTIncludes>PowerToys.MeasureToolCore;PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
@@ -79,6 +79,7 @@
|
||||
<Folder Include="Assets\Icons\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\interop\PowerToys.Interop.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||
<ProjectReference Include="..\MeasureToolCore\PowerToys.MeasureToolCore.vcxproj" />
|
||||
|
||||
@@ -93,6 +93,12 @@ public:
|
||||
return MODULE_NAME;
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredFindMyMouseEnabledValue();
|
||||
}
|
||||
|
||||
// Return JSON with the configuration options.
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
|
||||
@@ -84,6 +84,12 @@ public:
|
||||
return MODULE_NAME;
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredMouseHightlighterEnabledValue();
|
||||
}
|
||||
|
||||
// Return JSON with the configuration options.
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
|
||||
@@ -85,6 +85,12 @@ public:
|
||||
return MODULE_NAME;
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredMousePointerCrosshairsEnabledValue();
|
||||
}
|
||||
|
||||
// Return JSON with the configuration options.
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
|
||||
@@ -37,6 +37,13 @@ public partial class App : Application, IDisposable
|
||||
|
||||
private void Application_Startup(object sender, StartupEventArgs e)
|
||||
{
|
||||
if (PowerToys.GPOWrapperProjection.GPOWrapper.GetConfiguredTextExtractorEnabledValue() == PowerToys.GPOWrapperProjection.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
// allow only one instance of PowerOCR
|
||||
_instanceMutex = new Mutex(true, @"Local\PowerToys_PowerOCR_InstanceMutex", out bool createdNew);
|
||||
if (!createdNew)
|
||||
|
||||
@@ -39,11 +39,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="System.ComponentModel.Composition" Version="6.0.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapperProjection\GPOWrapperProjection.csproj" />
|
||||
<ProjectReference Include="..\..\..\common\Common.UI\Common.UI.csproj" />
|
||||
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -188,6 +188,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredTextExtractorEnabledValue();
|
||||
}
|
||||
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <common/utils/EventWaiter.h>
|
||||
#include <common/utils/gpo.h>
|
||||
|
||||
#include "shortcut_guide.h"
|
||||
#include "target_state.h"
|
||||
@@ -46,6 +47,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
{
|
||||
winrt::init_apartment();
|
||||
LoggerHelpers::init_logger(ShortcutGuideConstants::ModuleKey, L"ShortcutGuide", LogSettings::shortcutGuideLoggerName);
|
||||
|
||||
if (powertoys_gpo::getConfiguredShortcutGuideEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled)
|
||||
{
|
||||
Logger::warn(L"Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
InitUnhandledExceptionHandler();
|
||||
Logger::trace("Starting Shortcut Guide");
|
||||
|
||||
|
||||
@@ -48,6 +48,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredShortcutGuideEnabledValue();
|
||||
}
|
||||
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <common/utils/ProcessWaiter.h>
|
||||
#include <common/utils/window.h>
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
#include <common/utils/gpo.h>
|
||||
|
||||
#include <common/utils/logger_helper.h>
|
||||
|
||||
@@ -18,7 +19,14 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
{
|
||||
winrt::init_apartment();
|
||||
LoggerHelpers::init_logger(moduleName, internalPath, LogSettings::alwaysOnTopLoggerName);
|
||||
InitUnhandledExceptionHandler();
|
||||
|
||||
if (powertoys_gpo::getConfiguredAlwaysOnTopEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled)
|
||||
{
|
||||
Logger::warn(L"Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
InitUnhandledExceptionHandler();
|
||||
|
||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||
if (mutex == nullptr)
|
||||
|
||||
@@ -64,6 +64,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredAlwaysOnTopEnabledValue();
|
||||
}
|
||||
|
||||
// Return JSON with the configuration options.
|
||||
// These are the settings shown on the settings page along with their current values.
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
|
||||
@@ -21,6 +21,13 @@
|
||||
<AnalysisMode>Recommended</AnalysisMode>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
@@ -42,6 +49,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.46-beta">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
@@ -53,6 +61,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -61,6 +61,12 @@ namespace Awake
|
||||
// only one instance of Awake is running.
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredAwakeEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
Exit("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.", 1, _exitSignal, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LockMutex = new Mutex(true, InternalConstants.AppName, out bool instantiated);
|
||||
|
||||
if (!instantiated)
|
||||
|
||||
@@ -85,6 +85,12 @@ public:
|
||||
Logger::info("Launcher object is constructing");
|
||||
};
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredAwakeEnabledValue();
|
||||
}
|
||||
|
||||
virtual void destroy() override
|
||||
{
|
||||
delete this;
|
||||
|
||||
@@ -189,6 +189,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredColorPickerEnabledValue();
|
||||
}
|
||||
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<Resource Include="Shaders\GridShader.cso" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.6" />
|
||||
<PackageReference Include="System.ComponentModel.Composition" Version="6.0.0" />
|
||||
@@ -60,6 +61,7 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapperProjection\GPOWrapperProjection.csproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||
<ProjectReference Include="..\..\..\common\Common.UI\Common.UI.csproj" />
|
||||
|
||||
@@ -18,6 +18,13 @@ namespace ColorPicker
|
||||
{
|
||||
_args = args;
|
||||
Logger.LogInfo($"Color Picker started with pid={Environment.ProcessId}");
|
||||
|
||||
if (PowerToys.GPOWrapperProjection.GPOWrapper.GetConfiguredColorPickerEnabledValue() == PowerToys.GPOWrapperProjection.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
return;
|
||||
}
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
try
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <common/utils/ProcessWaiter.h>
|
||||
#include <common/utils/window.h>
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
#include <common/utils/gpo.h>
|
||||
|
||||
#include <FancyZonesLib/trace.h>
|
||||
#include <FancyZonesLib/Generated Files/resource.h>
|
||||
@@ -26,6 +27,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
{
|
||||
winrt::init_apartment();
|
||||
LoggerHelpers::init_logger(moduleName, internalPath, LogSettings::fancyZonesLoggerName);
|
||||
|
||||
if (powertoys_gpo::getConfiguredFancyZonesEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled)
|
||||
{
|
||||
Logger::warn(L"Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
InitUnhandledExceptionHandler();
|
||||
|
||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||
|
||||
@@ -51,6 +51,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredFancyZonesEnabledValue();
|
||||
}
|
||||
|
||||
// Return JSON with the configuration options.
|
||||
// These are the settings shown on the settings page along with their current values.
|
||||
virtual bool get_config(_Out_ PWSTR buffer, _Out_ int* buffer_size) override
|
||||
|
||||
@@ -66,6 +66,13 @@ namespace FancyZonesEditor
|
||||
|
||||
private void OnStartup(object sender, StartupEventArgs e)
|
||||
{
|
||||
if (PowerToys.GPOWrapperProjection.GPOWrapper.GetConfiguredFancyZonesEnabledValue() == PowerToys.GPOWrapperProjection.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
Shutdown(0);
|
||||
return;
|
||||
}
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
||||
|
||||
_themeManager = new ThemeManager(this);
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||
@@ -29,7 +28,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>images\FancyZonesEditor.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
@@ -47,6 +46,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.6" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="17.2.3" />
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.2" />
|
||||
@@ -55,6 +55,7 @@
|
||||
<Resource Include="images\FancyZonesEditor.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\common\GPOWrapperProjection\GPOWrapperProjection.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\common\interop\PowerToys.Interop.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\common\Common.UI\Common.UI.csproj" />
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/utils/gpo.h>
|
||||
|
||||
class CSettings
|
||||
{
|
||||
public:
|
||||
@@ -7,6 +9,11 @@ public:
|
||||
|
||||
inline bool GetEnabled()
|
||||
{
|
||||
auto gpoSetting = powertoys_gpo::getConfiguredImageResizerEnabledValue();
|
||||
if (gpoSetting == powertoys_gpo::gpo_rule_configured_enabled)
|
||||
return true;
|
||||
if (gpoSetting == powertoys_gpo::gpo_rule_configured_disabled)
|
||||
return false;
|
||||
Reload();
|
||||
return settings.enabled;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredImageResizerEnabledValue();
|
||||
}
|
||||
|
||||
// Return JSON with the configuration options.
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
|
||||
@@ -28,6 +28,16 @@ namespace ImageResizer
|
||||
{
|
||||
// Fix for .net 3.1.19 making Image Resizer not adapt to DPI changes.
|
||||
NativeMethods.SetProcessDPIAware();
|
||||
|
||||
if (PowerToys.GPOWrapperProjection.GPOWrapper.GetConfiguredImageResizerEnabledValue() == PowerToys.GPOWrapperProjection.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
/* TODO: Add logs to ImageResizer.
|
||||
* Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
*/
|
||||
Environment.Exit(0); // Current.Exit won't work until there's a window opened.
|
||||
return;
|
||||
}
|
||||
|
||||
var batch = ResizeBatch.FromCommandLine(Console.In, e?.Args);
|
||||
|
||||
// TODO: Add command-line parameters that can be used in lieu of the input page (issue #14)
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
@@ -45,6 +44,7 @@
|
||||
<Resource Include="Resources\ImageResizer.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.6" />
|
||||
<PackageReference Include="System.IO.Abstractions">
|
||||
@@ -53,6 +53,7 @@
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapperProjection\GPOWrapperProjection.csproj" />
|
||||
<ProjectReference Include="..\..\..\common\interop\PowerToys.Interop.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\Common.UI\Common.UI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <compare>
|
||||
#include <common/utils/gpo.h>
|
||||
|
||||
/*
|
||||
DLL Interface for PowerToys. The powertoy_create() (see below) must return
|
||||
@@ -112,6 +113,11 @@ public:
|
||||
|
||||
virtual bool is_enabled_by_default() const { return true; }
|
||||
|
||||
/* Provides the GPO configuration value for the module. This should be overriden by the module interface to get the proper gpo policy setting. */
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() {
|
||||
return powertoys_gpo::gpo_rule_configured_not_configured;
|
||||
}
|
||||
|
||||
protected:
|
||||
HANDLE CreateDefaultEvent(const wchar_t* eventName)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <common/utils/ProcessWaiter.h>
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
#include <common/utils/gpo.h>
|
||||
|
||||
#include <trace.h>
|
||||
|
||||
@@ -28,6 +29,13 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
|
||||
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Editor", LogSettings::keyboardManagerLoggerName);
|
||||
|
||||
if (powertoys_gpo::getConfiguredKeyboardManagerEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled)
|
||||
{
|
||||
Logger::warn(L"Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
InitUnhandledExceptionHandler();
|
||||
Trace::RegisterProvider();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <common/utils/winapi_error.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
#include <common/utils/gpo.h>
|
||||
#include <keyboardmanager/common/KeyboardManagerConstants.h>
|
||||
#include <keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.h>
|
||||
#include <keyboardmanager/KeyboardManagerEngineLibrary/trace.h>
|
||||
@@ -14,7 +15,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
{
|
||||
winrt::init_apartment();
|
||||
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Engine", LogSettings::keyboardManagerLoggerName);
|
||||
|
||||
|
||||
if (powertoys_gpo::getConfiguredKeyboardManagerEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled)
|
||||
{
|
||||
Logger::warn(L"Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
InitUnhandledExceptionHandler();
|
||||
|
||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||
|
||||
@@ -69,6 +69,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredKeyboardManagerEnabledValue();
|
||||
}
|
||||
|
||||
// Return JSON with the configuration options.
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
|
||||
@@ -152,6 +152,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredPowerLauncherEnabledValue();
|
||||
}
|
||||
|
||||
// Return JSON with the configuration options.
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
|
||||
<PackageReference Include="Mages" Version="2.0.1" />
|
||||
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
||||
|
||||
@@ -52,6 +52,12 @@ namespace PowerLauncher
|
||||
NativeThreadCTS = new CancellationTokenSource();
|
||||
|
||||
Log.Info($"Starting PowerToys Run with PID={Environment.ProcessId}", typeof(App));
|
||||
if (PowerToys.GPOWrapperProjection.GPOWrapper.GetConfiguredPowerLauncherEnabledValue() == PowerToys.GPOWrapperProjection.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
Log.Warn("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.", typeof(App));
|
||||
return;
|
||||
}
|
||||
|
||||
int powerToysPid = GetPowerToysPId();
|
||||
if (powerToysPid != 0)
|
||||
{
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Interop.Microsoft.Office.Interop.OneNote" Version="1.1.0.2" />
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
|
||||
<PackageReference Include="Mages" Version="2.0.1" />
|
||||
@@ -94,6 +95,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapperProjection\GPOWrapperProjection.csproj" />
|
||||
<ProjectReference Include="..\..\..\common\interop\PowerToys.Interop.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||
<ProjectReference Include="..\..\..\common\Common.UI\Common.UI.csproj" />
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.PowerAccentKeyboardService</CsWinRTIncludes>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper;PowerToys.PowerAccentKeyboardService</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
@@ -23,6 +23,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
|
||||
<ProjectReference Include="..\PowerAccentKeyboardService\PowerAccentKeyboardService.vcxproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -28,6 +28,12 @@ internal static class Program
|
||||
{
|
||||
_ = new Mutex(true, PROGRAM_APP_NAME, out bool instantiated);
|
||||
|
||||
if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredQuickAccentEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (instantiated)
|
||||
{
|
||||
Arguments(args);
|
||||
|
||||
@@ -108,6 +108,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredQuickAccentEnabledValue();
|
||||
}
|
||||
|
||||
virtual void set_config(const wchar_t* config) override
|
||||
{
|
||||
try
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <common/logger/logger.h>
|
||||
#include <common/logger/logger_settings.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <common/utils/gpo.h>
|
||||
|
||||
using namespace winrt;
|
||||
using namespace winrt::Microsoft::UI::Xaml;
|
||||
@@ -53,6 +54,12 @@ void App::OnLaunched(LaunchActivatedEventArgs const&)
|
||||
{
|
||||
LoggerHelpers::init_logger(moduleName, L"", LogSettings::powerRenameLoggerName);
|
||||
|
||||
if (powertoys_gpo::getConfiguredPowerRenameEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled)
|
||||
{
|
||||
Logger::warn(L"Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
||||
auto args = std::wstring{ GetCommandLine() };
|
||||
size_t pos{ args.rfind(L"\\\\.\\pipe\\") };
|
||||
|
||||
|
||||
@@ -182,6 +182,12 @@ public:
|
||||
return app_key.c_str();
|
||||
}
|
||||
|
||||
// Return the configured status for the gpo policy for the module
|
||||
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
||||
{
|
||||
return powertoys_gpo::getConfiguredPowerRenameEnabledValue();
|
||||
}
|
||||
|
||||
// Enable the powertoy
|
||||
virtual void enable()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/utils/json.h>
|
||||
#include <common/utils/gpo.h>
|
||||
|
||||
class CSettings
|
||||
{
|
||||
@@ -9,6 +10,11 @@ public:
|
||||
|
||||
inline bool GetEnabled()
|
||||
{
|
||||
auto gpoSetting = powertoys_gpo::getConfiguredPowerRenameEnabledValue();
|
||||
if (gpoSetting == powertoys_gpo::gpo_rule_configured_enabled)
|
||||
return true;
|
||||
if (gpoSetting == powertoys_gpo::gpo_rule_configured_disabled)
|
||||
return false;
|
||||
Reload();
|
||||
return settings.enabled;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,25 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Disable missing comment warning. WinRT/C++ libraries added won't have comments on thier reflections. -->
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="17.2.3" />
|
||||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -43,6 +43,20 @@ namespace Microsoft.PowerToys.PreviewHandler.Gcode
|
||||
/// <param name="dataSource">Stream reference to access source file.</param>
|
||||
public override void DoPreview<T>(T dataSource)
|
||||
{
|
||||
if (global::PowerToys.GPOWrapper.GPOWrapper.GetConfiguredGcodePreviewEnabledValue() == global::PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
// GPO is disabling this utility. Show an error message instead.
|
||||
InvokeOnControlThread(() =>
|
||||
{
|
||||
_infoBarAdded = true;
|
||||
AddTextBoxControl(Properties.Resource.GpoDisabledErrorText);
|
||||
Resize += FormResized;
|
||||
base.DoPreview(dataSource);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
InvokeOnControlThread(() =>
|
||||
{
|
||||
try
|
||||
|
||||
@@ -77,5 +77,14 @@ namespace Microsoft.PowerToys.PreviewHandler.Gcode.Properties {
|
||||
return ResourceManager.GetString("GcodeWithoutEmbeddedThumbnails", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string for an error when Gpo has the utility disabled.
|
||||
/// </summary>
|
||||
internal static string GpoDisabledErrorText {
|
||||
get {
|
||||
return ResourceManager.GetString("GpoDisabledErrorText", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,4 +124,8 @@
|
||||
<data name="GcodeWithoutEmbeddedThumbnails" xml:space="preserve">
|
||||
<value>This G-code does not contain any embedded thumbnails.</value>
|
||||
</data>
|
||||
<data name="GpoDisabledErrorText" xml:space="preserve">
|
||||
<value>Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.</value>
|
||||
<comment>GPO stands for the Windows Group Policy Object feature.</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -158,6 +158,12 @@ namespace Microsoft.PowerToys.ThumbnailHandler.Gcode
|
||||
return;
|
||||
}
|
||||
|
||||
if (global::PowerToys.GPOWrapper.GPOWrapper.GetConfiguredGcodeThumbnailsEnabledValue() == global::PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
// GPO is disabling this utility.
|
||||
return;
|
||||
}
|
||||
|
||||
using (var stream = new ReadonlyStream(this.Stream as IStream))
|
||||
{
|
||||
using (var reader = new StreamReader(stream))
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<AssemblyName>PowerToys.GcodeThumbnailProvider</AssemblyName>
|
||||
<AssemblyTitle>PowerToys.GcodeThumbnailProvider</AssemblyTitle>
|
||||
<AssemblyDescription>PowerToys GcodePreviewHandler</AssemblyDescription>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
|
||||
<EnableComHosting>true</EnableComHosting>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Description>PowerToys GcodePreviewHandler</Description>
|
||||
@@ -18,7 +18,23 @@
|
||||
|
||||
<Import Project="..\..\..\Version.props" />
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Disable missing comment warning. WinRT/C++ libraries added won't have comments on thier reflections. -->
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||
<ProjectReference Include="..\Common\PreviewHandlerCommon.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -37,7 +37,19 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Disable missing comment warning. WinRT/C++ libraries added won't have comments on thier reflections. -->
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.42" />
|
||||
<PackageReference Include="Markdig.Signed" Version="0.27.0" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1343.22" />
|
||||
@@ -45,6 +57,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\Common.UI\Common.UI.csproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj" />
|
||||
|
||||
@@ -130,6 +130,21 @@ namespace Microsoft.PowerToys.PreviewHandler.Markdown
|
||||
/// <param name="dataSource">Path to the file.</param>
|
||||
public override void DoPreview<T>(T dataSource)
|
||||
{
|
||||
if (global::PowerToys.GPOWrapper.GPOWrapper.GetConfiguredMarkdownPreviewEnabledValue() == global::PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
// GPO is disabling this utility. Show an error message instead.
|
||||
InvokeOnControlThread(() =>
|
||||
{
|
||||
_infoBarDisplayed = true;
|
||||
_infoBar = GetTextBoxControl(Resources.GpoDisabledErrorText);
|
||||
Resize += FormResized;
|
||||
Controls.Add(_infoBar);
|
||||
base.DoPreview(dataSource);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CleanupWebView2UserDataFolder();
|
||||
|
||||
_infoBarDisplayed = false;
|
||||
|
||||
@@ -77,5 +77,14 @@ namespace Microsoft.PowerToys.PreviewHandler.Markdown.Properties {
|
||||
return ResourceManager.GetString("MarkdownNotPreviewedError", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string for an error when Gpo has the utility disabled.
|
||||
/// </summary>
|
||||
internal static string GpoDisabledErrorText {
|
||||
get {
|
||||
return ResourceManager.GetString("GpoDisabledErrorText", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,4 +125,8 @@
|
||||
<value>The markdown could not be preview due to an internal error.</value>
|
||||
<comment>This text is displayed if markdown fails to preview</comment>
|
||||
</data>
|
||||
<data name="GpoDisabledErrorText" xml:space="preserve">
|
||||
<value>Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.</value>
|
||||
<comment>GPO stands for the Windows Group Policy Object feature.</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -26,7 +26,19 @@
|
||||
<NoWarn>1701;1702</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Disable missing comment warning. WinRT/C++ libraries added won't have comments on thier reflections. -->
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1343.22" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="17.2.3" />
|
||||
</ItemGroup>
|
||||
@@ -41,6 +53,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\Common.UI\Common.UI.csproj" />
|
||||
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj" />
|
||||
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
|
||||
|
||||
@@ -37,6 +37,16 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
|
||||
new XmlFormatter(),
|
||||
}.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Text box to display the information about blocked elements from Svg.
|
||||
/// </summary>
|
||||
private RichTextBox _textBox;
|
||||
|
||||
/// <summary>
|
||||
/// Represent if an text box info bar is added for showing message.
|
||||
/// </summary>
|
||||
private bool _infoBarAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Saves if the user already navigated to the index page
|
||||
/// </summary>
|
||||
@@ -94,6 +104,20 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
|
||||
{
|
||||
Logger.LogTrace();
|
||||
|
||||
if (global::PowerToys.GPOWrapper.GPOWrapper.GetConfiguredMonacoPreviewEnabledValue() == global::PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
// GPO is disabling this utility. Show an error message instead.
|
||||
InvokeOnControlThread(() =>
|
||||
{
|
||||
_infoBarAdded = true;
|
||||
AddTextBoxControl(Properties.Resources.GpoDisabledErrorText);
|
||||
Resize += FormResized;
|
||||
base.DoPreview(dataSource);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
base.DoPreview(dataSource);
|
||||
|
||||
// Sets background color
|
||||
@@ -421,5 +445,47 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
|
||||
await Launcher.LaunchUriAsync(new Uri("https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section"));
|
||||
Logger.LogTrace();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when RichtextBox is resized.
|
||||
/// </summary>
|
||||
/// <param name="sender">Reference to resized control.</param>
|
||||
/// <param name="e">Provides data for the ContentsResized event.</param>
|
||||
private void RTBContentsResized(object sender, ContentsResizedEventArgs e)
|
||||
{
|
||||
var richTextBox = sender as RichTextBox;
|
||||
richTextBox.Height = e.NewRectangle.Height + 5;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when form is resized.
|
||||
/// </summary>
|
||||
/// <param name="sender">Reference to resized control.</param>
|
||||
/// <param name="e">Provides data for the resize event.</param>
|
||||
private void FormResized(object sender, EventArgs e)
|
||||
{
|
||||
if (_infoBarAdded)
|
||||
{
|
||||
_textBox.Width = Width;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Text Box in Controls for showing information about blocked elements.
|
||||
/// </summary>
|
||||
/// <param name="message">Message to be displayed in textbox.</param>
|
||||
private void AddTextBoxControl(string message)
|
||||
{
|
||||
_textBox = new RichTextBox();
|
||||
_textBox.Text = message;
|
||||
_textBox.BackColor = Color.LightYellow;
|
||||
_textBox.Multiline = true;
|
||||
_textBox.Dock = DockStyle.Top;
|
||||
_textBox.ReadOnly = true;
|
||||
_textBox.ContentsResized += RTBContentsResized;
|
||||
_textBox.ScrollBars = RichTextBoxScrollBars.None;
|
||||
_textBox.BorderStyle = BorderStyle.None;
|
||||
Controls.Add(_textBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,5 +106,14 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco.Properties {
|
||||
return ResourceManager.GetString("WebView2_Not_Installed_Message", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string for an error when Gpo has the utility disabled.
|
||||
/// </summary>
|
||||
internal static string GpoDisabledErrorText {
|
||||
get {
|
||||
return ResourceManager.GetString("GpoDisabledErrorText", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,4 +136,8 @@ Max file size: %1KB</value>
|
||||
<data name="Download_WebView2" xml:space="preserve">
|
||||
<value>Download WebView2 to display this file.</value>
|
||||
</data>
|
||||
<data name="GpoDisabledErrorText" xml:space="preserve">
|
||||
<value>Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.</value>
|
||||
<comment>GPO stands for the Windows Group Policy Object feature.</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -31,11 +31,24 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Disable missing comment warning. WinRT/C++ libraries added won't have comments on thier reflections. -->
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="17.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -52,6 +52,19 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
/// <param name="dataSource">Stream reference to access source file.</param>
|
||||
public override void DoPreview<T>(T dataSource)
|
||||
{
|
||||
if (global::PowerToys.GPOWrapper.GPOWrapper.GetConfiguredPdfPreviewEnabledValue() == global::PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
// GPO is disabling this utility. Show an error message instead.
|
||||
InvokeOnControlThread(() =>
|
||||
{
|
||||
_infoBar = GetTextBoxControl(Resources.GpoDisabledErrorText);
|
||||
Controls.Add(_infoBar);
|
||||
base.DoPreview(dataSource);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.SuspendLayout();
|
||||
|
||||
try
|
||||
|
||||
@@ -100,5 +100,14 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf.Properties
|
||||
return ResourceManager.GetString("PdfMorePagesMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string for an error when Gpo has the utility disabled.
|
||||
/// </summary>
|
||||
internal static string GpoDisabledErrorText {
|
||||
get {
|
||||
return ResourceManager.GetString("GpoDisabledErrorText", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,4 +129,8 @@
|
||||
<value>Can't preview file. This PDF is password protected.</value>
|
||||
<comment>This text is displayed if PDF is password protected.</comment>
|
||||
</data>
|
||||
<data name="GpoDisabledErrorText" xml:space="preserve">
|
||||
<value>Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.</value>
|
||||
<comment>GPO stands for the Windows Group Policy Object feature.</comment>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -49,6 +49,12 @@ namespace Microsoft.PowerToys.ThumbnailHandler.Pdf
|
||||
return;
|
||||
}
|
||||
|
||||
if (global::PowerToys.GPOWrapper.GPOWrapper.GetConfiguredPdfThumbnailsEnabledValue() == global::PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
// GPO is disabling this utility.
|
||||
return;
|
||||
}
|
||||
|
||||
using var dataStream = new ReadonlyStream(this.Stream as IStream);
|
||||
using var memStream = new MemoryStream();
|
||||
|
||||
|
||||
@@ -17,7 +17,23 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\..\Version.props" />
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Disable missing comment warning. WinRT/C++ libraries added won't have comments on thier reflections. -->
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||
<ProjectReference Include="..\Common\PreviewHandlerCommon.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -123,6 +123,12 @@ namespace Microsoft.PowerToys.ThumbnailHandler.Stl
|
||||
return;
|
||||
}
|
||||
|
||||
if (global::PowerToys.GPOWrapper.GPOWrapper.GetConfiguredStlThumbnailsEnabledValue() == global::PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
// GPO is disabling this utility.
|
||||
return;
|
||||
}
|
||||
|
||||
using (var stream = new ReadonlyStream(this.Stream as IStream))
|
||||
{
|
||||
using (var memStream = new MemoryStream())
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<AssemblyName>PowerToys.StlThumbnailProvider</AssemblyName>
|
||||
<AssemblyTitle>PowerToys.StlThumbnailProvider</AssemblyTitle>
|
||||
<AssemblyDescription>PowerToys StlPreviewHandler</AssemblyDescription>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
|
||||
<EnableComHosting>true</EnableComHosting>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Description>PowerToys StlPreviewHandler</Description>
|
||||
@@ -18,12 +18,25 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\..\Version.props" />
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Disable missing comment warning. WinRT/C++ libraries added won't have comments on thier reflections. -->
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="HelixToolkit" Version="2.20.2" />
|
||||
<PackageReference Include="HelixToolkit.Core.Wpf" Version="2.20.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||
<ProjectReference Include="..\Common\PreviewHandlerCommon.csproj" />
|
||||
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
|
||||
|
||||
@@ -77,5 +77,14 @@ namespace Microsoft.PowerToys.PreviewHandler.Svg.Properties {
|
||||
return ResourceManager.GetString("SvgNotPreviewedError", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string for an error when Gpo has the utility disabled.
|
||||
/// </summary>
|
||||
internal static string GpoDisabledErrorText {
|
||||
get {
|
||||
return ResourceManager.GetString("GpoDisabledErrorText", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,4 +123,8 @@
|
||||
<data name="SvgNotPreviewedError" xml:space="preserve">
|
||||
<value>The Svg could not be preview due to an internal error in Svg Preview Handler.</value>
|
||||
</data>
|
||||
<data name="GpoDisabledErrorText" xml:space="preserve">
|
||||
<value>Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.</value>
|
||||
<comment>GPO stands for the Windows Group Policy Object feature.</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -11,6 +11,7 @@ using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Windows.Forms;
|
||||
using Common;
|
||||
using Common.Utilities;
|
||||
using Microsoft.PowerToys.PreviewHandler.Svg.Properties;
|
||||
using Microsoft.PowerToys.PreviewHandler.Svg.Telemetry.Events;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
@@ -82,6 +83,20 @@ namespace Microsoft.PowerToys.PreviewHandler.Svg
|
||||
/// <param name="dataSource">Stream reference to access source file.</param>
|
||||
public override void DoPreview<T>(T dataSource)
|
||||
{
|
||||
if (global::PowerToys.GPOWrapper.GPOWrapper.GetConfiguredSvgPreviewEnabledValue() == global::PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
// GPO is disabling this utility. Show an error message instead.
|
||||
InvokeOnControlThread(() =>
|
||||
{
|
||||
_infoBarAdded = true;
|
||||
AddTextBoxControl(Properties.Resource.GpoDisabledErrorText);
|
||||
Resize += FormResized;
|
||||
base.DoPreview(dataSource);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CleanupWebView2UserDataFolder();
|
||||
|
||||
string svgData = null;
|
||||
|
||||
@@ -32,12 +32,25 @@
|
||||
<Compile Update="SvgPreviewControl.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Disable missing comment warning. WinRT/C++ libraries added won't have comments on thier reflections. -->
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1343.22" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -272,6 +272,12 @@ namespace Microsoft.PowerToys.ThumbnailHandler.Svg
|
||||
return;
|
||||
}
|
||||
|
||||
if (global::PowerToys.GPOWrapper.GPOWrapper.GetConfiguredSvgThumbnailsEnabledValue() == global::PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
// GPO is disabling this utility.
|
||||
return;
|
||||
}
|
||||
|
||||
string svgData = null;
|
||||
using (var stream = new ReadonlyStream(this.Stream as IStream))
|
||||
{
|
||||
|
||||
@@ -20,10 +20,24 @@
|
||||
|
||||
<Import Project="..\..\..\Version.props" />
|
||||
|
||||
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>
|
||||
<CsWinRTGeneratedFilesDir>$(OutDir)</CsWinRTGeneratedFilesDir>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Disable missing comment warning. WinRT/C++ libraries added won't have comments on thier reflections. -->
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1343.22" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
|
||||
<ProjectReference Include="..\Common\PreviewHandlerCommon.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Markdig.Signed" Version="0.27.0" />
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj" />
|
||||
<ProjectReference Include="..\SvgPreviewHandler\SvgPreviewHandler.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<Import Project="..\..\..\Version.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||
|
||||
@@ -28,38 +28,47 @@ PowerPreviewModule::PowerPreviewModule() :
|
||||
const bool installPerUser = true;
|
||||
m_fileExplorerModules.push_back({ .settingName = L"svg-previewer-toggle-setting",
|
||||
.settingDescription = GET_RESOURCE_STRING(IDS_PREVPANE_SVG_SETTINGS_DESCRIPTION),
|
||||
.checkModuleGPOEnabledRuleFunction = powertoys_gpo::getConfiguredSvgPreviewEnabledValue,
|
||||
.registryChanges = getSvgPreviewHandlerChangeSet(installationDir, installPerUser) });
|
||||
|
||||
m_fileExplorerModules.push_back({ .settingName = L"md-previewer-toggle-setting",
|
||||
.settingDescription = GET_RESOURCE_STRING(IDS_PREVPANE_MD_SETTINGS_DESCRIPTION),
|
||||
.checkModuleGPOEnabledRuleFunction = powertoys_gpo::getConfiguredMarkdownPreviewEnabledValue,
|
||||
.registryChanges = getMdPreviewHandlerChangeSet(installationDir, installPerUser) });
|
||||
|
||||
m_fileExplorerModules.push_back({ .settingName = L"monaco-previewer-toggle-setting",
|
||||
.settingDescription = GET_RESOURCE_STRING(IDS_PREVPANE_MONACO_SETTINGS_DESCRIPTION),
|
||||
.checkModuleGPOEnabledRuleFunction = powertoys_gpo::getConfiguredMonacoPreviewEnabledValue,
|
||||
.registryChanges = getMonacoPreviewHandlerChangeSet(installationDir, installPerUser) });
|
||||
|
||||
m_fileExplorerModules.push_back({ .settingName = L"pdf-previewer-toggle-setting",
|
||||
.settingDescription = GET_RESOURCE_STRING(IDS_PREVPANE_PDF_SETTINGS_DESCRIPTION),
|
||||
.checkModuleGPOEnabledRuleFunction = powertoys_gpo::getConfiguredPdfPreviewEnabledValue,
|
||||
.registryChanges = getPdfPreviewHandlerChangeSet(installationDir, installPerUser) });
|
||||
|
||||
m_fileExplorerModules.push_back({ .settingName = L"gcode-previewer-toggle-setting",
|
||||
.settingDescription = GET_RESOURCE_STRING(IDS_PREVPANE_GCODE_SETTINGS_DESCRIPTION),
|
||||
.checkModuleGPOEnabledRuleFunction = powertoys_gpo::getConfiguredGcodePreviewEnabledValue,
|
||||
.registryChanges = getGcodePreviewHandlerChangeSet(installationDir, installPerUser) });
|
||||
|
||||
m_fileExplorerModules.push_back({ .settingName = L"svg-thumbnail-toggle-setting",
|
||||
.settingDescription = GET_RESOURCE_STRING(IDS_SVG_THUMBNAIL_PROVIDER_SETTINGS_DESCRIPTION),
|
||||
.checkModuleGPOEnabledRuleFunction = powertoys_gpo::getConfiguredSvgThumbnailsEnabledValue,
|
||||
.registryChanges = getSvgThumbnailHandlerChangeSet(installationDir, installPerUser) });
|
||||
|
||||
m_fileExplorerModules.push_back({ .settingName = L"pdf-thumbnail-toggle-setting",
|
||||
.settingDescription = GET_RESOURCE_STRING(IDS_PDF_THUMBNAIL_PROVIDER_SETTINGS_DESCRIPTION),
|
||||
.checkModuleGPOEnabledRuleFunction = powertoys_gpo::getConfiguredPdfThumbnailsEnabledValue,
|
||||
.registryChanges = getPdfThumbnailHandlerChangeSet(installationDir, installPerUser) });
|
||||
|
||||
m_fileExplorerModules.push_back({ .settingName = L"gcode-thumbnail-toggle-setting",
|
||||
.settingDescription = GET_RESOURCE_STRING(IDS_GCODE_THUMBNAIL_PROVIDER_SETTINGS_DESCRIPTION),
|
||||
.checkModuleGPOEnabledRuleFunction = powertoys_gpo::getConfiguredGcodeThumbnailsEnabledValue,
|
||||
.registryChanges = getGcodeThumbnailHandlerChangeSet(installationDir, installPerUser) });
|
||||
|
||||
m_fileExplorerModules.push_back({ .settingName = L"stl-thumbnail-toggle-setting",
|
||||
.settingDescription = GET_RESOURCE_STRING(IDS_STL_THUMBNAIL_PROVIDER_SETTINGS_DESCRIPTION),
|
||||
.checkModuleGPOEnabledRuleFunction = powertoys_gpo::getConfiguredStlThumbnailsEnabledValue,
|
||||
.registryChanges = getStlThumbnailHandlerChangeSet(installationDir, installPerUser) });
|
||||
|
||||
try
|
||||
@@ -202,15 +211,43 @@ void PowerPreviewModule::apply_settings(const PowerToysSettings::PowerToyValues&
|
||||
for (auto& fileExplorerModule : m_fileExplorerModules)
|
||||
{
|
||||
const auto toggle = settings.get_bool_value(fileExplorerModule.settingName);
|
||||
const auto gpo_rule = fileExplorerModule.checkModuleGPOEnabledRuleFunction();
|
||||
const auto gpo_is_configured = gpo_rule == powertoys_gpo::gpo_rule_configured_enabled || gpo_rule == powertoys_gpo::gpo_rule_configured_disabled;
|
||||
|
||||
if (gpo_rule == powertoys_gpo::gpo_rule_configured_unavailable)
|
||||
{
|
||||
Logger::warn(L"Couldn't read the gpo rule for Power Preview module {}", fileExplorerModule.settingName);
|
||||
}
|
||||
if (gpo_rule == powertoys_gpo::gpo_rule_configured_wrong_value)
|
||||
{
|
||||
Logger::warn(L"gpo rule for Power Preview module {} is set to an unknown value", fileExplorerModule.settingName);
|
||||
}
|
||||
|
||||
// Skip if no need to update
|
||||
if (!toggle.has_value() || *toggle == fileExplorerModule.registryChanges.isApplied())
|
||||
if (!toggle.has_value() && !gpo_is_configured)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool module_new_state = false;
|
||||
if (toggle.has_value())
|
||||
{
|
||||
module_new_state = *toggle;
|
||||
}
|
||||
if (gpo_is_configured)
|
||||
{
|
||||
// gpo rule overrides settings state
|
||||
module_new_state = gpo_rule == powertoys_gpo::gpo_rule_configured_enabled;
|
||||
}
|
||||
|
||||
// Skip if no need to update
|
||||
if (module_new_state == fileExplorerModule.registryChanges.isApplied())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// (Un)Apply registry changes depending on the new setting value
|
||||
const bool updated = *toggle ? fileExplorerModule.registryChanges.apply() : fileExplorerModule.registryChanges.unApply();
|
||||
const bool updated = module_new_state ? fileExplorerModule.registryChanges.apply() : fileExplorerModule.registryChanges.unApply();
|
||||
|
||||
if (updated)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user