From 9136ed98020b98f6c51b583fc1b5609a31844356 Mon Sep 17 00:00:00 2001 From: Martin Wiethan <47688561+Marterich@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:32:41 +0200 Subject: [PATCH] Fix: Window Statechange on doubleclick works everywhere (#2768) * Run the Doubleclick action only on Grid and Stackpanel and cleanup the logic * Remove ternary operator because it is only supported for powershell 7+ --- scripts/main.ps1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 28bf9525..0a0c566b 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -255,10 +255,14 @@ $sync["Form"].Add_MouseLeftButtonDown({ }) $sync["Form"].Add_MouseDoubleClick({ - if ($sync["Form"].WindowState -eq [Windows.WindowState]::Normal) { - $sync["Form"].WindowState = [Windows.WindowState]::Maximized; - } else { - $sync["Form"].WindowState = [Windows.WindowState]::Normal; + if ($_.OriginalSource -is [System.Windows.Controls.Grid] -or + $_.OriginalSource -is [System.Windows.Controls.StackPanel]) { + if ($sync["Form"].WindowState -eq [Windows.WindowState]::Normal){ + $sync["Form"].WindowState = [Windows.WindowState]::Maximized + } + else{ + $sync["Form"].WindowState = [Windows.WindowState]::Normal + } } })