Merge remote-tracking branch 'origin/main' into stefan/env_var_new

This commit is contained in:
Stefan Markovic
2023-10-04 09:04:00 +02:00
26 changed files with 228 additions and 65 deletions

View File

@@ -136,6 +136,7 @@ BITMAPFILEHEADER
bitmapimage
BITMAPINFO
BITMAPINFOHEADER
Bitmaps
bitmask
BITSPIXEL
bla
@@ -1370,7 +1371,6 @@ pef
PElems
Pels
PERCEIVEDFLAG
Percision
perfmon
pesi
petabyte

View File

@@ -41,17 +41,17 @@ Go to the [Microsoft PowerToys GitHub releases page][github-release-link] and cl
<!-- items that need to be updated release to release -->
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F48
[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F47
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.0/PowerToysUserSetup-0.74.0-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.0/PowerToysUserSetup-0.74.0-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.0/PowerToysSetup-0.74.0-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.0/PowerToysSetup-0.74.0-arm64.exe
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.1/PowerToysUserSetup-0.74.1-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.1/PowerToysUserSetup-0.74.1-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.1/PowerToysSetup-0.74.1-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.1/PowerToysSetup-0.74.1-arm64.exe
| Description | Filename | sha256 hash |
|----------------|----------|-------------|
| Per user - x64 | [PowerToysUserSetup-0.74.0-x64.exe][ptUserX64] | 1C4ECE9F11488BAFFAE6B76D2B0504FA18BFFEA11EBC38BCC87F5D86AEA87C7C |
| Per user - ARM64 | [PowerToysUserSetup-0.74.0-arm64.exe][ptUserArm64] | 4F3842FAB0839A361A15A06B7720BA8A0FE7F9AF98EA94245C08DEF37678CA4A |
| Machine wide - x64 | [PowerToysSetup-0.74.0-x64.exe][ptMachineX64] | 648992E8CEA08F3C63C7CCBD554ADDF500ECBC4560187310BC12E6CB9C2F38E3 |
| Machine wide - ARM64 | [PowerToysSetup-0.74.0-arm64.exe][ptMachineArm64] | 2B6D92F1A0EA688C7EE882050AC9B030C8B3A18765163FB6D67E5E694A4D4FE3 |
| Per user - x64 | [PowerToysUserSetup-0.74.1-x64.exe][ptUserX64] | 748BF7BA33913237D36D6F48E3839D0C8035967305137A17DEFF39D775735C81 |
| Per user - ARM64 | [PowerToysUserSetup-0.74.1-arm64.exe][ptUserArm64] | F5DAA89A9CF3A2805E121085AFD056A890F241A170FAB5007AA58E2755C88C54 |
| Machine wide - x64 | [PowerToysSetup-0.74.1-x64.exe][ptMachineX64] | 298C6F4E4391BDC06E128BED86A303C3300A68EAF754B4630AF7542C78C0944A |
| Machine wide - ARM64 | [PowerToysSetup-0.74.1-arm64.exe][ptMachineArm64] | A65F3C300A48F9F81312B7FC7B306382CB87F591612D0CEC7E5C0E47E868904B |
This is our preferred method.

View File

@@ -111,6 +111,11 @@
<ItemGroup>
<ResourceCompile Include="GPOWrapper.rc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\common\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets')" />

View File

@@ -43,6 +43,11 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\common\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets')" />

View File

@@ -48,9 +48,6 @@
<ProjectReference Include="..\SettingsAPI\SettingsAPI.vcxproj">
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
<ProjectReference Include="..\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="UnitTests-CommonLib.rc" />

View File

@@ -74,6 +74,9 @@
<ProjectReference Include="..\..\logging\logging.vcxproj">
<Project>{7e1e3f13-2bd6-3f75-a6a7-873a2b55c60f}</Project>
</ProjectReference>
<ProjectReference Include="..\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@@ -67,6 +67,9 @@
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
<ProjectReference Include="..\BackgroundActivator\BackgroundActivator.vcxproj">
<Project>{031AC72E-FA28-4AB7-B690-6F7B9C28AA73}</Project>
</ProjectReference>

View File

@@ -51,9 +51,6 @@
<ProjectReference Include="..\SettingsAPI\SettingsAPI.vcxproj">
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
<ProjectReference Include="..\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@@ -10,6 +10,25 @@
</ItemGroup>
<WriteLinesToFile File="Generated Files\version_gen.h" Lines="@(HeaderLines)" Overwrite="true" Encoding="Unicode" WriteOnlyWhenDifferent="true" />
</Target>
<!-- Needed for .\src\modules\videoconference\VideoConferenceProxyFilter\build_vcm_x86.cmd -->
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}</ProjectGuid>

View File

@@ -260,9 +260,6 @@
<ProjectReference Include="..\..\..\common\Themes\Themes.vcxproj">
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\common\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="..\..\..\..\deps\spdlog.props" />

View File

@@ -29,6 +29,7 @@
#include <FancyZonesLib/VirtualDesktop.h>
#include <FancyZonesLib/WindowKeyboardSnap.h>
#include <FancyZonesLib/WindowMouseSnap.h>
#include <FancyZonesLib/WindowUtils.h>
#include <FancyZonesLib/WorkArea.h>
#include <FancyZonesLib/WorkAreaConfiguration.h>
@@ -394,6 +395,15 @@ void FancyZones::WindowCreated(HWND window) noexcept
return;
}
// Hotfix
// Avoid automatically moving popup windows, as they can be just popup menus.
bool isPopup = FancyZonesWindowUtils::IsPopupWindow(window);
bool hasThickFrame = FancyZonesWindowUtils::HasThickFrame(window);
if (isPopup && !hasThickFrame)
{
return;
}
// Avoid already stamped (zoned) windows
const bool isZoned = !FancyZonesWindowProperties::RetrieveZoneIndexProperty(window).empty();
if (isZoned)

View File

@@ -192,6 +192,12 @@ bool FancyZonesWindowUtils::IsPopupWindow(HWND window) noexcept
return ((style & WS_POPUP) == WS_POPUP);
}
bool FancyZonesWindowUtils::HasThickFrame(HWND window) noexcept
{
auto style = GetWindowLong(window, GWL_STYLE);
return ((style & WS_THICKFRAME) == WS_THICKFRAME);
}
bool FancyZonesWindowUtils::HasThickFrameAndMinimizeMaximizeButtons(HWND window) noexcept
{
auto style = GetWindowLong(window, GWL_STYLE);

View File

@@ -20,6 +20,7 @@ namespace FancyZonesWindowUtils
bool HasVisibleOwner(HWND window) noexcept;
bool IsStandardWindow(HWND window);
bool IsPopupWindow(HWND window) noexcept;
bool HasThickFrame(HWND window) noexcept;
bool HasThickFrameAndMinimizeMaximizeButtons(HWND window) noexcept;
bool IsProcessOfWindowElevated(HWND window); // If HWND is already dead, we assume it wasn't elevated

View File

@@ -2,6 +2,9 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Globalization;
namespace Peek.Common.Helpers
{
public static class MathHelper
@@ -10,5 +13,10 @@ namespace Peek.Common.Helpers
{
return a < 0 ? ((a % b) + b) % b : a % b;
}
public static int NumberOfDigits(int num)
{
return Math.Abs(num).ToString(CultureInfo.InvariantCulture).Length;
}
}
}

View File

@@ -10,34 +10,40 @@ namespace Peek.Common.Helpers
{
public static class ReadableStringHelper
{
private const int DecimalPercision = 10;
private const int MaxDigitsToDisplay = 3;
private const int PowerFactor = 1024;
public static string BytesToReadableString(ulong bytes)
{
var resourceLoader = ResourceLoaderInstance.ResourceLoader;
List<string> format = new List<string>
{
(bytes == 1) ?
resourceLoader.GetString("ReadableString_ByteAbbreviationFormat") : // "byte"
resourceLoader.GetString("ReadableString_BytesAbbreviationFormat"), // "bytes"
resourceLoader.GetString("ReadableString_KiloByteAbbreviationFormat"), // "KB"
resourceLoader.GetString("ReadableString_MegaByteAbbreviationFormat"), // "MB"
resourceLoader.GetString("ReadableString_GigaByteAbbreviationFormat"), // "GB"
resourceLoader.GetString("ReadableString_TeraByteAbbreviationFormat"), // "TB"
resourceLoader.GetString("ReadableString_PetaByteAbbreviationFormat"), // "PB"
resourceLoader.GetString("ReadableString_ExaByteAbbreviationFormat"), // "EB"
};
string totalBytesDisplays = (bytes == 1) ?
ResourceLoaderInstance.ResourceLoader.GetString("ReadableString_ByteString") :
ResourceLoaderInstance.ResourceLoader.GetString("ReadableString_BytesString");
int index = 0;
double number = 0.0;
if (bytes > 0)
{
index = (int)Math.Floor(Math.Log(bytes) / Math.Log(1024));
number = Math.Round((bytes / Math.Pow(1024, index)) * DecimalPercision) / DecimalPercision;
index = (int)Math.Floor(Math.Log(bytes) / Math.Log(PowerFactor));
number = bytes / Math.Pow(PowerFactor, index);
}
return string.Format(CultureInfo.InvariantCulture, format[index], number);
if (index > 0 && number >= Math.Pow(10, MaxDigitsToDisplay))
{
index++;
number = bytes / Math.Pow(PowerFactor, index);
}
int precision = GetPrecision(index, number);
int decimalPrecision = (int)Math.Pow(10, precision);
number = Math.Truncate(number * decimalPrecision) / decimalPrecision;
string formatSpecifier = GetFormatSpecifierString(index, number, bytes, precision);
return bytes == 0
? string.Format(CultureInfo.CurrentCulture, formatSpecifier, number)
: string.Format(CultureInfo.CurrentCulture, formatSpecifier + totalBytesDisplays, number, bytes);
}
public static string FormatResourceString(string resourceId, object? args)
@@ -55,5 +61,32 @@ namespace Peek.Common.Helpers
return formattedString;
}
public static int GetPrecision(int index, double number)
{
int numberOfDigits = MathHelper.NumberOfDigits((int)number);
return index == 0 ?
0 :
MaxDigitsToDisplay - numberOfDigits;
}
public static string GetFormatSpecifierString(int index, double number, ulong bytes, int precision)
{
var resourceLoader = ResourceLoaderInstance.ResourceLoader;
List<string> format = new List<string>
{
(bytes == 1) ?
resourceLoader.GetString("ReadableString_ByteAbbreviationFormat") : // "byte"
resourceLoader.GetString("ReadableString_BytesAbbreviationFormat"), // "bytes"
resourceLoader.GetString("ReadableString_KiloByteAbbreviationFormat"), // "KB"
resourceLoader.GetString("ReadableString_MegaByteAbbreviationFormat"), // "MB"
resourceLoader.GetString("ReadableString_GigaByteAbbreviationFormat"), // "GB"
resourceLoader.GetString("ReadableString_TeraByteAbbreviationFormat"), // "TB"
resourceLoader.GetString("ReadableString_PetaByteAbbreviationFormat"), // "PB"
resourceLoader.GetString("ReadableString_ExaByteAbbreviationFormat"), // "EB"
};
return "{0:F" + precision + "} " + format[index];
}
}
}

View File

@@ -154,31 +154,31 @@
<comment>Date Modified label for the unsupported files view. {0} is the date.</comment>
</data>
<data name="ReadableString_ByteAbbreviationFormat" xml:space="preserve">
<value>{0} byte</value>
<value>byte</value>
<comment>Abbreviation for the size unit byte.</comment>
</data>
<data name="ReadableString_KiloByteAbbreviationFormat" xml:space="preserve">
<value>{0} KB</value>
<value>KB</value>
<comment>Abbreviation for the size unit kilobyte.</comment>
</data>
<data name="ReadableString_MegaByteAbbreviationFormat" xml:space="preserve">
<value>{0} MB</value>
<value>MB</value>
<comment>Abbreviation for the size unit megabyte.</comment>
</data>
<data name="ReadableString_GigaByteAbbreviationFormat" xml:space="preserve">
<value>{0} GB</value>
<value>GB</value>
<comment>Abbreviation for the size unit gigabyte.</comment>
</data>
<data name="ReadableString_TeraByteAbbreviationFormat" xml:space="preserve">
<value>{0} TB</value>
<value>TB</value>
<comment>Abbreviation for the size unit terabyte.</comment>
</data>
<data name="ReadableString_PetaByteAbbreviationFormat" xml:space="preserve">
<value>{0} PB</value>
<value>PB</value>
<comment>Abbreviation for the size unit petabyte.</comment>
</data>
<data name="ReadableString_ExaByteAbbreviationFormat" xml:space="preserve">
<value>{0} EB</value>
<value>EB</value>
<comment>Abbreviation for the size unit exabyte.</comment>
</data>
<data name="PreviewTooltip_FileName" xml:space="preserve">
@@ -234,7 +234,7 @@
<comment>{0} is the size of the archive, {1} is the extracted size</comment>
</data>
<data name="ReadableString_BytesAbbreviationFormat" xml:space="preserve">
<value>{0} bytes</value>
<value>bytes</value>
<comment>Abbreviation for the size bytes</comment>
</data>
<data name="OpenUriDialog.CloseButtonText" xml:space="preserve">
@@ -253,4 +253,12 @@
<value>Do you want Peek to open the external application?</value>
<comment>Title of the dialog showed when an URI is clicked,"Peek" is the name of the utility. </comment>
</data>
<data name="ReadableString_BytesString" xml:space="preserve">
<value> ({1:N0} bytes)</value>
<comment>Displays total number of bytes. Don't localize the "{1:N0}" part.</comment>
</data>
<data name="ReadableString_ByteString" xml:space="preserve">
<value> ({1:N0} byte)</value>
<comment>Displays unit byte. Don't localize the "{1:N0}" part.</comment>
</data>
</root>

View File

@@ -118,12 +118,55 @@ namespace PowerAccent.Core
.Union(GetDefaultLetterKeySR(letter))
.Union(GetDefaultLetterKeySV(letter))
.Union(GetDefaultLetterKeyTK(letter))
.Union(GetDefaultLetterKeyAllLanguagesOnly(letter))
.ToArray();
}
return _allLanguagesCache[letter];
}
// Contains all characters that should be shown in all languages but currently don't belong to any of the single languages available for that letter.
// These characters can be removed from this list after they've been added to one of the other languages for that specific letter.
private static string[] GetDefaultLetterKeyAllLanguagesOnly(LetterKey letter)
{
return letter switch
{
LetterKey.VK_A => new[] { "α", "ȧ" },
LetterKey.VK_B => new[] { "ḃ", "β" },
LetterKey.VK_C => new[] { "ċ", "χ", "°C", "©", "" },
LetterKey.VK_D => new[] { "ḍ", "ḋ", "δ" },
LetterKey.VK_E => new[] { "ε", "η", "∈" },
LetterKey.VK_F => new[] { "ḟ", "°F" },
LetterKey.VK_G => new[] { "ģ", "ǧ", "ġ", "ĝ", "ǥ", "γ" },
LetterKey.VK_H => new[] { "ḣ", "ĥ", "ħ" },
LetterKey.VK_I => new[] { "ι" },
LetterKey.VK_J => new[] { "ĵ" },
LetterKey.VK_K => new[] { "ķ", "ǩ", "κ" },
LetterKey.VK_L => new[] { "ļ", "₺", "λ" }, // ₺ is in VK_T for other languages, but not VK_L, so we add it here.
LetterKey.VK_M => new[] { "ṁ", "μ" },
LetterKey.VK_N => new[] { "ņ", "ṅ", "ⁿ", "ν", "" },
LetterKey.VK_O => new[] { "ȯ", "ω", "ο" },
LetterKey.VK_P => new[] { "ṗ", "φ", "ψ", "℗" },
LetterKey.VK_Q => new[] { "" },
LetterKey.VK_R => new[] { "ṙ", "ρ", "®", "" },
LetterKey.VK_S => new[] { "ṡ", "σ", "\u00A7" },
LetterKey.VK_T => new[] { "ţ", "ṫ", "ŧ", "θ", "τ", "™" },
LetterKey.VK_U => new[] { "ŭ", "υ" },
LetterKey.VK_V => new[] { "V̇" },
LetterKey.VK_W => new[] { "ẇ" },
LetterKey.VK_X => new[] { "ẋ", "ξ", "×" },
LetterKey.VK_Y => new[] { "ẏ" },
LetterKey.VK_Z => new[] { "ʒ", "ǯ", "ζ", "" },
LetterKey.VK_COMMA => new[] { "∙", "₋", "⁻", "" }, // is in VK_MINUS for other languages, but not VK_COMMA, so we add it here.
LetterKey.VK_PERIOD => new[] { "\u0300", "\u0301", "\u0302", "\u0303", "\u0304", "\u0308", "\u030C" },
LetterKey.VK_MINUS => new[] { "~", "", "", "", "—", "―", "", "", "⸺", "⸻" },
LetterKey.VK_SLASH_ => new[] { "÷" },
LetterKey.VK_DIVIDE_ => new[] { "÷" },
LetterKey.VK_MULTIPLY_ => new[] { "×", "⋅" },
_ => Array.Empty<string>(),
};
}
// Currencies (source: https://www.eurochange.co.uk/travel-money/world-currency-abbreviations-symbols-and-codes-travel-money)
private static string[] GetDefaultLetterKeyCUR(LetterKey letter)
{

View File

@@ -113,9 +113,6 @@
<ProjectReference Include="..\..\..\common\SettingsAPI\SettingsAPI.vcxproj">
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\common\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="PowerAccentKeyboardService.rc" />

View File

@@ -193,9 +193,6 @@
<ProjectReference Include="..\..\..\common\Themes\Themes.vcxproj">
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\common\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
<ProjectReference Include="..\lib\PowerRenameLib.vcxproj">
<Project>{51920f1f-c28c-4adf-8660-4238766796c2}</Project>
</ProjectReference>

View File

@@ -63,9 +63,6 @@
<ProjectReference Include="..\..\..\common\Themes\Themes.vcxproj">
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\common\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
<ProjectReference Include="..\lib\PowerRenameLib.vcxproj">
<Project>{51920f1f-c28c-4adf-8660-4238766796c2}</Project>
</ProjectReference>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 27.5.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!-- Generator: Adobe Illustrator 27.5.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg viewBox="0 0 100 100"
xmlns="http://www.w3.org/2000/svg">
<circle cx="50"
cy="50"
fill="rgba(0, 0, 255, 1)"
r="50">
<script>alert("valid-message")</script>
</circle>
</svg>
<!-- Generator: Adobe Illustrator 27.5.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->

After

Width:  |  Height:  |  Size: 552 B

View File

@@ -4,14 +4,12 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using Common.ComInterlop;
using Microsoft.PowerToys.STATestExtension;
using Microsoft.PowerToys.ThumbnailHandler.Svg;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace SvgThumbnailProviderUnitTests
{
@@ -211,5 +209,17 @@ namespace SvgThumbnailProviderUnitTests
Assert.IsTrue(bitmap != null);
}
[TestMethod]
public void SvgCommentsAreHandledCorrectly()
{
var filePath = "HelperFiles/WithComments.svg";
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(filePath);
Bitmap bitmap = svgThumbnailProvider.GetThumbnail(8);
Assert.IsTrue(bitmap != null);
}
}
}

View File

@@ -38,15 +38,19 @@
<ProjectReference Include="..\SvgThumbnailProvider\SvgThumbnailProvider.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\STATestClassAttribute.cs" Link="STATestClassAttribute.cs" />
<Compile Include="..\STATestMethodAttribute.cs" Link="STATestMethodAttribute.cs" />
<Compile Include="..\STATestClassAttribute.cs"
Link="STATestClassAttribute.cs" />
<Compile Include="..\STATestMethodAttribute.cs"
Link="STATestMethodAttribute.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="HelperFiles\file1.svg">
<Content Include="HelperFiles\*.svg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="HelperFiles\file2.svg">
<Content Include="HelperFiles\*.bmp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@@ -119,7 +119,7 @@ namespace Common.Utilities
while ((index = s.IndexOf('<', index)) != -1)
{
if (index < s.Length - 1 && s[index + 1] != '?')
if (index < s.Length - 1 && s[index + 1] != '?' && s[index + 1] != '!')
{
return index;
}
@@ -130,11 +130,11 @@ namespace Common.Utilities
return -1;
}
private static int FindFirstXmlCloseTagIndex(string s)
private static int FindFirstXmlCloseTagIndex(string s, int openTagIndex)
{
int index = 1;
while ((index = s.IndexOf('>', index)) != -1)
while ((index = s.IndexOf('>', openTagIndex)) != -1)
{
if (index > 0 && s[index - 1] != '?')
{
@@ -160,7 +160,7 @@ namespace Common.Utilities
return stringSvgData;
}
int firstXmlCloseTagIndex = FindFirstXmlCloseTagIndex(stringSvgData);
int firstXmlCloseTagIndex = FindFirstXmlCloseTagIndex(stringSvgData, firstXmlOpenTagIndex);
if (firstXmlCloseTagIndex == -1)
{
return stringSvgData;
@@ -192,13 +192,18 @@ namespace Common.Utilities
styleIndex -= numRemoved;
}
firstXmlCloseTagIndex -= numRemoved;
stringSvgData = RemoveAttribute(stringSvgData, heightIndex, HeightAttribute, out numRemoved);
if (styleIndex != -1 && styleIndex > heightIndex)
{
styleIndex -= numRemoved;
}
firstXmlCloseTagIndex -= numRemoved;
stringSvgData = RemoveAttribute(stringSvgData, styleIndex, StyleAttribute, out numRemoved);
firstXmlCloseTagIndex -= numRemoved;
width = CheckUnit(width);
height = CheckUnit(height);
@@ -213,7 +218,7 @@ namespace Common.Utilities
scaling += $" _height:expression(this.scrollHeight &gt; {heightR} ? &quot; {height}&quot; : &quot;auto&quot;); _width:expression(this.scrollWidth &gt; {widthR} ? &quot;{width}&quot; : &quot;auto&quot;);";
string newStyle = $"style=\"{scaling}{centering}{oldStyle}\"";
int insertAt = stringSvgData.IndexOf(">", StringComparison.InvariantCultureIgnoreCase);
int insertAt = firstXmlCloseTagIndex;
stringSvgData = stringSvgData.Insert(insertAt, " " + newStyle);

View File

@@ -445,7 +445,7 @@ namespace RegistryPreview
i++;
}
if (value[i - 1] != '\\' && value[i] == '"')
if (i < value.Length && value[i - 1] != '\\' && value[i] == '"')
{
// Don't allow non-escaped quotes
registryValue.Type = "ERROR";

View File

@@ -140,6 +140,9 @@
<ProjectReference Include="..\VideoConferenceShared\VideoConferenceShared.vcxproj">
<Project>{459e0768-7ebd-4c41-bba1-6db3b3815e0a}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\common\version\version.vcxproj">
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">