Small patches for main.ps1 script (#2640)

* Re-order some logic in 'main.ps1' script

* Use 'Write-Host' instead of 'Write-Warning' in 'main.ps1' script to make sure the output is seen in different environments

This'll make sure that the output is displayed in PowerShell 5 developing environments, and when outputing Warnings/Errors in Runspaces.
This commit is contained in:
Mr.k 2024-08-29 00:55:40 +03:00 committed by GitHub
parent f8db21bbee
commit 97876348d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,22 +85,16 @@ try {
$sync["Form"] = [Windows.Markup.XamlReader]::Load( $reader ) $sync["Form"] = [Windows.Markup.XamlReader]::Load( $reader )
$readerOperationSuccessful = $true $readerOperationSuccessful = $true
} catch [System.Management.Automation.MethodInvocationException] { } catch [System.Management.Automation.MethodInvocationException] {
Write-Warning "We ran into a problem with the XAML code. Check the syntax for this control..." Write-Host "We ran into a problem with the XAML code. Check the syntax for this control..." -ForegroundColor Red
Write-Host $error[0].Exception.Message -ForegroundColor Red Write-Host $error[0].Exception.Message -ForegroundColor Red
If ($error[0].Exception.Message -like "*button*") { If ($error[0].Exception.Message -like "*button*") {
write-warning "Ensure your <button in the `$inputXML does NOT have a Click=ButtonClick property. PS can't handle this`n`n`n`n" write-Host "Ensure your <button in the `$inputXML does NOT have a Click=ButtonClick property. PS can't handle this`n`n`n`n" -ForegroundColor Red
} }
} catch { } catch {
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed." Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed." -ForegroundColor Red
} }
# Load the configuration files
#Invoke-WPFUIElements -configVariable $sync.configs.nav -targetGridName "WPFMainGrid"
Invoke-WPFUIElements -configVariable $sync.configs.applications -targetGridName "appspanel" -columncount 5
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2
if (-NOT ($readerOperationSuccessful)) { if (-NOT ($readerOperationSuccessful)) {
Write-Host "Failed to parse xaml content using Windows.Markup.XamlReader's Load Method." -ForegroundColor Red Write-Host "Failed to parse xaml content using Windows.Markup.XamlReader's Load Method." -ForegroundColor Red
Write-Host "Quitting winutil..." -ForegroundColor Red Write-Host "Quitting winutil..." -ForegroundColor Red
@ -110,6 +104,12 @@ if (-NOT ($readerOperationSuccessful)) {
exit 1 exit 1
} }
# Load the configuration files
#Invoke-WPFUIElements -configVariable $sync.configs.nav -targetGridName "WPFMainGrid"
Invoke-WPFUIElements -configVariable $sync.configs.applications -targetGridName "appspanel" -columncount 5
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2
#=========================================================================== #===========================================================================
# Store Form Objects In PowerShell # Store Form Objects In PowerShell
#=========================================================================== #===========================================================================