Merge branch 'main' into dev/seraphima/tests/29246-fancyzones-tests-initial-step

This commit is contained in:
seraphima
2023-11-21 12:28:42 +01:00
395 changed files with 8903 additions and 3803 deletions

View File

@@ -14,7 +14,9 @@ https://www.regexplanet.com/advanced/perl/) yours before committing to verify it
* well-formed pattern. * 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. try adding it to the `patterns.txt` file.
Patterns are Perl 5 Regular Expressions - you can [test]( Patterns are Perl 5 Regular Expressions - you can [test](

View File

@@ -9,4 +9,5 @@ sdl
ssh ssh
ubuntu ubuntu
unuing unuing
workarounds
wil 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 # marker to ignore all code on line
^.*/\* #no-spell-check-line \*/.*$ ^.*/\* #no-spell-check-line \*/.*$
# marker for ignoring a comment to the end of the line # marker to ignore all code on line
// #no-spell-check.*$ ^.*\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 # patch hunk comments
^\@\@ -\d+(?:,\d+|) \+\d+(?:,\d+|) \@\@ .* ^\@\@ -\d+(?:,\d+|) \+\d+(?:,\d+|) \@\@ .*
# git index header # 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 urls
(['"])cid:.*?\g{-1} (['"])cid:.*?\g{-1}
# data url in parens # 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 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 url
data:[-a-zA-Z=;:/0-9+]*,\S* 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 urls
mailto:[-a-zA-Z=;:/?%&0-9+@.]{3,} mailto:[-a-zA-Z=;:/?%&0-9+@.]{3,}
@@ -35,6 +48,9 @@ magnet:[?=:\w]+
# asciinema # asciinema
\basciinema\.org/a/[0-9a-zA-Z]+ \basciinema\.org/a/[0-9a-zA-Z]+
# asciinema v2
^\[\d+\.\d+, "[io]", ".*"\]$
# apple # apple
\bdeveloper\.apple\.com/[-\w?=/]+ \bdeveloper\.apple\.com/[-\w?=/]+
# Apple music # Apple music
@@ -89,7 +105,7 @@ vpc-\w+
# Google Drive # Google Drive
\bdrive\.google\.com/(?:file/d/|open)[-0-9a-zA-Z_?=]* \bdrive\.google\.com/(?:file/d/|open)[-0-9a-zA-Z_?=]*
# Google Groups # 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 # Google Maps
\bmaps\.google\.com/maps\?[\w&;=]* \bmaps\.google\.com/maps\?[\w&;=]*
# Google themes # 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|) (?:\[`?[0-9a-f]+`?\]\(https:/|)/(?:www\.|)github\.com(?:/[^/\s"]+){2,}(?:/[^/\s")]+)(?:[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|)
# GitHub SHAs # GitHub SHAs
\bgithub\.com(?:/[^/\s"]+){2}[@#][0-9a-f]+\b \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 # GitHub wiki
\bgithub\.com/(?:[^/]+/){2}wiki/(?:(?:[^/]+/|)_history|[^/]+(?:/_compare|)/[0-9a-f.]{40,})\b \bgithub\.com/(?:[^/]+/){2}wiki/(?:(?:[^/]+/|)_history|[^/]+(?:/_compare|)/[0-9a-f.]{40,})\b
# githubusercontent # githubusercontent
@@ -128,9 +146,9 @@ themes\.googleusercontent\.com/static/fonts/[^/\s"]+/v\d+/[^.]+.
# git.io # git.io
\bgit\.io/[0-9a-zA-Z]+ \bgit\.io/[0-9a-zA-Z]+
# GitHub JSON # GitHub JSON
"node_id": "[-a-zA-Z=;:/0-9+]*" "node_id": "[-a-zA-Z=;:/0-9+_]*"
# Contributor # Contributor
\[[^\]]+\]\(https://github\.com/[^/\s"]+\) \[[^\]]+\]\(https://github\.com/[^/\s"]+/?\)
# GHSA # GHSA
GHSA(?:-[0-9a-z]{4}){3} GHSA(?:-[0-9a-z]{4}){3}
@@ -143,8 +161,8 @@ GHSA(?:-[0-9a-z]{4}){3}
# GitLab commits # GitLab commits
\bgitlab\.[^/\s"]*/(?:[^/\s"]+/){2}commits?/[0-9a-f]+\b \bgitlab\.[^/\s"]*/(?:[^/\s"]+/){2}commits?/[0-9a-f]+\b
# binanace # binance
accounts.binance.com/[a-z/]*oauth/authorize\?[-0-9a-zA-Z&%]* accounts\.binance\.com/[a-z/]*oauth/authorize\?[-0-9a-zA-Z&%]*
# bitbucket diff # bitbucket diff
\bapi\.bitbucket\.org/\d+\.\d+/repositories/(?:[^/\s"]+/){2}diff(?:stat|)(?:/[^/\s"]+){2}:[0-9a-f]+ \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_.%?=&;]+ \bdropbox\.com/sh?/[^/\s"]+/[-0-9A-Za-z_.%?=&;]+
# ipfs protocol # ipfs protocol
ipfs://[0-9a-z]* ipfs://[0-9a-zA-Z]{3,}
# ipfs url # ipfs url
/ipfs/[0-9a-z]* /ipfs/[0-9a-zA-Z]{3,}
# w3 # w3
\bw3\.org/[-0-9a-zA-Z/#.]+ \bw3\.org/[-0-9a-zA-Z/#.]+
@@ -359,14 +377,22 @@ ipfs://[0-9a-z]*
# tinyurl # tinyurl
\btinyurl\.com/\w+ \btinyurl\.com/\w+
# codepen
\bcodepen\.io/[\w/]+
# registry.npmjs.org
\bregistry\.npmjs\.org/(?:@[^/"']+/|)[^/"']+/-/[-\w@.]+
# getopts # getopts
\bgetopts\s+(?:"[^"]+"|'[^']+') \bgetopts\s+(?:"[^"]+"|'[^']+')
# ANSI color codes # ANSI color codes
(?:\\(?:u00|x)1b|\x1b)\[\d+(?:;\d+|)m (?:\\(?:u00|x)1[Bb]|\x1b|\\u\{1[Bb]\})\[\d+(?:;\d+|)m
# URL escaped characters # URL escaped characters
\%[0-9A-F][A-F] \%[0-9A-F][A-F]
# lower URL escaped characters
\%[0-9a-f][a-f](?=[a-z]{2,})
# IPv6 # IPv6
\b(?:[0-9a-fA-F]{0,4}:){3,7}[0-9a-fA-F]{0,4}\b \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) # c99 hex digits (not the full format, just one I've seen)
@@ -376,7 +402,7 @@ ipfs://[0-9a-z]*
# sha # sha
sha\d+:[0-9]*[a-f]{3,}[0-9a-f]* sha\d+:[0-9]*[a-f]{3,}[0-9a-f]*
# sha-... -- uses a fancy capture # sha-... -- uses a fancy capture
(['"]|")[0-9a-f]{40,}\g{-1} (\\?['"]|")[0-9a-f]{40,}\g{-1}
# hex runs # hex runs
\b[0-9a-fA-F]{16,}\b \b[0-9a-fA-F]{16,}\b
# hex in url queries # hex in url queries
@@ -391,18 +417,21 @@ sha\d+:[0-9]*[a-f]{3,}[0-9a-f]*
# Well known gpg keys # Well known gpg keys
.well-known/openpgpkey/[\w./]+ .well-known/openpgpkey/[\w./]+
# pki
-----BEGIN.*-----END
# uuid: # uuid:
\b[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\b \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: # 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
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 # https://www.gnu.org/software/groff/manual/groff.html
# man troff content # man troff content
\\f[BCIPR] \\f[BCIPR]
# ' # '/"
\\\(aq \\\([ad]q
# .desktop mime types # .desktop mime types
^MimeTypes?=.*$ ^MimeTypes?=.*$
@@ -411,21 +440,33 @@ integrity="sha\d+-[-a-zA-Z=;:/0-9+]{40,}"
# Localized .desktop content # Localized .desktop content
Name\[[^\]]+\]=.* Name\[[^\]]+\]=.*
# IServiceProvider # IServiceProvider / isAThing
\bI(?=(?:[A-Z][a-z]{2,})+\b) \b(?:I|isA)(?=(?:[A-Z][a-z]{2,})+\b)
# crypt # crypt
"\$2[ayb]\$.{56}" (['"])\$2[ayb]\$.{56}\g{-1}
# scrypt / argon # scrypt / argon
\$(?:scrypt|argon\d+[di]*)\$\S+ \$(?:scrypt|argon\d+[di]*)\$\S+
# Input to GitHub JSON # go.sum
content: "[-a-zA-Z=;:/0-9+]*=" \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 # 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 # Regular expressions for (P|p)assword
\([A-Z]\|[a-z]\)[a-z]+ \([A-Z]\|[a-z]\)[a-z]+
@@ -441,16 +482,35 @@ content: "[-a-zA-Z=;:/0-9+]*="
^\s*/\\[b].*/[gim]*\s*(?:\)(?:;|$)|,$) ^\s*/\\[b].*/[gim]*\s*(?:\)(?:;|$)|,$)
# javascript replace regex # javascript replace regex
\.replace\(/[^/\s"]*/[gim]*\s*, \.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 # Go regular expressions
regexp?\.MustCompile\(`[^`]*`\) regexp?\.MustCompile\(`[^`]*`\)
# regex choice
\(\?:[^)]+\|[^)]+\)
# proto
^\s*(\w+)\s\g{-1} =
# sed regular expressions # sed regular expressions
sed 's/(?:[^/]*?[a-zA-Z]{3,}[^/]*?/){2} sed 's/(?:[^/]*?[a-zA-Z]{3,}[^/]*?/){2}
# node packages
(["'])\@[^/'" ]+/[^/'" ]+\g{-1}
# go install # go install
go install(?:\s+[a-z]+\.[-@\w/.]+)+ go install(?:\s+[a-z]+\.[-@\w/.]+)+
# jetbrains schema https://youtrack.jetbrains.com/issue/RSRP-489571
urn:shemas-jetbrains-com
# kubernetes pod status lists # kubernetes pod status lists
# https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase # https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
\w+(?:-\w+)+\s+\d+/\d+\s+(?:Running|Pending|Succeeded|Failed|Unknown)\s+ \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 -[0-9a-f]{10}-\w{5}\s
# posthog secrets # posthog secrets
posthog\.init\((['"])phc_[^"',]+\g{-1}, ([`'"])phc_[^"',]+\g{-1}
# xcode # xcode
# xcodeproject scenes # xcodeproject scenes
(?:Controller|ID|id)="\w{3}-\w{2}-\w{3}" (?:Controller|destination|ID|id)="\w{3}-\w{2}-\w{3}"
# xcode api botches # xcode api botches
customObjectInstantitationMethod customObjectInstantitationMethod
# configure flags
.* \| --\w{2,}.*?(?=\w+\s\w+)
# font awesome classes # font awesome classes
\.fa-[-a-z0-9]+ \.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 ) # 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 - # 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: # 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|[,.])* (?:\w|\s|[,.])*\b(?i)(?:amet|consectetur|cursus|dolor|eros|ipsum|lacus|libero|ligula|lorem|magna|neque|nulla|suscipit|tempus)\b(?:\w|\s|[,.])*
# Non-English # 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 # French
# This corpus only had capital letters, but you probably want lowercase ones as well. # This corpus only had capital letters, but you probably want lowercase ones as well.
\b[LN]'+[a-z]{2,}\b \b[LN]'+[a-z]{2,}\b
# latex # latex (check-spelling >= 0.0.22)
\\(?:n(?:ew|ormal|osub)|r(?:enew)|t(?:able(?:of|)|he|itle))(?=[a-z]+) \\\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 # 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: # 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: # ignore long runs of a single character:
\b([A-Za-z])\g{-1}{3,}\b \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# # version suffix <word>v#
(?:(?<=[A-Z]{2})V|(?<=[a-z]{2}|[A-Z]{2})v)\d+(?:\b|(?=[a-zA-Z_])) (?:(?<=[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 (Unix, Java/Scala)
# Compiler flags # Use if you have things like `-Pdocker` and want to treat them as `docker`
#(?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,}) #(?:^|[\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) # Compiler flags (linker)
,-B ,-B
# curl arguments # curl arguments
\b(?:\\n|)curl(?:\s+-[a-zA-Z]{1,2}\b)*(?:\s+-[a-zA-Z]{3,})(?:\s+-[a-zA-Z]+)* \b(?:\\n|)curl(?:\s+-[a-zA-Z]{1,2}\b)*(?:\s+-[a-zA-Z]{3,})(?:\s+-[a-zA-Z]+)*
# set arguments # set arguments

View File

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

View File

@@ -21,6 +21,7 @@ activationaction
ADDUNDORECORD ADDUNDORECORD
ADifferent ADifferent
adio adio
adipiscing
administra administra
ADMINS ADMINS
adml adml
@@ -34,6 +35,7 @@ AGGREGATABLE
AHybrid AHybrid
ALarger ALarger
alekhyareddy alekhyareddy
aliquip
ALLAPPS ALLAPPS
ALLINPUT ALLINPUT
ALLOWUNDO ALLOWUNDO
@@ -97,6 +99,7 @@ ASingle
ASSOCCHANGED ASSOCCHANGED
ASYNCWINDOWPLACEMENT ASYNCWINDOWPLACEMENT
ASYNCWINDOWPOS ASYNCWINDOWPOS
ative
atl atl
atlbase atlbase
atlcom atlcom
@@ -150,7 +153,6 @@ BLURREGION
bmi bmi
bms bms
BNumber BNumber
Bokm
BOKMAL BOKMAL
bootstrapper bootstrapper
BOOTSTRAPPERINSTALLFOLDER BOOTSTRAPPERINSTALLFOLDER
@@ -172,6 +174,7 @@ BTNFACE
Bto Bto
buf buf
bugreport bugreport
BUILDARCH
BUILDNUMBER BUILDNUMBER
buildtask buildtask
buildtransitive buildtransitive
@@ -274,6 +277,7 @@ cominterop
commandline commandline
COMMANDTITLE COMMANDTITLE
commctrl commctrl
commodo
compmgmt compmgmt
COMPOSITIONFULL COMPOSITIONFULL
comsupp comsupp
@@ -284,6 +288,8 @@ CONFIGW
CONFLICTINGMODIFIERKEY CONFLICTINGMODIFIERKEY
CONFLICTINGMODIFIERSHORTCUT CONFLICTINGMODIFIERSHORTCUT
CONOUT CONOUT
consectetur
consequat
Consolas Consolas
constexpr constexpr
consts consts
@@ -326,6 +332,7 @@ CTRLALTDEL
Ctrls Ctrls
Ctx Ctx
CUI CUI
cupidatat
currentculture currentculture
CURRENTDIR CURRENTDIR
CURSORINFO CURSORINFO
@@ -372,6 +379,7 @@ dcomp
DComposition DComposition
dcr dcr
dcs dcs
ddd
DDEIf DDEIf
DDevice DDevice
ddf ddf
@@ -380,6 +388,7 @@ Deact
debian debian
debugbreak debugbreak
DECLAR DECLAR
declatory
declspec declspec
decryptor decryptor
Dedup Dedup
@@ -398,12 +407,12 @@ DELETEDKEYIMAGE
DELETESCANS DELETESCANS
deletethis deletethis
Delimarsky Delimarsky
dend
DENORMAL DENORMAL
Deondre Deondre
depersist depersist
deprioritized deprioritized
deref deref
deserunt
DESKTOPABSOLUTEEDITING DESKTOPABSOLUTEEDITING
DESKTOPABSOLUTEPARSING DESKTOPABSOLUTEPARSING
desktopshorcutinstalled desktopshorcutinstalled
@@ -484,6 +493,7 @@ dxgidebug
dxgiformat dxgiformat
dxguid dxguid
ecount ecount
ecyclebin
EData EData
Edid Edid
EDITKEYBOARD EDITKEYBOARD
@@ -491,8 +501,13 @@ editkeyboardwindow
EDITSHORTCUTS EDITSHORTCUTS
editshortcutswindow editshortcutswindow
EFile EFile
egistry
egistrypreview
eip eip
ekus ekus
elease
elemetry
elit
emmintrin emmintrin
Emoji Emoji
ENABLEDELAYEDEXPANSION ENABLEDELAYEDEXPANSION
@@ -503,6 +518,7 @@ encryptor
endpointvolume endpointvolume
endregion endregion
ENDSESSION ENDSESSION
enim
ENTERSIZEMOVE ENTERSIZEMOVE
ENU ENU
EOAC EOAC
@@ -517,10 +533,16 @@ ERRORLEVEL
ERRORTITLE ERRORTITLE
ESettings ESettings
esize esize
esource
esrp esrp
estapp
estart
ests
esult
etl etl
etstat etstat
etw ETW
etwork
EUQ EUQ
eurochange eurochange
eventlog eventlog
@@ -538,6 +560,7 @@ exabyte
examplehandler examplehandler
examplepowertoy examplepowertoy
EXAND EXAND
Excepteur
EXCLUDEFROMCAPTURE EXCLUDEFROMCAPTURE
exdisp exdisp
executionpolicy executionpolicy
@@ -548,6 +571,8 @@ exlist
EXPCMDFLAGS EXPCMDFLAGS
EXPCMDSTATE EXPCMDSTATE
explr explr
exppowertoys
exptas
exsb exsb
EXSEL EXSEL
exstyle exstyle
@@ -575,7 +600,7 @@ FILEOP
FILEOS FILEOS
FILESUBTYPE FILESUBTYPE
FILESYSPATH FILESYSPATH
filetime Filetime
FILEVERSION FILEVERSION
Filtergraph Filtergraph
Filterkeyboard Filterkeyboard
@@ -907,6 +932,8 @@ killrunner
Knownfolders Knownfolders
KSPROPERTY KSPROPERTY
Kybd Kybd
laboris
laborum
LAlt LAlt
Lambson Lambson
langword langword
@@ -1028,6 +1055,7 @@ majortype
MAJORVERSION MAJORVERSION
makecab makecab
MAKEINTRESOURCE MAKEINTRESOURCE
MAKEINTRESOURCEA
MAKEINTRESOURCEW MAKEINTRESOURCEW
makepri makepri
manifestdependency manifestdependency
@@ -1110,6 +1138,7 @@ mockapi
MODECHANGE MODECHANGE
modernwpf modernwpf
MODESPRUNED MODESPRUNED
mollit
MONITORENUMPROC MONITORENUMPROC
MONITORINFO MONITORINFO
MONITORINFOEX MONITORINFOEX
@@ -1128,6 +1157,8 @@ MOUSEWHEEL
MOVESIZEEND MOVESIZEEND
MOVESIZESTART MOVESIZESTART
mozilla mozilla
MOZILLAPL
MOZPL
mpmc mpmc
MRM MRM
MRT MRT
@@ -1154,10 +1185,12 @@ msrc
msstore msstore
mst mst
msvc msvc
msvcp
MTND MTND
Mul Mul
MULTIPLEUSE MULTIPLEUSE
multizone multizone
muxc
mvvm mvvm
mwb mwb
MWBEx MWBEx
@@ -1182,6 +1215,7 @@ NCMBUTTONUP
NCMOUSELEAVE NCMOUSELEAVE
NCMOUSEMOVE NCMOUSEMOVE
NCol NCol
nconsectetur
ncpa ncpa
NCPAINT NCPAINT
NCRBUTTONDBLCLK NCRBUTTONDBLCLK
@@ -1197,6 +1231,7 @@ netcore
netcoreapp netcoreapp
netcpl netcpl
netframework netframework
Netscape
netsetup netsetup
netsh netsh
Neue Neue
@@ -1205,8 +1240,8 @@ newdev
newitem newitem
newpath newpath
newrow newrow
newsgroups
Newtonsoft Newtonsoft
niels
nielslaute nielslaute
NIF NIF
nint nint
@@ -1223,6 +1258,8 @@ NOCOPYBITS
nodeca nodeca
nodiscard nodiscard
nodoc nodoc
NODRAWCAPTION
NODRAWICON
NOINHERITLAYOUT NOINHERITLAYOUT
NOINTERFACE NOINTERFACE
NOLINKINFO NOLINKINFO
@@ -1249,6 +1286,7 @@ NORMALUSER
NOSEARCH NOSEARCH
NOSENDCHANGING NOSENDCHANGING
NOSIZE NOSIZE
nostrud
notfound notfound
NOTIFICATIONSDLL NOTIFICATIONSDLL
NOTIFYICONDATAW NOTIFYICONDATAW
@@ -1264,6 +1302,7 @@ NOZORDER
NPH NPH
NResize NResize
nrw nrw
nsunt
NTAPI NTAPI
ntdll ntdll
ntfs ntfs
@@ -1280,12 +1319,15 @@ Objbase
OBJID OBJID
objidl objidl
oblitum oblitum
obmikh
occaecat
ocr ocr
Ocrsettings Ocrsettings
odbc odbc
odbccp odbccp
Oem Oem
officehubintl officehubintl
officia
ofs ofs
oid oid
oldcolor oldcolor
@@ -1302,6 +1344,7 @@ onenote
onstd onstd
oobe oobe
OOBEPT OOBEPT
ools
opencode opencode
opensource opensource
openxmlformats openxmlformats
@@ -1315,6 +1358,8 @@ ostr
OSVERSIONINFOEX OSVERSIONINFOEX
OSVERSIONINFOEXW OSVERSIONINFOEXW
osvi osvi
otating
otifications
OUTOFCONTEXT OUTOFCONTEXT
OUTOFMEMORY OUTOFMEMORY
outpin outpin
@@ -1461,6 +1506,7 @@ PRODUCTVERSION
Progman Progman
programdata programdata
PROGRAMFILES PROGRAMFILES
proident
projectname projectname
PROPBAG PROPBAG
PROPERTYKEY PROPERTYKEY
@@ -1541,6 +1587,7 @@ RECTL
rectp rectp
rects rects
RECTSOURCE RECTSOURCE
recyclebin
redirectedfrom redirectedfrom
Redist Redist
redistributable redistributable
@@ -1612,6 +1659,7 @@ RIGHTDOWN
RIGHTSCROLLBAR RIGHTSCROLLBAR
RIGHTUP RIGHTUP
riid riid
ringbuffer
RKey RKey
RLO RLO
RMENU RMENU
@@ -1677,7 +1725,6 @@ SDKDDK
sdns sdns
searchterm searchterm
secpol secpol
Secur
Segoe Segoe
Sekan Sekan
SENDCHANGE SENDCHANGE
@@ -1698,6 +1745,7 @@ SETTINGCHANGE
SETTINGSCHANGED SETTINGSCHANGED
settingsheader settingsheader
settingshotkeycontrol settingshotkeycontrol
setvariable
SETWORKAREA SETWORKAREA
setzero setzero
sfgao sfgao
@@ -1853,6 +1901,7 @@ stylecop
Subdir Subdir
subfolders subfolders
subkey subkey
subkeys
SUBLANG SUBLANG
subquery subquery
subresource subresource
@@ -1888,7 +1937,7 @@ SYSTEMTIME
sysvol sysvol
Tadele Tadele
talynone talynone
TApp tapp
TApplication TApplication
TApplied TApplied
targ targ
@@ -1945,6 +1994,7 @@ tlbimp
TMPVAR TMPVAR
TNP TNP
toggleswitch toggleswitch
tonos
toolkitcontrols toolkitcontrols
toolkitconverters toolkitconverters
Toolset Toolset
@@ -1965,6 +2015,7 @@ Tsd
TServer TServer
TStr TStr
TValue TValue
tweakme
TWF TWF
tymed tymed
typedef typedef
@@ -1987,6 +2038,7 @@ UIEx
uipi uipi
UIs UIs
ULARGE ULARGE
ullamco
ULONGLONG ULONGLONG
ums ums
unapply unapply
@@ -2008,6 +2060,7 @@ unknwn
UNLEN UNLEN
Unmap Unmap
unmute unmute
unner
UNORM UNORM
unregistering unregistering
unremapped unremapped
@@ -2048,6 +2101,7 @@ VCINSTALLDIR
vcm vcm
Vcpkg Vcpkg
VCRT VCRT
vcruntime
vcvars vcvars
VDesktop VDesktop
vdi vdi
@@ -2090,6 +2144,7 @@ vsconfig
VSCROLL VSCROLL
vsetq vsetq
VSM VSM
vso
vsonline vsonline
vstemplate vstemplate
VSTHRD VSTHRD
@@ -2186,7 +2241,7 @@ WKSG
Wlkr Wlkr
wmain wmain
Wman Wman
wmi WMI
WMICIM WMICIM
wmimgmt wmimgmt
WMKEYDOWN WMKEYDOWN
@@ -2229,6 +2284,8 @@ wsl
wss wss
wstr wstr
wsz wsz
WTA
WTNCA
wtoi wtoi
WTS WTS
wtsapi 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 # \bm_data\b
# If you have a framework that uses `it()` for testing and `fit()` for debugging a specific test, # If you have a framework that uses `it()` for testing and `fit()` for debugging a specific test,
@@ -6,40 +8,72 @@
# to use this: # to use this:
#\bfit\( #\bfit\(
# s.b. anymore
\bany more[,.]
# s.b. GitHub # s.b. GitHub
\bGithub\b (?<![&*.]|// |\btype )\bGithub\b(?![{)])
# s.b. GitLab # s.b. GitLab
\bGitlab\b (?<![&*.]|// |\btype )\bGitlab\b(?![{)])
# s.b. JavaScript # s.b. JavaScript
\bJavascript\b \bJavascript\b
# s.b. macOS or Mac OS X or ...
\bMacOS\b
# s.b. Microsoft # s.b. Microsoft
\bMicroSoft\b \bMicroSoft\b
# s.b. TypeScript
\bTypescript\b
# s.b. another # s.b. another
\ban[- ]other\b \ban[- ]other\b
# s.b. deprecation warning
\b[Dd]epreciation [Ww]arnings?\b
# s.b. greater than # s.b. greater than
\bgreater then\b \bgreater then\b
# s.b. in front of
\bin from of\b
# s.b. into # 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 # s.b. opt-in
\sopt in\s (?<!\sfor)\sopt in\s
# s.b. less than # s.b. less than
\bless then\b \bless then\b
# s.b. one of
\bon of\b
# s.b. otherwise # s.b. otherwise
\bother[- ]wise\b \bother[- ]wise\b
# s.b. or (more|less)
\bore (?:more|less)\b
# s.b. nonexistent # s.b. nonexistent
\bnon existing\b \bnon existing\b
\b[Nn]o[nt][- ]existent\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 # s.b. preexisting
[Pp]re[- ]existing [Pp]re[- ]existing
@@ -49,14 +83,37 @@
# s.b. preemptively # s.b. preemptively
[Pp]re[- ]emptively [Pp]re[- ]emptively
# s.b. recently changed or recent changes
[Rr]ecent changed
# s.b. reentrancy # s.b. reentrancy
[Rr]e[- ]entrancy [Rr]e[- ]entrancy
# s.b. reentrant # s.b. reentrant
[Rr]e[- ]entrant [Rr]e[- ]entrant
# s.b. workaround(s) # s.b. understand
#\bwork[- ]arounds?\b \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 \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 # See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns
# Automatically suggested patterns # Automatically suggested patterns
# hit-count: 2206 file-count: 617 # hit-count: 3011 file-count: 842
# IServiceProvider # IServiceProvider / isAThing
\bI(?=(?:[A-Z][a-z]{2,})+\b) \b(?:I|isA)(?=(?:[A-Z][a-z]{2,})+\b)
# hit-count: 111 file-count: 57 # hit-count: 2239 file-count: 134
# hex runs # hex runs
\b[0-9a-fA-F]{16,}\b \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) # GitHub SHAs (markdown)
(?:\[`?[0-9a-f]+`?\]\(https:/|)/(?:www\.|)github\.com(?:/[^/\s"]+){2,}(?:/[^/\s")]+)(?:[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|) (?:\[`?[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 # w3
\bw3\.org/[-0-9a-zA-Z/#.]+ \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 # Contributor
\[[^\]]+\]\(https://github\.com/[^/\s"]+\) \[[^\]]+\]\(https://github\.com/[^/\s"]+/?\)
# hit-count: 45 file-count: 2 # hit-count: 28 file-count: 22
# Non-English
[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*
# hit-count: 22 file-count: 18
# stackexchange -- https://stackexchange.com/feeds/sites # stackexchange -- https://stackexchange.com/feeds/sites
\b(?:askubuntu|serverfault|stack(?:exchange|overflow)|superuser).com/(?:questions/\w+/[-\w]+|a/) \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 # Wikipedia
\ben\.wikipedia\.org/wiki/[-\w%.#]+ \ben\.wikipedia\.org/wiki/[-\w%.#]+
# hit-count: 6 file-count: 3
# css url wrappings
\burl\([^)]+\)
# hit-count: 5 file-count: 3 # hit-count: 5 file-count: 3
# vs devops # vs devops
\bvisualstudio.com(?::443|)/[-\w/?=%&.]* \bvisualstudio.com(?::443|)/[-\w/?=%&.]*
# hit-count: 3 file-count: 3 # hit-count: 4 file-count: 3
# githubusercontent # Non-English
/[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]* [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 # hit-count: 2 file-count: 2
# mailto urls # mailto urls
mailto:[-a-zA-Z=;:/?%&0-9+@.]{3,} 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 # msdn
\b(?:download\.visualstudio|docs|msdn|learn)\.microsoft\.com/[-_a-zA-Z0-9()=./]* \b(?:download\.visualstudio|docs|msdn|learn)\.microsoft\.com/[-_a-zA-Z0-9()=./]*
aka\.ms/[a-zA-Z0-9]+ aka\.ms/[a-zA-Z0-9]+
# medium # hit-count: 2 file-count: 1
link\.medium\.com/[a-zA-Z0-9]+ # While you could try to match `http://` and `https://` by using `s?` in `https?://`, sometimes there
\bmedium\.com/\@[^/]+/[-\w]+ # YouTube url
\b(?:(?:www\.|)youtube\.com|youtu.be)/(?:channel/|embed/|user/|playlist\?list=|watch\?v=|v/|)[-a-zA-Z0-9?&=_%]*
# 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*
# uuid: (or CompGUIDPrefix) # uuid: (or CompGUIDPrefix)
L?(["']|[-<({>]|\b)[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{10,12}(?:\g{-1}|[<})>]) 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]+" (?:L"[abAB]+", ){3}L"[abAB]+"
"Lorem[^"]+?\."
TestCase\("[^"]+"
# Test line with hexadecimal colors # hit-count: 1 file-count: 1
\[DataRow\("[0-9A-F]{6}", \d{3}, \d{3}, \d{3}\)\] # marker to ignore all code on line
\[DataRow\("[0-9A-F]{6}", \d{3}.\d{1}, \d{3}.\d{1}, \d{3}.\d{1}\)\] ^.*/\* #no-spell-check-line \*/.*$
\[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}",$
# UnitTests # UnitTests
\[DataRow\(.*\)\] \[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 # D2D
D?2D D?2D
# marker for ignoring a comment to the end of the line # hit-count: 1 file-count: 1
^.*/\* #no-spell-check-line \*/.*$ # GHSA
// #no-spell-check.*$ 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 # 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` # Questionably acceptable forms of `in to`
# Personally, I prefer `log into`, but people object # Personally, I prefer `log into`, but people object
# https://www.tprteaching.com/log-into-log-in-to-login/ # 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 # acceptable duplicates
# ls directory listings # ls directory listings
# /bin/ls -l output [-bcdlpsw](?:[-r][-w][-Ssx]){3}\s+\d+\s+\S+\s+\S+\s+\d+\s+
[-bcdlpsw](?:[-r][-w][-sx]){3}\s+\d+\s+(\S+)\s+\g{-1}\s+\d+\s+ # mount
\bmount\s+-t\s+(\w+)\s+\g{-1}\b
# C types and repeated CSS values # 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 # go templates
\s(\w+)\s+\g{-1}\s+\`(?:graphql|json|yaml): \s(\w+)\s+\g{-1}\s+\`(?:graphql|inject|json|yaml):
# javadoc / .net # doxygen / javadoc / .net
(?:[\\@](?:groupname|param)|(?:public|private)(?:\s+static|\s+readonly)*)\s+(\w+)\s+\g{-1}\s (?:[\\@](?: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 # Commit message -- Signed-off-by and friends
^\s*(?:(?:Based-on-patch|Co-authored|Helped|Mentored|Reported|Reviewed|Signed-off)-by|Thanks-to): (?:[^<]*<[^>]*>|[^<]*)\s*$ ^\s*(?:(?:Based-on-patch|Co-authored|Helped|Mentored|Reported|Reviewed|Signed-off)-by|Thanks-to): (?:[^<]*<[^>]*>|[^<]*)\s*$

View File

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

View File

@@ -233,5 +233,14 @@ configuration:
- addReply: - addReply:
reply: Hi! Thanks for making us aware of the problem. We raised the issue with our internal localization team. This issue should be fixed hopefully in the next version of PowerToys. reply: Hi! Thanks for making us aware of the problem. We raised the issue with our internal localization team. This issue should be fixed hopefully in the next version of PowerToys.
description: description:
- if:
- payloadType: Issue_Comment
- commentContains:
pattern: 'I would [like|love] [to help|helping|to contribute|contributing|to implement|implementing|to fix|fixing]'
isRegex: True
then:
- addReply:
reply: Hi! Your last comment indicates to our system, that you might want to contribute to this feature/fix this bug. Thank you! Please make us aware on our ["Would you like to contribute to PowerToys?" thread](https://github.com/microsoft/PowerToys/issues/28769), as we don't see all the comments. <br /><br />_I'm a bot (beep!) so please excuse any mistakes I may make_
description:
onFailure: onFailure:
onSuccess: onSuccess:

View File

@@ -5,7 +5,7 @@ name: Spell checking
# https://github.com/check-spelling/check-spelling/wiki/Feature%3A-Restricted-Permissions # 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 # `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. # 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 # `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 # 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: on:
push: push:
branches: branches:
@@ -43,12 +66,13 @@ on:
pull_request_target: pull_request_target:
branches: branches:
- "**" - "**"
tags-ignore:
- "**"
types: types:
- 'opened' - 'opened'
- 'reopened' - 'reopened'
- 'synchronize' - 'synchronize'
issue_comment:
types:
- 'created'
jobs: jobs:
spelling: spelling:
@@ -57,10 +81,11 @@ jobs:
contents: read contents: read
pull-requests: read pull-requests: read
actions: read actions: read
security-events: write
outputs: outputs:
followup: ${{ steps.spelling.outputs.followup }} followup: ${{ steps.spelling.outputs.followup }}
runs-on: ubuntu-latest 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: concurrency:
group: spelling-${{ github.event.pull_request.number || github.ref }} group: spelling-${{ github.event.pull_request.number || github.ref }}
# note: If you use only_check_changed_files, you do not want cancel-in-progress # note: If you use only_check_changed_files, you do not want cancel-in-progress
@@ -68,24 +93,45 @@ jobs:
steps: steps:
- name: check-spelling - name: check-spelling
id: spelling id: spelling
uses: check-spelling/check-spelling@v0.0.21 uses: check-spelling/check-spelling@v0.0.22
with: with:
config: .github/actions/spell-check 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 checkout: true
check_file_names: 1 check_file_names: 1
spell_check_this: check-spelling/spell-check-this@prerelease spell_check_this: microsoft/PowerToys@main
post_comment: 0 post_comment: 0
use_magic_file: 1 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: extra_dictionaries:
cspell:software-terms/src/software-terms.txt cspell:software-terms/dict/softwareTerms.txt
cspell:cpp/src/stdlib-cpp.txt cspell:cpp/src/stdlib-cpp.txt
cspell:filetypes/filetypes.txt cspell:filetypes/filetypes.txt
cspell:cpp/src/stdlib-c.txt cspell:cpp/src/stdlib-c.txt
cspell:fullstack/fullstack.txt cspell:python/src/python/python-lib.txt
cspell:html/html.txt cspell:lorem-ipsum/dictionary.txt
cspell:css/css.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: comment-push:
name: Report (Push) name: Report (Push)
@@ -97,11 +143,11 @@ jobs:
if: (success() || failure()) && needs.spelling.outputs.followup && github.event_name == 'push' if: (success() || failure()) && needs.spelling.outputs.followup && github.event_name == 'push'
steps: steps:
- name: comment - name: comment
uses: check-spelling/check-spelling@v0.0.21 uses: check-spelling/check-spelling@v0.0.22
with: with:
config: .github/actions/spell-check config: .github/actions/spell-check
checkout: true checkout: true
spell_check_this: check-spelling/spell-check-this@prerelease spell_check_this: microsoft/PowerToys@main
task: ${{ needs.spelling.outputs.followup }} task: ${{ needs.spelling.outputs.followup }}
comment-pr: comment-pr:
@@ -110,13 +156,39 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: spelling needs: spelling
permissions: permissions:
contents: read
pull-requests: write pull-requests: write
if: (success() || failure()) && needs.spelling.outputs.followup && contains(github.event_name, 'pull_request') if: (success() || failure()) && needs.spelling.outputs.followup && contains(github.event_name, 'pull_request')
steps: steps:
- name: comment - name: comment
uses: check-spelling/check-spelling@v0.0.21 uses: check-spelling/check-spelling@v0.0.22
with: with:
config: .github/actions/spell-check config: .github/actions/spell-check
checkout: true checkout: true
spell_check_this: check-spelling/spell-check-this@prerelease spell_check_this: check-spelling/spell-check-this@prerelease
task: ${{ needs.spelling.outputs.followup }} 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

@@ -73,6 +73,12 @@
"PowerToys.PdfThumbnailProviderCpp.dll", "PowerToys.PdfThumbnailProviderCpp.dll",
"PowerToys.powerpreview.dll", "PowerToys.powerpreview.dll",
"PowerToys.PreviewHandlerCommon.dll", "PowerToys.PreviewHandlerCommon.dll",
"PowerToys.QoiPreviewHandler.dll",
"PowerToys.QoiPreviewHandler.exe",
"PowerToys.QoiPreviewHandlerCpp.dll",
"PowerToys.QoiThumbnailProvider.dll",
"PowerToys.QoiThumbnailProvider.exe",
"PowerToys.QoiThumbnailProviderCpp.dll",
"PowerToys.StlThumbnailProvider.dll", "PowerToys.StlThumbnailProvider.dll",
"PowerToys.StlThumbnailProvider.exe", "PowerToys.StlThumbnailProvider.exe",
"PowerToys.StlThumbnailProviderCpp.dll", "PowerToys.StlThumbnailProviderCpp.dll",
@@ -289,6 +295,7 @@
"ColorCode.Core.dll", "ColorCode.Core.dll",
"ColorCode.UWP.dll", "ColorCode.UWP.dll",
"UnitsNet.dll", "UnitsNet.dll",
"UtfUnknown.dll",
"Wpf.Ui.dll" "Wpf.Ui.dll"
], ],
"SigningInfo": { "SigningInfo": {

View File

@@ -1,3 +1,4 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/main/service-schema.json
trigger: trigger:
batch: true batch: true
branches: branches:
@@ -9,18 +10,24 @@ trigger:
- doc/* - doc/*
- temp/* - temp/*
- tools/* - tools/*
- '**.md'
pr: pr:
branches: branches:
include: include:
- main - main
- stable - stable
paths:
exclude:
- '**.md'
- doc
# 0.0.yyMM.dd## # 0.0.yyMM.dd##
# 0.0.1904.0900 # 0.0.1904.0900
name: 0.0.$(Date:yyMM).$(Date:dd)$(Rev:rr) name: 0.0.$(Date:yyMM).$(Date:dd)$(Rev:rr)
jobs: jobs:
- template: ./templates/build-powertoys-precheck.yml
- template: ./templates/build-powertoys-ci.yml - template: ./templates/build-powertoys-ci.yml
parameters: parameters:
platform: x64 platform: x64

View File

@@ -6,6 +6,8 @@ parameters:
jobs: jobs:
- job: Build${{ parameters.platform }}${{ parameters.configuration }} - job: Build${{ parameters.platform }}${{ parameters.configuration }}
displayName: Build ${{ parameters.platform }} ${{ parameters.configuration }} displayName: Build ${{ parameters.platform }} ${{ parameters.configuration }}
dependsOn: Precheck
condition: and(succeeded(),ne(dependencies.Precheck.outputs['verifyBuildRequest.skipBuild'], 'Yes'))
variables: variables:
BuildConfiguration: ${{ parameters.configuration }} BuildConfiguration: ${{ parameters.configuration }}
BuildPlatform: ${{ parameters.platform }} BuildPlatform: ${{ parameters.platform }}

View File

@@ -0,0 +1,38 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json
jobs:
- job: Precheck
pool:
demands: ImageOverride -equals SHINE-VS17-Latest
${{ if eq(variables['System.CollectionUri'], 'https://dev.azure.com/ms/') }}:
name: SHINE-OSS-L
${{ if ne(variables['System.CollectionUri'], 'https://dev.azure.com/ms/') }}:
name: SHINE-INT-L
steps:
- checkout: none
- task: PowerShell@2
displayName: Verify Build Request
inputs:
targetType: 'inline'
script: |
try {
# Try based on pull request first
$pullRequestNumber = "$(system.pullRequest.pullRequestNumber)";
$gitHubPullRequest = Invoke-RestMethod -Method Get "https://api.github.com/repos/microsoft/PowerToys/pulls/$pullRequestNumber/files"
# If there are no files updated in the commit that are .md, set skipBuild variable
if(([array]($gitHubPullRequest.filename) -notmatch ".md|.txt").Length -eq 0) {
Write-Host '##vso[task.setvariable variable=skipBuild;isOutput=true]Yes'
Write-Host 'Skipping Build'
}
}
catch {
# Fall back to the latest commit otherwise.
$commit = "$(build.sourceVersion)";
$gitHubCommit = Invoke-RestMethod -Method Get "https://api.github.com/repos/microsoft/PowerToys/commits/$commit"
if(([array]($githubCommit.files.filename) -notmatch ".md|.txt").Length -eq 0) {
Write-Host '##vso[task.setvariable variable=skipBuild;isOutput=true]Yes'
Write-Host 'Skipping Build'
}
}
pwsh: true
name: verifyBuildRequest

View File

@@ -195,8 +195,10 @@ steps:
**\UnitTests-GcodeThumbnailProvider.dll **\UnitTests-GcodeThumbnailProvider.dll
**\UnitTests-StlThumbnailProvider.dll **\UnitTests-StlThumbnailProvider.dll
**\UnitTests-PdfThumbnailProvider.dll **\UnitTests-PdfThumbnailProvider.dll
**\UnitTests-QoiThumbnailProvider.dll
**\Settings.UI.UnitTests.dll **\Settings.UI.UnitTests.dll
**\UnitTests-GcodePreviewHandler.dll **\UnitTests-GcodePreviewHandler.dll
**\UnitTests-QoiPreviewHandler.dll
**\UnitTests-FancyZonesEditor.dll **\UnitTests-FancyZonesEditor.dll
**\UnitTests-PdfPreviewHandler.dll **\UnitTests-PdfPreviewHandler.dll
**\UnitTests-PreviewHandlerCommon.dll **\UnitTests-PreviewHandlerCommon.dll

View File

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

View File

@@ -31,7 +31,7 @@ Upvote the original issue by clicking its [+😊] button and hitting 👍 (+1) i
## Contributing fixes / features ## Contributing fixes / features
Please comment on an issue to let us know you're interested in working on something before you start the work. Not only does this avoid multiple people unexpectedly working on the same thing at the same time but it enables us to make sure everyone is clear on what should be done to implement any new functionality. It's less work for everyone, in the long run, to establish this up front. Please comment on [our "Would you like to contribute to PowerToys?" thread](https://github.com/microsoft/PowerToys/issues/28769) to let us know you're interested in working on something before you start the work. Not only does this avoid multiple people unexpectedly working on the same thing at the same time but it enables us to make sure everyone is clear on what should be done to implement any new functionality. It's less work for everyone, in the long run, to establish this up front.
### Localization issues ### Localization issues

View File

@@ -12,6 +12,7 @@
<EnableNETAnalyzers>true</EnableNETAnalyzers> <EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>Recommended</AnalysisMode> <AnalysisMode>Recommended</AnalysisMode>
<_SkipUpgradeNetAnalyzersNuGetWarning>true</_SkipUpgradeNetAnalyzersNuGetWarning> <_SkipUpgradeNetAnalyzersNuGetWarning>true</_SkipUpgradeNetAnalyzersNuGetWarning>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion> <!-- Don't add source revision hash to the product version of binaries. -->
<PlatformTarget>$(Platform)</PlatformTarget> <PlatformTarget>$(Platform)</PlatformTarget>
</PropertyGroup> </PropertyGroup>

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

@@ -34,11 +34,11 @@
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" /> <PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" /> <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageVersion Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.2" /> <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.Compatibility" Version="7.0.3" />
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.2.46-beta" /> <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. --> <!-- 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. -->
<PackageVersion Include="Microsoft.Windows.CsWinRT" Version="2.0.3" /> <PackageVersion Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" /> <PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageVersion Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" /> <PackageVersion Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.4.230913002" /> <PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.4.230913002" />
@@ -67,12 +67,14 @@
<PackageVersion Include="System.Reactive" Version="6.0.0-preview.9" /> <PackageVersion Include="System.Reactive" Version="6.0.0-preview.9" />
<PackageVersion Include="System.Runtime.Caching" Version="7.0.0" /> <PackageVersion Include="System.Runtime.Caching" Version="7.0.0" />
<PackageVersion Include="System.ServiceProcess.ServiceController" Version="7.0.1" /> <PackageVersion Include="System.ServiceProcess.ServiceController" Version="7.0.1" />
<PackageVersion Include="System.Text.Encoding.CodePages" Version="7.0.0" />
<PackageVersion Include="UnicodeInformation" Version="2.6.0" /> <PackageVersion Include="UnicodeInformation" Version="2.6.0" />
<PackageVersion Include="UnitsNet" Version="4.145.0" /> <PackageVersion Include="UnitsNet" Version="4.145.0" />
<PackageVersion Include="UTF.Unknown" Version="2.5.1" />
<PackageVersion Include="Vanara.PInvoke.User32" Version="3.4.11" /> <PackageVersion Include="Vanara.PInvoke.User32" Version="3.4.11" />
<PackageVersion Include="Vanara.PInvoke.Shell32" Version="3.4.11" /> <PackageVersion Include="Vanara.PInvoke.Shell32" Version="3.4.11" />
<PackageVersion Include="WinUIEx" Version="2.2.0" /> <PackageVersion Include="WinUIEx" Version="2.2.0" />
<PackageVersion Include="WPF-UI" Version="3.0.0-preview.4" /> <PackageVersion Include="WPF-UI" Version="3.0.0-preview.9" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(IsExperimentationLive)'!=''"> <ItemGroup Condition="'$(IsExperimentationLive)'!=''">
<!-- Additional dependencies used by experimentation --> <!-- Additional dependencies used by experimentation -->

967
NOTICE.md

File diff suppressed because it is too large Load Diff

View File

@@ -177,6 +177,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
src\.editorconfig = src\.editorconfig src\.editorconfig = src\.editorconfig
.vsconfig = .vsconfig .vsconfig = .vsconfig
Directory.Build.props = Directory.Build.props Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Directory.Packages.props = Directory.Packages.props Directory.Packages.props = Directory.Packages.props
Solution.props = Solution.props Solution.props = Solution.props
EndProjectSection EndProjectSection
@@ -537,7 +538,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLock", "src\modules\
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLockModuleInterface", "src\modules\CropAndLock\CropAndLockModuleInterface\CropAndLockModuleInterface.vcxproj", "{3157FA75-86CF-4EE2-8F62-C43F776493C6}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLockModuleInterface", "src\modules\CropAndLock\CropAndLockModuleInterface\CropAndLockModuleInterface.vcxproj", "{3157FA75-86CF-4EE2-8F62-C43F776493C6}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-FancyZonesEditor", "src\modules\fancyzones\UnitTests-FancyZonesEditor\UnitTests-FancyZonesEditor.csproj", "{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests-FancyZonesEditor", "src\modules\fancyzones\UnitTests-FancyZonesEditor\UnitTests-FancyZonesEditor.csproj", "{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EnvironmentVariables", "EnvironmentVariables", "{538ED0BB-B863-4B20-98CC-BCDF7FA0B68A}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EnvironmentVariables", "EnvironmentVariables", "{538ED0BB-B863-4B20-98CC-BCDF7FA0B68A}"
EndProject EndProject
@@ -545,6 +546,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnvironmentVariables", "src
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EnvironmentVariablesModuleInterface", "src\modules\EnvironmentVariables\EnvironmentVariablesModuleInterface\EnvironmentVariablesModuleInterface.vcxproj", "{B9420661-B0E4-4241-ABD4-4A27A1F64250}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EnvironmentVariablesModuleInterface", "src\modules\EnvironmentVariables\EnvironmentVariablesModuleInterface\EnvironmentVariablesModuleInterface.vcxproj", "{B9420661-B0E4-4241-ABD4-4A27A1F64250}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoiThumbnailProviderCpp", "src\modules\previewpane\QoiThumbnailProviderCpp\QoiThumbnailProviderCpp.vcxproj", "{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QoiThumbnailProvider", "src\modules\previewpane\QoiThumbnailProvider\QoiThumbnailProvider.csproj", "{D949EC7D-48A9-4279-95D5-078E7FD1F048}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QoiPreviewHandlerCpp", "src\modules\previewpane\QoiPreviewHandlerCpp\QoiPreviewHandlerCpp.vcxproj", "{3BAF9C81-A194-4925-A035-5E24A5D1E542}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QoiPreviewHandler", "src\modules\previewpane\QoiPreviewHandler\QoiPreviewHandler.csproj", "{6B04803D-B418-4833-A67E-B0FC966636A5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests-QoiPreviewHandler", "src\modules\previewpane\UnitTests-QoiPreviewHandler\UnitTests-QoiPreviewHandler.csproj", "{3940AD4D-F748-4BE4-9083-85769CD553EF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests-QoiThumbnailProvider", "src\modules\previewpane\UnitTests-QoiThumbnailProvider\UnitTests-QoiThumbnailProvider.csproj", "{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests-FancyZones", "src\modules\fancyzones\UITests-FancyZones\UITests-FancyZones.csproj", "{FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests-FancyZones", "src\modules\fancyzones\UITests-FancyZones\UITests-FancyZones.csproj", "{FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests-FancyZonesEditor", "src\modules\fancyzones\UITests-FancyZonesEditor\UITests-FancyZonesEditor.csproj", "{3A9A791E-94A9-49F8-8401-C11CE288D5FB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests-FancyZonesEditor", "src\modules\fancyzones\UITests-FancyZonesEditor\UITests-FancyZonesEditor.csproj", "{3A9A791E-94A9-49F8-8401-C11CE288D5FB}"
@@ -2355,6 +2368,78 @@ Global
{B9420661-B0E4-4241-ABD4-4A27A1F64250}.Release|x64.Build.0 = Release|x64 {B9420661-B0E4-4241-ABD4-4A27A1F64250}.Release|x64.Build.0 = Release|x64
{B9420661-B0E4-4241-ABD4-4A27A1F64250}.Release|x86.ActiveCfg = Release|x64 {B9420661-B0E4-4241-ABD4-4A27A1F64250}.Release|x86.ActiveCfg = Release|x64
{B9420661-B0E4-4241-ABD4-4A27A1F64250}.Release|x86.Build.0 = Release|x64 {B9420661-B0E4-4241-ABD4-4A27A1F64250}.Release|x86.Build.0 = Release|x64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Debug|ARM64.ActiveCfg = Debug|ARM64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Debug|ARM64.Build.0 = Debug|ARM64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Debug|x64.ActiveCfg = Debug|x64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Debug|x64.Build.0 = Debug|x64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Debug|x86.ActiveCfg = Debug|x64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Debug|x86.Build.0 = Debug|x64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Release|ARM64.ActiveCfg = Release|ARM64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Release|ARM64.Build.0 = Release|ARM64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Release|x64.ActiveCfg = Release|x64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Release|x64.Build.0 = Release|x64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Release|x86.ActiveCfg = Release|x64
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7}.Release|x86.Build.0 = Release|x64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Debug|ARM64.ActiveCfg = Debug|ARM64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Debug|ARM64.Build.0 = Debug|ARM64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Debug|x64.ActiveCfg = Debug|x64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Debug|x64.Build.0 = Debug|x64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Debug|x86.ActiveCfg = Debug|x64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Debug|x86.Build.0 = Debug|x64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Release|ARM64.ActiveCfg = Release|ARM64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Release|ARM64.Build.0 = Release|ARM64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Release|x64.ActiveCfg = Release|x64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Release|x64.Build.0 = Release|x64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Release|x86.ActiveCfg = Release|x64
{D949EC7D-48A9-4279-95D5-078E7FD1F048}.Release|x86.Build.0 = Release|x64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Debug|ARM64.ActiveCfg = Debug|ARM64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Debug|ARM64.Build.0 = Debug|ARM64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Debug|x64.ActiveCfg = Debug|x64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Debug|x64.Build.0 = Debug|x64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Debug|x86.ActiveCfg = Debug|x64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Debug|x86.Build.0 = Debug|x64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Release|ARM64.ActiveCfg = Release|ARM64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Release|ARM64.Build.0 = Release|ARM64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Release|x64.ActiveCfg = Release|x64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Release|x64.Build.0 = Release|x64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Release|x86.ActiveCfg = Release|x64
{3BAF9C81-A194-4925-A035-5E24A5D1E542}.Release|x86.Build.0 = Release|x64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Debug|ARM64.ActiveCfg = Debug|ARM64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Debug|ARM64.Build.0 = Debug|ARM64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Debug|x64.ActiveCfg = Debug|x64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Debug|x64.Build.0 = Debug|x64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Debug|x86.ActiveCfg = Debug|x64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Debug|x86.Build.0 = Debug|x64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Release|ARM64.ActiveCfg = Release|ARM64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Release|ARM64.Build.0 = Release|ARM64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Release|x64.ActiveCfg = Release|x64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Release|x64.Build.0 = Release|x64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Release|x86.ActiveCfg = Release|x64
{6B04803D-B418-4833-A67E-B0FC966636A5}.Release|x86.Build.0 = Release|x64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Debug|ARM64.ActiveCfg = Debug|ARM64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Debug|ARM64.Build.0 = Debug|ARM64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Debug|x64.ActiveCfg = Debug|x64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Debug|x64.Build.0 = Debug|x64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Debug|x86.ActiveCfg = Debug|x64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Debug|x86.Build.0 = Debug|x64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Release|ARM64.ActiveCfg = Release|ARM64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Release|ARM64.Build.0 = Release|ARM64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Release|x64.ActiveCfg = Release|x64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Release|x64.Build.0 = Release|x64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Release|x86.ActiveCfg = Release|x64
{3940AD4D-F748-4BE4-9083-85769CD553EF}.Release|x86.Build.0 = Release|x64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Debug|ARM64.ActiveCfg = Debug|ARM64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Debug|ARM64.Build.0 = Debug|ARM64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Debug|x64.ActiveCfg = Debug|x64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Debug|x64.Build.0 = Debug|x64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Debug|x86.ActiveCfg = Debug|x64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Debug|x86.Build.0 = Debug|x64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Release|ARM64.ActiveCfg = Release|ARM64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Release|ARM64.Build.0 = Release|ARM64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Release|x64.ActiveCfg = Release|x64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Release|x64.Build.0 = Release|x64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Release|x86.ActiveCfg = Release|x64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Release|x86.Build.0 = Release|x64
{FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52}.Debug|ARM64.ActiveCfg = Debug|ARM64 {FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52}.Debug|ARM64.ActiveCfg = Debug|ARM64
{FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52}.Debug|ARM64.Build.0 = Debug|ARM64 {FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52}.Debug|ARM64.Build.0 = Debug|ARM64
{FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52}.Debug|x64.ActiveCfg = Debug|x64 {FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52}.Debug|x64.ActiveCfg = Debug|x64
@@ -2577,6 +2662,12 @@ Global
{538ED0BB-B863-4B20-98CC-BCDF7FA0B68A} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC} {538ED0BB-B863-4B20-98CC-BCDF7FA0B68A} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
{51465DA1-C18B-4B99-93E1-ECF8E0FA0CBA} = {538ED0BB-B863-4B20-98CC-BCDF7FA0B68A} {51465DA1-C18B-4B99-93E1-ECF8E0FA0CBA} = {538ED0BB-B863-4B20-98CC-BCDF7FA0B68A}
{B9420661-B0E4-4241-ABD4-4A27A1F64250} = {538ED0BB-B863-4B20-98CC-BCDF7FA0B68A} {B9420661-B0E4-4241-ABD4-4A27A1F64250} = {538ED0BB-B863-4B20-98CC-BCDF7FA0B68A}
{CCB5E44F-84D9-4203-83C6-1C9EC9302BC7} = {2F305555-C296-497E-AC20-5FA1B237996A}
{D949EC7D-48A9-4279-95D5-078E7FD1F048} = {2F305555-C296-497E-AC20-5FA1B237996A}
{3BAF9C81-A194-4925-A035-5E24A5D1E542} = {2F305555-C296-497E-AC20-5FA1B237996A}
{6B04803D-B418-4833-A67E-B0FC966636A5} = {2F305555-C296-497E-AC20-5FA1B237996A}
{3940AD4D-F748-4BE4-9083-85769CD553EF} = {2F305555-C296-497E-AC20-5FA1B237996A}
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38} = {2F305555-C296-497E-AC20-5FA1B237996A}
{FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD} {FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
{3A9A791E-94A9-49F8-8401-C11CE288D5FB} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD} {3A9A791E-94A9-49F8-8401-C11CE288D5FB} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
EndGlobalSection EndGlobalSection

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. 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 --> <!-- 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-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%2F47 [github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F48
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.74.1/PowerToysUserSetup-0.74.1-x64.exe [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.74.1/PowerToysUserSetup-0.74.1-arm64.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.74.1/PowerToysSetup-0.74.1-x64.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.74.1/PowerToysSetup-0.74.1-arm64.exe [ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.75.1/PowerToysSetup-0.75.1-arm64.exe
| Description | Filename | sha256 hash | | Description | Filename | sha256 hash |
|----------------|----------|-------------| |----------------|----------|-------------|
| Per user - x64 | [PowerToysUserSetup-0.74.1-x64.exe][ptUserX64] | 748BF7BA33913237D36D6F48E3839D0C8035967305137A17DEFF39D775735C81 | | Per user - x64 | [PowerToysUserSetup-0.75.1-x64.exe][ptUserX64] | CFDAE52607689A695F4E4DDD7C1FE68400359AEF0D2B23C86122835E9D32A20F |
| Per user - ARM64 | [PowerToysUserSetup-0.74.1-arm64.exe][ptUserArm64] | F5DAA89A9CF3A2805E121085AFD056A890F241A170FAB5007AA58E2755C88C54 | | Per user - ARM64 | [PowerToysUserSetup-0.75.1-arm64.exe][ptUserArm64] | 9BAD3EF71DEDE70445416AC7369D115FAE095152722BC4F23EE393D8A10F45CA |
| Machine wide - x64 | [PowerToysSetup-0.74.1-x64.exe][ptMachineX64] | 298C6F4E4391BDC06E128BED86A303C3300A68EAF754B4630AF7542C78C0944A | | Machine wide - x64 | [PowerToysSetup-0.75.1-x64.exe][ptMachineX64] | 18FEB9377B0BA45189FFF4F89627B152DD794CCC15F005592B34A40A3EA62EA8 |
| Machine wide - ARM64 | [PowerToysSetup-0.74.1-arm64.exe][ptMachineArm64] | A65F3C300A48F9F81312B7FC7B306382CB87F591612D0CEC7E5C0E47E868904B | | Machine wide - ARM64 | [PowerToysSetup-0.75.1-arm64.exe][ptMachineArm64] | F5CDF5A35876A0B581F446BF728B7AC52B6B701C0850D9CEA9A1874523745CFD |
This is our preferred method. 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. 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** **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! - 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!
- 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)! - 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!
- Improved FancyZones stability, fixing some layout resets and improving handling of newly created windows on Windows 11. - 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)!
- Fixed many silent crashes that were reported to Watson and the user's event viewer.
### General ### General
- Turning animations off in Windows Settings will now also turn them off in PowerToys. - Many typo fixes through the projects and documentation. Thanks [@brianteeman](https://github.com/brianteeman)!
- 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! - Refactored and improved the logic across utilities for bringing a window to the foreground after activation.
- 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)!
### Color Picker ### 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 ### Environment Variables
- 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. - 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 ### FancyZones
- Set the process and main thread priority to normal. - Fixed an issue causing context menu pop-ups from some apps to automatically snap to a zone. (This was a hotfix for 0.74)
- Fixed handling newly created windows on Windows 11. - Applied the fix for the context menu pop-ups to the logic that decides which windows can be snapped.
- Fixed scenarios where opening the FancyZones Editor would reset the layouts. - 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 ### File Explorer add-ons
- Optimized CPU usage for generating SVG thumbnails. - Fixed an issue blocking some SVG files from being previewed correctly. (This was a hotfix for 0.74)
- Improved handling of Gcode Thumbnails, including JPG and QOI formats. Thanks [@pedrolamas](https://github.com/pedrolamas)! - Fixed crashes on invalid files in the STL Thumbnail generator.
- Better handled errors when sending telemetry, which were causing reported crashes.
- Fixed some thumbnails not being shown centered like before the optimization.
### File Locksmith ### GPO
- Shows files opened by processes with PID greater than 65535. Thanks [@poke30744](https://github.com/poke30744)! - Added a global GPO rule that applies for all utilities unless it's overridden. Thanks [@htcfreek](https://github.com/htcfreek)!
- Fixed a GDI object leak in the context menu which would crash Explorer. - 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.
### Find My Mouse ### Image Resizer
- Added new activation methods, including by hotkey. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - Fixed wrong .bmp file association in the registry. Thanks [@meitinger](https://github.com/meitinger)!
### 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)!
### Keyboard Manager ### 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 ### Peek
- Using Peek on HTML files will show a white background by default, similar to a browser's default behavior. - Reported file sizes will now more closely match what's reported by File Explorer. Thanks [@Deepak-Sangle](https://github.com/Deepak-Sangle)!
- Fix a white flash on Dark theme when switching file and improved the development file preview detection and adjustments. - 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 ### 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 ### PowerToys Run
- It's now possible to select which shell is used by the Shell plugin. - Fixed a case where the query wasn't being cleared after invoking a result action through the keyboard. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- A combobox option type was added to the plugin options. - 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)!
- 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. * 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.)
- Improved the Program plugin stability when it fails to load a program's thumbnail at startup. - 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 use of Pinyin for querying some plugins can now be turned on in Settings. Thanks [@ChaseKnowlden](https://github.com/ChaseKnowlden)! - The PowerToys plugin allows calling the new Environment Variables utility. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Refactored option types for plugin and added number, string and composite types to be used in the future. Thanks [@htcfreek](https://github.com/htcfreek)! - Refactored and added support to VSCodium Stable, VSCodium Insider and Remote Tunnels workspaces. Thanks [@eternalphane](https://github.com/eternalphane)!
- Fixed the entry for searching for Windows updates in the Settings plugin. Thanks [@htcfreek](https://github.com/htcfreek)!
### Quick Accent ### 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)! - Fixed characters that were removed from "All languages" because they were not in any single language. (This was a hotfix for 0.74)
- Added é to the Norwegian and Swedish languages. Thanks [@Aaron-Junker](https://github.com/Aaron-Junker)! - Added Asturian characters to the Spanish character set. Thanks [@blakestack](https://github.com/blakestack)!
- Added a runtime cache to the "All languages" character set, to only calculate accents once per key. - Added Greek characters with tonos. Thanks [@PesBandi](https://github.com/PesBandi)!
### Registry Preview ### Registry Preview
- Fixed focusing issues at startup. - Fixed a parsing error that crashed the Application. (This was a hotfix for 0.74)
- Improved the data visualization to show data in a similar way to the Windows Registry Editor. Thanks [@dillydylann](https://github.com/dillydylann)! - 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 ### 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 ### Settings
- Improved the way the OOBE window reacts to Windows theme change. - 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 an issue that made it impossible to change the "Switch between windows in the current zone" "Next window" shortcut for FancyZones. - Fixed a typo in the Hosts File Editor page. Thanks [@Deepak-Sangle](https://github.com/Deepak-Sangle)!
- 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 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 ### Documentation
- SECURITY.md was updated from 0.0.2 to 0.0.9. Thanks [@Aaron-Junker](https://github.com/Aaron-Junker)! - 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.
- Improved the README and main development document for clarity and completeness. Thanks [@codeofdusk](https://github.com/codeofdusk) and [@aprilbbrockhoeft](https://github.com/aprilbbrockhoeft)!
### Development ### Development
- Fixed PowerToys Run DateTime plugin tests that were failing depending on locale, so that they can be run correctly on all dev machines. - Added project dependencies to the version project and headers to avoid building errors. Thanks [@johnterickson](https://github.com/johnterickson)!
- 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)! - Enabled Control Flow Guard in the C++ projects. Thanks [@DHowett](https://github.com/DHowett)!
- Fixed a markdown bug on the GitHub /helped command. - Switched the release pipeline to the 1ES governed template. Thanks [@DHowett](https://github.com/DHowett)!
- Switched build pipelines to a new agent pool. 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)!
- New .cs files created in Visual Studio get the header added automatically. 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 - Language selection
- .NET 8 upgrade - .NET 8 upgrade
- Policy support for managing PowerToys Run plugins. - Allowing Keyboard Manager to output arbitrary Unicode sequences
*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. - Automated UI testing through WinAppDriver
- 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)
- Modernize and refresh the UX of PowerToys based on WPF. Here's Work in Progress previews for the modules "PowerToys Run" and "Color Picker": - 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) ![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 # Keyboard Manager UI
## Table of Contents: ## Table of Contents:
1. [C++ XAML Islands](#c-xaml-islands) 1. [XAML Implementation](#xaml-implementation)
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)
2. [UI Structure](#ui-structure) 2. [UI Structure](#ui-structure)
3. [EditKeyboardWindow / EditShortcutsWindow](#editkeyboardwindow--editshortcutswindow) 3. [EditKeyboardWindow / EditShortcutsWindow](#editkeyboardwindow--editshortcutswindow)
1. [OK and Cancel button](#ok-and-cancel-button) 1. [OK and Cancel button](#ok-and-cancel-button)
@@ -17,28 +14,18 @@
2. [Single Key ComboBox Selection Handler](#single-key-combobox-selection-handler) 2. [Single Key ComboBox Selection Handler](#single-key-combobox-selection-handler)
3. [Shortcut ComboBox Selection Handler](#shortcut-combobox-selection-handler) 3. [Shortcut ComboBox Selection Handler](#shortcut-combobox-selection-handler)
## C++ XAML Islands ## XAML Implementation
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. 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. [**Link to the original documentation**](https://github.com/microsoft/PowerToys/blob/b3f27057d43445abc59aa04405f7c24bb895a61c/doc/devdocs/modules/keyboardmanager/keyboardmanagerui.md#c-xaml-islands)
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>());`
## UI Structure ## 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. 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 (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 ## Update monaco editor

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -28,7 +28,7 @@
Type="string" /> Type="string" />
<!-- Registry Keys for the context menu handler for each of the following image formats: bmp, dib, gif, jfif, jpe, jpeg, jpg, jxr, png, rle, tif, tiff, wdp --> <!-- Registry Keys for the context menu handler for each of the following image formats: bmp, dib, gif, jfif, jpe, jpeg, jpg, jxr, png, rle, tif, tiff, wdp -->
<RegistryValue Root="$(var.RegistryScope)" <RegistryValue Root="$(var.RegistryScope)"
Key="SOFTWARE\Classes\SOFTWARE\Classes\SystemFileAssociations\.bmp\ShellEx\ContextMenuHandlers\ImageResizer" Key="SOFTWARE\Classes\SystemFileAssociations\.bmp\ShellEx\ContextMenuHandlers\ImageResizer"
Value="{51B4D7E5-7568-4234-B4BB-47FB3C016A69}" Value="{51B4D7E5-7568-4234-B4BB-47FB3C016A69}"
Type="string" /> Type="string" />
<RegistryValue Root="$(var.RegistryScope)" <RegistryValue Root="$(var.RegistryScope)"

View File

@@ -17,6 +17,14 @@
<RegistryValue Type="string" Name="Module_KeyboardManager_Editor" Value="" KeyPath="yes"/> <RegistryValue Type="string" Name="Module_KeyboardManager_Editor" Value="" KeyPath="yes"/>
</RegistryKey> </RegistryKey>
<File Source="$(var.BinDir)KeyboardManagerEditor\PowerToys.KeyboardManagerEditor.exe" /> <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> </Component>
</DirectoryRef> </DirectoryRef>

View File

@@ -402,6 +402,15 @@
</RegistryKey> </RegistryKey>
<File Id="Launcher_ValueGenerator_$(var.IdSafeLanguage)_File" Source="$(var.BinDir)RunPlugins\ValueGenerator\$(var.Language)\Community.PowerToys.Run.Plugin.ValueGenerator.resources.dll" /> <File Id="Launcher_ValueGenerator_$(var.IdSafeLanguage)_File" Source="$(var.BinDir)RunPlugins\ValueGenerator\$(var.Language)\Community.PowerToys.Run.Plugin.ValueGenerator.resources.dll" />
</Component> </Component>
<Component
Id="QoiPreviewHandler_$(var.IdSafeLanguage)_Component"
Directory="Resource$(var.IdSafeLanguage)INSTALLFOLDER"
Guid="$(var.CompGUIDPrefix)1E">
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="QoiPreviewHandler_$(var.IdSafeLanguage)_Component" Value="" KeyPath="yes"/>
</RegistryKey>
<File Id="QoiPreviewHandler_$(var.IdSafeLanguage)_File" Source="$(var.BinDir)\$(var.Language)\PowerToys.QoiPreviewHandler.resources.dll" />
</Component>
<?undef IdSafeLanguage?> <?undef IdSafeLanguage?>
<?undef CompGUIDPrefix?> <?undef CompGUIDPrefix?>
<?endforeach?> <?endforeach?>

View File

@@ -1005,7 +1005,7 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall)
} }
processes.resize(bytes / sizeof(processes[0])); processes.resize(bytes / sizeof(processes[0]));
std::array<std::wstring_view, 29> processesToTerminate = { std::array<std::wstring_view, 31> processesToTerminate = {
L"PowerToys.PowerLauncher.exe", L"PowerToys.PowerLauncher.exe",
L"PowerToys.Settings.exe", L"PowerToys.Settings.exe",
L"PowerToys.Awake.exe", L"PowerToys.Awake.exe",
@@ -1026,7 +1026,9 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall)
L"PowerToys.StlThumbnailProvider.exe", L"PowerToys.StlThumbnailProvider.exe",
L"PowerToys.SvgThumbnailProvider.exe", L"PowerToys.SvgThumbnailProvider.exe",
L"PowerToys.GcodePreviewHandler.exe", L"PowerToys.GcodePreviewHandler.exe",
L"PowerToys.QoiPreviewHandler.exe",
L"PowerToys.PdfPreviewHandler.exe", L"PowerToys.PdfPreviewHandler.exe",
L"PowerToys.QoiThumbnailProvider.exe",
L"PowerToys.SvgPreviewHandler.exe", L"PowerToys.SvgPreviewHandler.exe",
L"PowerToys.Peek.UI.exe", L"PowerToys.Peek.UI.exe",
L"PowerToys.MouseWithoutBorders.exe", L"PowerToys.MouseWithoutBorders.exe",

View File

@@ -24,7 +24,7 @@ namespace Microsoft.VariantAssignment.Contract
public bool EnableCaching { get; set; } public bool EnableCaching { get; set; }
/// <summary> /// <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> /// </summary>
public TimeSpan ResponseCacheTime { get; set; } public TimeSpan ResponseCacheTime { get; set; }
} }

View File

@@ -0,0 +1,16 @@
// 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 Common.UI
{
public static class OSVersionHelper
{
public static bool IsWindows11()
{
return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= 22000;
}
}
}

View File

@@ -14,6 +14,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Markdig.Signed" /> <PackageReference Include="Markdig.Signed" />
<PackageReference Include="System.Text.Encoding.CodePages" />
<PackageReference Include="UTF.Unknown" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -107,6 +107,7 @@ namespace Microsoft.PowerToys.FilePreviewCommon
public static string ReadIndexHtml() public static string ReadIndexHtml()
{ {
string html; string html;
using (StreamReader htmlFileReader = new StreamReader(new FileStream(MonacoDirectory + "\\index.html", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) using (StreamReader htmlFileReader = new StreamReader(new FileStream(MonacoDirectory + "\\index.html", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
{ {
html = htmlFileReader.ReadToEnd(); html = htmlFileReader.ReadToEnd();

View File

@@ -152,4 +152,12 @@ namespace winrt::PowerToys::GPOWrapper::implementation
{ {
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredEnvironmentVariablesEnabledValue()); return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredEnvironmentVariablesEnabledValue());
} }
GpoRuleConfigured GPOWrapper::GetConfiguredQoiPreviewEnabledValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredQoiPreviewEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredQoiThumbnailsEnabledValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredQoiThumbnailsEnabledValue());
}
} }

View File

@@ -44,6 +44,8 @@ namespace winrt::PowerToys::GPOWrapper::implementation
static GpoRuleConfigured GetAllowExperimentationValue(); static GpoRuleConfigured GetAllowExperimentationValue();
static GpoRuleConfigured GetRunPluginEnabledValue(winrt::hstring const& pluginID); static GpoRuleConfigured GetRunPluginEnabledValue(winrt::hstring const& pluginID);
static GpoRuleConfigured GetConfiguredEnvironmentVariablesEnabledValue(); static GpoRuleConfigured GetConfiguredEnvironmentVariablesEnabledValue();
static GpoRuleConfigured GetConfiguredQoiPreviewEnabledValue();
static GpoRuleConfigured GetConfiguredQoiThumbnailsEnabledValue();
}; };
} }

View File

@@ -48,6 +48,8 @@ namespace PowerToys
static GpoRuleConfigured GetAllowExperimentationValue(); static GpoRuleConfigured GetAllowExperimentationValue();
static GpoRuleConfigured GetRunPluginEnabledValue(String pluginID); static GpoRuleConfigured GetRunPluginEnabledValue(String pluginID);
static GpoRuleConfigured GetConfiguredEnvironmentVariablesEnabledValue(); static GpoRuleConfigured GetConfiguredEnvironmentVariablesEnabledValue();
static GpoRuleConfigured GetConfiguredQoiPreviewEnabledValue();
static GpoRuleConfigured GetConfiguredQoiThumbnailsEnabledValue();
} }
} }
} }

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(); serverPipe.Start();
ClientPipe.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); ClientPipe.Send(testString);
reset.WaitOne(); reset.WaitOne();

View File

@@ -235,6 +235,10 @@ public
return gcnew String(CommonSharedConstants::GCODE_PREVIEW_RESIZE_EVENT); return gcnew String(CommonSharedConstants::GCODE_PREVIEW_RESIZE_EVENT);
} }
static String ^ QoiPreviewResizeEvent() {
return gcnew String(CommonSharedConstants::QOI_PREVIEW_RESIZE_EVENT);
}
static String ^ DevFilesPreviewResizeEvent() { static String ^ DevFilesPreviewResizeEvent() {
return gcnew String(CommonSharedConstants::DEV_FILES_PREVIEW_RESIZE_EVENT); return gcnew String(CommonSharedConstants::DEV_FILES_PREVIEW_RESIZE_EVENT);
} }

View File

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

View File

@@ -62,6 +62,9 @@ namespace CommonSharedConstants
// Path to the event used by GcodePreviewHandler // Path to the event used by GcodePreviewHandler
const wchar_t GCODE_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysGcodePreviewResizeEvent-6ff1f9bd-ccbd-4b24-a79f-40a34fb0317d"; const wchar_t GCODE_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysGcodePreviewResizeEvent-6ff1f9bd-ccbd-4b24-a79f-40a34fb0317d";
// Path to the event used by QoiPreviewHandler
const wchar_t QOI_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysQoiPreviewResizeEvent-579518d1-8c8b-494f-8143-04f43d761ead";
// Path to the event used by DevFilesPreviewHandler // Path to the event used by DevFilesPreviewHandler
const wchar_t DEV_FILES_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysDevFilesPreviewResizeEvent-5707a22c-2cac-4ea2-82f0-27c03ef0b5f3"; const wchar_t DEV_FILES_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysDevFilesPreviewResizeEvent-5707a22c-2cac-4ea2-82f0-27c03ef0b5f3";

View File

@@ -27,6 +27,10 @@ struct LogSettings
inline const static std::wstring pdfPrevLogPath = L"logs\\FileExplorer_localLow\\PdfPrevHandler\\pdf-prev-handler-log.txt"; inline const static std::wstring pdfPrevLogPath = L"logs\\FileExplorer_localLow\\PdfPrevHandler\\pdf-prev-handler-log.txt";
inline const static std::string pdfThumbLoggerName = "PdfThumbnailProvider"; inline const static std::string pdfThumbLoggerName = "PdfThumbnailProvider";
inline const static std::wstring pdfThumbLogPath = L"logs\\FileExplorer_localLow\\PdfThumbnailProvider\\pdf-thumbnail-provider-log.txt"; inline const static std::wstring pdfThumbLogPath = L"logs\\FileExplorer_localLow\\PdfThumbnailProvider\\pdf-thumbnail-provider-log.txt";
inline const static std::string qoiPrevLoggerName = "QoiPrevHandler";
inline const static std::wstring qoiPrevLogPath = L"logs\\FileExplorer_localLow\\QoiPreviewHandler\\qoi-prev-handler-log.txt";
inline const static std::string qoiThumbLoggerName = "QoiThumbnailProvider";
inline const static std::wstring qoiThumbLogPath = L"logs\\FileExplorer_localLow\\QoiThumbnailProvider\\qoi-thumbnail-provider-log.txt";
inline const static std::string stlThumbLoggerName = "StlThumbnailProvider"; inline const static std::string stlThumbLoggerName = "StlThumbnailProvider";
inline const static std::wstring stlThumbLogPath = L"logs\\FileExplorer_localLow\\StlThumbnailProvider\\stl-thumbnail-provider-log.txt"; inline const static std::wstring stlThumbLogPath = L"logs\\FileExplorer_localLow\\StlThumbnailProvider\\stl-thumbnail-provider-log.txt";
inline const static std::string svgPrevLoggerName = "SvgPrevHandler"; inline const static std::string svgPrevLoggerName = "SvgPrevHandler";

View File

@@ -3,9 +3,10 @@
#ifndef PCH_H #ifndef PCH_H
#define PCH_H #define PCH_H
#pragma warning(push)
#pragma warning(disable : 5205) #pragma warning(disable : 5205)
#include <winrt/base.h> #include <winrt/base.h>
#pragma warning(default : 5205) #pragma warning(pop)
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define NOMINMAX #define NOMINMAX
#include <Windows.h> #include <Windows.h>

View File

@@ -56,6 +56,8 @@ namespace powertoys_gpo {
const std::wstring POLICY_CONFIGURE_ENABLED_MOUSE_WITHOUT_BORDERS = L"ConfigureEnabledUtilityMouseWithoutBorders"; const std::wstring POLICY_CONFIGURE_ENABLED_MOUSE_WITHOUT_BORDERS = L"ConfigureEnabledUtilityMouseWithoutBorders";
const std::wstring POLICY_CONFIGURE_ENABLED_PEEK = L"ConfigureEnabledUtilityPeek"; const std::wstring POLICY_CONFIGURE_ENABLED_PEEK = L"ConfigureEnabledUtilityPeek";
const std::wstring POLICY_CONFIGURE_ENABLED_ENVIRONMENT_VARIABLES = L"ConfigureEnabledUtilityEnvironmentVariables"; const std::wstring POLICY_CONFIGURE_ENABLED_ENVIRONMENT_VARIABLES = L"ConfigureEnabledUtilityEnvironmentVariables";
const std::wstring POLICY_CONFIGURE_ENABLED_QOI_PREVIEW = L"ConfigureEnabledUtilityFileExplorerQOIPreview";
const std::wstring POLICY_CONFIGURE_ENABLED_QOI_THUMBNAILS = L"ConfigureEnabledUtilityFileExplorerQOIThumbnails";
// The registry value names for PowerToys installer and update policies. // The registry value names for PowerToys installer and update policies.
const std::wstring POLICY_DISABLE_PER_USER_INSTALLATION = L"PerUserInstallationDisabled"; const std::wstring POLICY_DISABLE_PER_USER_INSTALLATION = L"PerUserInstallationDisabled";
@@ -446,4 +448,14 @@ namespace powertoys_gpo {
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_POWER_LAUNCHER_ALL_PLUGINS); return getConfiguredValue(POLICY_CONFIGURE_ENABLED_POWER_LAUNCHER_ALL_PLUGINS);
} }
} }
inline gpo_rule_configured_t getConfiguredQoiPreviewEnabledValue()
{
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_QOI_PREVIEW);
}
inline gpo_rule_configured_t getConfiguredQoiThumbnailsEnabledValue()
{
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_QOI_THUMBNAILS);
}
} }

View File

@@ -70,4 +70,40 @@ namespace json
{ {
return value; // identity function overload for convenience return value; // identity function overload for convenience
} }
template<typename T, typename D = std::optional<T>>
requires std::constructible_from<std::optional<T>, D>
void get(const json::JsonObject& o, const wchar_t* name, T& destination, D default_value = std::nullopt)
{
try
{
if constexpr (std::is_same_v<T, bool>)
{
destination = o.GetNamedBoolean(name);
}
else if constexpr (std::is_arithmetic_v<T>)
{
destination = static_cast<T>(o.GetNamedNumber(name));
}
else if constexpr (std::is_same_v<T, std::wstring>)
{
destination = o.GetNamedString(name);
}
else if constexpr (std::is_same_v<T, json::JsonObject>)
{
destination = o.GetNamedObject(name);
}
else
{
static_assert(std::bool_constant<std::is_same_v<T, T&>>::value, "Unsupported type");
}
}
catch (...)
{
std::optional<T> maybe_default{ std::move(default_value) };
if (maybe_default.has_value())
destination = std::move(*maybe_default);
}
}
} }

View File

@@ -18,6 +18,7 @@ namespace NonLocalizable
const static std::vector<std::wstring> ExtPDF = { L".pdf" }; const static std::vector<std::wstring> ExtPDF = { L".pdf" };
const static std::vector<std::wstring> ExtGCode = { L".gcode" }; const static std::vector<std::wstring> ExtGCode = { L".gcode" };
const static std::vector<std::wstring> ExtSTL = { L".stl" }; const static std::vector<std::wstring> ExtSTL = { L".stl" };
const static std::vector<std::wstring> ExtQOI = { L".qoi" };
const static std::vector<std::wstring> ExtNoNoNo = { const static std::vector<std::wstring> ExtNoNoNo = {
L".svgz" //Monaco cannot handle this file type at all; it's a binary file. L".svgz" //Monaco cannot handle this file type at all; it's a binary file.
}; };
@@ -145,6 +146,19 @@ inline registry::ChangeSet getGcodePreviewHandlerChangeSet(const std::wstring in
NonLocalizable::ExtGCode); NonLocalizable::ExtGCode);
} }
inline registry::ChangeSet getQoiPreviewHandlerChangeSet(const std::wstring installationDir, const bool perUser)
{
using namespace registry::shellex;
return generatePreviewHandler(PreviewHandlerType::preview,
perUser,
L"{729B72CD-B72E-4FE9-BCBF-E954B33FE699}",
get_std_product_version(),
(fs::path{ installationDir } / LR"d(PowerToys.QoiPreviewHandlerCpp.dll)d").wstring(),
L"QoiPreviewHandler",
L"Qoi Preview Handler",
NonLocalizable::ExtQOI);
}
inline registry::ChangeSet getSvgThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser) inline registry::ChangeSet getSvgThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
{ {
using namespace registry::shellex; using namespace registry::shellex;
@@ -156,6 +170,7 @@ inline registry::ChangeSet getSvgThumbnailHandlerChangeSet(const std::wstring in
L"SvgThumbnailProvider", L"SvgThumbnailProvider",
L"Svg Thumbnail Provider", L"Svg Thumbnail Provider",
NonLocalizable::ExtSVG, NonLocalizable::ExtSVG,
L"image",
L"Picture"); L"Picture");
} }
@@ -198,6 +213,21 @@ inline registry::ChangeSet getStlThumbnailHandlerChangeSet(const std::wstring in
NonLocalizable::ExtSTL); NonLocalizable::ExtSTL);
} }
inline registry::ChangeSet getQoiThumbnailHandlerChangeSet(const std::wstring installationDir, const bool perUser)
{
using namespace registry::shellex;
return generatePreviewHandler(PreviewHandlerType::thumbnail,
perUser,
L"{AD856B15-D25E-4008-AFB7-AFAA55586188}",
get_std_product_version(),
(fs::path{ installationDir } / LR"d(PowerToys.QoiThumbnailProviderCpp.dll)d").wstring(),
L"QoiThumbnailProvider",
L"Qoi Thumbnail Provider",
NonLocalizable::ExtQOI,
L"image",
L"Picture");
}
inline registry::ChangeSet getRegistryPreviewSetDefaultAppChangeSet(const std::wstring installationDir, const bool perUser) inline registry::ChangeSet getRegistryPreviewSetDefaultAppChangeSet(const std::wstring installationDir, const bool perUser)
{ {
const HKEY scope = perUser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; const HKEY scope = perUser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
@@ -245,9 +275,11 @@ inline std::vector<registry::ChangeSet> getAllOnByDefaultModulesChangeSets(const
getMdPreviewHandlerChangeSet(installationDir, PER_USER), getMdPreviewHandlerChangeSet(installationDir, PER_USER),
getMonacoPreviewHandlerChangeSet(installationDir, PER_USER), getMonacoPreviewHandlerChangeSet(installationDir, PER_USER),
getGcodePreviewHandlerChangeSet(installationDir, PER_USER), getGcodePreviewHandlerChangeSet(installationDir, PER_USER),
getQoiPreviewHandlerChangeSet(installationDir, PER_USER),
getSvgThumbnailHandlerChangeSet(installationDir, PER_USER), getSvgThumbnailHandlerChangeSet(installationDir, PER_USER),
getGcodeThumbnailHandlerChangeSet(installationDir, PER_USER), getGcodeThumbnailHandlerChangeSet(installationDir, PER_USER),
getStlThumbnailHandlerChangeSet(installationDir, PER_USER), getStlThumbnailHandlerChangeSet(installationDir, PER_USER),
getQoiThumbnailHandlerChangeSet(installationDir, PER_USER),
getRegistryPreviewChangeSet(installationDir, PER_USER) }; getRegistryPreviewChangeSet(installationDir, PER_USER) };
} }
@@ -259,10 +291,12 @@ inline std::vector<registry::ChangeSet> getAllModulesChangeSets(const std::wstri
getMonacoPreviewHandlerChangeSet(installationDir, PER_USER), getMonacoPreviewHandlerChangeSet(installationDir, PER_USER),
getPdfPreviewHandlerChangeSet(installationDir, PER_USER), getPdfPreviewHandlerChangeSet(installationDir, PER_USER),
getGcodePreviewHandlerChangeSet(installationDir, PER_USER), getGcodePreviewHandlerChangeSet(installationDir, PER_USER),
getQoiPreviewHandlerChangeSet(installationDir, PER_USER),
getSvgThumbnailHandlerChangeSet(installationDir, PER_USER), getSvgThumbnailHandlerChangeSet(installationDir, PER_USER),
getPdfThumbnailHandlerChangeSet(installationDir, PER_USER), getPdfThumbnailHandlerChangeSet(installationDir, PER_USER),
getGcodeThumbnailHandlerChangeSet(installationDir, PER_USER), getGcodeThumbnailHandlerChangeSet(installationDir, PER_USER),
getStlThumbnailHandlerChangeSet(installationDir, PER_USER), getStlThumbnailHandlerChangeSet(installationDir, PER_USER),
getQoiThumbnailHandlerChangeSet(installationDir, PER_USER),
getRegistryPreviewChangeSet(installationDir, PER_USER), getRegistryPreviewChangeSet(installationDir, PER_USER),
getRegistryPreviewSetDefaultAppChangeSet(installationDir, PER_USER) }; getRegistryPreviewSetDefaultAppChangeSet(installationDir, PER_USER) };
} }

View File

@@ -395,6 +395,7 @@ namespace registry
std::wstring className, std::wstring className,
std::wstring displayName, std::wstring displayName,
std::vector<std::wstring> fileTypes, std::vector<std::wstring> fileTypes,
std::wstring perceivedType = L"",
std::wstring fileKindType = L"") std::wstring fileKindType = L"")
{ {
const HKEY scope = perUser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; const HKEY scope = perUser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
@@ -436,9 +437,8 @@ namespace registry
for (const auto& fileType : fileTypes) for (const auto& fileType : fileTypes)
{ {
std::wstring fileAssociationPath = L"Software\\Classes\\"; std::wstring fileTypePath = L"Software\\Classes\\" + fileType;
fileAssociationPath += fileType; std::wstring fileAssociationPath = fileTypePath + L"\\shellex\\";
fileAssociationPath += L"\\shellex\\";
fileAssociationPath += handlerType == PreviewHandlerType::preview ? IPREVIEW_HANDLER_CLSID : ITHUMBNAIL_PROVIDER_CLSID; fileAssociationPath += handlerType == PreviewHandlerType::preview ? IPREVIEW_HANDLER_CLSID : ITHUMBNAIL_PROVIDER_CLSID;
changes.push_back({ scope, fileAssociationPath, std::nullopt, handlerClsid }); changes.push_back({ scope, fileAssociationPath, std::nullopt, handlerClsid });
if (!fileKindType.empty()) if (!fileKindType.empty())
@@ -448,6 +448,10 @@ namespace registry
std::wstring kindMapPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\KindMap"; std::wstring kindMapPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\KindMap";
changes.push_back({ HKEY_LOCAL_MACHINE, kindMapPath, fileType, fileKindType, false}); changes.push_back({ HKEY_LOCAL_MACHINE, kindMapPath, fileType, fileKindType, false});
} }
if (!perceivedType.empty())
{
changes.push_back({ scope, fileTypePath, L"PerceivedType", perceivedType });
}
if (handlerType == PreviewHandlerType::preview && fileType == L".reg") if (handlerType == PreviewHandlerType::preview && fileType == L".reg")
{ {
// this regfile registry key has precedence over Software\Classes\.reg for .reg files // this regfile registry key has precedence over Software\Classes\.reg for .reg files

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. <!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. --> 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> <policyNamespaces>
<target prefix="powertoys" namespace="Microsoft.Policies.PowerToys" /> <target prefix="powertoys" namespace="Microsoft.Policies.PowerToys" />
</policyNamespaces> </policyNamespaces>
<resources minRequiredRevision="1.4"/><!-- Last changed with PowerToys v0.75.0 --> <resources minRequiredRevision="1.6"/><!-- Last changed with PowerToys v0.76.0 -->
<supportedOn> <supportedOn>
<definitions> <definitions>
<definition name="SUPPORTED_POWERTOYS_0_64_0" displayName="$(string.SUPPORTED_POWERTOYS_0_64_0)"/> <definition name="SUPPORTED_POWERTOYS_0_64_0" displayName="$(string.SUPPORTED_POWERTOYS_0_64_0)"/>
@@ -14,6 +14,7 @@
<definition name="SUPPORTED_POWERTOYS_0_70_0" displayName="$(string.SUPPORTED_POWERTOYS_0_70_0)"/> <definition name="SUPPORTED_POWERTOYS_0_70_0" displayName="$(string.SUPPORTED_POWERTOYS_0_70_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_73_0" displayName="$(string.SUPPORTED_POWERTOYS_0_73_0)"/> <definition name="SUPPORTED_POWERTOYS_0_73_0" displayName="$(string.SUPPORTED_POWERTOYS_0_73_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_75_0" displayName="$(string.SUPPORTED_POWERTOYS_0_75_0)"/> <definition name="SUPPORTED_POWERTOYS_0_75_0" displayName="$(string.SUPPORTED_POWERTOYS_0_75_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_76_0" displayName="$(string.SUPPORTED_POWERTOYS_0_76_0)"/>
</definitions> </definitions>
</supportedOn> </supportedOn>
<categories> <categories>
@@ -78,6 +79,16 @@
<decimal value="0" /> <decimal value="0" />
</disabledValue> </disabledValue>
</policy> </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"> <policy name="ConfigureEnabledUtilityFancyZones" class="Both" displayName="$(string.ConfigureEnabledUtilityFancyZones)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFancyZones">
<parentCategory ref="PowerToys" /> <parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_64_0" /> <supportedOn ref="SUPPORTED_POWERTOYS_0_64_0" />
@@ -178,6 +189,26 @@
<decimal value="0" /> <decimal value="0" />
</disabledValue> </disabledValue>
</policy> </policy>
<policy name="ConfigureEnabledUtilityFileExplorerQOIPreview" class="Both" displayName="$(string.ConfigureEnabledUtilityFileExplorerQOIPreview)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFileExplorerQOIPreview">
<parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_76_0" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="ConfigureEnabledUtilityFileExplorerQOIThumbnails" class="Both" displayName="$(string.ConfigureEnabledUtilityFileExplorerQOIThumbnails)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFileExplorerQOIThumbnails">
<parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_76_0" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="ConfigureEnabledUtilityFileExplorerSTLThumbnails" class="Both" displayName="$(string.ConfigureEnabledUtilityFileExplorerSTLThumbnails)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFileExplorerSTLThumbnails"> <policy name="ConfigureEnabledUtilityFileExplorerSTLThumbnails" class="Both" displayName="$(string.ConfigureEnabledUtilityFileExplorerSTLThumbnails)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityFileExplorerSTLThumbnails">
<parentCategory ref="PowerToys" /> <parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_64_0" /> <supportedOn ref="SUPPORTED_POWERTOYS_0_64_0" />

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. <!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. --> 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.6" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<displayName>PowerToys</displayName> <displayName>PowerToys</displayName>
<description>PowerToys</description> <description>PowerToys</description>
<resources> <resources>
@@ -16,6 +16,7 @@
<string id="SUPPORTED_POWERTOYS_0_70_0">PowerToys version 0.70.0 or later</string> <string id="SUPPORTED_POWERTOYS_0_70_0">PowerToys version 0.70.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_73_0">PowerToys version 0.73.0 or later</string> <string id="SUPPORTED_POWERTOYS_0_73_0">PowerToys version 0.73.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_75_0">PowerToys version 0.75.0 or later</string> <string id="SUPPORTED_POWERTOYS_0_75_0">PowerToys version 0.75.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_76_0">PowerToys version 0.76.0 or later</string>
<string id="ConfigureGlobalUtilityEnabledStateDescription">This policy configures the enabled state for all PowerToys utilities. <string id="ConfigureGlobalUtilityEnabledStateDescription">This policy configures the enabled state for all PowerToys utilities.
@@ -23,7 +24,7 @@ If you enable this setting, all utilities will be always enabled and the user wo
If you disable this setting, all utilities will be always disabled and the user won't be able to enable it. If you disable this setting, all utilities will be always disabled and the user won't be able to enable it.
If you don't configure this setting, users are able to disable or enable the utilities. If you don't configure this setting, users are able to enable or disable the utilities.
The individual enabled state policies for the utilities will override this policy. The individual enabled state policies for the utilities will override this policy.
</string> </string>
@@ -34,7 +35,7 @@ If you enable this setting, the utility will be always enabled and the user won'
If you disable this setting, the utility will be always disabled and the user won't be able to enable it. If you disable this setting, the utility will be always disabled and the user won't be able to enable it.
If you don't configure this setting, users are able to disable or enable the utility. If you don't configure this setting, users are able to enable or disable the utility.
This policy has a higher priority than the policy "Configure global utility enabled state" and overrides it. This policy has a higher priority than the policy "Configure global utility enabled state" and overrides it.
</string> </string>
@@ -46,7 +47,7 @@ If you enable this setting, the utility will be always enabled and the user won'
If you disable this setting, the utility will be always disabled and the user won't be able to enable it. If you disable this setting, the utility will be always disabled and the user won't be able to enable it.
If you don't configure this setting, users are able to disable or enable the utility. If you don't configure this setting, users are able to enable or disable the utility.
This policy has a higher priority than the policy "Configure global utility enabled state" and overrides it. This policy has a higher priority than the policy "Configure global utility enabled state" and overrides it.
</string> </string>
@@ -78,7 +79,7 @@ If disabled or not configured, the automatic update checks are enabled.
</string> </string>
<string id="AllowExperimentationDescription">This policy configures whether PowerToys experimentation is allowed. With experimentation allowed the user sees the new features being experimented if it gets selected as part of the test group. (Experimentation will only happen on Windows Insider builds.) <string id="AllowExperimentationDescription">This policy configures whether PowerToys experimentation is allowed. With experimentation allowed the user sees the new features being experimented if it gets selected as part of the test group. (Experimentation will only happen on Windows Insider builds.)
If this setting is not configured or enabled, the user can control experimentation in the PowerToys settings menu. If this setting is enabled or not configured, the user can control experimentation in the PowerToys settings menu.
If this setting is disabled, experimentation is not allowed. If this setting is disabled, experimentation is not allowed.
</string> </string>
@@ -88,22 +89,22 @@ If you enable this setting, the plugins will be always enabled and the user won'
If you disable this setting, the plugins will be always disabled and the user won't be able to enable it. If you disable this setting, the plugins will be always disabled and the user won't be able to enable it.
If you don't configure this setting, users are able to disable or enable the plugins. If you don't configure this setting, users are able to enable or disable the plugins.
You can override this policy for individual plugins using the policy "Configure enabled state for individual plugins". You can override this policy for individual plugins using the policy "Configure enabled state for individual plugins".
Note: Changes require a restart of PowerToys Run. Note: Changes require a restart of PowerToys Run.
</string> </string>
<string id="PowerToysRunIndividualPluginEnabledStateDescription">With this policy you can configures an individual enabled state for each PowerToys Run plugin that you add to the list. <string id="PowerToysRunIndividualPluginEnabledStateDescription">With this policy you can configure an individual enabled state for each PowerToys Run plugin that you add to the list.
If you enable this setting, you can define the list of plugins and their enabled states: If you enable this setting, you can define the list of plugins and their enabled states:
- The value name (first column) is the plugin ID. You will find it in the plugin.json which is located in the plugin folder. - The value name (first column) is the plugin ID. You will find it in the plugin.json file which is located in the plugin folder.
- The value (second column) is a numeric value: 0 for disabled, 1 for enabled and 2 for user takes control. - The value (second column) is a numeric value: 0 for disabled, 1 for enabled and 2 for user takes control.
- Example to disable the Program plugin: 791FC278BA414111B8D1886DFE447410 | 0 - Example to disable the Program plugin: 791FC278BA414111B8D1886DFE447410 | 0
If you disable or don't configure this policy, either the user or the policy "Configure enabled state for all plugins" takes control over the enabled state of the plugins. If you disable or don't configure this policy, either the user or the policy "Configure enabled state for all plugins" takes control over the enabled state of the plugins.
You can set the enabled state for all plugins not listed here using the policy "Configure enabled state for all plugins". You can set the enabled state for all plugins not configured by this policy using the policy "Configure enabled state for all plugins".
Note: Changes require a restart of PowerToys Run. Note: Changes require a restart of PowerToys Run.
</string> </string>
@@ -112,6 +113,7 @@ Note: Changes require a restart of PowerToys Run.
<string id="ConfigureEnabledUtilityAwake">Awake: Configure enabled state</string> <string id="ConfigureEnabledUtilityAwake">Awake: Configure enabled state</string>
<string id="ConfigureEnabledUtilityColorPicker">Color Picker: 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="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="ConfigureEnabledUtilityFancyZones">FancyZones: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFileLocksmith">File Locksmith: Configure enabled state</string> <string id="ConfigureEnabledUtilityFileLocksmith">File Locksmith: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFileExplorerSVGPreview">SVG file preview: Configure enabled state</string> <string id="ConfigureEnabledUtilityFileExplorerSVGPreview">SVG file preview: Configure enabled state</string>
@@ -148,6 +150,8 @@ Note: Changes require a restart of PowerToys Run.
<string id="AllowExperimentation">Allow Experimentation</string> <string id="AllowExperimentation">Allow Experimentation</string>
<string id="PowerToysRunAllPluginsEnabledState">Configure enabled state for all plugins</string> <string id="PowerToysRunAllPluginsEnabledState">Configure enabled state for all plugins</string>
<string id="PowerToysRunIndividualPluginEnabledState">Configure enabled state for individual plugins</string> <string id="PowerToysRunIndividualPluginEnabledState">Configure enabled state for individual plugins</string>
<string id="ConfigureEnabledUtilityFileExplorerQOIPreview">QOI file preview: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFileExplorerQOIThumbnails">QOI file thumbnail: Configure enabled state</string>
</stringTable> </stringTable>
<presentationTable> <presentationTable>

View File

@@ -87,12 +87,29 @@ void ReparentCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
DisconnectTarget(); DisconnectTarget();
m_currentTarget = windowToCrop; m_currentTarget = windowToCrop;
// Adjust the crop rect to be in the window space as reported by win32k // Save original state
SaveOriginalState();
RECT windowRect = {}; RECT windowRect = {};
winrt::check_bool(GetWindowRect(m_currentTarget, &windowRect)); winrt::check_bool(GetWindowRect(m_currentTarget, &windowRect));
auto clientRect = ClientAreaInScreenSpace(m_currentTarget); 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 diffX = clientRect.left - windowRect.left;
auto diffY = clientRect.top - windowRect.top; 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; auto adjustedCropRect = cropRect;
adjustedCropRect.left += diffX; adjustedCropRect.left += diffX;
adjustedCropRect.top += diffY; adjustedCropRect.top += diffY;
@@ -100,8 +117,6 @@ void ReparentCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
adjustedCropRect.bottom += diffY; adjustedCropRect.bottom += diffY;
cropRect = adjustedCropRect; 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 newX = adjustedCropRect.left + windowRect.left;
auto newY = adjustedCropRect.top + windowRect.top; auto newY = adjustedCropRect.top + windowRect.top;
@@ -153,11 +168,53 @@ void ReparentCropAndLockWindow::DisconnectTarget()
m_currentTarget = nullptr; m_currentTarget = nullptr;
return; 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); RestoreOriginalState();
auto targetStyle = static_cast<DWORD>(GetWindowLongPtrW(m_currentTarget, GWL_STYLE)); }
targetStyle &= ~WS_CHILD; }
SetWindowLongPtrW(m_currentTarget, GWL_STYLE, targetStyle);
m_currentTarget = nullptr; 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 Hide();
void DisconnectTarget(); void DisconnectTarget();
void SaveOriginalState();
void RestoreOriginalState();
private: private:
HWND m_currentTarget = nullptr; HWND m_currentTarget = nullptr;
POINT m_previousPosition = {};
std::unique_ptr<ChildWindow> m_childWindow; std::unique_ptr<ChildWindow> m_childWindow;
bool m_destroyed = false; bool m_destroyed = false;
std::function<void(HWND)> m_closedCallback; std::function<void(HWND)> m_closedCallback;
LONG_PTR originalExStyle = 0;
LONG_PTR originalStyle = 0;
WINDOWPLACEMENT originalPlacement = { sizeof(WINDOWPLACEMENT) };
RECT originalRect = {};
}; };

View File

@@ -188,7 +188,7 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I
m_reparent_event_handle = CreateEventW(nullptr, false, false, CommonSharedConstants::CROP_AND_LOCK_REPARENT_EVENT); m_reparent_event_handle = CreateEventW(nullptr, false, false, CommonSharedConstants::CROP_AND_LOCK_REPARENT_EVENT);
m_thumbnail_event_handle = CreateEventW(nullptr, false, false, CommonSharedConstants::CROP_AND_LOCK_THUMBNAIL_EVENT); m_thumbnail_event_handle = CreateEventW(nullptr, false, false, CommonSharedConstants::CROP_AND_LOCK_THUMBNAIL_EVENT);
m_exit_event_handle = CreateEventW(nullptr, false, false, CommonSharedConstants::CROP_AND_LOCK_EXIT_EVENT); m_exit_event_handle = CreateEventW(nullptr, false, false, CommonSharedConstants::CROP_AND_LOCK_EXIT_EVENT);
if (!m_reparent_event_handle || !m_reparent_event_handle || !m_exit_event_handle) if (!m_reparent_event_handle || !m_thumbnail_event_handle || !m_exit_event_handle)
{ {
Logger::warn(L"Failed to create events. {}", get_last_error_or_default(GetLastError())); Logger::warn(L"Failed to create events. {}", get_last_error_or_default(GetLastError()));
return 1; return 1;

View File

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

View File

@@ -24,10 +24,24 @@
<DataTemplate x:Key="VariableTemplate" x:DataType="models:Variable"> <DataTemplate x:Key="VariableTemplate" x:DataType="models:Variable">
<controls:SettingsCard <controls:SettingsCard
CommandParameter="{x:Bind (models:Variable)}" CommandParameter="{x:Bind (models:Variable)}"
Header="{x:Bind Name, Mode=TwoWay}"
IsActionIconVisible="False" IsActionIconVisible="False"
IsClickEnabled="False" IsClickEnabled="False"
Style="{StaticResource DefaultSettingsExpanderItemStyle}"> Style="{StaticResource DefaultSettingsExpanderItemStyle}">
<controls:SettingsCard.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{x:Bind Name, Mode=TwoWay}" />
<FontIcon
Margin="6,0,6,0"
FontSize="16"
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
Glyph="&#xE930;"
Visibility="{x:Bind IsAppliedFromProfile, Converter={StaticResource BoolToVisibilityConverter}}">
<ToolTipService.ToolTip>
<TextBlock x:Uid="VariableIsAppliedByActiveProfileTooltip" TextWrapping="Wrap" />
</ToolTipService.ToolTip>
</FontIcon>
</StackPanel>
</controls:SettingsCard.Header>
<controls:SettingsCard.Description> <controls:SettingsCard.Description>
<StackPanel HorizontalAlignment="Left"> <StackPanel HorizontalAlignment="Left">
<ItemsControl <ItemsControl
@@ -52,7 +66,6 @@
Visibility="{x:Bind ShowAsList, Converter={StaticResource BoolToInvertedVisibilityConverter}}" /> Visibility="{x:Bind ShowAsList, Converter={StaticResource BoolToInvertedVisibilityConverter}}" />
</StackPanel> </StackPanel>
</controls:SettingsCard.Description> </controls:SettingsCard.Description>
<Button <Button
Content="{ui:FontIcon Glyph=&#xE712;}" Content="{ui:FontIcon Glyph=&#xE712;}"
IsEnabled="{x:Bind IsEditable}" IsEnabled="{x:Bind IsEditable}"
@@ -622,7 +635,8 @@
<Flyout <Flyout
x:Name="AddVariableFlyout" x:Name="AddVariableFlyout"
Closed="AddVariableFlyout_Closed" Closed="AddVariableFlyout_Closed"
Placement="Right"> Placement="Right"
ShouldConstrainToRootBounds="False">
<Grid Width="320" Height="480"> <Grid Width="320" Height="480">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />

View File

@@ -21,25 +21,25 @@ namespace EnvironmentVariables.Helpers
internal static Variable GetExisting(string variableName) internal static Variable GetExisting(string variableName)
{ {
var userVariables = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.User); DefaultVariablesSet userSet = new DefaultVariablesSet(Guid.NewGuid(), "tmpUser", VariablesSetType.User);
GetVariables(EnvironmentVariableTarget.User, userSet);
foreach (DictionaryEntry variable in userVariables) foreach (var variable in userSet.Variables)
{ {
var key = variable.Key as string; if (variable.Name.Equals(variableName, StringComparison.OrdinalIgnoreCase))
if (key.Equals(variableName, StringComparison.OrdinalIgnoreCase))
{ {
return new Variable(key, userVariables[key] as string, VariablesSetType.User); return new Variable(variable.Name, variable.Values, VariablesSetType.User);
} }
} }
var systemVariables = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine); DefaultVariablesSet systemSet = new DefaultVariablesSet(Guid.NewGuid(), "tmpSystem", VariablesSetType.System);
GetVariables(EnvironmentVariableTarget.Machine, systemSet);
foreach (DictionaryEntry variable in systemVariables) foreach (var variable in systemSet.Variables)
{ {
var key = variable.Key as string; if (variable.Name.Equals(variableName, StringComparison.OrdinalIgnoreCase))
if (key.Equals(variableName, StringComparison.OrdinalIgnoreCase))
{ {
return new Variable(key, systemVariables[key] as string, VariablesSetType.System); return new Variable(variable.Name, variable.Values, VariablesSetType.System);
} }
} }
@@ -65,6 +65,9 @@ namespace EnvironmentVariables.Helpers
return baseKey.OpenSubKey(keyName, writable: writable); return baseKey.OpenSubKey(keyName, writable: writable);
} }
// Code taken from https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Environment.Win32.cs
// Set variables directly to registry instead of using Environment API - Environment.SetEnvironmentVariable() has 1 second timeout for SendNotifyMessage(WM_SETTINGSCHANGED).
// When applying profile, this would take num_of_variables * 1s to propagate the changes. We do manually SendNotifyMessage with no timeout where needed.
private static void SetEnvironmentVariableFromRegistryWithoutNotify(string variable, string value, bool fromMachine) private static void SetEnvironmentVariableFromRegistryWithoutNotify(string variable, string value, bool fromMachine)
{ {
const int MaxUserEnvVariableLength = 255; // User-wide env vars stored in the registry have names limited to 255 chars const int MaxUserEnvVariableLength = 255; // User-wide env vars stored in the registry have names limited to 255 chars
@@ -84,7 +87,15 @@ namespace EnvironmentVariables.Helpers
} }
else else
{ {
environmentKey.SetValue(variable, value); // If a variable contains %, we save it as a REG_EXPAND_SZ, which is the same behavior as the Windows default environment variables editor.
if (value.Contains('%'))
{
environmentKey.SetValue(variable, value, RegistryValueKind.ExpandString);
}
else
{
environmentKey.SetValue(variable, value, RegistryValueKind.String);
}
} }
} }
} }
@@ -102,23 +113,32 @@ namespace EnvironmentVariables.Helpers
} }
} }
// Code taken from https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Environment.Win32.cs
// Reading variables from registry instead of using Environment API, because Environment API expands variables by default.
internal static void GetVariables(EnvironmentVariableTarget target, VariablesSet set) internal static void GetVariables(EnvironmentVariableTarget target, VariablesSet set)
{ {
var variables = Environment.GetEnvironmentVariables(target);
var sortedList = new SortedList<string, Variable>(); var sortedList = new SortedList<string, Variable>();
foreach (DictionaryEntry variable in variables) bool fromMachine = target == EnvironmentVariableTarget.Machine ? true : false;
using (RegistryKey environmentKey = OpenEnvironmentKeyIfExists(fromMachine, writable: false))
{ {
string key = variable.Key as string; if (environmentKey != null)
string value = variable.Value as string;
if (string.IsNullOrEmpty(key))
{ {
continue; foreach (string name in environmentKey.GetValueNames())
{
string value = environmentKey.GetValue(name, string.Empty, RegistryValueOptions.DoNotExpandEnvironmentNames).ToString();
try
{
Variable entry = new Variable(name, value, set.Type);
sortedList.Add(name, entry);
}
catch (ArgumentException)
{
// Throw and catch intentionally to provide non-fatal notification about corrupted environment block
}
}
} }
Variable entry = new Variable(key, value, set.Type);
sortedList.Add(key, entry);
} }
set.Variables = new System.Collections.ObjectModel.ObservableCollection<Variable>(sortedList.Values); set.Variables = new System.Collections.ObjectModel.ObservableCollection<Variable>(sortedList.Values);

View File

@@ -28,12 +28,17 @@ namespace EnvironmentVariables.Models
[ObservableProperty] [ObservableProperty]
private bool _applyToSystem; private bool _applyToSystem;
[JsonIgnore]
[property: JsonIgnore]
[ObservableProperty]
private bool _isAppliedFromProfile; // Used to mark that a variable in a default set is applied by a profile. Used to disable editing / mark it in the UI.
[JsonIgnore] [JsonIgnore]
public bool IsEditable public bool IsEditable
{ {
get get
{ {
return ParentType != VariablesSetType.System || App.GetService<IElevationHelper>().IsElevated; return (ParentType != VariablesSetType.System || App.GetService<IElevationHelper>().IsElevated) && !IsAppliedFromProfile;
} }
} }

View File

@@ -280,4 +280,7 @@
<data name="StateProfileNotApplicableMsg" xml:space="preserve"> <data name="StateProfileNotApplicableMsg" xml:space="preserve">
<value>Variables or backup variables are invalid.</value> <value>Variables or backup variables are invalid.</value>
</data> </data>
<data name="VariableIsAppliedByActiveProfileTooltip.Text" xml:space="preserve">
<value>This variable is written by the active profile</value>
</data>
</root> </root>

View File

@@ -67,6 +67,16 @@ namespace EnvironmentVariables.ViewModels
foreach (var variable in UserDefaultSet.Variables) foreach (var variable in UserDefaultSet.Variables)
{ {
DefaultVariables.Variables.Add(variable); DefaultVariables.Variables.Add(variable);
if (AppliedProfile != null)
{
if (AppliedProfile.Variables.Where(
x => (x.Name.Equals(variable.Name, StringComparison.OrdinalIgnoreCase) && x.Values.Equals(variable.Values, StringComparison.OrdinalIgnoreCase))
|| variable.Name.Equals(EnvironmentVariablesHelper.GetBackupVariableName(x, AppliedProfile.Name), StringComparison.OrdinalIgnoreCase)).Any())
{
// If it's a user variable that's also in the profile or is a backup variable, mark it as applied from profile.
variable.IsAppliedFromProfile = true;
}
}
} }
foreach (var variable in SystemDefaultSet.Variables) foreach (var variable in SystemDefaultSet.Variables)
@@ -132,10 +142,13 @@ namespace EnvironmentVariables.ViewModels
var variables = new List<Variable>(); var variables = new List<Variable>();
if (AppliedProfile != null) if (AppliedProfile != null)
{ {
variables = variables.Concat(AppliedProfile.Variables.OrderBy(x => x.Name)).ToList(); variables = variables.Concat(AppliedProfile.Variables.Select(x => new Variable(x.Name, Environment.ExpandEnvironmentVariables(x.Values), VariablesSetType.Profile)).OrderBy(x => x.Name)).ToList();
} }
variables = variables.Concat(UserDefaultSet.Variables.OrderBy(x => x.Name)).Concat(SystemDefaultSet.Variables.OrderBy(x => x.Name)).ToList(); // Variables are expanded to be shown in the applied variables section, so the user sees their actual values.
variables = variables.Concat(UserDefaultSet.Variables.Select(x => new Variable(x.Name, Environment.ExpandEnvironmentVariables(x.Values), VariablesSetType.User)).OrderBy(x => x.Name))
.Concat(SystemDefaultSet.Variables.Select(x => new Variable(x.Name, Environment.ExpandEnvironmentVariables(x.Values), VariablesSetType.System)).OrderBy(x => x.Name))
.ToList();
// Handle PATH variable - add USER value to the end of the SYSTEM value // Handle PATH variable - add USER value to the end of the SYSTEM value
var profilePath = variables.Where(x => x.Name.Equals("PATH", StringComparison.OrdinalIgnoreCase) && x.ParentType == VariablesSetType.Profile).FirstOrDefault(); var profilePath = variables.Where(x => x.Name.Equals("PATH", StringComparison.OrdinalIgnoreCase) && x.ParentType == VariablesSetType.Profile).FirstOrDefault();

View File

@@ -53,7 +53,7 @@ private:
//contains the non localized key of the powertoy //contains the non localized key of the powertoy
std::wstring app_key; std::wstring app_key;
HANDLE m_hProcess; HANDLE m_hProcess = nullptr;
HANDLE m_hShowEvent; HANDLE m_hShowEvent;

View File

@@ -309,9 +309,8 @@ std::wstring NtdllExtensions::pid_to_user(DWORD pid)
} }
DWORD token_size = 0; DWORD token_size = 0;
GetTokenInformation(token, TokenUser, nullptr, 0, &token_size); const bool ok = GetTokenInformation(token, TokenUser, nullptr, 0, &token_size);
if ((!ok && GetLastError() != ERROR_INSUFFICIENT_BUFFER) || !token_size)
if (token_size < 0)
{ {
return user; return user;
} }

View File

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

View File

@@ -5,6 +5,7 @@
using System.IO.Abstractions.TestingHelpers; using System.IO.Abstractions.TestingHelpers;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hosts.Exceptions;
using Hosts.Helpers; using Hosts.Helpers;
using Hosts.Models; using Hosts.Models;
using Hosts.Settings; using Hosts.Settings;
@@ -18,11 +19,13 @@ namespace Hosts.Tests
[TestClass] [TestClass]
public class HostsServiceTest public class HostsServiceTest
{ {
private static Mock<IUserSettings> _userSettings;
private static Mock<IElevationHelper> _elevationHelper; private static Mock<IElevationHelper> _elevationHelper;
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext context) public static void ClassInitialize(TestContext context)
{ {
_userSettings = new Mock<IUserSettings>();
_elevationHelper = new Mock<IElevationHelper>(); _elevationHelper = new Mock<IElevationHelper>();
_elevationHelper.Setup(m => m.IsElevated).Returns(true); _elevationHelper.Setup(m => m.IsElevated).Returns(true);
} }
@@ -31,8 +34,7 @@ namespace Hosts.Tests
public void Hosts_Exists() public void Hosts_Exists()
{ {
var fileSystem = new CustomMockFileSystem(); 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)); fileSystem.AddFile(service.HostsFilePath, new MockFileData(string.Empty));
var result = service.Exists(); var result = service.Exists();
@@ -43,8 +45,7 @@ namespace Hosts.Tests
public void Hosts_Not_Exists() public void Hosts_Not_Exists()
{ {
var fileSystem = new CustomMockFileSystem(); 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(); var result = service.Exists();
Assert.IsFalse(result); Assert.IsFalse(result);
@@ -65,8 +66,7 @@ namespace Hosts.Tests
"; ";
var fileSystem = new CustomMockFileSystem(); 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)); fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
var data = await service.ReadAsync(); var data = await service.ReadAsync();
@@ -91,8 +91,7 @@ namespace Hosts.Tests
"; ";
var fileSystem = new CustomMockFileSystem(); 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)); fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
var data = await service.ReadAsync(); var data = await service.ReadAsync();
@@ -118,8 +117,7 @@ namespace Hosts.Tests
"; ";
var fileSystem = new CustomMockFileSystem(); 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)); fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
var data = await service.ReadAsync(); var data = await service.ReadAsync();
@@ -138,9 +136,7 @@ namespace Hosts.Tests
public async Task Empty_Hosts() public async Task Empty_Hosts()
{ {
var fileSystem = new CustomMockFileSystem(); 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)); fileSystem.AddFile(service.HostsFilePath, new MockFileData(string.Empty));
await service.WriteAsync(string.Empty, Enumerable.Empty<Entry>()); await service.WriteAsync(string.Empty, Enumerable.Empty<Entry>());
@@ -203,7 +199,6 @@ namespace Hosts.Tests
var fileSystem = new CustomMockFileSystem(); var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>(); var userSettings = new Mock<IUserSettings>();
userSettings.Setup(m => m.AdditionalLinesPosition).Returns(HostsAdditionalLinesPosition.Bottom); userSettings.Setup(m => m.AdditionalLinesPosition).Returns(HostsAdditionalLinesPosition.Bottom);
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)); fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
@@ -228,8 +223,7 @@ namespace Hosts.Tests
"; ";
var fileSystem = new CustomMockFileSystem(); 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)); fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
var data = await service.ReadAsync(); var data = await service.ReadAsync();
@@ -243,12 +237,37 @@ namespace Hosts.Tests
public async Task Save_NotRunningElevatedException() public async Task Save_NotRunningElevatedException()
{ {
var fileSystem = new CustomMockFileSystem(); var fileSystem = new CustomMockFileSystem();
var userSettings = new Mock<IUserSettings>();
var elevationHelper = new Mock<IElevationHelper>(); var elevationHelper = new Mock<IElevationHelper>();
elevationHelper.Setup(m => m.IsElevated).Returns(false); 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>())); 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; using System;
namespace Hosts.Helpers namespace Hosts.Exceptions
{ {
public class NotRunningElevatedException : Exception 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.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hosts.Exceptions;
using Hosts.Models; using Hosts.Models;
using Hosts.Settings; using Hosts.Settings;
using ManagedCommon; using ManagedCommon;
@@ -129,6 +130,11 @@ namespace Hosts.Helpers
throw new NotRunningElevatedException(); throw new NotRunningElevatedException();
} }
if (_fileSystem.FileInfo.FromFileName(HostsFilePath).IsReadOnly)
{
throw new ReadOnlyHostsException();
}
var lines = new List<string>(); var lines = new List<string>();
if (entries.Any()) 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() public void Dispose()
{ {
Dispose(disposing: true); Dispose(disposing: true);

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,6 +15,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.WinUI; using CommunityToolkit.WinUI;
using CommunityToolkit.WinUI.Collections; using CommunityToolkit.WinUI.Collections;
using Hosts.Exceptions;
using Hosts.Helpers; using Hosts.Helpers;
using Hosts.Models; using Hosts.Models;
using Hosts.Settings; using Hosts.Settings;
@@ -48,6 +49,9 @@ namespace Hosts.ViewModels
[ObservableProperty] [ObservableProperty]
private string _errorMessage; private string _errorMessage;
[ObservableProperty]
private bool _isReadOnly;
[ObservableProperty] [ObservableProperty]
private bool _fileChanged; private bool _fileChanged;
@@ -262,6 +266,13 @@ namespace Hosts.ViewModels
_hostsService.OpenHostsFile(); _hostsService.OpenHostsFile();
} }
[RelayCommand]
public void OverwriteHosts()
{
_hostsService.RemoveReadOnly();
_ = Task.Run(SaveAsync);
}
public void Dispose() public void Dispose()
{ {
Dispose(disposing: true); Dispose(disposing: true);
@@ -374,6 +385,7 @@ namespace Hosts.ViewModels
{ {
bool error = true; bool error = true;
string errorMessage = string.Empty; string errorMessage = string.Empty;
bool isReadOnly = false;
try try
{ {
@@ -385,6 +397,12 @@ namespace Hosts.ViewModels
var resourceLoader = ResourceLoaderInstance.ResourceLoader; var resourceLoader = ResourceLoaderInstance.ResourceLoader;
errorMessage = resourceLoader.GetString("FileSaveError_NotElevated"); 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) 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 // 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; Error = error;
ErrorMessage = errorMessage; ErrorMessage = errorMessage;
IsReadOnly = isReadOnly;
}); });
} }

View File

@@ -32,8 +32,6 @@ namespace
winrt::com_ptr<ID2D1Bitmap> ConvertID3D11Texture2DToD2D1Bitmap(winrt::com_ptr<ID2D1RenderTarget> rt, winrt::com_ptr<ID2D1Bitmap> ConvertID3D11Texture2DToD2D1Bitmap(winrt::com_ptr<ID2D1RenderTarget> rt,
const MappedTextureView* capturedScreenTexture) const MappedTextureView* capturedScreenTexture)
{ {
capturedScreenTexture->view.pixels;
D2D1_BITMAP_PROPERTIES props = { .pixelFormat = rt->GetPixelFormat() }; D2D1_BITMAP_PROPERTIES props = { .pixelFormat = rt->GetPixelFormat() };
rt->GetDpi(&props.dpiX, &props.dpiY); rt->GetDpi(&props.dpiX, &props.dpiY);
const auto sizeF = rt->GetSize(); const auto sizeF = rt->GetSize();

View File

@@ -85,28 +85,6 @@ namespace MouseWithoutBorders
return stack; return stack;
} }
internal static void SuspendAllThreadsBut(int threadId)
{
lock (ThreadsLock)
{
#pragma warning disable 618 // Temporary
threads.Where(t => t.IsAlive && t.ManagedThreadId != threadId).ToList().ForEach(
t =>
{
try
{
t.Suspend();
}
catch (Exception)
{
// This method is suspending every thread so that it can kill the process right after restarting.
// Makes no sense to crash on a thread suspension fail, since we're killing the process afterwards, anyway.
}
});
#pragma warning restore 618
}
}
internal void SetApartmentState(ApartmentState apartmentState) internal void SetApartmentState(ApartmentState apartmentState)
{ {
thread.SetApartmentState(apartmentState); thread.SetApartmentState(apartmentState);

View File

@@ -349,8 +349,6 @@ namespace MouseWithoutBorders
_ = Process.Start(Application.ExecutablePath, desktop); _ = Process.Start(Application.ExecutablePath, desktop);
LogDebug($"Started on desktop {desktop}"); LogDebug($"Started on desktop {desktop}");
Thread.SuspendAllThreadsBut(Thread.CurrentThread.ManagedThreadId);
Process.GetCurrentProcess().KillProcess(true); Process.GetCurrentProcess().KillProcess(true);
}, },
$"{actionName} watchdog").Start(); $"{actionName} watchdog").Start();

View File

@@ -12,8 +12,6 @@
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ui:ThemesDictionary Theme="Dark" /> <ui:ThemesDictionary Theme="Dark" />
<ui:ControlsDictionary /> <ui:ControlsDictionary />
<ResourceDictionary Source="/Styles/Colors.xaml" />
<ResourceDictionary Source="/Styles/ButtonStyles.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>

View File

@@ -3,12 +3,13 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:PowerOCR"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:p="clr-namespace:PowerOCR.Properties"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="TextExtractor" Title="TextExtractor"
Width="200" Width="200"
Height="200" Height="200"
ui:Design.Background="Transparent"
AllowsTransparency="True" AllowsTransparency="True"
Background="Transparent" Background="Transparent"
Loaded="Window_Loaded" Loaded="Window_Loaded"
@@ -23,19 +24,22 @@
mc:Ignorable="d"> mc:Ignorable="d">
<Window.Resources> <Window.Resources>
<Style x:Key="SymbolTextStyle" TargetType="TextBlock"> <Style BasedOn="{StaticResource DefaultToggleButtonStyle}" TargetType="{x:Type ToggleButton}">
<Setter Property="HorizontalAlignment" Value="Center" /> <Setter Property="Margin" Value="4,0" />
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="Padding" Value="0" />
<Setter Property="FontFamily" Value="Segoe MDL2 Assets" /> <Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="FontSize" Value="16" /> <Setter Property="Width" Value="32" />
<Setter Property="Margin" Value="4" /> <Setter Property="Height" Value="32" />
<Setter Property="Background" Value="Transparent" />
</Style> </Style>
<Style TargetType="ToggleButton">
<Setter Property="Margin" Value="2,0" /> <Style BasedOn="{StaticResource DefaultButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="Margin" Value="4,0" />
<Setter Property="HorizontalAlignment" Value="Center" /> <Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Width" Value="30" /> <Setter Property="Padding" Value="0" />
<Setter Property="Height" Value="30" /> <Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Background" Value="Transparent" />
</Style> </Style>
</Window.Resources> </Window.Resources>
@@ -70,23 +74,23 @@
<MenuItem <MenuItem
Name="SingleLineMenuItem" Name="SingleLineMenuItem"
Click="SingleLineMenuItem_Click" Click="SingleLineMenuItem_Click"
Header="Make Result Text Single Line" Header="{x:Static p:Resources.ResultTextSingleLine}"
IsCheckable="True" /> IsCheckable="True" />
<MenuItem <MenuItem
Name="TableMenuItem" Name="TableMenuItem"
Click="TableToggleButton_Click" Click="TableToggleButton_Click"
Header="OCR text as a table" Header="{x:Static p:Resources.ResultTextTable}"
IsCheckable="True" /> IsCheckable="True" />
<Separator /> <Separator />
<MenuItem <MenuItem
Name="SettingsMenuItem" Name="SettingsMenuItem"
Click="SettingsMenuItem_Click" Click="SettingsMenuItem_Click"
Header="Settings" /> Header="{x:Static p:Resources.Settings}" />
<Separator /> <Separator />
<MenuItem <MenuItem
Name="CancelMenuItem" Name="CancelMenuItem"
Click="CancelMenuItem_Click" Click="CancelMenuItem_Click"
Header="Cancel" /> Header="{x:Static p:Resources.Cancel}" />
</ContextMenu> </ContextMenu>
</Canvas.ContextMenu> </Canvas.ContextMenu>
</Canvas> </Canvas>
@@ -96,7 +100,6 @@
Padding="4,8,12,8" Padding="4,8,12,8"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
d:Background="White"
d:Visibility="Visible" d:Visibility="Visible"
Background="{DynamicResource ApplicationBackgroundBrush}" Background="{DynamicResource ApplicationBackgroundBrush}"
CornerRadius="8" CornerRadius="8"
@@ -104,75 +107,60 @@
<Border.Effect> <Border.Effect>
<DropShadowEffect <DropShadowEffect
BlurRadius="32" BlurRadius="32"
Direction="-90" Opacity="0.28"
Opacity="0.6" RenderingBias="Performance"
RenderingBias="Performance" /> ShadowDepth="1" />
</Border.Effect> </Border.Effect>
<StackPanel <StackPanel
Margin="2,0"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Orientation="Horizontal"> Orientation="Horizontal">
<ComboBox <ComboBox
x:Name="LanguagesComboBox" x:Name="LanguagesComboBox"
Margin="2,0" Height="32"
Padding="4,2,0,2" Margin="4,0"
Foreground="{DynamicResource TextFillColorPrimaryBrush}" AutomationProperties.Name="{x:Static p:Resources.SelectedLang}"
SelectionChanged="LanguagesComboBox_SelectionChanged"> SelectionChanged="LanguagesComboBox_SelectionChanged">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock <TextBlock
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
FontFamily="Segoe UI"
Style="{StaticResource SymbolTextStyle}"
Text="{Binding NativeName}" /> Text="{Binding NativeName}" />
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
<ToggleButton <ToggleButton
x:Name="SingleLineToggleButton" x:Name="SingleLineToggleButton"
Width="34"
Height="34"
Margin="2,0"
d:IsChecked="True" d:IsChecked="True"
AutomationProperties.Name="{x:Static p:Resources.ResultTextSingleLine}"
Click="SingleLineMenuItem_Click" Click="SingleLineMenuItem_Click"
IsChecked="{Binding IsChecked, ElementName=SingleLineMenuItem, Mode=TwoWay}" IsChecked="{Binding IsChecked, ElementName=SingleLineMenuItem, Mode=TwoWay}"
Style="{StaticResource ToggleSymbolButton}" ToolTip="{x:Static p:Resources.ResultTextSingleLineShortcut}">
ToolTip="(S) Make result a single line"> <ui:SymbolIcon FontSize="18" Symbol="SubtractSquare24" />
<TextBlock Style="{StaticResource SymbolTextStyle}" Text="" />
</ToggleButton> </ToggleButton>
<ToggleButton <ToggleButton
x:Name="TableToggleButton" x:Name="TableToggleButton"
Width="34"
Height="34"
Margin="2,0"
d:IsChecked="True" d:IsChecked="True"
AutomationProperties.Name="{x:Static p:Resources.ResultTextTable}"
Click="TableToggleButton_Click" Click="TableToggleButton_Click"
IsChecked="{Binding IsChecked, ElementName=TableMenuItem, Mode=TwoWay}" IsChecked="{Binding IsChecked, ElementName=TableMenuItem, Mode=TwoWay}"
Style="{StaticResource ToggleSymbolButton}" ToolTip="{x:Static p:Resources.ResultTextTableShortcut}">
ToolTip="(T) OCR text as a table"> <ui:SymbolIcon FontSize="18" Symbol="Table24" />
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" />
</ToggleButton> </ToggleButton>
<Button <Button
x:Name="SettingsButton" x:Name="SettingsButton"
Width="34" AutomationProperties.Name="{x:Static p:Resources.Settings}"
Height="34"
Margin="2,0"
Click="SettingsMenuItem_Click" Click="SettingsMenuItem_Click"
Style="{StaticResource SymbolButton}" ToolTip="{x:Static p:Resources.Settings}">
ToolTip="Settings"> <ui:SymbolIcon FontSize="18" Symbol="Settings24" />
<TextBlock Style="{StaticResource SymbolTextStyle}" Text="" />
</Button> </Button>
<Button <Button
x:Name="CancelButton" x:Name="CancelButton"
Width="34"
Height="34"
Margin="2,0,0,0"
Click="CancelMenuItem_Click" Click="CancelMenuItem_Click"
Style="{StaticResource SymbolButton}" ToolTip="{x:Static p:Resources.CancelShortcut}">
ToolTip="(Esc) Cancel"> <ui:SymbolIcon FontSize="18" Symbol="Dismiss24" />
<TextBlock Style="{StaticResource SymbolTextStyle}" Text="" />
</Button> </Button>
</StackPanel> </StackPanel>
</Border> </Border>

View File

@@ -49,7 +49,7 @@ public partial class OCROverlay : Window
Top = screenRectangle.Top >= 0 ? screenRectangle.Top : screenRectangle.Top + (screenRectangle.Height / 2); Top = screenRectangle.Top >= 0 ? screenRectangle.Top : screenRectangle.Top + (screenRectangle.Height / 2);
InitializeComponent(); InitializeComponent();
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this, Wpf.Ui.Controls.WindowBackdropType.None);
PopulateLanguageMenu(); PopulateLanguageMenu();
} }

View File

@@ -61,4 +61,20 @@
<ProjectReference Include="..\..\..\common\Common.UI\Common.UI.csproj" /> <ProjectReference Include="..\..\..\common\Common.UI\Common.UI.csproj" />
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" /> <ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
</Project> </Project>

View File

@@ -0,0 +1,135 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PowerOCR.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PowerOCR.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Cancel.
/// </summary>
public static string Cancel {
get {
return ResourceManager.GetString("Cancel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cancel (Esc).
/// </summary>
public static string CancelShortcut {
get {
return ResourceManager.GetString("CancelShortcut", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Format result as a single line.
/// </summary>
public static string ResultTextSingleLine {
get {
return ResourceManager.GetString("ResultTextSingleLine", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Format result as a single line (S).
/// </summary>
public static string ResultTextSingleLineShortcut {
get {
return ResourceManager.GetString("ResultTextSingleLineShortcut", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Format result as a table.
/// </summary>
public static string ResultTextTable {
get {
return ResourceManager.GetString("ResultTextTable", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Format result as a table (T).
/// </summary>
public static string ResultTextTableShortcut {
get {
return ResourceManager.GetString("ResultTextTableShortcut", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Selected language.
/// </summary>
public static string SelectedLang {
get {
return ResourceManager.GetString("SelectedLang", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Settings.
/// </summary>
public static string Settings {
get {
return ResourceManager.GetString("Settings", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Cancel" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="CancelShortcut" xml:space="preserve">
<value>Cancel (Esc)</value>
<comment>(Esc) indicates the keyboard shortcut</comment>
</data>
<data name="ResultTextSingleLine" xml:space="preserve">
<value>Format result as a single line</value>
</data>
<data name="ResultTextSingleLineShortcut" xml:space="preserve">
<value>Format result as a single line (S)</value>
<comment>(S) indicates the keyboard shortcut</comment>
</data>
<data name="ResultTextTable" xml:space="preserve">
<value>Format result as a table</value>
</data>
<data name="ResultTextTableShortcut" xml:space="preserve">
<value>Format result as a table (T)</value>
<comment>(T) indicates the keyboard shortcut</comment>
</data>
<data name="SelectedLang" xml:space="preserve">
<value>Selected language</value>
</data>
<data name="Settings" xml:space="preserve">
<value>Settings</value>
</data>
</root>

View File

@@ -1,695 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="Menu.Static.Background" Color="{DynamicResource SolidBackgroundFillColorSecondaryBrush}" />
<SolidColorBrush x:Key="Menu.Static.Border" Color="{DynamicResource SystemAccentColor}" />
<SolidColorBrush x:Key="Menu.Static.Foreground" Color="White" />
<SolidColorBrush x:Key="Menu.Static.Separator" Color="{DynamicResource SystemAccentColorSecondary}" />
<SolidColorBrush x:Key="Menu.Disabled.Foreground" Color="#FF707070" />
<SolidColorBrush x:Key="MenuItem.Selected.Background" Color="#3D26A0DA" />
<SolidColorBrush x:Key="MenuItem.Selected.Border" Color="{DynamicResource SystemAccentColor}" />
<SolidColorBrush x:Key="MenuItem.Highlight.Background" Color="#3D26A0DA" />
<SolidColorBrush x:Key="MenuItem.Highlight.Border" Color="{DynamicResource SystemAccentColor}" />
<SolidColorBrush x:Key="MenuItem.Highlight.Disabled.Background" Color="#0A000000" />
<SolidColorBrush x:Key="MenuItem.Highlight.Disabled.Border" Color="#21000000" />
<MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter" />
<Geometry x:Key="DownArrow">M 0,0 L 3.5,4 L 7,0 Z</Geometry>
<Geometry x:Key="UpArrow">M 0,4 L 3.5,0 L 7,4 Z</Geometry>
<Geometry x:Key="RightArrow">M 0,0 L 4,3.5 L 0,7 Z</Geometry>
<Geometry x:Key="Checkmark">F1 M 10.0,1.2 L 4.7,9.1 L 4.5,9.1 L 0,5.2 L 1.3,3.5 L 4.3,6.1L 8.3,0 L 10.0,1.2 Z</Geometry>
<Style x:Key="FocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle
Margin="2"
SnapsToDevicePixels="true"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<SolidColorBrush x:Key="Button.Static.Background" Color="Transparent" />
<SolidColorBrush x:Key="Button.Static.Border" Color="Transparent" />
<SolidColorBrush x:Key="Button.MouseOver.Background" Color="{DynamicResource SystemAccentColorSecondaryBrush}" />
<SolidColorBrush x:Key="Button.MouseOver.Border" Color="Transparent" />
<SolidColorBrush x:Key="Button.Pressed.Background" Color="#071818" />
<SolidColorBrush x:Key="Button.Pressed.Border" Color="#071818" />
<SolidColorBrush x:Key="Button.Disabled.Background" Color="Transparent" />
<SolidColorBrush x:Key="Button.Disabled.Border" Color="Transparent" />
<SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383" />
<Style x:Key="ToggleSymbolButton" TargetType="{x:Type ToggleButton}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
<Setter Property="Background" Value="{StaticResource Button.Static.Background}" />
<Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border
x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="true">
<ContentPresenter
x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsDefaulted" Value="true">
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="Background" Value="{DynamicResource SystemAccentColorBrush}" />
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Pressed.Border}" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="border" Property="Background" Value="{DynamicResource SystemAccentColorSecondaryBrush}" />
<Setter Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="border" Property="Background" Value="{StaticResource Button.Disabled.Background}" />
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Disabled.Border}" />
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{StaticResource Button.Disabled.Foreground}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="White" />
<Setter TargetName="border" Property="Background" Value="{DynamicResource SystemAccentColorSecondaryBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style
x:Key="MenuScrollButton"
BasedOn="{x:Null}"
TargetType="{x:Type RepeatButton}">
<Setter Property="ClickMode" Value="Hover" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border
x:Name="templateRoot"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="1"
SnapsToDevicePixels="true">
<ContentPresenter
Margin="6"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
<Border
x:Name="templateRoot"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="true">
<Grid VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
x:Name="Icon"
Width="16"
Height="16"
Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Path
x:Name="GlyphPanel"
Margin="3"
VerticalAlignment="Center"
Data="{StaticResource Checkmark}"
Fill="{StaticResource Menu.Static.Foreground}"
FlowDirection="LeftToRight"
Visibility="Collapsed" />
<ContentPresenter
Grid.Column="1"
Margin="{TemplateBinding Padding}"
ContentSource="Header"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="templateRoot" Property="Background" Value="{StaticResource MenuItem.Highlight.Background}" />
<Setter TargetName="templateRoot" Property="BorderBrush" Value="{StaticResource MenuItem.Highlight.Border}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="templateRoot" Property="TextElement.Foreground" Value="{StaticResource Menu.Disabled.Foreground}" />
<Setter TargetName="GlyphPanel" Property="Fill" Value="{StaticResource Menu.Disabled.Foreground}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsHighlighted" Value="True" />
<Condition Property="IsEnabled" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="templateRoot" Property="Background" Value="{StaticResource MenuItem.Highlight.Disabled.Background}" />
<Setter TargetName="templateRoot" Property="BorderBrush" Value="{StaticResource MenuItem.Highlight.Disabled.Border}" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
<Border
x:Name="templateRoot"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="true">
<Grid VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
x:Name="Icon"
Width="16"
Height="16"
Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Path
x:Name="GlyphPanel"
Margin="3"
VerticalAlignment="Center"
Data="{StaticResource Checkmark}"
Fill="{TemplateBinding Foreground}"
FlowDirection="LeftToRight"
Visibility="Collapsed" />
<ContentPresenter
Grid.Column="1"
Margin="{TemplateBinding Padding}"
ContentSource="Header"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Popup
x:Name="PART_Popup"
AllowsTransparency="true"
Focusable="false"
IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=templateRoot}"
PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
<Border
x:Name="SubMenuBorder"
Padding="2"
Background="{StaticResource Menu.Static.Background}"
BorderBrush="{StaticResource Menu.Static.Border}"
BorderThickness="1">
<ScrollViewer x:Name="SubMenuScrollViewer" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
<Grid RenderOptions.ClearTypeHint="Enabled">
<Canvas
Width="0"
Height="0"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Rectangle
x:Name="OpaqueRect"
Width="{Binding ActualWidth, ElementName=SubMenuBorder}"
Height="{Binding ActualHeight, ElementName=SubMenuBorder}"
Fill="{Binding Background, ElementName=SubMenuBorder}" />
</Canvas>
<Rectangle
Width="1"
Margin="29,2,0,2"
HorizontalAlignment="Left"
Fill="{StaticResource Menu.Static.Separator}" />
<ItemsPresenter
x:Name="ItemsPresenter"
Grid.IsSharedSizeScope="true"
KeyboardNavigation.DirectionalNavigation="Cycle"
KeyboardNavigation.TabNavigation="Cycle"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</ScrollViewer>
</Border>
</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSuspendingPopupAnimation" Value="true">
<Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="templateRoot" Property="Background" Value="{StaticResource MenuItem.Highlight.Background}" />
<Setter TargetName="templateRoot" Property="BorderBrush" Value="{StaticResource MenuItem.Highlight.Border}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="templateRoot" Property="TextElement.Foreground" Value="{StaticResource Menu.Disabled.Foreground}" />
<Setter TargetName="GlyphPanel" Property="Fill" Value="{StaticResource Menu.Disabled.Foreground}" />
</Trigger>
<Trigger SourceName="SubMenuScrollViewer" Property="ScrollViewer.CanContentScroll" Value="false">
<Setter TargetName="OpaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=SubMenuScrollViewer}" />
<Setter TargetName="OpaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=SubMenuScrollViewer}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
<Border
x:Name="templateRoot"
Height="22"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="true">
<Grid Margin="-1">
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="Auto"
MinWidth="22"
SharedSizeGroup="MenuItemIconColumnGroup" />
<ColumnDefinition Width="13" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<ContentPresenter
x:Name="Icon"
Width="16"
Height="16"
Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Border
x:Name="GlyphPanel"
Width="22"
Height="22"
Margin="-1,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="{StaticResource MenuItem.Selected.Background}"
BorderBrush="{StaticResource MenuItem.Selected.Border}"
BorderThickness="1"
ClipToBounds="False"
Visibility="Hidden">
<Path
x:Name="Glyph"
Width="10"
Height="11"
Data="{StaticResource Checkmark}"
Fill="{StaticResource Menu.Static.Foreground}"
FlowDirection="LeftToRight" />
</Border>
<ContentPresenter
x:Name="menuHeaderContainer"
Grid.Column="2"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
ContentSource="Header"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<TextBlock
x:Name="menuGestureText"
Grid.Column="4"
Margin="{TemplateBinding Padding}"
VerticalAlignment="Center"
Opacity="0.7"
Text="{TemplateBinding InputGestureText}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="templateRoot" Property="Background" Value="{StaticResource MenuItem.Highlight.Background}" />
<Setter TargetName="templateRoot" Property="BorderBrush" Value="{StaticResource MenuItem.Highlight.Border}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="templateRoot" Property="TextElement.Foreground" Value="{StaticResource Menu.Disabled.Foreground}" />
<Setter TargetName="Glyph" Property="Fill" Value="{StaticResource Menu.Disabled.Foreground}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsHighlighted" Value="True" />
<Condition Property="IsEnabled" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="templateRoot" Property="Background" Value="{StaticResource MenuItem.Highlight.Disabled.Background}" />
<Setter TargetName="templateRoot" Property="BorderBrush" Value="{StaticResource MenuItem.Highlight.Disabled.Border}" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
<Border
x:Name="templateRoot"
Height="22"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="true">
<Grid Margin="-1">
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="Auto"
MinWidth="22"
SharedSizeGroup="MenuItemIconColumnGroup" />
<ColumnDefinition Width="13" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<ContentPresenter
x:Name="Icon"
Width="16"
Height="16"
Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Border
x:Name="GlyphPanel"
Width="22"
Height="22"
Margin="-1,0,0,0"
VerticalAlignment="Center"
Background="{StaticResource MenuItem.Highlight.Background}"
BorderBrush="{StaticResource MenuItem.Highlight.Border}"
BorderThickness="1"
Visibility="Hidden">
<Path
x:Name="Glyph"
Width="9"
Height="11"
Data="{DynamicResource Checkmark}"
Fill="{StaticResource Menu.Static.Foreground}"
FlowDirection="LeftToRight" />
</Border>
<ContentPresenter
Grid.Column="2"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
ContentSource="Header"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<TextBlock
Grid.Column="4"
Margin="{TemplateBinding Padding}"
VerticalAlignment="Center"
Opacity="0.7"
Text="{TemplateBinding InputGestureText}" />
<Path
x:Name="RightArrow"
Grid.Column="5"
Margin="10,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Data="{StaticResource RightArrow}"
Fill="{StaticResource Menu.Static.Foreground}" />
<Popup
x:Name="PART_Popup"
AllowsTransparency="true"
Focusable="false"
HorizontalOffset="-2"
IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Right"
PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"
VerticalOffset="-3">
<Border
x:Name="SubMenuBorder"
Padding="2"
Background="{StaticResource Menu.Static.Background}"
BorderBrush="{StaticResource Menu.Static.Border}"
BorderThickness="1">
<ScrollViewer x:Name="SubMenuScrollViewer" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
<Grid RenderOptions.ClearTypeHint="Enabled">
<Canvas
Width="0"
Height="0"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Rectangle
x:Name="OpaqueRect"
Width="{Binding ActualWidth, ElementName=SubMenuBorder}"
Height="{Binding ActualHeight, ElementName=SubMenuBorder}"
Fill="{Binding Background, ElementName=SubMenuBorder}" />
</Canvas>
<Rectangle
Width="1"
Margin="29,2,0,2"
HorizontalAlignment="Left"
Fill="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
<ItemsPresenter
x:Name="ItemsPresenter"
Grid.IsSharedSizeScope="true"
KeyboardNavigation.DirectionalNavigation="Cycle"
KeyboardNavigation.TabNavigation="Cycle"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</ScrollViewer>
</Border>
</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSuspendingPopupAnimation" Value="true">
<Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="templateRoot" Property="Background" Value="Transparent" />
<Setter TargetName="templateRoot" Property="BorderBrush" Value="{StaticResource MenuItem.Highlight.Border}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="templateRoot" Property="TextElement.Foreground" Value="{StaticResource Menu.Disabled.Foreground}" />
<Setter TargetName="Glyph" Property="Fill" Value="{StaticResource Menu.Disabled.Foreground}" />
<Setter TargetName="RightArrow" Property="Fill" Value="{StaticResource Menu.Disabled.Foreground}" />
</Trigger>
<Trigger SourceName="SubMenuScrollViewer" Property="ScrollViewer.CanContentScroll" Value="false">
<Setter TargetName="OpaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=SubMenuScrollViewer}" />
<Setter TargetName="OpaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=SubMenuScrollViewer}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="DarkMenuItemStyle" TargetType="{x:Type MenuItem}">
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
<Style.Triggers>
<Trigger Property="Role" Value="TopLevelHeader">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Foreground" Value="{StaticResource Menu.Static.Foreground}" />
<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
<Setter Property="Padding" Value="6,0" />
</Trigger>
<Trigger Property="Role" Value="TopLevelItem">
<Setter Property="Background" Value="{StaticResource Menu.Static.Background}" />
<Setter Property="BorderBrush" Value="{StaticResource Menu.Static.Border}" />
<Setter Property="Foreground" Value="{StaticResource Menu.Static.Foreground}" />
<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=TopLevelItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
<Setter Property="Padding" Value="6,0" />
</Trigger>
<Trigger Property="Role" Value="SubmenuHeader">
<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="TitleBarCloseButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Padding" Value="0" />
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
x:Name="border"
BorderThickness="0"
SnapsToDevicePixels="true">
<ContentPresenter
x:Name="contentPresenter"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Focusable="False"
RecognizesAccessKey="True" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="Background" Value="Red" />
<Setter Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="Background" Value="DarkRed" />
<Setter Property="Foreground" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TitleBarButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Padding" Value="0" />
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
x:Name="border"
BorderThickness="0"
SnapsToDevicePixels="true">
<ContentPresenter
x:Name="contentPresenter"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Focusable="False"
RecognizesAccessKey="True" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="Background" Value="{StaticResource Menu.Static.Border}" />
<Setter Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="Background" Value="{StaticResource Menu.Static.Separator}" />
<Setter Property="Foreground" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TealColor" TargetType="Button">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="{DynamicResource SystemAccentColorSecondaryBrush}" />
<Setter Property="Padding" Value="0" />
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
x:Name="border"
Background="{TemplateBinding Background}"
CornerRadius="4"
SnapsToDevicePixels="true">
<ContentPresenter
x:Name="contentPresenter"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Focusable="False"
RecognizesAccessKey="True" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="{DynamicResource SystemAccentColorSecondaryBrush}" />
<Setter Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="border" Property="Background" Value="#071818" />
<Setter Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="border" Property="Opacity" Value="0.4" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SymbolButton" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="6" />
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
x:Name="border"
CornerRadius="4"
SnapsToDevicePixels="true">
<ContentPresenter
x:Name="contentPresenter"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Focusable="False"
RecognizesAccessKey="True" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="Background" Value="{DynamicResource SystemAccentColorSecondaryBrush}" />
<Setter Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="Background" Value="#071818" />
<Setter Property="Foreground" Value="{DynamicResource SystemAccentColorSecondaryBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.3" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@@ -1,6 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="DarkBackground" Color="{DynamicResource ApplicationBackgroundColor}" />
<SolidColorBrush x:Key="DarkControlBackground" Color="{DynamicResource SolidBackgroundFillColorQuarternaryBrushColor}" />
<SolidColorBrush x:Key="DarkTeal" Color="{DynamicResource SystemAccentColorSecondary}" />
<SolidColorBrush x:Key="Teal" Color="{DynamicResource SystemAccentColor}" />
</ResourceDictionary>

View File

@@ -12,6 +12,7 @@
#include <common/interop/shared_constants.h> #include <common/interop/shared_constants.h>
#include <common/utils/logger_helper.h> #include <common/utils/logger_helper.h>
#include <common/utils/winapi_error.h> #include <common/utils/winapi_error.h>
#include <common/utils/package.h>
BOOL APIENTRY DllMain(HMODULE /*hModule*/, BOOL APIENTRY DllMain(HMODULE /*hModule*/,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
@@ -293,6 +294,13 @@ public:
{ {
return m_enabled; return m_enabled;
} }
// Returns whether the PowerToys should be enabled by default
virtual bool is_enabled_by_default() const override
{
// disabled by default for Windows 11 and enabled by default on Windows 10
return !package::IsWin11OrGreater();
}
}; };
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()

View File

@@ -79,6 +79,11 @@
<Compile Update="Program.cs"> <Compile Update="Program.cs">
<CopyToOutputDirectory>Never</CopyToOutputDirectory> <CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Compile> </Compile>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -87,11 +92,17 @@
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.NetAnalyzers"> <PackageReference Update="Microsoft.CodeAnalysis.NetAnalyzers">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -6,12 +6,14 @@ using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO; using System.IO;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Awake.Core.Models; using Awake.Core.Models;
using Awake.Core.Native; using Awake.Core.Native;
using Awake.Properties;
using ManagedCommon; using ManagedCommon;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.Win32; using Microsoft.Win32;
@@ -274,9 +276,9 @@ namespace Awake.Core
{ {
Dictionary<string, int> optionsList = new Dictionary<string, int> Dictionary<string, int> optionsList = new Dictionary<string, int>
{ {
{ "30 minutes", 1800 }, { string.Format(CultureInfo.InvariantCulture, Resources.AWAKE_MINUTES, 30), 1800 },
{ "1 hour", 3600 }, { Resources.AWAKE_1_HOUR, 3600 },
{ "2 hours", 7200 }, { string.Format(CultureInfo.InvariantCulture, Resources.AWAKE_HOURS, 2), 7200 },
}; };
return optionsList; return optionsList;
} }

View File

@@ -6,11 +6,13 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Awake.Core.Models; using Awake.Core.Models;
using Awake.Core.Native; using Awake.Core.Native;
using Awake.Properties;
using ManagedCommon; using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
@@ -115,11 +117,11 @@ namespace Awake.Core
if (!startedFromPowerToys) if (!startedFromPowerToys)
{ {
// If Awake is started from PowerToys, the correct way to exit it is disabling it from Settings. // If Awake is started from PowerToys, the correct way to exit it is disabling it from Settings.
Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING, (uint)TrayCommands.TC_EXIT, "Exit"); Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING, (uint)TrayCommands.TC_EXIT, Resources.AWAKE_EXIT);
Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_SEPARATOR, 0, string.Empty); Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_SEPARATOR, 0, string.Empty);
} }
Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (keepDisplayOn ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED) | (mode == AwakeMode.PASSIVE ? Native.Constants.MF_DISABLED : Native.Constants.MF_ENABLED), (uint)TrayCommands.TC_DISPLAY_SETTING, "Keep screen on"); Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (keepDisplayOn ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED) | (mode == AwakeMode.PASSIVE ? Native.Constants.MF_DISABLED : Native.Constants.MF_ENABLED), (uint)TrayCommands.TC_DISPLAY_SETTING, Resources.AWAKE_KEEP_SCREEN_ON);
} }
// In case there are no tray shortcuts defined for the application default to a // In case there are no tray shortcuts defined for the application default to a
@@ -137,10 +139,10 @@ namespace Awake.Core
Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_SEPARATOR, 0, string.Empty); Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_SEPARATOR, 0, string.Empty);
Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (mode == AwakeMode.PASSIVE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_PASSIVE, "Off (keep using the selected power plan)"); Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (mode == AwakeMode.PASSIVE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_PASSIVE, Resources.AWAKE_OFF);
Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (mode == AwakeMode.INDEFINITE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_INDEFINITE, "Keep awake indefinitely"); Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (mode == AwakeMode.INDEFINITE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_INDEFINITE, Resources.AWAKE_KEEP_INDEFINITELY);
Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_POPUP | (mode == AwakeMode.TIMED ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)awakeTimeMenu, "Keep awake on interval"); Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_POPUP | (mode == AwakeMode.TIMED ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)awakeTimeMenu, Resources.AWAKE_KEEP_ON_INTERVAL);
Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | Native.Constants.MF_DISABLED | (mode == AwakeMode.EXPIRABLE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_EXPIRABLE, "Keep awake until expiration date and time"); Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | Native.Constants.MF_DISABLED | (mode == AwakeMode.EXPIRABLE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_EXPIRABLE, Resources.AWAKE_KEEP_UNTIL_EXPIRATION);
TrayIcon.Text = text; TrayIcon.Text = text;
} }
@@ -157,7 +159,7 @@ namespace Awake.Core
public override AccessibleRole Role => AccessibleRole.CheckButton; public override AccessibleRole Role => AccessibleRole.CheckButton;
public override string Name => _menuItem.Text + ", " + Role + ", " + (_menuItem.Checked ? "Checked" : "Unchecked"); public override string Name => _menuItem.Text + ", " + Role + ", " + (_menuItem.Checked ? Resources.AWAKE_CHECKED : Resources.AWAKE_UNCHECKED);
} }
private sealed class CheckButtonToolStripMenuItem : ToolStripMenuItem private sealed class CheckButtonToolStripMenuItem : ToolStripMenuItem

View File

@@ -0,0 +1,171 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Awake.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Awake.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to 1 hour.
/// </summary>
internal static string AWAKE_1_HOUR {
get {
return ResourceManager.GetString("AWAKE_1_HOUR", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 1 minute.
/// </summary>
internal static string AWAKE_1_MINUTE {
get {
return ResourceManager.GetString("AWAKE_1_MINUTE", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Checked.
/// </summary>
internal static string AWAKE_CHECKED {
get {
return ResourceManager.GetString("AWAKE_CHECKED", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Exit.
/// </summary>
internal static string AWAKE_EXIT {
get {
return ResourceManager.GetString("AWAKE_EXIT", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} hours.
/// </summary>
internal static string AWAKE_HOURS {
get {
return ResourceManager.GetString("AWAKE_HOURS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Keep awake indefinitely.
/// </summary>
internal static string AWAKE_KEEP_INDEFINITELY {
get {
return ResourceManager.GetString("AWAKE_KEEP_INDEFINITELY", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Keep awake on interval.
/// </summary>
internal static string AWAKE_KEEP_ON_INTERVAL {
get {
return ResourceManager.GetString("AWAKE_KEEP_ON_INTERVAL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Keep screen on.
/// </summary>
internal static string AWAKE_KEEP_SCREEN_ON {
get {
return ResourceManager.GetString("AWAKE_KEEP_SCREEN_ON", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Keep awake until expiration date and time.
/// </summary>
internal static string AWAKE_KEEP_UNTIL_EXPIRATION {
get {
return ResourceManager.GetString("AWAKE_KEEP_UNTIL_EXPIRATION", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} minutes.
/// </summary>
internal static string AWAKE_MINUTES {
get {
return ResourceManager.GetString("AWAKE_MINUTES", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Off (keep using the selected power plan).
/// </summary>
internal static string AWAKE_OFF {
get {
return ResourceManager.GetString("AWAKE_OFF", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unchecked.
/// </summary>
internal static string AWAKE_UNCHECKED {
get {
return ResourceManager.GetString("AWAKE_UNCHECKED", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AWAKE_CHECKED" xml:space="preserve">
<value>Checked</value>
</data>
<data name="AWAKE_EXIT" xml:space="preserve">
<value>Exit</value>
</data>
<data name="AWAKE_1_HOUR" xml:space="preserve">
<value>1 hour</value>
</data>
<data name="AWAKE_HOURS" xml:space="preserve">
<value>{0} hours</value>
<comment>{0} shouldn't be removed. It will be replaced by a number greater than 1 at runtime by the application. Used for defining a period to keep the PC awake.</comment>
</data>
<data name="AWAKE_KEEP_INDEFINITELY" xml:space="preserve">
<value>Keep awake indefinitely</value>
<comment>Keep the system awake forever</comment>
</data>
<data name="AWAKE_KEEP_ON_INTERVAL" xml:space="preserve">
<value>Keep awake on interval</value>
<comment>Keep the system awake for a given time</comment>
</data>
<data name="AWAKE_KEEP_SCREEN_ON" xml:space="preserve">
<value>Keep screen on</value>
</data>
<data name="AWAKE_KEEP_UNTIL_EXPIRATION" xml:space="preserve">
<value>Keep awake until expiration date and time</value>
<comment>Keep the system awake until expiration date and time</comment>
</data>
<data name="AWAKE_1_MINUTE" xml:space="preserve">
<value>1 minute</value>
</data>
<data name="AWAKE_MINUTES" xml:space="preserve">
<value>{0} minutes</value>
<comment>{0} shouldn't be removed. It will be replaced by a number greater than 1 at runtime by the application. Used for defining a period to keep the PC awake.</comment>
</data>
<data name="AWAKE_OFF" xml:space="preserve">
<value>Off (keep using the selected power plan)</value>
<comment>Don't keep the system awake, use the selected system power plan</comment>
</data>
<data name="AWAKE_UNCHECKED" xml:space="preserve">
<value>Unchecked</value>
</data>
</root>

View File

@@ -394,6 +394,15 @@ void FancyZones::WindowCreated(HWND window) noexcept
return; 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 // Avoid already stamped (zoned) windows
const bool isZoned = !FancyZonesWindowProperties::RetrieveZoneIndexProperty(window).empty(); const bool isZoned = !FancyZonesWindowProperties::RetrieveZoneIndexProperty(window).empty();
if (isZoned) 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. // 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 // also, popup could be the windows we want to snap disregarding the "allowSnapPopupWindows" setting, e.g. Telegram
bool isPopup = FancyZonesWindowUtils::IsPopupWindow(window); bool isPopup = FancyZonesWindowUtils::IsPopupWindow(window) && !FancyZonesWindowUtils::HasThickFrameAndMinimizeMaximizeButtons(window);
bool hasThickFrame = FancyZonesWindowUtils::HasThickFrame(window); if (isPopup && !FancyZonesSettings::settings().allowSnapPopupWindows)
if (isPopup && (!hasThickFrame || !FancyZonesSettings::settings().allowSnapPopupWindows))
{ {
return false; return false;
} }

View File

@@ -238,7 +238,7 @@ void FancyZonesSettings::LoadSettings()
if (auto val = values.get_int_value(NonLocalizable::OverlappingZonesAlgorithmID)) if (auto val = values.get_int_value(NonLocalizable::OverlappingZonesAlgorithmID))
{ {
// Avoid undefined behavior // Avoid undefined behavior
if (*val >= 0 || *val < static_cast<int>(OverlappingZonesAlgorithm::EnumElements)) if (*val >= 0 && *val < static_cast<int>(OverlappingZonesAlgorithm::EnumElements))
{ {
auto algorithm = (OverlappingZonesAlgorithm)*val; auto algorithm = (OverlappingZonesAlgorithm)*val;
if (m_settings.overlappingZonesAlgorithm != algorithm) if (m_settings.overlappingZonesAlgorithm != algorithm)

View File

@@ -306,26 +306,23 @@ void FancyZonesWindowUtils::SizeWindowToRect(HWND window, RECT rect) noexcept
::GetWindowPlacement(window, &placement); ::GetWindowPlacement(window, &placement);
} }
if (!IsWindowVisible(window)) if (IsWindowVisible(window))
{
placement.showCmd = SW_HIDE;
}
else
{ {
// Do not restore minimized windows. We change their placement though so they restore to the correct zone. // Do not restore minimized windows. We change their placement though so they restore to the correct zone.
if ((placement.showCmd != SW_SHOWMINIMIZED) && if ((placement.showCmd != SW_SHOWMINIMIZED) &&
(placement.showCmd != SW_MINIMIZE)) (placement.showCmd != SW_MINIMIZE))
{ {
placement.showCmd = SW_RESTORE; // Remove maximized show command to make sure window is moved to the correct zone.
} if (placement.showCmd == SW_SHOWMAXIMIZED)
placement.flags &= ~WPF_RESTORETOMAXIMIZED;
// Remove maximized show command to make sure window is moved to the correct zone.
if (placement.showCmd == SW_SHOWMAXIMIZED)
{
placement.showCmd = SW_RESTORE; placement.showCmd = SW_RESTORE;
placement.flags &= ~WPF_RESTORETOMAXIMIZED;
} }
} }
else
{
placement.showCmd = SW_HIDE;
}
ScreenToWorkAreaCoords(window, rect); ScreenToWorkAreaCoords(window, rect);

View File

@@ -44,7 +44,7 @@ namespace ImageResizer.ViewModels
{ {
if (_batch.Files.Count == 0) if (_batch.Files.Count == 0)
{ {
_batch.Files.AddRange(view?.OpenPictureFiles()); _batch.Files.AddRange(view.OpenPictureFiles());
} }
CurrentPage = new InputViewModel(_settings, this, view, _batch); CurrentPage = new InputViewModel(_settings, this, view, _batch);

View File

@@ -16,7 +16,6 @@
ExtendsContentIntoTitleBar="True" ExtendsContentIntoTitleBar="True"
Icon="/PowerToys.ImageResizer;component/Resources/ImageResizer.ico" Icon="/PowerToys.ImageResizer;component/Resources/ImageResizer.ico"
ResizeMode="NoResize" ResizeMode="NoResize"
WindowBackdropType="Mica"
WindowCornerPreference="Default" WindowCornerPreference="Default"
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">

View File

@@ -5,6 +5,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Common.UI;
using ImageResizer.ViewModels; using ImageResizer.ViewModels;
using Microsoft.Win32; using Microsoft.Win32;
using Wpf.Ui.Controls; using Wpf.Ui.Controls;
@@ -17,7 +18,17 @@ namespace ImageResizer.Views
public MainWindow(MainViewModel viewModel) public MainWindow(MainViewModel viewModel)
{ {
DataContext = viewModel; DataContext = viewModel;
Wpf.Ui.Appearance.Watcher.Watch(this); Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this);
if (OSVersionHelper.IsWindows11())
{
WindowBackdropType = WindowBackdropType.Mica;
}
else
{
WindowBackdropType = WindowBackdropType.None;
}
InitializeComponent(); InitializeComponent();
} }

View File

@@ -1,4 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild"> <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" /> <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> </Target>

View File

@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Project configurations --> <!-- 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')" /> <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> <PropertyGroup>
<NoWarn>81010002</NoWarn> <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> <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> </ClCompile>
<Link> <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> <AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(ConfigurationName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
@@ -109,7 +111,7 @@
<Link> <Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <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> <AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(ConfigurationName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
@@ -160,6 +162,10 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <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.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> </ImportGroup>
<Import Project="..\..\..\..\deps\spdlog.props" /> <Import Project="..\..\..\..\deps\spdlog.props" />
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild"> <Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
@@ -171,5 +177,15 @@
</PropertyGroup> </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.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.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> </Target>
</Project> </Project>

View File

@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <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" /> <package id="Microsoft.Windows.CppWinRT" version="2.0.221104.6" targetFramework="native" />
</packages> </packages>

View File

@@ -15,7 +15,7 @@
#include "EditKeyboardWindow.h" #include "EditKeyboardWindow.h"
#include "SingleKeyRemapControl.h" #include "SingleKeyRemapControl.h"
#include "KeyDropDownControl.h" #include "KeyDropDownControl.h"
#include "XamlBridge.h" #include "XamlBridge2.h"
#include "Styles.h" #include "Styles.h"
#include "Dialog.h" #include "Dialog.h"
#include "LoadingAndSavingRemappingHelper.h" #include "LoadingAndSavingRemappingHelper.h"
@@ -41,12 +41,12 @@ HWND hwndEditKeyboardNativeWindow = nullptr;
std::mutex editKeyboardWindowMutex; std::mutex editKeyboardWindowMutex;
// Stores a pointer to the Xaml Bridge object so that it can be accessed from the window procedure // 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 // Theming
ThemeListener theme_listener{}; static ThemeListener theme_listener{};
void handleTheme() static void handleTheme()
{ {
auto theme = theme_listener.AppTheme; auto theme = theme_listener.AppTheme;
auto isDark = theme == AppTheme::Dark; auto isDark = theme == AppTheme::Dark;
@@ -137,7 +137,7 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
windowClass.lpfnWndProc = EditKeyboardWindowProc; windowClass.lpfnWndProc = EditKeyboardWindowProc;
windowClass.hInstance = hInst; windowClass.hInstance = hInst;
windowClass.lpszClassName = szWindowClass; 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.hIcon = static_cast<HICON>(LoadImageW(
windowClass.hInstance, windowClass.hInstance,
MAKEINTRESOURCE(IDS_KEYBOARDMANAGER_ICON), MAKEINTRESOURCE(IDS_KEYBOARDMANAGER_ICON),
@@ -196,17 +196,19 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
hwndEditKeyboardNativeWindow = _hWndEditKeyboardWindow; hwndEditKeyboardNativeWindow = _hWndEditKeyboardWindow;
hwndLock.unlock(); 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(); handleTheme();
theme_listener.AddChangedHandler(handleTheme); theme_listener.AddChangedHandler(handleTheme);
// Create the xaml bridge object // Create the xaml bridge object
XamlBridge xamlBridge(_hWndEditKeyboardWindow); XamlBridge2 xamlBridge(_hWndEditKeyboardWindow);
// DesktopSource needs to be declared before the RelativePanel xamlContainer object to avoid errors
winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource desktopSource;
// Create the desktop window xaml source object and set its content // 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 // Set the pointer to the xaml bridge object
xamlBridgePtr = &xamlBridge; xamlBridgePtr = &xamlBridge;
@@ -322,11 +324,8 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
// Add remap key button // Add remap key button
Windows::UI::Xaml::Controls::Button addRemapKey; 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.Margin({ 10, 10, 0, 25 });
addRemapKey.Style(AccentButtonStyle());
addRemapKey.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) { addRemapKey.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
SingleKeyRemapControl::AddNewControlKeyRemapRow(keyRemapTable, keyboardRemapControlObjects); SingleKeyRemapControl::AddNewControlKeyRemapRow(keyRemapTable, keyboardRemapControlObjects);
@@ -337,14 +336,19 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
UIHelpers::SetFocusOnTypeButtonInLastRow(keyRemapTable, EditorConstants::RemapTableColCount); 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 // Set accessible name for the addRemapKey button
addRemapKey.SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_ADD_KEY_REMAP_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 // Header and example text at the top of the window
StackPanel helperText; StackPanel helperText;
helperText.Children().Append(keyRemapInfoHeader); 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 ////End XAML Island section
if (_hWndEditKeyboardWindow) if (_hWndEditKeyboardWindow)
{ {
@@ -400,9 +417,6 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
hwndEditKeyboardNativeWindow = nullptr; hwndEditKeyboardNativeWindow = nullptr;
keyboardManagerState.ResetUIState(); keyboardManagerState.ResetUIState();
keyboardManagerState.ClearRegisteredKeyDelays(); 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) void CreateEditKeyboardWindow(HINSTANCE hInst, KBMEditor::KeyboardManagerState& keyboardManagerState, MappingConfiguration& mappingConfiguration)

Some files were not shown because too many files have changed in this diff Show More