mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-22 05:51:30 -06:00
83450aef7b
* Add @CodingWonders to the About page for his contribution and determination to make WinUtil (and MicroWin) the best software it can be! * Remove the 'LogoSize' Parameter for About page - Make every sponsor in the sponsors list a link to ChrisTitusTech's Sponsors web link * Change Theme Option name from 'ConfigTabButtonFontSize' to 'ConfigUpdateButtonFontSize' - Lower its value from 16 to 14 * Change Theme Option name from 'FontSizeHeading' to 'HeadingFontSize' for consistency * Update 'LinkForegroundColor' for Light Theme to be lighter which'll make link hover color more noticeable * Update 'Show-CustomDialog' Private Function - Made a lot of theming/styling choices for Custom Dialogs exposed as parameters. - Update the documentation for these new parameters in 'Show-CustomDialog' Function. - Add a Link Hover Effect using 'Add_EVENT' methods (This can be tweaks/tuned-down if needed). - Made use of 'Title' Parameter for 'Show-CustomDialog' Function inside 'scripts/main.ps1' script, to change Dialog Window Title. - Now you can change the Logo Size of WinUtil through the 'LogoSize' Theming Option (the option was there, but not used in implementation). * Preprocessing result * Fix Settings Popup not closing after losing focus - Add trivial null checks for better debugging of UI code * Remove unnecessary whitespace indentation in 'main.ps1' script * Add a new 'Invoke-WPFPopup' Function to Better Handle Showing/Hiding/Toggling of Popups * Improve 'Invoke-WPFPopup' by @MyDrift-user Thanks for the improvements :) --------- Co-authored-by: MyDrift <personal@mdiana.ch> Co-authored-by: Chris Titus <contact@christitus.com>
55 lines
1.7 KiB
PowerShell
55 lines
1.7 KiB
PowerShell
function Invoke-WPFPopup {
|
|
param (
|
|
[ValidateSet("Show", "Hide", "Toggle")]
|
|
[string]$Action = "",
|
|
|
|
[string[]]$Popups = @(),
|
|
|
|
[ValidateScript({
|
|
$invalid = $_.GetEnumerator() | Where-Object { $_.Value -notin @("Show", "Hide", "Toggle") }
|
|
if ($invalid) {
|
|
throw "Found invalid Popup-Action pair(s): " + ($invalid | ForEach-Object { "$($_.Key) = $($_.Value)" } -join "; ")
|
|
}
|
|
$true
|
|
})]
|
|
[hashtable]$PopupActionTable = @{}
|
|
)
|
|
|
|
if (-not $PopupActionTable.Count -and (-not $Action -or -not $Popups.Count)) {
|
|
throw "Provide either 'PopupActionTable' or both 'Action' and 'Popups'."
|
|
}
|
|
|
|
if ($PopupActionTable.Count -and ($Action -or $Popups.Count)) {
|
|
throw "Use 'PopupActionTable' on its own, or 'Action' with 'Popups'."
|
|
}
|
|
|
|
# Collect popups and actions
|
|
$PopupsToProcess = if ($PopupActionTable.Count) {
|
|
$PopupActionTable.GetEnumerator() | ForEach-Object { [PSCustomObject]@{ Name = "$($_.Key)Popup"; Action = $_.Value } }
|
|
} else {
|
|
$Popups | ForEach-Object { [PSCustomObject]@{ Name = "$_`Popup"; Action = $Action } }
|
|
}
|
|
|
|
$PopupsNotFound = @()
|
|
|
|
# Apply actions
|
|
foreach ($popupEntry in $PopupsToProcess) {
|
|
$popupName = $popupEntry.Name
|
|
|
|
if (-not $sync.$popupName) {
|
|
$PopupsNotFound += $popupName
|
|
continue
|
|
}
|
|
|
|
$sync.$popupName.IsOpen = switch ($popupEntry.Action) {
|
|
"Show" { $true }
|
|
"Hide" { $false }
|
|
"Toggle" { -not $sync.$popupName.IsOpen }
|
|
}
|
|
}
|
|
|
|
if ($PopupsNotFound.Count -gt 0) {
|
|
throw "Could not find the following popups: $($PopupsNotFound -join ', ')"
|
|
}
|
|
}
|