Merge branch 'microsoft-master'

This commit is contained in:
Den Delimarsky 2021-04-07 17:13:45 -07:00
commit 9cb333f7b5
No known key found for this signature in database
GPG Key ID: E1BE1355085F0BCF
610 changed files with 21033 additions and 18406 deletions

View File

@ -1,38 +0,0 @@
---
name: 🐛 Bug report
about: Report errors or unexpected behavior
title: ''
labels: Issue-Bug,Triage-Needed
assignees: ''
---
<!--
**Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**.
Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue.
-->
## Computer information
- PowerToys version:
- PowerToy Utility:
- Running PowerToys as Admin:
- Windows build number: [run "winver"]
## 📝 Provide detailed reproduction steps (if any)
1. …
2. …
3. …
### ✔️ Expected result
_What is the expected result of the above steps?_
### ❌ Actual result
_What is the actual result of the above steps?_
## 📷 Screenshots
_Are there any useful screenshots? WinKey+Shift+S and then just paste them directly into the form_

87
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,87 @@
name: "🐛 Bug report"
description: Report errors or unexpected behavior
title: ''
labels:
- Issue-Bug
- Triage-Needed
assignees: ''
issue_body: true
body:
- type: markdown
attributes:
value: |
Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one!
- type: input
attributes:
label: Microsoft PowerToys version
placeholder: |
"0.33.1"
description: |
Hover over system tray icon or look at Settings
validations:
required: true
- type: checkboxes
attributes:
label: Running as admin
description: Are you running PowerToys as Admin?
options:
- label: "Yes"
- type: dropdown
attributes:
label: Area(s) with issue?
description: What things had an issue? Check all that apply.
multiple: true
options:
- General
- ColorPicker
- FancyZones
- FancyZones Editor
- Image Resizer
- Keyboard Manager
- MD Preview
- PowerRename
- PowerToys Run
- Shortcut Guide
- SVG Preview
- SVG Thumbnail
- Settings
- Welcome / PowerToys Tour window
- System tray interaction
- Installer
validations:
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: We highly suggest including a screenshots and a bug report log (System tray->Report bug). To include, paste them into the markdown editor below the form or follow up with a separate comment.
placeholder: Tell us the steps required to trigger your bug.
validations:
required: true
- type: textarea
attributes:
label: ✔️ Expected Behavior
placeholder: What were you expecting?
validations:
required: false
- type: textarea
attributes:
label: ❌ Actual Behavior
placeholder: What happened instead?
validations:
required: true
- type: textarea
attributes:
label: Other Software
description: If you're reporting a bug about our interaction with other software, what software? What versions?
placeholder: |
vim 8.2 (inside WSL)
OpenSSH_for_Windows_8.1p1
My Cool Application v0.3 (include a code snippet if it would help!)
validations:
required: false

View File

@ -1,30 +0,0 @@
---
name: 📖 Localization/Translation issue
about: Report incorrect translations.
title: ''
labels: Issue-Bug,Area-Localization,Issue-Translation,Triage-Needed
assignees: ''
---
## Computer information
- PowerToys version:
- PowerToy utility:
- Language:
## 📝 Provide where the issue is / 📷 Screenshots
_Are there any useful screenshots? WinKey+Shift+S and then just paste them directly into the form_
### ❌ Actual phrase(s)
_What is there?_
### ✔️ Expected phrase(s)
_What do you expect?_
### Why is the current translation wrong
_If it is opinion based issue, why do you feel this is incorrect? Example: term is outdated_

View File

@ -0,0 +1,71 @@
name: "🌐 Localization/Translation issue"
description: Report incorrect translations.
title: ''
labels:
- Issue-Bug
- Area-Localization
- Issue-Translation
- Triage-Needed
assignees: ''
issue_body: true
body:
- type: markdown
attributes:
value: |
Please make sure to [search for existing issues](https://github.com/microsoft/PowerTOys/issues) before filing a new one!
- type: input
attributes:
label: Microsoft PowerToys version
placeholder: "0.33.1"
description: |
Hover over system tray icon or look at Settings
validations:
required: true
- type: dropdown
attributes:
label: Utility with translation issue
description: |
Please include a screenshot as that is extremely helpful. To include, paste them into the markdown editor below the form or follow up with a separate comment.
options:
- General
- ColorPicker
- FancyZones
- FancyZones Editor
- Image Resizer
- Keyboard Manager
- MD Preview
- PowerRename
- PowerToys Run
- Shortcut Guide
- SVG Preview
- SVG Thumbnail
- Settings
- Welcome / PowerToys Tour window
- System tray interaction
- Installer
validations:
required: true
- type: input
attributes:
label: 🌐 Language affected
placeholder: "German"
validations:
required: true
- type: textarea
attributes:
label: ❌ Actual phrase(s)
placeholder: What is there?
validations:
required: true
- type: textarea
attributes:
label: ✔️ Expected phrase(s)
placeholder: What was expected?
validations:
required: true
- type: textarea
attributes:
label: Why is the current translation wrong
placeholder: Why do you feel this is incorrect?
validations:
required: true

View File

@ -1,3 +1,13 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-excludes
(?:^|/)(?i)COPYRIGHT
(?:^|/)(?i)LICEN[CS]E
(?:^|/)package(?:-lock)\.json$
(?:^|/)vendor/
/package(?:-lock|)\.json$
/pinyindb/
/settings-html/
ignore$
[/.][a-z]{2}(?:-[a-zA-Z]{2}|)\.
\.ai$
\.bmp$
\.dat$
@ -7,13 +17,13 @@
\.ico$
\.jpg$
\.lcl$
\.lock$
\.min\.
\.mod$
\.pdf$
\.png$
\.PNG$
\.woff$
\.zip$
^\.github/
^\.github/actions/spell-check/
/package(?:-lock|)\.json$
/pinyindb/
/settings-html/
[/.][a-z]{2}(?:-[a-zA-Z]{2}|)\.

View File

@ -3,13 +3,10 @@ AAD
abcd
abcdef
abcdefgh
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abgr
ABlocked
Abug
acb
accctrl
accd
Acceleratorkeys
ACCEPTFILES
accessibile
@ -20,13 +17,15 @@ AColumn
acos
acrt
Actioncenter
actioned
activatable
ACTIVATEAPP
activationaction
Addavirtualdesktop
Addins
addrum
ADDUNDORECORD
ADifferent
ADMINS
adopsinsider
advapi
advfirewall
@ -51,9 +50,10 @@ amd
Amicrosoft
AMirror
AModifier
AMPROPERTY
AMPROPSETID
anges
ansicolor
ansicpg
antialiased
ANull
AOC
@ -121,7 +121,6 @@ aumid
AUTHN
AUTOAPPEND
autocomplete
autogenerated
autogenerates
AUTOHIDE
AUTOMATIONPROPERTIES
@ -131,18 +130,14 @@ autoupdate
AValid
azurecr
azurewebsites
baae
baccda
backend
backtracer
bak
bbe
bbwe
bc
bcc
bck
Bcl
bddac
BEGINLABELEDIT
betadele
betsegaw
@ -169,8 +164,10 @@ BLURREGION
bmi
bmp
bms
BNumber
Bokm
BOKMAL
Bools
bootstrapper
BOTTOMALIGN
BPBF
@ -180,9 +177,7 @@ bricelam
BRIGHTGREEN
Browsable
bsd
BSODs
bstr
BText
bti
Btn
BTNFACE
@ -202,7 +197,6 @@ Captureascreenshot
CAPTURECHANGED
CASESENSITIVE
CAtl
cbfbad
CCDDEE
ccf
cch
@ -210,20 +204,20 @@ CCom
CContext
CDATA
CDBECF
cde
cdecl
CDeclaration
CDEF
cdpx
cdpxwin
CENTERALIGN
cfg
changecursor
Changemove
cguid
charconv
charset
chdir
checkbox
checkboxes
CHECKCANCELED
Checkedin
checknetisolation
Chicklet
@ -237,7 +231,6 @@ chrono
chrzan
CHT
CImage
cimv
cinttypes
cla
clangformat
@ -261,12 +254,12 @@ CMDARG
cmder
Cmdlet
cmdline
Cmds
CMIC
CMINVOKECOMMANDINFO
CMINVOKECOMMANDINFOEX
CMock
CMONITORS
cmpr
cmyk
cn
cnt
@ -274,13 +267,10 @@ coclass
codebase
codecvt
codeofconduct
codeql
codereview
Codespaces
COINIT
colorconv
colorhistory
colorhistorylimit
colorpicker
colorpickerref
COLORREF
@ -317,7 +307,6 @@ CONTROLL
CONTROLPARENT
Controlz
coords
copiedcolorrepresentation
COPYDATASTRUCT
corehr
cortana
@ -347,7 +336,6 @@ critsec
crlf
CRM
crmcustomerinsightsapp
cron
CRSEL
crutkas
CSearch
@ -370,12 +358,12 @@ ctime
CTLCOLORSTATIC
ctor
CTRLALTDEL
Ctrls
Ctx
CUI
currentculture
CURSORINFO
cursorpos
customaction
CUSTOMACTIONTEST
cvd
cw
@ -427,8 +415,6 @@ DEFAULTTONEAREST
DEFAULTTONULL
DEFAULTTOPRIMARY
DEFERERASE
deff
deflang
DEFPUSHBUTTON
deinitialization
DELA
@ -453,7 +439,8 @@ DEU
Devagya
devblogs
devdocs
devenv
devenum
DEVMON
df
DFactory
Dialpad
@ -506,6 +493,7 @@ drivedetectionwarning
DRM
dropdown
dropref
dshow
dst
DSVG
DText
@ -554,7 +542,7 @@ EBE
EBEC
EBEE
EBEF
ebf
EBF
EBFC
ECAA
ECAB
@ -567,6 +555,7 @@ ECDC
ECDE
ECDF
ECEB
ECED
ECEE
ecef
ECFE
@ -627,7 +616,7 @@ EFBA
EFC
EFDA
EFDE
efe
EFE
EFEB
EFFC
EFFE
@ -646,6 +635,7 @@ endregion
Enque
ENTERSIZEMOVE
Entireitemname
Entitlements
entrypoint
ENU
enum
@ -709,12 +699,9 @@ FANCYZONESEDITOR
Farbraum
FARPROC
Favicon
fcharset
fd
fda
feimage
ffcd
ffd
FFDDDDDD
fff
figcaption
@ -735,17 +722,16 @@ finalizer
findstr
FIXEDFILEINFO
FLASHZONES
FLASHZONESONQUICKSWITCH
Fle
fluentui
flyout
fmtlib
fnil
fody
FOF
FOFX
FOLDERID
folderpath
fonttbl
FORCEOFFLINE
foreach
formatetc
@ -774,8 +760,6 @@ gdi
gdiplus
GDISCALED
generatesqlfromuserquery
getancestor
getasynckeystate
GETDISPINFO
GETDLGCODE
GETEMPTYMARKUP
@ -793,17 +777,16 @@ githubusercontent
gitignore
globals
gmx
GNumber
google
GPTR
grayscale
GText
gui
guiddef
GUITHREADINFO
GValue
gwl
GWLP
gwmi
HACCEL
hangeul
hanja
@ -904,6 +887,7 @@ IAppx
IAsync
IAuto
IBackground
IBase
IBeam
IBind
icase
@ -918,11 +902,11 @@ IComparer
ICONERROR
ICONINFORMATION
ICONQUESTION
Iconsempty
Iconset
IContext
ICONWARNING
ICore
ICreate
IData
IDCANCEL
IDD
@ -968,20 +952,20 @@ Iindex
IInitialize
IInput
IInspectable
IIO
IItem
IJson
IKs
IList
ILogon
IMAGEHLP
imageresizer
IMAGERESIZEREXT
imageresizersettings
IMain
IMarkdown
ime
imeutil
img
IMoniker
IMonitor
IMouse
impl
@ -997,7 +981,7 @@ inheritdoc
ini
INITCOMMONCONTROLSEX
INITDIALOG
INITGUID
initguid
inl
Inlines
inorder
@ -1007,7 +991,6 @@ inout
INPC
inprivate
inproc
inputdev
INPUTHARDWARE
INPUTKEYBOARD
INPUTLANGCHANGED
@ -1020,7 +1003,6 @@ INSTALLLOCATION
INSTALLLOGATTRIBUTES
INSTALLLOGMODE
INSTALLMESSAGE
installpath
INSTALLPROPERTY
INSTALLSTARTMENUSHORTCUT
INSTALLSTATE
@ -1047,15 +1029,17 @@ ipc
ipcmanager
ipconfig
IPersist
IPin
IPlugin
IPower
ipp
IPreview
ipreviewhandler
ipreviewhandlertranslateaccelerator
ipreviewhandlervisualssetfont
IPrincipal
IProgram
IProgress
IProperty
IPublic
IQuery
IRead
@ -1074,9 +1058,9 @@ isetting
isfinite
IShell
ISingle
ISmart
ismethod
isocpp
issuecomment
IStorage
IStream
istreambuf
@ -1092,7 +1076,6 @@ ith
IThrottled
IThumbnail
ITrigger
itsme
IUI
IUnknown
IUri
@ -1109,7 +1092,6 @@ IZoom
JArray
jarro
Jarryd
javascript
jfif
jgeosdfsdsgmkedfgdfgdfgbkmhcgcflmi
jjw
@ -1118,9 +1100,9 @@ jp
jpe
jpeg
jpg
jsoref
JPN
json
JSONOf
jsonval
jsx
junja
@ -1265,6 +1247,7 @@ LVHT
LVIF
LVIS
LVN
LVS
LVSIL
LWA
lwin
@ -1273,6 +1256,7 @@ lzw
mailto
MAINICON
Mainwindow
majortype
makeappx
MAKEINTRESOURCE
MAKEINTRESOURCEW
@ -1284,6 +1268,7 @@ MAPPEDTOSAMEKEY
MAPTOSAMESHORTCUT
MAPVK
Markdig
MARQUEEPROGRESS
martinchrzan
martinmoene
MATCHALLOCCURENCES
@ -1291,6 +1276,7 @@ MATCHMODE
MAXIMIZEBOX
MAXSHORTCUTSIZE
maxversiontested
mayitbeegh
MBUTTON
MBUTTONDBLCLK
MBUTTONDOWN
@ -1299,6 +1285,8 @@ Mdb
MDICHILD
MDL
mdpreviewhandler
MEDIASUBTYPE
MEDIATYPE
Melman
memcpy
memset
@ -1306,7 +1294,6 @@ Mensching
menuitem
MENUITEMINFO
MENUITEMINFOW
menurc
messagebox
messageboxes
METACHARSET
@ -1326,6 +1313,7 @@ miniz
MINMAXINFO
Miracast
mixin
MJPG
mkdir
MLogo
MMI
@ -1360,7 +1348,7 @@ msclr
mscoree
mscorlib
msdata
msdn
MSDN
msedge
mshtmdid
msi
@ -1412,7 +1400,7 @@ NCMBUTTONDOWN
NCMBUTTONUP
NCMOUSELEAVE
NCMOUSEMOVE
ncol
NCol
NCPAINT
NCRBUTTONDBLCLK
NCRBUTTONDOWN
@ -1424,7 +1412,6 @@ NESW
netcore
netcoreapp
netframework
NETFX
netsh
netstandard
Neue
@ -1432,8 +1419,7 @@ newcolor
newitem
newpath
newrow
newtonsoft
nf
Newtonsoft
niels
nielslaute
NIF
@ -1494,7 +1480,6 @@ npmjs
npos
NResize
ntdll
NTFS
NTSTATUS
nuget
nullopt
@ -1525,9 +1510,7 @@ oldpath
oldtheme
oleaut
OLECHAR
oledb
oledbcommand
oledbconnection
OLEDB
OLIVEGREEN
OLogo
Onboarding
@ -1552,15 +1535,12 @@ ostringstream
OSVERSIONINFOEXW
osx
otating
ouicompat
OUTOFCONTEXT
OUTOFMEMORY
Outptr
outro
outsettings
OVERLAPPEDWINDOW
overlaywindow
owidctlpar
OWNDC
PACL
PAINTSTRUCT
@ -1577,7 +1557,6 @@ PARENTRELATIVEPARSING
parray
PARTIALCONFIRMATIONDIALOGTITLE
pathcch
pavelzw
pb
pbc
Pbgra
@ -1610,6 +1589,7 @@ phwnd
pici
pid
pidl
PINDIR
pinfo
pinvoke
Pipelinhttps
@ -1668,7 +1648,7 @@ PREMULTIPLIED
prevhost
previewer
PREVIEWGROUP
previewhandlerframeinfo
PREVIEWHANDLERFRAMEINFO
previewpane
PREVIOUSVERSIONSINSTALLED
prevpane
@ -1678,9 +1658,9 @@ PRINTCLIENT
printf
Printfax
prm
proactively
PROCESSKEY
PRODUCTVERSION
PROGDLG
Progman
programdata
PROGRAMFILES
@ -1689,6 +1669,7 @@ Proj
projectname
propkey
propvarutil
prpui
Prt
prui
prvpane
@ -1725,12 +1706,11 @@ qianlifeng
qit
QITAB
QITABENT
qryidx
Queryable
QUERYENDSESSION
queryfocus
QUERYOPEN
QUEUESYNC
QUICKLAYOUTSWITCH
qwertyuiopasdfghjklzxcvbnm
qword
qwrtyuiopsghjklzxvnm
@ -1756,6 +1736,7 @@ READWRITE
RECTDESTINATION
RECTL
rectp
rects
recyclebin
redirectedfrom
refactor
@ -1791,16 +1772,15 @@ rescap
resgen
resheader
Resizable
resizers
resmimetype
RESOURCEID
resourcemanager
RESTORESIZE
RESTORETOMAXIMIZED
restrictedcapabilities
resultlist
resw
resx
returnvalue
retval
rexit
rfind
@ -1812,26 +1792,25 @@ Rgn
rgs
rhs
ricardosantos
Riched
Richtext
RIGHTSCROLLBAR
riid
riverar
RKey
RMENU
RNumber
roadmap
Roboto
roslyn
royvou
rpc
RRF
rshift
RSHIFT
rshift
Rsp
rst
Rstrtmgr
RTB
RText
rtf
Rtl
RTLREADING
@ -1860,7 +1839,6 @@ SAMESHORTCUTPREVIOUSLYMAPPED
SAVEFAILED
scancode
scanled
Schd
Scn
SCOPEID
screenshot
@ -1872,15 +1850,12 @@ sdk
SDKDDK
searchbox
SEARCHFOR
searchqueryhelper
SEARCHREPLACEGROUP
searchterm
Secur
securityoverview
segoe
Segoe
Sekan
SENDCHANGE
sendinput
sendvirtualinput
serializationexception
serializer
@ -1892,7 +1867,6 @@ SETFOCUS
SETFOREGROUND
SETICON
setlocal
setnt
SETRANGE
Setrect
SETREDRAW
@ -1901,10 +1875,8 @@ SETTEXT
SETTINGCHANGE
settingsheader
settingshotkeycontrol
settingsui
settingsv
Setttings
setwindowpos
SETWORKAREA
sfgao
SFGAOF
@ -1937,18 +1909,15 @@ SHORTCUTSTARTWITHMODIFIER
Shortcuttool
shortdate
SHORTPATH
showcolorname
SHOWDEFAULT
SHOWELEVATIONPROMPT
SHOWMAXIMIZED
SHOWMINIMIZED
SHOWNA
SHOWNORMAL
showwindow
SHOWWINDOW
shtypes
sid
sideload
sideloading
sidepanel
siex
SIGABRT
@ -1979,7 +1948,7 @@ sln
SLogo
SMALLICON
SMTO
snd
Snd
somil
SORTDOWN
SOURCECLIENTAREAONLY
@ -1990,9 +1959,10 @@ spdth
spec'ing
spesi
spinbuttonref
splitee
splitwstring
spoprod
sppd
sppre
spsi
spsia
spsrif
@ -2024,7 +1994,7 @@ STARTUPINFOEX
STARTUPINFOW
startupscreen
STATEIMAGEMASK
statflag
STATFLAG
STATICEDGE
STATSTG
stdafx
@ -2054,6 +2024,7 @@ stringify
STRINGIZE
stringtable
stringval
Strmiids
strsafe
strutil
sttngs
@ -2091,10 +2062,9 @@ SYSCOLORCHANGE
SYSCOMMAND
SYSDEADCHAR
SYSICONINDEX
sysinfo
SYSKEY
syskeydown
syskeyup
SYSKEYUP
syslog
SYSMENU
systemd
@ -2126,7 +2096,6 @@ tcscpy
TCustom
td
TDevice
technet
Telemarketer
Templated
templatenamespace
@ -2141,7 +2110,6 @@ textblock
textbox
TEXTINCLUDE
textref
tf
TFVC
tga
thead
@ -2152,9 +2120,11 @@ thre
tif
TILEDWINDOW
Timeline
TIMERID
timeunion
timeutil
titlecase
TLayout
tlb
tlbimp
tmp
@ -2167,7 +2137,6 @@ toggleref
toggleright
toggleswitch
toolbar
Toolchain
toolset
tooltip
toolwindow
@ -2180,7 +2149,6 @@ towupper
tracelogging
traies
TRAYMOUSEMESSAGE
TRCA
TRK
trl
truetype
@ -2206,10 +2174,8 @@ Tz
UAC
UAL
uap
ubuntu
udit
UIA
uiauto
Uid
uifabric
uifabricicons
@ -2257,7 +2223,6 @@ unremapped
unsubscribe
Unsync
Untag
upd
Updatelayout
UPDOWNKEYDROPSLIST
UPGRADINGPRODUCTCODE
@ -2306,18 +2271,16 @@ Versioning
VFT
vh
vid
VIDEOINFOHEADER
viewbox
viewkind
viewmodel
virtualization
visiblecolorformats
Visibletrue
Visio
visualbrush
visualstudio
vk
VKey
VKTAB
vm
vmax
vmin
@ -2327,6 +2290,7 @@ VREDRAW
VSC
VSCBD
vscode
vsconfig
VSCROLL
vse
vsonline
@ -2355,11 +2319,10 @@ wcslen
wcsncmp
wcsnicmp
wdp
wds
wdupenv
weakme
webapp
Webcam
webcam
webclient
webkit
webp
@ -2379,7 +2342,6 @@ wikipedia
wil
wildcards
winapi
winauto
wincolor
windef
windevbuildagents
@ -2404,7 +2366,6 @@ Winhook
winkey
WINL
winmd
winmsg
winnt
winres
winrt
@ -2413,9 +2374,8 @@ winsdkver
winspool
winstore
winui
winuser
winver
winxamlmanager
wistd
withinrafael
Withscript
wix
@ -2450,7 +2410,6 @@ wprintf
wprp
wregex
WResize
wrl
wsf
wsh
wsl
@ -2461,7 +2420,6 @@ wstringstream
wsz
WTS
WTSAT
wtypes
wu
Wwan
www
@ -2472,7 +2430,6 @@ xaml
XAngle
XAttribute
xbf
XBind
XBUTTON
XBUTTONDBLCLK
XBUTTONDOWN
@ -2498,7 +2455,7 @@ XStr
XToolset
xunit
XY
yaml
Yaml
YAngle
YDiff
YESNO
@ -2507,7 +2464,10 @@ yinwang
YLogo
yml
YOffset
YourUserName
YStr
YUY
YUYV
yy
Zc
ZEROINIT

View File

@ -1,11 +1,25 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns
https?://(?:(?:www\.|)youtube\.com|youtu.be)/[-a-zA-Z0-9?&=]*
# GitHub SHAs
\bapi.github\.com/repos/[^/]+/[^/]+/[^/]+/[0-9a-f]+\b
://github\.(?:com|blog)/[^\w")]+
(?:\[[0-9a-f]+\]\(https:/|)/github\.com/[^/]+/[^/]+/[^/]+/[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b
# githubusercontent
://githubusercontent\.com/[^\w")]+
# gist github
/gist\.github\.com/[^/]+/[0-9a-f]+
# msdn
\b(?:download\.visualstudio|docs|msdn)\.microsoft\.com/[-_a-zA-Z0-9()=./]*
data:[a-zA-Z=;,/0-9+-]+
0x[0-9a-fA-F](?:\.[0-9a-fA-F]*|)[pP]
(?:0[Xx]|U\+|#)[a-f0-9A-FGgRr]{2,}[Uu]?[Ll]{0,2}\b
[{"][0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}"]
\b([A-Za-z])\1{3,}\b
# uuid:
[-<({"'>][0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[<'"})>]
# ignore long runs of a single character:
\b([A-Za-z])\g{-1}{3,}\b
(?:L"[abAB]+", ){3}L"[abAB]+"
"Lorem[^"]+?\."
TestCase\("[^"]+"
@ -45,3 +59,5 @@ TestCase\("[^"]+"
# marker for ignoring a comment to the end of the line
^.*/\* #no-spell-check-line \*/.*$
// #no-spell-check.*$
http://tes/

View File

@ -1,20 +1,24 @@
name: Spell checking
on:
pull_request_target:
push:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '15 * * * *'
jobs:
build:
name: Spell checking
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.0.0
- name: checkout-merge
if: "contains(github.event_name, 'pull_request')"
uses: actions/checkout@v2.0.0
with:
ref: refs/pull/${{github.event.pull_request.number}}/merge
fetch-depth: 5
- name: checkout
if: "!contains(github.event_name, 'pull_request')"
uses: actions/checkout@v2.0.0
with:
fetch-depth: 5
- uses: check-spelling/check-spelling@0.0.16-alpha
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
bucket: .github/actions
project: spell-check
- uses: check-spelling/check-spelling@0.0.17-alpha
with:
config: .github/actions/spell-check

2
.gitignore vendored
View File

@ -342,3 +342,5 @@ src/common/Telemetry/*.etl
!**/MergeModules/Release/
!**/MergeModules/Debug/
/src/modules/previewpane/SvgThumbnailProvider/$(SolutionDir)$(Platform)/$(Configuration)/modules/FileExplorerPreview/SvgThumbnailProvider.xml
/src/modules/powerrename/ui/RCa24464
/src/modules/powerrename/ui/RCb24464

View File

@ -7,4 +7,3 @@ set SolutionDir=%cd%
popd
SET IsPipeline=1
call msbuild ../tools/BugReportTool/BugReportTool.sln /p:Configuration=Release /p:Platform=x64 /p:CIBuild=true || exit /b 1

View File

@ -55,6 +55,25 @@ steps:
msbuildArgs: ${{ parameters.additionalBuildArguments }}
maximumCpuCount: true
- task: NuGetCommand@2
displayName: Restore NuGet packages for WebcamReportTool.sln
inputs:
command: restore
feedsToUse: config
configPath: NuGet.config
restoreSolution: tools\WebcamReportTool\WebcamReportTool.sln
restoreDirectory: '$(Build.SourcesDirectory)\tools\WebcamReportTool\packages'
- task: VSBuild@1
displayName: 'Build WebcamReportTool.sln'
inputs:
solution: '**\WebcamReportTool.sln'
vsVersion: 16.0
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArgs: ${{ parameters.additionalBuildArguments }}
maximumCpuCount: true
- task: NuGetCommand@2
displayName: Restore NuGet packages for PowerToysSetup.sln
inputs:
@ -93,40 +112,52 @@ steps:
msbuildArgs: ${{ parameters.additionalBuildArguments }}
maximumCpuCount: true
# directly not doing WinAppDriver testing
- task: VSTest@2
displayName: 'Run .Net Core Tests 1'
displayName: 'MS Tests'
inputs:
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\Microsoft.Plugin.Folder.UnitTest.dll
**\UnitTests-SvgThumbnailProvider.dll
**\Microsoft.PowerToys.Settings.UI.UnitTests.dll
**\UnitTests-SvgPreviewHandler.dll
**\UnitTests-PreviewHandlerCommon.dll
**\PreviewPaneUnitTests.dll
**\Microsoft.PowerToys.Run.Plugin.Registry.UnitTests.dll
**\UnitTest-ColorPickerUI.dll
**\Microsoft.Interop.Tests.dll
!**\obj\**
- task: VSTest@2
displayName: 'XUnit Tests'
inputs:
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\ImageResizer.Test.dll
!**\obj\**
- task: VSTest@2
displayName: 'NUnit Tests'
inputs:
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\Microsoft.Plugin.Folder.UnitTests.dll
**\Microsoft.Plugin.Program.UnitTests.dll
**\Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest.dll
**\Microsoft.Plugin.Uri.UnitTests.dll
**\Wox.Test.dll
**\Microsoft.PowerToys.Settings.UI.UnitTests.dll
**\UnitTest-ColorPickerUI.dll
**\Microsoft.Interop.Tests.dll
!**\obj\**
- task: VSTest@2
displayName: 'Run .Net Core Tests 2'
inputs:
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\PreviewPaneUnitTests.dll #this is the markdown tests
**\UnitTests-PreviewHandlerCommon.dll
**\UnitTests-SvgPreviewHandler.dll
**\ImageResizer.Test.dll
**\powerpreviewTest.dll
**\Microsoft.PowerToys.Run.Plugin.System.UnitTests.dll
!**\obj\**
# Native dlls
- task: VSTest@2
displayName: 'Run Native Tests'
displayName: 'Native Tests'
inputs:
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
@ -135,4 +166,5 @@ steps:
**\KeyboardManagerTest.dll
**\UnitTests-CommonLib.dll
**\PowerRenameUnitTests.dll
**\powerpreviewTest.dll
!**\obj\**

View File

@ -150,7 +150,6 @@ build:
- 'os-detection.dll'
- 'PowerToys.exe'
- 'PowerToysInterop.dll'
- 'PowerToysSettings.exe'
- 'Settings\Microsoft.PowerToys.Settings.UI.exe'
- 'Settings\Microsoft.PowerToys.Settings.UI.Lib.dll'
- 'Settings\PowerToys.Settings.dll'

15
.vsconfig Normal file
View File

@ -0,0 +1,15 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Component.CoreEditor",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.VisualStudio.Workload.NativeDesktop",
"Microsoft.VisualStudio.Workload.ManagedDesktop",
"Microsoft.VisualStudio.Workload.Universal",
"Microsoft.VisualStudio.Component.Windows10SDK.17134",
"Microsoft.VisualStudio.Component.Windows10SDK.18362",
"Microsoft.VisualStudio.ComponentGroup.UWP.VC",
"Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre",
"Microsoft.VisualStudio.Component.VC.ATL.Spectre"
]
}

File diff suppressed because it is too large Load Diff

View File

@ -24,8 +24,9 @@ Microsoft PowerToys is a set of utilities for power users to tune and streamline
### Requirements
- Windows 10 v1903 (build 18362) or better preferred, Windows 10 v1803 (build 17134) minimum.
- Have [.NET Core 3.1 Desktop Runtime](https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-desktop-3.1.11-windows-x64-installer). The installer should handle this but we want to directly make people aware.
- Windows 10 v1903 (build 18362) or newer preferred, Windows 10 v1803 (build 17134) minimum.
- ⚠️ PowerToys minimum version of Windows 10 will be increased to v1903 starting with the 0.37 release
- Have [.NET Core 3.1.13 Desktop Runtime](https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-desktop-3.1.13-windows-x64-installer). The installer should handle this but we want to directly make people aware.
### Via GitHub with EXE [Recommended]
@ -41,7 +42,7 @@ To install the Video Conference mute, please use the [v0.28 pre-release experime
We hope to have an updated version in February 2021 with the new DirectShow driver.
### Via WinGet (Preview)
Download PowerToys from [WinGet](https://github.com/microsoft/winget-cli/releases). To install PowerToys, run the following command from the command line / PowerShell:
Download PowerToys from [WinGet](https://github.com/microsoft/winget-cli#installing-the-client). To install PowerToys, run the following command from the command line / PowerShell:
```powershell
WinGet install powertoys
@ -75,65 +76,71 @@ For guidance on developing for PowerToys, please read the [developer docs](/doc/
Our [prioritized roadmap][roadmap] of features and utilities that the core team is focusing on.
### 0.33 - February 2021 Update
### 0.35 - March 2021 Update
Our goals for [v0.33 release cycle][github-release-link] was to add in some critical new functionality into the new user experience as well as a plug-in manager for PowerToys Run. In addition, we feel we are near ready to add in Video Conference mute into the stable release pending feedback from the pending 0.34 experimental release. The 0.34 experimental release will happen week of March 8th toward the end of the week pending testing.
Our goals for the [v0.35 release cycle][github-release-link] were to add in new functionality to support quick swapping layouts for FancyZones, wrap up work for the DirectShow migration for Video Conference Mute so we can migrate into the main dev branch as well as fixing bugs. The 0.36 experimental release will happen the week of April 5th toward the end of the week pending testing. Throughout these efforts, we continue working towards stability across all PowerToys utilities.
Our [prioritized roadmap][roadmap] of features and utilities that the core team is focusing on for the near future. We fixed a lot of localization issues from our initial release but we may not still be perfect. If you find an issue, please file a [localization bug][loc-bug].
Our [prioritized roadmap][roadmap] of features and utilities will dictate what the core team is focusing on for the near future.
#### Highlights from v0.33 Stable/0.34 Experimental
#### Highlights from v0.35 Stable/0.36 Experimental
**General**
- Updated overview links to be language agnostic to the docs site.
- 'First time load' experience. The hope is a quick, light way to learn about basic functionality. We have some more work to do and want to also use the same framework for teaching about updates as well.
- PowerToys will start requiring Windows 10 v1903 or greater after 0.35.x release. The v1 settings, which supports older Windows versions, will be removed in 0.37.
- Note: We may be able to bring back support when we migrate to WinUI3 but as of now, we will be increasing the minimum version of Windows to 1903 or greater.
- Localization corrections
- Improved GitHub report bug template.
- Increased .NET Core to 3.1.13
- Fixed installer 'run as user' regression
**Color Picker**
- UX adjustments to editor. Thanks [@niels9001](https://github.com/niels9001)!
- `Esc` can now be used to exit the editor. Thanks [@BenConstable9](https://github.com/BenConstable9)!
**FancyZones**
- Adjusted editor UX based on feedback. Thanks [@niels9001](https://github.com/niels9001)!
- New options to change zone activation algorithm.
**File Explorer**
- Improved how SVG images are previewed in the preview pane, thanks[@Drakula44](https://github.com/Drakula44)!
- [@Aaron-Junker](Aaron-Junker) has created a proof of concept for using [Monaco editor](https://github.com/microsoft/monaco-editor) for previewing dev files. This will enable over 125+ file types.
- Added hotkeys and quick swap functionality for custom layouts! Users can now assign a hotkey in the editor and use it to quickly set a desktop's zones with `Ctrl + Win + Alt + NUMBER` key binding, or by pressing the hotkey while dragging a window.
- UX updates. Thanks [@niels9001](https://github.com/niels9001)!
- Fixed zone placement algorithm for when the Taskbar is vertical
- Bug fixes
**PowerToys Run**
- Plugin Manager now is in settings. You can directly turn on / off, include items in general search, and change the action key! Thanks [@htcfreek](https://github.com/htcfreek) for the great feedback!
- Improved support for additional window managers by abstracting out shell process calls. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Fix for PT Run registering the hotkey on non-supported OS versions.
- `~` will now act as the user home directory in Folder plugin. Thanks [@davidegiacometti](https://github.com/davidegiacometti)
- Service plugin has adjusted status messages
- Users can specify where to show the launcher window. Thanks [@addrum](https://github.com/addrum)!
- New plugin added to support opening previously used Visual Studio Code workspaces, remote machines (SSH or Codespaces), and containers! When enabled, use `{` to query for available workspaces. Thanks [@ricardosantos9521](https://github.com/ricardosantos9521)! Please note, this plugin is off by default.
- Shell history now saves the raw command instead of the resolved command. A command like `%appdata%` would now save in the Shell history as is instead of `C:\Users\YourUserName\AppData\Roaming`. Thanks [@mayitbeegh](https://github.com/mayitbeegh)!
- Better logging to try to track down some bugs
- Bug fixes
**Video Conference Mute (Experimental)**
- Adjust video muting to leverage DirectShow.
- Goal is to have 0.34 experimental release week of March 8th.
- Tracking work remaining at issue [#7944](https://github.com/microsoft/PowerToys/issues/7944)
- Goal is to have 0.36 experimental release week of April 5th (Yes, we've stated this before, we know)
**Settings**
- When restarting as admin, the settings now will reopen. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
**ARM64 Progress**
- Investigation on how we'll accomplish Settings with the XAML Island and WPF app.
**Contributor workflow**
- Main project now has a vsconfig which will prompt you to install needed items versus having to use a script. This will aid in keeping you up-to-date when something changes.
- Updated spell checker. Thanks [@jsoref](https://github.com/jsoref)!
#### Community contributions
We'd like to directly mention (in alphabetical order) for their continued community support this month and helping directly make PowerToys a better piece of software.
[@Aaron-Junker](https://github.com/Aaron-Junker),
[@davidegiacometti](https://github.com/davidegiacometti),
[@Drakula44](https://github.com/Drakula44),
[@htcfreek](https://github.com/htcfreek),
[@Jay-o-Way](https://github.com/Jay-o-Way),
[@addrum](https://github.com/addrum),
[@BenConstable9](https://github.com/BenConstable9),
[@htcfreek](https://github.com/htcfreek),
[@Jay-o-Way](https://github.com/Jay-o-Way),
[@jsoref](https://github.com/jsoref),
[@mayitbeegh](https://github.com/mayitbeegh),
[@niels9001](https://github.com/niels9001),
and
[@notDevagya](https://github.com/notDevagya)
[@pc-v2](https://github.com/pc-v2),
and
[@ricardosantos9521](https://github.com/ricardosantos9521)
#### What is being planned for v0.35 - March 2021
#### What is being planned for v0.37 - April 2021
For [v0.35][github-next-release-work], we are planning to work on:
For [v0.37][github-next-release-work], we are planning to work on:
- Stability and bug fixes
- FZ Editor hotkey layout swap support
- Integrating VCM in main release
- Start process for removal support for old settings system and migrating our minimum OS version to Windows 10 1903.
- Adding VCM to the stable release
- Removing v1 Settings / PT minimum version will become Windows 10 v1903
- Post-update guidance prompt work
## PowerToys Community
@ -158,5 +165,5 @@ The application logs basic telemetry. Our Telemetry Data page (Coming Soon) has
[usingPowerToys-docs-link]: https://docs.microsoft.com/windows/powertoys/
<!-- items that need to be updated release to release -->
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aopen+is%3Aissue+project%3Amicrosoft%2FPowerToys%2F18
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aopen+is%3Aissue+project%3Amicrosoft%2FPowerToys%2F19
[github-prerelease-link]: https://github.com/microsoft/PowerToys/releases/tag/v0.28.0

View File

@ -64,28 +64,7 @@ Various tools used by PowerToys. Includes the Visual Studio 2019 project templat
1. Windows 10 April 2018 Update (version 1803) or newer
2. Visual Studio Community/Professional/Enterprise 2019
3. Run the command below in cmd/terminal to install all the workloads and components for VS.
```shell
cd "%ProgramFiles(x86)%\Microsoft Visual Studio\2019"
SET targetFolder="\"
IF EXIST Preview\NUL (SET targetFolder=Preview)
IF EXIST Enterprise\NUL (SET targetFolder=Enterprise)
IF EXIST Professional\NUL (SET targetFolder=Professional)
IF EXIST Community\NUL (SET targetFolder=Community)
ECHO %targetFolder%
"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vs_installer.exe" ^
modify --installpath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\%targetFolder%" ^
--add Microsoft.VisualStudio.Workload.NativeDesktop ^
--add Microsoft.VisualStudio.Workload.ManagedDesktop ^
--add Microsoft.VisualStudio.Workload.Universal ^
--add Microsoft.VisualStudio.Component.Windows10SDK.17134 ^
--add Microsoft.VisualStudio.ComponentGroup.UWP.VC ^
--add Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre ^
--add Microsoft.VisualStudio.Component.VC.ATL.Spectre
```
3. Once you've cloned and started the `PowerToys.sln`, in the solution explorer, if you see a dialog that says `install extra components`, click `install`
### Compile source code
@ -101,25 +80,37 @@ Our installer is two parts, an EXE and an MSI. The EXE (Bootstrapper) contains
The installer can only be compiled in `Release` mode, step 1 and 2 must be done before the MSI will be able to be compiled.
1. Compile PowerToys.sln. Instructions are listed above.
2. Compile Bug reporting tool. Path from root: `tools\BugReportTool\BugReportTool.sln` (details listed below)
3. Compile PowerToysSetup.sln Path from root: `installer\PowerToysSetup.sln` (details listed below)
1. Compile `PowerToys.sln`. Instructions are listed above.
2. Compile `BugReportTool.sln` tool. Path from root: `tools\BugReportTool\BugReportTool.sln` (details listed below)
3. Compile `PowerToysSetup.sln` Path from root: `installer\PowerToysSetup.sln` (details listed below)
4. Compile `PowerToysBootstrapper.sln` Path from root: `installer\PowerToysBootstrapper\PowerToysBootstrapper.sln` (details listed below)
### Prerequisites for building the MSI installer
1. Build `tools\BugReportTool\BugReportTool.sln`: in Visual Studio, in the `Solutions Configuration` drop-down menu select `Release`, from the `Build` menu choose `Build Solution`.
2. Install the [WiX Toolset Visual Studio 2019 Extension](https://marketplace.visualstudio.com/items?itemName=RobMensching.WiXToolset).
3. Install the [WiX Toolset build tools](https://wixtoolset.org/releases/).
1. Install the [WiX Toolset Visual Studio 2019 Extension](https://marketplace.visualstudio.com/items?itemName=RobMensching.WiXToolset).
2. Install the [WiX Toolset build tools](https://wixtoolset.org/releases/).
### Locally compiling the Bug reporting tool
1. Open `tools\BugReportTool\BugReportTool.sln`
1. In Visual Studio, in the `Solutions Configuration` drop-down menu select `Release`
2. From the `Build` menu, choose `Build Solution`.
### Locally compiling the .MSI installer
- Open `installer\PowerToysSetup.sln`: in Visual Studio, in the `Solutions Configuration` drop-down menu select `Release`, from the `Build` menu choose `Build Solution`.
- The resulting `PowerToysSetup.msi` installer will be available in the `installer\PowerToysSetup\x64\Release\` folder.
1. Open `installer\PowerToysSetup.sln`
2. In Visual Studio, in the `Solutions Configuration` drop-down menu select `Release`
3. From the `Build` menu choose `Build Solution`.
The resulting `PowerToysSetup.msi` installer will be available in the `installer\PowerToysSetup\x64\Release\` folder.
### Locally compiling the .EXE Bootstrapper installer
- Open `installer\PowerToysBootstrapper\PowerToysBootstrapper.sln`: in Visual Studio, in the `Solutions Configuration` drop-down menu select `Release`, from the `Build` menu choose `Build Solution`.
- The `PowerToysSetup-0.0.1-x64.exe` binary is created in the `installer\PowerToysBootstrapper\x64\Release\` folder.
1. Open `installer\PowerToysBootstrapper\PowerToysBootstrapper.sln`
2. In Visual Studio, in the `Solutions Configuration` drop-down menu select `Release`
3. From the `Build` menu choose `Build Solution`.
The `PowerToysSetup-0.0.1-x64.exe` binary is created in the `installer\PowerToysBootstrapper\x64\Release\` folder.
#### Supported arguments for the .EXE Bootstrapper installer

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

View File

@ -158,4 +158,7 @@
<data name="NEWER_VERSION_ERROR" xml:space="preserve">
<value>A newer version is already installed.</value>
</data>
<data name="OLD_WINDOWS_ERROR" xml:space="preserve">
<value>PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.</value>
</data>
</root>

View File

@ -12,6 +12,7 @@
#include <common/utils/resources.h>
#include <common/utils/window.h>
#include <common/utils/winapi_error.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <runner/action_runner_utils.h>
@ -79,6 +80,27 @@ void SetupLogger(fs::path directory, const spdlog::level::level_enum severity)
}
}
void CleanupSettingsFromOlderVersions()
{
try
{
const auto logSettingsFile = fs::path{ PTSettingsHelper::get_root_save_folder_location() } / PTSettingsHelper::log_settings_filename;
if (fs::is_regular_file(logSettingsFile))
{
fs::remove(logSettingsFile);
spdlog::info("Removed old log settings file");
}
else
{
spdlog::info("Old log settings file wasn't found");
}
}
catch(...)
{
spdlog::error("Failed to cleanup old log settings");
}
}
void ShowMessageBoxError(const wchar_t* message)
{
if (!g_Silent)
@ -152,8 +174,6 @@ int Bootstrapper(HINSTANCE hInstance)
const auto installDirArg = cmdArgs["install_dir"].as<std::string>();
const bool extract_msi_only = cmdArgs["extract_msi"].as<bool>();
spdlog::level::level_enum severity = spdlog::level::off;
std::wstring installFolderProp;
if (!installDirArg.empty())
{
@ -185,6 +205,7 @@ int Bootstrapper(HINSTANCE hInstance)
{
}
spdlog::level::level_enum severity = spdlog::level::off;
if (logLevel == "debug")
{
severity = spdlog::level::debug;
@ -197,6 +218,16 @@ int Bootstrapper(HINSTANCE hInstance)
SetupLogger(logDir, severity);
spdlog::debug("PowerToys Bootstrapper is launched\nnoFullUI: {}\nsilent: {}\nno_start_pt: {}\nskip_dotnet_install: {}\nlog_level: {}\ninstall_dir: {}\nextract_msi: {}\n", noFullUI, g_Silent, noStartPT, skipDotnetInstall, logLevel, installDirArg, extract_msi_only);
const VersionHelper myVersion(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);
// Do not support installing on Windows < 1903
if (myVersion >= VersionHelper{0, 36, 0} && updating::is_old_windows_version())
{
ShowMessageBoxError(IDS_OLD_WINDOWS_ERROR);
spdlog::error("PowerToys {} requires at least Windows 1903 to run.", myVersion.toString());
return 1;
}
// If a user requested an MSI -> extract it and exit
if (extract_msi_only)
{
@ -212,7 +243,6 @@ int Bootstrapper(HINSTANCE hInstance)
}
// Check if there's a newer version installed
const VersionHelper myVersion(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);
const auto installedVersion = updating::get_installed_powertoys_version();
if (installedVersion && *installedVersion >= myVersion)
{
@ -371,6 +401,8 @@ int Bootstrapper(HINSTANCE hInstance)
spdlog::error("Unknown exception during dotnet installation");
ShowMessageBoxError(IDS_DOTNET_INSTALL_ERROR);
}
CleanupSettingsFromOlderVersions();
// At this point, there's no reason to show progress bar window, since MSI installers have their own
CloseProgressBarDialog();

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Aby se sada PowerToys dala spustit, vyžaduje Windows 10 verze 1903 (aktualizace z května 2019) nebo novější.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[PowerToys erfordert zur Ausführung Windows 10, Version 1903 (May 2019 Update) oder höher.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[PowerToys requiere Windows 10 versión 1903 (actualización de mayo de 2019) o posterior para ejecutarse.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[PowerToys nécessite Windows 10 version 1903 (mise à jour de mai 2019) ou plus récent pour s'exécuter.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[A PowerToys futtatásához a Windows 10 legalább 1903-as verziója (2019. májusi frissítés) szükséges.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[PowerToys richiede Windows 10 versione 1903 (aggiornamento di maggio 2019) o versione successiva.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Powertoy を実行するには、Windows 10 バージョン 1903 (2019 年 5 月の更新プログラム) 以降が必要です。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[PowerToys를 사용하려면 Windows 10 버전 1903(2019년 5월 업데이트) 이상을 실행해야 합니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Windows 10 versie 1903 (update van mei 2019) of nieuwer is vereist om PowerToys te kunnen uitvoeren.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Program PowerToys wymaga do działania systemu Windows 10 w wersji 1903 (aktualizacja z maja 2019 r.) lub nowszej.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Os PowerToys exigem o Windows 10 versão 1903 (Atualização de maio de 2019) ou mais recente para serem executados.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[O PowerToys requer a versão 1903 do Windows 10 (Atualização de maio de 2019) ou mais recente para ser executado.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Для запуска PowerToys требуется Windows 10 версии 1903 (обновление за май 2019 года) или более поздней.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[PowerToys kräver Windows 10 version 1903 (uppdateringen från maj 2019) eller senare för att köras.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[PowerToys'un çalışabilmesi için Windows 10 sürüm 1903 (Mayıs 2019 Güncelleştirmesi) veya daha yeni bir sürümü gereklidir.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[PowerToys 需要 Windows 10 版本 1903 (2019 年 5 月更新)或更高版本才能运行。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -283,6 +283,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";OLD_WINDOWS_ERROR" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[PowerToys 需要 Windows 10 1903 版 (2019 年 5 月更新) 或更新版本才能執行。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";SNOOZE_BUTTON" ItemType="0;.resx" PsrId="211" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Snooze]]></Val>

View File

@ -103,7 +103,6 @@
<CustomAction
Id="TerminateProcesses"
Return="ignore"
Impersonate="no"
Execute="immediate"
BinaryKey="PTCustomActions"
DllEntry="TerminateProcessesCA" />
@ -282,13 +281,12 @@
<Directory Id="SettingsV2XamlAssetsInstallFolder" Name="Assets" />
</Directory>
</Directory>
<Directory Id="SettingsHtmlInstallFolder" Name="settings-html">
<Directory Id="SettingsHtmlDistInstallFolder" Name="dist"/>
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder"/>
<Directory Id="DesktopFolder" Name="Desktop"/>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="PowerToys (Preview)"/>
</Directory>
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
</Fragment>
@ -302,20 +300,7 @@
</RegistryKey>
</Component>
<Component Id="powertoys_exe" Guid="A2C66D91-3485-4D00-B04D-91844E6B345B" Win64="yes">
<File Id="PowerToys.exe" KeyPath="yes" Checksum="yes">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="PowerToys (Preview)"
Description="PowerToys - Windows system utilities to maximize productivity"
Directory="ProgramMenuFolder"
Icon="powertoys.exe"
IconIndex="0"
Advertise="yes">
<ShortcutProperty Key="System.AppUserModel.ID" Value="Microsoft.PowerToysWin32"/>
<!-- ToastActivatorCLSID is used only by toast background activation, which currently isn't used, but causes MSI warning 1946 to display for a small share of users -->
<!-- <ShortcutProperty Key="System.AppUserModel.ToastActivatorCLSID" Value="{DD5CACDA-7C2E-4997-A62A-04A597B58F76}"/> -->
</Shortcut>
</File>
<File Id="PowerToys.exe" KeyPath="yes" Checksum="yes" />
<RegistryKey Root="HKCR" Key="powertoys">
<RegistryValue Type="string" Name="URL Protocol" Value=""/>
<RegistryValue Type="string" Value="URL:PowerToys custom internal URI protocol"/>
@ -326,13 +311,6 @@
<RegistryValue Type="string" Value="&quot;[INSTALLFOLDER]PowerToys.exe&quot; &quot;%1&quot;" />
</RegistryKey>
</RegistryKey>
</Component>
<Component Id="settings_exe" Guid="A5A461A9-7097-4CBA-9D39-3DBBB6B7B80C" Win64="yes">
<File Id="PowerToysSettings.exe" KeyPath="yes" Checksum="yes" />
</Component>
<Component Id="BackgroundActivator_dll" Guid="23B25EE4-BCA2-45DF-BBCD-82FBDF01C5AB" Win64="yes">
<File Id="BackgroundActivatorDLL.dll" KeyPath="yes" Checksum="yes" />
@ -356,6 +334,24 @@
<?endforeach?>
</Component>
</DirectoryRef>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="PowerToysStartMenuShortcut" Guid="336AB4F9-078C-4DCA-B69F-3808A9FFD758">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="PowerToys (Preview)"
Description="PowerToys - Windows system utilities to maximize productivity"
Icon="powertoys.exe"
IconIndex="0"
Target="[!PowerToys.exe]"
WorkingDirectory="INSTALLFOLDER">
<ShortcutProperty Key="System.AppUserModel.ID" Value="Microsoft.PowerToysWin32"/>
</Shortcut>
<RemoveFolder Id="CleanUpStartMenuShortCut" Directory="ApplicationProgramsFolder" On="uninstall"/>
<!-- ApplicationStartMenuShortcut is implicitly installed in HKCU, so WIX won't allow changing this reg value to HKLM. -->
<RegistryValue Root="HKCU" Key="Software\Microsoft\PowerToys" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="SvgsInstallFolder" FileSource="$(var.BinX64Dir)svgs\">
<Component Id="PowerToysSvgs" Guid="7C4D4EED-9338-423D-992C-DCE02F3E2D35" Win64="yes">
<File Source="$(var.BinX64Dir)svgs\0.svg" />
@ -378,6 +374,7 @@
<File Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\fancyzones.dll" KeyPath="yes" />
<File Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\FancyZonesEditor.dll" />
<File Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\FancyZonesEditor.runtimeconfig.json" />
<File Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\FancyZonesEditor.deps.json" />
<File Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\FancyZonesEditor.exe" />
<File Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\ControlzEx.dll" />
<File Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\Microsoft.Xaml.Behaviors.dll" />
@ -740,23 +737,10 @@
</Component>
</DirectoryRef>
<DirectoryRef Id="SettingsHtmlInstallFolder" FileSource="$(var.RepoDir)\settings\settings-html\">
<Component Id="settings_html" Guid="87881A99-E917-4B0D-B1D8-5C6EB9709F96" Win64="yes">
<File Source="$(var.RepoDir)\src\settings\settings-html\index.html" KeyPath="yes" />
</Component>
<Component Id="settings_dark_html" Guid="855866C7-2F13-4B08-B5C1-B507354C2760" Win64="yes">
<File Source="$(var.RepoDir)\src\settings\settings-html\index-dark.html" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="SettingsHtmlDistInstallFolder" FileSource="$(var.RepoDir)\settings\settings-html\dist\">
<Component Id="settings_js_bundle" Guid="9EF539C1-2F50-421E-B074-C58ED3A9785C" Win64="yes">
<File Source="$(var.RepoDir)\src\settings\settings-html\dist\bundle.js" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcut" Guid="87321F2B-CC48-4326-881E-9C62CC260DC8">
<Condition>INSTALLDESKTOPSHORTCUT</Condition>
<!-- DesktopShortcutId is implicitly installed in HKCU, so WIX won't allow changing this reg value to HKLM. -->
<RegistryValue Root="HKCU"
Key="Software\[Manufacturer]\[ProductName]"
Name="desktopshorcutinstalled"
@ -777,6 +761,7 @@
<Fragment>
<ComponentGroup Id="CoreComponents" Directory="INSTALLFOLDER">
<ComponentRef Id="powertoys_exe" />
<ComponentRef Id="PowerToysStartMenuShortcut"/>
<ComponentRef Id="BackgroundActivator_dll" />
<ComponentRef Id="action_runner_exe" />
<ComponentRef Id="powertoys_toast_clsid" />
@ -806,10 +791,6 @@
<ComponentRef Id="SettingsV2Styles" />
<ComponentRef Id="SettingsV2Views" />
<ComponentRef Id="SettingsV2XamlAssets" />
<ComponentRef Id="settings_exe" />
<ComponentRef Id="settings_html" />
<ComponentRef Id="settings_dark_html" />
<ComponentRef Id="settings_js_bundle" />
</ComponentGroup>
<ComponentGroup Id="ToolComponents" Directory="ToolsFolder">
<ComponentRef Id="BugReportTool_exe" />
@ -917,15 +898,15 @@
</Fragment>
<Fragment>
<ComponentGroup Id="LauncherComponents">
<Component Id="launcherInstallComponent" Directory="LauncherInstallFolder" Guid="5E688DB4-C522-4268-BA54-ED1CDFFE9DB6">
<Component Id="launcherShortcutComponent" Directory="LauncherInstallFolder" Guid="8824006B-CD06-4D87-8AC4-1B40C71DB4D7">
<!-- Toast Notification AUMID -->
<RegistryKey Root="HKCU" Key="SOFTWARE\Classes\AppUserModelId\PowerToysRun">
<RegistryKey Root="HKLM" Key="SOFTWARE\Classes\AppUserModelId\PowerToysRun">
<RegistryValue Type="string" Name="DisplayName" Value="PowerToys Run" />
<RegistryValue Type="string" Name="IconUri" Value="[LauncherImagesFolder]RunAsset.ico" />
</RegistryKey>
</Component>
<Component Id="launcherInstallComponent" Directory="LauncherInstallFolder" Guid="5E688DB4-C522-4268-BA54-ED1CDFFE9DB6">
<File Source="$(var.BinX64Dir)modules\Launcher\Microsoft.Launcher.dll" />
<?foreach File in concrt140_app.dll;ICSharpCode.SharpZipLib.dll;JetBrains.Annotations.dll;Mages.Core.dll;Microsoft.Search.Interop.dll;Mono.Cecil.dll;Mono.Cecil.Mdb.dll;Mono.Cecil.Pdb.dll;Mono.Cecil.Rocks.dll;msvcp140_1_app.dll;msvcp140_2_app.dll;msvcp140_app.dll;Newtonsoft.Json.dll;NLog.dll;NLog.Extensions.Logging.dll;PowerLauncher.deps.json;PowerLauncher.dll;PowerLauncher.exe;Microsoft.Xaml.Behaviors.dll;System.Text.Json.dll;PowerLauncher.runtimeconfig.json;System.Data.OleDb.dll;vcamp140_app.dll;vccorlib140_app.dll;vcomp140_app.dll;vcruntime140_1_app.dll;vcruntime140_app.dll;Wox.Infrastructure.dll;Wox.Plugin.dll;PowerToysInterop.dll;ManagedTelemetry.dll;PowerLauncher.Telemetry.dll;Microsoft.Extensions.Configuration.Abstractions.dll;Microsoft.Extensions.Configuration.Binder.dll;Microsoft.Extensions.Configuration.dll;Microsoft.Extensions.DependencyInjection.Abstractions.dll;Microsoft.Extensions.DependencyInjection.dll;Microsoft.Extensions.Logging.Abstractions.dll;Microsoft.Extensions.Logging.dll;Microsoft.Extensions.Options.dll;Microsoft.Extensions.Primitives.dll;ControlzEx.dll;ManagedCommon.dll;System.IO.Abstractions.dll;Microsoft.PowerToys.Common.UI.dll;System.ServiceProcess.ServiceController.dll;Microsoft.Toolkit.Uwp.Notifications.dll;ModernWpf.Controls.dll;ModernWpf.dll?>
<File Id="File_$(var.File)" Source="$(var.BinX64Dir)modules\launcher\$(var.File)" />

View File

@ -3,6 +3,7 @@
#include <ProjectTelemetry.h>
#include "../../src/common/updating/installer.h"
#include "../../src/common/version/version.h"
using namespace std;
@ -416,6 +417,7 @@ UINT __stdcall TelemetryLogInstallSuccessCA(MSIHANDLE hInstall)
TraceLoggingWrite(
g_hProvider,
"Install_Success",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
@ -436,6 +438,7 @@ UINT __stdcall TelemetryLogInstallCancelCA(MSIHANDLE hInstall)
TraceLoggingWrite(
g_hProvider,
"Install_Cancel",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
@ -456,6 +459,7 @@ UINT __stdcall TelemetryLogInstallFailCA(MSIHANDLE hInstall)
TraceLoggingWrite(
g_hProvider,
"Install_Fail",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
@ -476,6 +480,7 @@ UINT __stdcall TelemetryLogUninstallSuccessCA(MSIHANDLE hInstall)
TraceLoggingWrite(
g_hProvider,
"UnInstall_Success",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
@ -496,6 +501,7 @@ UINT __stdcall TelemetryLogUninstallCancelCA(MSIHANDLE hInstall)
TraceLoggingWrite(
g_hProvider,
"UnInstall_Cancel",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
@ -516,6 +522,7 @@ UINT __stdcall TelemetryLogUninstallFailCA(MSIHANDLE hInstall)
TraceLoggingWrite(
g_hProvider,
"UnInstall_Fail",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
@ -536,6 +543,7 @@ UINT __stdcall TelemetryLogRepairCancelCA(MSIHANDLE hInstall)
TraceLoggingWrite(
g_hProvider,
"Repair_Cancel",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
@ -556,6 +564,7 @@ UINT __stdcall TelemetryLogRepairFailCA(MSIHANDLE hInstall)
TraceLoggingWrite(
g_hProvider,
"Repair_Fail",
TraceLoggingWideString(get_product_version().c_str(), "Version"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));

View File

@ -48,6 +48,7 @@
<LinkIncremental>false</LinkIncremental>
<OutDir>$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)$(ProjectName)\$(Platform)\$(Configuration)\obj\</IntDir>
<IncludePath>..\..\src\common\Telemetry;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>

View File

@ -1,6 +0,0 @@
#pragma once
#include <TraceLoggingProvider.h>
#include <TraceLoggingDefines.h>
TRACELOGGING_DECLARE_PROVIDER(g_hProvider);

View File

@ -1,6 +0,0 @@
#pragma once
#define TraceLoggingOptionProjectTelemetry() TraceLoggingOptionGroup(0x42749043, 0x438c, 0x46a2, 0x82, 0xbe, 0xc6, 0xcb, 0xeb, 0x19, 0x2f, 0xf2)
#define ProjectTelemetryPrivacyDataTag(tag) TraceLoggingUInt64((tag), "Ignore")
#define ProjectTelemetryTag_ProductAndServicePerformance 0x0u
#define PROJECT_KEYWORD_MEASURE 0x0

View File

@ -0,0 +1,13 @@
// 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 StartupPosition
{
Cursor,
PrimaryMonitor,
Focus,
}
}

View File

@ -16,6 +16,8 @@ namespace Microsoft.PowerToys.Telemetry.Events
{
public bool UTCReplace_AppSessionGuid => true;
public string EventName { get; set; }
private string _version;
public string Version

View File

@ -37,7 +37,7 @@ namespace Microsoft.PowerToys.Telemetry
where T : EventBase, IEvent
{
this.Write<T>(
null,
telemetryEvent.EventName,
new EventSourceOptions()
{
Keywords = ProjectKeywordMeasure,

View File

@ -4,7 +4,6 @@
namespace PTSettingsHelper
{
constexpr inline const wchar_t* settings_filename = L"\\settings.json";
constexpr inline const wchar_t* log_settings_filename = L"log_settings.json";
constexpr inline const wchar_t* oobe_filename = L"oobe_settings.json";
std::wstring get_root_save_folder_location()

View File

@ -6,6 +6,8 @@
namespace PTSettingsHelper
{
constexpr inline const wchar_t* log_settings_filename = L"log_settings.json";
std::wstring get_module_save_folder_location(std::wstring_view powertoy_name);
std::wstring get_root_save_folder_location();

View File

@ -52,10 +52,13 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>

View File

@ -135,10 +135,24 @@ public
public:
literal int VK_WIN_BOTH = CommonSharedConstants::VK_WIN_BOTH;
static String ^ AppDataPath() {
auto localPath = Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData);
auto powerToysPath = gcnew String(CommonSharedConstants::APPDATA_PATH);
return System::IO::Path::Combine(localPath, powerToysPath);
}
static String ^ PowerLauncherSharedEvent() {
return gcnew String(CommonSharedConstants::POWER_LAUNCHER_SHARED_EVENT);
}
static String ^ RunSendSettingsTelemetryEvent() {
return gcnew String(CommonSharedConstants::RUN_SEND_SETTINGS_TELEMETRY_EVENT);
}
static String ^ ColorPickerSendSettingsTelemetryEvent() {
return gcnew String(CommonSharedConstants::COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT);
}
static String ^ ShowColorPickerSharedEvent() {
return gcnew String(CommonSharedConstants::SHOW_COLOR_PICKER_SHARED_EVENT);
}

View File

@ -10,9 +10,15 @@ namespace CommonSharedConstants
// Fake key code to represent VK_WIN.
inline const int VK_WIN_BOTH = 0x104;
const wchar_t APPDATA_PATH[] = L"Microsoft\\PowerToys";
// Path to the event used by PowerLauncher
const wchar_t POWER_LAUNCHER_SHARED_EVENT[] = L"Local\\PowerToysRunInvokeEvent-30f26ad7-d36d-4c0e-ab02-68bb5ff3c4ab";
const wchar_t RUN_SEND_SETTINGS_TELEMETRY_EVENT[] = L"Local\\PowerToysRunInvokeEvent-638ec522-0018-4b96-837d-6bd88e06f0d6";
const wchar_t COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT[] = L"Local\\ColorPickerSettingsTelemetryEvent-6c7071d8-4014-46ec-b687-913bd8a422f1";
// Path to the event used to show Color Picker
const wchar_t SHOW_COLOR_PICKER_SHARED_EVENT[] = L"Local\\ShowColorPickerEvent-8c46be2a-3e05-4186-b56b-4ae986ef2525";

View File

@ -38,7 +38,7 @@ level_enum getLogLevel(std::wstring_view logSettingsPath)
return result;
}
std::shared_ptr<spdlog::logger> Logger::logger;
std::shared_ptr<spdlog::logger> Logger::logger = spdlog::null_logger_mt("null");
bool Logger::wasLogFailedShown()
{

View File

@ -4,16 +4,18 @@
struct LogSettings
{
// The following strings are not localizable
inline const static std::wstring defaultLogLevel = L"warn";
inline const static std::wstring defaultLogLevel = L"trace";
inline const static std::wstring logLevelOption = L"logLevel";
inline const static std::string runnerLoggerName = "runner";
inline const static std::wstring logPath = L"Logs\\";
inline const static std::wstring runnerLogPath = L"RunnerLogs\\runner-log.txt";
inline const static std::string actionRunnerLoggerName = "action-runner";
inline const static std::wstring actionRunnerLogPath = L"RunnerLogs\\action-runner-log.txt";
inline const static std::string launcherLoggerName = "launcher";
inline const static std::wstring launcherLogPath = L"LogsModuleInterface\\launcher-log.txt";
inline const static std::string fancyZonesLoggerName = "fancyzones";
inline const static std::wstring fancyZonesLogPath = L"FancyZonesLogs\\fancyzones-log.txt";
inline const static std::wstring fancyZonesLogPath = L"fancyzones-log.txt";
inline const static std::wstring fancyZonesOldLogPath = L"FancyZonesLogs\\"; // needed to clean up old logs
inline const static std::string shortcutGuideLoggerName = "shortcut-guide";
inline const static std::wstring shortcutGuideLogPath = L"ShortcutGuideLogs\\shortcut-guide-log.txt";
inline const static std::string keyboardManagerLoggerName = "keyboard-manager";

View File

@ -10,7 +10,7 @@ namespace fs = std::filesystem;
namespace updating
{
constexpr size_t REQUIRED_MINIMAL_PATCH = 11;
constexpr size_t REQUIRED_MINIMAL_PATCH = 13;
bool dotnet_is_installed()
{
@ -46,7 +46,7 @@ namespace updating
std::optional<fs::path> download_dotnet()
{
const wchar_t DOTNET_DESKTOP_DOWNLOAD_LINK[] = L"https://download.visualstudio.microsoft.com/download/pr/3f1cc4f7-0c1a-48ca-9551-a8447fa55892/ed9809822448f55b649858920afb35cb/windowsdesktop-runtime-3.1.11-win-x64.exe";
const wchar_t DOTNET_DESKTOP_DOWNLOAD_LINK[] = L"https://download.visualstudio.microsoft.com/download/pr/aa717f57-3ae5-48fa-a3ab-0018338d0726/fb37276b1575772461701339110e7a54/windowsdesktop-runtime-3.1.13-win-x64.exe";
const wchar_t DOTNET_DESKTOP_FILENAME[] = L"windowsdesktop-runtime.exe";
auto dotnet_download_path = fs::temp_directory_path() / DOTNET_DESKTOP_FILENAME;

View File

@ -3,6 +3,7 @@
#include "installer.h"
#include <common/version/version.h>
#include <common/notifications/notifications.h>
#include <common/utils/os-detect.h>
#include "utils/winapi_error.h"
namespace // Strings in this namespace should not be localized
@ -192,4 +193,8 @@ namespace updating
co_return false;
}
bool is_old_windows_version()
{
return !Is19H1OrHigher();
}
}

View File

@ -16,4 +16,6 @@ namespace updating
std::optional<VersionHelper> get_installed_powertoys_version();
std::future<bool> uninstall_previous_msix_version_async();
bool is_old_windows_version();
}

View File

@ -7,9 +7,10 @@
#include "notifications.h"
#include "updating.h"
#include <common/utils/json.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <common/notifications/notifications.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <common/utils/json.h>
#include <common/utils/os-detect.h>
namespace // Strings in this namespace should not be localized
{
@ -68,12 +69,17 @@ namespace updating
{
co_return nonstd::make_unexpected(strings.GITHUB_NEW_VERSION_USING_LOCAL_BUILD_ERROR);
}
try
{
http::HttpClient client;
json::JsonObject release_object;
const VersionHelper current_version(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);
VersionHelper github_version = current_version;
// On a <1903 system, block updates to 0.36+
const bool blockNonPatchReleases = current_version.major == 0 && current_version.minor == 35 && !Is19H1OrHigher();
if (prerelease)
{
const auto body = co_await client.request(Uri{ ALL_RELEASES_ENDPOINT });
@ -102,6 +108,11 @@ namespace updating
}
}
if (blockNonPatchReleases && github_version >= VersionHelper{ 0, 36, 0 })
{
co_return version_up_to_date{};
}
if (github_version <= current_version)
{
co_return version_up_to_date{};

View File

@ -0,0 +1,55 @@
#pragma once
#include <filesystem>
#include <common/version/version.h>
namespace LoggerHelpers
{
inline std::filesystem::path get_log_folder_path(std::wstring_view appPath)
{
std::filesystem::path logFolderPath(appPath);
logFolderPath.append(LogSettings::logPath);
logFolderPath.append(get_product_version());
return logFolderPath;
}
inline bool delete_old_log_folder(const std::filesystem::path& logFolderPath)
{
try
{
std::filesystem::remove_all(logFolderPath);
return true;
}
catch (std::filesystem::filesystem_error& e)
{
Logger::error("Failed to delete old log folder: {}", e.what());
}
return false;
}
inline bool delete_other_versions_log_folders(std::wstring_view appPath, const std::filesystem::path& currentVersionLogFolder)
{
bool result = true;
std::filesystem::path logFolderPath(appPath);
logFolderPath.append(LogSettings::logPath);
for (const auto& dir : std::filesystem::directory_iterator(logFolderPath))
{
if (dir != currentVersionLogFolder)
{
try
{
std::filesystem::remove_all(dir);
}
catch (std::filesystem::filesystem_error& e)
{
Logger::error("Failed to delete previous version log folder: {}", e.what());
result = false;
}
}
}
return result;
}
}

View File

@ -2,7 +2,7 @@
#include <winrt/Windows.Foundation.Metadata.h>
// The following three helper functions determine if the user has a build version higher than or equal to 19h1, as that is a requirement for xaml islands
// The following three helper functions determine if the user has a build version higher than or equal to 19h1 (aka 1903), as that is a requirement for xaml islands
// Source : Microsoft-ui-xaml github
// Link: https://github.com/microsoft/microsoft-ui-xaml/blob/c045cde57c5c754683d674634a0baccda34d58c4/dev/dll/SharedHelpers.cpp
template<uint16_t APIVersion>

View File

@ -39,3 +39,14 @@ std::wstring VersionHelper::toWstring() const
result += std::to_wstring(revision);
return result;
}
std::string VersionHelper::toString() const
{
std::string result{ "v" };
result += std::to_string(major);
result += '.';
result += std::to_string(minor);
result += '.';
result += std::to_string(revision);
return result;
}

View File

@ -15,4 +15,5 @@ struct VersionHelper
size_t revision;
std::wstring toWstring() const;
std::string toString() const;
};

View File

@ -54,6 +54,9 @@
<ClCompile Include="trace.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\logger\logger.vcxproj">
<Project>{d9b8fc84-322a-4f9f-bbb9-20915c47ddfd}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\common\SettingsAPI\SetttingsAPI.vcxproj">
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
@ -69,6 +72,7 @@
<None Include="Resources.resx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="..\..\..\..\deps\spdlog.props" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>

View File

@ -4,11 +4,13 @@
#include <interface/powertoy_module_interface.h>
#include "trace.h"
#include "Generated Files/resource.h"
#include <common/logger/logger.h>
#include <common/SettingsAPI/settings_objects.h>
#include <common/utils/os-detect.h>
#include <common/utils/resources.h>
#include <colorPicker/ColorPicker/ColorPickerConstants.h>
#include <common/interop/shared_constants.h>
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
@ -28,6 +30,17 @@ BOOL APIENTRY DllMain(HMODULE hModule,
return TRUE;
}
namespace
{
const wchar_t JSON_KEY_PROPERTIES[] = L"properties";
const wchar_t JSON_KEY_WIN[] = L"win";
const wchar_t JSON_KEY_ALT[] = L"alt";
const wchar_t JSON_KEY_CTRL[] = L"ctrl";
const wchar_t JSON_KEY_SHIFT[] = L"shift";
const wchar_t JSON_KEY_CODE[] = L"code";
const wchar_t JSON_KEY_ACTIVATION_SHORTCUT[] = L"ActivationShortcut";
}
struct ModuleSettings
{
} g_settings;
@ -47,11 +60,103 @@ private:
// Time to wait for process to close after sending WM_CLOSE signal
static const int MAX_WAIT_MILLISEC = 10000;
HANDLE send_telemetry_event;
Hotkey m_hotkey;
// Handle to event used to invoke ColorPicker
HANDLE m_hInvokeEvent;
void parse_hotkey(PowerToysSettings::PowerToyValues& settings)
{
auto settingsObject = settings.get_raw_json();
if (settingsObject.GetView().Size())
{
try
{
auto jsonHotkeyObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_ACTIVATION_SHORTCUT);
m_hotkey.win = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_WIN);
m_hotkey.alt = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_ALT);
m_hotkey.shift = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_SHIFT);
m_hotkey.ctrl = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_CTRL);
m_hotkey.key = static_cast<unsigned char>(jsonHotkeyObject.GetNamedNumber(JSON_KEY_CODE));
}
catch (...)
{
Logger::error("Failed to initialize ColorPicker start shortcut");
}
}
else
{
Logger::info("ColorPicker settings are empty");
}
if (!m_hotkey.key)
{
Logger::info("ColorPicker is going to use default shortcut");
m_hotkey.win = true;
m_hotkey.alt = false;
m_hotkey.shift = true;
m_hotkey.ctrl = false;
m_hotkey.key = 'C';
}
}
bool is_process_running()
{
return WaitForSingleObject(m_hProcess, 0) == WAIT_TIMEOUT;
}
void launch_process()
{
Logger::trace(L"Launching ColorPicker process");
unsigned long powertoys_pid = GetCurrentProcessId();
std::wstring executable_args = L"";
executable_args.append(std::to_wstring(powertoys_pid));
SHELLEXECUTEINFOW sei{ sizeof(sei) };
sei.fMask = { SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI };
sei.lpFile = L"modules\\ColorPicker\\ColorPickerUI.exe";
sei.nShow = SW_SHOWNORMAL;
sei.lpParameters = executable_args.data();
if (!ShellExecuteExW(&sei))
{
DWORD error = GetLastError();
std::wstring message = L"ColorPicker failed to start with error = ";
message += std::to_wstring(error);
Logger::error(message);
}
m_hProcess = sei.hProcess;
}
// Load the settings file.
void init_settings()
{
try
{
// Load and parse the settings file for this PowerToy.
PowerToysSettings::PowerToyValues settings =
PowerToysSettings::PowerToyValues::load_from_settings_file(get_key());
parse_hotkey(settings);
}
catch (std::exception ex)
{
Logger::warn(L"An exception occurred while loading the settings file");
// Error while loading from the settings file. Let default values stay as they are.
}
}
public:
ColorPicker()
{
app_name = GET_RESOURCE_STRING(IDS_COLORPICKER_NAME);
app_key = ColorPickerConstants::ModuleKey;
send_telemetry_event = CreateDefaultEvent(CommonSharedConstants::COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT);
m_hInvokeEvent = CreateDefaultEvent(CommonSharedConstants::SHOW_COLOR_PICKER_SHARED_EVENT);
init_settings();
}
~ColorPicker()
@ -105,6 +210,7 @@ public:
PowerToysSettings::PowerToyValues values =
PowerToysSettings::PowerToyValues::from_json_string(config, get_key());
parse_hotkey(values);
// If you don't need to do any custom processing of the settings, proceed
// to persists the values calling:
values.save_to_settings_file();
@ -119,23 +225,12 @@ public:
virtual void enable()
{
ResetEvent(send_telemetry_event);
ResetEvent(m_hInvokeEvent);
// use only with new settings?
if (UseNewSettings())
{
unsigned long powertoys_pid = GetCurrentProcessId();
std::wstring executable_args = L"";
executable_args.append(std::to_wstring(powertoys_pid));
SHELLEXECUTEINFOW sei{ sizeof(sei) };
sei.fMask = { SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI };
sei.lpFile = L"modules\\ColorPicker\\ColorPickerUI.exe";
sei.nShow = SW_SHOWNORMAL;
sei.lpParameters = executable_args.data();
ShellExecuteExW(&sei);
m_hProcess = sei.hProcess;
launch_process();
m_enabled = true;
}
};
@ -144,16 +239,57 @@ public:
{
if (m_enabled)
{
ResetEvent(send_telemetry_event);
ResetEvent(m_hInvokeEvent);
TerminateProcess(m_hProcess, 1);
}
m_enabled = false;
}
virtual bool on_hotkey(size_t hotkeyId) override
{
if (m_enabled)
{
Logger::trace(L"ColorPicker hotkey pressed");
if (!is_process_running())
{
launch_process();
}
SetEvent(m_hInvokeEvent);
return true;
}
return false;
}
virtual size_t get_hotkeys(Hotkey* hotkeys, size_t buffer_size) override
{
if (m_hotkey.key)
{
if (hotkeys && buffer_size >= 1)
{
hotkeys[0] = m_hotkey;
}
return 1;
}
else
{
return 0;
}
}
virtual bool is_enabled() override
{
return m_enabled;
}
virtual void send_settings_telemetry() override
{
SetEvent(send_telemetry_event);
}
};
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()

View File

@ -18,7 +18,7 @@ namespace ColorPickerUI
{
private Mutex _instanceMutex;
private static string[] _args;
private int _powerToysPid;
private int _powerToysRunnerPid;
private bool disposedValue;
private ThemeManager _themeManager;
@ -27,23 +27,27 @@ namespace ColorPickerUI
_args = e?.Args;
// allow only one instance of color picker
_instanceMutex = new Mutex(true, @"Global\ColorPicker", out bool createdNew);
_instanceMutex = new Mutex(true, @"Local\PowerToys_ColorPicker_InstanceMutex", out bool createdNew);
if (!createdNew)
{
_instanceMutex = null;
Application.Current.Shutdown();
Environment.Exit(0);
return;
}
if (_args?.Length > 0)
{
_ = int.TryParse(_args[0], out _powerToysPid);
}
_ = int.TryParse(_args[0], out _powerToysRunnerPid);
RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () =>
RunnerHelper.WaitForPowerToysRunner(_powerToysRunnerPid, () =>
{
Environment.Exit(0);
});
}
else
{
Environment.Exit(0);
});
_powerToysRunnerPid = -1;
}
_themeManager = new ThemeManager(this);
base.OnStartup(e);
@ -83,5 +87,10 @@ namespace ColorPickerUI
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
public bool IsRunningDetachedFromPowerToys()
{
return _powerToysRunnerPid == -1;
}
}
}

View File

@ -2,19 +2,8 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ColorPicker.Helpers;
namespace ColorPicker
{
@ -23,16 +12,19 @@ namespace ColorPicker
/// </summary>
public partial class ColorEditorWindow : Window
{
public ColorEditorWindow()
private readonly AppStateHandler _appStateHandler;
public ColorEditorWindow(AppStateHandler appStateHandler)
{
InitializeComponent();
_appStateHandler = appStateHandler;
Closing += ColorEditorWindow_Closing;
}
private void ColorEditorWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
this.Hide();
_appStateHandler.EndUserSession();
}
}
}

View File

@ -56,6 +56,7 @@ namespace ColorPicker.Controls
private void CopyToClipboardButton_Click(object sender, RoutedEventArgs e)
{
ClipboardHelper.CopyToClipboard(ColorTextRepresentationTextBlock.Text);
SessionEventHelper.Event.EditorColorCopiedToClipboard = true;
if (!_copyIndicatorVisible)
{
AppearCopiedIndicator();

View File

@ -32,7 +32,8 @@
Background="LightPink"
Click="ColorVariationButton_Click"
AutomationProperties.Name="Color shade 1"
Style="{DynamicResource ColorShadeButtonStyle}"/>
Style="{DynamicResource ColorShadeButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}"/>
<Button x:Name="colorVariation2Button"
Grid.Column="1"
ui:ControlHelper.CornerRadius="0"
@ -40,7 +41,8 @@
Background="LightPink"
Click="ColorVariationButton_Click"
AutomationProperties.Name="Color shade 2"
Style="{DynamicResource ColorShadeButtonStyle}"/>
Style="{DynamicResource ColorShadeButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}"/>
<Button x:Name="colorVariation3Button"
Grid.Column="3"
TabIndex="7"
@ -48,7 +50,8 @@
Background="LightPink"
Click="ColorVariationButton_Click"
AutomationProperties.Name="Color shade 3"
Style="{DynamicResource ColorShadeButtonStyle}"/>
Style="{DynamicResource ColorShadeButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}"/>
<Button x:Name="colorVariation4Button"
Grid.Column="4"
TabIndex="8"
@ -56,7 +59,8 @@
Background="LightPink"
Click="ColorVariationButton_Click"
AutomationProperties.Name="Color shade 5"
Style="{DynamicResource ColorShadeButtonStyle}"/>
Style="{DynamicResource ColorShadeButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}"/>
<Button x:Name="CurrentColorButton"
HorizontalAlignment="Left"
Grid.Column="0"
@ -72,7 +76,8 @@
AutomationProperties.HelpText="{x:Static p:Resources.Selected_color_helptext}"
ToolTipService.ToolTip="{x:Static p:Resources.Selected_color_tooltip}"
Click="CurrentColorButton_Click"
Style="{DynamicResource ColorShadeButtonStyle}"/>
Style="{DynamicResource ColorShadeButtonStyle}">
</Button>
</Grid>
<!--Details panel-->
@ -202,71 +207,73 @@
</Border>
</Grid>
<Grid HorizontalAlignment="Stretch" Margin="12,16,12,8">
<Grid HorizontalAlignment="Stretch"
Margin="12,16,12,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="68"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="20" />
<ColumnDefinition Width="86" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="36"/>
<RowDefinition Height="36"/>
<RowDefinition Height="36" />
<RowDefinition Height="36" />
<RowDefinition Height="36" />
</Grid.RowDefinitions>
<TextBlock Text="R"
FontWeight="SemiBold"
VerticalAlignment="Center"/>
<TextBox x:Name="RTextBox"
Margin="0,0,0,0"
Grid.Column="1"
Height="32"
AutomationProperties.Name="{x:Static p:Resources.Red_value}"
TextChanged="RGBTextBoxes_TextChanged"
TextWrapping="Wrap"/>
VerticalAlignment="Center" />
<ui:NumberBox x:Name="RNumberBox"
Grid.Column="1"
Height="32"
AutomationProperties.Name="{x:Static p:Resources.Red_value}"
ValueChanged="RGBNumberBox_ValueChanged"
Minimum="0"
Maximum="255" />
<TextBlock Text="G"
FontWeight="SemiBold"
Grid.Row="1"
VerticalAlignment="Center"/>
VerticalAlignment="Center" />
<TextBox x:Name="GTextBox"
Width="68"
Height="32"
Grid.Row="1"
Grid.Column="1"
AutomationProperties.Name="{x:Static p:Resources.Green_value}"
TextChanged="RGBTextBoxes_TextChanged"
TextWrapping="Wrap"/>
<ui:NumberBox x:Name="GNumberBox"
Height="32"
Grid.Row="1"
Grid.Column="1"
AutomationProperties.Name="{x:Static p:Resources.Green_value}"
ValueChanged="RGBNumberBox_ValueChanged"
Minimum="0"
Maximum="255" />
<TextBlock Text="B"
FontWeight="SemiBold"
Grid.Row="2"
VerticalAlignment="Center"/>
VerticalAlignment="Center" />
<TextBox x:Name="BTextBox"
Width="68"
Height="32"
Grid.Column="1"
Grid.Row="2"
AutomationProperties.Name="{x:Static p:Resources.Blue_value}"
TextChanged="RGBTextBoxes_TextChanged"
TextWrapping="Wrap"/>
<ui:NumberBox x:Name="BNumberBox"
Height="32"
Grid.Column="1"
Grid.Row="2"
AutomationProperties.Name="{x:Static p:Resources.Blue_value}"
ValueChanged="RGBNumberBox_ValueChanged"
Minimum="0"
Maximum="255" />
<TextBlock Text="HEX"
Grid.Column="2"
HorizontalAlignment="Right"
FontWeight="SemiBold"
VerticalAlignment="Center"/>
VerticalAlignment="Center" />
<TextBox x:Name="HexCode"
HorizontalAlignment="Stretch"
Margin="8,0,0,0"
Height="32"
Grid.Column="3"
AutomationProperties.Name="{x:Static p:Resources.Hex_value}"
GotKeyboardFocus="HexCode_GotKeyboardFocus"
TextChanged="HexCode_TextChanged"
TextWrapping="Wrap"/>
TextWrapping="Wrap" />
</Grid>
<WrapPanel HorizontalAlignment="Right"
Margin="0,0,0,0"

View File

@ -56,20 +56,24 @@ namespace ColorPicker.Controls
private static void SelectedColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (ColorPickerControl)d;
var newColor = (Color)e.NewValue;
((ColorPickerControl)d)._originalColor = ((ColorPickerControl)d)._currentColor = newColor;
var newColorBackground = new SolidColorBrush(newColor);
((ColorPickerControl)d).CurrentColorButton.Background = newColorBackground;
((ColorPickerControl)d)._ignoreHexChanges = true;
((ColorPickerControl)d)._ignoreRGBChanges = true;
((ColorPickerControl)d).HexCode.Text = ColorToHex(newColor);
((ColorPickerControl)d).RTextBox.Text = newColor.R.ToString(CultureInfo.InvariantCulture);
((ColorPickerControl)d).GTextBox.Text = newColor.G.ToString(CultureInfo.InvariantCulture);
((ColorPickerControl)d).BTextBox.Text = newColor.B.ToString(CultureInfo.InvariantCulture);
((ColorPickerControl)d).SetColorFromTextBoxes(System.Drawing.Color.FromArgb(newColor.R, newColor.G, newColor.B));
((ColorPickerControl)d)._ignoreRGBChanges = false;
((ColorPickerControl)d)._ignoreHexChanges = false;
control._originalColor = control._currentColor = newColor;
var newColorBackground = new SolidColorBrush(newColor);
control.CurrentColorButton.Background = newColorBackground;
control._ignoreHexChanges = true;
control._ignoreRGBChanges = true;
control.HexCode.Text = ColorToHex(newColor);
control.RNumberBox.Text = newColor.R.ToString(CultureInfo.InvariantCulture);
control.GNumberBox.Text = newColor.G.ToString(CultureInfo.InvariantCulture);
control.BNumberBox.Text = newColor.B.ToString(CultureInfo.InvariantCulture);
control.SetColorFromTextBoxes(System.Drawing.Color.FromArgb(newColor.R, newColor.G, newColor.B));
control._ignoreRGBChanges = false;
control._ignoreHexChanges = false;
var hsv = ColorHelper.ConvertToHSVColor(System.Drawing.Color.FromArgb(newColor.R, newColor.G, newColor.B));
@ -107,12 +111,13 @@ namespace ColorPicker.Controls
}
var s = hsv.saturation;
var control = (ColorPickerControl)d;
((ColorPickerControl)d).colorVariation1Button.Background = new SolidColorBrush(HSVColor.RGBFromHSV(Math.Min(hsv.hue + (hueCoefficient * 8), 360), s, Math.Min(hsv.value + 0.3, 1)));
((ColorPickerControl)d).colorVariation2Button.Background = new SolidColorBrush(HSVColor.RGBFromHSV(Math.Min(hsv.hue + (hueCoefficient * 4), 360), s, Math.Min(hsv.value + 0.15, 1)));
control.colorVariation1Button.Background = new SolidColorBrush(HSVColor.RGBFromHSV(Math.Min(hsv.hue + (hueCoefficient * 8), 360), s, Math.Min(hsv.value + 0.3, 1)));
control.colorVariation2Button.Background = new SolidColorBrush(HSVColor.RGBFromHSV(Math.Min(hsv.hue + (hueCoefficient * 4), 360), s, Math.Min(hsv.value + 0.15, 1)));
((ColorPickerControl)d).colorVariation3Button.Background = new SolidColorBrush(HSVColor.RGBFromHSV(Math.Max(hsv.hue - (hueCoefficient2 * 4), 0), s, Math.Max(hsv.value - 0.2, 0)));
((ColorPickerControl)d).colorVariation4Button.Background = new SolidColorBrush(HSVColor.RGBFromHSV(Math.Max(hsv.hue - (hueCoefficient2 * 8), 0), s, Math.Max(hsv.value - 0.3, 0)));
control.colorVariation3Button.Background = new SolidColorBrush(HSVColor.RGBFromHSV(Math.Max(hsv.hue - (hueCoefficient2 * 4), 0), s, Math.Max(hsv.value - 0.2, 0)));
control.colorVariation4Button.Background = new SolidColorBrush(HSVColor.RGBFromHSV(Math.Max(hsv.hue - (hueCoefficient2 * 8), 0), s, Math.Max(hsv.value - 0.3, 0)));
}
private void UpdateValueColorGradient(double posX)
@ -161,9 +166,9 @@ namespace ColorPicker.Controls
if (!_ignoreRGBChanges)
{
RTextBox.Text = currentColor.R.ToString(CultureInfo.InvariantCulture);
GTextBox.Text = currentColor.G.ToString(CultureInfo.InvariantCulture);
BTextBox.Text = currentColor.B.ToString(CultureInfo.InvariantCulture);
RNumberBox.Text = currentColor.R.ToString(CultureInfo.InvariantCulture);
GNumberBox.Text = currentColor.G.ToString(CultureInfo.InvariantCulture);
BNumberBox.Text = currentColor.B.ToString(CultureInfo.InvariantCulture);
}
_currentColor = currentColor;
@ -200,6 +205,7 @@ namespace ColorPicker.Controls
detailsStackPanel.BeginAnimation(StackPanel.OpacityProperty, opacityAppear);
detailsGrid.BeginAnimation(Grid.HeightProperty, resize);
CurrentColorButton.IsEnabled = false;
SessionEventHelper.Event.EditorAdjustColorOpened = true;
}
}
@ -234,8 +240,8 @@ namespace ColorPicker.Controls
private void OKButton_Click(object sender, RoutedEventArgs e)
{
HideDetails();
SelectedColorChangedCommand.Execute(_currentColor);
SessionEventHelper.Event.EditorColorAdjusted = true;
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
@ -253,6 +259,7 @@ namespace ColorPicker.Controls
{
var selectedColor = ((SolidColorBrush)((Button)sender).Background).Color;
SelectedColorChangedCommand.Execute(selectedColor);
SessionEventHelper.Event.EditorSimilarColorPicked = true;
}
private void ValueGradientGrid_MouseMove(object sender, MouseEventArgs e)
@ -357,19 +364,15 @@ namespace ColorPicker.Controls
}
}
private void RGBTextBoxes_TextChanged(object sender, TextChangedEventArgs e)
#pragma warning disable CA1801 // Review unused parameters
private void RGBNumberBox_ValueChanged(ModernWpf.Controls.NumberBox sender, ModernWpf.Controls.NumberBoxValueChangedEventArgs args)
#pragma warning restore CA1801 // Review unused parameters
{
var validNumber = int.TryParse((sender as TextBox).Text, out int result);
if (!validNumber || result < 0 || result > 255)
{
return;
}
if (!_ignoreRGBChanges)
{
var r = byte.Parse(RTextBox.Text, CultureInfo.InvariantCulture);
var g = byte.Parse(GTextBox.Text, CultureInfo.InvariantCulture);
var b = byte.Parse(BTextBox.Text, CultureInfo.InvariantCulture);
var r = byte.Parse(RNumberBox.Text, CultureInfo.InvariantCulture);
var g = byte.Parse(GNumberBox.Text, CultureInfo.InvariantCulture);
var b = byte.Parse(BNumberBox.Text, CultureInfo.InvariantCulture);
_ignoreRGBChanges = true;
SetColorFromTextBoxes(System.Drawing.Color.FromArgb(r, g, b));
_ignoreRGBChanges = false;
@ -397,5 +400,10 @@ namespace ColorPicker.Controls
{
return "#" + BitConverter.ToString(new byte[] { color.R, color.G, color.B }).Replace("-", string.Empty, StringComparison.InvariantCulture);
}
private void HexCode_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
(sender as TextBox).SelectAll();
}
}
}

View File

@ -5,7 +5,9 @@
using System;
using System.ComponentModel.Composition;
using System.Windows;
using ColorPicker.Settings;
using ColorPicker.ViewModelContracts;
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
namespace ColorPicker.Helpers
{
@ -13,15 +15,17 @@ namespace ColorPicker.Helpers
public class AppStateHandler
{
private readonly IColorEditorViewModel _colorEditorViewModel;
private readonly IUserSettings _userSettings;
private ColorEditorWindow _colorEditorWindow;
private bool _colorPickerShown;
private object _colorPickerVisibilityLock = new object();
[ImportingConstructor]
public AppStateHandler(IColorEditorViewModel colorEditorViewModel)
public AppStateHandler(IColorEditorViewModel colorEditorViewModel, IUserSettings userSettings)
{
Application.Current.MainWindow.Closed += MainWindow_Closed;
_colorEditorViewModel = colorEditorViewModel;
_userSettings = userSettings;
}
public event EventHandler AppShown;
@ -30,45 +34,61 @@ namespace ColorPicker.Helpers
public event EventHandler AppClosed;
public void ShowColorPicker()
public void StartUserSession()
{
lock (_colorPickerVisibilityLock)
{
if (!_colorPickerShown)
if (!_colorPickerShown && !IsColorPickerEditorVisible())
{
AppShown?.Invoke(this, EventArgs.Empty);
Application.Current.MainWindow.Opacity = 0;
Application.Current.MainWindow.Visibility = Visibility.Visible;
_colorPickerShown = true;
SessionEventHelper.Start(_userSettings.ActivationAction.Value);
}
if (_userSettings.ActivationAction.Value == ColorPickerActivationAction.OpenEditor)
{
ShowColorPickerEditor();
}
else
{
ShowColorPicker();
}
}
}
public void HideColorPicker()
public void EndUserSession()
{
lock (_colorPickerVisibilityLock)
{
if (_colorPickerShown)
if (IsColorPickerEditorVisible() || _colorPickerShown)
{
Application.Current.MainWindow.Opacity = 0;
Application.Current.MainWindow.Visibility = Visibility.Collapsed;
AppHidden?.Invoke(this, EventArgs.Empty);
_colorPickerShown = false;
if (IsColorPickerEditorVisible())
{
HideColorPickerEditor();
}
else
{
HideColorPicker();
}
SessionEventHelper.End();
}
}
}
public void ShowColorPickerEditor()
public void OnColorPickerMouseDown()
{
if (_colorEditorWindow == null)
if (_userSettings.ActivationAction.Value == ColorPickerActivationAction.OpenColorPickerAndThenEditor || _userSettings.ActivationAction.Value == ColorPickerActivationAction.OpenEditor)
{
_colorEditorWindow = new ColorEditorWindow();
_colorEditorWindow.Content = _colorEditorViewModel;
_colorEditorViewModel.OpenColorPickerRequested += ColorEditorViewModel_OpenColorPickerRequested;
}
lock (_colorPickerVisibilityLock)
{
HideColorPicker();
}
_colorEditorViewModel.Initialize();
_colorEditorWindow.Show();
ShowColorPickerEditor();
}
else
{
EndUserSession();
}
}
public static void SetTopMost()
@ -77,6 +97,65 @@ namespace ColorPicker.Helpers
Application.Current.MainWindow.Topmost = true;
}
private void ShowColorPicker()
{
if (!_colorPickerShown)
{
AppShown?.Invoke(this, EventArgs.Empty);
Application.Current.MainWindow.Opacity = 0;
Application.Current.MainWindow.Visibility = Visibility.Visible;
_colorPickerShown = true;
}
}
private void HideColorPicker()
{
if (_colorPickerShown)
{
Application.Current.MainWindow.Opacity = 0;
Application.Current.MainWindow.Visibility = Visibility.Collapsed;
AppHidden?.Invoke(this, EventArgs.Empty);
_colorPickerShown = false;
}
}
private void ShowColorPickerEditor()
{
if (_colorEditorWindow == null)
{
_colorEditorWindow = new ColorEditorWindow(this);
_colorEditorWindow.Content = _colorEditorViewModel;
_colorEditorViewModel.OpenColorPickerRequested += ColorEditorViewModel_OpenColorPickerRequested;
_colorEditorViewModel.OpenColorPickerRequested += (object sender, EventArgs e) =>
{
SessionEventHelper.Event.EditorColorPickerOpened = true;
};
}
_colorEditorViewModel.Initialize();
_colorEditorWindow.Show();
SessionEventHelper.Event.EditorOpened = true;
}
private void HideColorPickerEditor()
{
if (_colorEditorWindow != null)
{
_colorEditorWindow.Hide();
}
}
private bool IsColorPickerEditorVisible()
{
if (_colorEditorWindow != null)
{
// Check if we are visible and on top. Using focus producing unreliable results the first time the picker is opened.
return _colorEditorWindow.Topmost && _colorEditorWindow.IsVisible;
}
return false;
}
private void MainWindow_Closed(object sender, EventArgs e)
{
AppClosed?.Invoke(this, EventArgs.Empty);
@ -84,7 +163,11 @@ namespace ColorPicker.Helpers
private void ColorEditorViewModel_OpenColorPickerRequested(object sender, EventArgs e)
{
ShowColorPicker();
lock (_colorPickerVisibilityLock)
{
ShowColorPicker();
}
_colorEditorWindow.Hide();
}
}

View File

@ -5,14 +5,16 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Abstractions;
using interop;
namespace ColorPicker.Helpers
{
public static class Logger
{
private static readonly IFileSystem _fileSystem = new FileSystem();
private static readonly string ApplicationLogPath = _fileSystem.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ColorPicker");
private static readonly string ApplicationLogPath = Path.Combine(Constants.AppDataPath(), "ColorPicker\\Logs");
static Logger()
{

View File

@ -3,25 +3,13 @@
// See the LICENSE file in the project root for more information.
using System;
using System.ComponentModel.Composition;
using System.Threading;
using System.Windows;
using interop;
namespace ColorPicker.Helpers
{
[Export(typeof(NativeEventWaiter))]
public class NativeEventWaiter
public static class NativeEventWaiter
{
private AppStateHandler _appStateHandler;
[ImportingConstructor]
public NativeEventWaiter(AppStateHandler appStateHandler)
{
_appStateHandler = appStateHandler;
WaitForEventLoop(Constants.ShowColorPickerSharedEvent(), _appStateHandler.ShowColorPicker);
}
public static void WaitForEventLoop(string eventName, Action callback)
{
new Thread(() =>
@ -31,7 +19,7 @@ namespace ColorPicker.Helpers
{
if (eventHandle.WaitOne())
{
Logger.LogInfo("Successfully waited for SHOW_COLOR_PICKER_EVENT");
Logger.LogInfo($"Successfully waited for {eventName}");
Application.Current.Dispatcher.Invoke(callback);
}
}

View File

@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using ColorPicker.Telemetry;
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
using Microsoft.PowerToys.Telemetry;
namespace ColorPicker.Helpers
{
public static class SessionEventHelper
{
public static ColorPickerSession Event { get; private set; }
public static void Start(ColorPickerActivationAction startedAs)
{
Event = new ColorPickerSession();
Event.StartedAs = startedAs.ToString();
_startTime = DateTime.Now;
}
public static void End()
{
if (_startTime == null)
{
Logger.LogError("Failed to send ColorPickerSessionEvent");
return;
}
var duration = DateTime.Now - _startTime.Value;
Event.Duration = duration.Seconds + (duration.Milliseconds == 0 ? 0 : 1);
_startTime = null;
PowerToysTelemetry.Log.WriteEvent(Event);
}
private static DateTime? _startTime;
}
}

View File

@ -179,7 +179,7 @@ namespace ColorPicker.Helpers
{
_zoomWindow.Left = _lastLeft + 1;
_zoomWindow.Top = _lastTop + 1;
PowerToysTelemetry.Log.WriteEvent(new ColorPickerZoomOpenedEvent());
SessionEventHelper.Event.ZoomUsed = true;
}
_throttledActionInvoker.ScheduleAction(

View File

@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Windows.Input;
using ColorPicker.Helpers;
using ColorPicker.Settings;
@ -22,7 +21,7 @@ namespace ColorPicker.Keyboard
{
private readonly AppStateHandler _appStateHandler;
private readonly IUserSettings _userSettings;
private List<string> _previouslyPressedKeys;
private List<string> _previouslyPressedKeys = new List<string>();
private List<string> _activationKeys = new List<string>();
private GlobalKeyboardHook _keyboardHook;
@ -73,47 +72,43 @@ namespace ColorPicker.Keyboard
// ESC pressed
if (virtualCode == KeyInterop.VirtualKeyFromKey(Key.Escape))
{
_appStateHandler.HideColorPicker();
PowerToysTelemetry.Log.WriteEvent(new ColorPickerCancelledEvent());
_appStateHandler.EndUserSession();
return;
}
var name = Helper.GetKeyName((uint)virtualCode);
// If the last key pressed is a modifier key, then currentlyPressedKeys cannot possibly match with _activationKeys
// because _activationKeys contains exactly 1 non-modifier key. Hence, there's no need to check if `name` is a
// modifier key or to do any additional processing on it.
if (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown || e.KeyboardState == GlobalKeyboardHook.KeyboardState.SysKeyDown)
if ((System.Windows.Application.Current as ColorPickerUI.App).IsRunningDetachedFromPowerToys())
{
// Check pressed modifier keys.
AddModifierKeys(currentlyPressedKeys);
var name = Helper.GetKeyName((uint)virtualCode);
currentlyPressedKeys.Add(name);
}
currentlyPressedKeys.Sort();
if (currentlyPressedKeys.Count == 0 && _previouslyPressedKeys.Count != 0)
{
// no keys pressed, we can enable activation shortcut again
_activationShortcutPressed = false;
}
_previouslyPressedKeys = currentlyPressedKeys;
if (ArraysAreSame(currentlyPressedKeys, _activationKeys))
{
// avoid triggering this action multiple times as this will be called nonstop while keys are pressed
if (!_activationShortcutPressed)
// If the last key pressed is a modifier key, then currentlyPressedKeys cannot possibly match with _activationKeys
// because _activationKeys contains exactly 1 non-modifier key. Hence, there's no need to check if `name` is a
// modifier key or to do any additional processing on it.
if (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown || e.KeyboardState == GlobalKeyboardHook.KeyboardState.SysKeyDown)
{
_activationShortcutPressed = true;
if (_userSettings.ActivationAction.Value == ColorPickerActivationAction.OpenEditor)
// Check pressed modifier keys.
AddModifierKeys(currentlyPressedKeys);
currentlyPressedKeys.Add(name);
}
currentlyPressedKeys.Sort();
if (currentlyPressedKeys.Count == 0 && _previouslyPressedKeys.Count != 0)
{
// no keys pressed, we can enable activation shortcut again
_activationShortcutPressed = false;
}
_previouslyPressedKeys = currentlyPressedKeys;
if (ArraysAreSame(currentlyPressedKeys, _activationKeys))
{
// avoid triggering this action multiple times as this will be called nonstop while keys are pressed
if (!_activationShortcutPressed)
{
_appStateHandler.ShowColorPickerEditor();
}
else
{
_appStateHandler.ShowColorPicker();
_activationShortcutPressed = true;
_appStateHandler.StartUserSession();
}
}
}

View File

@ -114,6 +114,7 @@ namespace ColorPicker.Mouse
{
MouseDevice mouseDev = InputManager.Current.PrimaryMouseDevice;
MouseWheel.Invoke(null, new MouseWheelEventArgs(mouseDev, Environment.TickCount, (int)mouseHookStruct.mouseData >> 16));
return new IntPtr(-1);
}
}
}

View File

@ -195,6 +195,15 @@ namespace ColorPicker.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Select color.
/// </summary>
public static string Select_color {
get {
return ResourceManager.GetString("Select_color", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Selected color.
/// </summary>

View File

@ -361,4 +361,7 @@
<value>Plum</value>
<comment>Plum color</comment>
</data>
<data name="Select_color" xml:space="preserve">
<value>Select color</value>
</data>
</root>

View File

@ -105,6 +105,7 @@
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
Opacity="0"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
@ -113,12 +114,12 @@
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Background" Property="Opacity" Value="0.8" />
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPointerOver}" />
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" />
<Setter TargetName="ContentPresenter" Property="Opacity" Value="1" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="Background" Property="Opacity" Value="0.9" />
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPressed}" />
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundPressed}" />
<Setter TargetName="ContentPresenter" Property="Opacity" Value="1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

View File

@ -25,5 +25,7 @@ namespace ColorPicker.Settings
ObservableCollection<string> VisibleColorFormats { get; }
SettingItem<bool> ShowColorName { get; }
void SendSettingsTelemetry();
}
}

View File

@ -13,6 +13,7 @@ using ColorPicker.Common;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Telemetry;
namespace ColorPicker.Settings
{
@ -160,5 +161,27 @@ namespace ColorPicker.Settings
}
}
}
public void SendSettingsTelemetry()
{
Logger.LogInfo("Sending settings telemetry");
var settings = _settingsUtils.GetSettingsOrDefault<ColorPickerSettings>(ColorPickerModuleName);
var properties = settings?.Properties;
if (properties == null)
{
Logger.LogError("Failed to send settings telemetry");
return;
}
var telemetrySettings = new Telemetry.ColorPickerSettings(properties.VisibleColorFormats)
{
ActivationShortcut = properties.ActivationShortcut.ToString(),
ActivationBehaviour = properties.ActivationAction.ToString(),
ColorFormatForClipboard = properties.CopiedColorRepresentation.ToString(),
ShowColorName = properties.ShowColorName,
};
PowerToysTelemetry.Log.WriteEvent(telemetrySettings);
}
}
}

View File

@ -1,16 +0,0 @@
// 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.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
namespace ColorPicker.Telemetry
{
[EventData]
public class ColorPickerCancelledEvent : EventBase, IEvent
{
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
namespace ColorPicker.Telemetry
{
[EventData]
public class ColorPickerSession : EventBase, IEvent
{
public ColorPickerSession()
{
EventName = "ColorPicker_Session";
}
public string StartedAs { get; set; }
public bool ZoomUsed { get; set; }
public bool EditorOpened { get; set; }
public bool EditorColorPickerOpened { get; set; }
public bool EditorAdjustColorOpened { get; set; }
public bool EditorColorAdjusted { get; set; }
public bool EditorSimilarColorPicked { get; set; }
public bool EditorHistoryColorPicked { get; set; }
public bool EditorHistoryColorRemoved { get; set; }
public bool EditorColorCopiedToClipboard { get; set; }
public int Duration { get; set; }
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@ -0,0 +1,33 @@
// 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.Collections.Generic;
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
namespace ColorPicker.Telemetry
{
[EventData]
public class ColorPickerSettings : EventBase, IEvent
{
public ColorPickerSettings(IDictionary<string, bool> editorFormats)
{
EditorFormats = editorFormats;
EventName = "ColorPicker_Settings";
}
public string ActivationShortcut { get; set; }
public string ActivationBehaviour { get; set; }
public string ColorFormatForClipboard { get; set; }
public bool ShowColorName { get; set; }
public IDictionary<string, bool> EditorFormats { get; }
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@ -1,16 +0,0 @@
// 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.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
namespace ColorPicker.Telemetry
{
[EventData]
public class ColorPickerShowEvent : EventBase, IEvent
{
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@ -134,6 +134,7 @@ namespace ColorPicker.ViewModels
var indexToSelect = SelectedColorIndex == ColorsHistory.Count - 1 ? ColorsHistory.Count - 2 : SelectedColorIndex;
ColorsHistory.RemoveAt(SelectedColorIndex);
SelectedColorIndex = indexToSelect;
SessionEventHelper.Event.EditorHistoryColorRemoved = true;
}
private void SetupAllColorRepresentations()

View File

@ -15,6 +15,7 @@ using ColorPicker.Mouse;
using ColorPicker.Settings;
using ColorPicker.Telemetry;
using ColorPicker.ViewModelContracts;
using interop;
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
using Microsoft.PowerToys.Telemetry;
@ -26,7 +27,6 @@ namespace ColorPicker.ViewModels
private readonly ZoomWindowHelper _zoomWindowHelper;
private readonly AppStateHandler _appStateHandler;
private readonly IUserSettings _userSettings;
private readonly NativeEventWaiter _nativeEventWaiter;
/// <summary>
/// Backing field for <see cref="OtherColor"/>
@ -49,13 +49,13 @@ namespace ColorPicker.ViewModels
ZoomWindowHelper zoomWindowHelper,
AppStateHandler appStateHandler,
KeyboardMonitor keyboardMonitor,
NativeEventWaiter nativeEventWaiter,
IUserSettings userSettings)
{
_zoomWindowHelper = zoomWindowHelper;
_appStateHandler = appStateHandler;
_userSettings = userSettings;
_nativeEventWaiter = nativeEventWaiter;
NativeEventWaiter.WaitForEventLoop(Constants.ShowColorPickerSharedEvent(), _appStateHandler.StartUserSession);
NativeEventWaiter.WaitForEventLoop(Constants.ColorPickerSendSettingsTelemetryEvent(), _userSettings.SendSettingsTelemetry);
if (mouseInfoProvider != null)
{
@ -140,14 +140,7 @@ namespace ColorPicker.ViewModels
_userSettings.ColorHistory.RemoveAt(_userSettings.ColorHistory.Count - 1);
}
_appStateHandler.HideColorPicker();
if (_userSettings.ActivationAction.Value == ColorPickerActivationAction.OpenColorPickerAndThenEditor || _userSettings.ActivationAction.Value == ColorPickerActivationAction.OpenEditor)
{
_appStateHandler.ShowColorPickerEditor();
}
PowerToysTelemetry.Log.WriteEvent(new ColorPickerShowEvent());
_appStateHandler.OnColorPickerMouseDown();
}
private string GetColorString()

View File

@ -20,13 +20,16 @@
<!-- Side bar -->
<Grid Background="{DynamicResource SecondaryBackgroundBrush}">
<ui:ListView Margin="0,48,0,0"
<ui:ListView x:Name="HistoryColors"
Margin="0,48,0,0"
Grid.Row="1"
Padding="0"
TabIndex="3"
ItemsSource="{Binding ColorsHistory}"
SelectedIndex="{Binding SelectedColorIndex}"
ItemContainerStyle="{DynamicResource ColorHistoryListViewStyle}">
ItemContainerStyle="{DynamicResource ColorHistoryListViewStyle}"
IsItemClickEnabled="True"
ItemClick="HistoryColors_ItemClick">
<ui:ListView.ContextMenu>
<ContextMenu Visibility="{Binding ColorsHistory.Count, Converter={StaticResource numberToVisibilityConverter}}">
<MenuItem Header="{x:Static p:Resources.Remove}"
@ -75,7 +78,7 @@
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="0,1,0,0" />
<!-- Enable once we have settings linking available -->
<!--<Button Width="46"
Height="32"
@ -87,7 +90,7 @@
Margin="0,0,46,0"
ToolTipService.ToolTip="{x:Static p:Resources.Open_settings}"
AutomationProperties.Name="{x:Static p:Resources.Open_settings}" />-->
<Button Width="64"
Height="32"
TabIndex="1"

View File

@ -2,20 +2,8 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ColorPicker.Helpers;
namespace ColorPicker.Views
{
@ -26,5 +14,12 @@ namespace ColorPicker.Views
{
public ColorEditorView() =>
InitializeComponent();
private void HistoryColors_ItemClick(object sender, ModernWpf.Controls.ItemClickEventArgs e)
{
// Note: it does not handle clicking on the same color.
// More appropriate event would be SelectionChanged but we can not distinguish between user action and program action inside of it.
SessionEventHelper.Event.EditorHistoryColorPicked = true;
}
}
}

View File

@ -28,13 +28,13 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="coverlet.collector" Version="1.3.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="coverlet.collector" Version="3.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
</ItemGroup>
<ItemGroup>

View File

@ -14,6 +14,7 @@
#include <lib/FancyZonesWinHookEventIDs.h>
#include <lib/FancyZonesData.cpp>
#include <common/logger/logger.h>
#include <common/utils/logger_helper.h>
#include <common/utils/resources.h>
#include <common/utils/winapi_error.h>
#include <common/utils/window.h>
@ -156,9 +157,19 @@ public:
{
app_name = GET_RESOURCE_STRING(IDS_FANCYZONES);
app_key = NonLocalizable::FancyZonesStr;
std::filesystem::path logFilePath(PTSettingsHelper::get_module_save_folder_location(app_key));
const auto appFolder = PTSettingsHelper::get_module_save_folder_location(app_key);
const std::filesystem::path logFolder = LoggerHelpers::get_log_folder_path(appFolder);
std::filesystem::path logFilePath(logFolder);
logFilePath.append(LogSettings::fancyZonesLogPath);
Logger::init(LogSettings::fancyZonesLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
std::filesystem::path oldLogFolder(appFolder);
oldLogFolder.append(LogSettings::fancyZonesOldLogPath);
LoggerHelpers::delete_old_log_folder(oldLogFolder);
LoggerHelpers::delete_other_versions_log_folders(appFolder, logFolder);
m_settings = MakeFancyZonesSettings(reinterpret_cast<HINSTANCE>(&__ImageBase), FancyZonesModule::get_name(), FancyZonesModule::get_key());
FancyZonesDataInstance().LoadFancyZonesData();
s_instance = this;

View File

@ -135,15 +135,7 @@ namespace FancyZonesEditor
sb.AppendLine(ParsingErrorDataTag);
sb.AppendLine(parseResult.MalformedData);
string message = parseResult.Message + Environment.NewLine + Environment.NewLine + FancyZonesEditor.Properties.Resources.Error_Parsing_Zones_Settings_User_Choice;
if (MessageBox.Show(message, FancyZonesEditor.Properties.Resources.Error_Parsing_Zones_Settings_Title, MessageBoxButton.YesNo) == MessageBoxResult.No)
{
// TODO: log error
ShowExceptionReportMessageBox(sb.ToString());
Environment.Exit(0);
}
ShowExceptionReportMessageBox(sb.ToString());
MessageBox.Show(parseResult.Message, FancyZonesEditor.Properties.Resources.Error_Parsing_Zones_Settings_Title, MessageBoxButton.OK);
}
MainWindowSettingsModel settings = ((App)Current).MainWindowSettings;

View File

@ -16,7 +16,12 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border x:Name="ThumbBorder" Opacity="0" BorderBrush="{DynamicResource SystemControlBackgroundAccentBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Border x:Name="ThumbBorder"
Opacity="0"
CornerRadius="0"
BorderBrush="{DynamicResource SystemControlBackgroundAccentBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates" >
<VisualStateGroup.Transitions>
@ -64,7 +69,9 @@
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsDefaulted" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource SystemControlBackgroundAccentBrush}"/>
<Setter Property="BorderBrush"
TargetName="border"
Value="{DynamicResource SystemControlBackgroundAccentBrush}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Opacity" TargetName="contentPresenter" Value="0.6"/>
@ -79,10 +86,9 @@
</Style>
</UserControl.Resources>
<Border BorderBrush="{DynamicResource LayoutPreviewZoneBorderBrush}"
<Border BorderBrush="{DynamicResource SystemControlBackgroundAccentBrush}"
Background="{DynamicResource CanvasZoneBackgroundBrush}"
CornerRadius="4"
Effect="{StaticResource ZoneDropShadow}"
CornerRadius="0"
BorderThickness="1">
<Grid x:Name="Frame">
<Grid.RowDefinitions>
@ -129,15 +135,15 @@
<Thumb x:Name="Caption" Cursor="SizeAll" Background="Transparent" BorderThickness="3" Padding="4" Grid.Column="0" Grid.ColumnSpan="5" Margin="-1" Grid.Row="0" Grid.RowSpan="5" DragDelta="UniversalDragDelta" DragStarted="Caption_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="NResize" Cursor="SizeNS" BorderThickness="0,3,0,0" Grid.ColumnSpan="5" DragDelta="UniversalDragDelta" DragStarted="NResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="SResize" Cursor="SizeNS" BorderThickness="0,0,0,3" Grid.Row="4" Grid.ColumnSpan="5" DragDelta="UniversalDragDelta" DragStarted="SResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="WResize" Cursor="SizeWE" BorderThickness="3,0,0,0" Grid.RowSpan="5" DragDelta="UniversalDragDelta" DragStarted="WResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="EResize" Cursor="SizeWE" BorderThickness="0,0,3,0" Grid.Column="4" Grid.RowSpan="5" DragDelta="UniversalDragDelta" DragStarted="EResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="NResize" Cursor="SizeNS" BorderThickness="0,2,0,0" Grid.ColumnSpan="5" DragDelta="UniversalDragDelta" DragStarted="NResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="SResize" Cursor="SizeNS" BorderThickness="0,0,0,2" Grid.Row="4" Grid.ColumnSpan="5" DragDelta="UniversalDragDelta" DragStarted="SResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="WResize" Cursor="SizeWE" BorderThickness="2,0,0,0" Grid.RowSpan="5" DragDelta="UniversalDragDelta" DragStarted="WResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="EResize" Cursor="SizeWE" BorderThickness="0,0,2,0" Grid.Column="4" Grid.RowSpan="5" DragDelta="UniversalDragDelta" DragStarted="EResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="NWResize" Cursor="SizeNWSE" BorderThickness="3,3,0,0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="2" DragDelta="UniversalDragDelta" DragStarted="NWResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="NEResize" Cursor="SizeNESW" BorderThickness="0,3,3,0" Grid.Row="0" Grid.Column="3" Grid.RowSpan="2" Grid.ColumnSpan="2" DragDelta="UniversalDragDelta" DragStarted="NEResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="SWResize" Cursor="SizeNESW" BorderThickness="3,0,0,3" Grid.Row="3" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="2" DragDelta="UniversalDragDelta" DragStarted="SWResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="SEResize" Cursor="SizeNWSE" BorderThickness="0,0,3,3" Grid.Row="3" Grid.Column="3" Grid.RowSpan="2" Grid.ColumnSpan="2" DragDelta="UniversalDragDelta" DragStarted="SEResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="NWResize" Cursor="SizeNWSE" BorderThickness="2,2,0,0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="2" DragDelta="UniversalDragDelta" DragStarted="NWResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="NEResize" Cursor="SizeNESW" BorderThickness="0,2,2,0" Grid.Row="0" Grid.Column="3" Grid.RowSpan="2" Grid.ColumnSpan="2" DragDelta="UniversalDragDelta" DragStarted="NEResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="SWResize" Cursor="SizeNESW" BorderThickness="2,0,0,2" Grid.Row="3" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="2" DragDelta="UniversalDragDelta" DragStarted="SWResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Thumb x:Name="SEResize" Cursor="SizeNWSE" BorderThickness="0,0,2,2" Grid.Row="3" Grid.Column="3" Grid.RowSpan="2" Grid.ColumnSpan="2" DragDelta="UniversalDragDelta" DragStarted="SEResize_DragStarted" Style="{DynamicResource CanvasZoneThumbStyle}"/>
<Button Content="&#xE894;"
BorderThickness="0"

View File

@ -71,7 +71,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.IO.Abstractions" Version="12.2.5" />
<PackageReference Include="System.Text.Json" Version="4.7.2" />
<PackageReference Include="System.Text.Json" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<Resource Include="images\FancyZonesEditor.ico" />

File diff suppressed because it is too large Load Diff

View File

@ -1,604 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using FancyZonesEditor.Models;
namespace FancyZonesEditor
{
public class GridDragHandles
{
public GridDragHandles(UIElementCollection resizers, Action<object, DragDeltaEventArgs> dragDelta, Action<object, DragCompletedEventArgs> dragCompleted)
{
_resizers = resizers;
_dragDelta = dragDelta;
_dragCompleted = dragCompleted;
}
public void InitDragHandles(GridLayoutModel model)
{
if (_resizers.Count == 0)
{
int[,] indices = model.CellChildMap;
// horizontal resizers
for (int row = 0; row < model.Rows - 1; row++)
{
for (int col = 0; col < model.Columns; col++)
{
if (indices[row, col] != indices[row + 1, col])
{
int endCol = col + 1;
while (endCol < model.Columns && indices[row, endCol] != indices[row + 1, endCol])
{
endCol++;
}
AddDragHandle(Orientation.Horizontal, row, row + 1, col, endCol, row);
col = endCol - 1;
}
}
}
// vertical resizers
for (int col = 0; col < model.Columns - 1; col++)
{
for (int row = 0; row < model.Rows; row++)
{
if (indices[row, col] != indices[row, col + 1])
{
int endRow = row + 1;
while (endRow < model.Rows && indices[endRow, col] != indices[endRow, col + 1])
{
endRow++;
}
AddDragHandle(Orientation.Vertical, row, endRow, col, col + 1, col + model.Rows - 1);
row = endRow - 1;
}
}
}
}
}
public void AddDragHandle(Orientation orientation, int foundRow, int foundCol, GridLayoutModel model)
{
int[,] indices = model.CellChildMap;
int endRow = foundRow + 1;
while (endRow < model.Rows && indices[endRow, foundCol] == indices[endRow - 1, foundCol])
{
endRow++;
}
int endCol = foundCol + 1;
while (endCol < model.Columns && indices[foundRow, endCol] == indices[foundRow, endCol - 1])
{
endCol++;
}
int index = (orientation == Orientation.Horizontal) ? foundRow : foundCol + model.Rows - 1;
AddDragHandle(orientation, foundRow, endRow, foundCol, endCol, index);
}
public void AddDragHandle(Orientation orientation, int rowStart, int rowEnd, int colStart, int colEnd, int index)
{
GridResizer resizer = new GridResizer
{
Orientation = orientation,
StartRow = rowStart,
EndRow = rowEnd,
StartCol = colStart,
EndCol = colEnd,
};
resizer.DragDelta += (obj, eventArgs) => _dragDelta(obj, eventArgs);
resizer.DragCompleted += (obj, eventArgs) => _dragCompleted(obj, eventArgs);
if (index > _resizers.Count)
{
index = _resizers.Count;
}
_resizers.Insert(index, resizer);
}
public void UpdateForExistingVerticalSplit(GridLayoutModel model, int foundRow, int splitCol)
{
Func<GridResizer, bool> cmpr = (GridResizer resizer) =>
{
return resizer.Orientation == Orientation.Vertical && resizer.StartCol == splitCol;
};
Func<GridResizer, bool> endCmpr = (GridResizer resizer) =>
{
return resizer.EndRow == foundRow;
};
Func<GridResizer, bool> startCmpr = (GridResizer resizer) =>
{
return resizer.StartRow == foundRow + 1;
};
if (!UpdateDragHandlerForExistingSplit(Orientation.Vertical, cmpr, endCmpr, startCmpr))
{
AddDragHandle(Orientation.Vertical, foundRow, splitCol, model);
}
}
public void UpdateForExistingHorizontalSplit(GridLayoutModel model, int splitRow, int foundCol)
{
Func<GridResizer, bool> cmpr = (GridResizer resizer) =>
{
return resizer.Orientation == Orientation.Horizontal && resizer.StartRow == splitRow;
};
Func<GridResizer, bool> endCmpr = (GridResizer resizer) =>
{
return resizer.EndCol == foundCol;
};
Func<GridResizer, bool> startCmpr = (GridResizer resizer) =>
{
return resizer.StartCol == foundCol + 1;
};
if (!UpdateDragHandlerForExistingSplit(Orientation.Horizontal, cmpr, endCmpr, startCmpr))
{
AddDragHandle(Orientation.Horizontal, splitRow, foundCol, model);
}
}
/**
* Has to be called on split before adding new drag handle
*/
public void UpdateAfterVerticalSplit(int foundCol)
{
foreach (GridResizer r in _resizers)
{
if (r.StartCol > foundCol || (r.StartCol == foundCol && r.Orientation == Orientation.Vertical))
{
r.StartCol++;
}
if (r.EndCol > foundCol)
{
r.EndCol++;
}
}
}
/**
* Has to be called on split before adding new drag handle
*/
public void UpdateAfterHorizontalSplit(int foundRow)
{
foreach (GridResizer r in _resizers)
{
if (r.StartRow > foundRow || (r.StartRow == foundRow && r.Orientation == Orientation.Horizontal))
{
r.StartRow++;
}
if (r.EndRow > foundRow)
{
r.EndRow++;
}
}
}
public void UpdateAfterSwap(GridResizer resizer, double delta)
{
Orientation orientation = resizer.Orientation;
bool isHorizontal = orientation == Orientation.Horizontal;
bool isDeltaNegative = delta < 0;
List<GridResizer> swappedResizers = new List<GridResizer>();
if (isDeltaNegative)
{
DecreaseResizerValues(resizer, orientation);
}
else
{
IncreaseResizerValues(resizer, orientation);
}
// same orientation resizers update
foreach (GridResizer r in _resizers)
{
if (r.Orientation == orientation)
{
if ((isHorizontal && r.StartRow == resizer.StartRow && r.StartCol != resizer.StartCol) ||
(!isHorizontal && r.StartCol == resizer.StartCol && r.StartRow != resizer.StartRow))
{
if (isDeltaNegative)
{
IncreaseResizerValues(r, orientation);
}
else
{
DecreaseResizerValues(r, orientation);
}
swappedResizers.Add(r);
}
}
}
// different orientation resizers update
foreach (GridResizer r in _resizers)
{
if (r.Orientation != resizer.Orientation)
{
if (isHorizontal)
{
// vertical resizers corresponding to dragged resizer
if (r.StartCol >= resizer.StartCol && r.EndCol < resizer.EndCol)
{
if (r.StartRow == resizer.StartRow + 2 && isDeltaNegative)
{
r.StartRow--;
}
if (r.EndRow == resizer.EndRow + 1 && isDeltaNegative)
{
r.EndRow--;
}
if (r.StartRow == resizer.StartRow && !isDeltaNegative)
{
r.StartRow++;
}
if (r.EndRow == resizer.EndRow - 1 && !isDeltaNegative)
{
r.EndRow++;
}
}
else
{
// vertical resizers corresponding to swapped resizers
foreach (GridResizer sr in swappedResizers)
{
if (r.StartCol >= sr.StartCol && r.EndCol <= sr.EndCol)
{
if (r.StartRow == resizer.StartRow + 1 && isDeltaNegative)
{
r.StartRow++;
}
if (r.EndRow == resizer.EndRow && isDeltaNegative)
{
r.EndRow++;
}
if (r.StartRow == resizer.StartRow + 1 && !isDeltaNegative)
{
r.StartRow--;
}
if (r.EndRow == resizer.EndRow && !isDeltaNegative)
{
r.EndRow--;
}
}
}
}
}
else
{
// horizontal resizers corresponding to dragged resizer
if (r.StartRow >= resizer.StartRow && r.EndRow < resizer.EndRow)
{
if (r.StartCol == resizer.StartCol + 3 && isDeltaNegative)
{
r.StartCol--;
}
if (r.EndCol == resizer.EndCol + 1 && isDeltaNegative)
{
r.EndCol--;
}
if (r.StartCol == resizer.StartCol && !isDeltaNegative)
{
r.StartCol++;
}
if (r.EndCol == resizer.EndCol - 1 && !isDeltaNegative)
{
r.EndCol++;
}
}
else
{
// horizontal resizers corresponding to swapped resizers
foreach (GridResizer sr in swappedResizers)
{
if (r.StartRow >= sr.StartRow && r.EndRow <= sr.EndRow)
{
if (r.StartCol == resizer.StartCol + 1 && isDeltaNegative)
{
r.StartCol++;
}
if (r.EndCol == resizer.EndCol && isDeltaNegative)
{
r.EndCol++;
}
if (r.StartCol == resizer.StartCol + 1 && !isDeltaNegative)
{
r.StartCol--;
}
if (r.EndCol == resizer.EndCol && !isDeltaNegative)
{
r.EndCol--;
}
}
}
}
}
}
}
}
public void UpdateAfterDetach(GridResizer resizer, double delta)
{
bool isDeltaNegative = delta < 0;
Orientation orientation = resizer.Orientation;
foreach (GridResizer r in _resizers)
{
bool notEqual = r.StartRow != resizer.StartRow || r.EndRow != resizer.EndRow || r.StartCol != resizer.StartCol || r.EndCol != resizer.EndCol;
if (r.Orientation == orientation && notEqual)
{
if (orientation == Orientation.Horizontal)
{
if (r.StartRow > resizer.StartRow || (r.StartRow == resizer.StartRow && isDeltaNegative))
{
r.StartRow++;
}
if (r.EndRow > resizer.EndRow || (r.EndRow == resizer.EndRow && isDeltaNegative))
{
r.EndRow++;
}
}
else
{
if (r.StartCol > resizer.StartCol || (r.StartCol == resizer.StartCol && isDeltaNegative))
{
r.StartCol++;
}
if (r.EndCol > resizer.EndCol || (r.EndCol == resizer.EndCol && isDeltaNegative))
{
r.EndCol++;
}
}
}
}
if (!isDeltaNegative)
{
IncreaseResizerValues(resizer, orientation);
}
foreach (GridResizer r in _resizers)
{
if (r.Orientation != orientation)
{
if (orientation == Orientation.Vertical)
{
if (isDeltaNegative)
{
bool isRowNonAdjacent = r.EndRow < resizer.StartRow || r.StartRow > resizer.EndRow;
if (r.StartCol > resizer.StartCol + 1 || (r.StartCol == resizer.StartCol + 1 && isRowNonAdjacent))
{
r.StartCol++;
}
if (r.EndCol > resizer.EndCol || (r.EndCol == resizer.EndCol && isRowNonAdjacent))
{
r.EndCol++;
}
}
else
{
if (r.StartCol > resizer.StartCol || (r.StartCol == resizer.StartCol && r.StartRow >= resizer.StartRow && r.EndRow <= resizer.EndRow))
{
r.StartCol++;
}
if (r.EndCol > resizer.EndCol - 1 || (r.EndCol == resizer.EndCol - 1 && r.StartRow >= resizer.StartRow && r.EndRow <= resizer.EndRow))
{
r.EndCol++;
}
}
}
else
{
if (isDeltaNegative)
{
bool isColNonAdjacent = r.EndCol < resizer.StartCol || r.StartCol > resizer.EndCol;
if (r.StartRow > resizer.StartRow + 1 || (r.StartRow == resizer.StartRow + 1 && isColNonAdjacent))
{
r.StartRow++;
}
if (r.EndRow > resizer.EndRow || (r.EndRow == resizer.EndRow && isColNonAdjacent))
{
r.EndRow++;
}
}
else
{
if (r.StartRow > resizer.StartRow || (r.StartRow == resizer.StartRow && r.StartCol >= resizer.StartCol && r.EndCol <= resizer.EndCol))
{
r.StartRow++;
}
if (r.EndRow > resizer.EndRow - 1 || (r.EndRow == resizer.EndRow - 1 && r.StartCol >= resizer.StartCol && r.EndCol <= resizer.EndCol))
{
r.EndRow++;
}
}
}
}
}
}
public void RemoveDragHandles()
{
_resizers.Clear();
}
public bool HasSnappedNonAdjacentResizers(GridResizer resizer)
{
/**
* Resizers between zones 0,1 and 4,5 are snapped to each other and not adjacent.
* ------------------------------
* | 0 | 1 |
* ------------------------------
* | 2 | 3 |
* ------------------------------
* | 4 | 5 |
* ------------------------------
*
* Resizers between zones 0,1 and 2,3 are snapped to each other and adjacent.
* ------------------------------
* | 0 | 1 |
* ------------------------------
* | 2 | 3 |
* ------------------------------
* | 4 | 5 |
* ------------------------------
*
* Vertical resizers should have same StartColumn and different StartRow.
* Horizontal resizers should have same StartRow and different StartColumn.
* Difference between rows or columns should be more than 1.
*/
foreach (GridResizer r in _resizers)
{
if (r.Orientation == resizer.Orientation)
{
bool isHorizontalSnapped = resizer.Orientation == Orientation.Horizontal && r.StartRow == resizer.StartRow && (Math.Abs(resizer.StartCol - r.StartCol) > 1);
bool isVerticalSnapped = resizer.Orientation == Orientation.Vertical && r.StartCol == resizer.StartCol && (Math.Abs(resizer.StartRow - r.StartRow) > 1);
if (isHorizontalSnapped || isVerticalSnapped)
{
return true;
}
}
}
return false;
}
private static void IncreaseResizerValues(GridResizer resizer, Orientation orientation)
{
if (orientation == Orientation.Vertical)
{
resizer.StartCol++;
resizer.EndCol++;
}
else
{
resizer.StartRow++;
resizer.EndRow++;
}
}
private static void DecreaseResizerValues(GridResizer resizer, Orientation orientation)
{
if (orientation == Orientation.Vertical)
{
resizer.StartCol--;
resizer.EndCol--;
}
else
{
resizer.StartRow--;
resizer.EndRow--;
}
}
private bool UpdateDragHandlerForExistingSplit(Orientation orientation, Func<GridResizer, bool> cmpr, Func<GridResizer, bool> endCmpr, Func<GridResizer, bool> startCmpr)
{
bool updCurrentResizers = false;
GridResizer leftNeighbour = null;
GridResizer rightNeighbour = null;
for (int i = 0; i < _resizers.Count && (leftNeighbour == null || rightNeighbour == null); i++)
{
GridResizer resizer = (GridResizer)_resizers[i];
if (cmpr(resizer))
{
if (leftNeighbour == null && endCmpr(resizer))
{
leftNeighbour = resizer;
updCurrentResizers = true;
}
if (rightNeighbour == null && startCmpr(resizer))
{
rightNeighbour = resizer;
updCurrentResizers = true;
}
}
}
if (updCurrentResizers)
{
if (leftNeighbour != null && rightNeighbour != null)
{
if (orientation == Orientation.Vertical)
{
leftNeighbour.EndRow = rightNeighbour.EndRow;
}
else
{
leftNeighbour.EndCol = rightNeighbour.EndCol;
}
_resizers.Remove(rightNeighbour);
}
else if (leftNeighbour != null)
{
if (orientation == Orientation.Vertical)
{
leftNeighbour.EndRow++;
}
else
{
leftNeighbour.EndCol++;
}
}
else if (rightNeighbour != null)
{
if (orientation == Orientation.Vertical)
{
rightNeighbour.StartRow--;
}
else
{
rightNeighbour.StartCol--;
}
}
}
return updCurrentResizers;
}
private readonly UIElementCollection _resizers;
private readonly Action<object, DragDeltaEventArgs> _dragDelta;
private readonly Action<object, DragCompletedEventArgs> _dragCompleted;
}
}

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@ -20,6 +21,9 @@ namespace FancyZonesEditor
private const string PropertyRowsChangedID = "Rows";
private const string PropertyColumnsChangedID = "Columns";
private const string ObjectDependencyID = "Model";
private const string PropertyIsShiftKeyPressedID = "IsShiftKeyPressed";
private const int MinZoneSize = 100;
public static readonly DependencyProperty ModelProperty = DependencyProperty.Register(ObjectDependencyID, typeof(GridLayoutModel), typeof(GridEditor), new PropertyMetadata(null, OnGridDimensionsChanged));
@ -27,13 +31,15 @@ namespace FancyZonesEditor
private int gridEditorUniqueId;
private GridData _data;
public GridEditor()
{
InitializeComponent();
Loaded += GridEditor_Loaded;
Unloaded += GridEditor_Unloaded;
((App)Application.Current).MainWindowSettings.PropertyChanged += ZoneSettings_PropertyChanged;
gridEditorUniqueId = ++gridEditorUniqueIdCounter;
((App)Application.Current).MainWindowSettings.PropertyChanged += ZoneSettings_PropertyChanged;
}
private void GridEditor_Loaded(object sender, RoutedEventArgs e)
@ -45,21 +51,127 @@ namespace FancyZonesEditor
}
_data = new GridData(model);
_dragHandles = new GridDragHandles(AdornerLayer.Children, Resizer_DragDelta, Resizer_DragCompleted);
_dragHandles.InitDragHandles(model);
Model = model;
Model.PropertyChanged += OnGridDimensionsChanged;
SetupUI();
}
int zoneCount = _data.ZoneCount;
for (int i = 0; i < zoneCount; i++)
private void PlaceResizer(GridResizer resizerThumb)
{
var leftZone = Preview.Children[resizerThumb.LeftReferenceZone];
var rightZone = Preview.Children[resizerThumb.RightReferenceZone];
var topZone = Preview.Children[resizerThumb.TopReferenceZone];
var bottomZone = Preview.Children[resizerThumb.BottomReferenceZone];
double left = Canvas.GetLeft(leftZone);
double right = Canvas.GetLeft(rightZone) + (rightZone as GridZone).MinWidth;
double top = Canvas.GetTop(topZone);
double bottom = Canvas.GetTop(bottomZone) + (bottomZone as GridZone).MinHeight;
double x = (left + right) / 2.0;
double y = (top + bottom) / 2.0;
Canvas.SetLeft(resizerThumb, x - 24);
Canvas.SetTop(resizerThumb, y - 24);
}
private void SetZonePanelSize(GridZone panel, GridData.Zone zone)
{
Size actualSize = WorkAreaSize();
double spacing = Model.ShowSpacing ? Model.Spacing : 0;
double topSpacing = zone.Top == 0 ? spacing : spacing / 2;
double bottomSpacing = zone.Bottom == GridData.Multiplier ? spacing : spacing / 2;
double leftSpacing = zone.Left == 0 ? spacing : spacing / 2;
double rightSpacing = zone.Right == GridData.Multiplier ? spacing : spacing / 2;
Canvas.SetTop(panel, (actualSize.Height * zone.Top / GridData.Multiplier) + topSpacing);
Canvas.SetLeft(panel, (actualSize.Width * zone.Left / GridData.Multiplier) + leftSpacing);
panel.MinWidth = Math.Max(1, (actualSize.Width * (zone.Right - zone.Left) / GridData.Multiplier) - leftSpacing - rightSpacing);
panel.MinHeight = Math.Max(1, (actualSize.Height * (zone.Bottom - zone.Top) / GridData.Multiplier) - topSpacing - bottomSpacing);
}
private void SetupUI()
{
Size actualSize = WorkAreaSize();
if (actualSize.Width < 1 || _data == null || Model == null)
{
AddZone();
return;
}
Rect workingArea = App.Overlay.WorkArea;
Size actualSize = new Size(workingArea.Width, workingArea.Height);
ArrangeGridRects(actualSize);
int spacing = Model.ShowSpacing ? Model.Spacing : 0;
_data.MinZoneWidth = Convert.ToInt32(GridData.Multiplier / actualSize.Width * (MinZoneSize + (2 * spacing)));
_data.MinZoneHeight = Convert.ToInt32(GridData.Multiplier / actualSize.Height * (MinZoneSize + (2 * spacing)));
Preview.Children.Clear();
AdornerLayer.Children.Clear();
Preview.Width = actualSize.Width;
Preview.Height = actualSize.Height;
MagneticSnap snapX = new MagneticSnap(GridData.PrefixSum(Model.ColumnPercents).GetRange(1, Model.ColumnPercents.Count - 1), actualSize.Width);
MagneticSnap snapY = new MagneticSnap(GridData.PrefixSum(Model.RowPercents).GetRange(1, Model.RowPercents.Count - 1), actualSize.Height);
for (int zoneIndex = 0; zoneIndex < _data.Zones.Count(); zoneIndex++)
{
// this is needed for the lambda
int zoneIndexCopy = zoneIndex;
var zone = _data.Zones[zoneIndex];
var zonePanel = new GridZone(spacing, snapX, snapY, (orientation, offset) => _data.CanSplit(zoneIndexCopy, offset, orientation), zone);
zonePanel.UpdateShiftState(((App)Application.Current).MainWindowSettings.IsShiftKeyPressed);
Preview.Children.Add(zonePanel);
zonePanel.Split += OnSplit;
zonePanel.MergeDrag += OnMergeDrag;
zonePanel.MergeComplete += OnMergeComplete;
SetZonePanelSize(zonePanel, zone);
zonePanel.LabelID.Content = zoneIndex + 1;
}
foreach (var resizer in _data.Resizers)
{
var resizerThumb = new GridResizer();
resizerThumb.DragStarted += Resizer_DragStarted;
resizerThumb.DragDelta += Resizer_DragDelta;
resizerThumb.DragCompleted += Resizer_DragCompleted;
resizerThumb.Orientation = resizer.Orientation;
AdornerLayer.Children.Add(resizerThumb);
if (resizer.Orientation == Orientation.Horizontal)
{
resizerThumb.LeftReferenceZone = resizer.PositiveSideIndices[0];
resizerThumb.RightReferenceZone = resizer.PositiveSideIndices.Last();
resizerThumb.TopReferenceZone = resizer.PositiveSideIndices[0];
resizerThumb.BottomReferenceZone = resizer.NegativeSideIndices[0];
}
else
{
resizerThumb.LeftReferenceZone = resizer.PositiveSideIndices[0];
resizerThumb.RightReferenceZone = resizer.NegativeSideIndices[0];
resizerThumb.TopReferenceZone = resizer.PositiveSideIndices[0];
resizerThumb.BottomReferenceZone = resizer.PositiveSideIndices.Last();
}
PlaceResizer(resizerThumb);
}
}
private void OnSplit(object sender, SplitEventArgs args)
{
MergeCancelClick(null, null);
var zonePanel = sender as GridZone;
int zoneIndex = Preview.Children.IndexOf(zonePanel);
if (_data.CanSplit(zoneIndex, args.Offset, args.Orientation))
{
_data.Split(zoneIndex, args.Offset, args.Orientation);
SetupUI();
}
}
private void GridEditor_Unloaded(object sender, RoutedEventArgs e)
@ -67,16 +179,10 @@ namespace FancyZonesEditor
gridEditorUniqueId = -1;
}
private void ZoneSettings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
private Size WorkAreaSize()
{
Rect workingArea = App.Overlay.WorkArea;
Size actualSize = new Size(workingArea.Width, workingArea.Height);
// Only enter if this is the newest instance
if (actualSize.Width > 0 && gridEditorUniqueId == gridEditorUniqueIdCounter)
{
ArrangeGridRects(actualSize);
}
return new Size(workingArea.Width, workingArea.Height);
}
public GridLayoutModel Model
@ -90,258 +196,6 @@ namespace FancyZonesEditor
get { return Preview; }
}
private void OnFullSplit(object o, SplitEventArgs e)
{
UIElementCollection previewChildren = Preview.Children;
UIElement splitee = (UIElement)o;
GridLayoutModel model = Model;
int spliteeIndex = previewChildren.IndexOf(splitee);
int rows = model.Rows;
int cols = model.Columns;
_startRow = -1;
_startCol = -1;
for (int row = rows - 1; row >= 0; row--)
{
for (int col = cols - 1; col >= 0; col--)
{
if (model.CellChildMap[row, col] == spliteeIndex)
{
_dragHandles.RemoveDragHandles();
_startRow = _endRow = row;
_startCol = _endCol = col;
ExtendRangeToHaveEvenCellEdges();
for (row = _startRow; row <= _endRow; row++)
{
for (col = _startCol; col <= _endCol; col++)
{
if ((row != _startRow) || (col != _startCol))
{
model.CellChildMap[row, col] = AddZone();
}
}
}
OnGridDimensionsChanged();
return;
}
}
}
}
private void ExtendRangeToHaveEvenCellEdges()
{
// As long as there is an edge of the 2D range such that some zone crosses its boundary, extend
// that boundary. A single pass is not enough, a while loop is needed. This results in the unique
// smallest rectangle containing the initial range such that no zone is "broken", meaning that
// some part of it is inside the 2D range, and some part is outside.
GridLayoutModel model = Model;
bool possiblyBroken = true;
while (possiblyBroken)
{
possiblyBroken = false;
for (int col = _startCol; col <= _endCol; col++)
{
if (_startRow > 0 && model.CellChildMap[_startRow - 1, col] == model.CellChildMap[_startRow, col])
{
_startRow--;
possiblyBroken = true;
break;
}
if (_endRow < model.Rows - 1 && model.CellChildMap[_endRow + 1, col] == model.CellChildMap[_endRow, col])
{
_endRow++;
possiblyBroken = true;
break;
}
}
for (int row = _startRow; row <= _endRow; row++)
{
if (_startCol > 0 && model.CellChildMap[row, _startCol - 1] == model.CellChildMap[row, _startCol])
{
_startCol--;
possiblyBroken = true;
break;
}
if (_endCol < model.Columns - 1 && model.CellChildMap[row, _endCol + 1] == model.CellChildMap[row, _endCol])
{
_endCol++;
possiblyBroken = true;
break;
}
}
}
}
private void OnSplit(object o, SplitEventArgs e)
{
MergeCancelClick(null, null);
UIElementCollection previewChildren = Preview.Children;
GridZone splitee = (GridZone)o;
int spliteeIndex = previewChildren.IndexOf(splitee);
GridLayoutModel model = Model;
int rows = model.Rows;
int cols = model.Columns;
Tuple<int, int> rowCol = _data.RowColByIndex(spliteeIndex);
int foundRow = rowCol.Item1;
int foundCol = rowCol.Item2;
int newChildIndex = AddZone();
double offset = e.Offset;
double space = e.Space;
if (e.Orientation == Orientation.Vertical)
{
if (splitee.VerticalSnapPoints != null)
{
offset += Canvas.GetLeft(splitee);
int count = splitee.VerticalSnapPoints.Length;
bool foundExistingSplit = false;
int splitCol = foundCol;
for (int i = 0; i <= count; i++)
{
if (foundExistingSplit)
{
int walkRow = foundRow;
while ((walkRow < rows) && (_data.GetIndex(walkRow, foundCol + i) == spliteeIndex))
{
_data.SetIndex(walkRow++, foundCol + i, newChildIndex);
}
}
if (_data.ColumnBottom(foundCol + i) == offset)
{
foundExistingSplit = true;
splitCol = foundCol + i;
// use existing division
}
}
if (foundExistingSplit)
{
_data.ReplaceIndicesToMaintainOrder(Preview.Children.Count);
_dragHandles.UpdateForExistingVerticalSplit(model, foundRow, splitCol);
OnGridDimensionsChanged();
return;
}
while (_data.ColumnBottom(foundCol) < offset)
{
foundCol++;
}
offset -= _data.ColumnTop(foundCol);
}
_dragHandles.UpdateAfterVerticalSplit(foundCol);
_data.SplitColumn(foundCol, spliteeIndex, newChildIndex, space, offset, App.Overlay.WorkArea.Width);
_dragHandles.AddDragHandle(Orientation.Vertical, foundRow, foundCol, model);
}
else
{
// Horizontal
if (splitee.HorizontalSnapPoints != null)
{
offset += Canvas.GetTop(splitee);
int count = splitee.HorizontalSnapPoints.Length;
bool foundExistingSplit = false;
int splitRow = foundRow;
for (int i = 0; i <= count; i++)
{
if (foundExistingSplit)
{
int walkCol = foundCol;
while ((walkCol < cols) && (_data.GetIndex(foundRow + i, walkCol) == spliteeIndex))
{
_data.SetIndex(foundRow + i, walkCol++, newChildIndex);
}
}
if (_data.RowEnd(foundRow + i) == offset)
{
foundExistingSplit = true;
splitRow = foundRow + i;
// use existing division
}
}
if (foundExistingSplit)
{
_data.ReplaceIndicesToMaintainOrder(Preview.Children.Count);
_dragHandles.UpdateForExistingHorizontalSplit(model, splitRow, foundCol);
OnGridDimensionsChanged();
return;
}
while (_data.RowEnd(foundRow) < offset)
{
foundRow++;
}
offset -= _data.RowStart(foundRow);
}
_dragHandles.UpdateAfterHorizontalSplit(foundRow);
_data.SplitRow(foundRow, spliteeIndex, newChildIndex, space, offset, App.Overlay.WorkArea.Height);
_dragHandles.AddDragHandle(Orientation.Horizontal, foundRow, foundCol, model);
}
var workArea = App.Overlay.WorkArea;
Size actualSize = new Size(workArea.Width, workArea.Height);
ArrangeGridRects(actualSize);
}
private void DeleteZone(int index)
{
Preview.Children.RemoveAt(index);
}
private int AddZone()
{
GridZone zone;
if (Model != null)
{
IList<int> freeZones = Model.FreeZones;
// first check free list
if (freeZones.Count > 0)
{
int freeIndex = freeZones[0];
freeZones.RemoveAt(0);
zone = (GridZone)Preview.Children[freeIndex];
zone.Visibility = Visibility.Visible;
return freeIndex;
}
zone = new GridZone(Model.ShowSpacing ? Model.Spacing : 0);
zone.Split += OnSplit;
zone.MergeDrag += OnMergeDrag;
zone.MergeComplete += OnMergeComplete;
zone.FullSplit += OnFullSplit;
Preview.Children.Add(zone);
return Preview.Children.Count - 1;
}
return 0;
}
private void OnGridDimensionsChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
// Only enter if this is the newest instance
@ -351,230 +205,201 @@ namespace FancyZonesEditor
}
}
private void ZoneSettings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if ((e.PropertyName == PropertyIsShiftKeyPressedID) && gridEditorUniqueId == gridEditorUniqueIdCounter)
{
foreach (var child in Preview.Children)
{
var zone = child as GridZone;
zone.UpdateShiftState(((App)Application.Current).MainWindowSettings.IsShiftKeyPressed);
}
}
}
private static void OnGridDimensionsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((GridEditor)d).OnGridDimensionsChanged();
((GridEditor)d).SetupUI();
}
private void OnGridDimensionsChanged()
{
Rect workingArea = App.Overlay.WorkArea;
Size actualSize = new Size(workingArea.Width, workingArea.Height);
if (actualSize.Width > 0)
{
ArrangeGridRects(actualSize);
}
SetupUI();
}
private void ArrangeGridRects(Size arrangeSize)
private double _dragX = 0;
private double _dragY = 0;
private void Resizer_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
{
var workArea = App.Overlay.WorkArea;
Preview.Width = workArea.Width;
Preview.Height = workArea.Height;
GridLayoutModel model = Model;
if (model == null || _data == null)
{
return;
}
if (model.Rows != model.RowPercents.Count || model.Columns != model.ColumnPercents.Count)
{
// Merge was not finished
return;
}
int spacing = model.ShowSpacing ? model.Spacing : 0;
_data.RecalculateZones(spacing, arrangeSize);
_data.ArrangeZones(Preview.Children, spacing);
_dragHandles.InitDragHandles(model);
_data.ArrangeResizers(AdornerLayer.Children, spacing);
_dragX = 0;
_dragY = 0;
}
private void Resizer_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
MergeCancelClick(null, null);
GridResizer resizer = (GridResizer)sender;
_dragX += e.HorizontalChange;
_dragY += e.VerticalChange;
double delta = (resizer.Orientation == Orientation.Vertical) ? e.HorizontalChange : e.VerticalChange;
if (delta == 0)
GridResizer resizer = (GridResizer)sender;
int resizerIndex = AdornerLayer.Children.IndexOf(resizer);
Size actualSize = WorkAreaSize();
int delta;
if (resizer.Orientation == Orientation.Vertical)
{
return;
delta = Convert.ToInt32(_dragX / actualSize.Width * GridData.Multiplier);
}
else
{
delta = Convert.ToInt32(_dragY / actualSize.Height * GridData.Multiplier);
}
GridData.ResizeInfo resizeInfo = _data.CalculateResizeInfo(resizer, delta);
if (resizeInfo.IsResizeAllowed)
if (_data.CanDrag(resizerIndex, delta))
{
if (_dragHandles.HasSnappedNonAdjacentResizers(resizer))
// Just update the UI, don't tell _data
if (resizer.Orientation == Orientation.Vertical)
{
double spacing = 0;
GridLayoutModel model = Model;
if (model.ShowSpacing)
_data.Resizers[resizerIndex].PositiveSideIndices.ForEach((zoneIndex) =>
{
spacing = model.Spacing;
}
var zone = Preview.Children[zoneIndex];
Canvas.SetLeft(zone, Canvas.GetLeft(zone) + e.HorizontalChange);
(zone as GridZone).MinWidth -= e.HorizontalChange;
});
_data.SplitOnDrag(resizer, delta, spacing);
_dragHandles.UpdateAfterDetach(resizer, delta);
_data.Resizers[resizerIndex].NegativeSideIndices.ForEach((zoneIndex) =>
{
var zone = Preview.Children[zoneIndex];
Canvas.SetRight(zone, Canvas.GetRight(zone) + e.HorizontalChange);
(zone as GridZone).MinWidth += e.HorizontalChange;
});
Canvas.SetLeft(resizer, Canvas.GetLeft(resizer) + e.HorizontalChange);
}
else
{
_data.DragResizer(resizer, resizeInfo);
if (_data.SwapNegativePercents(resizer.Orientation, resizer.StartRow, resizer.EndRow, resizer.StartCol, resizer.EndCol))
_data.Resizers[resizerIndex].PositiveSideIndices.ForEach((zoneIndex) =>
{
_dragHandles.UpdateAfterSwap(resizer, delta);
var zone = Preview.Children[zoneIndex];
Canvas.SetTop(zone, Canvas.GetTop(zone) + e.VerticalChange);
(zone as GridZone).MinHeight -= e.VerticalChange;
});
_data.Resizers[resizerIndex].NegativeSideIndices.ForEach((zoneIndex) =>
{
var zone = Preview.Children[zoneIndex];
Canvas.SetBottom(zone, Canvas.GetBottom(zone) + e.VerticalChange);
(zone as GridZone).MinHeight += e.VerticalChange;
});
Canvas.SetTop(resizer, Canvas.GetTop(resizer) + e.VerticalChange);
}
foreach (var child in AdornerLayer.Children)
{
GridResizer resizerThumb = child as GridResizer;
if (resizerThumb != resizer)
{
PlaceResizer(resizerThumb);
}
}
}
Rect workingArea = App.Overlay.WorkArea;
Size actualSize = new Size(workingArea.Width, workingArea.Height);
ArrangeGridRects(actualSize);
AdornerLayer.UpdateLayout();
else
{
// Undo changes
_dragX -= e.HorizontalChange;
_dragY -= e.VerticalChange;
}
}
private void Resizer_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
{
GridResizer resizer = (GridResizer)sender;
int index = _data.SwappedIndexAfterResize(resizer);
if (index != -1)
{
Rect workingArea = App.Overlay.WorkArea;
Size actualSize = new Size(workingArea.Width, workingArea.Height);
ArrangeGridRects(actualSize);
}
}
int resizerIndex = AdornerLayer.Children.IndexOf(resizer);
Size actualSize = WorkAreaSize();
private Point _startDragPos = new Point(-1, -1);
double pixelDelta = resizer.Orientation == Orientation.Vertical ?
_dragX / actualSize.Width * GridData.Multiplier :
_dragY / actualSize.Height * GridData.Multiplier;
_data.Drag(resizerIndex, Convert.ToInt32(pixelDelta));
SetupUI();
}
private void OnMergeComplete(object o, MouseButtonEventArgs e)
{
Point mousePoint = e.GetPosition(Preview);
_startDragPos = new Point(-1, -1);
_inMergeDrag = false;
int mergedIndex = Model.CellChildMap[_startRow, _startCol];
for (int row = _startRow; row <= _endRow; row++)
var selectedIndices = new List<int>();
for (int zoneIndex = 0; zoneIndex < _data.Zones.Count; zoneIndex++)
{
for (int col = _startCol; col <= _endCol; col++)
if ((Preview.Children[zoneIndex] as GridZone).IsSelected)
{
if (Model.CellChildMap[row, col] != mergedIndex)
{
// selection is more than one cell, merge is valid
MergePanel.Visibility = Visibility.Visible;
Canvas.SetTop(MergeButtons, mousePoint.Y);
Canvas.SetLeft(MergeButtons, mousePoint.X);
return;
}
selectedIndices.Add(zoneIndex);
}
}
// merge is only one zone. cancel merge;
ClearSelection();
if (selectedIndices.Count <= 1)
{
ClearSelection();
}
else
{
Point mousePoint = e.GetPosition(Preview);
MergePanel.Visibility = Visibility.Visible;
Canvas.SetLeft(MergeButtons, mousePoint.X);
Canvas.SetTop(MergeButtons, mousePoint.Y);
}
}
private bool _inMergeDrag;
private Point _mergeDragStart;
private void OnMergeDrag(object o, MouseEventArgs e)
{
if (_startDragPos.X == -1)
Point dragPosition = e.GetPosition(Preview);
Size actualSize = WorkAreaSize();
if (!_inMergeDrag)
{
_startDragPos = e.GetPosition(Preview);
_inMergeDrag = true;
_mergeDragStart = dragPosition;
}
GridLayoutModel model = Model;
// Find the new zone, if any
int dataLowX = Convert.ToInt32(Math.Min(_mergeDragStart.X, dragPosition.X) / actualSize.Width * GridData.Multiplier);
int dataHighX = Convert.ToInt32(Math.Max(_mergeDragStart.X, dragPosition.X) / actualSize.Width * GridData.Multiplier);
int dataLowY = Convert.ToInt32(Math.Min(_mergeDragStart.Y, dragPosition.Y) / actualSize.Height * GridData.Multiplier);
int dataHighY = Convert.ToInt32(Math.Max(_mergeDragStart.Y, dragPosition.Y) / actualSize.Height * GridData.Multiplier);
if (_startDragPos.X != -1)
var selectedIndices = new List<int>();
for (int zoneIndex = 0; zoneIndex < _data.Zones.Count(); zoneIndex++)
{
Point dragPos = e.GetPosition(Preview);
_startRow = -1;
_endRow = -1;
_startCol = -1;
_endCol = -1;
var zoneData = _data.Zones[zoneIndex];
int rows = model.Rows;
int cols = model.Columns;
bool selected = Math.Max(zoneData.Left, dataLowX) <= Math.Min(zoneData.Right, dataHighX) &&
Math.Max(zoneData.Top, dataLowY) <= Math.Min(zoneData.Bottom, dataHighY);
double minX, maxX;
if (dragPos.X < _startDragPos.X)
// Check whether the zone intersects the selected rectangle
(Preview.Children[zoneIndex] as GridZone).IsSelected = selected;
if (selected)
{
minX = dragPos.X;
maxX = _startDragPos.X;
selectedIndices.Add(zoneIndex);
}
else
{
minX = _startDragPos.X;
maxX = dragPos.X;
}
double minY, maxY;
if (dragPos.Y < _startDragPos.Y)
{
minY = dragPos.Y;
maxY = _startDragPos.Y;
}
else
{
minY = _startDragPos.Y;
maxY = dragPos.Y;
}
for (int row = 0; row < rows; row++)
{
if (_startRow == -1)
{
if (_data.RowEnd(row) > minY)
{
_startRow = row;
}
}
else if (_data.RowStart(row) > maxY)
{
_endRow = row - 1;
break;
}
}
if ((_startRow >= 0) && (_endRow == -1))
{
_endRow = rows - 1;
}
for (int col = 0; col < cols; col++)
{
if (_startCol == -1)
{
if (_data.ColumnBottom(col) > minX)
{
_startCol = col;
}
}
else if (_data.ColumnTop(col) > maxX)
{
_endCol = col - 1;
break;
}
}
if ((_startCol >= 0) && (_endCol == -1))
{
_endCol = cols - 1;
}
ExtendRangeToHaveEvenCellEdges();
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < cols; col++)
{
((GridZone)Preview.Children[model.CellChildMap[row, col]]).IsSelected = (row >= _startRow) && (row <= _endRow) && (col >= _startCol) && (col <= _endCol);
}
}
e.Handled = true;
}
OnPreviewMouseMove(e);
// Compute the closure
_data.MergeClosureIndices(selectedIndices).ForEach((zoneIndex) =>
{
(Preview.Children[zoneIndex] as GridZone).IsSelected = true;
});
}
private void ClearSelection()
@ -583,22 +408,27 @@ namespace FancyZonesEditor
{
((GridZone)zone).IsSelected = false;
}
_inMergeDrag = false;
}
private void MergeClick(object sender, RoutedEventArgs e)
{
MergePanel.Visibility = Visibility.Collapsed;
Action<int> deleteAction = (index) =>
{
DeleteZone(index);
};
_data.MergeZones(_startRow, _endRow, _startCol, _endCol, deleteAction, Preview.Children.Count);
_dragHandles.RemoveDragHandles();
_dragHandles.InitDragHandles(Model);
var selectedIndices = new List<int>();
for (int zoneIndex = 0; zoneIndex < _data.Zones.Count(); zoneIndex++)
{
if ((Preview.Children[zoneIndex] as GridZone).IsSelected)
{
selectedIndices.Add(zoneIndex);
}
}
OnGridDimensionsChanged();
ClearSelection();
_data.DoMerge(selectedIndices);
SetupUI();
}
private void MergeCancelClick(object sender, RoutedEventArgs e)
@ -615,17 +445,9 @@ namespace FancyZonesEditor
protected override Size ArrangeOverride(Size arrangeBounds)
{
Size returnSize = base.ArrangeOverride(arrangeBounds);
ArrangeGridRects(arrangeBounds);
SetupUI();
return returnSize;
}
private GridData _data;
private GridDragHandles _dragHandles;
private int _startRow = -1;
private int _endRow = -1;
private int _startCol = -1;
private int _endCol = -1;
}
}

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