Compare commits

...

30 Commits

Author SHA1 Message Date
Stefan Markovic
76b4e8dc1c TEST 1 2023-11-11 14:08:04 +01:00
Jay
bb10ef5ef5 [General][UX]Flyouts are not constrained to the UI root anymore (#29734)
* add property

* add property

* Update DashboardPage.xaml

* small additions

* Fix XAML style
2023-11-09 17:08:42 +00:00
Niels Laute
230639fbd6 [A11y]Fix unreadable color brushes (#29731)
* Updating SubtleButton brushes

* Remove system brush resource

* Updating custom infobar colors

* Updating other SubtleButtonStyle references
2023-11-09 16:12:25 +00:00
Niels Laute
6084a51e23 [Settings][UX]Fix backup info clipping (#29729) 2023-11-09 15:07:09 +00:00
Pedro Lamas
097c9706b3 [Build]Add Microsoft.Build.CopyOnWrite package for Dev Drive speedup (#29726) 2023-11-09 14:57:52 +00:00
Laszlo Nemeth
9620d265ae [Settings][Dashboard]Switch to settings page on module clicked (#29554)
* Settings Dashboard: Adding feature switch to settings page if module panel clicked.

* fixing xaml styling

* Refactoring, creating common methods GetModuleAccentColor and GetModulePageType

* Correct button style to be invisible. Add the same functionality to the disabled modules.

* fixing XAML styling
2023-11-09 14:43:28 +00:00
gokcekantarci
912d7ec060 [PTRun][Program]Fix crashes getting images for .lnk files (#29237)
* [PTRun] Refactor GetHBitmap to handle external DLL failures in a separate task.

* Revert "[PTRun] Refactor GetHBitmap to handle external DLL failures in a separate task."

This reverts commit 159c5744b8.

* [PTRun] GetBitmapSource function has been added for file extensions that cause crashes.

* [PTRun] Spell Check update.

* [PTRun] Renamed function and variable name.

* [PTRun] ShellLinkHelper moved to Wox.Infrastructure for common use.
2023-11-09 14:18:00 +00:00
Davide Giacometti
534b9673cd [Tests]Increase WebView2 loading timeout (#29760) 2023-11-09 12:22:35 +00:00
Jaime Bernardo
889de94fa2 [Tests]Fix flaky interop tests (#29749) 2023-11-08 17:26:50 +00:00
PesBandi
019a6b85e8 [QuickAccent]Add support for Danish (#29688)
* Add support for Danish

* Update Languages.cs
2023-11-08 11:28:18 +00:00
PesBandi
8f6ad98e5d [QuickAccent]Add fraction characters (#29676) 2023-11-08 11:21:32 +00:00
gokcekantarci
0d5ec087ce [CropAndLock]Restore window maximized state (#29540)
* [Crop and Lock] Saving and restoring original state of hwnd.

* [Crop and Lock] Unnecessary parts are removed.

* [Crop and Lock] Line spaces added.

* [Crop and Lock] Unnecessary parts are removed.

* [Crop and Lock] Restoring placement before window position and dimensions.

* [Crop and Lock] Restoring steps order adjusted.

* [Crop and Lock] Remove parent moved above SetWindowPlacement.

* [Crop and Lock] Error checks are improved. Sleep at end of DisconnectTarget removed.
2023-11-07 17:00:36 +00:00
Laszlo Nemeth
2c83d36954 [Settings]Refactor module data for Dashboard and Flyout (#29555)
* Intoducing ModuleType enum, restructuring Dashboard AllApps page

* Restructuring LauncherViewModel + fix spell checker

* Restructuring Dashboard page

* Fixing MousePointerCrossHair icon path, refactoring UpdatingGeneralSettingsCallback method

* Updating Flyout Launch page.

* Fix logging
2023-11-07 16:38:06 +00:00
Dylan Briedis
97a8aeb118 [KeyboardManager]Modernize the editor UI (#28473)
* Fix dark title bar for shortcuts window

* Adjust editor sizes

* Fetch accent button style from resources instead

* Modernize the editor UI
Reimplemented the XAML bridge to support Mica

* Use fluent icons

* Modernize the preview key visuals

* Implement teaching tips for key drop-down messages

* Fix spelling

* Fix delete button alignment in keys editor

* Remove trace log from bridge message handler

* Add WinUI depends to installer script

* Hide icon and caption from editor title bar

* Update remap entries to look like cards

* Use built-in content dialog buttons

* Update add button

* Fix spelling

* Fix installer script for ARM64

* Fix spelling AGAIN

* Update dev documentation

* Prevent white flash on dark mode

* Revert 3-key layout but make window wider

* f: align webview versions

* f: add pipeline exceptions for Microsoft DLLs that are not versioned

* f: add vcruntime140_1_app.dll to the exception list

* f: update webview versions
2023-11-07 14:26:19 +00:00
Davide Giacometti
35b0f71317 [Peek]Fix idle CPU usage before window initialization (#29665) 2023-11-06 11:13:31 +00:00
Daniel Huang
faaffe3909 [QuickAccent]Add Latin Letter vy (#29640) 2023-11-03 17:06:46 +00:00
gokcekantarci
a00c3a6ec3 [PTRun]Fix COMexception error loading base images (#29663)
* [PTRun] Add PNG file integrity check before loading images

* [PTRun] Removed unused usings

* [PTRun] Log line is deleted.
2023-11-03 16:53:14 +00:00
PesBandi
4876a88eba [Quick Accent]Add missing currency symbols to Croatian, Gaeilge, Gàidhlig and Welsh (#29597)
* Add € to Croatian Quick Accent

* Add € to Gaeilge and £ to Gàidhlig and Welsh
2023-11-03 16:12:26 +00:00
Davide Giacometti
16e26a200e [Hosts]Handle read-only hosts file (#29562)
* handle read-only hosts file
2023-11-03 16:10:26 +00:00
Davide Giacometti
d5b9c31847 [Run][VSCode]Fix plugin initialization failing with trailing backslash in path (#29547) 2023-11-03 14:46:14 +00:00
Davide Giacometti
4875564a59 [Peek]Use space to play/resume video (#29487) 2023-11-03 11:11:57 +00:00
David Lascelles
47aa28977c [QuickAccent]Add support for Finnish (#29483)
* Add support for Finnish

* Also add FI to GetDefaultLetterKeyALL

* Fix missing space
2023-11-03 10:13:25 +00:00
Davide Giacometti
4060df8c64 [Chore]Update WebView2 dependency to 1.0.2088.41 (#29416) 2023-11-03 09:53:00 +00:00
Josh Soref
0a4d30ae22 [ci]check-spelling 0.0.22 (#29119)
* spelling: microsoft

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* spelling: the

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

* [ci]Upgrade check-spelling to v0.0.22

---------

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-11-02 17:16:29 +00:00
Stefan Markovic
d105d67b34 [GPO]Add Environment Variables to admx/amdl files (#29624)
* [GPO] Add Environment Variables to admx/amdl files

* Up the revisions to avoid gpo issues with the resource file

---------

Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2023-11-02 16:14:51 +00:00
Siddheya Kulkarni
4743632dfa Fixed the typos in Readme.md (#29551) 2023-10-31 12:34:41 -07:00
Jaime Bernardo
4ef39f2a6a [Docs]Update README hashes for 0.75.1 (#29542) 2023-10-31 10:47:39 -07:00
Jaime Bernardo
53133f0904 [HotFix]Revert "[FancyZones]Filtering popup windows for all operations (#28975)" (#29532)
This reverts commit 1b333dfee0.
2023-10-31 11:08:18 +00:00
Michael Nadeau
cded4efff7 [PTRun][Dev]Fix additional option default values not taking settings values (#29480) 2023-10-31 09:24:54 +00:00
Jaime Bernardo
3fe56176f3 0.75 changelogs (#29402)
Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>
Co-authored-by: Aaron Junker <aaron.junker@outlook.com>
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
2023-10-30 08:06:14 -07:00
96 changed files with 2364 additions and 1596 deletions

View File

@@ -14,7 +14,9 @@ https://www.regexplanet.com/advanced/perl/) yours before committing to verify it
* well-formed pattern.
If you can write a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it,
If you can write a [pattern](
https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns
) that would match it,
try adding it to the `patterns.txt` file.
Patterns are Perl 5 Regular Expressions - you can [test](

View File

@@ -9,4 +9,5 @@ sdl
ssh
ubuntu
unuing
workarounds
wil

View File

@@ -0,0 +1,11 @@
etw
filetime
flyouts
lnks
reparented
screenshots
SIDs
subkeys
TApp
websites
wmi

View File

@@ -1,23 +1,36 @@
# marker to ignore all code on line
^.*/\* #no-spell-check-line \*/.*$
# marker for ignoring a comment to the end of the line
// #no-spell-check.*$
# marker to ignore all code on line
^.*\bno-spell-check(?:-line|)(?:\s.*|)$
# https://cspell.org/configuration/document-settings/
# cspell inline
^.*\b[Cc][Ss][Pp][Ee][Ll]{2}:\s*[Dd][Ii][Ss][Aa][Bb][Ll][Ee]-[Ll][Ii][Nn][Ee]\b
# patch hunk comments
^\@\@ -\d+(?:,\d+|) \+\d+(?:,\d+|) \@\@ .*
# git index header
index [0-9a-z]{7,40}\.\.[0-9a-z]{7,40}
index (?:[0-9a-z]{7,40},|)[0-9a-z]{7,40}\.\.[0-9a-z]{7,40}
# file permissions
['"`\s][-bcdLlpsw](?:[-r][-w][-Ssx]){2}[-r][-w][-SsTtx]\+?['"`\s]
# css url wrappings
\burl\([^)]+\)
# cid urls
(['"])cid:.*?\g{-1}
# data url in parens
\(data:[^)]*?(?:[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})[^)]*\)
\(data:(?:[^) ][^)]*?|)(?:[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})[^)]*\)
# data url in quotes
([`'"])data:.*?(?:[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,}).*\g{-1}
([`'"])data:(?:[^ `'"].*?|)(?:[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,}).*\g{-1}
# data url
data:[-a-zA-Z=;:/0-9+]*,\S*
# https/http/file urls
#(?:\b(?:https?|ftp|file)://)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]
# mailto urls
mailto:[-a-zA-Z=;:/?%&0-9+@.]{3,}
@@ -35,6 +48,9 @@ magnet:[?=:\w]+
# asciinema
\basciinema\.org/a/[0-9a-zA-Z]+
# asciinema v2
^\[\d+\.\d+, "[io]", ".*"\]$
# apple
\bdeveloper\.apple\.com/[-\w?=/]+
# Apple music
@@ -89,7 +105,7 @@ vpc-\w+
# Google Drive
\bdrive\.google\.com/(?:file/d/|open)[-0-9a-zA-Z_?=]*
# Google Groups
\bgroups\.google\.com/(?:(?:forum/#!|d/)(?:msg|topics?|searchin)|a)/[^/\s"]+/[-a-zA-Z0-9$]+(?:/[-a-zA-Z0-9]+)*
\bgroups\.google\.com(?:/[a-z]+/(?:#!|)[^/\s"]+)*
# Google Maps
\bmaps\.google\.com/maps\?[\w&;=]*
# Google themes
@@ -117,6 +133,8 @@ themes\.googleusercontent\.com/static/fonts/[^/\s"]+/v\d+/[^.]+.
(?:\[`?[0-9a-f]+`?\]\(https:/|)/(?:www\.|)github\.com(?:/[^/\s"]+){2,}(?:/[^/\s")]+)(?:[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|)
# GitHub SHAs
\bgithub\.com(?:/[^/\s"]+){2}[@#][0-9a-f]+\b
# GitHub SHA refs
\[([0-9a-f]+)\]\(https://(?:www\.|)github.com/[-\w]+/[-\w]+/commit/\g{-1}[0-9a-f]*
# GitHub wiki
\bgithub\.com/(?:[^/]+/){2}wiki/(?:(?:[^/]+/|)_history|[^/]+(?:/_compare|)/[0-9a-f.]{40,})\b
# githubusercontent
@@ -128,9 +146,9 @@ themes\.googleusercontent\.com/static/fonts/[^/\s"]+/v\d+/[^.]+.
# git.io
\bgit\.io/[0-9a-zA-Z]+
# GitHub JSON
"node_id": "[-a-zA-Z=;:/0-9+]*"
"node_id": "[-a-zA-Z=;:/0-9+_]*"
# Contributor
\[[^\]]+\]\(https://github\.com/[^/\s"]+\)
\[[^\]]+\]\(https://github\.com/[^/\s"]+/?\)
# GHSA
GHSA(?:-[0-9a-z]{4}){3}
@@ -143,8 +161,8 @@ GHSA(?:-[0-9a-z]{4}){3}
# GitLab commits
\bgitlab\.[^/\s"]*/(?:[^/\s"]+/){2}commits?/[0-9a-f]+\b
# binanace
accounts.binance.com/[a-z/]*oauth/authorize\?[-0-9a-zA-Z&%]*
# binance
accounts\.binance\.com/[a-z/]*oauth/authorize\?[-0-9a-zA-Z&%]*
# bitbucket diff
\bapi\.bitbucket\.org/\d+\.\d+/repositories/(?:[^/\s"]+/){2}diff(?:stat|)(?:/[^/\s"]+){2}:[0-9a-f]+
@@ -280,9 +298,9 @@ slack://[a-zA-Z0-9?&=]+
\bdropbox\.com/sh?/[^/\s"]+/[-0-9A-Za-z_.%?=&;]+
# ipfs protocol
ipfs://[0-9a-z]*
ipfs://[0-9a-zA-Z]{3,}
# ipfs url
/ipfs/[0-9a-z]*
/ipfs/[0-9a-zA-Z]{3,}
# w3
\bw3\.org/[-0-9a-zA-Z/#.]+
@@ -359,14 +377,22 @@ ipfs://[0-9a-z]*
# tinyurl
\btinyurl\.com/\w+
# codepen
\bcodepen\.io/[\w/]+
# registry.npmjs.org
\bregistry\.npmjs\.org/(?:@[^/"']+/|)[^/"']+/-/[-\w@.]+
# getopts
\bgetopts\s+(?:"[^"]+"|'[^']+')
# ANSI color codes
(?:\\(?:u00|x)1b|\x1b)\[\d+(?:;\d+|)m
(?:\\(?:u00|x)1[Bb]|\x1b|\\u\{1[Bb]\})\[\d+(?:;\d+|)m
# URL escaped characters
\%[0-9A-F][A-F]
# lower URL escaped characters
\%[0-9a-f][a-f](?=[a-z]{2,})
# IPv6
\b(?:[0-9a-fA-F]{0,4}:){3,7}[0-9a-fA-F]{0,4}\b
# c99 hex digits (not the full format, just one I've seen)
@@ -376,7 +402,7 @@ ipfs://[0-9a-z]*
# sha
sha\d+:[0-9]*[a-f]{3,}[0-9a-f]*
# sha-... -- uses a fancy capture
(['"]|&quot;)[0-9a-f]{40,}\g{-1}
(\\?['"]|&quot;)[0-9a-f]{40,}\g{-1}
# hex runs
\b[0-9a-fA-F]{16,}\b
# hex in url queries
@@ -391,18 +417,21 @@ sha\d+:[0-9]*[a-f]{3,}[0-9a-f]*
# Well known gpg keys
.well-known/openpgpkey/[\w./]+
# pki
-----BEGIN.*-----END
# uuid:
\b[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\b
# hex digits including css/html color classes:
(?:[\\0][xX]|\\u|[uU]\+|#x?|\%23)[0-9_a-fA-FgGrR]*?[a-fA-FgGrR]{2,}[0-9_a-fA-FgGrR]*(?:[uUlL]{0,3}|u\d+)\b
(?:[\\0][xX]|\\u|[uU]\+|#x?|\%23)[0-9_a-fA-FgGrR]*?[a-fA-FgGrR]{2,}[0-9_a-fA-FgGrR]*(?:[uUlL]{0,3}|[iu]\d+)\b
# integrity
integrity="sha\d+-[-a-zA-Z=;:/0-9+]{40,}"
integrity=(['"])(?:\s*sha\d+-[-a-zA-Z=;:/0-9+]{40,})+\g{-1}
# https://www.gnu.org/software/groff/manual/groff.html
# man troff content
\\f[BCIPR]
# '
\\\(aq
# '/"
\\\([ad]q
# .desktop mime types
^MimeTypes?=.*$
@@ -411,21 +440,33 @@ integrity="sha\d+-[-a-zA-Z=;:/0-9+]{40,}"
# Localized .desktop content
Name\[[^\]]+\]=.*
# IServiceProvider
\bI(?=(?:[A-Z][a-z]{2,})+\b)
# IServiceProvider / isAThing
\b(?:I|isA)(?=(?:[A-Z][a-z]{2,})+\b)
# crypt
"\$2[ayb]\$.{56}"
(['"])\$2[ayb]\$.{56}\g{-1}
# scrypt / argon
\$(?:scrypt|argon\d+[di]*)\$\S+
# Input to GitHub JSON
content: "[-a-zA-Z=;:/0-9+]*="
# go.sum
\bh1:\S+
# Python stringprefix / binaryprefix
# scala modules
#("[^"]+"\s*%%?\s*){2,3}"[^"]+"
# Input to GitHub JSON
content: (['"])[-a-zA-Z=;:/0-9+]*=\g{-1}
# This does not cover multiline strings, if your repository has them,
# you'll want to remove the `(?=.*?")` suffix.
# The `(?=.*?")` suffix should limit the false positives rate
# printf
#%(?:(?:(?:hh?|ll?|[jzt])?[diuoxn]|l?[cs]|L?[fega]|p)(?=[a-z]{2,})|(?:X|L?[FEGA]|p)(?=[a-zA-Z]{2,}))(?=[_a-zA-Z]+\b)(?!%)(?=.*?['"])
# Python string prefix / binary prefix
# Note that there's a high false positive rate, remove the `?=` and search for the regex to see if the matches seem like reasonable strings
(?<!')\b(?:B|BR|Br|F|FR|Fr|R|RB|RF|Rb|Rf|U|UR|Ur|b|bR|br|f|fR|fr|r|rB|rF|rb|rf|u|uR|ur)'(?:[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})
(?<!')\b(?:B|BR|Br|F|FR|Fr|R|RB|RF|Rb|Rf|U|UR|Ur|b|bR|br|f|fR|fr|r|rB|rF|rb|rf|u|uR|ur)'(?=[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})
# Regular expressions for (P|p)assword
\([A-Z]\|[a-z]\)[a-z]+
@@ -441,16 +482,35 @@ content: "[-a-zA-Z=;:/0-9+]*="
^\s*/\\[b].*/[gim]*\s*(?:\)(?:;|$)|,$)
# javascript replace regex
\.replace\(/[^/\s"]*/[gim]*\s*,
# assign regex
= /[^*]*?(?:[a-z]{3,}|[A-Z]{3,}|[A-Z][a-z]{2,}).*/
# perl regex test
[!=]~ (?:/.*/|m\{.*?\}|m<.*?>|m([|!/@#,;']).*?\g{-1})
# perl qr regex
(?<!\$)\bqr(?:\{.*?\}|<.*?>|\(.*?\)|([|!/@#,;']).*?\g{-1})
# Go regular expressions
regexp?\.MustCompile\(`[^`]*`\)
# regex choice
\(\?:[^)]+\|[^)]+\)
# proto
^\s*(\w+)\s\g{-1} =
# sed regular expressions
sed 's/(?:[^/]*?[a-zA-Z]{3,}[^/]*?/){2}
# node packages
(["'])\@[^/'" ]+/[^/'" ]+\g{-1}
# go install
go install(?:\s+[a-z]+\.[-@\w/.]+)+
# jetbrains schema https://youtrack.jetbrains.com/issue/RSRP-489571
urn:shemas-jetbrains-com
# kubernetes pod status lists
# https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
\w+(?:-\w+)+\s+\d+/\d+\s+(?:Running|Pending|Succeeded|Failed|Unknown)\s+
@@ -462,19 +522,47 @@ go install(?:\s+[a-z]+\.[-@\w/.]+)+
-[0-9a-f]{10}-\w{5}\s
# posthog secrets
posthog\.init\((['"])phc_[^"',]+\g{-1},
([`'"])phc_[^"',]+\g{-1}
# xcode
# xcodeproject scenes
(?:Controller|ID|id)="\w{3}-\w{2}-\w{3}"
(?:Controller|destination|ID|id)="\w{3}-\w{2}-\w{3}"
# xcode api botches
customObjectInstantitationMethod
# configure flags
.* \| --\w{2,}.*?(?=\w+\s\w+)
# font awesome classes
\.fa-[-a-z0-9]+
# bearer auth
(['"])Bear[e][r] .*?\g{-1}
# basic auth
(['"])Basic [-a-zA-Z=;:/0-9+]{3,}\g{-1}
# base64 encoded content
([`'"])[-a-zA-Z=;:/0-9+]+=\g{-1}
# base64 encoded content in xml/sgml
>[-a-zA-Z=;:/0-9+]+=</
# base64 encoded content, possibly wrapped in mime
(?:^|[\s=;:?])[-a-zA-Z=;:/0-9+]{50,}(?:[\s=;:?]|$)
# encoded-word
=\?[-a-zA-Z0-9"*%]+\?[BQ]\?[^?]{0,75}\?=
# Time Zones
\b(?:Africa|Atlantic|America|Antarctica|Asia|Australia|Europe|Indian|Pacific)(?:/\w+)+
# linux kernel info
^(?:bugs|flags|Features)\s+:.*
# systemd mode
systemd.*?running in system mode \([-+].*\)$
# Update Lorem based on your content (requires `ge` and `w` from https://github.com/jsoref/spelling; and `review` from https://github.com/check-spelling/check-spelling/wiki/Looking-for-items-locally )
# grep '^[^#].*lorem' .github/actions/spelling/patterns.txt|perl -pne 's/.*i..\?://;s/\).*//' |tr '|' "\n"|sort -f |xargs -n1 ge|perl -pne 's/^[^:]*://'|sort -u|w|sed -e 's/ .*//'|w|review -
# Warning, while `(?i)` is very neat and fancy, if you have some binary files that aren't proper unicode, you might run into:
@@ -485,32 +573,57 @@ customObjectInstantitationMethod
(?:\w|\s|[,.])*\b(?i)(?:amet|consectetur|cursus|dolor|eros|ipsum|lacus|libero|ligula|lorem|magna|neque|nulla|suscipit|tempus)\b(?:\w|\s|[,.])*
# Non-English
[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*
[a-zA-Z]*[ÀÁÂÃÄÅÆČÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæčçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆČÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæčçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*|[a-zA-Z]{3,}[ÀÁÂÃÄÅÆČÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæčçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]|[ÀÁÂÃÄÅÆČÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæčçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3,}
# highlighted letters
\[[A-Z]\][a-z]+
# French
# This corpus only had capital letters, but you probably want lowercase ones as well.
\b[LN]'+[a-z]{2,}\b
# latex
\\(?:n(?:ew|ormal|osub)|r(?:enew)|t(?:able(?:of|)|he|itle))(?=[a-z]+)
# latex (check-spelling >= 0.0.22)
\\\w{2,}\{
# eslint
"varsIgnorePattern": ".+"
# Windows short paths
[/\\][^/\\]{5,6}~\d{1,2}[/\\]
# in check-spelling@v0.0.22+, printf markers aren't automatically consumed
# printf markers
#(?<!\\)\\[nrt](?=[a-z]{2,})
# alternate markers if you run into latex and friends
#(?<!\\)\\[nrt](?=[a-z]{2,})(?=.*['"`])
# apache
a2(?:en|dis)
# weak e-tag
W/"[^"]+"
# the negative lookahead here is to allow catching 'templatesz' as a misspelling
# but to otherwise recognize a Windows path with \templates\foo.template or similar:
\\(?:necessary|r(?:eport|esolve[dr]?|esult)|t(?:arget|emplates?))(?![a-z])
#\\(?:necessary|r(?:eport|esolve[dr]?|esult)|t(?:arget|emplates?))(?![a-z])
# ignore long runs of a single character:
\b([A-Za-z])\g{-1}{3,}\b
# Note that the next example is no longer necessary if you are using
# to match a string starting with a `#`, use a character-class:
[#]backwards
# version suffix <word>v#
(?:(?<=[A-Z]{2})V|(?<=[a-z]{2}|[A-Z]{2})v)\d+(?:\b|(?=[a-zA-Z_]))
# Compiler flags (Scala)
(?:^|[\t ,>"'`=(])-J-[DPWXY](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
# Compiler flags
#(?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
# Compiler flags (Unix, Java/Scala)
# Use if you have things like `-Pdocker` and want to treat them as `docker`
#(?:^|[\t ,>"'`=(])-(?:(?:J-|)[DPWXY]|[Llf])(?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
# Compiler flags (Windows / PowerShell)
# This is a subset of the more general compiler flags pattern.
# It avoids matching `-Path` to prevent it from being treated as `ath`
#(?:^|[\t ,"'`=(])-(?:[DPL](?=[A-Z]{2,})|[WXYlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,}))
# Compiler flags (linker)
,-B
# curl arguments
\b(?:\\n|)curl(?:\s+-[a-zA-Z]{1,2}\b)*(?:\s+-[a-zA-Z]{3,})(?:\s+-[a-zA-Z]+)*
# set arguments

View File

@@ -10,68 +10,87 @@
(?:^|/)FilePreviewCommon/Assets/Monaco/monacoSpecialLanguages.js
(?:^|/)monacoSRC/
(?:^|/)package(?:-lock|)\.json$
(?:^|/)Pipfile$
(?:^|/)power-rename-ui-flags$
(?:^|/)pyproject.toml
(?:^|/)requirements(?:-dev|-doc|-test|)\.txt$
(?:^|/)timezones\.json$
(?:^|/)vendor/
(?:^|/)WindowsSettings\.json$
/package(?:-lock|)\.json$
/pinyindb/
/settings-html/
[/.][a-z]{2}(?:-[a-zA-Z]{2}|)\.
/images/launcher/[^/]+$
/TestFiles/
[^/]\.gcode$
[^/]\.rgs$
\.a$
\.ai$
\.all-contributorsrc$
\.avi$
\.bmp$
\.bz2$
\.cer$
\.class$
\.coveragerc$
\.crl$
\.crt$
\.dat$
\.csr$
\.dll$
\.docx?$
\.drawio$
\.DS_Store$
\.eot$
\.eps$
\.exe$
\.filters$
\.gcode$
\.gif$
\.git-blame-ignore-revs$
\.gitattributes$
\.gitignore$
\.gitkeep$
\.graffle$
\.gz$
\.icns$
\.ico$
\.ipynb$
\.jar$
\.jks$
\.jpe?g$
\.key$
\.lcl$
\.lib$
\.lock$
\.map$
\.min\..
\.mo$
\.mod$
\.mp[34]$
\.o$
\.ocf$
\.otf$
\.p12$
\.parquet$
\.pdf$
\.pem$
\.PNG$
\.pfx$
\.png$
\.psd$
\.pyc$
\.pylintrc$
\.qm$
\.s$
\.stl$
\.svg$
\.sig$
\.so$
\.svgz?$
\.sys$
\.tar$
\.tgz$
\.tiff?$
\.ttf$
\.wav$
\.webm$
\.webp$
\.woff2?$
\.xcf$
\.xlsx?$
\.xpm$
\.xz$
\.zip$
^\.github/actions/spell-check/
^\.gitmodules$
@@ -79,38 +98,28 @@
^\Q.pipelines/ESRPSigning_core.json\E$
^\Qinstaller/PowerToysSetup/Settings.wxs\E$
^\Qsrc/common/ManagedCommon/ColorFormatHelper.cs\E$
^\Q.pipelines/sdl.gdnbaselines\E$
^\Qsrc/common/FilePreviewCommon/Assets/Monaco/monaco_languages.json\E$
^\Qsrc/common/notifications/BackgroundActivatorDLL/cpp.hint\E$
^\Qsrc/modules/colorPicker/ColorPickerUI/Assets/ColorPicker/colorPicker.cur\E$
^\Qsrc/modules/colorPicker/ColorPickerUI/Shaders/GridShader.cso\E$
^\Qsrc/modules/MouseUtils/MouseJumpUI/MainForm.resx\E$
^\Qsrc/modules/MouseWithoutBorders/App/Form/frmAbout.cs\E$
^\Qsrc/modules/MouseWithoutBorders/App/Properties/AssemblyInfo.cs\E$
^\Qsrc/modules/MouseWithoutBorders/ModuleInterface/generateSecurityDescriptor.h\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/CorruptJson/Microsoft/PowerToys/settings.json\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/PowerRename/power-rename-ui-flags\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/PowerRename/power-rename-ui-flags\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/PowerRename/power-rename-ui-flags\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/FancyZones/settings.json\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/PowerRename/power-rename-ui-flags\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/FancyZones/settings.json\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/PowerRename/power-rename-ui-flags\E$
^\Qsrc/modules/MouseUtils/MouseJumpUI/NativeMethods/User32/UI/WindowsAndMessaging/User32.SYSTEM_METRICS_INDEX.cs\E$
^\Qsrc/modules/MouseWithoutBorders/App/Form/frmInputCallback.resx\E$
^\Qsrc/modules/MouseWithoutBorders/App/Form/frmLogon.resx\E$
^\Qsrc/modules/MouseWithoutBorders/App/Form/frmMatrix.resx\E$
^\Qsrc/modules/MouseWithoutBorders/App/Form/frmScreen.resx\E$
^\Qsrc/modules/peek/Peek.Common/NativeMethods.txt\E$
^\Qsrc/modules/previewpane/SvgPreviewHandler/SvgHTMLPreviewGenerator.cs\E$
^\Qsrc/modules/previewpane/UnitTests-StlThumbnailProvider/HelperFiles/sample.stl\E$
^\Qtools/project_template/ModuleTemplate/resource.h\E$
^doc/devdocs/akaLinks\.md$
^installer/PowerToysSetup/WebView2/MicrosoftEdgeWebview2Setup.exe$
^src/common/logger/logger\.vcxproj\.filters$
^src/common/notifications/BackgroundActivatorDLL/BackgroundActivator\.vcxproj\.filters$
^src/common/notifications/BackgroundActivatorDLL/cpp\.hint$
^src/modules/colorPicker/ColorPickerUI/Assets/ColorPicker/colorPicker\.cur$
^src/modules/fancyzones/lib/FancyZonesWinHookEventIDs\.h$
^src/modules/imageresizer/dll/ContextMenuHandler\.rgs$
^src/modules/imageresizer/dll/ImageResizerExt\.rgs$
^src/modules/MouseUtils/MouseJumpUI/NativeMethods/User32/UI/WindowsAndMessaging/User32.SYSTEM_METRICS_INDEX.cs$
^src/modules/MouseWithoutBorders/App/Form/.*\.resx$
^src/modules/MouseWithoutBorders/App/Form/.*\.Designer\.cs$
^src/modules/MouseWithoutBorders/App/Helper/.*\.resx$
^src/modules/MouseWithoutBorders/App/.*/NativeMethods\.cs$
^src/modules/peek/Peek\.Common/NativeMethods\.txt$
^src/modules/powerrename/testapp/PowerRenameTest\.vcxproj\.filters$
^src/modules/previewpane/PreviewPaneUnitTests/HelperFiles/MarkdownWithHTMLImageTag\.txt$
^src/modules/previewpane/UnitTests-MarkdownPreviewHandler/HelperFiles/MarkdownWithHTMLImageTag.txt$
^tools/CleanUp_tool/CleanUp_tool\.vcxproj\.filters$
^tools/Verification scripts/Check preview handler registration\.ps1$
ignore$

View File

@@ -21,6 +21,7 @@ activationaction
ADDUNDORECORD
ADifferent
adio
adipiscing
administra
ADMINS
adml
@@ -34,6 +35,7 @@ AGGREGATABLE
AHybrid
ALarger
alekhyareddy
aliquip
ALLAPPS
ALLINPUT
ALLOWUNDO
@@ -97,6 +99,7 @@ ASingle
ASSOCCHANGED
ASYNCWINDOWPLACEMENT
ASYNCWINDOWPOS
ative
atl
atlbase
atlcom
@@ -150,7 +153,6 @@ BLURREGION
bmi
bms
BNumber
Bokm
BOKMAL
bootstrapper
BOOTSTRAPPERINSTALLFOLDER
@@ -172,6 +174,7 @@ BTNFACE
Bto
buf
bugreport
BUILDARCH
BUILDNUMBER
buildtask
buildtransitive
@@ -274,6 +277,7 @@ cominterop
commandline
COMMANDTITLE
commctrl
commodo
compmgmt
COMPOSITIONFULL
comsupp
@@ -284,6 +288,8 @@ CONFIGW
CONFLICTINGMODIFIERKEY
CONFLICTINGMODIFIERSHORTCUT
CONOUT
consectetur
consequat
Consolas
constexpr
consts
@@ -326,6 +332,7 @@ CTRLALTDEL
Ctrls
Ctx
CUI
cupidatat
currentculture
CURRENTDIR
CURSORINFO
@@ -372,6 +379,7 @@ dcomp
DComposition
dcr
dcs
ddd
DDEIf
DDevice
ddf
@@ -398,12 +406,12 @@ DELETEDKEYIMAGE
DELETESCANS
deletethis
Delimarsky
dend
DENORMAL
Deondre
depersist
deprioritized
deref
deserunt
DESKTOPABSOLUTEEDITING
DESKTOPABSOLUTEPARSING
desktopshorcutinstalled
@@ -484,6 +492,7 @@ dxgidebug
dxgiformat
dxguid
ecount
ecyclebin
EData
Edid
EDITKEYBOARD
@@ -491,8 +500,13 @@ editkeyboardwindow
EDITSHORTCUTS
editshortcutswindow
EFile
egistry
egistrypreview
eip
ekus
elease
elemetry
elit
emmintrin
Emoji
ENABLEDELAYEDEXPANSION
@@ -503,6 +517,7 @@ encryptor
endpointvolume
endregion
ENDSESSION
enim
ENTERSIZEMOVE
ENU
EOAC
@@ -517,10 +532,16 @@ ERRORLEVEL
ERRORTITLE
ESettings
esize
esource
esrp
estapp
estart
ests
esult
etl
etstat
etw
ETW
etwork
EUQ
eurochange
eventlog
@@ -538,6 +559,7 @@ exabyte
examplehandler
examplepowertoy
EXAND
Excepteur
EXCLUDEFROMCAPTURE
exdisp
executionpolicy
@@ -548,6 +570,8 @@ exlist
EXPCMDFLAGS
EXPCMDSTATE
explr
exppowertoys
exptas
exsb
EXSEL
exstyle
@@ -575,7 +599,7 @@ FILEOP
FILEOS
FILESUBTYPE
FILESYSPATH
filetime
Filetime
FILEVERSION
Filtergraph
Filterkeyboard
@@ -585,6 +609,7 @@ findfast
firefox
FIXEDFILEINFO
flyout
flyouts
FOF
FOFX
FOLDERID
@@ -907,6 +932,8 @@ killrunner
Knownfolders
KSPROPERTY
Kybd
laboris
laborum
LAlt
Lambson
langword
@@ -957,6 +984,7 @@ lmcons
LMEM
LMENU
lnk
lnks
LOADFROMFILE
LOBYTE
LOCALAPPDATA
@@ -1028,6 +1056,7 @@ majortype
MAJORVERSION
makecab
MAKEINTRESOURCE
MAKEINTRESOURCEA
MAKEINTRESOURCEW
makepri
manifestdependency
@@ -1110,6 +1139,7 @@ mockapi
MODECHANGE
modernwpf
MODESPRUNED
mollit
MONITORENUMPROC
MONITORINFO
MONITORINFOEX
@@ -1154,10 +1184,12 @@ msrc
msstore
mst
msvc
msvcp
MTND
Mul
MULTIPLEUSE
multizone
muxc
mvvm
mwb
MWBEx
@@ -1182,6 +1214,7 @@ NCMBUTTONUP
NCMOUSELEAVE
NCMOUSEMOVE
NCol
nconsectetur
ncpa
NCPAINT
NCRBUTTONDBLCLK
@@ -1206,7 +1239,6 @@ newitem
newpath
newrow
Newtonsoft
niels
nielslaute
NIF
nint
@@ -1223,6 +1255,8 @@ NOCOPYBITS
nodeca
nodiscard
nodoc
NODRAWCAPTION
NODRAWICON
NOINHERITLAYOUT
NOINTERFACE
NOLINKINFO
@@ -1249,6 +1283,7 @@ NORMALUSER
NOSEARCH
NOSENDCHANGING
NOSIZE
nostrud
notfound
NOTIFICATIONSDLL
NOTIFYICONDATAW
@@ -1264,6 +1299,7 @@ NOZORDER
NPH
NResize
nrw
nsunt
NTAPI
ntdll
ntfs
@@ -1280,12 +1316,15 @@ Objbase
OBJID
objidl
oblitum
obmikh
occaecat
ocr
Ocrsettings
odbc
odbccp
Oem
officehubintl
officia
ofs
oid
oldcolor
@@ -1302,6 +1341,7 @@ onenote
onstd
oobe
OOBEPT
ools
opencode
opensource
openxmlformats
@@ -1315,6 +1355,8 @@ ostr
OSVERSIONINFOEX
OSVERSIONINFOEXW
osvi
otating
otifications
OUTOFCONTEXT
OUTOFMEMORY
outpin
@@ -1461,6 +1503,7 @@ PRODUCTVERSION
Progman
programdata
PROGRAMFILES
proident
projectname
PROPBAG
PROPERTYKEY
@@ -1541,6 +1584,7 @@ RECTL
rectp
rects
RECTSOURCE
recyclebin
redirectedfrom
Redist
redistributable
@@ -1579,6 +1623,7 @@ renamable
RENAMEONCOLLISION
Renamer
reparent
reparented
reparenting
reparse
reportbug
@@ -1612,6 +1657,7 @@ RIGHTDOWN
RIGHTSCROLLBAR
RIGHTUP
riid
ringbuffer
RKey
RLO
RMENU
@@ -1671,13 +1717,13 @@ Scode
scoobe
SCOPEID
screenshot
screenshots
scrollviewer
sddl
SDKDDK
sdns
searchterm
secpol
Secur
Segoe
Sekan
SENDCHANGE
@@ -1753,6 +1799,7 @@ sia
SIATTRIBFLAGS
SICHINT
sid
SIDs
siex
sigdn
SIGNINGSCENARIO
@@ -1853,6 +1900,7 @@ stylecop
Subdir
subfolders
subkey
subkeys
SUBLANG
subquery
subresource
@@ -1888,7 +1936,7 @@ SYSTEMTIME
sysvol
Tadele
talynone
TApp
tapp
TApplication
TApplied
targ
@@ -1945,6 +1993,7 @@ tlbimp
TMPVAR
TNP
toggleswitch
tonos
toolkitcontrols
toolkitconverters
Toolset
@@ -1965,6 +2014,7 @@ Tsd
TServer
TStr
TValue
tweakme
TWF
tymed
typedef
@@ -1987,6 +2037,7 @@ UIEx
uipi
UIs
ULARGE
ullamco
ULONGLONG
ums
unapply
@@ -2008,6 +2059,7 @@ unknwn
UNLEN
Unmap
unmute
unner
UNORM
unregistering
unremapped
@@ -2048,6 +2100,7 @@ VCINSTALLDIR
vcm
Vcpkg
VCRT
vcruntime
vcvars
VDesktop
vdi
@@ -2116,6 +2169,7 @@ webpage
websearch
webserver
website
websites
wekyb
Wevtapi
wgpocpl
@@ -2186,7 +2240,7 @@ WKSG
Wlkr
wmain
Wman
wmi
WMI
WMICIM
wmimgmt
WMKEYDOWN
@@ -2229,6 +2283,8 @@ wsl
wss
wstr
wsz
WTA
WTNCA
wtoi
WTS
wtsapi

View File

@@ -1,4 +1,6 @@
# reject `m_data` as there's a certain OS which has evil defines that break things if it's used elsewhere
# reject `m_data` as VxWorks defined it and that breaks things if it's used elsewhere
# see [fprime](https://github.com/nasa/fprime/commit/d589f0a25c59ea9a800d851ea84c2f5df02fb529)
# and [Qt](https://github.com/qtproject/qt-solutions/blame/fb7bc42bfcc578ff3fa3b9ca21a41e96eb37c1c7/qtscriptclassic/src/qscriptbuffer_p.h#L46)
# \bm_data\b
# If you have a framework that uses `it()` for testing and `fit()` for debugging a specific test,
@@ -6,40 +8,72 @@
# to use this:
#\bfit\(
# s.b. anymore
\bany more[,.]
# s.b. GitHub
\bGithub\b
(?<![&*.]|// |\btype )\bGithub\b(?![{)])
# s.b. GitLab
\bGitlab\b
(?<![&*.]|// |\btype )\bGitlab\b(?![{)])
# s.b. JavaScript
\bJavascript\b
# s.b. macOS or Mac OS X or ...
\bMacOS\b
# s.b. Microsoft
\bMicroSoft\b
# s.b. TypeScript
\bTypescript\b
# s.b. another
\ban[- ]other\b
# s.b. deprecation warning
\b[Dd]epreciation [Ww]arnings?\b
# s.b. greater than
\bgreater then\b
# s.b. in front of
\bin from of\b
# s.b. into
\sin to\s
# when not phrasal and when `in order to` would be wrong:
# https://thewritepractice.com/into-vs-in-to/
\sin to\s(?!if\b)
# s.b. is obsolete
\bis obsolescent\b
# s.b. it's or its
\bits[']
# s.b. opt-in
\sopt in\s
(?<!\sfor)\sopt in\s
# s.b. less than
\bless then\b
# s.b. one of
\bon of\b
# s.b. otherwise
\bother[- ]wise\b
# s.b. or (more|less)
\bore (?:more|less)\b
# s.b. nonexistent
\bnon existing\b
\b[Nn]o[nt][- ]existent\b
# s.b. brief / details/ param / return / retval
(?:^\s*|(?:\*|//|/*)\s+`)[\\@](?:breif|(?:detail|detials)|(?:params(?!\.)|prama?)|ret(?:uns?)|retvl)\b
# s.b. preexisting
[Pp]re[- ]existing
@@ -49,14 +83,37 @@
# s.b. preemptively
[Pp]re[- ]emptively
# s.b. recently changed or recent changes
[Rr]ecent changed
# s.b. reentrancy
[Rr]e[- ]entrancy
# s.b. reentrant
[Rr]e[- ]entrant
# s.b. workaround(s)
#\bwork[- ]arounds?\b
# s.b. understand
\bunder stand\b
# Reject duplicate words
# s.b. workarounds
#\bwork[- ]arounds\b
# s.b. workaround
(?:(?:[Aa]|[Tt]he|ugly)\swork[- ]around\b|\swork[- ]around\s+for)
# s.b. (coarse|fine)-grained
\b(?:coarse|fine) grained\b
# s.b. neither/nor -- or reword
#\bnot\b[^.?!"/(]+\bnor\b
# probably a double negative
# s.b. neither/nor (plus rewording the beginning)
\bnot\b[^.?!"/]*\bneither\b[^.?!"/(]*\bnor\b
# In English, it is generally wrong to have the same word twice in a row without punctuation.
# Duplicated words are generally mistakes.
# There are a few exceptions where it is acceptable (e.g. "that that").
# If the highlighted doubled word pair is in a code snippet, you can write a pattern to mask it.
# If the highlighted doubled word pair is in prose, have someone read the English before you dismiss this error.
\s([A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})\s\g{-1}\s

View File

@@ -1,179 +1,177 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns
# Automatically suggested patterns
# hit-count: 2206 file-count: 617
# IServiceProvider
\bI(?=(?:[A-Z][a-z]{2,})+\b)
# hit-count: 3011 file-count: 842
# IServiceProvider / isAThing
\b(?:I|isA)(?=(?:[A-Z][a-z]{2,})+\b)
# hit-count: 111 file-count: 57
# hit-count: 2239 file-count: 134
# hex runs
\b[0-9a-fA-F]{16,}\b
# hit-count: 89 file-count: 36
# hit-count: 1868 file-count: 1
# sha-... -- uses a fancy capture
(\\?['"]|&quot;)[0-9a-f]{40,}\g{-1}
# hit-count: 1100 file-count: 97
# base64 encoded content, possibly wrapped in mime
(?:^|[\s=;:?])[-a-zA-Z=;:/0-9+]{50,}(?:[\s=;:?]|$)
# hit-count: 426 file-count: 165
# GitHub SHAs (markdown)
(?:\[`?[0-9a-f]+`?\]\(https:/|)/(?:www\.|)github\.com(?:/[^/\s"]+){2,}(?:/[^/\s")]+)(?:[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|)
# hit-count: 67 file-count: 59
# hit-count: 331 file-count: 117
# hex digits including css/html color classes:
(?:[\\0][xX]|\\u|[uU]\+|#x?|\%23)[0-9_a-fA-FgGrR]*?[a-fA-FgGrR]{2,}[0-9_a-fA-FgGrR]*(?:[uUlL]{0,3}|[iu]\d+)\b
# hit-count: 275 file-count: 45
# version suffix <word>v#
(?:(?<=[A-Z]{2})V|(?<=[a-z]{2}|[A-Z]{2})v)\d+(?:\b|(?=[a-zA-Z_]))
# hit-count: 209 file-count: 97
# w3
\bw3\.org/[-0-9a-zA-Z/#.]+
# hit-count: 47 file-count: 3
# hit-count: 137 file-count: 38
# alternate markers if you run into latex and friends
(?<!\\)\\[nrt](?=[a-z]{2,})(?=.*['"`](?:, "[^{]|\]))
# tabs in c#
\$"\\t
# windows line breaks in strings
\\r\\n
# hit-count: 104 file-count: 43
# regex choice
\(\?:[^)]+\|[^)]+\)
# hit-count: 76 file-count: 28
# base64 encoded content
([`'"])[-a-zA-Z=;:/0-9+]+=\g{-1}
# hit-count: 70 file-count: 5
# Contributor
\[[^\]]+\]\(https://github\.com/[^/\s"]+\)
\[[^\]]+\]\(https://github\.com/[^/\s"]+/?\)
# hit-count: 45 file-count: 2
# Non-English
[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*
# hit-count: 22 file-count: 18
# hit-count: 28 file-count: 22
# stackexchange -- https://stackexchange.com/feeds/sites
\b(?:askubuntu|serverfault|stack(?:exchange|overflow)|superuser).com/(?:questions/\w+/[-\w]+|a/)
# hit-count: 7 file-count: 3
# hit-count: 21 file-count: 2
# Update Lorem based on your content (requires `ge` and `w` from https://github.com/jsoref/spelling; and `review` from https://github.com/check-spelling/check-spelling/wiki/Looking-for-items-locally )
# grep '^[^#].*lorem' .github/actions/spelling/patterns.txt|perl -pne 's/.*i..\?://;s/\).*//' |tr '|' "\n"|sort -f |xargs -n1 ge|perl -pne 's/^[^:]*://'|sort -u|w|sed -e 's/ .*//'|w|review -
# Warning, while `(?i)` is very neat and fancy, if you have some binary files that aren't proper unicode, you might run into:
## Operation "substitution (s///)" returns its argument for non-Unicode code point 0x1C19AE (the code point will vary).
## You could manually change `(?i)X...` to use `[Xx]...`
## or you could add the files to your `excludes` file (a version after 0.0.19 should identify the file path)
# Lorem
(?:\w|\s|[,.])*\b(?i)(?:amet|consectetur|cursus|dolor|eros|ipsum|lacus|libero|ligula|lorem|magna|neque|nulla|suscipit|tempus)\b(?:\w|\s|[,.])*
# hit-count: 18 file-count: 15
# microsoft
\b(?:https?://|)(?:(?:download\.visualstudio|docs|msdn2?|research)\.microsoft|blogs\.msdn)\.com/[-_a-zA-Z0-9()=./%]*
# hit-count: 14 file-count: 5
# githubusercontent
/[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]*
# hit-count: 14 file-count: 3
# node packages
(["'])\@[^/'" ]+/[^/'" ]+\g{-1}
# hit-count: 10 file-count: 4
# URL escaped characters
\%[0-9A-F][A-F]
# hit-count: 9 file-count: 5
# Wikipedia
\ben\.wikipedia\.org/wiki/[-\w%.#]+
# hit-count: 6 file-count: 3
# css url wrappings
\burl\([^)]+\)
# hit-count: 5 file-count: 3
# vs devops
\bvisualstudio.com(?::443|)/[-\w/?=%&.]*
# hit-count: 3 file-count: 3
# githubusercontent
/[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]*
# hit-count: 4 file-count: 3
# Non-English
[a-zA-Z]*[ÀÁÂÃÄÅÆČÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæčçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆČÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæčçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*|[a-zA-Z]{3,}[ÀÁÂÃÄÅÆČÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæčçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]|[ÀÁÂÃÄÅÆČÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæčçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3,}
# hit-count: 4 file-count: 2
# data url in quotes
([`'"])data:(?:[^ `'"].*?|)(?:[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,}).*\g{-1}
# hit-count: 2 file-count: 2
# mailto urls
mailto:[-a-zA-Z=;:/?%&0-9+@.]{3,}
https?://(?:(?:www\.|)youtube\.com|youtu.be)/[-a-zA-Z0-9?&=]*
# GitHub SHAs
\bapi.github\.com/repos/[^/]+/[^/]+/[^/]+/[0-9a-f]+\b
://github\.(?:com|blog)/[^\w")]+
(?:\[[0-9a-f]+\]\(https:/|)/github\.com/[^/]+/[^/]+/[^/]+/[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b
# githubusercontent
://githubusercontent\.com/[^\w")]+
# gist github
/gist\.github\.com/[^/]+/[0-9a-f]+
# msdn
\b(?:download\.visualstudio|docs|msdn|learn)\.microsoft\.com/[-_a-zA-Z0-9()=./]*
aka\.ms/[a-zA-Z0-9]+
# medium
link\.medium\.com/[a-zA-Z0-9]+
\bmedium\.com/\@[^/]+/[-\w]+
# experimentation urls
https?://default\.exp-tas\.com/[-_a-zA-Z0-9/]*
publicKeyToken=(['"]|)[0-9a-f]+\g{-1}
\@sha256:[0-9a-f]{64}\b
# data urls
(['"])data:.*?\g{-1}
data:[-a-zA-Z=;:/0-9+]*,\S*
# hit-count: 2 file-count: 1
# While you could try to match `http://` and `https://` by using `s?` in `https?://`, sometimes there
# YouTube url
\b(?:(?:www\.|)youtube\.com|youtu.be)/(?:channel/|embed/|user/|playlist\?list=|watch\?v=|v/|)[-a-zA-Z0-9?&=_%]*
# uuid: (or CompGUIDPrefix)
L?(["']|[-<({>]|\b)[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{10,12}(?:\g{-1}|[<})>])
# c99 hex digits (not the full format, just one I've seen)
0x[0-9a-fA-F](?:\.[0-9a-fA-F]*|)[pP]
# URL escaped characters
\%[0-9A-F]{2}
# wregex
std::wregex\(L"[^"]*"\)
# hash
Hash="[0-9A-F]{40}"
# SHA256 hash
'[0-9A-F]{64}'
# hex digits including css/html color classes:
(?:[\\0][xX]|\\u|[uU]\+|#x?|\%23|L")[0-9a-fA-FgGrR_]{2,}(?:[uU]?[lL]{0,2}|u\d+)\b
(?:L"[abAB]+", ){3}L"[abAB]+"
"Lorem[^"]+?\."
TestCase\("[^"]+"
# Test line with hexadecimal colors
\[DataRow\("[0-9A-F]{6}", \d{3}, \d{3}, \d{3}\)\]
\[DataRow\("[0-9A-F]{6}", \d{3}.\d{1}, \d{3}.\d{1}, \d{3}.\d{1}\)\]
\[DataRow\("[0-9A-F]{6}", "[BCGMRY]\d\d?", \d{3}, \d{3}\)\]
# version suffix <word>v#
[Vv]\d+(?:\b|(?=[a-zA-Z_]))
# Windows paths
\\native
\\netcoreapp
\\netstandard
\\network
\\notifications
\\recyclebin
\\Registry
\\registry
\\reinstall
\\release
\\Resize
\\resource
\\Resources
\\restart
\\restore
\\result
\\robmikh
\\rotating
\\runner
\\runtimes
\\Telemetry
\\telemetry
\\testapp
\\tests
\\tools
# plugin.json
^ "ID": "[0-9A-F]{32}",$
# hit-count: 1 file-count: 1
# marker to ignore all code on line
^.*/\* #no-spell-check-line \*/.*$
# UnitTests
\[DataRow\(.*\)\]
# Id info inside markdown file (registry.md)
^\|\s+ID\s+\|\s*\`[0-9A-F]{32}\`
# TestCase strings intentionally have non dictionary items
\[TestCase\(new string.*\]
# D2D
D?2D
# marker for ignoring a comment to the end of the line
^.*/\* #no-spell-check-line \*/.*$
// #no-spell-check.*$
# hit-count: 1 file-count: 1
# GHSA
GHSA(?:-[0-9a-z]{4}){3}
http://tes/
# hit-count: 1 file-count: 1
# medium
\bmedium\.com/\@?[^/\s"]+/[-\w]+
# hit-count: 1 file-count: 1
# kubectl.kubernetes.io/last-applied-configuration
"kubectl.kubernetes.io/last-applied-configuration": ".*"
# hit-count: 1 file-count: 1
# tar arguments
\b(?:\\n|)tar(?:\s+-[a-zA-Z]+|\s[a-z]+)+
\b(?:\\n|)g?tar(?:\.exe|)(?:(?:\s+--[-a-zA-Z]+|\s+-[a-zA-Z]+|\s[ABGJMOPRSUWZacdfh-pr-xz]+\b)(?:=[^ ]*|))+
\bSecur32
# fabricbot.json
"id": "\S+"
"commentPattern": ".*"
# Questionably acceptable forms of `in to`
# Personally, I prefer `log into`, but people object
# https://www.tprteaching.com/log-into-log-in-to-login/
\b[Ll]og in to\b
\b(?:[Ll]og|[Ss]ign) in to\b
# to opt in
\bto opt in\b
# acceptable duplicates
# ls directory listings
# /bin/ls -l output
[-bcdlpsw](?:[-r][-w][-sx]){3}\s+\d+\s+(\S+)\s+\g{-1}\s+\d+\s+
[-bcdlpsw](?:[-r][-w][-Ssx]){3}\s+\d+\s+\S+\s+\S+\s+\d+\s+
# mount
\bmount\s+-t\s+(\w+)\s+\g{-1}\b
# C types and repeated CSS values
\s(center|div|inherit|long|LONG|none|normal|solid|thin|transparent|very)(?: \g{-1})+\s
\s(auto|center|div|inherit|long|LONG|none|normal|solid|thin|transparent|very)(?: \g{-1})+\s
# C struct
\bstruct\s+(\w+)\s+\g{-1}\b
# go templates
\s(\w+)\s+\g{-1}\s+\`(?:graphql|json|yaml):
# javadoc / .net
(?:[\\@](?:groupname|param)|(?:public|private)(?:\s+static|\s+readonly)*)\s+(\w+)\s+\g{-1}\s
\s(\w+)\s+\g{-1}\s+\`(?:graphql|inject|json|yaml):
# doxygen / javadoc / .net
(?:[\\@](?:brief|groupname|t?param|return|retval)|(?:public|private|\[Parameter(?:\(.+\)|)\])(?:\s+static|\s+override|\s+readonly)*)(?:\s+\{\w+\}|)\s+(\w+)\s+\g{-1}\s
# Commit message -- Signed-off-by and friends
^\s*(?:(?:Based-on-patch|Co-authored|Helped|Mentored|Reported|Reviewed|Signed-off)-by|Thanks-to): (?:[^<]*<[^>]*>|[^<]*)\s*$

View File

@@ -1,4 +1,5 @@
^attache$
^bellow$
benefitting
occurences?
^dependan.*

View File

@@ -5,7 +5,7 @@ name: Spell checking
# https://github.com/check-spelling/check-spelling/wiki/Feature%3A-Restricted-Permissions
#
# `jobs.comment-push` runs when a push is made to a repository and the `jobs.spelling` job needs to make a comment
# (in odd cases, it might actually run just to collapse a commment, but that's fairly rare)
# (in odd cases, it might actually run just to collapse a comment, but that's fairly rare)
# it needs `contents: write` in order to add a comment.
#
# `jobs.comment-pr` runs when a pull_request is made to a repository and the `jobs.spelling` job needs to make a comment
@@ -34,6 +34,29 @@ name: Spell checking
#
# For background, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Update-with-deploy-key
# Sarif reporting
#
# Access to Sarif reports is generally restricted (by GitHub) to members of the repository.
#
# Requires enabling `security-events: write`
# and configuring the action with `use_sarif: 1`
#
# For information on the feature, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Sarif-output
# Minimal workflow structure:
#
# on:
# push:
# ...
# pull_request_target:
# ...
# jobs:
# # you only want the spelling job, all others should be omitted
# spelling:
# # remove `security-events: write` and `use_sarif: 1`
# # remove `experimental_apply_changes_via_bot: 1`
# ... otherwise adjust the `with:` as you wish
on:
push:
branches:
@@ -43,12 +66,13 @@ on:
pull_request_target:
branches:
- "**"
tags-ignore:
- "**"
types:
- 'opened'
- 'reopened'
- 'synchronize'
issue_comment:
types:
- 'created'
jobs:
spelling:
@@ -57,10 +81,11 @@ jobs:
contents: read
pull-requests: read
actions: read
security-events: write
outputs:
followup: ${{ steps.spelling.outputs.followup }}
runs-on: ubuntu-latest
if: "contains(github.event_name, 'pull_request') || github.event_name == 'push'"
if: ${{ contains(github.event_name, 'pull_request') || github.event_name == 'push' }}
concurrency:
group: spelling-${{ github.event.pull_request.number || github.ref }}
# note: If you use only_check_changed_files, you do not want cancel-in-progress
@@ -68,24 +93,45 @@ jobs:
steps:
- name: check-spelling
id: spelling
uses: check-spelling/check-spelling@v0.0.21
uses: check-spelling/check-spelling@v0.0.22
with:
config: .github/actions/spell-check
suppress_push_for_open_pull_request: 1
suppress_push_for_open_pull_request: ${{ github.actor != 'dependabot[bot]' && 1 }}
checkout: true
check_file_names: 1
spell_check_this: check-spelling/spell-check-this@prerelease
spell_check_this: microsoft/PowerToys@main
post_comment: 0
use_magic_file: 1
extra_dictionary_limit: 10
warnings: bad-regex,binary-file,deprecated-feature,ignored-expect-variant,large-file,limited-references,no-newline-at-eof,noisy-file,non-alpha-in-dictionary,token-is-substring,unexpected-line-ending,whitespace-in-dictionary,minified-file,unsupported-configuration,no-files-to-check
experimental_apply_changes_via_bot: ${{ github.repository_owner != 'microsoft' && 1 }}
use_sarif: ${{ (!github.event.pull_request || (github.event.pull_request.head.repo.full_name == github.repository)) && 1 }}
extra_dictionary_limit: 20
extra_dictionaries:
cspell:software-terms/src/software-terms.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:cpp/src/stdlib-cpp.txt
cspell:filetypes/filetypes.txt
cspell:cpp/src/stdlib-c.txt
cspell:fullstack/fullstack.txt
cspell:html/html.txt
cspell:css/css.txt
cspell:python/src/python/python-lib.txt
cspell:lorem-ipsum/dictionary.txt
cspell:php/dict/php.txt
cspell:typescript/dict/typescript.txt
cspell:swift/src/swift.txt
cspell:fullstack/dict/fullstack.txt
cspell:node/dict/node.txt
cspell:dotnet/dict/dotnet.txt
cspell:django/dict/django.txt
cspell:python/src/python/python.txt
cspell:csharp/csharp.txt
cspell:python/src/common/extra.txt
cspell:cpp/src/compiler-msvc.txt
cspell:aws/aws.txt
cspell:golang/dict/go.txt
cspell:java/src/java.txt
cspell:html/dict/html.txt
cspell:css/dict/css.txt
cspell:k8s/dict/k8s.txt
cspell:java/src/java-terms.txt
cspell:powershell/dict/powershell.txt
comment-push:
name: Report (Push)
@@ -97,11 +143,11 @@ jobs:
if: (success() || failure()) && needs.spelling.outputs.followup && github.event_name == 'push'
steps:
- name: comment
uses: check-spelling/check-spelling@v0.0.21
uses: check-spelling/check-spelling@v0.0.22
with:
config: .github/actions/spell-check
checkout: true
spell_check_this: check-spelling/spell-check-this@prerelease
spell_check_this: microsoft/PowerToys@main
task: ${{ needs.spelling.outputs.followup }}
comment-pr:
@@ -110,13 +156,39 @@ jobs:
runs-on: ubuntu-latest
needs: spelling
permissions:
contents: read
pull-requests: write
if: (success() || failure()) && needs.spelling.outputs.followup && contains(github.event_name, 'pull_request')
steps:
- name: comment
uses: check-spelling/check-spelling@v0.0.21
uses: check-spelling/check-spelling@v0.0.22
with:
config: .github/actions/spell-check
checkout: true
spell_check_this: check-spelling/spell-check-this@prerelease
task: ${{ needs.spelling.outputs.followup }}
experimental_apply_changes_via_bot: ${{ github.repository_owner != 'microsoft' && 1 }}
update:
name: Update PR
permissions:
contents: write
pull-requests: write
actions: read
runs-on: ubuntu-latest
if: ${{
github.repository_owner != 'microsoft' &&
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '@check-spelling-bot apply')
}}
concurrency:
group: spelling-update-${{ github.event.issue.number }}
cancel-in-progress: false
steps:
- name: apply spelling updates
uses: check-spelling/check-spelling@v0.0.22
with:
experimental_apply_changes_via_bot: ${{ github.repository_owner != 'microsoft' && 1 }}
checkout: true
ssh_key: "${{ secrets.CHECK_SPELLING }}"

View File

@@ -25,7 +25,11 @@ $nullVersionExceptions = @(
"codicon.ttf",
"e_sqlite3.dll",
"vcamp140_app.dll",
"vcruntime140_app.dll",
"vcruntime140_1_app.dll",
"msvcp140_app.dll",
"marshal.dll",
"Microsoft.Toolkit.Win32.UI.XamlHost.dll",
"Microsoft.UI.Composition.OSSupport.dll",
"Microsoft.UI.Windowing.dll",
"Microsoft.UI.Xaml.Internal.dll",

3
Directory.Build.targets Normal file
View File

@@ -0,0 +1,3 @@
<Project>
<Sdk Name="Microsoft.Build.CopyOnWrite" Version="1.0.282" />
</Project>

View File

@@ -12,7 +12,7 @@
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Sizers" Version="8.0.230907" />
<PackageVersion Include="CommunityToolkit.WinUI.Collections " Version="8.0.230907" />
<PackageVersion Include="CommunityToolkit.WinUI.Converters" Version="8.0.230907" />
<PackageVersion Include="CommunityToolkit.WinUI.Extensions" Version="8.0.230907" />
<PackageVersion Include="CommunityToolkit.WinUI.Extensions" Version="8.0.230907" />
<PackageVersion Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
<PackageVersion Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />
<PackageVersion Include="ControlzEx" Version="6.0.0" />
@@ -34,7 +34,7 @@
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageVersion Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.2" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.1722.45" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2088.41" />
<PackageVersion Include="Microsoft.Windows.Compatibility" Version="7.0.3" />
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.2.46-beta" />
<!-- CsWinRT version needs to be set to have a WinRT.Runtime.dll at the same version contained inside the NET SDK we're currently building on CI. -->
@@ -79,4 +79,4 @@
<PackageVersion Include="Microsoft.VariantAssignment.Client" Version="2.4.17140001" />
<PackageVersion Include="Microsoft.VariantAssignment.Contract" Version="3.0.16990001" />
</ItemGroup>
</Project>
</Project>

View File

@@ -336,7 +336,7 @@ SOFTWARE.
- Microsoft.Extensions.Logging 7.0.0
- Microsoft.NET.Test.Sdk 17.6.3
- Microsoft.Toolkit.Uwp.Notifications 7.1.2
- Microsoft.Web.WebView2 1.0.1722.45
- Microsoft.Web.WebView2 1.0.2088.41
- Microsoft.Windows.Compatibility 7.0.3
- Microsoft.Windows.CsWin32 0.2.46-beta
- Microsoft.Windows.CsWinRT 2.0.3

View File

@@ -177,6 +177,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
src\.editorconfig = src\.editorconfig
.vsconfig = .vsconfig
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Directory.Packages.props = Directory.Packages.props
Solution.props = Solution.props
EndProjectSection

174
README.md
View File

@@ -39,19 +39,19 @@ Microsoft PowerToys is a set of utilities for power users to tune and streamline
Go to the [Microsoft PowerToys GitHub releases page][github-release-link] and 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 -->
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F48
[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F47
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.1/PowerToysUserSetup-0.74.1-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.1/PowerToysUserSetup-0.74.1-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.1/PowerToysSetup-0.74.1-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.1/PowerToysSetup-0.74.1-arm64.exe
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F49
[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F48
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.75.1/PowerToysUserSetup-0.75.1-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.75.1/PowerToysUserSetup-0.75.1-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.75.1/PowerToysSetup-0.75.1-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.75.1/PowerToysSetup-0.75.1-arm64.exe
| Description | Filename | sha256 hash |
|----------------|----------|-------------|
| Per user - x64 | [PowerToysUserSetup-0.74.1-x64.exe][ptUserX64] | 748BF7BA33913237D36D6F48E3839D0C8035967305137A17DEFF39D775735C81 |
| Per user - ARM64 | [PowerToysUserSetup-0.74.1-arm64.exe][ptUserArm64] | F5DAA89A9CF3A2805E121085AFD056A890F241A170FAB5007AA58E2755C88C54 |
| Machine wide - x64 | [PowerToysSetup-0.74.1-x64.exe][ptMachineX64] | 298C6F4E4391BDC06E128BED86A303C3300A68EAF754B4630AF7542C78C0944A |
| Machine wide - ARM64 | [PowerToysSetup-0.74.1-arm64.exe][ptMachineArm64] | A65F3C300A48F9F81312B7FC7B306382CB87F591612D0CEC7E5C0E47E868904B |
| Per user - x64 | [PowerToysUserSetup-0.75.1-x64.exe][ptUserX64] | CFDAE52607689A695F4E4DDD7C1FE68400359AEF0D2B23C86122835E9D32A20F |
| Per user - ARM64 | [PowerToysUserSetup-0.75.1-arm64.exe][ptUserArm64] | 9BAD3EF71DEDE70445416AC7369D115FAE095152722BC4F23EE393D8A10F45CA |
| Machine wide - x64 | [PowerToysSetup-0.75.1-x64.exe][ptMachineX64] | 18FEB9377B0BA45189FFF4F89627B152DD794CCC15F005592B34A40A3EA62EA8 |
| Machine wide - ARM64 | [PowerToysSetup-0.75.1-arm64.exe][ptMachineArm64] | F5CDF5A35876A0B581F446BF728B7AC52B6B701C0850D9CEA9A1874523745CFD |
This is our preferred method.
@@ -97,147 +97,139 @@ 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.
### 0.74 - September 2023 Update
### 0.75 - October 2023 Update
In this release, we focused on stability and improvements.
In this release, we focused on new features, stability and improvements.
**Highlights**
- Upgraded to Windows App SDK 1.4.1, increasing stability of WinUI3 utilities. Thanks [@dongle-the-gadget](https://github.com/dongle-the-gadget) for starting the upgrade!
- Text Extractor was upgraded to its version 2.0, with a new overlay, table mode and more Quality of Life improvements. Thanks [@TheJoeFin](https://github.com/TheJoeFin)!
- Improved FancyZones stability, fixing some layout resets and improving handling of newly created windows on Windows 11.
- Fixed many silent crashes that were reported to Watson and the user's event viewer.
- New utility: An environment variables editor with the functionality to configure profiles that can be enabled/disabled. Thanks [@niels9001](https://github.com/niels9001) for the design and UI work that made this possible!
- Settings has a new Dashboard home page, with quick access for enabling modules, short descriptions and activation methods. Thanks [@niels9001](https://github.com/niels9001) for the design and UI work that made this possible!
- Added a previewer to Peek that hosts File Explorer previewers to support every file type that a machine is currently able to preview. For example, this means that if Microsoft Office handlers are installed, Peek can preview Office files. Thanks [@dillydylann](https://github.com/dillydylann)!
### General
- Turning animations off in Windows Settings will now also turn them off in PowerToys.
- Upgraded the Windows App SDK dependency to 1.4.1. Thanks [@dongle-the-gadget](https://github.com/dongle-the-gadget) for the original 1.4.0 upgrade!
- Show in the thumbnail label and application titles when running as administrator. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Upgraded the Win UI Community Toolkit dependency to 8.0. Thanks [@niels9001](https://github.com/niels9001)!
### Awake
- Added down-sampled variants to the application's icon. Thanks [@morriscurtis](https://github.com/morriscurtis)!
- Many typo fixes through the projects and documentation. Thanks [@brianteeman](https://github.com/brianteeman)!
- Refactored and improved the logic across utilities for bringing a window to the foreground after activation.
### Color Picker
- After adding a new color in the editor, the history will scroll the new color into view. Thanks [@peerpalo](https://github.com/peerpalo)!
- After activating Color Picker, it's now possible to cancel the session by clicking the right mouse button. Thanks [@fredso90](https://github.com/fredso90)!
### Crop and Lock
- Fixed a Crop and Lock crash that would occur when trying to reparent a window crashes the target application. An error message is shown instead.
### Environment Variables
- Added a new utility: An environment variables editor that has the functionality to configure profiles that can be enabled/disabled. Thanks [@niels9001](https://github.com/niels9001) for the design and UI work that made this possible!
- Shows in the title bar if it's running as an administrator. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### FancyZones
- Set the process and main thread priority to normal.
- Fixed handling newly created windows on Windows 11.
- Fixed scenarios where opening the FancyZones Editor would reset the layouts.
- Fixed an issue causing context menu pop-ups from some apps to automatically snap to a zone. (This was a hotfix for 0.74)
- Applied the fix for the context menu pop-ups to the logic that decides which windows can be snapped.
- Reworked the "Keep windows in their zones" option to include the work area and turn it on by default, fixing an incompatibility with the Copilot flyout.
- Fixed an issue causing windows to be snapped while moving to a different virtual desktop.
### File Explorer add-ons
- Optimized CPU usage for generating SVG thumbnails.
- Improved handling of Gcode Thumbnails, including JPG and QOI formats. Thanks [@pedrolamas](https://github.com/pedrolamas)!
- Better handled errors when sending telemetry, which were causing reported crashes.
- Fixed some thumbnails not being shown centered like before the optimization.
- Fixed an issue blocking some SVG files from being previewed correctly. (This was a hotfix for 0.74)
- Fixed crashes on invalid files in the STL Thumbnail generator.
### File Locksmith
### GPO
- Shows files opened by processes with PID greater than 65535. Thanks [@poke30744](https://github.com/poke30744)!
- Fixed a GDI object leak in the context menu which would crash Explorer.
### Find My Mouse
- Added a global GPO rule that applies for all utilities unless it's overridden. Thanks [@htcfreek](https://github.com/htcfreek)!
- Added GPO rules to control which PowerToys Run plugins should be enabled/disabled by policy. Thanks [@htcfreek](https://github.com/htcfreek)!
* All plugins have to provide its plugin ID as static property in its Main method.
- Added new activation methods, including by hotkey. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### Image Resizer
### Hosts File Editor
- Ignore the default ACME sample entries in the hosts file. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Improved save error handling and added better error messages. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Corrected a check for an error when signaling the application to start as administrator.
- Refactored the context menu. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Fixed dialogs overlapping the title bar after the upgrade to Windows App SDK 1.4. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Fixed wrong .bmp file association in the registry. Thanks [@meitinger](https://github.com/meitinger)!
### Keyboard Manager
- Distinguish between the regular minus key and the numpad minus key.
- Visually distinguish between the Numpad and regular period characters in the UI.
- This utility is now disabled by default on new installations, since it requires user configuration to affect keyboard behavior.
- Fixed a typo in the Numpad Subtract key in the editor.
### Mouse Without Borders
### Mouse Highlighter
- Fixed a crash when trying to restart the application.
- Removed the lower limit of fade delay and duration, to allow better signaling of doing a double click. Thanks [@fredso90](https://github.com/fredso90)!
### Mouse Jump
- The process now runs in the background, for a faster activation time. Thanks [@mikeclayton](https://github.com/mikeclayton)!
### Peek
- Using Peek on HTML files will show a white background by default, similar to a browser's default behavior.
- Fix a white flash on Dark theme when switching file and improved the development file preview detection and adjustments.
- Reported file sizes will now more closely match what's reported by File Explorer. Thanks [@Deepak-Sangle](https://github.com/Deepak-Sangle)!
- Added a previewer that hosts File Explorer previewers to support every file type that a machine is currently able to preview. Thanks [@dillydylann](https://github.com/dillydylann)!
- Fixed an issue causing the preview of the first file to be stuck loading. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Fixed showing the previously previewed video file when invoking Peek with a new file. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Added the wrap and file formatting options to the Monaco previewer. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### PowerRename
- Fixed a crash caused by big counter values on the new enumeration method.
- Save data from the last run in a different file to avoid conflicting with changing settings in the Settings application.
### PowerToys Run
- It's now possible to select which shell is used by the Shell plugin.
- A combobox option type was added to the plugin options.
- Fixed a bug in the Calculator plugin that was causing decimal numbers to be misinterpreted on locales where the dot (`.`) character isn't used as a decimal or digit separator.
- Improved the Program plugin stability when it fails to load a program's thumbnail at startup.
- The use of Pinyin for querying some plugins can now be turned on in Settings. Thanks [@ChaseKnowlden](https://github.com/ChaseKnowlden)!
- Refactored option types for plugin and added number, string and composite types to be used in the future. Thanks [@htcfreek](https://github.com/htcfreek)!
- Fixed the entry for searching for Windows updates in the Settings plugin. Thanks [@htcfreek](https://github.com/htcfreek)!
- Fixed a case where the query wasn't being cleared after invoking a result action through the keyboard. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Improved the shell selection option for Windows Terminal in the Shell plugin and improved the backend code for adding combo box options to plugins. Thanks [@htcfreek](https://github.com/htcfreek)!
* The implementation of the combo box items has changed and isn't backward compatible. (Old plugins won't crash, but the combo box setting isn't shown in settings ui anymore.)
- Added Unix time in milliseconds, fixed negative unix time input and improved error messages in the TimeDate plugin. Thanks [@htcfreek](https://github.com/htcfreek)!
- The PowerToys plugin allows calling the new Environment Variables utility. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Refactored and added support to VSCodium Stable, VSCodium Insider and Remote Tunnels workspaces. Thanks [@eternalphane](https://github.com/eternalphane)!
### Quick Accent
- The "All languages" character set is now calculated by programmatically querying the characters for every available language. Thanks [@dannysummerlin](https://github.com/dannysummerlin)!
- Added é to the Norwegian and Swedish languages. Thanks [@Aaron-Junker](https://github.com/Aaron-Junker)!
- Added a runtime cache to the "All languages" character set, to only calculate accents once per key.
- Fixed characters that were removed from "All languages" because they were not in any single language. (This was a hotfix for 0.74)
- Added Asturian characters to the Spanish character set. Thanks [@blakestack](https://github.com/blakestack)!
- Added Greek characters with tonos. Thanks [@PesBandi](https://github.com/PesBandi)!
### Registry Preview
- Fixed focusing issues at startup.
- Improved the data visualization to show data in a similar way to the Windows Registry Editor. Thanks [@dillydylann](https://github.com/dillydylann)!
- Fixed a parsing error that crashed the Application. (This was a hotfix for 0.74)
- Fixed opening file names with non-ASCII characters. Thanks [@randyrants](https://github.com/randyrants)!
- Fixed wrong parsing when the file contained an assignment with spaces around the equals sign. Thanks [@randyrants](https://github.com/randyrants)!
- Fixed key transversal issues when a key was a substring of a parent key. Thanks [@randyrants](https://github.com/randyrants)!
### Runner
- Fixed hanging when a bug report was generated from the flyout. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Fixed the update notification toast to show a Unicode arrow. Thanks [@TheJoeFin](https://github.com/TheJoeFin)!
### Settings
- Improved the way the OOBE window reacts to Windows theme change.
- Fixed an issue that made it impossible to change the "Switch between windows in the current zone" "Next window" shortcut for FancyZones.
- Fixed a crash when entering a duplicate name for a color in the Color Picker page and improved clean up when cancelling a color edit. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Added a new Dashboard home page, with quick access for enabling modules, short descriptions and activation methods. Thanks [@niels9001](https://github.com/niels9001) for the design and UI work that made this possible!
- Fixed a typo in the Hosts File Editor page. Thanks [@Deepak-Sangle](https://github.com/Deepak-Sangle)!
- Added a lock icon to the flyout listing of all modules when its enabled state is controlled by policy.
- The "All apps" list in the flyout will now list all apps even if their enabled state is controlled by policy.
### Text Extractor
### Video Conference Mute
- Text Extractor 2.0, with a new overlay, table mode and more Quality of Life improvements. Thanks [@TheJoeFin](https://github.com/TheJoeFin)!
- Added an option to allow for the toolbar to hide after some time passed. Thanks [@quyenvsp](https://github.com/quyenvsp)!
- Added an option to select to mute or unmute at startup. Thanks [@quyenvsp](https://github.com/quyenvsp)!
- Fixed an issue causing a cascade of mute/unmute triggers.
### Documentation
- SECURITY.md was updated from 0.0.2 to 0.0.9. Thanks [@Aaron-Junker](https://github.com/Aaron-Junker)!
- Improved the README and main development document for clarity and completeness. Thanks [@codeofdusk](https://github.com/codeofdusk) and [@aprilbbrockhoeft](https://github.com/aprilbbrockhoeft)!
- Updated the Group Policy documentation on learn.microsoft.com, removed the Group Policy documentation from the repository and linked to the published documentation on learn.microsoft.com instead.
### Development
- Fixed PowerToys Run DateTime plugin tests that were failing depending on locale, so that they can be run correctly on all dev machines.
- Fixed PowerToys Run System plugin tests that were failing for certain network interfaces, so that they can be run correctly on all dev machines. Thanks [@snickler](https://github.com/snickler)!
- Fixed a markdown bug on the GitHub /helped command.
- Switched build pipelines to a new agent pool. Thanks [@DHowett](https://github.com/DHowett)!
- New .cs files created in Visual Studio get the header added automatically. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Added project dependencies to the version project and headers to avoid building errors. Thanks [@johnterickson](https://github.com/johnterickson)!
- Enabled Control Flow Guard in the C++ projects. Thanks [@DHowett](https://github.com/DHowett)!
- Switched the release pipeline to the 1ES governed template. Thanks [@DHowett](https://github.com/DHowett)!
- Styled XAML files and added a XAML Style checker to the solution, with a CI action to check if code being contributed is compliant. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Suppressed redundant midl file warnings in PowerRename.
- Add unit tests to FancyZones Editor. Thanks [@garv5014](https://github.com/garv5014), [@andrewbengordon](https://github.com/andrewbengordon) and [@Cwighty](https://github.com/Cwighty)!
- Improved the Default Layouts internal structure in FancyZones Editor. Thanks [@garv5014](https://github.com/garv5014)!
- Fixed code issues to allow building in Visual Studio 17.8 Preview 4.
#### What is being planned for version 0.75
#### What is being planned for version 0.76
For [v0.75][github-next-release-work], we'll work on the items below:
For [v0.76][github-next-release-work], we'll work on the items below:
- Language selection
- .NET 8 upgrade
- Policy support for managing PowerToys Run plugins.
*Attention*: A breaking change is planned (for 0.75), in which each plugin has to declare its identifier programmatically so that it can be controlled through GPO. For third-party plugin developers, please check https://github.com/microsoft/PowerToys/pull/27468 for more details.
- New utility: Environment Variables Editor. Here's a Work in Progress preview:
![Environment Variables Editor WIP](https://github.com/microsoft/PowerToys/assets/26118718/f99532a8-5aae-481b-a662-19a95f4aa03d)
- New Settings homepage. Here's a Work in Progress preview:
![PowerToys Settings Dashboard WIP](https://github.com/microsoft/PowerToys/assets/26118718/938a5715-0a9b-4fe9-9e15-adfec92da694)
- Allowing Keyboard Manager to output arbitrary Unicode sequences
- Automated UI testing through WinAppDriver
- Modernize and refresh the UX of PowerToys based on WPF. Here's Work in Progress previews for the modules "PowerToys Run" and "Color Picker":
![PowerToys Run UI refresh WIP](https://github.com/microsoft/PowerToys/assets/9866362/16903bcb-c18e-49fb-93ca-738b81957055)

View File

@@ -1,10 +1,7 @@
# Keyboard Manager UI
## Table of Contents:
1. [C++ XAML Islands](#c-xaml-islands)
1. [Debugging exceptions in XAML Islands](#debugging-exceptions-in-xaml-islands)
2. [Build times](#build-times)
3. [Setting custom backgrounds for Xaml Controls using brushes](#setting-custom-backgrounds-for-xaml-controls-using-brushes)
1. [XAML Implementation](#xaml-implementation)
2. [UI Structure](#ui-structure)
3. [EditKeyboardWindow / EditShortcutsWindow](#editkeyboardwindow--editshortcutswindow)
1. [OK and Cancel button](#ok-and-cancel-button)
@@ -17,28 +14,18 @@
2. [Single Key ComboBox Selection Handler](#single-key-combobox-selection-handler)
3. [Shortcut ComboBox Selection Handler](#shortcut-combobox-selection-handler)
## C++ XAML Islands
The KBM UI is implemented as a C++ XAML Island, but all the controls are implemented in code behind rather than .xaml and .xaml.cs files. This was done as per a XAML Island Code sample and it didn't require a separate UWP project, which could be limited in terms of using hooks. There is a [tech debt item](https://github.com/microsoft/PowerToys/issues/2027) for moving this to XAML. The reason it wasn't implemented in the C# Settings was because it required communication with the low level hook thread, which could be too slow if IPC is used, since the UI needs to update on every key event.
## XAML Implementation
The KBM UI was originally implemented as a XAML Island, but in order to easily support Mica, which is [still an issue](https://github.com/microsoft/microsoft-ui-xaml/issues/5319), the [`XamlBridge`](https://github.com/microsoft/PowerToys/blob/b3f27057d43445abc59aa04405f7c24bb895a61c/src/modules/keyboardmanager/KeyboardManagerEditorLibrary/XamlBridge2.cpp) was rewritten to use a [`FrameworkView`](https://github.com/microsoft/PowerToys/blob/b3f27057d43445abc59aa04405f7c24bb895a61c/src/modules/keyboardmanager/KeyboardManagerEditorLibrary/XamlBridge2.cpp#L47C11-L49) object which is how a traditional UWP app behaves:
1. A `CoreWindow` is created by [calling a function inside of `Windows.UI.dll` with an ordinal number of `1500`](https://github.com/microsoft/PowerToys/blob/b3f27057d43445abc59aa04405f7c24bb895a61c/src/modules/keyboardmanager/KeyboardManagerEditorLibrary/XamlBridge2.cpp#L35-L42).
2. A [stubbed implementation of `CoreApplicationView`](https://github.com/microsoft/PowerToys/blob/b3f27057d43445abc59aa04405f7c24bb895a61c/src/modules/keyboardmanager/KeyboardManagerEditorLibrary/XamlBridge2.cpp#L10-L18) was created.
3. Then [both objects are passed on to the `FrameworkView`](https://github.com/microsoft/PowerToys/blob/b3f27057d43445abc59aa04405f7c24bb895a61c/src/modules/keyboardmanager/KeyboardManagerEditorLibrary/XamlBridge2.cpp#L47-L49) to initialize the XAML framework.
4. Lastly, the `CoreWindow` is [attached to the editor window](https://github.com/microsoft/PowerToys/blob/b3f27057d43445abc59aa04405f7c24bb895a61c/src/modules/keyboardmanager/KeyboardManagerEditorLibrary/XamlBridge2.cpp#L54-L61) and its `HWND` is used in-place of `DesktopWindowXamlSource`'s.
**Note:** For functions which take a XAML component as argument, pass it by value and not by reference. This is because `winrt` WinUI classes store their own internal references, so they are supposed to be passed by value (and internally ref counts are incremented). Passing by reference can lead to weird behavior where the object is `null`.
Mica is then achieved by calling [`BackdropMaterial::SetApplyToRootOrPageBackground()`](https://github.com/microsoft/PowerToys/blob/b3f27057d43445abc59aa04405f7c24bb895a61c/src/modules/keyboardmanager/KeyboardManagerEditorLibrary/EditKeyboardWindow.cpp#L388-L400) in both of the editor windows, or falls back to the `ApplicationPageBackgroundThemeBrush` background if Mica isn't available.
The windows are [created as C++ windows](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp#L128-L140) and the window sizes are set to default by [scaling them as per DPI](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp#L120-L126) using the `DPIAware::Convert` API from common lib. Since the UI is launched on a new thread, the window may not be in the foreground, so [we call `SetForegroundWindow`](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp#L146-L150).
The UI was also updated to use WinUI 2.8 to match the look and feel of the Fluent design language of Windows 11 and the rest of PowerToys. There has been talk about [migrating the implementation to XAML files instead of code-behind](https://github.com/microsoft/PowerToys/issues/2027) and [utilizing WinUI 3 going forward](https://github.com/microsoft/PowerToys/issues/15870). More about the update can be read in [here](https://github.com/microsoft/PowerToys/pull/28473).
`DesktopWindowXamlSource` has to be declared and [it is initialized](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp#L159-L162) using the [`XamlBridge`](https://github.com/microsoft/PowerToys/blob/main/src/modules/keyboardmanager/ui/XamlBridge.cpp), and [a second window handle](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp#L161-L162) is generated for the internal Xaml Island window. Most of the code was based on the [Xaml Island Sample](https://github.com/microsoft/Xaml-Islands-Samples/blob/master/Samples/Win32/SampleCppApp/XamlBridge.cpp). The `XamlBridge` class contains code which handles initializing the Xaml Island containers as well as handling special messages like keyboard navigation, and focus between islands and between the C++ window and the island. It also has methods for clearing the xaml islands and closing the window.
Once the UI controls are created, the parent container is set as the content for the `DesktopWindowXamlSource` and the `XamlBridge.MessageLoop` is executed. Messages are processed by the C++ window handler like [`EditKeyboardWindowProc`](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp#L364-L404). The general structure we use for this is, for any `WM_PAINT` or `WM_SIZE` message we resize the Xaml Island window. For `WM_GETMINMAXINFO` we set minimum widths so that the window cannot be resized beyond a minimum height and width. This is done to prevent the WinUI elements from overlapping and getting cropped. If it is neither of these cases we send the message to the [`XamlBridge.MessageHandler`](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/XamlBridge.cpp#L291-L301) which handles Destroy, Activation and Focus. If `WM_NCDESTROY` is received when the `XamlBridge` is `nullptr`, the window thread is terminated.
**Note:** `ContentDialog` in Xaml Islands requires manually settings a `XamlRoot`. This can generally be done by passing the XamlRoot from a component in the main window, such as the button used to open the dialog ([`sender.as<Button>().XamlRoot()`](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/ShortcutControl.cpp#L31-L32)). [These docs]((https://learn.microsoft.com/uwp/api/windows.ui.xaml.controls.contentdialog#contentdialog-in-appwindow-or-xaml-islands)) have more details about this.
### Debugging exceptions in XAML Islands
Sometimes if an exception occurs in XAML Islands, the stack trace may not always point to the correct code causing the exception and instead it will point to the Xaml Island message loop. In these cases the output window in VS will generally show the correct exception.
### Build times
C++ Xaml Islands generally take several minutes to build because the `pch` which contains the WinUI headers takes longer to build and compiles to a file of several GBs. To minimize the build times, multi-processor compilation within the projects have been enabled (files are distributed for compilation to the processors), and references to the Xaml headers have been removed from the .h headers files as much as possible. Since several classes of ours had class members with UI controls like `StackPanel` (which requires definitions of the classes in order to compile), we worked around this by declaring them as `IInspectable` (the equivalent of an object pointer in winrt), and initializing them to the actual control like `StackPanel` in the constructor and accessing all their member functions by inline typecasting (for `IInspectable x;` we do `x = StackPanel();` and `x.as<StackPanel>().MemberFunction()`). Check [this](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/ShortcutControl.cpp#L19-L25) for this type of usage in `ShortcutControl`.
### Setting custom backgrounds for Xaml Controls using brushes
To access the brushes available on C# Xaml, it has to be done with the `Resources.Lookup` syntax:
`primaryButton.Background(Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundBaseMediumLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>());`
[**Link to the original documentation**](https://github.com/microsoft/PowerToys/blob/b3f27057d43445abc59aa04405f7c24bb895a61c/doc/devdocs/modules/keyboardmanager/keyboardmanagerui.md#c-xaml-islands)
## UI Structure
The KBM UI consists of a [`Grid` with several columns](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp#L200-L218). Rows are added dynamically when [the add button is pressed](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp#L305-L309). [A vector of vector of unique pointers to `SingleKeyRemapControl`/`ShortcutControl`](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp#L248-L249) is created so that references to the UI components and their data are not lost until the window is closed. [`SingleKeyRemapControl`](https://github.com/microsoft/PowerToys/blob/main/src/modules/keyboardmanager/ui/SingleKeyRemapControl.cpp) is the UI class for each row of the Remap keys table, and [`ShortcutControl`](https://github.com/microsoft/PowerToys/blob/main/src/modules/keyboardmanager/ui/ShortcutControl.cpp) is the UI class for each row of the Remap shortcuts table. [`KeyDropDownControl`](https://github.com/microsoft/PowerToys/blob/main/src/modules/keyboardmanager/ui/KeyDropDownControl.cpp) is used for handling the ComboBox operations. Each of these two classes [have vectors of unique pointers to the `KeyDropDownControl` objects](https://github.com/microsoft/PowerToys/blob/b80578b1b9a4b24c9945bddac33c771204280107/src/modules/keyboardmanager/ui/ShortcutControl.h#L44-L45) so that references to the objects are active until the control is deleted.

View File

@@ -1,6 +1,6 @@
# Developer Preview (Monaco)
Developer preview is based on [Microsofts Monaco Editor](https://microsoft.github.io/monaco-editor/) which is maintained by the Visual Studio Code team.
Developer preview is based on [Microsoft's Monaco Editor](https://microsoft.github.io/monaco-editor/) which is maintained by the Visual Studio Code team.
## Update monaco editor

View File

@@ -17,6 +17,14 @@
<RegistryValue Type="string" Name="Module_KeyboardManager_Editor" Value="" KeyPath="yes"/>
</RegistryKey>
<File Source="$(var.BinDir)KeyboardManagerEditor\PowerToys.KeyboardManagerEditor.exe" />
<File Source="$(var.BinDir)KeyboardManagerEditor\Microsoft.Toolkit.Win32.UI.XamlHost.dll" />
<File Source="$(var.BinDir)KeyboardManagerEditor\Microsoft.UI.Xaml.dll" />
<File Source="$(var.BinDir)KeyboardManagerEditor\msvcp140_app.dll" />
<File Source="$(var.BinDir)KeyboardManagerEditor\resources.pri" />
<File Source="$(var.BinDir)KeyboardManagerEditor\vcruntime140_app.dll" />
<?if $(sys.BUILDARCH) = x64 ?>
<File Source="$(var.BinDir)KeyboardManagerEditor\vcruntime140_1_app.dll" />
<?endif ?>
</Component>
</DirectoryRef>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" >
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<?include $(sys.CURRENTDIR)\Common.wxi?>
@@ -12,8 +12,8 @@
<Directory Id="PowerRenameAssetsFolder" Name="PowerRename" />
</DirectoryRef>
<DirectoryRef Id="PowerRenameAssetsFolder" FileSource="$(var.PowerRenameAssetsFilesPath)">
<!-- Generated by generateFileComponents.ps1 -->
<!--PowerRenameAssetsFiles_Component_Def-->
<!-- Generated by generateFileComponents.ps1 -->
<!--PowerRenameAssetsFiles_Component_Def-->
<!-- !Warning! Make sure to change Component Guid if you update something here -->
<Component Id="Module_PowerRename" Guid="40D43079-240E-402D-8CE8-571BFFA71175" Win64="yes">
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\CLSID\{0440049F-D1DC-4E46-B27B-98393D79486B}">
@@ -30,16 +30,37 @@
</RegistryKey>
</Component>
<Component Id="Module_PowerRename_HKLM_Override" Guid="4910240F-1068-4172-8823-7EA4A197A3A3" Win64="yes">
<Condition>WixBundleElevated = 1</Condition>
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="Module_PowerRename_HKLM_Override" Value="" KeyPath="yes"/>
</RegistryKey>
<RegistryKey Root="HKLM" Key="Software\Classes\CLSID\{0440049F-D1DC-4E46-B27B-98393D79486B}">
<RegistryValue Type="string" Value="PowerRename Shell Extension" />
<RegistryValue Type="string" Name="ContextMenuOptIn" Value="" />
<RegistryValue Type="string" Key="InprocServer32" Value="[WinUI3AppsInstallFolder]PowerToys.PowerRenameExt.dll" />
<RegistryValue Type="string" Key="InprocServer32" Name="ThreadingModel" Value="Apartment" />
</RegistryKey>
<RegistryKey Root="HKLM" Key="SOFTWARE\Classes\AllFileSystemObjects\ShellEx\ContextMenuHandlers\PowerRenameExt">
<RegistryValue Type="string" Value="{0440049F-D1DC-4E46-B27B-98393D79486B}"/>
</RegistryKey>
<RegistryKey Root="HKLM" Key="SOFTWARE\Classes\Directory\background\ShellEx\ContextMenuHandlers\PowerRenameExt">
<RegistryValue Type="string" Value="{0440049F-D1DC-4E46-B27B-98393D79486B}"/>
</RegistryKey>
</Component>
</DirectoryRef>
<ComponentGroup Id="PowerRenameComponentGroup">
<Component Id="RemovePowerRenameFolder" Guid="2028549B-02E3-4D80-BC3F-59AEA37AC73D" Directory="PowerRenameAssetsFolder" >
<Component Id="RemovePowerRenameFolder" Guid="2028549B-02E3-4D80-BC3F-59AEA37AC73D" Directory="PowerRenameAssetsFolder">
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="RemovePowerRenameFolder" Value="" KeyPath="yes"/>
</RegistryKey>
<RemoveFolder Id="RemoveFolderPowerRenameAssetsFolder" Directory="PowerRenameAssetsFolder" On="uninstall"/>
</Component>
<ComponentRef Id="Module_PowerRename" />
<ComponentRef Id="Module_PowerRename_HKLM_Override" />
</ComponentGroup>
</Fragment>

View File

@@ -24,7 +24,7 @@ namespace Microsoft.VariantAssignment.Contract
public bool EnableCaching { get; set; }
/// <summary>
/// Gets or sets the the maximum time a cached variant assignment response may be used without re-validating.
/// Gets or sets the maximum time a cached variant assignment response may be used without re-validating.
/// </summary>
public TimeSpan ResponseCacheTime { get; set; }
}

View File

@@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace ManagedCommon
{
public enum ModuleType
{
AlwaysOnTop,
Awake,
ColorPicker,
CropAndLock,
EnvironmentVariables,
FancyZones,
FileLocksmith,
FindMyMouse,
Hosts,
ImageResizer,
KeyboardManager,
MouseHighlighter,
MouseJump,
MousePointerCrosshairs,
MouseWithoutBorders,
PastePlain,
Peek,
PowerRename,
PowerLauncher,
PowerAccent,
RegistryPreview,
MeasureTool,
ShortcutGuide,
PowerOCR,
}
}

View File

@@ -49,6 +49,9 @@ namespace Microsoft.Interop.Tests
serverPipe.Start();
ClientPipe.Start();
// Test can be flaky as the pipes are still being set up and we end up receiving no message. Wait for a bit to avoid that.
Thread.Sleep(100);
ClientPipe.Send(testString);
reset.WaitOne();

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->
<policyDefinitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.4" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyDefinitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.5" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyNamespaces>
<target prefix="powertoys" namespace="Microsoft.Policies.PowerToys" />
</policyNamespaces>
<resources minRequiredRevision="1.4"/><!-- Last changed with PowerToys v0.75.0 -->
<resources minRequiredRevision="1.5"/><!-- Last changed with PowerToys v0.75.1 -->
<supportedOn>
<definitions>
<definition name="SUPPORTED_POWERTOYS_0_64_0" displayName="$(string.SUPPORTED_POWERTOYS_0_64_0)"/>
@@ -78,6 +78,16 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="ConfigureEnabledUtilityEnvironmentVariables" class="Both" displayName="$(string.ConfigureEnabledUtilityEnvironmentVariables)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityEnvironmentVariables">
<parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_75_0" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="ConfigureEnabledUtilityFancyZones" class="Both" displayName="$(string.ConfigureEnabledUtilityFancyZones)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFancyZones">
<parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_64_0" />

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->
<policyDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.4" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.5" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<displayName>PowerToys</displayName>
<description>PowerToys</description>
<resources>
@@ -112,6 +112,7 @@ Note: Changes require a restart of PowerToys Run.
<string id="ConfigureEnabledUtilityAwake">Awake: Configure enabled state</string>
<string id="ConfigureEnabledUtilityColorPicker">Color Picker: Configure enabled state</string>
<string id="ConfigureEnabledUtilityCropAndLock">Crop And Lock: Configure enabled state</string>
<string id="ConfigureEnabledUtilityEnvironmentVariables">Environment Variables: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFancyZones">FancyZones: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFileLocksmith">File Locksmith: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFileExplorerSVGPreview">SVG file preview: Configure enabled state</string>

View File

@@ -87,12 +87,29 @@ void ReparentCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
DisconnectTarget();
m_currentTarget = windowToCrop;
// Adjust the crop rect to be in the window space as reported by win32k
// Save original state
SaveOriginalState();
RECT windowRect = {};
winrt::check_bool(GetWindowRect(m_currentTarget, &windowRect));
auto clientRect = ClientAreaInScreenSpace(m_currentTarget);
WINDOWPLACEMENT windowPlacement = { sizeof(windowPlacement) };
winrt::check_bool(GetWindowPlacement(m_currentTarget, &windowPlacement));
bool isMaximized = (windowPlacement.showCmd == SW_SHOWMAXIMIZED);
auto diffX = clientRect.left - windowRect.left;
auto diffY = clientRect.top - windowRect.top;
if (isMaximized)
{
MONITORINFO mi = { sizeof(mi) };
winrt::check_bool(GetMonitorInfo(MonitorFromWindow(m_currentTarget, MONITOR_DEFAULTTONEAREST), &mi));
diffX = mi.rcWork.left - windowRect.left;
diffY = mi.rcWork.top - windowRect.top;
}
auto adjustedCropRect = cropRect;
adjustedCropRect.left += diffX;
adjustedCropRect.top += diffY;
@@ -100,8 +117,6 @@ void ReparentCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
adjustedCropRect.bottom += diffY;
cropRect = adjustedCropRect;
// Save the previous position of the target so that we can restore it.
m_previousPosition = { windowRect.left, windowRect.top };
auto newX = adjustedCropRect.left + windowRect.left;
auto newY = adjustedCropRect.top + windowRect.top;
@@ -152,12 +167,54 @@ void ReparentCropAndLockWindow::DisconnectTarget()
// The child window was closed by other means?
m_currentTarget = nullptr;
return;
}
winrt::check_bool(SetWindowPos(m_currentTarget, nullptr, m_previousPosition.x, m_previousPosition.y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_FRAMECHANGED));
SetParent(m_currentTarget, nullptr);
auto targetStyle = static_cast<DWORD>(GetWindowLongPtrW(m_currentTarget, GWL_STYLE));
targetStyle &= ~WS_CHILD;
SetWindowLongPtrW(m_currentTarget, GWL_STYLE, targetStyle);
m_currentTarget = nullptr;
}
RestoreOriginalState();
}
}
void ReparentCropAndLockWindow::SaveOriginalState()
{
if (m_currentTarget != nullptr)
{
originalPlacement.length = sizeof(WINDOWPLACEMENT);
winrt::check_bool(GetWindowPlacement(m_currentTarget, &originalPlacement));
originalExStyle = GetWindowLongPtr(m_currentTarget, GWL_EXSTYLE);
winrt::check_bool(originalExStyle != 0 || GetLastError() == ERROR_SUCCESS);
originalStyle = GetWindowLongPtr(m_currentTarget, GWL_STYLE);
winrt::check_bool(originalStyle != 0 || GetLastError() == ERROR_SUCCESS);
winrt::check_bool(GetWindowRect(m_currentTarget, &originalRect));
}
}
void ReparentCropAndLockWindow::RestoreOriginalState()
{
if (m_currentTarget)
{
// Restore window position and dimensions
int width = originalRect.right - originalRect.left;
int height = originalRect.bottom - originalRect.top;
winrt::check_bool(SetWindowPos(m_currentTarget, nullptr, originalRect.left, originalRect.top, width, height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED));
SetParent(m_currentTarget, nullptr);
// Restore the original placement
if (originalPlacement.showCmd != SW_SHOWMAXIMIZED)
{
originalPlacement.showCmd = SW_RESTORE;
}
winrt::check_bool(SetWindowPlacement(m_currentTarget, &originalPlacement));
// Set the original extended style and style
originalStyle &= ~WS_CHILD;
LONG_PTR prevExStyle = SetWindowLongPtr(m_currentTarget, GWL_EXSTYLE, originalExStyle);
winrt::check_bool(prevExStyle != 0 || GetLastError() == ERROR_SUCCESS);
LONG_PTR prevStyle = SetWindowLongPtr(m_currentTarget, GWL_STYLE, originalStyle);
winrt::check_bool(prevStyle != 0 || GetLastError() == ERROR_SUCCESS);
}
}

View File

@@ -19,11 +19,17 @@ private:
void Hide();
void DisconnectTarget();
void SaveOriginalState();
void RestoreOriginalState();
private:
HWND m_currentTarget = nullptr;
POINT m_previousPosition = {};
std::unique_ptr<ChildWindow> m_childWindow;
bool m_destroyed = false;
std::function<void(HWND)> m_closedCallback;
LONG_PTR originalExStyle = 0;
LONG_PTR originalStyle = 0;
WINDOWPLACEMENT originalPlacement = { sizeof(WINDOWPLACEMENT) };
RECT originalRect = {};
};

View File

@@ -12,21 +12,66 @@
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<SolidColorBrush x:Key="SubtleButtonBackground" Color="{ThemeResource SubtleFillColorTransparent}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundPointerOver" Color="{ThemeResource SubtleFillColorSecondary}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundPressed" Color="{ThemeResource SubtleFillColorTertiary}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundDisabled" Color="{ThemeResource ControlFillColorDisabled}" />
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SubtleFillColorTransparent" />
<SolidColorBrush x:Key="SubtleButtonForeground" Color="{ThemeResource TextFillColorPrimary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundPointerOver" Color="{ThemeResource TextFillColorPrimary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundPressed" Color="{ThemeResource TextFillColorSecondary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundDisabled" Color="{ThemeResource TextFillColorDisabled}" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="TextFillColorSecondary" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="TextFillColorDisabled" />
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="TextFillColorSecondary" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="TextFillColorDisabled" />
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SystemColorHighlightTextColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SystemControlBackgroundBaseLowBrush" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SystemColorGrayTextColor" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="SystemColorButtonTextColorBrush" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<Style x:Key="SubtleButtonStyle" TargetType="Button">
<Setter Property="Background" Value="{ThemeResource SubtleButtonBackground}" />
<Setter Property="BackgroundSizing" Value="InnerBorderEdge" />
<Setter Property="Foreground" Value="{ThemeResource SubtleButtonForeground}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BorderBrush" Value="{ThemeResource SubtleButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}" />
<Setter Property="Padding" Value="{StaticResource ButtonPadding}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
@@ -53,11 +98,11 @@
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
CornerRadius="{TemplateBinding CornerRadius}">
CornerRadius="{TemplateBinding CornerRadius}"
Foreground="{TemplateBinding Foreground}">
<ContentPresenter.BackgroundTransition>
<BrushTransition Duration="0:0:0.083" />
</ContentPresenter.BackgroundTransition>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
@@ -66,6 +111,9 @@
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
@@ -74,12 +122,14 @@
<Setter Target="ContentPresenter.(AnimatedIcon.State)" Value="PointerOver" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundPressed}" />
</ObjectAnimationUsingKeyFrames>
@@ -88,12 +138,14 @@
<Setter Target="ContentPresenter.(AnimatedIcon.State)" Value="Pressed" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>

View File

@@ -635,7 +635,8 @@
<Flyout
x:Name="AddVariableFlyout"
Closed="AddVariableFlyout_Closed"
Placement="Right">
Placement="Right"
ShouldConstrainToRootBounds="False">
<Grid Width="320" Height="480">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />

View File

@@ -10,24 +10,67 @@
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<SolidColorBrush x:Key="SubtleButtonBackground" Color="{ThemeResource SubtleFillColorTransparent}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundPointerOver" Color="{ThemeResource SubtleFillColorSecondary}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundPressed" Color="{ThemeResource SubtleFillColorTertiary}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundDisabled" Color="{ThemeResource SubtleFillColorTransparent}" />
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SubtleFillColorTransparent" />
<SolidColorBrush x:Key="SubtleButtonForeground" Color="{ThemeResource TextFillColorPrimary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundPointerOver" Color="{ThemeResource TextFillColorPrimary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundPressed" Color="{ThemeResource TextFillColorSecondary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundDisabled" Color="{ThemeResource TextFillColorDisabled}" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="TextFillColorSecondary" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="TextFillColorDisabled" />
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="TextFillColorSecondary" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="TextFillColorDisabled" />
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SystemColorHighlightTextColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SystemControlBackgroundBaseLowBrush" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SystemColorGrayTextColor" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="SystemColorButtonTextColorBrush" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<Style x:Key="SubtleButtonStyle" TargetType="Button">
<Setter Property="Background" Value="{ThemeResource SubtleButtonBackground}" />
<Setter Property="BackgroundSizing" Value="InnerBorderEdge" />
<Setter Property="Foreground" Value="{ThemeResource SubtleButtonForeground}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Width" Value="36" />
<Setter Property="Padding" Value="0" />
<Setter Property="Height" Value="36" />
<Setter Property="BorderBrush" Value="{ThemeResource SubtleButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}" />
<Setter Property="Padding" Value="{StaticResource ButtonPadding}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
@@ -53,11 +96,11 @@
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
CornerRadius="{TemplateBinding CornerRadius}">
CornerRadius="{TemplateBinding CornerRadius}"
Foreground="{TemplateBinding Foreground}">
<ContentPresenter.BackgroundTransition>
<BrushTransition Duration="0:0:0.083" />
</ContentPresenter.BackgroundTransition>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
@@ -66,6 +109,9 @@
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
@@ -74,12 +120,14 @@
<Setter Target="ContentPresenter.(AnimatedIcon.State)" Value="PointerOver" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundPressed}" />
</ObjectAnimationUsingKeyFrames>
@@ -88,12 +136,14 @@
<Setter Target="ContentPresenter.(AnimatedIcon.State)" Value="Pressed" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
@@ -110,7 +160,6 @@
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@@ -5,6 +5,7 @@
using System.IO.Abstractions.TestingHelpers;
using System.Linq;
using System.Threading.Tasks;
using Hosts.Exceptions;
using Hosts.Helpers;
using Hosts.Models;
using Hosts.Settings;
@@ -18,11 +19,13 @@ namespace Hosts.Tests
[TestClass]
public class HostsServiceTest
{
private static Mock<IUserSettings> _userSettings;
private static Mock<IElevationHelper> _elevationHelper;
[ClassInitialize]
public static void ClassInitialize(TestContext context)
{
_userSettings = new Mock<IUserSettings>();
_elevationHelper = new Mock<IElevationHelper>();
_elevationHelper.Setup(m => m.IsElevated).Returns(true);
}
@@ -31,8 +34,7 @@ namespace Hosts.Tests
public void Hosts_Exists()
{
var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>();
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
var service = new HostsService(fileSystem, _userSettings.Object, _elevationHelper.Object);
fileSystem.AddFile(service.HostsFilePath, new MockFileData(string.Empty));
var result = service.Exists();
@@ -43,8 +45,7 @@ namespace Hosts.Tests
public void Hosts_Not_Exists()
{
var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>();
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
var service = new HostsService(fileSystem, _userSettings.Object, _elevationHelper.Object);
var result = service.Exists();
Assert.IsFalse(result);
@@ -65,8 +66,7 @@ namespace Hosts.Tests
";
var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>();
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
var service = new HostsService(fileSystem, _userSettings.Object, _elevationHelper.Object);
fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
var data = await service.ReadAsync();
@@ -91,8 +91,7 @@ namespace Hosts.Tests
";
var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>();
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
var service = new HostsService(fileSystem, _userSettings.Object, _elevationHelper.Object);
fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
var data = await service.ReadAsync();
@@ -118,8 +117,7 @@ namespace Hosts.Tests
";
var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>();
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
var service = new HostsService(fileSystem, _userSettings.Object, _elevationHelper.Object);
fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
var data = await service.ReadAsync();
@@ -138,9 +136,7 @@ namespace Hosts.Tests
public async Task Empty_Hosts()
{
var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>();
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
var service = new HostsService(fileSystem, _userSettings.Object, _elevationHelper.Object);
fileSystem.AddFile(service.HostsFilePath, new MockFileData(string.Empty));
await service.WriteAsync(string.Empty, Enumerable.Empty<Entry>());
@@ -203,7 +199,6 @@ namespace Hosts.Tests
var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>();
userSettings.Setup(m => m.AdditionalLinesPosition).Returns(HostsAdditionalLinesPosition.Bottom);
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
@@ -228,8 +223,7 @@ namespace Hosts.Tests
";
var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>();
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
var service = new HostsService(fileSystem, _userSettings.Object, _elevationHelper.Object);
fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
var data = await service.ReadAsync();
@@ -243,12 +237,37 @@ namespace Hosts.Tests
public async Task Save_NotRunningElevatedException()
{
var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>();
var elevationHelper = new Mock<IElevationHelper>();
elevationHelper.Setup(m => m.IsElevated).Returns(false);
var service = new HostsService(fileSystem, userSettings.Object, elevationHelper.Object);
var service = new HostsService(fileSystem, _userSettings.Object, elevationHelper.Object);
await Assert.ThrowsExceptionAsync<NotRunningElevatedException>(async () => await service.WriteAsync("# Empty hosts file", Enumerable.Empty<Entry>()));
}
[TestMethod]
public async Task Save_ReadOnlyHostsException()
{
var fileSystem = new CustomMockFileSystem();
var service = new HostsService(fileSystem, _userSettings.Object, _elevationHelper.Object);
var hostsFile = new MockFileData(string.Empty);
hostsFile.Attributes = System.IO.FileAttributes.ReadOnly;
fileSystem.AddFile(service.HostsFilePath, hostsFile);
await Assert.ThrowsExceptionAsync<ReadOnlyHostsException>(async () => await service.WriteAsync("# Empty hosts file", Enumerable.Empty<Entry>()));
}
[TestMethod]
public void Remove_ReadOnly()
{
var fileSystem = new CustomMockFileSystem();
var service = new HostsService(fileSystem, _userSettings.Object, _elevationHelper.Object);
var hostsFile = new MockFileData(string.Empty);
hostsFile.Attributes = System.IO.FileAttributes.ReadOnly;
fileSystem.AddFile(service.HostsFilePath, hostsFile);
service.RemoveReadOnly();
var readOnly = fileSystem.FileInfo.FromFileName(service.HostsFilePath).Attributes.HasFlag(System.IO.FileAttributes.ReadOnly);
Assert.IsFalse(readOnly);
}
}
}

View File

@@ -4,7 +4,7 @@
using System;
namespace Hosts.Helpers
namespace Hosts.Exceptions
{
public class NotRunningElevatedException : Exception
{

View File

@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Hosts.Exceptions
{
public class ReadOnlyHostsException : Exception
{
}
}

View File

@@ -13,6 +13,7 @@ using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Hosts.Exceptions;
using Hosts.Models;
using Hosts.Settings;
using ManagedCommon;
@@ -129,6 +130,11 @@ namespace Hosts.Helpers
throw new NotRunningElevatedException();
}
if (_fileSystem.FileInfo.FromFileName(HostsFilePath).IsReadOnly)
{
throw new ReadOnlyHostsException();
}
var lines = new List<string>();
if (entries.Any())
@@ -288,6 +294,15 @@ namespace Hosts.Helpers
}
}
public void RemoveReadOnly()
{
var fileInfo = _fileSystem.FileInfo.FromFileName(HostsFilePath);
if (fileInfo.IsReadOnly)
{
fileInfo.IsReadOnly = false;
}
}
public void Dispose()
{
Dispose(disposing: true);

View File

@@ -24,5 +24,7 @@ namespace Hosts.Helpers
void CleanupBackup();
void OpenHostsFile();
void RemoveReadOnly();
}
}

View File

@@ -11,24 +11,66 @@
</ResourceDictionary.MergedDictionaries>
<SolidColorBrush x:Key="SubtleButtonBackground" Color="{ThemeResource SubtleFillColorTransparent}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundPointerOver" Color="{ThemeResource SubtleFillColorSecondary}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundPressed" Color="{ThemeResource SubtleFillColorTertiary}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundDisabled" Color="{ThemeResource ControlFillColorDisabled}" />
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SubtleFillColorTransparent" />
<SolidColorBrush x:Key="SubtleButtonForeground" Color="{ThemeResource TextFillColorPrimary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundPointerOver" Color="{ThemeResource TextFillColorPrimary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundPressed" Color="{ThemeResource TextFillColorSecondary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundDisabled" Color="{ThemeResource TextFillColorDisabled}" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SubtleFillColorTransparent" />
<SolidColorBrush x:Key="WindowCaptionBackground">Transparent</SolidColorBrush>
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled">Transparent</SolidColorBrush>
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="TextFillColorSecondary" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="TextFillColorDisabled" />
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="TextFillColorSecondary" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="TextFillColorDisabled" />
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SystemColorHighlightTextColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SystemControlBackgroundBaseLowBrush" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SystemColorGrayTextColor" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="SystemColorButtonTextColorBrush" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<Style x:Key="SubtleButtonStyle" TargetType="Button">
<Setter Property="Background" Value="{ThemeResource SubtleButtonBackground}" />
<Setter Property="BackgroundSizing" Value="InnerBorderEdge" />
<Setter Property="Foreground" Value="{ThemeResource SubtleButtonForeground}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BorderBrush" Value="{ThemeResource SubtleButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}" />
<Setter Property="Padding" Value="{StaticResource ButtonPadding}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
@@ -55,11 +97,11 @@
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
CornerRadius="{TemplateBinding CornerRadius}">
CornerRadius="{TemplateBinding CornerRadius}"
Foreground="{TemplateBinding Foreground}">
<ContentPresenter.BackgroundTransition>
<BrushTransition Duration="0:0:0.083" />
</ContentPresenter.BackgroundTransition>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
@@ -68,6 +110,9 @@
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
@@ -76,12 +121,14 @@
<Setter Target="ContentPresenter.(AnimatedIcon.State)" Value="PointerOver" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundPressed}" />
</ObjectAnimationUsingKeyFrames>
@@ -90,12 +137,14 @@
<Setter Target="ContentPresenter.(AnimatedIcon.State)" Value="Pressed" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>

View File

@@ -80,7 +80,7 @@
FontSize=16}"
Style="{StaticResource SubtleButtonStyle}">
<Button.Flyout>
<Flyout>
<Flyout ShouldConstrainToRootBounds="False">
<StackPanel
Width="320"
HorizontalAlignment="Stretch"
@@ -377,7 +377,15 @@
IsOpen="{x:Bind ViewModel.Error, Mode=TwoWay}"
Message="{x:Bind ViewModel.ErrorMessage, Mode=TwoWay}"
Severity="Error"
Visibility="{x:Bind ViewModel.Error, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind ViewModel.Error, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}">
<InfoBar.ActionButton>
<Button
x:Uid="MakeWritable"
HorizontalAlignment="Right"
Command="{x:Bind ViewModel.OverwriteHostsCommand}"
Visibility="{x:Bind ViewModel.IsReadOnly, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}" />
</InfoBar.ActionButton>
</InfoBar>
<InfoBar
x:Uid="FileChanged"
Margin="0,8,0,0"
@@ -385,7 +393,10 @@
Severity="Informational"
Visibility="{x:Bind ViewModel.FileChanged, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}">
<InfoBar.ActionButton>
<Button x:Uid="Reload" Command="{x:Bind ViewModel.ReadHostsCommand}" />
<Button
x:Uid="Reload"
HorizontalAlignment="Right"
Command="{x:Bind ViewModel.ReadHostsCommand}" />
</InfoBar.ActionButton>
</InfoBar>
</StackPanel>

View File

@@ -228,6 +228,10 @@
<value>The hosts file cannot be saved because the program isn't running as administrator.</value>
<comment>"Hosts" refers to the system hosts file, do not loc</comment>
</data>
<data name="FileSaveError_ReadOnly" xml:space="preserve">
<value>The hosts file cannot be saved because it is read-only.</value>
<comment>"Hosts" refers to the system hosts file, do not loc</comment>
</data>
<data name="FilterBtn.[using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Filters</value>
</data>
@@ -246,6 +250,9 @@
<value>Hosts</value>
<comment>"Hosts" refers to the system hosts file, do not loc</comment>
</data>
<data name="MakeWritable.Content" xml:space="preserve">
<value>Make writable</value>
</data>
<data name="MoveDown.Text" xml:space="preserve">
<value>Move down</value>
</data>

View File

@@ -15,6 +15,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.WinUI;
using CommunityToolkit.WinUI.Collections;
using Hosts.Exceptions;
using Hosts.Helpers;
using Hosts.Models;
using Hosts.Settings;
@@ -48,6 +49,9 @@ namespace Hosts.ViewModels
[ObservableProperty]
private string _errorMessage;
[ObservableProperty]
private bool _isReadOnly;
[ObservableProperty]
private bool _fileChanged;
@@ -262,6 +266,13 @@ namespace Hosts.ViewModels
_hostsService.OpenHostsFile();
}
[RelayCommand]
public void OverwriteHosts()
{
_hostsService.RemoveReadOnly();
_ = Task.Run(SaveAsync);
}
public void Dispose()
{
Dispose(disposing: true);
@@ -374,6 +385,7 @@ namespace Hosts.ViewModels
{
bool error = true;
string errorMessage = string.Empty;
bool isReadOnly = false;
try
{
@@ -385,6 +397,12 @@ namespace Hosts.ViewModels
var resourceLoader = ResourceLoaderInstance.ResourceLoader;
errorMessage = resourceLoader.GetString("FileSaveError_NotElevated");
}
catch (ReadOnlyHostsException)
{
isReadOnly = true;
var resourceLoader = ResourceLoaderInstance.ResourceLoader;
errorMessage = resourceLoader.GetString("FileSaveError_ReadOnly");
}
catch (IOException ex) when ((ex.HResult & 0x0000FFFF) == 32)
{
// There are some edge cases where a big hosts file is being locked by svchost.exe https://github.com/microsoft/PowerToys/issues/28066
@@ -402,6 +420,7 @@ namespace Hosts.ViewModels
{
Error = error;
ErrorMessage = errorMessage;
IsReadOnly = isReadOnly;
});
}

View File

@@ -394,6 +394,15 @@ void FancyZones::WindowCreated(HWND window) noexcept
return;
}
// Hotfix
// Avoid automatically moving popup windows, as they can be just popup menus.
bool isPopup = FancyZonesWindowUtils::IsPopupWindow(window);
bool hasThickFrame = FancyZonesWindowUtils::HasThickFrame(window);
if (isPopup && !hasThickFrame)
{
return;
}
// Avoid already stamped (zoned) windows
const bool isZoned = !FancyZonesWindowProperties::RetrieveZoneIndexProperty(window).empty();
if (isZoned)

View File

@@ -27,9 +27,8 @@ bool FancyZonesWindowProcessing::IsProcessable(HWND window) noexcept
// popup could be the window we don't want to snap: start menu, notification popup, tray window, etc.
// also, popup could be the windows we want to snap disregarding the "allowSnapPopupWindows" setting, e.g. Telegram
bool isPopup = FancyZonesWindowUtils::IsPopupWindow(window);
bool hasThickFrame = FancyZonesWindowUtils::HasThickFrame(window);
if (isPopup && (!hasThickFrame || !FancyZonesSettings::settings().allowSnapPopupWindows))
bool isPopup = FancyZonesWindowUtils::IsPopupWindow(window) && !FancyZonesWindowUtils::HasThickFrameAndMinimizeMaximizeButtons(window);
if (isPopup && !FancyZonesSettings::settings().allowSnapPopupWindows)
{
return false;
}

View File

@@ -1,4 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(SolutionDir)tools\build\convert-resx-to-rc.ps1 ..\dll resource.base.h resource.h KeyboardManager.base.rc KeyboardManager.rc" />
</Target>

View File

@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Project configurations -->
<Import Project="..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props" Condition="Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props')" />
<Import Project="..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props" Condition="Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup>
<NoWarn>81010002</NoWarn>
@@ -98,7 +100,7 @@
<AdditionalIncludeDirectories>./;$(SolutionDir)src\modules\;$(SolutionDir)src\modules\KeyboardManager\KeyboardManagerEditorLibrary\;$(SolutionDir)src\common\Display;$(SolutionDir)src\common\inc;$(SolutionDir)src\common\Telemetry;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>Display.lib;shcore.lib;Dbghelp.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Display.lib;shcore.lib;Dbghelp.lib;dwmapi.lib;uxtheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(ConfigurationName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
@@ -109,7 +111,7 @@
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>Display.lib;shcore.lib;Dbghelp.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Display.lib;shcore.lib;Dbghelp.lib;dwmapi.lib;uxtheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(ConfigurationName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
@@ -160,6 +162,10 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.VCRTForwarders.140.1.0.7\build\native\Microsoft.VCRTForwarders.140.targets" Condition="Exists('..\..\..\..\packages\Microsoft.VCRTForwarders.140.1.0.7\build\native\Microsoft.VCRTForwarders.140.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2088.41\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2088.41\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" />
</ImportGroup>
<Import Project="..\..\..\..\deps\spdlog.props" />
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
@@ -171,5 +177,15 @@
</PropertyGroup>
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VCRTForwarders.140.1.0.7\build\native\Microsoft.VCRTForwarders.140.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.VCRTForwarders.140.1.0.7\build\native\Microsoft.VCRTForwarders.140.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2088.41\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2088.41\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets'))" />
</Target>
<Target Name="FakeResourcesPriMerge" BeforeTargets="FinalizeBuildStatus" DependsOnTargets="CopyFilesToOutputDirectory">
<Message Text="Renaming Microsoft.UI.Xaml.pri to resources.pri" />
<Move SourceFiles="$(OutDir)\Microsoft.UI.Xaml.pri" DestinationFiles="$(OutDir)\resources.pri" />
</Target>
</Project>

View File

@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Toolkit.Win32.UI.XamlApplication" version="6.1.3" targetFramework="native" />
<package id="Microsoft.UI.Xaml" version="2.8.2-prerelease.220830001" targetFramework="native" />
<package id="Microsoft.VCRTForwarders.140" version="1.0.7" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.2088.41" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.221104.6" targetFramework="native" />
</packages>

View File

@@ -15,7 +15,7 @@
#include "EditKeyboardWindow.h"
#include "SingleKeyRemapControl.h"
#include "KeyDropDownControl.h"
#include "XamlBridge.h"
#include "XamlBridge2.h"
#include "Styles.h"
#include "Dialog.h"
#include "LoadingAndSavingRemappingHelper.h"
@@ -41,12 +41,12 @@ HWND hwndEditKeyboardNativeWindow = nullptr;
std::mutex editKeyboardWindowMutex;
// Stores a pointer to the Xaml Bridge object so that it can be accessed from the window procedure
static XamlBridge* xamlBridgePtr = nullptr;
static XamlBridge2* xamlBridgePtr = nullptr;
// Theming
ThemeListener theme_listener{};
static ThemeListener theme_listener{};
void handleTheme()
static void handleTheme()
{
auto theme = theme_listener.AppTheme;
auto isDark = theme == AppTheme::Dark;
@@ -137,7 +137,7 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
windowClass.lpfnWndProc = EditKeyboardWindowProc;
windowClass.hInstance = hInst;
windowClass.lpszClassName = szWindowClass;
windowClass.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW);
windowClass.hbrBackground = CreateSolidBrush((ThemeHelpers::GetAppTheme() == AppTheme::Dark) ? 0x00000000 : 0x00FFFFFF);
windowClass.hIcon = static_cast<HICON>(LoadImageW(
windowClass.hInstance,
MAKEINTRESOURCE(IDS_KEYBOARDMANAGER_ICON),
@@ -196,17 +196,19 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
hwndEditKeyboardNativeWindow = _hWndEditKeyboardWindow;
hwndLock.unlock();
// Hide icon and caption from title bar
const DWORD windowThemeOptionsMask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;
WTA_OPTIONS windowThemeOptions{ windowThemeOptionsMask, windowThemeOptionsMask };
SetWindowThemeAttribute(_hWndEditKeyboardWindow, WTA_NONCLIENT, &windowThemeOptions, sizeof(windowThemeOptions));
handleTheme();
theme_listener.AddChangedHandler(handleTheme);
// Create the xaml bridge object
XamlBridge xamlBridge(_hWndEditKeyboardWindow);
// DesktopSource needs to be declared before the RelativePanel xamlContainer object to avoid errors
winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource desktopSource;
XamlBridge2 xamlBridge(_hWndEditKeyboardWindow);
// Create the desktop window xaml source object and set its content
hWndXamlIslandEditKeyboardWindow = xamlBridge.InitDesktopWindowsXamlSource(desktopSource);
hWndXamlIslandEditKeyboardWindow = xamlBridge.InitBridge();
// Set the pointer to the xaml bridge object
xamlBridgePtr = &xamlBridge;
@@ -322,11 +324,8 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
// Add remap key button
Windows::UI::Xaml::Controls::Button addRemapKey;
FontIcon plusSymbol;
plusSymbol.FontFamily(Media::FontFamily(L"Segoe MDL2 Assets"));
plusSymbol.Glyph(L"\xE710");
addRemapKey.Content(plusSymbol);
addRemapKey.Margin({ 10, 10, 0, 25 });
addRemapKey.Style(AccentButtonStyle());
addRemapKey.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
SingleKeyRemapControl::AddNewControlKeyRemapRow(keyRemapTable, keyboardRemapControlObjects);
@@ -337,14 +336,19 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
UIHelpers::SetFocusOnTypeButtonInLastRow(keyRemapTable, EditorConstants::RemapTableColCount);
});
// Remap key button content
StackPanel addRemapKeyContent;
addRemapKeyContent.Orientation(Orientation::Horizontal);
addRemapKeyContent.Spacing(10);
addRemapKeyContent.Children().Append(SymbolIcon(Symbol::Add));
TextBlock addRemapKeyText;
addRemapKeyText.Text(GET_RESOURCE_STRING(IDS_ADD_KEY_REMAP_BUTTON));
addRemapKeyContent.Children().Append(addRemapKeyText);
addRemapKey.Content(addRemapKeyContent);
// Set accessible name for the addRemapKey button
addRemapKey.SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_ADD_KEY_REMAP_BUTTON)));
// Add tooltip for add button which would appear on hover
ToolTip addRemapKeytoolTip;
addRemapKeytoolTip.Content(box_value(GET_RESOURCE_STRING(IDS_ADD_KEY_REMAP_BUTTON)));
ToolTipService::SetToolTip(addRemapKey, addRemapKeytoolTip);
// Header and example text at the top of the window
StackPanel helperText;
helperText.Children().Append(keyRemapInfoHeader);
@@ -381,7 +385,20 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
{
}
desktopSource.Content(xamlContainer);
UserControl xamlContent;
xamlContent.Content(xamlContainer);
if (Windows::Foundation::Metadata::ApiInformation::IsTypePresent(L"Windows.UI.Composition.ICompositionSupportsSystemBackdrop"))
{
// Apply Mica
muxc::BackdropMaterial::SetApplyToRootOrPageBackground(xamlContent, true);
}
else
{
// Mica isn't available
xamlContainer.Background(Application::Current().Resources().Lookup(box_value(L"ApplicationPageBackgroundThemeBrush")).as<Media::SolidColorBrush>());
}
Window::Current().Content(xamlContent);
////End XAML Island section
if (_hWndEditKeyboardWindow)
{
@@ -400,9 +417,6 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
hwndEditKeyboardNativeWindow = nullptr;
keyboardManagerState.ResetUIState();
keyboardManagerState.ClearRegisteredKeyDelays();
// Cannot be done in WM_DESTROY because that causes crashes due to fatal app exit
xamlBridge.ClearXamlIslands();
}
void CreateEditKeyboardWindow(HINSTANCE hInst, KBMEditor::KeyboardManagerState& keyboardManagerState, MappingConfiguration& mappingConfiguration)

View File

@@ -13,9 +13,10 @@
#include "ShortcutControl.h"
#include "Styles.h"
#include "UIHelpers.h"
#include "XamlBridge.h"
#include "XamlBridge2.h"
#include "ShortcutErrorType.h"
#include "EditorConstants.h"
#include <common/Themes/theme_listener.h>
using namespace winrt::Windows::Foundation;
@@ -34,7 +35,21 @@ HWND hwndEditShortcutsNativeWindow = nullptr;
std::mutex editShortcutsWindowMutex;
// Stores a pointer to the Xaml Bridge object so that it can be accessed from the window procedure
static XamlBridge* xamlBridgePtr = nullptr;
static XamlBridge2* xamlBridgePtr = nullptr;
// Theming
static ThemeListener theme_listener{};
static void handleTheme()
{
auto theme = theme_listener.AppTheme;
auto isDark = theme == AppTheme::Dark;
Logger::info(L"Theme is now {}", isDark ? L"Dark" : L"Light");
if (hwndEditShortcutsNativeWindow != nullptr)
{
ThemeHelpers::SetImmersiveDarkMode(hwndEditShortcutsNativeWindow, isDark);
}
}
static IAsyncAction OnClickAccept(
KBMEditor::KeyboardManagerState& keyboardManagerState,
@@ -75,7 +90,7 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
windowClass.lpfnWndProc = EditShortcutsWindowProc;
windowClass.hInstance = hInst;
windowClass.lpszClassName = szWindowClass;
windowClass.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW);
windowClass.hbrBackground = CreateSolidBrush((ThemeHelpers::GetAppTheme() == AppTheme::Dark) ? 0x00000000 : 0x00FFFFFF);
windowClass.hIcon = static_cast<HICON>(LoadImageW(
windowClass.hInstance,
MAKEINTRESOURCE(IDS_KEYBOARDMANAGER_ICON),
@@ -132,14 +147,19 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
hwndEditShortcutsNativeWindow = _hWndEditShortcutsWindow;
hwndLock.unlock();
// Hide icon and caption from title bar
const DWORD windowThemeOptionsMask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;
WTA_OPTIONS windowThemeOptions{ windowThemeOptionsMask, windowThemeOptionsMask };
SetWindowThemeAttribute(_hWndEditShortcutsWindow, WTA_NONCLIENT, &windowThemeOptions, sizeof(windowThemeOptions));
handleTheme();
theme_listener.AddChangedHandler(handleTheme);
// Create the xaml bridge object
XamlBridge xamlBridge(_hWndEditShortcutsWindow);
// DesktopSource needs to be declared before the RelativePanel xamlContainer object to avoid errors
winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource desktopSource;
XamlBridge2 xamlBridge(_hWndEditShortcutsWindow);
// Create the desktop window xaml source object and set its content
hWndXamlIslandEditShortcutsWindow = xamlBridge.InitDesktopWindowsXamlSource(desktopSource);
hWndXamlIslandEditShortcutsWindow = xamlBridge.InitBridge();
// Set the pointer to the xaml bridge object
xamlBridgePtr = &xamlBridge;
@@ -276,11 +296,8 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
// Add shortcut button
Windows::UI::Xaml::Controls::Button addShortcut;
FontIcon plusSymbol;
plusSymbol.FontFamily(Xaml::Media::FontFamily(L"Segoe MDL2 Assets"));
plusSymbol.Glyph(L"\xE710");
addShortcut.Content(plusSymbol);
addShortcut.Margin({ 10, 10, 0, 25 });
addShortcut.Style(AccentButtonStyle());
addShortcut.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
ShortcutControl::AddNewShortcutControlRow(shortcutTable, keyboardRemapControlObjects);
@@ -291,14 +308,19 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
UIHelpers::SetFocusOnTypeButtonInLastRow(shortcutTable, EditorConstants::ShortcutTableColCount);
});
// Remap shortcut button content
StackPanel addShortcutContent;
addShortcutContent.Orientation(Orientation::Horizontal);
addShortcutContent.Spacing(10);
addShortcutContent.Children().Append(SymbolIcon(Symbol::Add));
TextBlock addShortcutText;
addShortcutText.Text(GET_RESOURCE_STRING(IDS_ADD_SHORTCUT_BUTTON));
addShortcutContent.Children().Append(addShortcutText);
addShortcut.Content(addShortcutContent);
// Set accessible name for the add shortcut button
addShortcut.SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_ADD_SHORTCUT_BUTTON)));
// Add tooltip for add button which would appear on hover
ToolTip addShortcuttoolTip;
addShortcuttoolTip.Content(box_value(GET_RESOURCE_STRING(IDS_ADD_SHORTCUT_BUTTON)));
ToolTipService::SetToolTip(addShortcut, addShortcuttoolTip);
// Header and example text at the top of the window
StackPanel helperText;
helperText.Children().Append(shortcutRemapInfoHeader);
@@ -334,7 +356,19 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
{
}
desktopSource.Content(xamlContainer);
UserControl xamlContent;
xamlContent.Content(xamlContainer);
if (Windows::Foundation::Metadata::ApiInformation::IsTypePresent(L"Windows.UI.Composition.ICompositionSupportsSystemBackdrop"))
{
// Apply Mica
muxc::BackdropMaterial::SetApplyToRootOrPageBackground(xamlContent, true);
}
else
{
// Mica isn't available
xamlContainer.Background(Application::Current().Resources().Lookup(box_value(L"ApplicationPageBackgroundThemeBrush")).as<Media::SolidColorBrush>());
}
Window::Current().Content(xamlContent);
////End XAML Island section
if (_hWndEditShortcutsWindow)
@@ -353,9 +387,6 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
hwndEditShortcutsNativeWindow = nullptr;
keyboardManagerState.ResetUIState();
keyboardManagerState.ClearRegisteredKeyDelays();
// Cannot be done in WM_DESTROY because that causes crashes due to fatal app exit
xamlBridge.ClearXamlIslands();
}
void CreateEditShortcutsWindow(HINSTANCE hInst, KBMEditor::KeyboardManagerState& keyboardManagerState, MappingConfiguration& mappingConfiguration)

View File

@@ -3,12 +3,12 @@
namespace EditorConstants
{
// Default window sizes
inline const int DefaultEditKeyboardWindowWidth = 800;
inline const int DefaultEditKeyboardWindowWidth = 960;
inline const int DefaultEditKeyboardWindowHeight = 600;
inline const int MinimumEditKeyboardWindowWidth = 500;
inline const int MinimumEditKeyboardWindowHeight = 450;
inline const int EditKeyboardTableMinWidth = 700;
inline const int DefaultEditShortcutsWindowWidth = 1050;
inline const int DefaultEditShortcutsWindowWidth = 1410;
inline const int DefaultEditShortcutsWindowHeight = 600;
inline const int MinimumEditShortcutsWindowWidth = 500;
inline const int MinimumEditShortcutsWindowHeight = 500;
@@ -21,7 +21,9 @@ namespace EditorConstants
inline const long RemapTableArrowColIndex = 1;
inline const long RemapTableNewColIndex = 2;
inline const long RemapTableRemoveColIndex = 3;
inline const DWORD64 RemapTableDropDownWidth = 110;
inline const DWORD64 RemapTableDropDownWidth = 160;
inline const DWORD64 RemapTableDropDownSpacing = 10;
inline const long RemapTargetColumnWidth = 3 * RemapTableDropDownWidth + 3 * RemapTableDropDownSpacing + 65;
// Shortcut table constants
inline const long ShortcutTableColCount = 5;
@@ -32,14 +34,14 @@ namespace EditorConstants
inline const long ShortcutTableTargetAppColIndex = 3;
inline const long ShortcutTableRemoveColIndex = 4;
inline const long ShortcutArrowColumnWidth = 90;
inline const DWORD64 ShortcutTableDropDownWidth = 110;
inline const DWORD64 ShortcutTableDropDownWidth = 160;
inline const DWORD64 ShortcutTableDropDownSpacing = 10;
inline const long ShortcutOriginColumnWidth = 3 * ShortcutTableDropDownWidth + 3 * ShortcutTableDropDownSpacing;
inline const long ShortcutTargetColumnWidth = 3 * ShortcutTableDropDownWidth + 3 * ShortcutTableDropDownSpacing + 15;
// Drop down height used for both Edit Keyboard and Edit Shortcuts
inline const DWORD64 TableDropDownHeight = 200;
inline const DWORD64 TableArrowColWidth = 230;
inline const DWORD64 TableArrowColWidth = 130;
inline const DWORD64 TableRemoveColWidth = 20;
inline const DWORD64 TableWarningColWidth = 20;
inline const DWORD64 TableTargetAppColWidth = ShortcutTableDropDownWidth + TableRemoveColWidth * 2;

View File

@@ -51,8 +51,10 @@ std::vector<std::pair<DWORD, std::wstring>> KeyDropDownControl::GetKeyList(bool
void KeyDropDownControl::SetDefaultProperties(bool isShortcut, bool renderDisable)
{
dropDown = ComboBox();
#ifndef USE_NEW_DROPDOWN_WARNING_TIP
warningFlyout = Flyout();
warningMessage = TextBlock();
#endif
if (!isShortcut)
{
@@ -77,6 +79,19 @@ void KeyDropDownControl::SetDefaultProperties(bool isShortcut, bool renderDisabl
CheckAndUpdateKeyboardLayout(currentDropDown, isShortcut, renderDisable);
});
#ifdef USE_NEW_DROPDOWN_WARNING_TIP
// Attach the tip to the drop down
warningTip.Target(dropDown.as<ComboBox>());
dropDown.as<ComboBox>().Loaded([&](winrt::Windows::Foundation::IInspectable const& sender, auto args) {
Media::VisualTreeHelper::GetChild(dropDown.as<ComboBox>(), 0).as<Grid>().Children().Append(warningTip);
});
// Tip properties
muxc::SymbolIconSource warningIcon;
warningIcon.Symbol(Symbol::Important);
warningTip.IconSource(warningIcon);
warningTip.IsLightDismissEnabled(true);
#else
// Attach flyout to the drop down
warningFlyout.as<Flyout>().Content(warningMessage.as<TextBlock>());
@@ -86,6 +101,7 @@ void KeyDropDownControl::SetDefaultProperties(bool isShortcut, bool renderDisabl
style.Setters().Append(Setter(Windows::UI::Xaml::Controls::Control::TabNavigationProperty(), winrt::box_value(Windows::UI::Xaml::Input::KeyboardNavigationMode::Cycle)));
warningFlyout.as<Flyout>().FlyoutPresenterStyle(style);
dropDown.as<ComboBox>().ContextFlyout().SetAttachedFlyout((FrameworkElement)dropDown.as<ComboBox>(), warningFlyout.as<Flyout>());
#endif
// To set the accessible name of the combo-box (by default index 1)
SetAccessibleNameForComboBox(dropDown.as<ComboBox>(), 1);
@@ -376,6 +392,11 @@ void KeyDropDownControl::ValidateShortcutFromDropDownList(StackPanel table, Stac
void KeyDropDownControl::SetDropDownError(ComboBox currentDropDown, hstring message)
{
currentDropDown.SelectedIndex(-1);
#ifdef USE_NEW_DROPDOWN_WARNING_TIP
warningTip.Title(message);
warningTip.IsOpen(true);
#else
warningMessage.as<TextBlock>().Text(message);
try
{
@@ -386,6 +407,7 @@ void KeyDropDownControl::SetDropDownError(ComboBox currentDropDown, hstring mess
// If it's loading and some remaps are invalid from previous configs, avoid crashing when flyouts can't be showed yet.
Logger::error(L"Failed to show dropdown error flyout: {}", message);
}
#endif
}
// Function to add a shortcut to the UI control as combo boxes

View File

@@ -2,6 +2,9 @@
#include <keyboardmanager/common/Shortcut.h>
// Enables the WinUI teaching tip to show as the new warning flyout
#define USE_NEW_DROPDOWN_WARNING_TIP
namespace KBMEditor
{
class KeyboardManagerState;
@@ -38,11 +41,16 @@ private:
// Stores the previous layout
HKL previousLayout = 0;
#ifdef USE_NEW_DROPDOWN_WARNING_TIP
// Stores the teaching tip attached to the current drop down
muxc::TeachingTip warningTip;
#else
// Stores the flyout warning message
winrt::Windows::Foundation::IInspectable warningMessage;
// Stores the flyout attached to the current drop down
winrt::Windows::Foundation::IInspectable warningFlyout;
#endif
// Stores whether a key to shortcut warning has to be ignored
bool ignoreKeyToShortcutWarning;

View File

@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props" Condition="Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props')" />
<Import Project="..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props" Condition="Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
@@ -53,6 +55,7 @@
<ClInclude Include="trace.h" />
<ClInclude Include="UIHelpers.h" />
<ClInclude Include="XamlBridge.h" />
<ClInclude Include="XamlBridge2.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="BufferValidationHelpers.cpp" />
@@ -74,6 +77,7 @@
<ClCompile Include="trace.cpp" />
<ClCompile Include="UIHelpers.cpp" />
<ClCompile Include="XamlBridge.cpp" />
<ClCompile Include="XamlBridge2.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -95,6 +99,9 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2088.41\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2088.41\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" />
</ImportGroup>
<Import Project="..\..\..\..\deps\spdlog.props" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
@@ -103,6 +110,11 @@
</PropertyGroup>
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2088.41\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2088.41\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets'))" />
</Target>
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(SolutionDir)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory)\..\KeyboardManagerEditor\ resource.base.h resource.h KeyboardManagerEditor.base.rc KeyboardManagerEditor.rc" />

View File

@@ -75,6 +75,9 @@
<ClInclude Include="EditorConstants.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="XamlBridge2.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
@@ -128,6 +131,9 @@
<ClCompile Include="KeyDelay.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="XamlBridge2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@@ -118,8 +118,15 @@ void KeyboardManagerState::AddKeyToLayout(const StackPanel& panel, const hstring
border.Padding({ 20, 10, 20, 10 });
border.Margin({ 0, 0, 10, 0 });
// Use the base low brush to be consistent with the theme
border.Background(Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundBaseLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>());
// Based on settings-ui\Settings.UI\SettingsXAML\Controls\KeyVisual\KeyVisual.xaml
border.Background(Application::Current().Resources().Lookup(box_value(L"ButtonBackground")).as<Media::Brush>());
border.BorderBrush(Application::Current().Resources().Lookup(box_value(L"ButtonBorderBrush")).as<Media::Brush>());
border.BorderThickness(unbox_value<Thickness>(Application::Current().Resources().Lookup(box_value(L"ButtonBorderThemeThickness"))));
border.CornerRadius(unbox_value<CornerRadius>(Application::Current().Resources().Lookup(box_value(L"ControlCornerRadius"))));
remapKey.Foreground(Application::Current().Resources().Lookup(box_value(L"ButtonForeground")).as<Media::Brush>());
remapKey.FontWeight(Text::FontWeights::SemiBold());
remapKey.FontSize(20);
border.HorizontalAlignment(HorizontalAlignment::Left);
border.Child(remapKey);

View File

@@ -90,13 +90,12 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
newrow.emplace_back(std::make_unique<ShortcutControl>(parent, row, 1, targetAppTextBox));
keyboardRemapControlObjects.push_back(std::move(newrow));
row.Padding({ 10, 10, 10, 10 });
row.Padding({ 10, 15, 10, 5 });
row.Margin({ 0, 0, 0, 2 });
row.Orientation(Orientation::Horizontal);
auto brush = Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundListLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>();
if (keyboardRemapControlObjects.size() % 2)
{
row.Background(brush);
}
row.Background(Application::Current().Resources().Lookup(box_value(L"CardBackgroundFillColorDefaultBrush")).as<Media::Brush>());
row.BorderBrush(Application::Current().Resources().Lookup(box_value(L"CardStrokeColorDefaultBrush")).as<Media::Brush>());
row.BorderThickness({ 0, 1, 0, 1 });
// ShortcutControl for the original shortcut
auto origin = keyboardRemapControlObjects.back()[0]->GetShortcutControl();
@@ -104,14 +103,13 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
row.Children().Append(origin);
// Arrow icon
FontIcon arrowIcon;
arrowIcon.FontFamily(Xaml::Media::FontFamily(L"Segoe MDL2 Assets"));
arrowIcon.Glyph(L"\xE72A");
SymbolIcon arrowIcon(Symbol::Forward);
arrowIcon.VerticalAlignment(VerticalAlignment::Center);
arrowIcon.HorizontalAlignment(HorizontalAlignment::Center);
auto arrowIconContainer = UIHelpers::GetWrapped(arrowIcon, EditorConstants::ShortcutArrowColumnWidth).as<StackPanel>();
arrowIconContainer.Orientation(Orientation::Vertical);
arrowIconContainer.VerticalAlignment(VerticalAlignment::Center);
arrowIconContainer.Margin({ 0, 0, 0, 10 });
row.Children().Append(arrowIconContainer);
// ShortcutControl for the new shortcut
@@ -122,6 +120,7 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
targetAppTextBox.Width(EditorConstants::ShortcutTableDropDownWidth);
targetAppTextBox.PlaceholderText(KeyboardManagerEditorStrings::DefaultAppName());
targetAppTextBox.Text(targetAppName);
targetAppTextBox.Margin({ 0, 0, 0, 10 });
// GotFocus handler will be called whenever the user tabs into or clicks on the textbox
targetAppTextBox.GotFocus([targetAppTextBox](auto const& sender, auto const& e) {
@@ -194,13 +193,11 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
// Delete row button
Windows::UI::Xaml::Controls::Button deleteShortcut;
FontIcon deleteSymbol;
deleteSymbol.FontFamily(Xaml::Media::FontFamily(L"Segoe MDL2 Assets"));
deleteSymbol.Glyph(L"\xE74D");
deleteShortcut.Content(deleteSymbol);
deleteShortcut.Content(SymbolIcon(Symbol::Delete));
deleteShortcut.Background(Media::SolidColorBrush(Colors::Transparent()));
deleteShortcut.HorizontalAlignment(HorizontalAlignment::Center);
deleteShortcut.Click([&, parent, row, brush, deleteShortcut](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
deleteShortcut.Margin({ 0, 0, 0, 10 });
deleteShortcut.Click([&, parent, row, deleteShortcut](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
Button currentButton = sender.as<Button>();
uint32_t rowIndex;
// Get index of delete button
@@ -216,7 +213,6 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
for (uint32_t i = rowIndex + 1; i < children.Size(); i++)
{
StackPanel row = children.GetAt(i).as<StackPanel>();
row.Background(i % 2 ? brush : Media::SolidColorBrush(Colors::Transparent()));
StackPanel sourceCol = row.Children().GetAt(0).as<StackPanel>();
StackPanel targetCol = row.Children().GetAt(2).as<StackPanel>();
TextBox targetApp = row.Children().GetAt(3).as<StackPanel>().Children().GetAt(0).as<StackPanel>().Children().GetAt(0).as<TextBox>();
@@ -294,8 +290,6 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
// ContentDialog requires manually setting the XamlRoot (https://learn.microsoft.com/uwp/api/windows.ui.xaml.controls.contentdialog#contentdialog-in-appwindow-or-xaml-islands)
detectShortcutBox.XamlRoot(xamlRoot);
detectShortcutBox.Title(box_value(GET_RESOURCE_STRING(IDS_TYPESHORTCUT_TITLE)));
detectShortcutBox.IsPrimaryButtonEnabled(false);
detectShortcutBox.IsSecondaryButtonEnabled(false);
// Get the linked stack panel for the "Type shortcut" button that was clicked
VariableSizedWrapGrid linkedShortcutVariableSizedWrapGrid = UIHelpers::GetSiblingElement(sender).as<VariableSizedWrapGrid>();
@@ -359,16 +353,13 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
onReleaseEnter();
};
TextBlock primaryButtonText;
primaryButtonText.Text(GET_RESOURCE_STRING(IDS_OK_BUTTON));
Button primaryButton;
primaryButton.HorizontalAlignment(HorizontalAlignment::Stretch);
primaryButton.Margin({ 2, 2, 2, 2 });
primaryButton.Content(primaryButtonText);
// OK button
primaryButton.Click([onAccept](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
detectShortcutBox.DefaultButton(ContentDialogButton::Primary);
detectShortcutBox.PrimaryButtonText(GET_RESOURCE_STRING(IDS_OK_BUTTON));
detectShortcutBox.PrimaryButtonClick([onAccept](winrt::Windows::Foundation::IInspectable const& sender, ContentDialogButtonClickEventArgs const& args) {
// Cancel default dialog events
args.Cancel(true);
onAccept();
});
@@ -376,12 +367,10 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
keyboardManagerState.RegisterKeyDelay(
VK_RETURN,
selectDetectedShortcutAndResetKeys,
[primaryButton, onPressEnter, detectShortcutBox](DWORD) {
[onPressEnter, detectShortcutBox](DWORD) {
detectShortcutBox.Dispatcher().RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
[primaryButton, onPressEnter] {
// Use the base medium low brush to be consistent with the theme
primaryButton.Background(Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundBaseMediumLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>());
[onPressEnter] {
onPressEnter();
});
},
@@ -393,9 +382,6 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
});
});
TextBlock cancelButtonText;
cancelButtonText.Text(GET_RESOURCE_STRING(IDS_CANCEL_BUTTON));
auto onCancel = [&keyboardManagerState,
detectShortcutBox,
unregisterKeys,
@@ -418,12 +404,12 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
unregisterKeys();
};
Button cancelButton;
cancelButton.HorizontalAlignment(HorizontalAlignment::Stretch);
cancelButton.Margin({ 2, 2, 2, 2 });
cancelButton.Content(cancelButtonText);
// Cancel button
cancelButton.Click([onCancel](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
detectShortcutBox.CloseButtonText(GET_RESOURCE_STRING(IDS_CANCEL_BUTTON));
detectShortcutBox.CloseButtonClick([onCancel](winrt::Windows::Foundation::IInspectable const& sender, ContentDialogButtonClickEventArgs const& args) {
// Cancel default dialog events
args.Cancel(true);
onCancel();
});
@@ -474,21 +460,6 @@ void ShortcutControl::CreateDetectShortcutWindow(winrt::Windows::Foundation::IIn
holdEnterInfo.Margin({ 0, 0, 0, 0 });
stackPanel.Children().Append(holdEnterInfo);
ColumnDefinition primaryButtonColumn;
ColumnDefinition cancelButtonColumn;
Grid buttonPanel;
buttonPanel.Margin({ 0, 20, 0, 0 });
buttonPanel.HorizontalAlignment(HorizontalAlignment::Stretch);
buttonPanel.ColumnDefinitions().Append(primaryButtonColumn);
buttonPanel.ColumnDefinitions().Append(cancelButtonColumn);
buttonPanel.SetColumn(primaryButton, 0);
buttonPanel.SetColumn(cancelButton, 1);
buttonPanel.Children().Append(primaryButton);
buttonPanel.Children().Append(cancelButton);
stackPanel.Children().Append(buttonPanel);
try
{
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.

View File

@@ -84,33 +84,31 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
newrow.emplace_back(std::make_unique<SingleKeyRemapControl>(parent, row, 1));
keyboardRemapControlObjects.push_back(std::move(newrow));
row.Padding({ 10, 10, 10, 10 });
row.Padding({ 10, 15, 10, 5 });
row.Margin({ 0, 0, 0, 2 });
row.Orientation(Orientation::Horizontal);
auto brush = Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundListLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>();
if (keyboardRemapControlObjects.size() % 2)
{
row.Background(brush);
}
row.Background(Application::Current().Resources().Lookup(box_value(L"CardBackgroundFillColorDefaultBrush")).as<Media::Brush>());
row.BorderBrush(Application::Current().Resources().Lookup(box_value(L"CardStrokeColorDefaultBrush")).as<Media::Brush>());
row.BorderThickness({ 0, 1, 0, 1 });
// SingleKeyRemapControl for the original key.
auto originalElement = keyboardRemapControlObjects.back()[0]->getSingleKeyRemapControl();
originalElement.Width(EditorConstants::RemapTableDropDownWidth + EditorConstants::ShortcutTableDropDownSpacing);
originalElement.Width(EditorConstants::RemapTableDropDownWidth + EditorConstants::RemapTableDropDownSpacing);
row.Children().Append(originalElement);
// Arrow icon
FontIcon arrowIcon;
arrowIcon.FontFamily(Media::FontFamily(L"Segoe MDL2 Assets"));
arrowIcon.Glyph(L"\xE72A");
SymbolIcon arrowIcon(Symbol::Forward);
arrowIcon.VerticalAlignment(VerticalAlignment::Center);
arrowIcon.HorizontalAlignment(HorizontalAlignment::Center);
auto arrowIconContainer = UIHelpers::GetWrapped(arrowIcon, EditorConstants::TableArrowColWidth).as<StackPanel>();
arrowIconContainer.Orientation(Orientation::Vertical);
arrowIconContainer.VerticalAlignment(VerticalAlignment::Center);
arrowIconContainer.Margin({ 0, 0, 0, 10 });
row.Children().Append(arrowIconContainer);
// SingleKeyRemapControl for the new remap key
auto targetElement = keyboardRemapControlObjects.back()[1]->getSingleKeyRemapControl();
targetElement.Width(EditorConstants::ShortcutTargetColumnWidth);
targetElement.Width(EditorConstants::RemapTargetColumnWidth);
row.Children().Append(targetElement);
// Set the key text if the two keys are not null (i.e. default args)
@@ -135,13 +133,11 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
// Delete row button
Windows::UI::Xaml::Controls::Button deleteRemapKeys;
FontIcon deleteSymbol;
deleteSymbol.FontFamily(Media::FontFamily(L"Segoe MDL2 Assets"));
deleteSymbol.Glyph(L"\xE74D");
deleteRemapKeys.Content(deleteSymbol);
deleteRemapKeys.Content(SymbolIcon(Symbol::Delete));
deleteRemapKeys.Background(Media::SolidColorBrush(Colors::Transparent()));
deleteRemapKeys.HorizontalAlignment(HorizontalAlignment::Center);
deleteRemapKeys.Click([&, parent, row, brush, deleteRemapKeys](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
deleteRemapKeys.Margin({ 0, 0, 0, 10 });
deleteRemapKeys.Click([&, parent, row, deleteRemapKeys](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
uint32_t rowIndex;
// Get index of delete button
UIElementCollection children = parent.Children();
@@ -157,7 +153,6 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
for (uint32_t i = rowIndex + 1; i < children.Size(); i++)
{
StackPanel row = children.GetAt(i).as<StackPanel>();
row.Background(i % 2 ? brush : Media::SolidColorBrush(Colors::Transparent()));
StackPanel sourceCol = row.Children().GetAt(0).as<StackPanel>();
StackPanel targetCol = row.Children().GetAt(2).as<StackPanel>();
Button delButton = row.Children().GetAt(3).as<Button>();
@@ -224,8 +219,6 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
// ContentDialog requires manually setting the XamlRoot (https://learn.microsoft.com/uwp/api/windows.ui.xaml.controls.contentdialog#contentdialog-in-appwindow-or-xaml-islands)
detectRemapKeyBox.XamlRoot(xamlRoot);
detectRemapKeyBox.Title(box_value(GET_RESOURCE_STRING(IDS_TYPEKEY_TITLE)));
detectRemapKeyBox.IsPrimaryButtonEnabled(false);
detectRemapKeyBox.IsSecondaryButtonEnabled(false);
// Get the linked text block for the "Type Key" button that was clicked
ComboBox linkedRemapDropDown = UIHelpers::GetSiblingElement(sender).as<ComboBox>();
@@ -269,14 +262,13 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
onReleaseEnter();
};
TextBlock primaryButtonText;
primaryButtonText.Text(GET_RESOURCE_STRING(IDS_OK_BUTTON));
// OK button
detectRemapKeyBox.DefaultButton(ContentDialogButton::Primary);
detectRemapKeyBox.PrimaryButtonText(GET_RESOURCE_STRING(IDS_OK_BUTTON));
detectRemapKeyBox.PrimaryButtonClick([onAccept](winrt::Windows::Foundation::IInspectable const& sender, ContentDialogButtonClickEventArgs const& args) {
// Cancel default dialog events
args.Cancel(true);
Button primaryButton;
primaryButton.HorizontalAlignment(HorizontalAlignment::Stretch);
primaryButton.Margin({ 2, 2, 2, 2 });
primaryButton.Content(primaryButtonText);
primaryButton.Click([onAccept](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
onAccept();
});
@@ -284,12 +276,10 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
keyboardManagerState.RegisterKeyDelay(
VK_RETURN,
std::bind(&KBMEditor::KeyboardManagerState::SelectDetectedRemapKey, &keyboardManagerState, std::placeholders::_1),
[primaryButton, onPressEnter, detectRemapKeyBox](DWORD) {
[onPressEnter, detectRemapKeyBox](DWORD) {
detectRemapKeyBox.Dispatcher().RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
[primaryButton, onPressEnter] {
// Use the base medium low brush to be consistent with the theme
primaryButton.Background(Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundBaseMediumLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>());
[onPressEnter] {
onPressEnter();
});
},
@@ -301,9 +291,6 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
});
});
TextBlock cancelButtonText;
cancelButtonText.Text(GET_RESOURCE_STRING(IDS_CANCEL_BUTTON));
auto onCancel = [&keyboardManagerState,
detectRemapKeyBox,
unregisterKeys] {
@@ -317,13 +304,12 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
unregisterKeys();
};
Button cancelButton;
cancelButton.HorizontalAlignment(HorizontalAlignment::Stretch);
cancelButton.Margin({ 2, 2, 2, 2 });
cancelButton.Content(cancelButtonText);
// Cancel button
cancelButton.Click([onCancel](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
detectRemapKeyBox.CloseButtonText(GET_RESOURCE_STRING(IDS_CANCEL_BUTTON));
detectRemapKeyBox.CloseButtonClick([onCancel](winrt::Windows::Foundation::IInspectable const& sender, ContentDialogButtonClickEventArgs const& args) {
// Cancel default dialog events
args.Cancel(true);
onCancel();
});
@@ -367,21 +353,6 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
holdEnterInfo.Margin({ 0, 0, 0, 0 });
stackPanel.Children().Append(holdEnterInfo);
ColumnDefinition primaryButtonColumn;
ColumnDefinition cancelButtonColumn;
Grid buttonPanel;
buttonPanel.Margin({ 0, 20, 0, 0 });
buttonPanel.HorizontalAlignment(HorizontalAlignment::Stretch);
buttonPanel.ColumnDefinitions().Append(primaryButtonColumn);
buttonPanel.ColumnDefinitions().Append(cancelButtonColumn);
buttonPanel.SetColumn(primaryButton, 0);
buttonPanel.SetColumn(cancelButton, 1);
buttonPanel.Children().Append(primaryButton);
buttonPanel.Children().Append(cancelButton);
stackPanel.Children().Append(buttonPanel);
try
{
// If a layout update has been triggered by other methods (e.g.: adapting to zoom level), this may throw an exception.

View File

@@ -1,15 +1,7 @@
#include "pch.h"
#include "Styles.h"
#include <common/themes/windows_colors.h>
Style AccentButtonStyle()
{
Style style{ winrt::xaml_typename<Controls::Button>() };
style.Setters().Append(Setter{
Controls::Control::BackgroundProperty(),
winrt::Windows::UI::Xaml::Media::SolidColorBrush{ WindowsColors::get_accent_color() } });
style.Setters().Append(Setter{
Controls::Control::ForegroundProperty(),
winrt::Windows::UI::Xaml::Media::SolidColorBrush{ winrt::Windows::UI::Colors::White() } });
return style;
return Application::Current().Resources().Lookup(box_value(L"AccentButtonStyle")).as<Style>();
}

View File

@@ -0,0 +1,76 @@
#include "pch.h"
#include "XamlBridge2.h"
#include <CoreWindow.h> // ICoreWindowInterop
#include <winrt/Microsoft.Toolkit.Win32.UI.XamlHost.h>
#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h>
namespace wac = Windows::ApplicationModel::Core;
// Stubbed implementation for frameworkView.Initialize()
struct XamlBridgeCoreAppViewImpl : implements<XamlBridgeCoreAppViewImpl, wac::ICoreApplicationView>
{
auto CoreWindow() { return Core::CoreWindow::GetForCurrentThread(); }
auto Activated(Windows::Foundation::TypedEventHandler<wac::CoreApplicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs> const&) { return event_token(); }
auto Activated(event_token const&) {}
auto IsMain() { return true; }
auto IsHosted() { return false; }
};
// Function to run the message loop for the xaml window
void XamlBridge2::MessageLoop()
{
Logger::trace("XamlBridge2::MessageLoop()");
frameworkView.Run();
Logger::trace("XamlBridge2::MessageLoop() stopped");
}
// Function to initialize the xaml bridge
HWND XamlBridge2::InitBridge()
{
Logger::trace("XamlBridge2::InitBridge()");
HRESULT hr = S_OK;
winrt::init_apartment(apartment_type::single_threaded);
auto windowsUIHandle = LoadLibrary(TEXT("Windows.UI.dll"));
auto pfnPrivateCreateCoreWindow = reinterpret_cast<fnPrivateCreateCoreWindow>(GetProcAddress(windowsUIHandle, MAKEINTRESOURCEA(1500)));
// Create the core window to host the XAML content
void* pCoreWindow;
hr = pfnPrivateCreateCoreWindow(IMMERSIVE_HOSTED, L"", 0, 0, 0, 0, 0, parentWindow, winrt::guid_of<Core::ICoreWindow>(), &pCoreWindow);
winrt::check_hresult(hr);
coreWindow = Core::CoreWindow(pCoreWindow, winrt::take_ownership_from_abi);
// Prep for the WinUI resources
auto app = Microsoft::Toolkit::Win32::UI::XamlHost::XamlApplication({ Microsoft::UI::Xaml::XamlTypeInfo::XamlControlsXamlMetaDataProvider() });
// Initialize the XAML framework
frameworkView.Initialize(*reinterpret_cast<wac::CoreApplicationView*>(&make<XamlBridgeCoreAppViewImpl>()));
frameworkView.SetWindow(coreWindow);
// Add the WinUI resources
app.Resources().MergedDictionaries().Append(muxc::XamlControlsResources());
auto coreWindowInterop = coreWindow.as<ICoreWindowInterop>();
hr = coreWindowInterop->get_WindowHandle(&coreWindowHwnd);
winrt::check_hresult(hr);
SetParent(coreWindowHwnd, parentWindow);
SetWindowLong(coreWindowHwnd, GWL_STYLE, WS_CHILD | WS_VISIBLE);
return coreWindowHwnd;
}
// Message Handler function for Xaml windows
LRESULT XamlBridge2::MessageHandler(UINT const message, WPARAM const wParam, LPARAM const lParam) noexcept
{
switch (message)
{
case WM_ACTIVATE:
case WM_MOVE:
SendMessage(coreWindowHwnd, message, wParam, lParam);
break;
}
return DefWindowProc(parentWindow, message, wParam, lParam);
}

View File

@@ -0,0 +1,46 @@
#pragma once
// This class is used for handling XAML operations
class XamlBridge2
{
public:
// Function to run the message loop for the xaml window
void MessageLoop();
// Constructor
XamlBridge2(HWND parent) : parentWindow(parent) {}
// Function to initialize the xaml bridge
HWND InitBridge();
// Message Handler function for Xaml windows
LRESULT MessageHandler(UINT const message, WPARAM const wParam, LPARAM const lParam) noexcept;
private:
// Defines the window types for core windows
enum WINDOW_TYPE
{
IMMERSIVE_BODY = 0x0,
IMMERSIVE_DOCK = 0x1,
IMMERSIVE_HOSTED = 0x2,
IMMERSIVE_TEST = 0x3,
IMMERSIVE_BODY_ACTIVE = 0x4,
IMMERSIVE_DOCK_ACTIVE = 0x5,
NOT_IMMERSIVE = 0x6,
};
// Function signature for PrivateCreateCoreWindow
typedef HRESULT(CDECL* fnPrivateCreateCoreWindow)(WINDOW_TYPE WindowType, LPCWSTR pWindowTitle, INT X, INT Y, UINT uWidth, UINT uHeight, DWORD dwAttributes, HWND hOwnerWindow, REFIID riid, void** ppv);
// Stores the handle of the parent native window
HWND parentWindow = nullptr;
// Stores the core window for the UI thread
Core::CoreWindow coreWindow = nullptr;
// Stores the handle of the core window
HWND coreWindowHwnd = nullptr;
// Stores the xaml framework view for the UI thread
FrameworkView frameworkView;
};

View File

@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Toolkit.Win32.UI.XamlApplication" version="6.1.3" targetFramework="native" />
<package id="Microsoft.UI.Xaml" version="2.8.2-prerelease.220830001" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.2088.41" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.221104.6" targetFramework="native" />
</packages>

View File

@@ -10,8 +10,10 @@
#include <windows.ui.xaml.hosting.desktopwindowxamlsource.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Foundation.Metadata.h>
#include <winrt/Windows.UI.Core.h>
#include <winrt/Windows.UI.Text.h>
#include <winrt/Windows.ApplicationModel.Core.h>
#pragma push_macro("GetCurrentTime")
#undef GetCurrentTime
@@ -21,6 +23,7 @@
#include <winrt/Windows.UI.Xaml.Hosting.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
#include <winrt/Windows.ui.xaml.media.h>
#include <winrt/Microsoft.UI.Xaml.Controls.h>
#pragma pop_macro("GetCurrentTime")
#include <common/logger/logger.h>
@@ -37,4 +40,5 @@ using namespace Windows::UI::Composition;
using namespace Windows::UI::Xaml::Hosting;
using namespace Windows::Foundation::Numerics;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls;
namespace muxc = Microsoft::UI::Xaml::Controls;

View File

@@ -71,77 +71,90 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
foreach (var path in paths)
{
if (Directory.Exists(path))
if (!Directory.Exists(path))
{
var files = Directory.GetFiles(path)
.Where(x => (x.Contains("code", StringComparison.OrdinalIgnoreCase) || x.Contains("codium", StringComparison.OrdinalIgnoreCase))
&& !x.EndsWith(".cmd", StringComparison.OrdinalIgnoreCase)).ToArray();
var iconPath = Path.GetDirectoryName(path);
if (files.Length > 0)
{
var file = files[0];
var version = string.Empty;
var instance = new VSCodeInstance
{
ExecutablePath = file,
};
if (file.EndsWith("code", StringComparison.OrdinalIgnoreCase))
{
version = "Code";
instance.VSCodeVersion = VSCodeVersion.Stable;
}
else if (file.EndsWith("code-insiders", StringComparison.OrdinalIgnoreCase))
{
version = "Code - Insiders";
instance.VSCodeVersion = VSCodeVersion.Insiders;
}
else if (file.EndsWith("code-exploration", StringComparison.OrdinalIgnoreCase))
{
version = "Code - Exploration";
instance.VSCodeVersion = VSCodeVersion.Exploration;
}
else if (file.EndsWith("codium", StringComparison.OrdinalIgnoreCase))
{
version = "VSCodium";
instance.VSCodeVersion = VSCodeVersion.Stable;
}
else if (file.EndsWith("codium-insiders", StringComparison.OrdinalIgnoreCase))
{
version = "VSCodium - Insiders";
instance.VSCodeVersion = VSCodeVersion.Insiders;
}
if (version != string.Empty)
{
var portableData = Path.Join(iconPath, "data");
instance.AppData = Directory.Exists(portableData) ? Path.Join(portableData, "user-data") : Path.Combine(_userAppDataPath, version);
var vsCodeIconPath = Path.Join(iconPath, $"{version}.exe");
var vsCodeIcon = Icon.ExtractAssociatedIcon(vsCodeIconPath);
if (vsCodeIcon != null)
{
using var vsCodeIconBitmap = vsCodeIcon.ToBitmap();
// workspace
using var folderIcon = (Bitmap)Image.FromFile(Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images//folder.png"));
using var bitmapFolderIcon = BitmapOverlayToCenter(folderIcon, vsCodeIconBitmap);
instance.WorkspaceIconBitMap = Bitmap2BitmapImage(bitmapFolderIcon);
// remote
using var monitorIcon = (Bitmap)Image.FromFile(Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images//monitor.png"));
using var bitmapMonitorIcon = BitmapOverlayToCenter(monitorIcon, vsCodeIconBitmap);
instance.RemoteIconBitMap = Bitmap2BitmapImage(bitmapMonitorIcon);
}
Instances.Add(instance);
}
}
continue;
}
var files = Directory.GetFiles(path)
.Where(x => (x.Contains("code", StringComparison.OrdinalIgnoreCase) || x.Contains("codium", StringComparison.OrdinalIgnoreCase))
&& !x.EndsWith(".cmd", StringComparison.OrdinalIgnoreCase)).ToArray();
// Remove the trailing backslash to always get the correct path
var iconPath = Path.GetDirectoryName(path.TrimEnd('\\'));
if (files.Length == 0)
{
continue;
}
var file = files[0];
var version = string.Empty;
var instance = new VSCodeInstance
{
ExecutablePath = file,
};
if (file.EndsWith("code", StringComparison.OrdinalIgnoreCase))
{
version = "Code";
instance.VSCodeVersion = VSCodeVersion.Stable;
}
else if (file.EndsWith("code-insiders", StringComparison.OrdinalIgnoreCase))
{
version = "Code - Insiders";
instance.VSCodeVersion = VSCodeVersion.Insiders;
}
else if (file.EndsWith("code-exploration", StringComparison.OrdinalIgnoreCase))
{
version = "Code - Exploration";
instance.VSCodeVersion = VSCodeVersion.Exploration;
}
else if (file.EndsWith("codium", StringComparison.OrdinalIgnoreCase))
{
version = "VSCodium";
instance.VSCodeVersion = VSCodeVersion.Stable;
}
else if (file.EndsWith("codium-insiders", StringComparison.OrdinalIgnoreCase))
{
version = "VSCodium - Insiders";
instance.VSCodeVersion = VSCodeVersion.Insiders;
}
if (string.IsNullOrEmpty(version))
{
continue;
}
var portableData = Path.Join(iconPath, "data");
instance.AppData = Directory.Exists(portableData) ? Path.Join(portableData, "user-data") : Path.Combine(_userAppDataPath, version);
var vsCodeIconPath = Path.Join(iconPath, $"{version}.exe");
if (!File.Exists(vsCodeIconPath))
{
continue;
}
var vsCodeIcon = Icon.ExtractAssociatedIcon(vsCodeIconPath);
if (vsCodeIcon == null)
{
continue;
}
using var vsCodeIconBitmap = vsCodeIcon.ToBitmap();
// Workspace
using var folderIcon = (Bitmap)Image.FromFile(Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images//folder.png"));
using var bitmapFolderIcon = BitmapOverlayToCenter(folderIcon, vsCodeIconBitmap);
instance.WorkspaceIconBitMap = Bitmap2BitmapImage(bitmapFolderIcon);
// Remote
using var monitorIcon = (Bitmap)Image.FromFile(Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images//monitor.png"));
using var bitmapMonitorIcon = BitmapOverlayToCenter(monitorIcon, vsCodeIconBitmap);
instance.RemoteIconBitMap = Bitmap2BitmapImage(bitmapMonitorIcon);
Instances.Add(instance);
}
}
}

View File

@@ -7,10 +7,10 @@ using System.Diagnostics;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
using Microsoft.Plugin.Program.Programs;
using Microsoft.Plugin.Program.Storage;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Wox.Infrastructure;
using Wox.Infrastructure.FileSystemHelper;
using Wox.Infrastructure.Storage;
using Win32Program = Microsoft.Plugin.Program.Programs.Win32Program;

View File

@@ -281,6 +281,9 @@ namespace PowerLauncher
if (option.Key != null && defaultOptions.TryGetValue(option.Key, out PluginAdditionalOption defaultOption))
{
defaultOption.Value = option.Value;
defaultOption.ComboBoxValue = option.ComboBoxValue;
defaultOption.TextValue = option.TextValue;
defaultOption.NumberValue = option.NumberValue;
}
}

View File

@@ -2,7 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Microsoft.Plugin.Program.Programs
namespace Wox.Infrastructure
{
public interface IShellLinkHelper
{

View File

@@ -5,14 +5,15 @@
using System;
using System.Collections.Concurrent;
using System.Globalization;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using ManagedCommon;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
using Wox.Plugin.Logger;
@@ -43,20 +44,46 @@ namespace Wox.Infrastructure.Image
".ico",
};
// Checks whether it is a valid PNG by checking the 8 bytes at the beginning of the file.
public static bool IsValidPngSignature(string filePath)
{
byte[] pngSignature = { 137, 80, 78, 71, 13, 10, 26, 10 };
byte[] buffer = new byte[8];
using FileStream fs = new(filePath, FileMode.Open, FileAccess.Read);
return fs.Read(buffer, 0, buffer.Length) == buffer.Length && pngSignature.SequenceEqual(buffer);
}
public static void Initialize(Theme theme)
{
_hashGenerator = new ImageHashGenerator();
foreach (var icon in new[] { Constant.ErrorIcon, Constant.LightThemedErrorIcon })
{
BitmapImage bmi = new BitmapImage();
bmi.BeginInit();
bmi.UriSource = new Uri(icon);
bmi.CacheOption = BitmapCacheOption.OnLoad;
bmi.EndInit();
ImageSource img = bmi;
img.Freeze();
ImageCache[icon] = img;
var uri = new Uri(icon);
try
{
if (File.Exists(uri.LocalPath) && IsValidPngSignature(uri.LocalPath))
{
BitmapImage bmi = new BitmapImage();
bmi.BeginInit();
bmi.UriSource = uri;
bmi.CacheOption = BitmapCacheOption.OnLoad;
bmi.EndInit();
ImageSource img = bmi;
img.Freeze();
ImageCache[icon] = img;
}
else
{
Log.Error($"Image file '{icon}' is not a valid PNG.", MethodBase.GetCurrentMethod().DeclaringType);
}
}
catch (COMException comEx)
{
Log.Exception($"COMException was thrown in {uri.LocalPath} file.", comEx, MethodBase.GetCurrentMethod().DeclaringType);
}
}
UpdateIconPath(theme);

View File

@@ -82,7 +82,19 @@ namespace Wox.Infrastructure.Image
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
{
IntPtr hBitmap = GetHBitmap(Path.GetFullPath(fileName), width, height, options);
IntPtr hBitmap = IntPtr.Zero;
if (Path.GetExtension(fileName).Equals(".lnk", StringComparison.OrdinalIgnoreCase))
{
// If the file has a '.lnk' extension, it is a shortcut file. Use the shellLinkHelper to retrieve the actual target file path from the shortcut.
IShellLinkHelper shellLinkHelper = new ShellLinkHelper();
string targetFilePath = shellLinkHelper.RetrieveTargetPath(fileName);
hBitmap = ExtractIconToHBitmap(targetFilePath);
}
else
{
hBitmap = GetHBitmap(Path.GetFullPath(fileName), width, height, options);
}
try
{
@@ -119,7 +131,7 @@ namespace Wox.Infrastructure.Image
HResult hr = ((IShellItemImageFactory)nativeShellItem).GetImage(nativeSize, options, out hBitmap);
// if extracting image thumbnail and failed, extract shell icon
// if extracting image thumbnail and failed, extract shell icon
if (options == ThumbnailOptions.ThumbnailOnly && hr == HResult.ExtractionFailed)
{
hr = ((IShellItemImageFactory)nativeShellItem).GetImage(nativeSize, ThumbnailOptions.IconOnly, out hBitmap);
@@ -146,6 +158,19 @@ namespace Wox.Infrastructure.Image
}
}
public static IntPtr ExtractIconToHBitmap(string fileName)
{
// Extracts the icon associated with the file
using (System.Drawing.Icon thumbnailIcon = System.Drawing.Icon.ExtractAssociatedIcon(fileName))
{
// Convert to Bitmap
using (System.Drawing.Bitmap bitmap = thumbnailIcon.ToBitmap())
{
return bitmap.GetHbitmap();
}
}
}
private static bool logReportedAdobeReaderDetected; // Keep track if Adobe Reader detection has been logged yet.
private static bool logReportedErrorInDetectingAdobeReader; // Keep track if we reported an exception while trying to detect Adobe Reader yet.
private static bool adobeReaderDetectionLastResult; // The last result when Adobe Reader detection has read the registry.

View File

@@ -7,10 +7,9 @@ using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using Accessibility;
using Microsoft.Plugin.Program.Logger;
using Wox.Plugin.Logger;
namespace Microsoft.Plugin.Program.Programs
namespace Wox.Infrastructure
{
public class ShellLinkHelper : IShellLinkHelper
{
@@ -142,7 +141,7 @@ namespace Microsoft.Plugin.Program.Programs
}
catch (System.IO.FileNotFoundException ex)
{
ProgramLogger.Exception("Path could not be retrieved", ex, GetType(), path);
Log.Exception("Path could not be retrieved", ex, GetType(), path);
return string.Empty;
}
@@ -165,7 +164,7 @@ namespace Microsoft.Plugin.Program.Programs
((IShellLinkW)link).GetDescription(buffer, MAX_PATH);
Description = buffer.ToString();
}
catch (Exception e)
catch (System.Exception e)
{
Log.Exception($"Failed to fetch description for {target}, {e.Message}", e, GetType());
Description = string.Empty;

View File

@@ -40,6 +40,9 @@
Source="{x:Bind VideoPreviewer.Preview, Mode=OneWay}"
ToolTipService.ToolTip="{x:Bind ImageInfoTooltip, Mode=OneWay}"
Visibility="{x:Bind IsPreviewVisible(VideoPreviewer, Previewer.State), Mode=OneWay}">
<MediaPlayerElement.KeyboardAccelerators>
<KeyboardAccelerator Key="Space" Invoked="KeyboardAccelerator_Space_Invoked" />
</MediaPlayerElement.KeyboardAccelerators>
<MediaPlayerElement.TransportControls>
<MediaTransportControls
x:Name="mediaTransport"

View File

@@ -299,6 +299,28 @@ namespace Peek.FilePreviewer
}
}
private void KeyboardAccelerator_Space_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
{
var mediaPlayer = VideoPreview.MediaPlayer;
if (mediaPlayer.Source == null || !mediaPlayer.CanPause)
{
return;
}
if (mediaPlayer.CurrentState == Windows.Media.Playback.MediaPlayerState.Playing)
{
mediaPlayer.Pause();
}
else
{
mediaPlayer.Play();
}
// Prevent the keyboard accelerator to be called twice
args.Handled = true;
}
private async Task UpdateImageTooltipAsync(CancellationToken cancellationToken)
{
if (Item == null)

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using interop;
using ManagedCommon;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -11,6 +12,7 @@ using Microsoft.UI.Xaml;
using Peek.Common;
using Peek.FilePreviewer;
using Peek.FilePreviewer.Models;
using Peek.UI.Native;
using Peek.UI.Telemetry.Events;
using Peek.UI.Views;
@@ -28,7 +30,7 @@ namespace Peek.UI
get;
}
private Window? Window { get; set; }
private MainWindow? Window { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="App"/> class.
@@ -96,12 +98,32 @@ namespace Peek.UI
}
}
Window = new MainWindow();
NativeEventWaiter.WaitForEventLoop(Constants.ShowPeekEvent(), OnPeekHotkey);
}
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
{
PowerToysTelemetry.Log.WriteEvent(new ErrorEvent() { HResult = (Common.Models.HResult)e.Exception.HResult, Failure = ErrorEvent.FailureType.AppCrash });
}
/// <summary>
/// Handle Peek hotkey
/// </summary>
private void OnPeekHotkey()
{
// Need to read the foreground HWND before activating Peek to avoid focus stealing
// Foreground HWND must always be Explorer or Desktop
var foregroundWindowHandle = Windows.Win32.PInvoke.GetForegroundWindow();
bool firstActivation = false;
if (Window == null)
{
firstActivation = true;
Window = new MainWindow();
}
Window.Toggle(firstActivation, foregroundWindowHandle);
}
}
}

View File

@@ -1,9 +1,8 @@
// Copyright (c) Microsoft Corporation
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using interop;
using ManagedCommon;
using Microsoft.PowerToys.Telemetry;
using Microsoft.UI;
@@ -15,7 +14,6 @@ using Peek.Common.Extensions;
using Peek.FilePreviewer.Models;
using Peek.UI.Extensions;
using Peek.UI.Helpers;
using Peek.UI.Native;
using Peek.UI.Telemetry.Events;
using Windows.Foundation;
using WinUIEx;
@@ -30,7 +28,6 @@ namespace Peek.UI
public MainWindowViewModel ViewModel { get; }
private ThemeListener? themeListener;
private bool activated;
public MainWindow()
{
@@ -49,13 +46,40 @@ namespace Peek.UI
ViewModel = Application.Current.GetService<MainWindowViewModel>();
NativeEventWaiter.WaitForEventLoop(Constants.ShowPeekEvent(), OnPeekHotkey);
TitleBarControl.SetTitleBarToWindow(this);
AppWindow.Closing += AppWindow_Closing;
}
/// <summary>
/// Toggling the window visibility and querying files when necessary.
/// </summary>
public void Toggle(bool firstActivation, Windows.Win32.Foundation.HWND foregroundWindowHandle)
{
if (firstActivation)
{
Activate();
Initialize(foregroundWindowHandle);
return;
}
if (AppWindow.IsVisible)
{
if (IsNewSingleSelectedItem(foregroundWindowHandle))
{
Initialize(foregroundWindowHandle);
}
else
{
Uninitialize();
}
}
else
{
Initialize(foregroundWindowHandle);
}
}
private void HandleThemeChange()
{
AppWindow appWindow = this.AppWindow;
@@ -82,41 +106,6 @@ namespace Peek.UI
}
}
/// <summary>
/// Handle Peek hotkey, by toggling the window visibility and querying files when necessary.
/// </summary>
private void OnPeekHotkey()
{
// Need to read the foreground HWND before activating Peek to avoid focus stealing
// Foreground HWND must always be Explorer or Desktop
var foregroundWindowHandle = Windows.Win32.PInvoke.GetForegroundWindow();
// First Peek activation
if (!activated)
{
Activate();
Initialize(foregroundWindowHandle);
activated = true;
return;
}
if (AppWindow.IsVisible)
{
if (IsNewSingleSelectedItem(foregroundWindowHandle))
{
Initialize(foregroundWindowHandle);
}
else
{
Uninitialize();
}
}
else
{
Initialize(foregroundWindowHandle);
}
}
private void PreviousNavigationInvoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
{
ViewModel.AttemptPreviousNavigation();

View File

@@ -14,10 +14,12 @@ namespace PowerAccent.Core
CUR,
CY,
CZ,
DK,
GA,
GD,
DE,
EST,
FI,
FR,
HR,
HE,
@@ -52,10 +54,12 @@ namespace PowerAccent.Core
Language.CUR => GetDefaultLetterKeyCUR(letter), // Currency
Language.CY => GetDefaultLetterKeyCY(letter), // Welsh
Language.CZ => GetDefaultLetterKeyCZ(letter), // Czech
Language.DK => GetDefaultLetterKeyDK(letter), // Danish
Language.GA => GetDefaultLetterKeyGA(letter), // Gaeilge (Irish)
Language.GD => GetDefaultLetterKeyGD(letter), // Gàidhlig (Scottish Gaelic)
Language.DE => GetDefaultLetterKeyDE(letter), // German
Language.EST => GetDefaultLetterKeyEST(letter), // Estonian
Language.FI => GetDefaultLetterKeyFI(letter), // Finnish
Language.FR => GetDefaultLetterKeyFR(letter), // French
Language.HR => GetDefaultLetterKeyHR(letter), // Croatian
Language.HE => GetDefaultLetterKeyHE(letter), // Hebrew
@@ -93,10 +97,12 @@ namespace PowerAccent.Core
.Union(GetDefaultLetterKeyCUR(letter))
.Union(GetDefaultLetterKeyCY(letter))
.Union(GetDefaultLetterKeyCZ(letter))
.Union(GetDefaultLetterKeyDK(letter))
.Union(GetDefaultLetterKeyGA(letter))
.Union(GetDefaultLetterKeyGD(letter))
.Union(GetDefaultLetterKeyDE(letter))
.Union(GetDefaultLetterKeyEST(letter))
.Union(GetDefaultLetterKeyFI(letter))
.Union(GetDefaultLetterKeyFR(letter))
.Union(GetDefaultLetterKeyHR(letter))
.Union(GetDefaultLetterKeyHE(letter))
@@ -131,6 +137,13 @@ namespace PowerAccent.Core
{
return letter switch
{
LetterKey.VK_0 => new[] { "↉" },
LetterKey.VK_1 => new[] { "½", "⅓", "¼", "⅕", "⅙", "⅐", "⅛", "⅑", "⅒" },
LetterKey.VK_2 => new[] { "⅔", "⅖" },
LetterKey.VK_3 => new[] { "¾", "⅗", "⅜" },
LetterKey.VK_4 => new[] { "⅘" },
LetterKey.VK_5 => new[] { "⅚", "⅝" },
LetterKey.VK_7 => new[] { "⅞" },
LetterKey.VK_A => new[] { "α", "ά", "ȧ" },
LetterKey.VK_B => new[] { "ḃ", "β" },
LetterKey.VK_C => new[] { "ċ", "χ", "°C", "©", "" },
@@ -155,7 +168,7 @@ namespace PowerAccent.Core
LetterKey.VK_V => new[] { "V̇" },
LetterKey.VK_W => new[] { "ẇ" },
LetterKey.VK_X => new[] { "ẋ", "ξ", "×" },
LetterKey.VK_Y => new[] { "ẏ" },
LetterKey.VK_Y => new[] { "ẏ", "ꝡ" },
LetterKey.VK_Z => new[] { "ʒ", "ǯ", "ζ", "" },
LetterKey.VK_COMMA => new[] { "∙", "₋", "⁻", "" }, // is in VK_MINUS for other languages, but not VK_COMMA, so we add it here.
LetterKey.VK_PERIOD => new[] { "\u0300", "\u0301", "\u0302", "\u0303", "\u0304", "\u0308", "\u030C" },
@@ -200,6 +213,7 @@ namespace PowerAccent.Core
{
LetterKey.VK_C => new[] { "ć", "č" },
LetterKey.VK_D => new[] { "đ" },
LetterKey.VK_E => new[] { "€" },
LetterKey.VK_S => new[] { "š" },
LetterKey.VK_Z => new[] { "ž" },
_ => Array.Empty<string>(),
@@ -221,6 +235,18 @@ namespace PowerAccent.Core
};
}
// Finnish
private static string[] GetDefaultLetterKeyFI(LetterKey letter)
{
return letter switch
{
LetterKey.VK_A => new[] { "ä", "å" },
LetterKey.VK_E => new[] { "€" },
LetterKey.VK_O => new[] { "ö" },
_ => Array.Empty<string>(),
};
}
// French
private static string[] GetDefaultLetterKeyFR(LetterKey letter)
{
@@ -438,7 +464,7 @@ namespace PowerAccent.Core
return letter switch
{
LetterKey.VK_A => new[] { "á" },
LetterKey.VK_E => new[] { "é" },
LetterKey.VK_E => new[] { "é", "€" },
LetterKey.VK_I => new[] { "í" },
LetterKey.VK_O => new[] { "ó" },
LetterKey.VK_U => new[] { "ú" },
@@ -455,6 +481,7 @@ namespace PowerAccent.Core
LetterKey.VK_E => new[] { "è" },
LetterKey.VK_I => new[] { "ì" },
LetterKey.VK_O => new[] { "ò" },
LetterKey.VK_P => new[] { "£" },
LetterKey.VK_U => new[] { "ù" },
_ => Array.Empty<string>(),
};
@@ -588,6 +615,7 @@ namespace PowerAccent.Core
LetterKey.VK_E => new[] { "ê" },
LetterKey.VK_I => new[] { "î" },
LetterKey.VK_O => new[] { "ô" },
LetterKey.VK_P => new[] { "£" },
LetterKey.VK_U => new[] { "û" },
LetterKey.VK_Y => new[] { "ŷ" },
LetterKey.VK_W => new[] { "ŵ" },
@@ -644,6 +672,18 @@ namespace PowerAccent.Core
};
}
// Danish
private static string[] GetDefaultLetterKeyDK(LetterKey letter)
{
return letter switch
{
LetterKey.VK_A => new[] { "å", "æ" },
LetterKey.VK_E => new[] { "€" },
LetterKey.VK_O => new[] { "ø" },
_ => Array.Empty<string>(),
};
}
// Lithuanian
private static string[] GetDefaultLetterKeyLT(LetterKey letter)
{

View File

@@ -217,7 +217,7 @@
FontFamily="{ThemeResource SymbolThemeFontFamily}"
Visibility="{Binding ElementName=checkBox_regex, Path=IsChecked}">
<Button.Flyout>
<Flyout x:Name="RegExFlyout">
<Flyout x:Name="RegExFlyout" ShouldConstrainToRootBounds="False">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28" />

View File

@@ -17,7 +17,7 @@ namespace MarkdownPreviewHandlerUnitTests
public class MarkdownPreviewHandlerTest
{
// A long timeout is needed. WebView2 can take a long time to load the first time in some CI systems.
private static readonly int HardTimeoutInMilliseconds = 30000;
private static readonly int HardTimeoutInMilliseconds = 60000;
private static readonly int SleepTimeInMilliseconds = 200;
[TestMethod]

View File

@@ -4,9 +4,7 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Microsoft.PowerToys.PreviewHandler.Svg;
@@ -22,7 +20,7 @@ namespace SvgPreviewHandlerUnitTests
public class SvgPreviewControlTests
{
// A long timeout is needed. WebView2 can take a long time to load the first time in some CI systems.
private static readonly int HardTimeoutInMilliseconds = 30000;
private static readonly int HardTimeoutInMilliseconds = 60000;
private static readonly int SleepTimeInMilliseconds = 200;
[TestMethod]

View File

@@ -1,4 +1,5 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
<Target Name="IncrementalClean" />

View File

@@ -0,0 +1,199 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using global::PowerToys.GPOWrapper;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Views;
using Windows.UI;
namespace Microsoft.PowerToys.Settings.UI.Helpers
{
internal sealed class ModuleHelper
{
public static string GetModuleLabelResourceName(ModuleType moduleType)
{
switch (moduleType)
{
case ModuleType.PowerAccent: return "QuickAccent/ModuleTitle";
case ModuleType.PowerOCR: return "TextExtractor/ModuleTitle";
case ModuleType.FindMyMouse:
case ModuleType.MouseHighlighter:
case ModuleType.MouseJump:
case ModuleType.MousePointerCrosshairs: return $"MouseUtils_{moduleType}/Header";
default: return $"{moduleType}/ModuleTitle";
}
}
public static string GetModuleTypeFluentIconName(ModuleType moduleType)
{
switch (moduleType)
{
case ModuleType.MousePointerCrosshairs: return "ms-appx:///Assets/Settings/FluentIcons/FluentIconsMouseCrosshairs.png";
case ModuleType.MeasureTool: return "ms-appx:///Assets/Settings/FluentIcons/FluentIconsScreenRuler.png";
case ModuleType.PowerLauncher: return $"ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerToysRun.png";
default: return $"ms-appx:///Assets/Settings/FluentIcons/FluentIcons{moduleType}.png";
}
}
public static bool GetIsModuleEnabled(Library.GeneralSettings generalSettingsConfig, ModuleType moduleType)
{
switch (moduleType)
{
case ModuleType.AlwaysOnTop: return generalSettingsConfig.Enabled.AlwaysOnTop;
case ModuleType.Awake: return generalSettingsConfig.Enabled.Awake;
case ModuleType.ColorPicker: return generalSettingsConfig.Enabled.ColorPicker;
case ModuleType.CropAndLock: return generalSettingsConfig.Enabled.CropAndLock;
case ModuleType.EnvironmentVariables: return generalSettingsConfig.Enabled.EnvironmentVariables;
case ModuleType.FancyZones: return generalSettingsConfig.Enabled.FancyZones;
case ModuleType.FileLocksmith: return generalSettingsConfig.Enabled.FileLocksmith;
case ModuleType.FindMyMouse: return generalSettingsConfig.Enabled.FindMyMouse;
case ModuleType.Hosts: return generalSettingsConfig.Enabled.Hosts;
case ModuleType.ImageResizer: return generalSettingsConfig.Enabled.ImageResizer;
case ModuleType.KeyboardManager: return generalSettingsConfig.Enabled.KeyboardManager;
case ModuleType.MouseHighlighter: return generalSettingsConfig.Enabled.MouseHighlighter;
case ModuleType.MouseJump: return generalSettingsConfig.Enabled.MouseJump;
case ModuleType.MousePointerCrosshairs: return generalSettingsConfig.Enabled.MousePointerCrosshairs;
case ModuleType.MouseWithoutBorders: return generalSettingsConfig.Enabled.MouseWithoutBorders;
case ModuleType.PastePlain: return generalSettingsConfig.Enabled.PastePlain;
case ModuleType.Peek: return generalSettingsConfig.Enabled.Peek;
case ModuleType.PowerRename: return generalSettingsConfig.Enabled.PowerRename;
case ModuleType.PowerLauncher: return generalSettingsConfig.Enabled.PowerLauncher;
case ModuleType.PowerAccent: return generalSettingsConfig.Enabled.PowerAccent;
case ModuleType.RegistryPreview: return generalSettingsConfig.Enabled.RegistryPreview;
case ModuleType.MeasureTool: return generalSettingsConfig.Enabled.MeasureTool;
case ModuleType.ShortcutGuide: return generalSettingsConfig.Enabled.ShortcutGuide;
case ModuleType.PowerOCR: return generalSettingsConfig.Enabled.PowerOCR;
default: return false;
}
}
internal static void SetIsModuleEnabled(GeneralSettings generalSettingsConfig, ModuleType moduleType, bool isEnabled)
{
switch (moduleType)
{
case ModuleType.AlwaysOnTop: generalSettingsConfig.Enabled.AlwaysOnTop = isEnabled; break;
case ModuleType.Awake: generalSettingsConfig.Enabled.Awake = isEnabled; break;
case ModuleType.ColorPicker: generalSettingsConfig.Enabled.ColorPicker = isEnabled; break;
case ModuleType.CropAndLock: generalSettingsConfig.Enabled.CropAndLock = isEnabled; break;
case ModuleType.EnvironmentVariables: generalSettingsConfig.Enabled.EnvironmentVariables = isEnabled; break;
case ModuleType.FancyZones: generalSettingsConfig.Enabled.FancyZones = isEnabled; break;
case ModuleType.FileLocksmith: generalSettingsConfig.Enabled.FileLocksmith = isEnabled; break;
case ModuleType.FindMyMouse: generalSettingsConfig.Enabled.FindMyMouse = isEnabled; break;
case ModuleType.Hosts: generalSettingsConfig.Enabled.Hosts = isEnabled; break;
case ModuleType.ImageResizer: generalSettingsConfig.Enabled.ImageResizer = isEnabled; break;
case ModuleType.KeyboardManager: generalSettingsConfig.Enabled.KeyboardManager = isEnabled; break;
case ModuleType.MouseHighlighter: generalSettingsConfig.Enabled.MouseHighlighter = isEnabled; break;
case ModuleType.MouseJump: generalSettingsConfig.Enabled.MouseJump = isEnabled; break;
case ModuleType.MousePointerCrosshairs: generalSettingsConfig.Enabled.MousePointerCrosshairs = isEnabled; break;
case ModuleType.MouseWithoutBorders: generalSettingsConfig.Enabled.MouseWithoutBorders = isEnabled; break;
case ModuleType.PastePlain: generalSettingsConfig.Enabled.PastePlain = isEnabled; break;
case ModuleType.Peek: generalSettingsConfig.Enabled.Peek = isEnabled; break;
case ModuleType.PowerRename: generalSettingsConfig.Enabled.PowerRename = isEnabled; break;
case ModuleType.PowerLauncher: generalSettingsConfig.Enabled.PowerLauncher = isEnabled; break;
case ModuleType.PowerAccent: generalSettingsConfig.Enabled.PowerAccent = isEnabled; break;
case ModuleType.RegistryPreview: generalSettingsConfig.Enabled.RegistryPreview = isEnabled; break;
case ModuleType.MeasureTool: generalSettingsConfig.Enabled.MeasureTool = isEnabled; break;
case ModuleType.ShortcutGuide: generalSettingsConfig.Enabled.ShortcutGuide = isEnabled; break;
case ModuleType.PowerOCR: generalSettingsConfig.Enabled.PowerOCR = isEnabled; break;
}
}
public static GpoRuleConfigured GetModuleGpoConfiguration(ModuleType moduleType)
{
switch (moduleType)
{
case ModuleType.AlwaysOnTop: return GPOWrapper.GetConfiguredAlwaysOnTopEnabledValue();
case ModuleType.Awake: return GPOWrapper.GetConfiguredAwakeEnabledValue();
case ModuleType.ColorPicker: return GPOWrapper.GetConfiguredColorPickerEnabledValue();
case ModuleType.CropAndLock: return GPOWrapper.GetConfiguredCropAndLockEnabledValue();
case ModuleType.EnvironmentVariables: return GPOWrapper.GetConfiguredEnvironmentVariablesEnabledValue();
case ModuleType.FancyZones: return GPOWrapper.GetConfiguredFancyZonesEnabledValue();
case ModuleType.FileLocksmith: return GPOWrapper.GetConfiguredFileLocksmithEnabledValue();
case ModuleType.FindMyMouse: return GPOWrapper.GetConfiguredFindMyMouseEnabledValue();
case ModuleType.Hosts: return GPOWrapper.GetConfiguredHostsFileEditorEnabledValue();
case ModuleType.ImageResizer: return GPOWrapper.GetConfiguredImageResizerEnabledValue();
case ModuleType.KeyboardManager: return GPOWrapper.GetConfiguredKeyboardManagerEnabledValue();
case ModuleType.MouseHighlighter: return GPOWrapper.GetConfiguredMouseHighlighterEnabledValue();
case ModuleType.MouseJump: return GPOWrapper.GetConfiguredMouseJumpEnabledValue();
case ModuleType.MousePointerCrosshairs: return GPOWrapper.GetConfiguredMousePointerCrosshairsEnabledValue();
case ModuleType.MouseWithoutBorders: return GPOWrapper.GetConfiguredMouseWithoutBordersEnabledValue();
case ModuleType.PastePlain: return GPOWrapper.GetConfiguredPastePlainEnabledValue();
case ModuleType.Peek: return GPOWrapper.GetConfiguredPeekEnabledValue();
case ModuleType.PowerRename: return GPOWrapper.GetConfiguredPowerRenameEnabledValue();
case ModuleType.PowerLauncher: return GPOWrapper.GetConfiguredPowerLauncherEnabledValue();
case ModuleType.PowerAccent: return GPOWrapper.GetConfiguredQuickAccentEnabledValue();
case ModuleType.RegistryPreview: return GPOWrapper.GetConfiguredRegistryPreviewEnabledValue();
case ModuleType.MeasureTool: return GPOWrapper.GetConfiguredScreenRulerEnabledValue();
case ModuleType.ShortcutGuide: return GPOWrapper.GetConfiguredShortcutGuideEnabledValue();
case ModuleType.PowerOCR: return GPOWrapper.GetConfiguredTextExtractorEnabledValue();
default: return GpoRuleConfigured.Unavailable;
}
}
public static Color GetModuleAccentColor(ModuleType moduleType)
{
return moduleType switch
{
ModuleType.AlwaysOnTop => Color.FromArgb(255, 74, 196, 242), // #4ac4f2
ModuleType.Awake => Color.FromArgb(255, 40, 177, 233), // #28b1e9
ModuleType.ColorPicker => Color.FromArgb(255, 7, 129, 211), // #0781d3
ModuleType.CropAndLock => Color.FromArgb(255, 32, 166, 228), // #20a6e4
ModuleType.EnvironmentVariables => Color.FromArgb(255, 16, 132, 208), // #1084d0
ModuleType.FancyZones => Color.FromArgb(255, 65, 209, 247), // #41d1f7
ModuleType.FileLocksmith => Color.FromArgb(255, 245, 161, 20), // #f5a114
ModuleType.FindMyMouse => Color.FromArgb(255, 104, 109, 112), // #686d70
ModuleType.Hosts => Color.FromArgb(255, 16, 132, 208), // #1084d0
ModuleType.ImageResizer => Color.FromArgb(255, 85, 207, 248), // #55cff8
ModuleType.KeyboardManager => Color.FromArgb(255, 224, 231, 238), // #e0e7ee
ModuleType.MouseHighlighter => Color.FromArgb(255, 17, 126, 199), // #117ec7
ModuleType.MouseJump => Color.FromArgb(255, 240, 240, 239), // #f0f0ef
ModuleType.MousePointerCrosshairs => Color.FromArgb(255, 25, 115, 182), // #1973b6
ModuleType.MouseWithoutBorders => Color.FromArgb(255, 31, 164, 227), // #1fa4e3
ModuleType.PastePlain => Color.FromArgb(255, 243, 156, 16), // #f39c10
ModuleType.Peek => Color.FromArgb(255, 255, 214, 103), // #ffd667
ModuleType.PowerRename => Color.FromArgb(255, 43, 186, 243), // #2bbaf3
ModuleType.PowerLauncher => Color.FromArgb(255, 51, 191, 240), // #33bff0
ModuleType.PowerAccent => Color.FromArgb(255, 84, 89, 92), // #54595c
ModuleType.RegistryPreview => Color.FromArgb(255, 17, 80, 138), // #11508a
ModuleType.MeasureTool => Color.FromArgb(255, 135, 144, 153), // #879099
ModuleType.ShortcutGuide => Color.FromArgb(255, 193, 202, 209), // #c1cad1
ModuleType.PowerOCR => Color.FromArgb(255, 24, 153, 224), // #1899e0
_ => Color.FromArgb(255, 255, 255, 255), // never called, all values listed above
};
}
public static System.Type GetModulePageType(ModuleType moduleType)
{
return moduleType switch
{
ModuleType.AlwaysOnTop => typeof(AlwaysOnTopPage),
ModuleType.Awake => typeof(AwakePage),
ModuleType.ColorPicker => typeof(ColorPickerPage),
ModuleType.CropAndLock => typeof(CropAndLockPage),
ModuleType.EnvironmentVariables => typeof(EnvironmentVariablesPage),
ModuleType.FancyZones => typeof(FancyZonesPage),
ModuleType.FileLocksmith => typeof(FileLocksmithPage),
ModuleType.FindMyMouse => typeof(MouseUtilsPage),
ModuleType.Hosts => typeof(HostsPage),
ModuleType.ImageResizer => typeof(ImageResizerPage),
ModuleType.KeyboardManager => typeof(KeyboardManagerPage),
ModuleType.MouseHighlighter => typeof(MouseUtilsPage),
ModuleType.MouseJump => typeof(MouseUtilsPage),
ModuleType.MousePointerCrosshairs => typeof(MouseUtilsPage),
ModuleType.MouseWithoutBorders => typeof(MouseWithoutBordersPage),
ModuleType.PastePlain => typeof(PastePlainPage),
ModuleType.Peek => typeof(PeekPage),
ModuleType.PowerRename => typeof(PowerRenamePage),
ModuleType.PowerLauncher => typeof(PowerLauncherPage),
ModuleType.PowerAccent => typeof(PowerAccentPage),
ModuleType.RegistryPreview => typeof(RegistryPreviewPage),
ModuleType.MeasureTool => typeof(MeasureToolPage),
ModuleType.ShortcutGuide => typeof(ShortcutGuidePage),
ModuleType.PowerOCR => typeof(PowerOcrPage),
_ => typeof(DashboardPage), // never called, all values listed above
};
}
}
}

View File

@@ -26,7 +26,7 @@
</Border.Background>
</Border>
<DropDownButton.Flyout>
<Flyout>
<Flyout ShouldConstrainToRootBounds="False">
<ColorPicker
IsAlphaEnabled="True"
IsAlphaSliderVisible="True"

View File

@@ -26,7 +26,7 @@
</Border.Background>
</Border>
<DropDownButton.Flyout>
<Flyout>
<Flyout ShouldConstrainToRootBounds="False">
<ColorPicker
IsAlphaEnabled="False"
IsAlphaSliderVisible="False"

View File

@@ -5,6 +5,7 @@ using System;
using System.Threading;
using global::Windows.System;
using interop;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Controls;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Telemetry.Events;
@@ -37,16 +38,16 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
// Closing manually the flyout to workaround focus gain problems
App.GetFlyoutWindow()?.Hide();
switch ((string)selectedModuleBtn.Tag)
switch ((ModuleType)selectedModuleBtn.Tag)
{
case "ColorPicker": // Launch ColorPicker
case ModuleType.ColorPicker: // Launch ColorPicker
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShowColorPickerSharedEvent()))
{
eventHandle.Set();
}
break;
case "EnvironmentVariables": // Launch Environment Variables
case ModuleType.EnvironmentVariables: // Launch Environment Variables
{
bool launchAdmin = SettingsRepository<EnvironmentVariablesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.LaunchAdministrator;
string eventName = !App.IsElevated && launchAdmin
@@ -61,7 +62,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
break;
case "FancyZones": // Launch FancyZones Editor
case ModuleType.FancyZones: // Launch FancyZones Editor
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.FZEToggleEvent()))
{
eventHandle.Set();
@@ -69,7 +70,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
break;
case "Hosts": // Launch Hosts
case ModuleType.Hosts: // Launch Hosts
{
bool launchAdmin = SettingsRepository<HostsSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.LaunchAdministrator;
string eventName = !App.IsElevated && launchAdmin
@@ -84,14 +85,14 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
break;
case "RegistryPreview": // Launch Registry Preview
case ModuleType.RegistryPreview: // Launch Registry Preview
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.RegistryPreviewTriggerEvent()))
{
eventHandle.Set();
}
break;
case "MeasureTool": // Launch Screen Ruler
case ModuleType.MeasureTool: // Launch Screen Ruler
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.MeasureToolTriggerEvent()))
{
eventHandle.Set();
@@ -99,7 +100,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
break;
case "PowerLauncher": // Launch Run
case ModuleType.PowerLauncher: // Launch Run
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.PowerLauncherSharedEvent()))
{
eventHandle.Set();
@@ -107,7 +108,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
break;
case "PowerOCR": // Launch Text Extractor
case ModuleType.PowerOCR: // Launch Text Extractor
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShowPowerOCRSharedEvent()))
{
eventHandle.Set();
@@ -115,7 +116,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
break;
case "ShortcutGuide": // Launch Shortcut Guide
case ModuleType.ShortcutGuide: // Launch Shortcut Guide
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShortcutGuideTriggerEvent()))
{
eventHandle.Set();
@@ -130,7 +131,7 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout
if (moduleRun)
{
PowerToysTelemetry.Log.WriteEvent(new TrayFlyoutModuleRunEvent() { ModuleName = (string)selectedModuleBtn.Tag });
PowerToysTelemetry.Log.WriteEvent(new TrayFlyoutModuleRunEvent() { ModuleName = ((ModuleType)selectedModuleBtn.Tag).ToString() });
}
}

View File

@@ -81,92 +81,15 @@ namespace Microsoft.PowerToys.Settings.UI
});
// open main window
ShellPage.SetUpdatingGeneralSettingsCallback((string module, bool isEnabled) =>
ShellPage.SetUpdatingGeneralSettingsCallback((ModuleType moduleType, bool isEnabled) =>
{
SettingsRepository<GeneralSettings> repository = SettingsRepository<GeneralSettings>.GetInstance(new SettingsUtils());
GeneralSettings generalSettingsConfig = repository.SettingsConfig;
bool needToUpdate = false;
switch (module)
{
case "AlwaysOnTop":
needToUpdate = generalSettingsConfig.Enabled.AlwaysOnTop != isEnabled;
generalSettingsConfig.Enabled.AlwaysOnTop = isEnabled; break;
case "Awake":
needToUpdate = generalSettingsConfig.Enabled.Awake != isEnabled;
generalSettingsConfig.Enabled.Awake = isEnabled; break;
case "ColorPicker":
needToUpdate = generalSettingsConfig.Enabled.ColorPicker != isEnabled;
generalSettingsConfig.Enabled.ColorPicker = isEnabled; break;
case "CropAndLock":
needToUpdate = generalSettingsConfig.Enabled.CropAndLock != isEnabled;
generalSettingsConfig.Enabled.CropAndLock = isEnabled; break;
case "EnvironmentVariables":
needToUpdate = generalSettingsConfig.Enabled.EnvironmentVariables != isEnabled;
generalSettingsConfig.Enabled.EnvironmentVariables = isEnabled; break;
case "FancyZones":
needToUpdate = generalSettingsConfig.Enabled.FancyZones != isEnabled;
generalSettingsConfig.Enabled.FancyZones = isEnabled; break;
case "FileLocksmith":
needToUpdate = generalSettingsConfig.Enabled.FileLocksmith != isEnabled;
generalSettingsConfig.Enabled.FileLocksmith = isEnabled; break;
case "FindMyMouse":
needToUpdate = generalSettingsConfig.Enabled.FindMyMouse != isEnabled;
generalSettingsConfig.Enabled.FindMyMouse = isEnabled; break;
case "Hosts":
needToUpdate = generalSettingsConfig.Enabled.Hosts != isEnabled;
generalSettingsConfig.Enabled.Hosts = isEnabled; break;
case "ImageResizer":
needToUpdate = generalSettingsConfig.Enabled.ImageResizer != isEnabled;
generalSettingsConfig.Enabled.ImageResizer = isEnabled; break;
case "KeyboardManager":
needToUpdate = generalSettingsConfig.Enabled.KeyboardManager != isEnabled;
generalSettingsConfig.Enabled.KeyboardManager = isEnabled; break;
case "MouseHighlighter":
needToUpdate = generalSettingsConfig.Enabled.MouseHighlighter != isEnabled;
generalSettingsConfig.Enabled.MouseHighlighter = isEnabled; break;
case "MouseJump":
needToUpdate = generalSettingsConfig.Enabled.MouseJump != isEnabled;
generalSettingsConfig.Enabled.MouseJump = isEnabled; break;
case "MousePointerCrosshairs":
needToUpdate = generalSettingsConfig.Enabled.MousePointerCrosshairs != isEnabled;
generalSettingsConfig.Enabled.MousePointerCrosshairs = isEnabled; break;
case "MouseWithoutBorders":
needToUpdate = generalSettingsConfig.Enabled.MouseWithoutBorders != isEnabled;
generalSettingsConfig.Enabled.MouseWithoutBorders = isEnabled; break;
case "PastePlain":
needToUpdate = generalSettingsConfig.Enabled.PastePlain != isEnabled;
generalSettingsConfig.Enabled.PastePlain = isEnabled; break;
case "Peek":
needToUpdate = generalSettingsConfig.Enabled.Peek != isEnabled;
generalSettingsConfig.Enabled.Peek = isEnabled; break;
case "PowerRename":
needToUpdate = generalSettingsConfig.Enabled.PowerRename != isEnabled;
generalSettingsConfig.Enabled.PowerRename = isEnabled; break;
case "PowerLauncher":
needToUpdate = generalSettingsConfig.Enabled.PowerLauncher != isEnabled;
generalSettingsConfig.Enabled.PowerLauncher = isEnabled; break;
case "PowerAccent":
needToUpdate = generalSettingsConfig.Enabled.PowerAccent != isEnabled;
generalSettingsConfig.Enabled.PowerAccent = isEnabled; break;
case "RegistryPreview":
needToUpdate = generalSettingsConfig.Enabled.RegistryPreview != isEnabled;
generalSettingsConfig.Enabled.RegistryPreview = isEnabled; break;
case "MeasureTool":
needToUpdate = generalSettingsConfig.Enabled.MeasureTool != isEnabled;
generalSettingsConfig.Enabled.MeasureTool = isEnabled; break;
case "ShortcutGuide":
needToUpdate = generalSettingsConfig.Enabled.ShortcutGuide != isEnabled;
generalSettingsConfig.Enabled.ShortcutGuide = isEnabled; break;
case "PowerOCR":
needToUpdate = generalSettingsConfig.Enabled.PowerOCR != isEnabled;
generalSettingsConfig.Enabled.PowerOCR = isEnabled; break;
case "VideoConference":
needToUpdate = generalSettingsConfig.Enabled.VideoConference != isEnabled;
generalSettingsConfig.Enabled.VideoConference = isEnabled; break;
}
bool needToUpdate = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType) != isEnabled;
if (needToUpdate)
{
ModuleHelper.SetIsModuleEnabled(generalSettingsConfig, moduleType, isEnabled);
var outgoing = new OutGoingGeneralSettings(generalSettingsConfig);
this.DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal, () =>
{

View File

@@ -1,22 +1,65 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="SubtleButtonBackground" Color="{ThemeResource SubtleFillColorTransparent}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundPointerOver" Color="{ThemeResource SubtleFillColorSecondary}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundPressed" Color="{ThemeResource SubtleFillColorTertiary}" />
<SolidColorBrush x:Key="SubtleButtonBackgroundDisabled" Color="{ThemeResource SubtleFillColorTransparent}" />
<SolidColorBrush x:Key="SubtleButtonForeground" Color="{ThemeResource TextFillColorPrimary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundPointerOver" Color="{ThemeResource TextFillColorPrimary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundPressed" Color="{ThemeResource TextFillColorSecondary}" />
<SolidColorBrush x:Key="SubtleButtonForegroundDisabled" Color="{ThemeResource TextFillColorDisabled}" />
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="TextFillColorSecondary" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="TextFillColorDisabled" />
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SubtleFillColorTransparent" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="TextFillColorPrimary" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="TextFillColorSecondary" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="TextFillColorDisabled" />
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<StaticResource x:Key="SubtleButtonBackground" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundPointerOver" ResourceKey="SystemColorHighlightTextColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundPressed" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBackgroundDisabled" ResourceKey="SystemControlBackgroundBaseLowBrush" />
<StaticResource x:Key="SubtleButtonBorderBrush" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushPointerOver" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushPressed" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="SubtleButtonBorderBrushDisabled" ResourceKey="SystemColorGrayTextColor" />
<StaticResource x:Key="SubtleButtonForeground" ResourceKey="SystemColorButtonTextColorBrush" />
<StaticResource x:Key="SubtleButtonForegroundPointerOver" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SubtleButtonForegroundPressed" ResourceKey="SystemControlHighlightBaseHighBrush" />
<StaticResource x:Key="SubtleButtonForegroundDisabled" ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<Style x:Key="SubtleButtonStyle" TargetType="Button">
<Setter Property="Background" Value="{ThemeResource SubtleButtonBackground}" />
<Setter Property="BackgroundSizing" Value="InnerBorderEdge" />
<Setter Property="Foreground" Value="{ThemeResource SubtleButtonForeground}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Width" Value="36" />
<Setter Property="Padding" Value="0" />
<Setter Property="Height" Value="36" />
<Setter Property="BorderBrush" Value="{ThemeResource SubtleButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}" />
<Setter Property="Padding" Value="{StaticResource ButtonPadding}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
@@ -43,11 +86,11 @@
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
CornerRadius="{TemplateBinding CornerRadius}">
CornerRadius="{TemplateBinding CornerRadius}"
Foreground="{TemplateBinding Foreground}">
<ContentPresenter.BackgroundTransition>
<BrushTransition Duration="0:0:0.083" />
</ContentPresenter.BackgroundTransition>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
@@ -56,6 +99,9 @@
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
@@ -64,12 +110,14 @@
<Setter Target="ContentPresenter.(AnimatedIcon.State)" Value="PointerOver" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundPressed}" />
</ObjectAnimationUsingKeyFrames>
@@ -78,12 +126,14 @@
<Setter Target="ContentPresenter.(AnimatedIcon.State)" Value="Pressed" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBackgroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonBorderBrushDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SubtleButtonForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>

View File

@@ -14,8 +14,8 @@
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="InfoBarInformationalSeverityBackgroundBrush" Color="#FF34424d" />
<SolidColorBrush x:Key="SolidBackgroundBrush" Color="Black" />
<SolidColorBrush x:Key="InfoBarInformationalSeverityBackgroundBrush" Color="{StaticResource SystemColorWindowColor}" />
<SolidColorBrush x:Key="SolidBackgroundBrush" Color="{StaticResource SystemColorWindowTextColor}" />
<Color x:Key="InfoBarInformationalSeverityIconBackground">#FF5fb2f2</Color>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

View File

@@ -1,4 +1,4 @@
<Page
<Page
x:Class="Microsoft.PowerToys.Settings.UI.Views.DashboardPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -101,7 +101,10 @@
<DataTemplate x:Key="ModuleItemKBMTemplate" x:DataType="viewmodels:DashboardModuleKBMItem">
<Button x:Uid="DashboardKBMShowMappingsButton" HorizontalAlignment="Stretch">
<Button.Flyout>
<Flyout x:Name="DetailsFlyout" Placement="Bottom">
<Flyout
x:Name="DetailsFlyout"
Placement="Bottom"
ShouldConstrainToRootBounds="False">
<StackPanel Orientation="Vertical" Spacing="4">
<ItemsControl ItemsSource="{x:Bind Path=RemapKeys, Mode=OneWay}">
<ItemsControl.ItemsPanel>
@@ -300,77 +303,86 @@
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="viewmodels:DashboardListItem">
<Grid
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{StaticResource OverlayCornerRadius}"
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Border Grid.RowSpan="2" Opacity="0.05">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,3">
<GradientStop Offset="0.5" Color="{x:Bind AccentColor, Mode=OneWay}" />
<GradientStop Offset="0.9" Color="Transparent" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Grid Margin="16,8,16,0" ColumnSpacing="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Width="20" Margin="0,0,0,0">
<Image.Source>
<BitmapImage UriSource="{x:Bind Icon, Mode=OneWay}" />
</Image.Source>
</Image>
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="{x:Bind Label, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
<FontIcon
Grid.Column="2"
Width="20"
Margin="0,0,-12,0"
FontSize="16"
Glyph="&#xE72E;"
Visibility="{x:Bind IsLocked, Converter={StaticResource BoolToInvertedVisibilityConverter}, ConverterParameter=True, Mode=OneWay}">
<ToolTipService.ToolTip>
<TextBlock x:Uid="GPO_IsSettingForcedText" TextWrapping="WrapWholeWords" />
</ToolTipService.ToolTip>
</FontIcon>
<ToggleSwitch
Grid.Column="3"
Margin="0,-2,0,0"
HorizontalAlignment="Right"
IsEnabled="{x:Bind IsLocked, Converter={StaticResource BoolNegationConverter}, ConverterParameter=True, Mode=OneWay}"
IsOn="{x:Bind IsEnabled, Mode=TwoWay}"
OffContent=""
OnContent=""
Style="{StaticResource RightAlignedCompactToggleSwitchStyle}" />
</Grid>
<Button
Padding="0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Background="Transparent"
BorderThickness="0"
Click="DashboardListItemClick"
Tag="{x:Bind Tag, Mode=OneWay}">
<Grid
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{StaticResource OverlayCornerRadius}"
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Border Grid.RowSpan="2" Opacity="0.05">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,3">
<GradientStop Offset="0.5" Color="{x:Bind AccentColor, Mode=OneWay}" />
<GradientStop Offset="0.9" Color="Transparent" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Grid Margin="16,8,16,0" ColumnSpacing="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Width="20" Margin="0,0,0,0">
<Image.Source>
<BitmapImage UriSource="{x:Bind Icon, Mode=OneWay}" />
</Image.Source>
</Image>
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="{x:Bind Label, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
<FontIcon
Grid.Column="2"
Width="20"
Margin="0,0,-12,0"
FontSize="16"
Glyph="&#xE72E;"
Visibility="{x:Bind IsLocked, Converter={StaticResource BoolToInvertedVisibilityConverter}, ConverterParameter=True, Mode=OneWay}">
<ToolTipService.ToolTip>
<TextBlock x:Uid="GPO_IsSettingForcedText" TextWrapping="WrapWholeWords" />
</ToolTipService.ToolTip>
</FontIcon>
<ToggleSwitch
Grid.Column="3"
Margin="0,-2,0,0"
HorizontalAlignment="Right"
IsEnabled="{x:Bind IsLocked, Converter={StaticResource BoolNegationConverter}, ConverterParameter=True, Mode=OneWay}"
IsOn="{x:Bind IsEnabled, Mode=TwoWay}"
OffContent=""
OnContent=""
Style="{StaticResource RightAlignedCompactToggleSwitchStyle}" />
</Grid>
<ItemsControl
Grid.Row="1"
Margin="16,8,16,16"
ItemTemplateSelector="{StaticResource ModuleItemTemplateSelector}"
ItemsSource="{x:Bind DashboardModuleItems, Mode=OneWay}"
Visibility="{x:Bind IsEnabled, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Spacing="4" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
<ItemsControl
Grid.Row="1"
Margin="16,8,16,16"
ItemTemplateSelector="{StaticResource ModuleItemTemplateSelector}"
ItemsSource="{x:Bind DashboardModuleItems, Mode=OneWay}"
Visibility="{x:Bind IsEnabled, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Spacing="4" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
</Button>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
@@ -389,53 +401,62 @@
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="viewmodels:DashboardListItem">
<Grid
Padding="16,12"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{StaticResource OverlayCornerRadius}"
RowSpacing="12">
<Grid ColumnSpacing="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Width="20">
<Image.Source>
<BitmapImage UriSource="{x:Bind Icon, Mode=OneWay}" />
</Image.Source>
</Image>
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="{x:Bind Label, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
<FontIcon
Grid.Column="2"
Width="20"
Margin="0,0,-12,0"
FontSize="16"
Glyph="&#xE72E;"
Visibility="{x:Bind IsLocked, Converter={StaticResource BoolToInvertedVisibilityConverter}, ConverterParameter=True, Mode=OneWay}">
<ToolTipService.ToolTip>
<TextBlock x:Uid="GPO_IsSettingForcedText" TextWrapping="WrapWholeWords" />
</ToolTipService.ToolTip>
</FontIcon>
<ToggleSwitch
Grid.Column="3"
Margin="0,-2,0,0"
HorizontalAlignment="Right"
IsEnabled="{x:Bind IsLocked, Converter={StaticResource BoolNegationConverter}, ConverterParameter=True, Mode=OneWay}"
IsOn="{x:Bind IsEnabled, Mode=TwoWay}"
OffContent=""
OnContent=""
Style="{StaticResource RightAlignedCompactToggleSwitchStyle}" />
<Button
Padding="0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Background="Transparent"
BorderThickness="0"
Click="DashboardListItemClick"
Tag="{x:Bind Tag, Mode=OneWay}">
<Grid
Padding="16,12"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{StaticResource OverlayCornerRadius}"
RowSpacing="12">
<Grid ColumnSpacing="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Width="20">
<Image.Source>
<BitmapImage UriSource="{x:Bind Icon, Mode=OneWay}" />
</Image.Source>
</Image>
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="{x:Bind Label, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
<FontIcon
Grid.Column="2"
Width="20"
Margin="0,0,-12,0"
FontSize="16"
Glyph="&#xE72E;"
Visibility="{x:Bind IsLocked, Converter={StaticResource BoolToInvertedVisibilityConverter}, ConverterParameter=True, Mode=OneWay}">
<ToolTipService.ToolTip>
<TextBlock x:Uid="GPO_IsSettingForcedText" TextWrapping="WrapWholeWords" />
</ToolTipService.ToolTip>
</FontIcon>
<ToggleSwitch
Grid.Column="3"
Margin="0,-2,0,0"
HorizontalAlignment="Right"
IsEnabled="{x:Bind IsLocked, Converter={StaticResource BoolNegationConverter}, ConverterParameter=True, Mode=OneWay}"
IsOn="{x:Bind IsEnabled, Mode=TwoWay}"
OffContent=""
OnContent=""
Style="{StaticResource RightAlignedCompactToggleSwitchStyle}" />
</Grid>
</Grid>
</Grid>
</Button>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>

View File

@@ -50,9 +50,9 @@ namespace Microsoft.PowerToys.Settings.UI.Views
ViewModel.SWVersionButtonClicked();
}
private void SettingsButtonClicked(object sender, RoutedEventArgs e)
private void DashboardListItemClick(object sender, RoutedEventArgs e)
{
ViewModel.SettingsButtonClicked(sender);
ViewModel.DashboardListItemClick(sender);
}
}
}

View File

@@ -236,17 +236,18 @@
</StackPanel>
<controls:SettingsExpander.Items>
<controls:SettingsCard x:Uid="General_SettingsBackupAndRestoreLocationText">
<StackPanel
HorizontalAlignment="Right"
Orientation="Horizontal"
Spacing="8">
<Grid ColumnSpacing="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
x:Name="pathTextBlock"
VerticalAlignment="Center"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
IsTextSelectionEnabled="True"
Text="{x:Bind Mode=TwoWay, Path=ViewModel.SettingsBackupAndRestoreDir}"
TextTrimming="CharacterEllipsis">
TextWrapping="Wrap">
<ToolTipService.ToolTip>
<ToolTip IsEnabled="{Binding ElementName=pathTextBlock, Path=IsTextTrimmed}">
<TextBlock Text="{x:Bind Mode=TwoWay, Path=ViewModel.SettingsBackupAndRestoreDir}" />
@@ -254,6 +255,7 @@
</ToolTipService.ToolTip>
</TextBlock>
<Button
Grid.Column="1"
Command="{Binding SelectSettingBackupDirEventHandler}"
Content="&#xe8da;"
FontFamily="{ThemeResource SymbolThemeFontFamily}">
@@ -263,15 +265,18 @@
</ToolTip>
</ToolTipService.ToolTip>
</Button>
</StackPanel>
</Grid>
</controls:SettingsCard>
<controls:SettingsCard
x:Uid="General_SettingsBackupAndRestoreStatusInfo"
HorizontalContentAlignment="Left"
ContentAlignment="Vertical">
<Grid Margin="0,0,0,6" ColumnSpacing="8">
<Grid
Margin="0,0,0,6"
ColumnSpacing="36"
RowSpacing="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="{StaticResource SettingActionControlMinWidth}" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
@@ -281,7 +286,10 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock x:Uid="General_SettingsBackupInfo_StatusHeader" />
<TextBlock Grid.Column="1" Foreground="{ThemeResource TextFillColorSecondaryBrush}">
<TextBlock
Grid.Column="1"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
TextWrapping="WrapWholeWords">
<Run Text="{Binding CurrentSettingMatchText, Mode=OneWay}" />
<Hyperlink Click="UpdateBackupAndRestoreStatusText" TextDecorations="Underline">
<Run x:Uid="General_SettingsBackupAndRestore_LinkRefresh" />
@@ -293,20 +301,23 @@
Grid.Row="1"
Grid.Column="1"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{Binding LastSettingsBackupFileName, Mode=OneWay}" />
Text="{Binding LastSettingsBackupFileName, Mode=OneWay}"
TextWrapping="WrapWholeWords" />
<TextBlock x:Uid="General_SettingsBackupInfo_SourceHeader" Grid.Row="2" />
<TextBlock
Grid.Row="2"
Grid.Column="1"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{Binding LastSettingsBackupSource, Mode=OneWay}" />
Text="{Binding LastSettingsBackupSource, Mode=OneWay}"
TextWrapping="WrapWholeWords" />
<TextBlock x:Uid="General_SettingsBackupInfo_DateHeader" Grid.Row="3" />
<TextBlock
Grid.Row="3"
Grid.Column="1"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{Binding LastSettingsBackupDate, Mode=OneWay}" />
Text="{Binding LastSettingsBackupDate, Mode=OneWay}"
TextWrapping="WrapWholeWords" />
</Grid>
</controls:SettingsCard>
</controls:SettingsExpander.Items>

View File

@@ -77,7 +77,6 @@
AutomationProperties.AccessibilityView="Raw"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="10"
Foreground="{ThemeResource SystemBaseMediumColor}"
Style="{ThemeResource SecondaryTextStyle}"
Text="&#xE947;"
Visibility="{x:Bind Path=EnableEtraBoxes, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
@@ -89,7 +88,6 @@
Visibility="{x:Bind Path=EnableEtraBoxes, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
<TextBlock
Margin="0,0,4,0"
Foreground="{ThemeResource SystemBaseMediumColor}"
Style="{ThemeResource SecondaryTextStyle}"
Text="{x:Bind Unit, Mode=OneWay, Converter={StaticResource ImageResizerUnitToStringConverter}, ConverterParameter=ToLower}" />
</StackPanel>
@@ -110,8 +108,8 @@
<TextBlock x:Uid="EditTooltip" />
</ToolTipService.ToolTip>
<Button.Flyout>
<Flyout x:Uid="ImageResizer_EditSize">
<StackPanel Margin="0,12,0,0" Spacing="16">
<Flyout x:Uid="ImageResizer_EditSize" ShouldConstrainToRootBounds="False">
<StackPanel Spacing="16">
<TextBox
x:Uid="ImageResizer_Name"
Width="240"
@@ -148,7 +146,6 @@
<ComboBox
x:Uid="ImageResizer_Size"
Width="240"
Margin="0,0,0,24"
SelectedIndex="{Binding Path=Unit, Mode=TwoWay}">
<ComboBoxItem x:Uid="ImageResizer_Sizes_Units_CM" />
<ComboBoxItem x:Uid="ImageResizer_Sizes_Units_Inches" />
@@ -235,7 +232,7 @@
FontFamily="{ThemeResource SymbolThemeFontFamily}"
Style="{StaticResource SubtleButtonStyle}">
<Button.Flyout>
<Flyout>
<Flyout ShouldConstrainToRootBounds="False">
<TextBlock x:Name="FileFormatTextBlock">
<Run x:Uid="ImageResizer_FileFormatDescription" />
<LineBreak />

View File

@@ -288,8 +288,8 @@
<TextBlock x:Uid="EditTooltip" />
</ToolTipService.ToolTip>
<Button.Flyout>
<Flyout x:Uid="MouseJumpThumbnailSize_Edit">
<StackPanel Margin="0,12,0,0" Spacing="16">
<Flyout x:Uid="MouseJumpThumbnailSize_Edit" ShouldConstrainToRootBounds="False">
<StackPanel Spacing="16">
<NumberBox
x:Uid="MouseUtils_MouseJump_ThumbnailSize_Edit_Width"
Width="140"

View File

@@ -49,10 +49,12 @@
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Currency" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Croatian" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Czech" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Danish" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Gaeilge" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Gaidhlig" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Dutch" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Estonian" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Finnish" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_French" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_German" />
<ComboBoxItem x:Uid="QuickAccent_SelectedLanguage_Hebrew" />

View File

@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Services;
using Microsoft.PowerToys.Settings.UI.ViewModels;
@@ -34,7 +35,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// <summary>
/// Declaration for the updating the general settings callback function.
/// </summary>
public delegate bool UpdatingGeneralSettingsCallback(string module, bool isEnabled);
public delegate bool UpdatingGeneralSettingsCallback(ModuleType moduleType, bool isEnabled);
/// <summary>
/// Declaration for the opening oobe window callback function.

View File

@@ -3316,6 +3316,9 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="QuickAccent_SelectedLanguage_Czech.Content" xml:space="preserve">
<value>Czech</value>
</data>
<data name="QuickAccent_SelectedLanguage_Danish.Content" xml:space="preserve">
<value>Danish</value>
</data>
<data name="QuickAccent_SelectedLanguage_Gaeilge.Content" xml:space="preserve">
<value>Gaeilge</value>
<comment>Gaelic language spoken in Ireland</comment>
@@ -3333,6 +3336,9 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="QuickAccent_SelectedLanguage_French.Content" xml:space="preserve">
<value>French</value>
</data>
<data name="QuickAccent_SelectedLanguage_Finnish.Content" xml:space="preserve">
<value>Finnish</value>
</data>
<data name="QuickAccent_SelectedLanguage_Estonian.Content" xml:space="preserve">
<value>Estonian</value>
</data>

View File

@@ -6,6 +6,7 @@ using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using ManagedCommon;
using Microsoft.UI;
using Windows.UI;
@@ -22,7 +23,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public string ToolTip { get; set; }
public string Tag { get; set; }
public ModuleType Tag { get; set; }
public Color AccentColor { get; set; } = Colors.Transparent;

View File

@@ -9,6 +9,8 @@ using System.IO.Abstractions;
using System.Linq;
using System.Windows.Threading;
using global::PowerToys.GPOWrapper;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
@@ -23,7 +25,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public class DashboardViewModel : Observable
{
private const string JsonFileType = ".json";
private readonly IFileSystemWatcher _watcher;
private IFileSystemWatcher _watcher;
private DashboardModuleKBMItem _kbmItem;
private Dispatcher dispatcher;
@@ -53,325 +55,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_allModules = new List<DashboardListItem>();
GpoRuleConfigured gpo;
gpo = GPOWrapper.GetConfiguredAlwaysOnTopEnabledValue();
_allModules.Add(new DashboardListItem()
foreach (ModuleType moduleType in Enum.GetValues(typeof(ModuleType)))
{
Tag = "AlwaysOnTop",
Label = resourceLoader.GetString("AlwaysOnTop/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.AlwaysOnTop),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsAlwaysOnTop.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 74, 196, 242), // #4ac4f2
DashboardModuleItems = GetModuleItemsAlwaysOnTop(),
});
gpo = GPOWrapper.GetConfiguredAwakeEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "Awake",
Label = resourceLoader.GetString("Awake/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.Awake),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsAwake.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 40, 177, 233), // #28b1e9
DashboardModuleItems = GetModuleItemsAwake(),
});
gpo = GPOWrapper.GetConfiguredColorPickerEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "ColorPicker",
Label = resourceLoader.GetString("ColorPicker/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.ColorPicker),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsColorPicker.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 7, 129, 211), // #0781d3
DashboardModuleItems = GetModuleItemsColorPicker(),
});
gpo = GPOWrapper.GetConfiguredCropAndLockEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "CropAndLock",
Label = resourceLoader.GetString("CropAndLock/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.CropAndLock),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsCropAndLock.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 32, 166, 228), // #20a6e4
DashboardModuleItems = GetModuleItemsCropAndLock(),
});
gpo = GPOWrapper.GetConfiguredEnvironmentVariablesEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "EnvironmentVariables",
Label = resourceLoader.GetString("EnvironmentVariables/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.EnvironmentVariables),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsEnvironmentVariables.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 16, 132, 208), // #1084d0
DashboardModuleItems = GetModuleItemsEnvironmentVariables(),
});
gpo = GPOWrapper.GetConfiguredFancyZonesEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "FancyZones",
Label = resourceLoader.GetString("FancyZones/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.FancyZones),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsFancyZones.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 65, 209, 247), // #41d1f7
DashboardModuleItems = GetModuleItemsFancyZones(),
});
gpo = GPOWrapper.GetConfiguredFileLocksmithEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "FileLocksmith",
Label = resourceLoader.GetString("FileLocksmith/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.FileLocksmith),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsFileLocksmith.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 245, 161, 20), // #f5a114
DashboardModuleItems = GetModuleItemsFileLocksmith(),
});
gpo = GPOWrapper.GetConfiguredFindMyMouseEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "FindMyMouse",
Label = resourceLoader.GetString("MouseUtils_FindMyMouse/Header"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.FindMyMouse),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsFindMyMouse.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 104, 109, 112), // #686d70
DashboardModuleItems = GetModuleItemsFindMyMouse(),
});
gpo = GPOWrapper.GetConfiguredHostsFileEditorEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "Hosts",
Label = resourceLoader.GetString("Hosts/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.Hosts),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsHosts.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 16, 132, 208), // #1084d0
DashboardModuleItems = GetModuleItemsHosts(),
});
gpo = GPOWrapper.GetConfiguredImageResizerEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "ImageResizer",
Label = resourceLoader.GetString("ImageResizer/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.ImageResizer),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsImageResizer.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 85, 207, 248), // #55cff8
DashboardModuleItems = GetModuleItemsImageResizer(),
});
gpo = GPOWrapper.GetConfiguredKeyboardManagerEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "KeyboardManager",
Label = resourceLoader.GetString("KeyboardManager/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.KeyboardManager),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsKeyboardManager.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 224, 231, 238), // #e0e7ee
DashboardModuleItems = GetModuleItemsKeyboardManager(),
});
if (gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.KeyboardManager))
{
KeyboardManagerSettings kbmSettings = GetKBMSettings();
_watcher = Library.Utilities.Helper.GetFileWatcher(KeyboardManagerSettings.ModuleName, kbmSettings.Properties.ActiveConfiguration.Value + JsonFileType, () => LoadKBMSettingsFromJson());
AddDashboardListItem(moduleType);
}
gpo = GPOWrapper.GetConfiguredMouseHighlighterEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "MouseHighlighter",
Label = resourceLoader.GetString("MouseUtils_MouseHighlighter/Header"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.MouseHighlighter),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsMouseHighlighter.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 17, 126, 199), // #117ec7
DashboardModuleItems = GetModuleItemsMouseHighlighter(),
});
gpo = GPOWrapper.GetConfiguredMouseJumpEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "MouseJump",
Label = resourceLoader.GetString("MouseUtils_MouseJump/Header"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.MouseJump),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsMouseJump.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 240, 240, 239), // #f0f0ef
DashboardModuleItems = GetModuleItemsMouseJump(),
});
gpo = GPOWrapper.GetConfiguredMousePointerCrosshairsEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "MousePointerCrosshairs",
Label = resourceLoader.GetString("MouseUtils_MousePointerCrosshairs/Header"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.MousePointerCrosshairs),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsMouseCrosshairs.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 25, 115, 182), // #1973b6
DashboardModuleItems = GetModuleItemsMouseCrosshairs(),
});
gpo = GPOWrapper.GetConfiguredMouseWithoutBordersEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "MouseWithoutBorders",
Label = resourceLoader.GetString("MouseWithoutBorders/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.MouseWithoutBorders),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsMouseWithoutBorders.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 31, 164, 227), // #1fa4e3
DashboardModuleItems = GetModuleItemsMouseWithoutBorders(),
});
gpo = GPOWrapper.GetConfiguredPastePlainEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "PastePlain",
Label = resourceLoader.GetString("PastePlain/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.PastePlain),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPastePlain.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 243, 156, 16), // #f39c10
DashboardModuleItems = GetModuleItemsPastePlain(),
});
gpo = GPOWrapper.GetConfiguredPeekEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "Peek",
Label = resourceLoader.GetString("Peek/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.Peek),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPeek.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 255, 214, 103), // #ffd667
DashboardModuleItems = GetModuleItemsPeek(),
});
gpo = GPOWrapper.GetConfiguredPowerRenameEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "PowerRename",
Label = resourceLoader.GetString("PowerRename/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.PowerRename),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerRename.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 43, 186, 243), // #2bbaf3
DashboardModuleItems = GetModuleItemsPowerRename(),
});
gpo = GPOWrapper.GetConfiguredPowerLauncherEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "PowerLauncher",
Label = resourceLoader.GetString("PowerLauncher/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.PowerLauncher),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerToysRun.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 51, 191, 240), // #33bff0
DashboardModuleItems = GetModuleItemsRun(),
});
gpo = GPOWrapper.GetConfiguredQuickAccentEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "PowerAccent",
Label = resourceLoader.GetString("QuickAccent/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.PowerAccent),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerAccent.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 84, 89, 92), // #54595c
DashboardModuleItems = GetModuleItemsPowerAccent(),
});
gpo = GPOWrapper.GetConfiguredRegistryPreviewEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "RegistryPreview",
Label = resourceLoader.GetString("RegistryPreview/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.RegistryPreview),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsRegistryPreview.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 17, 80, 138), // #11508a
DashboardModuleItems = GetModuleItemsRegistryPreview(),
});
gpo = GPOWrapper.GetConfiguredScreenRulerEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "MeasureTool",
Label = resourceLoader.GetString("MeasureTool/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.MeasureTool),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsScreenRuler.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 135, 144, 153), // #879099
DashboardModuleItems = GetModuleItemsScreenRuler(),
});
gpo = GPOWrapper.GetConfiguredShortcutGuideEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "ShortcutGuide",
Label = resourceLoader.GetString("ShortcutGuide/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.ShortcutGuide),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsShortcutGuide.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 193, 202, 209), // #c1cad1
DashboardModuleItems = GetModuleItemsShortcutGuide(),
});
gpo = GPOWrapper.GetConfiguredTextExtractorEnabledValue();
_allModules.Add(new DashboardListItem()
{
Tag = "PowerOCR",
Label = resourceLoader.GetString("TextExtractor/ModuleTitle"),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && generalSettingsConfig.Enabled.PowerOCR),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerOCR.png",
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = Color.FromArgb(255, 24, 153, 224), // #1899e0
DashboardModuleItems = GetModuleItemsPowerOCR(),
});
ActiveModules = new ObservableCollection<DashboardListItem>(_allModules.Where(x => x.IsEnabled));
DisabledModules = new ObservableCollection<DashboardListItem>(_allModules.Where(x => !x.IsEnabled));
@@ -379,6 +67,27 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
UpdateAvailable = updatingSettingsConfig != null && (updatingSettingsConfig.State == UpdatingSettings.UpdatingState.ReadyToInstall || updatingSettingsConfig.State == UpdatingSettings.UpdatingState.ReadyToDownload);
}
private void AddDashboardListItem(ModuleType moduleType)
{
GpoRuleConfigured gpo = ModuleHelper.GetModuleGpoConfiguration(moduleType);
_allModules.Add(new DashboardListItem()
{
Tag = moduleType,
Label = resourceLoader.GetString(ModuleHelper.GetModuleLabelResourceName(moduleType)),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType)),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = ModuleHelper.GetModuleTypeFluentIconName(moduleType),
EnabledChangedCallback = EnabledChangedOnUI,
AccentColor = ModuleHelper.GetModuleAccentColor(moduleType),
DashboardModuleItems = GetModuleItems(moduleType),
});
if (moduleType == ModuleType.KeyboardManager && gpo != GpoRuleConfigured.Disabled)
{
KeyboardManagerSettings kbmSettings = GetKBMSettings();
_watcher = Library.Utilities.Helper.GetFileWatcher(KeyboardManagerSettings.ModuleName, kbmSettings.Properties.ActiveConfiguration.Value + JsonFileType, () => LoadKBMSettingsFromJson());
}
}
private void LoadKBMSettingsFromJson()
{
KeyboardManagerProfile kbmProfile = GetKBMProfile();
@@ -408,52 +117,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
return moduleSettingsRepository.SettingsConfig;
}
internal void SettingsButtonClicked(object sender)
{
Button button = sender as Button;
if (button == null)
{
return;
}
string tag = button.Tag as string;
if (tag == null)
{
return;
}
Type type = null;
switch (tag)
{
case "AlwaysOnTop": type = typeof(AlwaysOnTopPage); break;
case "Awake": type = typeof(AwakePage); break;
case "ColorPicker": type = typeof(ColorPickerPage); break;
case "CropAndLock": type = typeof(CropAndLockPage); break;
case "FancyZones": type = typeof(FancyZonesPage); break;
case "FileLocksmith": type = typeof(FileLocksmithPage); break;
case "FindMyMouse": type = typeof(MouseUtilsPage); break;
case "Hosts": type = typeof(HostsPage); break;
case "ImageResizer": type = typeof(ImageResizerPage); break;
case "KeyboardManager": type = typeof(KeyboardManagerPage); break;
case "MouseHighlighter": type = typeof(MouseUtilsPage); break;
case "MouseJump": type = typeof(MouseUtilsPage); break;
case "MousePointerCrosshairs": type = typeof(MouseUtilsPage); break;
case "MouseWithoutBorders": type = typeof(MouseWithoutBordersPage); break;
case "PastePlain": type = typeof(PastePlainPage); break;
case "Peek": type = typeof(PeekPage); break;
case "PowerRename": type = typeof(PowerRenamePage); break;
case "PowerLauncher": type = typeof(PowerLauncherPage); break;
case "PowerAccent": type = typeof(PowerAccentPage); break;
case "RegistryPreview": type = typeof(RegistryPreviewPage); break;
case "MeasureTool": type = typeof(MeasureToolPage); break;
case "ShortcutGuide": type = typeof(ShortcutGuidePage); break;
case "PowerOCR": type = typeof(PowerOcrPage); break;
case "VideoConference": type = typeof(VideoConferencePage); break;
}
NavigationService.Navigate(type);
}
private void EnabledChangedOnUI(DashboardListItem dashboardListItem)
{
Views.ShellPage.UpdateGeneralSettingsCallback(dashboardListItem.Tag, dashboardListItem.IsEnabled);
@@ -466,35 +129,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
generalSettingsConfig = _settingsRepository.SettingsConfig;
foreach (DashboardListItem item in _allModules)
{
switch (item.Tag)
{
case "AlwaysOnTop": item.IsEnabled = generalSettingsConfig.Enabled.AlwaysOnTop; break;
case "Awake": item.IsEnabled = generalSettingsConfig.Enabled.Awake; break;
case "ColorPicker": item.IsEnabled = generalSettingsConfig.Enabled.ColorPicker; break;
case "CropAndLock": item.IsEnabled = generalSettingsConfig.Enabled.CropAndLock; break;
case "EnvironmentVariables": item.IsEnabled = generalSettingsConfig.Enabled.EnvironmentVariables; break;
case "FancyZones": item.IsEnabled = generalSettingsConfig.Enabled.FancyZones; break;
case "FileLocksmith": item.IsEnabled = generalSettingsConfig.Enabled.FileLocksmith; break;
case "FindMyMouse": item.IsEnabled = generalSettingsConfig.Enabled.FindMyMouse; break;
case "Hosts": item.IsEnabled = generalSettingsConfig.Enabled.Hosts; break;
case "ImageResizer": item.IsEnabled = generalSettingsConfig.Enabled.ImageResizer; break;
case "KeyboardManager": item.IsEnabled = generalSettingsConfig.Enabled.KeyboardManager; break;
case "MouseHighlighter": item.IsEnabled = generalSettingsConfig.Enabled.MouseHighlighter; break;
case "MouseJump": item.IsEnabled = generalSettingsConfig.Enabled.MouseJump; break;
case "MousePointerCrosshairs": item.IsEnabled = generalSettingsConfig.Enabled.MousePointerCrosshairs; break;
case "MouseWithoutBorders": item.IsEnabled = generalSettingsConfig.Enabled.MouseWithoutBorders; break;
case "PastePlain": item.IsEnabled = generalSettingsConfig.Enabled.PastePlain; break;
case "Peek": item.IsEnabled = generalSettingsConfig.Enabled.Peek; break;
case "PowerRename": item.IsEnabled = generalSettingsConfig.Enabled.PowerRename; break;
case "PowerLauncher": item.IsEnabled = generalSettingsConfig.Enabled.PowerLauncher; break;
case "PowerAccent": item.IsEnabled = generalSettingsConfig.Enabled.PowerAccent; break;
case "RegistryPreview": item.IsEnabled = generalSettingsConfig.Enabled.RegistryPreview; break;
case "MeasureTool": item.IsEnabled = generalSettingsConfig.Enabled.MeasureTool; break;
case "ShortcutGuide": item.IsEnabled = generalSettingsConfig.Enabled.ShortcutGuide; break;
case "PowerOCR": item.IsEnabled = generalSettingsConfig.Enabled.PowerOCR; break;
case "VideoConference": item.IsEnabled = generalSettingsConfig.Enabled.VideoConference; break;
}
item.IsEnabled = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, item.Tag);
if (item.IsEnabled)
{
ActiveModules.Add(item);
@@ -509,6 +144,38 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
OnPropertyChanged(nameof(DisabledModules));
}
private ObservableCollection<DashboardModuleItem> GetModuleItems(ModuleType moduleType)
{
return moduleType switch
{
ModuleType.AlwaysOnTop => GetModuleItemsAlwaysOnTop(),
ModuleType.Awake => GetModuleItemsAwake(),
ModuleType.ColorPicker => GetModuleItemsColorPicker(),
ModuleType.CropAndLock => GetModuleItemsCropAndLock(),
ModuleType.EnvironmentVariables => GetModuleItemsEnvironmentVariables(),
ModuleType.FancyZones => GetModuleItemsFancyZones(),
ModuleType.FileLocksmith => GetModuleItemsFileLocksmith(),
ModuleType.FindMyMouse => GetModuleItemsFindMyMouse(),
ModuleType.Hosts => GetModuleItemsHosts(),
ModuleType.ImageResizer => GetModuleItemsImageResizer(),
ModuleType.KeyboardManager => GetModuleItemsKeyboardManager(),
ModuleType.MouseHighlighter => GetModuleItemsMouseHighlighter(),
ModuleType.MouseJump => GetModuleItemsMouseJump(),
ModuleType.MousePointerCrosshairs => GetModuleItemsMousePointerCrosshairs(),
ModuleType.MouseWithoutBorders => GetModuleItemsMouseWithoutBorders(),
ModuleType.PastePlain => GetModuleItemsPastePlain(),
ModuleType.Peek => GetModuleItemsPeek(),
ModuleType.PowerRename => GetModuleItemsPowerRename(),
ModuleType.PowerLauncher => GetModuleItemsPowerLauncher(),
ModuleType.PowerAccent => GetModuleItemsPowerAccent(),
ModuleType.RegistryPreview => GetModuleItemsRegistryPreview(),
ModuleType.MeasureTool => GetModuleItemsMeasureTool(),
ModuleType.ShortcutGuide => GetModuleItemsShortcutGuide(),
ModuleType.PowerOCR => GetModuleItemsPowerOCR(),
_ => new ObservableCollection<DashboardModuleItem>(), // never called, all values listed above
};
}
private ObservableCollection<DashboardModuleItem> GetModuleItemsAlwaysOnTop()
{
ISettingsRepository<AlwaysOnTopSettings> moduleSettingsRepository = SettingsRepository<AlwaysOnTopSettings>.GetInstance(new SettingsUtils());
@@ -668,7 +335,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
return new ObservableCollection<DashboardModuleItem>(list);
}
private ObservableCollection<DashboardModuleItem> GetModuleItemsMouseCrosshairs()
private ObservableCollection<DashboardModuleItem> GetModuleItemsMousePointerCrosshairs()
{
ISettingsRepository<MousePointerCrosshairsSettings> moduleSettingsRepository = SettingsRepository<MousePointerCrosshairsSettings>.GetInstance(new SettingsUtils());
var list = new List<DashboardModuleItem>
@@ -716,7 +383,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
return new ObservableCollection<DashboardModuleItem>(list);
}
private ObservableCollection<DashboardModuleItem> GetModuleItemsRun()
private ObservableCollection<DashboardModuleItem> GetModuleItemsPowerLauncher()
{
ISettingsRepository<PowerLauncherSettings> moduleSettingsRepository = SettingsRepository<PowerLauncherSettings>.GetInstance(new SettingsUtils());
var list = new List<DashboardModuleItem>
@@ -755,7 +422,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
return new ObservableCollection<DashboardModuleItem>(list);
}
private ObservableCollection<DashboardModuleItem> GetModuleItemsScreenRuler()
private ObservableCollection<DashboardModuleItem> GetModuleItemsMeasureTool()
{
ISettingsRepository<MeasureToolSettings> moduleSettingsRepository = SettingsRepository<MeasureToolSettings>.GetInstance(new SettingsUtils());
var list = new List<DashboardModuleItem>
@@ -829,5 +496,23 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
var actionName = "Launch";
SendConfigMSG("{\"action\":{\"RegistryPreview\":{\"action_name\":\"" + actionName + "\", \"value\":\"\"}}}");
}
internal void DashboardListItemClick(object sender)
{
Button button = sender as Button;
if (button == null)
{
return;
}
if (!(button.Tag is ModuleType))
{
return;
}
ModuleType moduleType = (ModuleType)button.Tag;
NavigationService.Navigate(ModuleHelper.GetModulePageType(moduleType));
}
}
}

View File

@@ -4,9 +4,9 @@
using System;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Flyout;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
@@ -30,86 +30,32 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
generalSettingsConfig = settingsRepository.SettingsConfig;
generalSettingsConfig.AddEnabledModuleChangeNotification(ModuleEnabledChangedOnSettingsPage);
resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader;
FlyoutMenuItems = new ObservableCollection<FlyoutMenuItem>();
resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader;
AddFlyoutMenuItem("AlwaysOnTop", generalSettingsConfig.Enabled.AlwaysOnTop, "AlwaysOnTop/ModuleTitle", "AlwaysOnTop");
AddFlyoutMenuItem("Awake", generalSettingsConfig.Enabled.Awake, "Awake/ModuleTitle", "Awake");
AddFlyoutMenuItem("ColorPicker", generalSettingsConfig.Enabled.ColorPicker, "ColorPicker/ModuleTitle", "ColorPicker");
AddFlyoutMenuItem("CropAndLock", generalSettingsConfig.Enabled.CropAndLock, "CropAndLock/ModuleTitle", "CropAndLock");
AddFlyoutMenuItem("EnvironmentVariables", generalSettingsConfig.Enabled.EnvironmentVariables, "EnvironmentVariables/ModuleTitle", "EnvironmentVariables");
AddFlyoutMenuItem("FancyZones", generalSettingsConfig.Enabled.FancyZones, "FancyZones/ModuleTitle", "FancyZones");
AddFlyoutMenuItem("FileLocksmith", generalSettingsConfig.Enabled.FileLocksmith, "FileLocksmith/ModuleTitle", "FileLocksmith");
AddFlyoutMenuItem("FindMyMouse", generalSettingsConfig.Enabled.FindMyMouse, "MouseUtils_FindMyMouse/Header", "FindMyMouse");
AddFlyoutMenuItem("Hosts", generalSettingsConfig.Enabled.Hosts, "Hosts/ModuleTitle", "Hosts");
AddFlyoutMenuItem("ImageResizer", generalSettingsConfig.Enabled.ImageResizer, "ImageResizer/ModuleTitle", "ImageResizer");
AddFlyoutMenuItem("KeyboardManager", generalSettingsConfig.Enabled.KeyboardManager, "KeyboardManager/ModuleTitle", "KeyboardManager");
AddFlyoutMenuItem("MouseHighlighter", generalSettingsConfig.Enabled.MouseHighlighter, "MouseUtils_MouseHighlighter/Header", "MouseHighlighter");
AddFlyoutMenuItem("MouseJump", generalSettingsConfig.Enabled.MouseJump, "MouseUtils_MouseJump/Header", "MouseJump");
AddFlyoutMenuItem("MousePointerCrosshairs", generalSettingsConfig.Enabled.MousePointerCrosshairs, "MouseUtils_MousePointerCrosshairs/Header", "MouseCrosshairs");
AddFlyoutMenuItem("MouseWithoutBorders", generalSettingsConfig.Enabled.MouseWithoutBorders, "MouseWithoutBorders/ModuleTitle", "MouseWithoutBorders");
AddFlyoutMenuItem("PastePlain", generalSettingsConfig.Enabled.PastePlain, "PastePlain/ModuleTitle", "PastePlain");
AddFlyoutMenuItem("Peek", generalSettingsConfig.Enabled.Peek, "Peek/ModuleTitle", "Peek");
AddFlyoutMenuItem("PowerRename", generalSettingsConfig.Enabled.PowerRename, "PowerRename/ModuleTitle", "PowerRename");
AddFlyoutMenuItem("PowerLauncher", generalSettingsConfig.Enabled.PowerLauncher, "PowerLauncher/ModuleTitle", "PowerToysRun");
AddFlyoutMenuItem("PowerAccent", generalSettingsConfig.Enabled.PowerAccent, "QuickAccent/ModuleTitle", "PowerAccent");
AddFlyoutMenuItem("RegistryPreview", generalSettingsConfig.Enabled.RegistryPreview, "RegistryPreview/ModuleTitle", "RegistryPreview");
AddFlyoutMenuItem("MeasureTool", generalSettingsConfig.Enabled.MeasureTool, "MeasureTool/ModuleTitle", "ScreenRuler");
AddFlyoutMenuItem("ShortcutGuide", generalSettingsConfig.Enabled.ShortcutGuide, "ShortcutGuide/ModuleTitle", "ShortcutGuide");
AddFlyoutMenuItem("PowerOCR", generalSettingsConfig.Enabled.PowerOCR, "TextExtractor/ModuleTitle", "PowerOCR");
foreach (ModuleType moduleType in Enum.GetValues(typeof(ModuleType)))
{
AddFlyoutMenuItem(moduleType);
}
// set the callback functions value to handle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc;
}
private void AddFlyoutMenuItem(string moduleName, bool isModuleEnabled, string moduleLabelResourceName, string moduleFluentIconName)
private void AddFlyoutMenuItem(ModuleType moduleType)
{
GpoRuleConfigured gpo = GetModuleGpoConfiguration(moduleName);
GpoRuleConfigured gpo = ModuleHelper.GetModuleGpoConfiguration(moduleType);
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString(moduleLabelResourceName),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && isModuleEnabled),
Label = resourceLoader.GetString(ModuleHelper.GetModuleLabelResourceName(moduleType)),
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType)),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Tag = moduleName,
Icon = $"ms-appx:///Assets/Settings/FluentIcons/FluentIcons{moduleFluentIconName}.png",
Tag = moduleType,
Icon = ModuleHelper.GetModuleTypeFluentIconName(moduleType),
EnabledChangedCallback = EnabledChangedOnUI,
});
}
private GpoRuleConfigured GetModuleGpoConfiguration(string moduleName)
{
switch (moduleName)
{
case "AlwaysOnTop": return GPOWrapper.GetConfiguredAlwaysOnTopEnabledValue();
case "Awake": return GPOWrapper.GetConfiguredAwakeEnabledValue();
case "ColorPicker": return GPOWrapper.GetConfiguredColorPickerEnabledValue();
case "CropAndLock": return GPOWrapper.GetConfiguredCropAndLockEnabledValue();
case "EnvironmentVariables": return GPOWrapper.GetConfiguredEnvironmentVariablesEnabledValue();
case "FancyZones": return GPOWrapper.GetConfiguredFancyZonesEnabledValue();
case "FileLocksmith": return GPOWrapper.GetConfiguredFileLocksmithEnabledValue();
case "FindMyMouse": return GPOWrapper.GetConfiguredFindMyMouseEnabledValue();
case "Hosts": return GPOWrapper.GetConfiguredHostsFileEditorEnabledValue();
case "ImageResizer": return GPOWrapper.GetConfiguredImageResizerEnabledValue();
case "KeyboardManager": return GPOWrapper.GetConfiguredKeyboardManagerEnabledValue();
case "MouseHighlighter": return GPOWrapper.GetConfiguredMouseHighlighterEnabledValue();
case "MouseJump": return GPOWrapper.GetConfiguredMouseJumpEnabledValue();
case "MousePointerCrosshairs": return GPOWrapper.GetConfiguredMousePointerCrosshairsEnabledValue();
case "MouseWithoutBorders": return GPOWrapper.GetConfiguredMouseWithoutBordersEnabledValue();
case "PastePlain": return GPOWrapper.GetConfiguredPastePlainEnabledValue();
case "Peek": return GPOWrapper.GetConfiguredPeekEnabledValue();
case "PowerRename": return GPOWrapper.GetConfiguredPowerRenameEnabledValue();
case "PowerLauncher": return GPOWrapper.GetConfiguredPowerLauncherEnabledValue();
case "PowerAccent": return GPOWrapper.GetConfiguredQuickAccentEnabledValue();
case "RegistryPreview": return GPOWrapper.GetConfiguredRegistryPreviewEnabledValue();
case "MeasureTool": return GPOWrapper.GetConfiguredScreenRulerEnabledValue();
case "ShortcutGuide": return GPOWrapper.GetConfiguredShortcutGuideEnabledValue();
case "PowerOCR": return GPOWrapper.GetConfiguredTextExtractorEnabledValue();
default: return GpoRuleConfigured.Unavailable;
}
}
private void EnabledChangedOnUI(FlyoutMenuItem flyoutMenuItem)
{
if (Views.ShellPage.UpdateGeneralSettingsCallback(flyoutMenuItem.Tag, flyoutMenuItem.IsEnabled))
@@ -124,34 +70,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
generalSettingsConfig.AddEnabledModuleChangeNotification(ModuleEnabledChangedOnSettingsPage);
foreach (FlyoutMenuItem item in FlyoutMenuItems)
{
switch (item.Tag)
{
case "AlwaysOnTop": item.IsEnabled = generalSettingsConfig.Enabled.AlwaysOnTop; break;
case "Awake": item.IsEnabled = generalSettingsConfig.Enabled.Awake; break;
case "ColorPicker": item.IsEnabled = generalSettingsConfig.Enabled.ColorPicker; break;
case "CropAndLock": item.IsEnabled = generalSettingsConfig.Enabled.CropAndLock; break;
case "EnvironmentVariables": item.IsEnabled = generalSettingsConfig.Enabled.EnvironmentVariables; break;
case "FancyZones": item.IsEnabled = generalSettingsConfig.Enabled.FancyZones; break;
case "FileLocksmith": item.IsEnabled = generalSettingsConfig.Enabled.FileLocksmith; break;
case "FindMyMouse": item.IsEnabled = generalSettingsConfig.Enabled.FindMyMouse; break;
case "Hosts": item.IsEnabled = generalSettingsConfig.Enabled.Hosts; break;
case "ImageResizer": item.IsEnabled = generalSettingsConfig.Enabled.ImageResizer; break;
case "KeyboardManager": item.IsEnabled = generalSettingsConfig.Enabled.KeyboardManager; break;
case "MouseHighlighter": item.IsEnabled = generalSettingsConfig.Enabled.MouseHighlighter; break;
case "MouseJump": item.IsEnabled = generalSettingsConfig.Enabled.MouseJump; break;
case "MousePointerCrosshairs": item.IsEnabled = generalSettingsConfig.Enabled.MousePointerCrosshairs; break;
case "MouseWithoutBorders": item.IsEnabled = generalSettingsConfig.Enabled.MouseWithoutBorders; break;
case "PastePlain": item.IsEnabled = generalSettingsConfig.Enabled.PastePlain; break;
case "Peek": item.IsEnabled = generalSettingsConfig.Enabled.Peek; break;
case "PowerRename": item.IsEnabled = generalSettingsConfig.Enabled.PowerRename; break;
case "PowerLauncher": item.IsEnabled = generalSettingsConfig.Enabled.PowerLauncher; break;
case "PowerAccent": item.IsEnabled = generalSettingsConfig.Enabled.PowerAccent; break;
case "RegistryPreview": item.IsEnabled = generalSettingsConfig.Enabled.RegistryPreview; break;
case "MeasureTool": item.IsEnabled = generalSettingsConfig.Enabled.MeasureTool; break;
case "ShortcutGuide": item.IsEnabled = generalSettingsConfig.Enabled.ShortcutGuide; break;
case "PowerOCR": item.IsEnabled = generalSettingsConfig.Enabled.PowerOCR; break;
case "VideoConference": item.IsEnabled = generalSettingsConfig.Enabled.VideoConference; break;
}
item.IsEnabled = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, item.Tag);
}
}
}

View File

@@ -5,7 +5,7 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Microsoft.UI.Xaml;
using ManagedCommon;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
@@ -20,7 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public string ToolTip { get; set; }
public string Tag { get; set; }
public ModuleType Tag { get; set; }
public bool IsLocked { get; set; }

View File

@@ -5,10 +5,12 @@
using System;
using System.Collections.ObjectModel;
using global::PowerToys.GPOWrapper;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Views;
using Microsoft.Windows.ApplicationModel.Resources;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
@@ -21,6 +23,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private GeneralSettings generalSettingsConfig;
private UpdatingSettings updatingSettingsConfig;
private ISettingsRepository<GeneralSettings> _settingsRepository;
private ResourceLoader resourceLoader;
private Func<string, int> SendIPCMessage { get; }
@@ -32,112 +35,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
// set the callback functions value to handle outgoing IPC message.
SendIPCMessage = ipcMSGCallBackFunc;
var resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader;
resourceLoader = ResourceLoaderInstance.ResourceLoader;
FlyoutMenuItems = new ObservableCollection<FlyoutMenuItem>();
if (GPOWrapper.GetConfiguredColorPickerEnabledValue() != GpoRuleConfigured.Disabled)
{
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString("ColorPicker/ModuleTitle"),
Tag = "ColorPicker",
Visible = generalSettingsConfig.Enabled.ColorPicker,
ToolTip = SettingsRepository<ColorPickerSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsColorPicker.png",
});
}
if (GPOWrapper.GetConfiguredEnvironmentVariablesEnabledValue() != GpoRuleConfigured.Disabled)
{
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString("EnvironmentVariables/ModuleTitle"),
Tag = "EnvironmentVariables",
Visible = generalSettingsConfig.Enabled.EnvironmentVariables,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsEnvironmentVariables.png",
});
}
if (GPOWrapper.GetConfiguredFancyZonesEnabledValue() != GpoRuleConfigured.Disabled)
{
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString("FZEditorString"),
Tag = "FancyZones",
Visible = generalSettingsConfig.Enabled.FancyZones,
ToolTip = SettingsRepository<FancyZonesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.FancyzonesEditorHotkey.Value.ToString(),
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsFancyZones.png",
});
}
if (GPOWrapper.GetConfiguredHostsFileEditorEnabledValue() != GpoRuleConfigured.Disabled)
{
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString("Hosts/ModuleTitle"),
Tag = "Hosts",
Visible = generalSettingsConfig.Enabled.Hosts,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsHosts.png",
});
}
if (GPOWrapper.GetConfiguredPowerLauncherEnabledValue() != GpoRuleConfigured.Disabled)
{
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString("PowerLauncher/ModuleTitle"),
Tag = "PowerLauncher",
Visible = generalSettingsConfig.Enabled.PowerLauncher,
ToolTip = SettingsRepository<PowerLauncherSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.OpenPowerLauncher.ToString(),
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerToysRun.png",
});
}
if (GPOWrapper.GetConfiguredTextExtractorEnabledValue() != GpoRuleConfigured.Disabled)
{
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString("TextExtractor/ModuleTitle"),
Tag = "PowerOCR",
Visible = generalSettingsConfig.Enabled.PowerOCR,
ToolTip = SettingsRepository<PowerOcrSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsPowerOcr.png",
});
}
if (GPOWrapper.GetConfiguredRegistryPreviewEnabledValue() != GpoRuleConfigured.Disabled)
{
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString("RegistryPreview/ModuleTitle"),
Tag = "RegistryPreview",
Visible = generalSettingsConfig.Enabled.RegistryPreview,
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsRegistryPreview.png",
});
}
if (GPOWrapper.GetConfiguredScreenRulerEnabledValue() != GpoRuleConfigured.Disabled)
{
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString("MeasureTool/ModuleTitle"),
Tag = "MeasureTool",
Visible = generalSettingsConfig.Enabled.MeasureTool,
ToolTip = SettingsRepository<MeasureToolSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsScreenRuler.png",
});
}
if (GPOWrapper.GetConfiguredShortcutGuideEnabledValue() != GpoRuleConfigured.Disabled)
{
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString("ShortcutGuide/ModuleTitle"),
Tag = "ShortcutGuide",
Visible = generalSettingsConfig.Enabled.ShortcutGuide,
ToolTip = SettingsRepository<ShortcutGuideSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.OpenShortcutGuide.ToString(),
Icon = "ms-appx:///Assets/Settings/FluentIcons/FluentIconsShortcutGuide.png",
});
}
AddFlyoutMenuItem(ModuleType.ColorPicker);
AddFlyoutMenuItem(ModuleType.EnvironmentVariables);
AddFlyoutMenuItem(ModuleType.FancyZones);
AddFlyoutMenuItem(ModuleType.Hosts);
AddFlyoutMenuItem(ModuleType.PowerLauncher);
AddFlyoutMenuItem(ModuleType.PowerOCR);
AddFlyoutMenuItem(ModuleType.RegistryPreview);
AddFlyoutMenuItem(ModuleType.MeasureTool);
AddFlyoutMenuItem(ModuleType.ShortcutGuide);
if (updatingSettingsConfig == null)
{
@@ -156,23 +65,44 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
private void AddFlyoutMenuItem(ModuleType moduleType)
{
if (ModuleHelper.GetModuleGpoConfiguration(moduleType) == GpoRuleConfigured.Disabled)
{
return;
}
FlyoutMenuItems.Add(new FlyoutMenuItem()
{
Label = resourceLoader.GetString(ModuleHelper.GetModuleLabelResourceName(moduleType)),
Tag = moduleType,
Visible = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType),
ToolTip = GetModuleTooltip(moduleType),
Icon = ModuleHelper.GetModuleTypeFluentIconName(moduleType),
});
}
private string GetModuleTooltip(ModuleType moduleType)
{
return moduleType switch
{
ModuleType.ColorPicker => SettingsRepository<ColorPickerSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
ModuleType.FancyZones => SettingsRepository<FancyZonesSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.FancyzonesEditorHotkey.Value.ToString(),
ModuleType.PowerLauncher => SettingsRepository<PowerLauncherSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.OpenPowerLauncher.ToString(),
ModuleType.PowerOCR => SettingsRepository<PowerOcrSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
ModuleType.MeasureTool => SettingsRepository<MeasureToolSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.ToString(),
ModuleType.ShortcutGuide => SettingsRepository<ShortcutGuideSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.OpenShortcutGuide.ToString(),
_ => string.Empty,
};
}
private void ModuleEnabledChanged()
{
generalSettingsConfig = _settingsRepository.SettingsConfig;
generalSettingsConfig.AddEnabledModuleChangeNotification(ModuleEnabledChanged);
foreach (FlyoutMenuItem item in FlyoutMenuItems)
{
switch (item.Tag)
{
case "ColorPicker": item.Visible = generalSettingsConfig.Enabled.ColorPicker; break;
case "FancyZones": item.Visible = generalSettingsConfig.Enabled.FancyZones; break;
case "Hosts": item.Visible = generalSettingsConfig.Enabled.Hosts; break;
case "PowerLauncher": item.Visible = generalSettingsConfig.Enabled.PowerLauncher; break;
case "PowerOCR": item.Visible = generalSettingsConfig.Enabled.PowerOCR; break;
case "RegistryPreview": item.Visible = generalSettingsConfig.Enabled.RegistryPreview; break;
case "MeasureTool": item.Visible = generalSettingsConfig.Enabled.MeasureTool; break;
case "ShortcutGuide": item.Visible = generalSettingsConfig.Enabled.ShortcutGuide; break;
}
item.Visible = ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, item.Tag);
}
}

View File

@@ -28,10 +28,12 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
"CUR",
"HR",
"CZ",
"DK",
"GA",
"GD",
"NL",
"EST",
"FI",
"FR",
"DE",
"HE",