Merge remote-tracking branch 'origin/main' into dev/snickler/net8-upgrade

This commit is contained in:
Jeremy Sinclair 2023-09-06 12:08:41 -04:00
commit ce5e0d7981
55 changed files with 652 additions and 356 deletions

View File

@ -112,7 +112,7 @@ AUTHN
AUTHZ AUTHZ
AUTOHIDE AUTOHIDE
AUTOMATIONPROPERTIES AUTOMATIONPROPERTIES
Autorun autorun
AUTOUPDATE AUTOUPDATE
AValid AValid
awakeness awakeness
@ -144,7 +144,7 @@ Blockquotes
blogs blogs
Blt Blt
BLUEGRAY BLUEGRAY
Bluetooth bluetooth
BLURBEHIND BLURBEHIND
BLURREGION BLURREGION
bmi bmi
@ -564,7 +564,6 @@ FARPROC
fdw fdw
feimage feimage
fff fff
fileapi
FILEEXPLORER FILEEXPLORER
FILEFLAGS FILEFLAGS
FILEFLAGSMASK FILEFLAGSMASK
@ -606,9 +605,9 @@ FZE
gabime gabime
GAC GAC
gacutil gacutil
Galaxi
Gaeilge Gaeilge
Gaidhlig Gaidhlig
Galaxi
GBarm GBarm
Gbits Gbits
Gbps Gbps
@ -620,6 +619,7 @@ gdi
gdiplus gdiplus
GDISCALED GDISCALED
GEmoji GEmoji
GETCLIENTAREAANIMATION
GETDESKWALLPAPER GETDESKWALLPAPER
GETDLGCODE GETDLGCODE
GETDPISCALEDSIZE GETDPISCALEDSIZE
@ -1569,7 +1569,6 @@ renamable
RENAMEONCOLLISION RENAMEONCOLLISION
Renamer Renamer
reparent reparent
reparented
reparenting reparenting
reparse reparse
reportbug reportbug
@ -1882,7 +1881,6 @@ talynone
TApp TApp
TApplication TApplication
TApplied TApplied
Taras
targ targ
TARGETAPPHEADER TARGETAPPHEADER
TARGETDIR TARGETDIR

View File

@ -212,7 +212,7 @@ configuration:
- addLabel: - addLabel:
label: Resolution-Helped User label: Resolution-Helped User
- addReply: - addReply:
reply: This issue is now marked as resolved. If you have any follow-up questions, please don't hesitate to ask. You can find out more about PowerToys functionalities in our [end-user documentation](https://aka.ms/powertoy-docs]. reply: This issue is now marked as resolved. If you have any follow-up questions, please don't hesitate to ask. You can find out more about PowerToys functionalities in our [end-user documentation](https://aka.ms/powertoy-docs).
- closeIssue - closeIssue
description: description:
- if: - if:

View File

@ -281,6 +281,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "utils", "utils", "{B39DC643
src\common\utils\logger_helper.h = src\common\utils\logger_helper.h src\common\utils\logger_helper.h = src\common\utils\logger_helper.h
src\common\utils\modulesRegistry.h = src\common\utils\modulesRegistry.h src\common\utils\modulesRegistry.h = src\common\utils\modulesRegistry.h
src\common\utils\MsiUtils.h = src\common\utils\MsiUtils.h src\common\utils\MsiUtils.h = src\common\utils\MsiUtils.h
src\common\utils\MsWindowsSettings.h = src\common\utils\MsWindowsSettings.h
src\common\utils\os-detect.h = src\common\utils\os-detect.h src\common\utils\os-detect.h = src\common\utils\os-detect.h
src\common\utils\package.h = src\common\utils\package.h src\common\utils\package.h = src\common\utils\package.h
src\common\utils\ProcessWaiter.h = src\common\utils\ProcessWaiter.h src\common\utils\ProcessWaiter.h = src\common\utils\ProcessWaiter.h

168
README.md
View File

@ -39,19 +39,19 @@ Microsoft PowerToys is a set of utilities for power users to tune and streamline
Go to [Microsoft PowerToys GitHub releases page][github-release-link], click on `Assets` at the bottom to show the files available in the release. Please use the appropriate PowerToys installer that matches your machine's architecture and install scope. For most, it is `x64` and per-user. Go to [Microsoft PowerToys GitHub releases page][github-release-link], click on `Assets` at the bottom to show the files available in the release. Please use the appropriate PowerToys installer that matches your machine's architecture and install scope. For most, it is `x64` and per-user.
<!-- items that need to be updated release to release --> <!-- items that need to be updated release to release -->
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F46 [github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F47
[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F45 [github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F46
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.72.0/PowerToysUserSetup-0.72.0-x64.exe [ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.73.0/PowerToysUserSetup-0.73.0-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.72.0/PowerToysUserSetup-0.72.0-arm64.exe [ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.73.0/PowerToysUserSetup-0.73.0-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.72.0/PowerToysSetup-0.72.0-x64.exe [ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.73.0/PowerToysSetup-0.73.0-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.72.0/PowerToysSetup-0.72.0-arm64.exe [ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.73.0/PowerToysSetup-0.73.0-arm64.exe
| Description | Filename | sha256 hash | | Description | Filename | sha256 hash |
|----------------|----------|-------------| |----------------|----------|-------------|
| Per user - x64 | [PowerToysUserSetup-0.72.0-x64.exe][ptUserX64] | 9925894D797458C78A8C3DF6FE4BD748580638B01BB43680477763662915109A | | Per user - x64 | [PowerToysUserSetup-0.73.0-x64.exe][ptUserX64] | BA55D245BDD734FD6F19803DD706A3AB8E0ABC491591195534997CF2122D3B7E |
| Per user - ARM64 | [PowerToysUserSetup-0.72.0-arm64.exe][ptUserArm64] | 2E68139C22C56648E64514E4E8E0A0D12882F6CF30B48EB20ECC66B4CCDD5909 | | Per user - ARM64 | [PowerToysUserSetup-0.73.0-arm64.exe][ptUserArm64] | FBFA40EA5FFA05236A7CCDD05E5142EE0C93D7485B965784196ED9B086BFEBF4 |
| Machine wide - x64 | [PowerToysSetup-0.72.0-x64.exe][ptMachineX64] | 788EE4D828169F092737A739030B218CEFEC79583E42858BB8F9F036B701BE6F | | Machine wide - x64 | [PowerToysSetup-0.73.0-x64.exe][ptMachineX64] | 7FDA06292C7C2E6DA5AEF88D8E9D3DE89D331E9E356A232289F9B37CE4503894 |
| Machine wide - ARM64 | [PowerToysSetup-0.72.0-arm64.exe][ptMachineArm64] | 39C1D430A538B0F3D7869D39DF7F636A64AAFAD8DFB3C82059A97F4EBD3369C4 | | Machine wide - ARM64 | [PowerToysSetup-0.73.0-arm64.exe][ptMachineArm64] | 4260AA30A1F52F194EE07E9E7ECD9E9F4CF35289267F213BC933F7A5191AC17C |
This is our preferred method. This is our preferred method.
@ -97,130 +97,138 @@ For guidance on developing for PowerToys, please read the [developer docs](/doc/
Our [prioritized roadmap][roadmap] of features and utilities that the core team is focusing on. Our [prioritized roadmap][roadmap] of features and utilities that the core team is focusing on.
### 0.72 - July 2023 Update ### 0.73 - August 2023 Update
In this release, we focused on stability and improvements. In this release, we focused on releasing new features, stability and improvements.
**Highlights** **Highlights**
- Greatly reduced the PowerToys installed space by having utilities share the same installed path. When compared to 0.71, the 0.72 x64 machine installed version of PowerToys reduces the size reported in the Installed Apps screen from 1.15GB to 785 MB and the size in File Explorer properties for the installation folder from 3.10GB to 554 MB. - Keyboard manager now supports Numpad. Note, with previously bound hotkeys stored in settings.json would only react to non-Numpad keys now. If a user wishes to restore the previous behavior, it could be done by manually adding another binding for the Numpad variant.
- Value Generator - A new PowerToys Run plugin that generates hashes and GUID values. Thanks [@IHorvalds](https://github.com/IHorvalds)! - New utility: Crop And Lock allows you to crop a current application into a smaller window or just create a thumbnail. Focus the target window and press the shortcut to start cropping.
- Mouse Highlighter has a new feature to have a highlight always follow the mouse pointer. Thanks [@hayatogh](https://github.com/hayatogh)! - FancyZones code improvements and refactor.
- PowerRename was reworked to support a bigger number of files without crashing. - Modernized ImageResizer UX.
- PowerRename advanced counter functionality.
### Known issues
- Due to changing paths in the installation folder, the Mouse Without Borders service might be pointing to the wrong place. Users not running as admin will have to enable service mode again after install. A toast notification will appear if Mouse Without Borders is unable to start the service correctly.
- File Explorer extensions changed paths might not be loaded correctly until File Explorer and Preview Host processes are restarted, so we advise restarting the computer when possible after updating PowerToys.
### General ### General
- Shared dependencies between applications in order to greatly reduce the installed size. - Added missing CoUninitialize call in elevation logic. Thanks [@sredna](https://github.com/sredna)!
- Added missing icons and icon sizes. Thanks [@niels9001](https://github.com/niels9001)! - New utility: Crop And Lock. Thanks [@robmikh](https://github.com/robmikh)! and [@kevinguo305](https://github.com/kevinguo305)!
- Added new /helped fabric bot command to GitHub repo. Thanks [@Aaron-Junker](https://github.com/Aaron-Junker)!
- Fixed crashes caused by invalid settings. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### Always On Top
- Added border transparency.
### FancyZones ### FancyZones
- Fixed an issue where FancyZones wouldn't register a change to the "Switch between windows in the current zone" setting. - Fixed issue causing canvas zones being drawn only when dragging in zone area.
- Added a Setting to enable the behavior of clicking the middle mouse button to toggle multiple zone spanning. - Fixed user-defined default layout highlighting issue.
- Refactored and improved code quality.
- Fixed issue causing wrong layout to be applied when duplicating non-selected layout.
### File Locksmith ### File Locksmith
- Fixed a File Explorer crash when deleting a file, updating PowerToys and then trying to right-click the background of a folder in File Explorer. - Icon update. Thanks [@jmaraujouy](https://github.com/jmaraujouy)!
- UI tweaks. Thanks [@Jay-o-Way](https://github.com/Jay-o-Way)!
### File Explorer add-ons ### File Explorer add-ons
- Updated the Monaco dependency for Developer Files Preview, supporting new file extensions and fixing issues. Thanks [@Aaron-Junker](https://github.com/Aaron-Junker)! - Fixed issue causing thumbnail previewers to lock files.
- Open URIs from developer files in default browser. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### Hosts File Editor
- Consolidated the way the Hosts application is launched. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- UI tweaks. Thanks [@Jay-o-Way](https://github.com/Jay-o-Way)!
### Installer ### Installer
- Refactored the Monaco dependency inclusion. What to install is now being generated automatically. - Fixed PowerToys autorun after installing as SYSTEM user.
- Removed hardlinks and simplified the installer files, now that many utilities use the same paths. - Removed CreateScheduledTask custom action to handle task creation only from runner code.
### Image Resizer
- Moved from ModernWPF to WpfUI to refresh and modernize UI/UX. Thanks [@niels9001](https://github.com/niels9001)!
### Keyboard Manager
- Rephrased labels to enhance clarity. Thanks [@Jay-o-Way](https://github.com/Jay-o-Way)!
- Keyboard manager now supports Numpad. Note, with previously bound hotkeys stored in settings.json would only react to non-Numpad keys now. If a user wishes to restore the previous behavior, it could be done by manually adding another binding for the Numpad variant.
### Mouse Highlighter ### Mouse Highlighter
- Added a feature so that a highlight follows the mouse even if no mouse button is being pressed. Thanks [@hayatogh](https://github.com/hayatogh)! - Fixed highlighter being invisible issue for Always on Top windows.
- Added settings for automatic activation on startup. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### Mouse Pointer Crosshairs ### Mouse Pointer Crosshairs
- Added a setting to hide the crosshairs when the mouse pointer is also hidden. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - Added settings for automatic activation on startup. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Added a setting to select a fixed length for the crosshairs, which also spans across screens. Thanks [@Epp-code](https://github.com/Epp-code)!
### Mouse Without Borders
- Switched to a UWP mouse input API to fix mouse pointer lag issues that were reported.
- A toast notification will appear when the service can't be started and Mouse Without Borders will try to start in non-service mode instead.
- Fixed a bug where the service path wouldn't update to the new binary path when trying to re-enable service mode.
- Fixed some grammar errors in the Mouse Without Borders user facing strings. Thanks [@KhurramJalil](https://github.com/KhurramJalil)!
- Allow changing the shortcuts in the same way as other utilities and changed them to better defaults to avoid conflicting with Alt Gr+letter combos on international layouts.
### Peek ### Peek
- Also benefits from the Monaco dependency update when peeking into files supported by the Developer Files Preview. Thanks [@Aaron-Junker](https://github.com/Aaron-Junker)! - Show correct file type for shortcuts. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Fixed a flash on PowerToys starting due to the Peek window activating and hiding right away. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - Fixed issue causing wrong file size to be displayed. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Updated icon design. Thanks [@niels9001](https://github.com/niels9001)! - Show 1 byte instead of 1 bytes file size. Thanks [@Deepak-Sangle](https://github.com/Deepak-Sangle)!
- Fixed flipped content issues on systems with RTL languages. - Open URIs from developer files in default browser. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Show thumbnail and fallback to icon for unsupported files. Thanks [@pedrolamas](https://github.com/pedrolamas)!
### PowerRename ### PowerRename
- Reworked the UI and resource consumption to fix crashes and hangs when trying to rename a huge number of files. - Updated OOBE gif. Thanks [@ChaseKnowlden](https://github.com/ChaseKnowlden)!
- Added the Mica background material and some UI tweaks. Thanks [@niels9001](https://github.com/niels9001)! - Localized renamed parts combo box.
- Introduced advanced counter functionality.
- Added remember last window size logic and optimized items sorting.
- Enable "Enumerate items" option by default.
### PowerToys Run ### PowerToys Run
- New plugin: Value Generator - generates values like hashes and GUIDs. Thanks [@IHorvalds](https://github.com/IHorvalds)! - Fixed issue causing original search to be abandoned when cycling through results.
- The default input smoothing values were changed to the recommended values. Thanks [@SamMercer172](https://github.com/SamMercer172)! - Updated device and bluetooth results for Settings plugin. Thanks [@htcfreek](https://github.com/htcfreek)!
- Fixed tab navigation issues when using Shift+Tab to go backwards. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - Fixed InvalidOperationException exception thrown. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Fixed a crash caused by images not being found in the image cache due to racing conditions. - Add Base64 Decoding function to the Value Generator plugin. Thanks [@LeagueOfPoro](https://github.com/LeagueOfPoro)!
- Fixed synchronization issues in the WindowWalker plugin. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - Added Keep shell open option for Shell plugin.
- Fixed a synchronization crash when getting localized system paths. - Added Crop And Lock to PowerToys plugin. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- The PowerToys plugin is now activated by default. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### Quick Accent
- Added the ("ḍ", U+1E0D) unicode character. Thanks [@SamMercer172](https://github.com/SamMercer172)!
- Fixed an issue causing the left and right keys being discarded even when Quick Accent didn't activate.
### Registry Preview ### Registry Preview
- Fixed a bug causing DWORD values to not be shown correctly. Thanks [@randyrants](https://github.com/randyrants)! - Updated AppBarButtons to use an explicit AppBarButton.Icon. Thanks [@randyrants](https://github.com/randyrants)!
- UI tweaks. Thanks [@Jay-o-Way](https://github.com/Jay-o-Way)! - Fixed crash on clicking Save As button.
### Runner ### Runner
- Show a warning asking the user to restart the computer after updating the PowerToys version. - Removed unneeded RegisterWindowMessage from tray icon logic. Thanks [@sredna](https://github.com/sredna)!
- Fixed startup looping issue.
- Improved old logs and installers cleanup logic. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### Screen Ruler ### Screen Ruler
- UI tweaks. Thanks [@Jay-o-Way](https://github.com/Jay-o-Way)! - Use proper resources file.
### Settings ### Settings
- Fix an unused Expander in the File Locksmith settings page. - Fixed issue causing problems with modifier keys and ShortcutControl. Thanks [@sh0ckj0ckey](https://github.com/sh0ckj0ckey)!
- Added an info box to better explain what the extended context menu is. - Fixed crash when clicking "Windows color settings" link.
- Added support for launching Settings app directly.
- Fixed issue causing DisplayDescription not showing for PowerToys Run PluginAdditionalOption.
- Fixed issue causing FileLocksmith 'Show File Locksmith in' setting not showing correct value.
- Fixed issue causing Awake on/off toggle in Settings flyout not to work when Settings Awake page is opened.
### Documentation
- Added documentation for PowerToys Run third-party plugins. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Fixed broken links in keyboardmanagerui.md. Thanks [@shubhsardana29](https://github.com/shubhsardana29)!
- Updated core team in COMMUNITY.md.
- Fixed broken links in ui-architecture.md. Thanks [@SamB](https://github.com/SamB)!
- Updated community.valuegenerator.md with Base64DecodeRequest description.
### Development ### Development
- Projects were restructured to allow sharing the same folder and dependencies and to avoid resource name conflicts. - Updated test packages and StyleCop. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Added scripts to CI to guard against applications having conflicting resources. - Condense NuGet Restore into MSBuild Tasks. Thanks [@snickler](https://github.com/snickler)!
- Added scripts to CI to guard against depending on different versions of the same dependency.
- Test projects now build to a separate path.
- Dependencies updated across the solution to ensure every project is using the same dependencies.
#### What is being planned for version 0.73 #### What is being planned for version 0.74
For [v0.73][github-next-release-work], we'll work on below: For [v0.74][github-next-release-work], we'll work on below:
- New utility: Crop and Lock
- Language selection - Language selection
- PowerRename enumeration keywords
- Modernize and refresh UX of PowerToys based on WPF - Modernize and refresh UX of PowerToys based on WPF
- Stability / bug fixes - Stability / bug fixes
- Peek: UI improvements - Peek: UI improvements
## PowerToys Community ## PowerToys Community

View File

@ -145,6 +145,7 @@ void LayoutMap::LayoutMapImpl::UpdateLayout()
keyboardLayoutMap[VK_RETURN | numpadOriginBit] = L"Enter (Numpad)"; keyboardLayoutMap[VK_RETURN | numpadOriginBit] = L"Enter (Numpad)";
keyboardLayoutMap[VK_DIVIDE | numpadOriginBit] = L"/ (Numpad)"; keyboardLayoutMap[VK_DIVIDE | numpadOriginBit] = L"/ (Numpad)";
keyboardLayoutMap[VK_SUBTRACT] = L"- (Substract)";
keyboardLayoutMap[VK_SELECT] = L"Select"; keyboardLayoutMap[VK_SELECT] = L"Select";
keyboardLayoutMap[VK_PRINT] = L"Print"; keyboardLayoutMap[VK_PRINT] = L"Print";
keyboardLayoutMap[VK_EXECUTE] = L"Execute"; keyboardLayoutMap[VK_EXECUTE] = L"Execute";

View File

@ -0,0 +1,13 @@
#pragma once
inline bool GetAnimationsEnabled()
{
BOOL enabled = 0;
BOOL fResult;
fResult = SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &enabled, 0);
if (!fResult)
{
Logger::error("SystemParametersInfo SPI_GETCLIENTAREAANIMATION failed.");
}
return enabled;
}

View File

@ -76,6 +76,8 @@ namespace Hosts.Tests
[DataRow("host 10.1.1.1")] [DataRow("host 10.1.1.1")]
[DataRow("# comment 10.1.1.1 host # comment")] [DataRow("# comment 10.1.1.1 host # comment")]
[DataRow("10.1.1.1 host01 host02 host03 host04 host05 host06 host07 host08 host09 host10")] [DataRow("10.1.1.1 host01 host02 host03 host04 host05 host06 host07 host08 host09 host10")]
[DataRow("102.54.94.97 rhino.acme.com # source server")]
[DataRow("38.25.63.10 x.acme.com # x client host")]
public void Not_Valid_Entry(string line) public void Not_Valid_Entry(string line)
{ {
var entry = new Entry(0, line); var entry = new Entry(0, line);

View File

@ -448,7 +448,7 @@
ScrollViewer.IsVerticalRailEnabled="True" ScrollViewer.IsVerticalRailEnabled="True"
ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollMode="Enabled" ScrollViewer.VerticalScrollMode="Enabled"
Text="{Binding Comment, Mode=TwoWay}" /> Text="{Binding Comment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<ToggleSwitch <ToggleSwitch
x:Uid="Active" x:Uid="Active"
IsOn="{Binding Active, Mode=TwoWay}" IsOn="{Binding Active, Mode=TwoWay}"

View File

@ -44,6 +44,7 @@ namespace Hosts.Models
} }
[ObservableProperty] [ObservableProperty]
[NotifyPropertyChangedFor(nameof(Valid))]
private string _comment; private string _comment;
[ObservableProperty] [ObservableProperty]
@ -153,7 +154,19 @@ namespace Hosts.Models
public bool Validate(bool validateHostsLength) public bool Validate(bool validateHostsLength)
{ {
if (Equals("102.54.94.97", "rhino.acme.com", "source server") || Equals("38.25.63.10", "x.acme.com", "x client host"))
{
return false;
}
return Type != AddressType.Invalid && ValidationHelper.ValidHosts(Hosts, validateHostsLength); return Type != AddressType.Invalid && ValidationHelper.ValidHosts(Hosts, validateHostsLength);
} }
private bool Equals(string address, string hosts, string comment)
{
return string.Equals(Address, address, StringComparison.Ordinal)
&& string.Equals(Hosts, hosts, StringComparison.Ordinal)
&& string.Equals(Comment, comment, StringComparison.Ordinal);
}
} }
} }

View File

@ -2,10 +2,12 @@
// //
#include "pch.h" #include "pch.h"
#include "FindMyMouse.h" #include "FindMyMouse.h"
#include "WinHookEventIDs.h"
#include "trace.h" #include "trace.h"
#include "common/utils/game_mode.h" #include "common/utils/game_mode.h"
#include "common/utils/process_path.h" #include "common/utils/process_path.h"
#include "common/utils/excluded_apps.h" #include "common/utils/excluded_apps.h"
#include "common/utils/MsWindowsSettings.h"
#include <vector> #include <vector>
#ifdef COMPOSITION #ifdef COMPOSITION
@ -246,6 +248,18 @@ LRESULT SuperSonar<D>::BaseWndProc(UINT message, WPARAM wParam, LPARAM lParam) n
return HTTRANSPARENT; return HTTRANSPARENT;
} }
if (message == WM_PRIV_SHORTCUT)
{
if (m_sonarStart == NoSonar)
{
StartSonar();
}
else
{
StopSonar();
}
}
return DefWindowProc(m_hwnd, message, wParam, lParam); return DefWindowProc(m_hwnd, message, wParam, lParam);
} }
@ -291,26 +305,27 @@ void SuperSonar<D>::OnSonarInput(WPARAM flags, HRAWINPUT hInput)
template<typename D> template<typename D>
void SuperSonar<D>::OnSonarKeyboardInput(RAWINPUT const& input) void SuperSonar<D>::OnSonarKeyboardInput(RAWINPUT const& input)
{ {
if ( m_activationMethod != FindMyMouseActivationMethod::DoubleControlKey || input.data.keyboard.VKey != VK_CONTROL) // Don't stop the sonar when the shortcut is released
if (m_activationMethod == FindMyMouseActivationMethod::Shortcut && (input.data.keyboard.Flags & RI_KEY_BREAK) != 0)
{
return;
}
if ((m_activationMethod != FindMyMouseActivationMethod::DoubleRightControlKey && m_activationMethod != FindMyMouseActivationMethod::DoubleLeftControlKey)
|| input.data.keyboard.VKey != VK_CONTROL)
{ {
StopSonar(); StopSonar();
return; return;
} }
bool pressed = (input.data.keyboard.Flags & RI_KEY_BREAK) == 0; bool pressed = (input.data.keyboard.Flags & RI_KEY_BREAK) == 0;
bool rightCtrl = (input.data.keyboard.Flags & RI_KEY_E0) != 0;
// Deal with rightCtrl first. bool leftCtrlPressed = (input.data.keyboard.Flags & RI_KEY_E0) == 0;
if (rightCtrl) bool rightCtrlPressed = (input.data.keyboard.Flags & RI_KEY_E0) != 0;
if ((m_activationMethod == FindMyMouseActivationMethod::DoubleRightControlKey && !rightCtrlPressed)
|| (m_activationMethod == FindMyMouseActivationMethod::DoubleLeftControlKey && !leftCtrlPressed))
{ {
/*
* SuperSonar originally exited when pressing right control after pressing left control twice.
* We take care of exiting FindMyMouse through module disabling in PowerToys settings instead.
if (m_sonarState == SonarState::ControlUp2)
{
Terminate();
}
*/
StopSonar(); StopSonar();
return; return;
} }
@ -634,6 +649,8 @@ struct CompositionSpotlight : SuperSonar<CompositionSpotlight>
void SetSonarVisibility(bool visible) void SetSonarVisibility(bool visible)
{ {
m_batch = m_compositor.GetCommitBatch(winrt::CompositionBatchTypes::Animation); m_batch = m_compositor.GetCommitBatch(winrt::CompositionBatchTypes::Animation);
BOOL isEnabledAnimations = GetAnimationsEnabled();
m_animation.Duration(std::chrono::milliseconds{ isEnabledAnimations ? m_fadeDuration : 1 });
m_batch.Completed([hwnd = m_hwnd](auto&&, auto&&) { m_batch.Completed([hwnd = m_hwnd](auto&&, auto&&) {
PostMessage(hwnd, WM_OPACITY_ANIMATION_COMPLETED, 0, 0); PostMessage(hwnd, WM_OPACITY_ANIMATION_COMPLETED, 0, 0);
}); });
@ -644,6 +661,11 @@ struct CompositionSpotlight : SuperSonar<CompositionSpotlight>
} }
} }
HWND GetHwnd() noexcept
{
return m_hwnd;
}
private: private:
bool OnCompositionCreate() bool OnCompositionCreate()
try try
@ -1057,6 +1079,8 @@ int FindMyMouseMain(HINSTANCE hinst, const FindMyMouseSettings& settings)
m_sonar = &sonar; m_sonar = &sonar;
Logger::info("Initialized the sonar instance."); Logger::info("Initialized the sonar instance.");
InitializeWinhookEventIds();
MSG msg; MSG msg;
// Main message loop: // Main message loop:
@ -1072,4 +1096,14 @@ int FindMyMouseMain(HINSTANCE hinst, const FindMyMouseSettings& settings)
return (int)msg.wParam; return (int)msg.wParam;
} }
HWND GetSonarHwnd() noexcept
{
if (m_sonar != nullptr)
{
return m_sonar->GetHwnd();
}
return nullptr;
}
#pragma endregion Super_Sonar_API #pragma endregion Super_Sonar_API

View File

@ -3,9 +3,11 @@
enum struct FindMyMouseActivationMethod : int enum struct FindMyMouseActivationMethod : int
{ {
DoubleControlKey = 0, DoubleLeftControlKey = 0,
ShakeMouse = 1, DoubleRightControlKey = 1,
EnumElements = 2, // number of elements in the enum, not counting this ShakeMouse = 2,
Shortcut = 3,
EnumElements = 4, // number of elements in the enum, not counting this
}; };
constexpr bool FIND_MY_MOUSE_DEFAULT_DO_NOT_ACTIVATE_ON_GAME_MODE = true; constexpr bool FIND_MY_MOUSE_DEFAULT_DO_NOT_ACTIVATE_ON_GAME_MODE = true;
@ -15,7 +17,7 @@ constexpr int FIND_MY_MOUSE_DEFAULT_OVERLAY_OPACITY = 50;
constexpr int FIND_MY_MOUSE_DEFAULT_SPOTLIGHT_RADIUS = 100; constexpr int FIND_MY_MOUSE_DEFAULT_SPOTLIGHT_RADIUS = 100;
constexpr int FIND_MY_MOUSE_DEFAULT_ANIMATION_DURATION_MS = 500; constexpr int FIND_MY_MOUSE_DEFAULT_ANIMATION_DURATION_MS = 500;
constexpr int FIND_MY_MOUSE_DEFAULT_SPOTLIGHT_INITIAL_ZOOM = 9; constexpr int FIND_MY_MOUSE_DEFAULT_SPOTLIGHT_INITIAL_ZOOM = 9;
constexpr FindMyMouseActivationMethod FIND_MY_MOUSE_DEFAULT_ACTIVATION_METHOD = FindMyMouseActivationMethod::DoubleControlKey; constexpr FindMyMouseActivationMethod FIND_MY_MOUSE_DEFAULT_ACTIVATION_METHOD = FindMyMouseActivationMethod::DoubleLeftControlKey;
constexpr int FIND_MY_MOUSE_DEFAULT_SHAKE_MINIMUM_DISTANCE = 1000; constexpr int FIND_MY_MOUSE_DEFAULT_SHAKE_MINIMUM_DISTANCE = 1000;
struct FindMyMouseSettings struct FindMyMouseSettings
@ -36,3 +38,4 @@ int FindMyMouseMain(HINSTANCE hinst, const FindMyMouseSettings& settings);
void FindMyMouseDisable(); void FindMyMouseDisable();
bool FindMyMouseIsEnabled(); bool FindMyMouseIsEnabled();
void FindMyMouseApplySettings(const FindMyMouseSettings& settings); void FindMyMouseApplySettings(const FindMyMouseSettings& settings);
HWND GetSonarHwnd() noexcept;

View File

@ -93,6 +93,7 @@
<ClInclude Include="pch.h" /> <ClInclude Include="pch.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="trace.h" /> <ClInclude Include="trace.h" />
<ClInclude Include="WinHookEventIDs.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="dllmain.cpp" /> <ClCompile Include="dllmain.cpp" />
@ -101,6 +102,7 @@
<PrecompiledHeader Condition="'$(CIBuild)'!='true'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(CIBuild)'!='true'">Create</PrecompiledHeader>
</ClCompile> </ClCompile>
<ClCompile Include="trace.cpp" /> <ClCompile Include="trace.cpp" />
<ClCompile Include="WinHookEventIDs.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\common\logger\logger.vcxproj"> <ProjectReference Include="..\..\..\common\logger\logger.vcxproj">

View File

@ -30,6 +30,9 @@
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="WinHookEventIDs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="pch.h"> <ClInclude Include="pch.h">
@ -44,6 +47,9 @@
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="WinHookEventIDs.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="FindMyMouse.rc"> <ResourceCompile Include="FindMyMouse.rc">

View File

@ -0,0 +1,14 @@
#include "pch.h"
#include "WinHookEventIDs.h"
UINT WM_PRIV_SHORTCUT;
std::once_flag init_flag;
void InitializeWinhookEventIds()
{
std::call_once(init_flag, [&] {
WM_PRIV_SHORTCUT = RegisterWindowMessage(L"{1365FFC7-A44E-4171-9692-A3EEF378AE60}");
});
}

View File

@ -0,0 +1,5 @@
#pragma once
extern UINT WM_PRIV_SHORTCUT; // Shortcut is pressed
void InitializeWinhookEventIds();

View File

@ -3,6 +3,7 @@
#include <common/SettingsAPI/settings_objects.h> #include <common/SettingsAPI/settings_objects.h>
#include "trace.h" #include "trace.h"
#include "FindMyMouse.h" #include "FindMyMouse.h"
#include "WinHookEventIDs.h"
#include <thread> #include <thread>
#include <common/utils/logger_helper.h> #include <common/utils/logger_helper.h>
#include <common/utils/color.h> #include <common/utils/color.h>
@ -22,6 +23,7 @@ namespace
const wchar_t JSON_KEY_SPOTLIGHT_INITIAL_ZOOM[] = L"spotlight_initial_zoom"; const wchar_t JSON_KEY_SPOTLIGHT_INITIAL_ZOOM[] = L"spotlight_initial_zoom";
const wchar_t JSON_KEY_EXCLUDED_APPS[] = L"excluded_apps"; const wchar_t JSON_KEY_EXCLUDED_APPS[] = L"excluded_apps";
const wchar_t JSON_KEY_SHAKING_MINIMUM_DISTANCE[] = L"shaking_minimum_distance"; const wchar_t JSON_KEY_SHAKING_MINIMUM_DISTANCE[] = L"shaking_minimum_distance";
const wchar_t JSON_KEY_ACTIVATION_SHORTCUT[] = L"activation_shortcut";
} }
extern "C" IMAGE_DOS_HEADER __ImageBase; extern "C" IMAGE_DOS_HEADER __ImageBase;
@ -58,6 +60,9 @@ private:
// The PowerToy state. // The PowerToy state.
bool m_enabled = false; bool m_enabled = false;
// Hotkey to invoke the module
HotkeyEx m_hotkey;
// Find My Mouse specific settings // Find My Mouse specific settings
FindMyMouseSettings m_findMyMouseSettings; FindMyMouseSettings m_findMyMouseSettings;
@ -157,6 +162,27 @@ public:
{ {
return m_enabled; return m_enabled;
} }
virtual std::optional<HotkeyEx> GetHotkeyEx() override
{
Logger::trace("GetHotkeyEx()");
if (m_findMyMouseSettings.activationMethod == FindMyMouseActivationMethod::Shortcut)
{
return m_hotkey;
}
return std::nullopt;
}
virtual void OnHotkeyEx() override
{
Logger::trace("OnHotkeyEx()");
HWND hwnd = GetSonarHwnd();
if (hwnd != nullptr)
{
PostMessageW(hwnd, WM_PRIV_SHORTCUT, NULL, NULL);
}
}
}; };
// Load the settings file. // Load the settings file.
@ -188,7 +214,15 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE)); int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
if (value < static_cast<int>(FindMyMouseActivationMethod::EnumElements) && value >= 0) if (value < static_cast<int>(FindMyMouseActivationMethod::EnumElements) && value >= 0)
{ {
findMyMouseSettings.activationMethod = static_cast<FindMyMouseActivationMethod>(value); std::wstring version = (std::wstring)settingsObject.GetNamedString(L"version");
if (version == L"1.0" && value == 1)
{
findMyMouseSettings.activationMethod = FindMyMouseActivationMethod::ShakeMouse;
}
else
{
findMyMouseSettings.activationMethod = static_cast<FindMyMouseActivationMethod>(value);
}
} }
else else
{ {
@ -362,6 +396,46 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
{ {
Logger::warn("Failed to initialize Shaking Minimum Distance from settings. Will use default value"); Logger::warn("Failed to initialize Shaking Minimum Distance from settings. Will use default value");
} }
try
{
// Parse HotKey
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_ACTIVATION_SHORTCUT);
auto hotkey = PowerToysSettings::HotkeyObject::from_json(jsonPropertiesObject);
m_hotkey = HotkeyEx();
if (hotkey.win_pressed())
{
m_hotkey.modifiersMask |= MOD_WIN;
}
if (hotkey.ctrl_pressed())
{
m_hotkey.modifiersMask |= MOD_CONTROL;
}
if (hotkey.shift_pressed())
{
m_hotkey.modifiersMask |= MOD_SHIFT;
}
if (hotkey.alt_pressed())
{
m_hotkey.modifiersMask |= MOD_ALT;
}
m_hotkey.vkCode = static_cast<WORD>(hotkey.get_code());
}
catch (...)
{
Logger::warn("Failed to initialize Activation Shortcut from settings. Will use default value");
}
if (!m_hotkey.modifiersMask)
{
Logger::info("Using default Activation Shortcut");
m_hotkey.modifiersMask = MOD_SHIFT | MOD_WIN;
m_hotkey.vkCode = 0x46; // F key
}
} }
else else
{ {

View File

@ -5,6 +5,7 @@
#include "start_visible.h" #include "start_visible.h"
#include <common/utils/resources.h> #include <common/utils/resources.h>
#include <common/utils/window.h> #include <common/utils/window.h>
#include <common/utils/MsWindowsSettings.h>
#include "shortcut_guide.h" #include "shortcut_guide.h"
#include "trace.h" #include "trace.h"
@ -269,11 +270,12 @@ D2D1_RECT_F D2DOverlaySVG::get_snap_right() const
D2DOverlayWindow::D2DOverlayWindow() : D2DOverlayWindow::D2DOverlayWindow() :
total_screen({}), total_screen({}),
background_animation(0.3),
global_windows_shortcuts_animation(0.3),
taskbar_icon_shortcuts_animation(0.3),
D2DWindow() D2DWindow()
{ {
BOOL isEnabledAnimations = GetAnimationsEnabled();
background_animation = isEnabledAnimations? 0.3f : 0.f;
global_windows_shortcuts_animation = isEnabledAnimations ? 0.3f : 0.f;
taskbar_icon_shortcuts_animation = isEnabledAnimations ? 0.3f : 0.f;
tasklist_thread = std::thread([&] { tasklist_thread = std::thread([&] {
while (running) while (running)
{ {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View File

@ -124,6 +124,14 @@ bool WorkArea::Snap(HWND window, const ZoneIndexSet& zones, bool updatePosition)
return false; return false;
} }
for (ZoneIndex zone : zones)
{
if (static_cast<size_t>(zone) >= m_layout->Zones().size())
{
return false;
}
}
m_layoutWindows.Assign(window, zones); m_layoutWindows.Assign(window, zones);
AppZoneHistory::instance().SetAppLastZones(window, m_uniqueId, m_layout->Id(), zones); AppZoneHistory::instance().SetAppLastZones(window, m_uniqueId, m_layout->Id(), zones);

View File

@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include <common/logger/logger.h> #include <common/logger/logger.h>
#include <common/utils/MsWindowsSettings.h>
namespace namespace
{ {
@ -125,6 +126,12 @@ ZonesOverlay::RenderResult ZonesOverlay::Render()
return RenderResult::AnimationEnded; return RenderResult::AnimationEnded;
} }
BOOL isEnabledAnimations = GetAnimationsEnabled();
if (!isEnabledAnimations)
{
animationAlpha = 1.f;
}
m_renderTarget->BeginDraw(); m_renderTarget->BeginDraw();
// Draw backdrop // Draw backdrop

View File

@ -316,6 +316,28 @@ namespace FancyZonesUnitTests
Assert::IsTrue(expected == layoutWindows.GetZoneIndexSetFromWindow(window)); Assert::IsTrue(expected == layoutWindows.GetZoneIndexSetFromWindow(window));
} }
TEST_METHOD(SnapEmptyZones)
{
const auto workArea = WorkArea::Create(m_hInst, m_workAreaId, m_parentUniqueId, m_workAreaRect);
const auto window = Mocks::WindowCreate(m_hInst);
Assert::IsFalse(workArea->Snap(window, {}));
}
TEST_METHOD(SnapToIncorrectZone)
{
const auto workArea = WorkArea::Create(m_hInst, m_workAreaId, m_parentUniqueId, m_workAreaRect);
const auto window = Mocks::WindowCreate(m_hInst);
const ZoneIndexSet zones = { 10 };
Assert::IsFalse(workArea->Snap(window, zones));
const auto processPath = get_process_path(window);
const auto history = AppZoneHistory::instance().GetZoneHistory(processPath, m_workAreaId);
Assert::IsFalse(history.has_value());
}
TEST_METHOD (UnsnapPropertyTest) TEST_METHOD (UnsnapPropertyTest)
{ {
const auto workArea = WorkArea::Create(m_hInst, m_workAreaId, m_parentUniqueId, m_workAreaRect); const auto workArea = WorkArea::Create(m_hInst, m_workAreaId, m_parentUniqueId, m_workAreaRect);

View File

@ -19,12 +19,13 @@ namespace FancyZonesEditor
private CanvasLayoutModel _model; private CanvasLayoutModel _model;
public CanvasEditor() public CanvasEditor(CanvasLayoutModel layout)
{ {
InitializeComponent(); InitializeComponent();
Loaded += OnLoaded; Loaded += OnLoaded;
Unloaded += OnUnloaded; Unloaded += OnUnloaded;
KeyDown += CanvasEditor_KeyDown; KeyDown += CanvasEditor_KeyDown;
_model = layout;
} }
private void CanvasEditor_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) private void CanvasEditor_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
@ -47,17 +48,8 @@ namespace FancyZonesEditor
private void OnLoaded(object sender, RoutedEventArgs e) private void OnLoaded(object sender, RoutedEventArgs e)
{ {
CanvasLayoutModel model = (CanvasLayoutModel)DataContext; UpdateZoneRects();
if (model != null) _model.PropertyChanged += OnModelChanged;
{
_model = model;
var workArea = App.Overlay.WorkArea;
UpdateZoneRects();
_model.PropertyChanged += OnModelChanged;
}
} }
private void OnUnloaded(object sender, RoutedEventArgs e) private void OnUnloaded(object sender, RoutedEventArgs e)

View File

@ -11,39 +11,28 @@ namespace FancyZonesEditor
{ {
public partial class CanvasEditorWindow : EditorWindow public partial class CanvasEditorWindow : EditorWindow
{ {
private CanvasLayoutModel _model; public CanvasEditorWindow(CanvasLayoutModel layout)
private CanvasLayoutModel _stashedModel; : base(layout)
public CanvasEditorWindow()
{ {
InitializeComponent(); InitializeComponent();
KeyUp += CanvasEditorWindow_KeyUp; KeyUp += CanvasEditorWindow_KeyUp;
KeyDown += CanvasEditorWindow_KeyDown; KeyDown += CanvasEditorWindow_KeyDown;
_model = App.Overlay.CurrentDataContext as CanvasLayoutModel;
_stashedModel = (CanvasLayoutModel)_model.Clone();
}
public LayoutModel Model
{
get
{
return _model;
}
} }
private void OnAddZone(object sender, RoutedEventArgs e) private void OnAddZone(object sender, RoutedEventArgs e)
{ {
Logger.LogInfo("Add zone"); Logger.LogInfo("Add zone");
_model.AddZone(); if (EditingLayout is CanvasLayoutModel canvas)
{
canvas.AddZone();
}
} }
protected new void OnCancel(object sender, RoutedEventArgs e) protected new void OnCancel(object sender, RoutedEventArgs e)
{ {
Logger.LogInfo("Cancel changes"); Logger.LogInfo("Cancel changes");
base.OnCancel(sender, e); base.OnCancel(sender, e);
_stashedModel.RestoreTo(_model);
} }
private void CanvasEditorWindow_KeyUp(object sender, KeyEventArgs e) private void CanvasEditorWindow_KeyUp(object sender, KeyEventArgs e)

View File

@ -11,29 +11,35 @@ namespace FancyZonesEditor
{ {
public class EditorWindow : Window public class EditorWindow : Window
{ {
public LayoutModel EditingLayout { get; set; }
public EditorWindow(LayoutModel editingLayout)
{
EditingLayout = editingLayout;
}
protected void OnSaveApplyTemplate(object sender, RoutedEventArgs e) protected void OnSaveApplyTemplate(object sender, RoutedEventArgs e)
{ {
Logger.LogTrace(); Logger.LogTrace();
var mainEditor = App.Overlay;
if (mainEditor.CurrentDataContext is LayoutModel model) // If new custom Canvas layout is created (i.e. edited Blank layout),
// it's type needs to be updated
if (EditingLayout.Type == LayoutType.Blank)
{ {
// If new custom Canvas layout is created (i.e. edited Blank layout), EditingLayout.Type = LayoutType.Custom;
// it's type needs to be updated
if (model.Type == LayoutType.Blank)
{
model.Type = LayoutType.Custom;
}
model.Persist();
MainWindowSettingsModel settings = ((App)Application.Current).MainWindowSettings;
settings.SetAppliedModel(model);
App.Overlay.Monitors[App.Overlay.CurrentDesktop].SetLayoutSettings(model);
} }
EditingLayout.Persist();
MainWindowSettingsModel settings = ((App)Application.Current).MainWindowSettings;
settings.SetAppliedModel(EditingLayout);
App.Overlay.Monitors[App.Overlay.CurrentDesktop].SetLayoutSettings(EditingLayout);
App.FancyZonesEditorIO.SerializeLayoutTemplates(); App.FancyZonesEditorIO.SerializeLayoutTemplates();
App.FancyZonesEditorIO.SerializeCustomLayouts(); App.FancyZonesEditorIO.SerializeCustomLayouts();
App.FancyZonesEditorIO.SerializeAppliedLayouts(); App.FancyZonesEditorIO.SerializeAppliedLayouts();
App.FancyZonesEditorIO.SerializeDefaultLayouts();
App.FancyZonesEditorIO.SerializeLayoutHotkeys();
Close(); Close();
} }
@ -46,7 +52,7 @@ namespace FancyZonesEditor
protected void OnCancel(object sender, RoutedEventArgs e) protected void OnCancel(object sender, RoutedEventArgs e)
{ {
// restore backup, clean up // restore backup, clean up
App.Overlay.EndEditing(true); App.Overlay.EndEditing(EditingLayout);
// select and draw applied layout // select and draw applied layout
var settings = ((App)Application.Current).MainWindowSettings; var settings = ((App)Application.Current).MainWindowSettings;

View File

@ -36,7 +36,7 @@ namespace FancyZonesEditor
private GridData _data; private GridData _data;
public GridEditor() public GridEditor(GridLayoutModel layoutModel)
{ {
InitializeComponent(); InitializeComponent();
Loaded += GridEditor_Loaded; Loaded += GridEditor_Loaded;
@ -44,6 +44,9 @@ namespace FancyZonesEditor
KeyDown += GridEditor_KeyDown; KeyDown += GridEditor_KeyDown;
KeyUp += GridEditor_KeyUp; KeyUp += GridEditor_KeyUp;
gridEditorUniqueId = ++gridEditorUniqueIdCounter; gridEditorUniqueId = ++gridEditorUniqueIdCounter;
_data = new GridData(layoutModel);
Model = layoutModel;
} }
public void FocusZone() public void FocusZone()
@ -58,16 +61,6 @@ namespace FancyZonesEditor
private void GridEditor_Loaded(object sender, RoutedEventArgs e) private void GridEditor_Loaded(object sender, RoutedEventArgs e)
{ {
((App)Application.Current).MainWindowSettings.PropertyChanged += ZoneSettings_PropertyChanged; ((App)Application.Current).MainWindowSettings.PropertyChanged += ZoneSettings_PropertyChanged;
GridLayoutModel model = (GridLayoutModel)DataContext;
if (model == null)
{
return;
}
_data = new GridData(model);
Model = model;
Model.PropertyChanged += OnGridDimensionsChanged; Model.PropertyChanged += OnGridDimensionsChanged;
SetupUI(); SetupUI();
} }

View File

@ -10,7 +10,8 @@ namespace FancyZonesEditor
{ {
public partial class GridEditorWindow : EditorWindow public partial class GridEditorWindow : EditorWindow
{ {
public GridEditorWindow() public GridEditorWindow(GridLayoutModel model)
: base(model)
{ {
InitializeComponent(); InitializeComponent();

View File

@ -3,14 +3,15 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows;
using FancyZonesEditor.Models; using FancyZonesEditor.Models;
using FancyZonesEditor.Utils;
namespace FancyZonesEditor namespace FancyZonesEditor
{ {
public class LayoutBackup public class LayoutBackup
{ {
private LayoutModel _backup; private LayoutModel _backup;
private string _hotkeyBackup;
private List<LayoutModel> _defaultLayoutsBackup; private List<LayoutModel> _defaultLayoutsBackup;
public LayoutBackup() public LayoutBackup()
@ -28,32 +29,31 @@ namespace FancyZonesEditor
_backup = new CanvasLayoutModel(canvas); _backup = new CanvasLayoutModel(canvas);
} }
_hotkeyBackup = MainWindowSettingsModel.LayoutHotkeys.Key(model.Uuid);
_defaultLayoutsBackup = new List<LayoutModel>(MainWindowSettingsModel.DefaultLayouts.Layouts); _defaultLayoutsBackup = new List<LayoutModel>(MainWindowSettingsModel.DefaultLayouts.Layouts);
} }
public void Restore() public void Restore(LayoutModel layoutToRestore)
{ {
if (_backup != null) if (_backup != null && layoutToRestore != null)
{ {
var settings = ((App)Application.Current).MainWindowSettings;
var selectedModel = settings.SelectedModel;
if (selectedModel == null)
{
return;
}
if (_backup is GridLayoutModel grid) if (_backup is GridLayoutModel grid)
{ {
grid.RestoreTo((GridLayoutModel)selectedModel); grid.RestoreTo((GridLayoutModel)layoutToRestore);
grid.InitTemplateZones(); grid.InitTemplateZones();
} }
else if (_backup is CanvasLayoutModel canvas) else if (_backup is CanvasLayoutModel canvas)
{ {
canvas.RestoreTo((CanvasLayoutModel)selectedModel); canvas.RestoreTo((CanvasLayoutModel)layoutToRestore);
canvas.InitTemplateZones();
} }
} }
if (_hotkeyBackup != null)
{
MainWindowSettingsModel.LayoutHotkeys.SelectKey(_hotkeyBackup, layoutToRestore.Uuid);
}
if (_defaultLayoutsBackup != null) if (_defaultLayoutsBackup != null)
{ {
MainWindowSettingsModel.DefaultLayouts.Restore(_defaultLayoutsBackup); MainWindowSettingsModel.DefaultLayouts.Restore(_defaultLayoutsBackup);
@ -63,6 +63,7 @@ namespace FancyZonesEditor
public void Clear() public void Clear()
{ {
_backup = null; _backup = null;
_hotkeyBackup = null;
_defaultLayoutsBackup = null; _defaultLayoutsBackup = null;
} }
} }

View File

@ -146,29 +146,17 @@ namespace FancyZonesEditor
private void DecrementZones_Click(object sender, RoutedEventArgs e) private void DecrementZones_Click(object sender, RoutedEventArgs e)
{ {
var mainEditor = App.Overlay; if (_settings.SelectedModel.TemplateZoneCount > 1)
if (mainEditor.CurrentDataContext is not LayoutModel model)
{ {
return; _settings.SelectedModel.TemplateZoneCount--;
}
if (model.TemplateZoneCount > 1)
{
model.TemplateZoneCount--;
} }
} }
private void IncrementZones_Click(object sender, RoutedEventArgs e) private void IncrementZones_Click(object sender, RoutedEventArgs e)
{ {
var mainEditor = App.Overlay; if (_settings.SelectedModel.IsZoneAddingAllowed)
if (mainEditor.CurrentDataContext is not LayoutModel model)
{ {
return; _settings.SelectedModel.TemplateZoneCount++;
}
if (model.IsZoneAddingAllowed)
{
model.TemplateZoneCount++;
} }
} }
@ -303,25 +291,23 @@ namespace FancyZonesEditor
private void Apply() private void Apply()
{ {
Logger.LogTrace(); Logger.LogTrace();
var mainEditor = App.Overlay;
if (mainEditor.CurrentDataContext is LayoutModel model) LayoutModel model = _settings.SelectedModel;
{ _settings.SetAppliedModel(model);
_settings.SetAppliedModel(model); App.Overlay.Monitors[App.Overlay.CurrentDesktop].SetLayoutSettings(model);
App.Overlay.Monitors[App.Overlay.CurrentDesktop].SetLayoutSettings(model); App.FancyZonesEditorIO.SerializeAppliedLayouts();
App.FancyZonesEditorIO.SerializeAppliedLayouts(); App.FancyZonesEditorIO.SerializeCustomLayouts();
App.FancyZonesEditorIO.SerializeCustomLayouts();
}
} }
private void OnClosing(object sender, EventArgs e) private void OnClosing(object sender, EventArgs e)
{ {
Logger.LogTrace(); Logger.LogTrace();
App.Overlay.EndEditing(true);
App.FancyZonesEditorIO.SerializeAppliedLayouts(); App.FancyZonesEditorIO.SerializeAppliedLayouts();
App.FancyZonesEditorIO.SerializeCustomLayouts(); App.FancyZonesEditorIO.SerializeCustomLayouts();
App.FancyZonesEditorIO.SerializeLayoutHotkeys(); App.FancyZonesEditorIO.SerializeLayoutHotkeys();
App.FancyZonesEditorIO.SerializeLayoutTemplates(); App.FancyZonesEditorIO.SerializeLayoutTemplates();
App.FancyZonesEditorIO.SerializeDefaultLayouts();
App.Overlay.CloseLayoutWindow(); App.Overlay.CloseLayoutWindow();
App.Current.Shutdown(); App.Current.Shutdown();
} }
@ -345,7 +331,8 @@ namespace FancyZonesEditor
var dataContext = ((FrameworkElement)sender).DataContext; var dataContext = ((FrameworkElement)sender).DataContext;
Select((LayoutModel)dataContext); Select((LayoutModel)dataContext);
App.Overlay.StartEditing((LayoutModel)dataContext);
App.Overlay.StartEditing(_settings.SelectedModel);
Keyboard.ClearFocus(); Keyboard.ClearFocus();
EditLayoutDialogTitle.Text = string.Format(CultureInfo.CurrentCulture, Properties.Resources.Edit_Template, ((LayoutModel)dataContext).Name); EditLayoutDialogTitle.Text = string.Format(CultureInfo.CurrentCulture, Properties.Resources.Edit_Template, ((LayoutModel)dataContext).Name);
@ -358,16 +345,8 @@ namespace FancyZonesEditor
var dataContext = ((FrameworkElement)sender).DataContext; var dataContext = ((FrameworkElement)sender).DataContext;
Select((LayoutModel)dataContext); Select((LayoutModel)dataContext);
EditLayoutDialog.Hide(); EditLayoutDialog.Hide();
var mainEditor = App.Overlay;
if (mainEditor.CurrentDataContext is not LayoutModel model)
{
return;
}
_settings.SetSelectedModel(model);
Hide(); Hide();
mainEditor.OpenEditor(model); App.Overlay.OpenEditor(_settings.SelectedModel);
} }
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
@ -438,7 +417,7 @@ namespace FancyZonesEditor
// EditLayout: Cancel changes // EditLayout: Cancel changes
private void EditLayoutDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) private void EditLayoutDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{ {
App.Overlay.EndEditing(false); App.Overlay.EndEditing(_settings.SelectedModel);
Select(_settings.AppliedModel); Select(_settings.AppliedModel);
} }
@ -447,13 +426,8 @@ namespace FancyZonesEditor
{ {
Logger.LogTrace(); Logger.LogTrace();
var mainEditor = App.Overlay; App.Overlay.EndEditing(null);
if (mainEditor.CurrentDataContext is not LayoutModel model) LayoutModel model = _settings.SelectedModel;
{
return;
}
mainEditor.EndEditing(false);
// update current settings // update current settings
if (model == _settings.AppliedModel) if (model == _settings.AppliedModel)
@ -465,6 +439,7 @@ namespace FancyZonesEditor
App.FancyZonesEditorIO.SerializeCustomLayouts(); App.FancyZonesEditorIO.SerializeCustomLayouts();
App.FancyZonesEditorIO.SerializeLayoutTemplates(); App.FancyZonesEditorIO.SerializeLayoutTemplates();
App.FancyZonesEditorIO.SerializeLayoutHotkeys(); App.FancyZonesEditorIO.SerializeLayoutHotkeys();
App.FancyZonesEditorIO.SerializeDefaultLayouts();
// reset selected model // reset selected model
Select(_settings.AppliedModel); Select(_settings.AppliedModel);
@ -653,7 +628,6 @@ namespace FancyZonesEditor
if (dataContext is LayoutModel model) if (dataContext is LayoutModel model)
{ {
MainWindowSettingsModel.DefaultLayouts.Set(model, MonitorConfigurationType.Vertical); MainWindowSettingsModel.DefaultLayouts.Set(model, MonitorConfigurationType.Vertical);
App.FancyZonesEditorIO.SerializeDefaultLayouts();
} }
} }
@ -663,7 +637,6 @@ namespace FancyZonesEditor
if (dataContext is LayoutModel model) if (dataContext is LayoutModel model)
{ {
MainWindowSettingsModel.DefaultLayouts.Set(model, MonitorConfigurationType.Horizontal); MainWindowSettingsModel.DefaultLayouts.Set(model, MonitorConfigurationType.Horizontal);
App.FancyZonesEditorIO.SerializeDefaultLayouts();
} }
} }
@ -673,7 +646,6 @@ namespace FancyZonesEditor
if (dataContext is LayoutModel model) if (dataContext is LayoutModel model)
{ {
MainWindowSettingsModel.DefaultLayouts.Reset(MonitorConfigurationType.Horizontal); MainWindowSettingsModel.DefaultLayouts.Reset(MonitorConfigurationType.Horizontal);
App.FancyZonesEditorIO.SerializeDefaultLayouts();
} }
} }
@ -683,7 +655,6 @@ namespace FancyZonesEditor
if (dataContext is LayoutModel model) if (dataContext is LayoutModel model)
{ {
MainWindowSettingsModel.DefaultLayouts.Reset(MonitorConfigurationType.Vertical); MainWindowSettingsModel.DefaultLayouts.Reset(MonitorConfigurationType.Vertical);
App.FancyZonesEditorIO.SerializeDefaultLayouts();
} }
} }
} }

View File

@ -184,6 +184,8 @@ namespace FancyZonesEditor.Models
public void RestoreTo(CanvasLayoutModel other) public void RestoreTo(CanvasLayoutModel other)
{ {
base.RestoreTo(other);
other.Zones.Clear(); other.Zones.Clear();
foreach (Int32Rect zone in Zones) foreach (Int32Rect zone in Zones)
{ {
@ -191,7 +193,6 @@ namespace FancyZonesEditor.Models
} }
other._topLeft = _topLeft; other._topLeft = _topLeft;
other.SensitivityRadius = SensitivityRadius;
other.CanvasRect = CanvasRect; other.CanvasRect = CanvasRect;
other.UpdateLayout(); other.UpdateLayout();
} }

View File

@ -280,6 +280,8 @@ namespace FancyZonesEditor.Models
public void RestoreTo(GridLayoutModel layout) public void RestoreTo(GridLayoutModel layout)
{ {
base.RestoreTo(layout);
int rows = Rows; int rows = Rows;
int cols = Columns; int cols = Columns;
@ -315,7 +317,6 @@ namespace FancyZonesEditor.Models
layout.ShowSpacing = ShowSpacing; layout.ShowSpacing = ShowSpacing;
layout.Spacing = Spacing; layout.Spacing = Spacing;
layout.SensitivityRadius = SensitivityRadius;
layout.FirePropertyChanged(); layout.FirePropertyChanged();
} }

View File

@ -68,6 +68,19 @@ namespace FancyZonesEditor.Models
return true; return true;
} }
public string Key(string uuid)
{
foreach (var pair in SelectedKeys)
{
if (pair.Value == uuid)
{
return pair.Key;
}
}
return Properties.Resources.Quick_Key_None;
}
public void CleanUp() public void CleanUp()
{ {
var keys = SelectedKeys.Keys.ToList(); var keys = SelectedKeys.Keys.ToList();

View File

@ -339,6 +339,12 @@ namespace FancyZonesEditor.Models
} }
} }
public void RestoreTo(LayoutModel layout)
{
layout.SensitivityRadius = SensitivityRadius;
layout.TemplateZoneCount = TemplateZoneCount;
}
// Adds new custom Layout // Adds new custom Layout
public void AddCustomLayout(LayoutModel model) public void AddCustomLayout(LayoutModel model)
{ {

View File

@ -186,26 +186,19 @@ namespace FancyZonesEditor
Logger.LogTrace(); Logger.LogTrace();
_layoutPreview = null; _layoutPreview = null;
if (CurrentDataContext is GridLayoutModel) if (model is GridLayoutModel grid)
{ {
_editorLayout = new GridEditor(); _editorLayout = new GridEditor(grid);
_editorWindow = new GridEditorWindow(grid);
} }
else if (CurrentDataContext is CanvasLayoutModel) else if (model is CanvasLayoutModel canvas)
{ {
_editorLayout = new CanvasEditor(); _editorLayout = new CanvasEditor(canvas);
_editorWindow = new CanvasEditorWindow(canvas);
} }
CurrentLayoutWindow.Content = _editorLayout; CurrentLayoutWindow.Content = _editorLayout;
if (model is GridLayoutModel)
{
_editorWindow = new GridEditorWindow();
}
else
{
_editorWindow = new CanvasEditorWindow();
}
_editorWindow.Owner = Monitors[App.Overlay.CurrentDesktop].Window; _editorWindow.Owner = Monitors[App.Overlay.CurrentDesktop].Window;
_editorWindow.DataContext = model; _editorWindow.DataContext = model;
_editorWindow.Show(); _editorWindow.Show();
@ -267,11 +260,11 @@ namespace FancyZonesEditor
_layoutBackup.Backup(model); _layoutBackup.Backup(model);
} }
public void EndEditing(bool restoreBackup) public void EndEditing(LayoutModel modelToRestore)
{ {
if (restoreBackup) if (modelToRestore != null)
{ {
_layoutBackup.Restore(); _layoutBackup.Restore(modelToRestore);
} }
_layoutBackup.Clear(); _layoutBackup.Clear();

View File

@ -1019,6 +1019,45 @@ namespace FancyZonesEditor.Utils
continue; continue;
} }
LayoutType layoutType = JsonTagToLayoutType(layout.AppliedLayout.Type);
LayoutSettings settings = new LayoutSettings
{
ZonesetUuid = layout.AppliedLayout.Uuid,
ShowSpacing = layout.AppliedLayout.ShowSpacing,
Spacing = layout.AppliedLayout.Spacing,
Type = layoutType,
ZoneCount = layout.AppliedLayout.ZoneCount,
SensitivityRadius = layout.AppliedLayout.SensitivityRadius,
};
// check if the custom layout exists
bool existingLayout = layoutType != LayoutType.Custom;
if (layoutType == LayoutType.Custom)
{
foreach (LayoutModel custom in MainWindowSettingsModel.CustomModels)
{
if (custom.Uuid == layout.AppliedLayout.Uuid)
{
existingLayout = true;
break;
}
}
}
// replace deleted layout with the Blank layout
if (!existingLayout)
{
LayoutModel blankLayout = MainWindowSettingsModel.TemplateModels[(int)LayoutType.Blank];
settings.ZonesetUuid = blankLayout.Uuid;
settings.Type = blankLayout.Type;
settings.ZoneCount = blankLayout.TemplateZoneCount;
settings.SensitivityRadius = blankLayout.SensitivityRadius;
// grid layout settings, just resetting them
settings.ShowSpacing = false;
settings.Spacing = 0;
}
bool unused = true; bool unused = true;
foreach (Monitor monitor in monitors) foreach (Monitor monitor in monitors)
{ {
@ -1028,16 +1067,6 @@ namespace FancyZonesEditor.Utils
(monitor.Device.VirtualDesktopId == layout.Device.VirtualDesktop || (monitor.Device.VirtualDesktopId == layout.Device.VirtualDesktop ||
layout.Device.VirtualDesktop == DefaultVirtualDesktopGuid)) layout.Device.VirtualDesktop == DefaultVirtualDesktopGuid))
{ {
var settings = new LayoutSettings
{
ZonesetUuid = layout.AppliedLayout.Uuid,
ShowSpacing = layout.AppliedLayout.ShowSpacing,
Spacing = layout.AppliedLayout.Spacing,
Type = JsonTagToLayoutType(layout.AppliedLayout.Type),
ZoneCount = layout.AppliedLayout.ZoneCount,
SensitivityRadius = layout.AppliedLayout.SensitivityRadius,
};
monitor.Settings = settings; monitor.Settings = settings;
unused = false; unused = false;
break; break;

View File

@ -239,7 +239,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
// Act // Act
// Using en-us culture to have a fixed number style // Using en-us culture to have a fixed number style
var result = engine.Interpret(input, new CultureInfo("en-us"), out _); var result = engine.Interpret(input, new CultureInfo("en-us", false), out _);
// Assert // Assert
Assert.IsNotNull(result); Assert.IsNotNull(result);

View File

@ -46,7 +46,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
public void Translate_ThrowError_WhenCalledNull(string input) public void Translate_ThrowError_WhenCalledNull(string input)
{ {
// Arrange // Arrange
var translator = NumberTranslator.Create(new CultureInfo("de-DE"), new CultureInfo("en-US")); var translator = NumberTranslator.Create(new CultureInfo("de-DE", false), new CultureInfo("en-US", false));
// Act // Act
Assert.ThrowsException<ArgumentNullException>(() => translator.Translate(input)); Assert.ThrowsException<ArgumentNullException>(() => translator.Translate(input));
@ -58,7 +58,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
public void Translate_WhenCalledEmpty(string input) public void Translate_WhenCalledEmpty(string input)
{ {
// Arrange // Arrange
var translator = NumberTranslator.Create(new CultureInfo("de-DE"), new CultureInfo("en-US")); var translator = NumberTranslator.Create(new CultureInfo("de-DE", false), new CultureInfo("en-US", false));
// Act // Act
var result = translator.Translate(input); var result = translator.Translate(input);
@ -76,7 +76,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
public void Translate_NoErrors_WhenCalled(string input, string expectedResult) public void Translate_NoErrors_WhenCalled(string input, string expectedResult)
{ {
// Arrange // Arrange
var translator = NumberTranslator.Create(new CultureInfo("de-DE"), new CultureInfo("en-US")); var translator = NumberTranslator.Create(new CultureInfo("de-DE", false), new CultureInfo("en-US", false));
// Act // Act
var result = translator.Translate(input); var result = translator.Translate(input);
@ -95,7 +95,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
public void TranslateBack_NoErrors_WhenCalled(string input, string expectedResult) public void TranslateBack_NoErrors_WhenCalled(string input, string expectedResult)
{ {
// Arrange // Arrange
var translator = NumberTranslator.Create(new CultureInfo("de-DE"), new CultureInfo("en-US")); var translator = NumberTranslator.Create(new CultureInfo("de-DE", false), new CultureInfo("en-US", false));
// Act // Act
var result = translator.TranslateBack(input); var result = translator.TranslateBack(input);
@ -113,7 +113,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
public void Translate_RemoveNumberGroupSeparator_WhenCalled(string decimalSeparator, string groupSeparator, string input, string expectedResult) public void Translate_RemoveNumberGroupSeparator_WhenCalled(string decimalSeparator, string groupSeparator, string input, string expectedResult)
{ {
// Arrange // Arrange
var sourceCulture = new CultureInfo("en-US") var sourceCulture = new CultureInfo("en-US", false)
{ {
NumberFormat = NumberFormat =
{ {
@ -121,7 +121,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
NumberGroupSeparator = groupSeparator, NumberGroupSeparator = groupSeparator,
}, },
}; };
var translator = NumberTranslator.Create(sourceCulture, new CultureInfo("en-US")); var translator = NumberTranslator.Create(sourceCulture, new CultureInfo("en-US", false));
// Act // Act
var result = translator.Translate(input); var result = translator.Translate(input);
@ -137,7 +137,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
public void Translate_NoRemovalOfLeadingZeroesOnEdgeCases(string input, string expectedResult) public void Translate_NoRemovalOfLeadingZeroesOnEdgeCases(string input, string expectedResult)
{ {
// Arrange // Arrange
var translator = NumberTranslator.Create(new CultureInfo("de-de"), new CultureInfo("en-US")); var translator = NumberTranslator.Create(new CultureInfo("de-de", false), new CultureInfo("en-US", false));
// Act // Act
var result = translator.Translate(input); var result = translator.Translate(input);

View File

@ -143,15 +143,13 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Components
/// <returns>List containing all network adapters</returns> /// <returns>List containing all network adapters</returns>
internal static List<NetworkConnectionProperties> GetList() internal static List<NetworkConnectionProperties> GetList()
{ {
List<NetworkConnectionProperties> list = new List<NetworkConnectionProperties>(); var interfaces = NetworkInterface.GetAllNetworkInterfaces()
.Where(x => x.NetworkInterfaceType != NetworkInterfaceType.Loopback && x.GetPhysicalAddress() != null)
var interfaces = NetworkInterface.GetAllNetworkInterfaces().Where(x => x.NetworkInterfaceType != NetworkInterfaceType.Loopback && x.GetPhysicalAddress() != null); .Select(i => new NetworkConnectionProperties(i))
foreach (NetworkInterface i in interfaces) .OrderByDescending(i => i.IPv4) // list IPv4 first
{ .ThenBy(i => i.IPv6Primary) // then IPv6
list.Add(new NetworkConnectionProperties(i)); .ToList();
} return interfaces;
return list;
} }
/// <summary> /// <summary>

View File

@ -24,9 +24,9 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
// Set culture to 'en-us' // Set culture to 'en-us'
originalCulture = CultureInfo.CurrentCulture; originalCulture = CultureInfo.CurrentCulture;
CultureInfo.CurrentCulture = new CultureInfo("en-us"); CultureInfo.CurrentCulture = new CultureInfo("en-us", false);
originalUiCulture = CultureInfo.CurrentUICulture; originalUiCulture = CultureInfo.CurrentUICulture;
CultureInfo.CurrentUICulture = new CultureInfo("en-us"); CultureInfo.CurrentUICulture = new CultureInfo("en-us", false);
} }
[DataTestMethod] [DataTestMethod]

View File

@ -25,9 +25,9 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
// Set culture to 'en-us' // Set culture to 'en-us'
originalCulture = CultureInfo.CurrentCulture; originalCulture = CultureInfo.CurrentCulture;
CultureInfo.CurrentCulture = new CultureInfo("en-us"); CultureInfo.CurrentCulture = new CultureInfo("en-us", false);
originalUiCulture = CultureInfo.CurrentUICulture; originalUiCulture = CultureInfo.CurrentUICulture;
CultureInfo.CurrentUICulture = new CultureInfo("en-us"); CultureInfo.CurrentUICulture = new CultureInfo("en-us", false);
} }
[DataTestMethod] [DataTestMethod]

View File

@ -20,9 +20,9 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
{ {
// Set culture to 'en-us' // Set culture to 'en-us'
originalCulture = CultureInfo.CurrentCulture; originalCulture = CultureInfo.CurrentCulture;
CultureInfo.CurrentCulture = new CultureInfo("en-us"); CultureInfo.CurrentCulture = new CultureInfo("en-us", false);
originalUiCulture = CultureInfo.CurrentUICulture; originalUiCulture = CultureInfo.CurrentUICulture;
CultureInfo.CurrentUICulture = new CultureInfo("en-us"); CultureInfo.CurrentUICulture = new CultureInfo("en-us", false);
} }
[DataTestMethod] [DataTestMethod]

View File

@ -21,14 +21,22 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
{ {
// Set culture to 'en-us' // Set culture to 'en-us'
originalCulture = CultureInfo.CurrentCulture; originalCulture = CultureInfo.CurrentCulture;
CultureInfo.CurrentCulture = new CultureInfo("en-us"); CultureInfo.CurrentCulture = new CultureInfo("en-us", false);
originalUiCulture = CultureInfo.CurrentUICulture; originalUiCulture = CultureInfo.CurrentUICulture;
CultureInfo.CurrentUICulture = new CultureInfo("en-us"); CultureInfo.CurrentUICulture = new CultureInfo("en-us", false);
} }
private DateTime GetDateTimeForTest() private DateTime GetDateTimeForTest(bool embedUtc = false)
{ {
return new DateTime(2022, 03, 02, 22, 30, 45); var dateTime = new DateTime(2022, 03, 02, 22, 30, 45);
if (embedUtc)
{
return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
}
else
{
return dateTime;
}
} }
[DataTestMethod] [DataTestMethod]
@ -181,8 +189,8 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
public void UtcFormatsWithShortTimeAndShortDate(string formatLabel, string expectedFormat) public void UtcFormatsWithShortTimeAndShortDate(string formatLabel, string expectedFormat)
{ {
// Setup // Setup
var helperResults = AvailableResultsList.GetList(true, false, false, GetDateTimeForTest()); var helperResults = AvailableResultsList.GetList(true, false, false, GetDateTimeForTest(true));
var expectedResult = GetDateTimeForTest().ToUniversalTime().ToString(expectedFormat, CultureInfo.CurrentCulture); var expectedResult = GetDateTimeForTest().ToString(expectedFormat, CultureInfo.CurrentCulture);
// Act // Act
var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase));
@ -201,8 +209,8 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
public void UtcFormatsWithShortTimeAndLongDate(string formatLabel, string expectedFormat) public void UtcFormatsWithShortTimeAndLongDate(string formatLabel, string expectedFormat)
{ {
// Setup // Setup
var helperResults = AvailableResultsList.GetList(true, false, true, GetDateTimeForTest()); var helperResults = AvailableResultsList.GetList(true, false, true, GetDateTimeForTest(true));
var expectedResult = GetDateTimeForTest().ToUniversalTime().ToString(expectedFormat, CultureInfo.CurrentCulture); var expectedResult = GetDateTimeForTest().ToString(expectedFormat, CultureInfo.CurrentCulture);
// Act // Act
var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase));
@ -221,8 +229,8 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
public void UtcFormatsWithLongTimeAndShortDate(string formatLabel, string expectedFormat) public void UtcFormatsWithLongTimeAndShortDate(string formatLabel, string expectedFormat)
{ {
// Setup // Setup
var helperResults = AvailableResultsList.GetList(true, true, false, GetDateTimeForTest()); var helperResults = AvailableResultsList.GetList(true, true, false, GetDateTimeForTest(true));
var expectedResult = GetDateTimeForTest().ToUniversalTime().ToString(expectedFormat, CultureInfo.CurrentCulture); var expectedResult = GetDateTimeForTest().ToString(expectedFormat, CultureInfo.CurrentCulture);
// Act // Act
var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase));
@ -241,8 +249,8 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
public void UtcFormatsWithLongTimeAndLongDate(string formatLabel, string expectedFormat) public void UtcFormatsWithLongTimeAndLongDate(string formatLabel, string expectedFormat)
{ {
// Setup // Setup
var helperResults = AvailableResultsList.GetList(true, true, true, GetDateTimeForTest()); var helperResults = AvailableResultsList.GetList(true, true, true, GetDateTimeForTest(true));
var expectedResult = GetDateTimeForTest().ToUniversalTime().ToString(expectedFormat, CultureInfo.CurrentCulture); var expectedResult = GetDateTimeForTest().ToString(expectedFormat, CultureInfo.CurrentCulture);
// Act // Act
var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase));

View File

@ -18,6 +18,7 @@ namespace Peek.FilePreviewer.Previewers.Helpers
public static async Task<BitmapSource> GetBitmapFromHBitmapAsync(IntPtr hbitmap, bool isSupportingTransparency, CancellationToken cancellationToken) public static async Task<BitmapSource> GetBitmapFromHBitmapAsync(IntPtr hbitmap, bool isSupportingTransparency, CancellationToken cancellationToken)
{ {
Bitmap? bitmap = null; Bitmap? bitmap = null;
Bitmap? tempBitmapForDeletion = null;
try try
{ {
@ -32,7 +33,8 @@ namespace Peek.FilePreviewer.Previewers.Helpers
var transparentBitmap = new Bitmap(bitmapData.Width, bitmapData.Height, bitmapData.Stride, PixelFormat.Format32bppArgb, bitmapData.Scan0); var transparentBitmap = new Bitmap(bitmapData.Width, bitmapData.Height, bitmapData.Stride, PixelFormat.Format32bppArgb, bitmapData.Scan0);
bitmap.Dispose(); // Can't dispose of original bitmap yet as that causes crashes on png files. Saving it for later disposal after saving to stream.
tempBitmapForDeletion = bitmap;
bitmap = transparentBitmap; bitmap = transparentBitmap;
} }
@ -53,6 +55,7 @@ namespace Peek.FilePreviewer.Previewers.Helpers
finally finally
{ {
bitmap?.Dispose(); bitmap?.Dispose();
tempBitmapForDeletion?.Dispose();
// delete HBitmap to avoid memory leaks // delete HBitmap to avoid memory leaks
NativeMethods.DeleteObject(hbitmap); NativeMethods.DeleteObject(hbitmap);

View File

@ -83,52 +83,37 @@ namespace PowerAccent.Core
// All // All
private static string[] GetDefaultLetterKeyALL(LetterKey letter) private static string[] GetDefaultLetterKeyALL(LetterKey letter)
{ {
return letter switch // would be even better to loop through Languages and call these functions dynamically, but I don't know how to do that!
{ return GetDefaultLetterKeyCA(letter)
LetterKey.VK_0 => new[] { "₀", "⁰" }, .Union(GetDefaultLetterKeyCUR(letter))
LetterKey.VK_1 => new[] { "₁", "¹" }, .Union(GetDefaultLetterKeyCY(letter))
LetterKey.VK_2 => new[] { "₂", "²" }, .Union(GetDefaultLetterKeyCZ(letter))
LetterKey.VK_3 => new[] { "₃", "³" }, .Union(GetDefaultLetterKeyGA(letter))
LetterKey.VK_4 => new[] { "₄", "⁴" }, .Union(GetDefaultLetterKeyGD(letter))
LetterKey.VK_5 => new[] { "₅", "⁵" }, .Union(GetDefaultLetterKeyDE(letter))
LetterKey.VK_6 => new[] { "₆", "⁶" }, .Union(GetDefaultLetterKeyEST(letter))
LetterKey.VK_7 => new[] { "₇", "⁷" }, .Union(GetDefaultLetterKeyFR(letter))
LetterKey.VK_8 => new[] { "₈", "⁸" }, .Union(GetDefaultLetterKeyHR(letter))
LetterKey.VK_9 => new[] { "₉", "⁹" }, .Union(GetDefaultLetterKeyHE(letter))
LetterKey.VK_A => new[] { "á", "à", "ä", "â", "ă", "å", "α", "ā", "ą", "ȧ", "ã", "ǎ", "æ" }, .Union(GetDefaultLetterKeyHU(letter))
LetterKey.VK_B => new[] { "ḃ", "β" }, .Union(GetDefaultLetterKeyIS(letter))
LetterKey.VK_C => new[] { "ç", "ć", "ĉ", "č", "ċ", "¢", "χ", "°C", "©", "" }, .Union(GetDefaultLetterKeyIT(letter))
LetterKey.VK_D => new[] { "ď", "ḍ", "ḋ", "đ", "δ", "ð" }, .Union(GetDefaultLetterKeyKU(letter))
LetterKey.VK_E => new[] { "é", "è", "ê", "ë", "ě", "ē", "ę", "ė", "ε", "η", "€", "∈" }, .Union(GetDefaultLetterKeyLT(letter))
LetterKey.VK_F => new[] { "ƒ", "ḟ", "°F" }, .Union(GetDefaultLetterKeyMK(letter))
LetterKey.VK_G => new[] { "ğ", "ģ", "ǧ", "ġ", "ĝ", "ǥ", "γ" }, .Union(GetDefaultLetterKeyMI(letter))
LetterKey.VK_H => new[] { "ḣ", "ĥ", "ħ" }, .Union(GetDefaultLetterKeyNL(letter))
LetterKey.VK_I => new[] { "ï", "î", "í", "ì", "ī", "į", "ı", "İ", "ι", "ǐ" }, .Union(GetDefaultLetterKeyNO(letter))
LetterKey.VK_J => new[] { "ĵ" }, .Union(GetDefaultLetterKeyPI(letter))
LetterKey.VK_K => new[] { "ķ", "ǩ", "κ" }, .Union(GetDefaultLetterKeyPL(letter))
LetterKey.VK_L => new[] { "ĺ", "ľ", "ļ", "ł", "₺", "λ" }, .Union(GetDefaultLetterKeyPT(letter))
LetterKey.VK_M => new[] { "ṁ", "μ" }, .Union(GetDefaultLetterKeyRO(letter))
LetterKey.VK_N => new[] { "ñ", "ń", "ŋ", "ň", "ņ", "ṅ", "ⁿ", "ν", "" }, .Union(GetDefaultLetterKeySK(letter))
LetterKey.VK_O => new[] { "ô", "ó", "ö", "ő", "ò", "ō", "ȯ", "ø", "õ", "œ", "ω", "ο", "ǒ" }, .Union(GetDefaultLetterKeySP(letter))
LetterKey.VK_P => new[] { "ṗ", "₽", "π", "φ", "ψ", "℗" }, .Union(GetDefaultLetterKeySR(letter))
LetterKey.VK_Q => new[] { "" }, .Union(GetDefaultLetterKeySV(letter))
LetterKey.VK_R => new[] { "ŕ", "ř", "ṙ", "₹", "ρ", "®", "" }, .Union(GetDefaultLetterKeyTK(letter))
LetterKey.VK_S => new[] { "ś", "ş", "š", "ș", "ṡ", "ŝ", "ß", "σ", "$", "\u00A7" }, .ToArray();
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[] { "¿", "¡", "∙", "₋", "⁻", "", "≤", "≥", "≠", "≈", "≙", "±", "₊", "⁺" },
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) // Currencies (source: https://www.eurochange.co.uk/travel-money/world-currency-abbreviations-symbols-and-codes-travel-money)

View File

@ -503,7 +503,6 @@
<ToggleButton <ToggleButton
x:Name="toggleButton_enumItems" x:Name="toggleButton_enumItems"
x:Uid="ToggleButton_EnumItems" x:Uid="ToggleButton_EnumItems"
IsChecked="True"
Height="32" Height="32"
Content="&#xEA40;" Content="&#xEA40;"
FontFamily="{ThemeResource SymbolThemeFontFamily}" /> FontFamily="{ThemeResource SymbolThemeFontFamily}" />

View File

@ -282,6 +282,7 @@ namespace winrt::PowerRenameUI::implementation
} }
button_rename().IsEnabled(false); button_rename().IsEnabled(false);
toggleButton_enumItems().IsChecked(true);
InitAutoComplete(); InitAutoComplete();
SearchReplaceChanged(); SearchReplaceChanged();
InvalidateItemListViewState(); InvalidateItemListViewState();

View File

@ -178,6 +178,9 @@
<data name="RegistryJumpToKeyButton.Label" xml:space="preserve"> <data name="RegistryJumpToKeyButton.Label" xml:space="preserve">
<value>Open Key</value> <value>Open Key</value>
</data> </data>
<data name="SaveDialogTitle" xml:space="preserve">
<value>Save As</value>
</data>
<data name="SaveAsButton.Label" xml:space="preserve"> <data name="SaveAsButton.Label" xml:space="preserve">
<value>Save as…</value> <value>Save as…</value>
</data> </data>

View File

@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
namespace Microsoft.PowerToys.Settings.UI.Library namespace Microsoft.PowerToys.Settings.UI.Library
@ -14,6 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
ExtendedContextMenuOnly = false; ExtendedContextMenuOnly = false;
} }
[JsonPropertyName("showInExtendedContextMenu")]
public bool ExtendedContextMenuOnly { get; set; } public bool ExtendedContextMenuOnly { get; set; }
public string ToJsonString() public string ToJsonString()

View File

@ -8,9 +8,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library
{ {
public class FindMyMouseProperties public class FindMyMouseProperties
{ {
public HotkeySettings DefaultActivationShortcut => new HotkeySettings(true, false, false, true, 0x46);
[JsonPropertyName("activation_method")] [JsonPropertyName("activation_method")]
public IntProperty ActivationMethod { get; set; } public IntProperty ActivationMethod { get; set; }
[JsonPropertyName("activation_shortcut")]
public HotkeySettings ActivationShortcut { get; set; }
[JsonPropertyName("do_not_activate_on_game_mode")] [JsonPropertyName("do_not_activate_on_game_mode")]
public BoolProperty DoNotActivateOnGameMode { get; set; } public BoolProperty DoNotActivateOnGameMode { get; set; }
@ -41,6 +46,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
public FindMyMouseProperties() public FindMyMouseProperties()
{ {
ActivationMethod = new IntProperty(0); ActivationMethod = new IntProperty(0);
ActivationShortcut = DefaultActivationShortcut;
DoNotActivateOnGameMode = new BoolProperty(true); DoNotActivateOnGameMode = new BoolProperty(true);
BackgroundColor = new StringProperty("#000000"); BackgroundColor = new StringProperty("#000000");
SpotlightColor = new StringProperty("#FFFFFF"); SpotlightColor = new StringProperty("#FFFFFF");

View File

@ -18,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
{ {
Name = ModuleName; Name = ModuleName;
Properties = new FindMyMouseProperties(); Properties = new FindMyMouseProperties();
Version = "1.0"; Version = "1.1";
} }
public string GetModuleName() public string GetModuleName()
@ -29,6 +29,17 @@ namespace Microsoft.PowerToys.Settings.UI.Library
// This can be utilized in the future if the settings.json file is to be modified/deleted. // This can be utilized in the future if the settings.json file is to be modified/deleted.
public bool UpgradeSettingsConfiguration() public bool UpgradeSettingsConfiguration()
{ {
if (Version == "1.0")
{
if (Properties.ActivationMethod.Value == 1)
{
Properties.ActivationMethod = new IntProperty(2);
}
Version = "1.1";
return true;
}
return false; return false;
} }
} }

View File

@ -3,26 +3,20 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System; using System;
using System.Globalization;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data; using Microsoft.UI.Xaml.Data;
namespace Microsoft.PowerToys.Settings.UI.Converters namespace Microsoft.PowerToys.Settings.UI.Converters
{ {
public sealed class FindMyMouseActivationShakeMouseIntToVisibilityConverter : IValueConverter public sealed class FindMyMouseActivationIntToVisibilityConverter : IValueConverter
{ {
public object Convert(object value, Type targetType, object parameter, string language) public object Convert(object value, Type targetType, object parameter, string language)
{ {
var activationShake = (int)value; var selectedActivation = (int)value;
var expectedActivation = int.Parse(parameter as string, CultureInfo.InvariantCulture);
// Assumes 1 is the index for the shake mouse option in the activation method combo box return selectedActivation == expectedActivation ? Visibility.Visible : Visibility.Collapsed;
if (activationShake == 1)
{
return Visibility.Visible;
}
else
{
return Visibility.Collapsed;
}
} }
public object ConvertBack(object value, Type targetType, object parameter, string language) public object ConvertBack(object value, Type targetType, object parameter, string language)

View File

@ -182,6 +182,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public void RefreshEnabledState() public void RefreshEnabledState()
{ {
UpdateEnabledState(_generalSettingsRepository.SettingsConfig.Enabled.Awake);
ViewModel.RefreshEnabledState(); ViewModel.RefreshEnabledState();
} }
} }

View File

@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls" xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:labs="using:CommunityToolkit.Labs.WinUI" xmlns:labs="using:CommunityToolkit.Labs.WinUI"
xmlns:localConverters="using:Microsoft.PowerToys.Settings.UI.Converters" xmlns:localConverters="using:Microsoft.PowerToys.Settings.UI.Converters"
@ -11,7 +12,9 @@
AutomationProperties.LandmarkType="Main" AutomationProperties.LandmarkType="Main"
mc:Ignorable="d"> mc:Ignorable="d">
<Page.Resources> <Page.Resources>
<localConverters:FindMyMouseActivationShakeMouseIntToVisibilityConverter x:Key="FindMyMouseActivationShakeMouseIntToVisibilityConverter" /> <localConverters:FindMyMouseActivationIntToVisibilityConverter x:Key="FindMyMouseActivationIntToVisibilityConverter" />
<converters:NegativeBoolToVisibilityConverter
x:Key="BoolToInvertedVisibilityConverter" />
</Page.Resources> </Page.Resources>
<controls:SettingsPageControl <controls:SettingsPageControl
x:Uid="MouseUtils" x:Uid="MouseUtils"
@ -42,12 +45,14 @@
MinWidth="{StaticResource SettingActionControlMinWidth}" MinWidth="{StaticResource SettingActionControlMinWidth}"
SelectedIndex="{x:Bind Path=ViewModel.FindMyMouseActivationMethod, Mode=TwoWay}"> SelectedIndex="{x:Bind Path=ViewModel.FindMyMouseActivationMethod, Mode=TwoWay}">
<ComboBoxItem x:Uid="MouseUtils_FindMyMouse_ActivationDoubleControlPress" /> <ComboBoxItem x:Uid="MouseUtils_FindMyMouse_ActivationDoubleControlPress" />
<ComboBoxItem x:Uid="MouseUtils_FindMyMouse_ActivationDoubleRightControlPress" />
<ComboBoxItem x:Uid="MouseUtils_FindMyMouse_ActivationShakeMouse" /> <ComboBoxItem x:Uid="MouseUtils_FindMyMouse_ActivationShakeMouse" />
<ComboBoxItem x:Uid="MouseUtils_FindMyMouse_ActivationCustomizedShortcut" />
</ComboBox> </ComboBox>
<labs:SettingsExpander.Items> <labs:SettingsExpander.Items>
<labs:SettingsCard <labs:SettingsCard
x:Uid="MouseUtils_FindMyMouse_ShakingMinimumDistance" x:Uid="MouseUtils_FindMyMouse_ShakingMinimumDistance"
Visibility="{x:Bind Mode=OneWay, Path=ViewModel.FindMyMouseActivationMethod, Converter={StaticResource FindMyMouseActivationShakeMouseIntToVisibilityConverter}}"> Visibility="{x:Bind Mode=OneWay, Path=ViewModel.FindMyMouseActivationMethod, Converter={StaticResource FindMyMouseActivationIntToVisibilityConverter}, ConverterParameter=2}">
<NumberBox <NumberBox
MinWidth="{StaticResource SettingActionControlMinWidth}" MinWidth="{StaticResource SettingActionControlMinWidth}"
LargeChange="1000" LargeChange="1000"
@ -57,6 +62,14 @@
SpinButtonPlacementMode="Compact" SpinButtonPlacementMode="Compact"
Value="{x:Bind Mode=TwoWay, Path=ViewModel.FindMyMouseShakingMinimumDistance}" /> Value="{x:Bind Mode=TwoWay, Path=ViewModel.FindMyMouseShakingMinimumDistance}" />
</labs:SettingsCard> </labs:SettingsCard>
<labs:SettingsCard
x:Uid="MouseUtils_FindMyMouse_ActivationShortcut"
HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=&#xEDA7;}"
Visibility="{x:Bind Mode=OneWay, Path=ViewModel.FindMyMouseActivationMethod, Converter={StaticResource FindMyMouseActivationIntToVisibilityConverter}, ConverterParameter=3}">
<controls:ShortcutControl
MinWidth="{StaticResource SettingActionControlMinWidth}"
HotkeySettings="{x:Bind Path=ViewModel.FindMyMouseActivationShortcut, Mode=TwoWay}" />
</labs:SettingsCard>
<labs:SettingsCard ContentAlignment="Left"> <labs:SettingsCard ContentAlignment="Left">
<CheckBox <CheckBox
x:Uid="MouseUtils_Prevent_Activation_On_Game_Mode" x:Uid="MouseUtils_Prevent_Activation_On_Game_Mode"
@ -64,7 +77,6 @@
</labs:SettingsCard> </labs:SettingsCard>
</labs:SettingsExpander.Items> </labs:SettingsExpander.Items>
</labs:SettingsExpander> </labs:SettingsExpander>
<labs:SettingsExpander <labs:SettingsExpander
x:Uid="Appearance_Behavior" x:Uid="Appearance_Behavior"
HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=&#xEB3C;}" HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=&#xEB3C;}"
@ -107,11 +119,17 @@
Minimum="0" Minimum="0"
SmallChange="10" SmallChange="10"
SpinButtonPlacementMode="Compact" SpinButtonPlacementMode="Compact"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsAnimationEnabledBySystem}"
Value="{x:Bind Mode=TwoWay, Path=ViewModel.FindMyMouseAnimationDurationMs}" /> Value="{x:Bind Mode=TwoWay, Path=ViewModel.FindMyMouseAnimationDurationMs}" />
</labs:SettingsCard> </labs:SettingsCard>
</labs:SettingsExpander.Items> </labs:SettingsExpander.Items>
</labs:SettingsExpander> </labs:SettingsExpander>
<InfoBar
x:Uid="MouseUtils_FindMyMouse_AnimationDurationMs_Disabled"
IsClosable="False"
IsOpen="True"
Severity="Informational"
Visibility="{x:Bind Mode=OneWay, Path=ViewModel.IsAnimationEnabledBySystem, Converter={StaticResource BoolToInvertedVisibilityConverter}}" />
<labs:SettingsExpander <labs:SettingsExpander
x:Uid="MouseUtils_FindMyMouse_ExcludedApps" x:Uid="MouseUtils_FindMyMouse_ExcludedApps"
HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=&#xECE4;}" HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=&#xECE4;}"

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
@ -1148,7 +1148,7 @@
<value>Use a shortcut or press the Windows key for some time to activate</value> <value>Use a shortcut or press the Windows key for some time to activate</value>
</data> </data>
<data name="Radio_ShortcutGuide_ActivationMethod_CustomizedShortcut.Content" xml:space="preserve"> <data name="Radio_ShortcutGuide_ActivationMethod_CustomizedShortcut.Content" xml:space="preserve">
<value>Customized shortcut</value> <value>Custom shortcut</value>
</data> </data>
<data name="Radio_ShortcutGuide_ActivationMethod_LongPressWindowsKey.Content" xml:space="preserve"> <data name="Radio_ShortcutGuide_ActivationMethod_LongPressWindowsKey.Content" xml:space="preserve">
<value>Hold down Windows key</value> <value>Hold down Windows key</value>
@ -2384,7 +2384,7 @@ From there, simply click on one of the supported files in the File Explorer and
<comment>Mouse as in the hardware peripheral</comment> <comment>Mouse as in the hardware peripheral</comment>
</data> </data>
<data name="Oobe_MouseUtils_FindMyMouse_Description.Text" xml:space="preserve"> <data name="Oobe_MouseUtils_FindMyMouse_Description.Text" xml:space="preserve">
<value>Shake the mouse or press the left Ctrl key twice to focus the mouse pointer.</value> <value>Focus the mouse pointer pressing the Ctrl key twice, using a custom shortcut or shaking the mouse.</value>
<comment>Mouse as in the hardware peripheral. Key as in a keyboard key</comment> <comment>Mouse as in the hardware peripheral. Key as in a keyboard key</comment>
</data> </data>
<data name="Oobe_MouseUtils_MouseHighlighter.Text" xml:space="preserve"> <data name="Oobe_MouseUtils_MouseHighlighter.Text" xml:space="preserve">
@ -2512,7 +2512,7 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
<comment>Refers to the utility name</comment> <comment>Refers to the utility name</comment>
</data> </data>
<data name="MouseUtils_FindMyMouse.Description" xml:space="preserve"> <data name="MouseUtils_FindMyMouse.Description" xml:space="preserve">
<value>Find My Mouse highlights the position of the cursor when shaking the mouse or pressing the left Ctrl key twice.</value> <value>Find My Mouse highlights the position of the cursor when pressing the Ctrl key twice, using a custom shortcut or when shaking the mouse.</value>
<comment>"Ctrl" is a keyboard key. "Find My Mouse" is the name of the utility</comment> <comment>"Ctrl" is a keyboard key. "Find My Mouse" is the name of the utility</comment>
</data> </data>
<data name="MouseUtils_Enable_FindMyMouse.Header" xml:space="preserve"> <data name="MouseUtils_Enable_FindMyMouse.Header" xml:space="preserve">
@ -2570,6 +2570,9 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
<value>Time before the spotlight appears (ms)</value> <value>Time before the spotlight appears (ms)</value>
<comment>ms = milliseconds</comment> <comment>ms = milliseconds</comment>
</data> </data>
<data name="MouseUtils_FindMyMouse_AnimationDurationMs_Disabled.Message" xml:space="preserve">
<value>Animations are disabled by OS. See Settings &gt; Accessibility &gt; Visual effects</value>
</data>
<data name="MouseUtils_FindMyMouse_ShakingMinimumDistance.Header" xml:space="preserve"> <data name="MouseUtils_FindMyMouse_ShakingMinimumDistance.Header" xml:space="preserve">
<value>Shake minimum distance</value> <value>Shake minimum distance</value>
</data> </data>
@ -3658,4 +3661,17 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="AlwaysOnTop_FrameOpacity.Header" xml:space="preserve"> <data name="AlwaysOnTop_FrameOpacity.Header" xml:space="preserve">
<value>Opacity (%)</value> <value>Opacity (%)</value>
</data> </data>
<data name="MouseUtils_FindMyMouse_ActivationCustomizedShortcut.Content" xml:space="preserve">
<value>Custom shortcut</value>
</data>
<data name="MouseUtils_FindMyMouse_ActivationDoubleRightControlPress.Content" xml:space="preserve">
<value>Press Right Control twice</value>
<comment>Right control is the physical key on the keyboard.</comment>
</data>
<data name="MouseUtils_FindMyMouse_ActivationShortcut.Description" xml:space="preserve">
<value>Customize the shortcut to turn on or off this mode</value>
</data>
<data name="MouseUtils_FindMyMouse_ActivationShortcut.Header" xml:space="preserve">
<value>Activation shortcut</value>
</data>
</root> </root>

View File

@ -22,5 +22,11 @@ namespace Microsoft.PowerToys.Settings.Utilities
[System.Runtime.InteropServices.DllImport("User32.dll")] [System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern bool IsIconic(IntPtr handle); public static extern bool IsIconic(IntPtr handle);
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
internal static extern bool SystemParametersInfo(int uiAction, int uiParam, ref int pvParam, int fWinIni);
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Interop object")]
public const int SPI_GETCLIENTAREAANIMATION = 0x1042;
} }
} }

View File

@ -9,6 +9,7 @@ using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.Utilities;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
@ -42,7 +43,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
ArgumentNullException.ThrowIfNull(findMyMouseSettingsRepository); ArgumentNullException.ThrowIfNull(findMyMouseSettingsRepository);
FindMyMouseSettingsConfig = findMyMouseSettingsRepository.SettingsConfig; FindMyMouseSettingsConfig = findMyMouseSettingsRepository.SettingsConfig;
_findMyMouseActivationMethod = FindMyMouseSettingsConfig.Properties.ActivationMethod.Value < 2 ? FindMyMouseSettingsConfig.Properties.ActivationMethod.Value : 0; _findMyMouseActivationMethod = FindMyMouseSettingsConfig.Properties.ActivationMethod.Value < 4 ? FindMyMouseSettingsConfig.Properties.ActivationMethod.Value : 0;
_findMyMouseDoNotActivateOnGameMode = FindMyMouseSettingsConfig.Properties.DoNotActivateOnGameMode.Value; _findMyMouseDoNotActivateOnGameMode = FindMyMouseSettingsConfig.Properties.DoNotActivateOnGameMode.Value;
string backgroundColor = FindMyMouseSettingsConfig.Properties.BackgroundColor.Value; string backgroundColor = FindMyMouseSettingsConfig.Properties.BackgroundColor.Value;
@ -99,6 +100,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_mousePointerCrosshairsFixedLength = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsFixedLength.Value; _mousePointerCrosshairsFixedLength = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsFixedLength.Value;
_mousePointerCrosshairsAutoActivate = MousePointerCrosshairsSettingsConfig.Properties.AutoActivate.Value; _mousePointerCrosshairsAutoActivate = MousePointerCrosshairsSettingsConfig.Properties.AutoActivate.Value;
int isEnabled = 0;
NativeMethods.SystemParametersInfo(NativeMethods.SPI_GETCLIENTAREAANIMATION, 0, ref isEnabled, 0);
_isAnimationEnabledBySystem = isEnabled != 0;
// set the callback functions value to handle outgoing IPC message. // set the callback functions value to handle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc; SendConfigMSG = ipcMSGCallBackFunc;
} }
@ -203,6 +208,23 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
} }
} }
public HotkeySettings FindMyMouseActivationShortcut
{
get
{
return FindMyMouseSettingsConfig.Properties.ActivationShortcut;
}
set
{
if (FindMyMouseSettingsConfig.Properties.ActivationShortcut != value)
{
FindMyMouseSettingsConfig.Properties.ActivationShortcut = value ?? FindMyMouseSettingsConfig.Properties.DefaultActivationShortcut;
NotifyFindMyMousePropertyChanged();
}
}
}
public bool FindMyMouseDoNotActivateOnGameMode public bool FindMyMouseDoNotActivateOnGameMode
{ {
get get
@ -295,6 +317,19 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
} }
} }
public bool IsAnimationEnabledBySystem
{
get
{
return _isAnimationEnabledBySystem;
}
set
{
_isAnimationEnabledBySystem = value;
}
}
public int FindMyMouseAnimationDurationMs public int FindMyMouseAnimationDurationMs
{ {
get get
@ -938,5 +973,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private bool _mousePointerCrosshairsIsFixedLengthEnabled; private bool _mousePointerCrosshairsIsFixedLengthEnabled;
private int _mousePointerCrosshairsFixedLength; private int _mousePointerCrosshairsFixedLength;
private bool _mousePointerCrosshairsAutoActivate; private bool _mousePointerCrosshairsAutoActivate;
private bool _isAnimationEnabledBySystem;
} }
} }