pi-win-notify 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/extensions/host.ps1 +14 -6
- package/package.json +1 -1
package/README.md
CHANGED
package/README.zh.md
CHANGED
package/extensions/host.ps1
CHANGED
|
@@ -6,7 +6,7 @@ function l($m) { try { "$m" | Out-File -Append -Encoding utf8 $log } catch {} }
|
|
|
6
6
|
|
|
7
7
|
l '[host-start]'
|
|
8
8
|
|
|
9
|
-
Add-Type -AssemblyName PresentationFramework,PresentationCore,WindowsBase,System.Windows.Forms
|
|
9
|
+
Add-Type -AssemblyName PresentationFramework,PresentationCore,WindowsBase,System.Windows.Forms,System.Drawing
|
|
10
10
|
l '[host-assemblies-ok]'
|
|
11
11
|
|
|
12
12
|
# PF: 切回终端
|
|
@@ -246,15 +246,23 @@ function Show-Notify($data) {
|
|
|
246
246
|
|
|
247
247
|
$cursor = [System.Windows.Forms.Cursor]::Position
|
|
248
248
|
$screen = [System.Windows.Forms.Screen]::FromPoint($cursor)
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
$
|
|
249
|
+
# WinForms WorkingArea 是物理像素;WPF Window 坐标是设备无关像素 (DIP, 1/96in)。
|
|
250
|
+
# 高分屏 (150%+/200%+) 下必须除以 DPI 缩放比。
|
|
251
|
+
# 注意:PowerShell 宿主中 SystemParameters.DpiX 返回 0,必须用 System.Drawing。
|
|
252
|
+
$gfx = [System.Drawing.Graphics]::FromHwnd([System.IntPtr]::Zero)
|
|
253
|
+
try {
|
|
254
|
+
$dpiScaleX = $gfx.DpiX / 96.0
|
|
255
|
+
$dpiScaleY = $gfx.DpiY / 96.0
|
|
256
|
+
} finally { $gfx.Dispose() }
|
|
257
|
+
$waL = $screen.WorkingArea.Left / $dpiScaleX
|
|
258
|
+
$waT = $screen.WorkingArea.Top / $dpiScaleY
|
|
259
|
+
$waW = $screen.WorkingArea.Width / $dpiScaleX
|
|
260
|
+
$waH = $screen.WorkingArea.Height / $dpiScaleY
|
|
253
261
|
$count = inc-stack
|
|
254
262
|
$offset = ($count - 1) * 128
|
|
255
263
|
$win.Left = $waL + $waW - $win.Width - 20
|
|
256
264
|
$win.Top = $waT + $waH - $win.Height - 10 - $offset
|
|
257
|
-
l "[ps-stack] count=$count offset=$offset"
|
|
265
|
+
l "[ps-stack] count=$count offset=$offset dpiScaleX=$dpiScaleX dpiScaleY=$dpiScaleY"
|
|
258
266
|
|
|
259
267
|
$timer = New-Object System.Windows.Threading.DispatcherTimer
|
|
260
268
|
$timer.Interval = [TimeSpan]::FromSeconds($timeout)
|