fresh2dev / AnyBox

The easiest way to develop apps for Windows.
MIT License
215 stars 22 forks source link

Missing Messages And Comments With Version 0.5.0 Using New-Object #21

Closed IanBAdams closed 2 years ago

IanBAdams commented 2 years ago

I've just been testing my scripts against version 0.5.0. All was fine until I tested the one script I have which uses New-Object rather than Show-AnyBox followed by parameters. This script works fine with version 0.4.0 but with version 0.5.0 the Messages and Comments are missing.

I've enclosed a simplified version of the AnyBox code below: Import-Module AnyBox $AnyBox = New-Object AnyBox.AnyBox $DevicesList = @('PC-ELAINE','PC-IAN','PC-RICHARD','PC-SAMANTHA')

$AnyBox.Prompts = @( New-AnyBoxPrompt -InputType Text -Message "What's the name of the target computer?" -ValidateSet $DevicesList -ShowSetAs Radio -ValidateScript { $_ -Ne '' } )

$AnyBox.Buttons = 'Continue','Cancel' $AnyBox.CancelButton = 'Cancel' $AnyBox.DefaultButton = 'Continue' $AnyBox.Comment = "","Comment line.","" $AnyBox.Message = "Message line 1.","Message line 2." $AnyBoxResult = $AnyBox | Show-AnyBox

With version 0.4.0 the following window is displayed: image

However, with exactly the same code in version 0.5.0 I get: image

If I change the code as follows: $DevicesList = @('PC-ELAINE','PC-IAN','PC-RICHARD','PC-SAMANTHA')

$Prompt = @( New-AnyBoxPrompt -InputType Text -Message "What's the name of the target computer?" -ValidateSet $DevicesList -ShowSetAs Radio -ValidateScript { $_ -Ne '' } )

$AnyBoxResult = Show-AnyBox -Buttons 'Continue','Cancel' -CancelButton 'Cancel' -DefaultButton 'Continue' -Comments "","Comment line.","" -Messages "Message line 1.","Message line 2." -Prompts $Prompt

I get the following window with version 0.5.0 (i.e. the same as the New-Object method with version 0.4.0): image

Obviously this isn't a big deal since I can rewrite the code. However, there are times where the New-Object method is preferable - i.e. if you want different messages or comments depending on some variable.

Let me know if anything is unclear or you need more information.

Many thanks Ian

fresh2dev commented 2 years ago

fixed in v0.5.1 and published to the PS Gallery.

https://github.com/fresh2dev/AnyBox/compare/v0.5.0...v0.5.1

IanBAdams commented 2 years ago

Perfect. Thanks for addressing so quickly.