some fixes

This commit is contained in:
MyDrift 2024-08-11 14:06:46 +02:00
parent 3be1999c22
commit 506c015496
2 changed files with 24 additions and 13 deletions

View File

@ -42,7 +42,7 @@ function Invoke-WPFUIElements {
# Create an object for the application # Create an object for the application
$entryObject = [PSCustomObject]@{ $entryObject = [PSCustomObject]@{
Name = $entry.Name Name = $entry
Category = $entryInfo.Category Category = $entryInfo.Category
Content = $entryInfo.Content Content = $entryInfo.Content
Choco = $entryInfo.choco Choco = $entryInfo.choco
@ -173,7 +173,6 @@ function Invoke-WPFUIElements {
$dockPanel = New-Object Windows.Controls.DockPanel $dockPanel = New-Object Windows.Controls.DockPanel
$checkBox = New-Object Windows.Controls.CheckBox $checkBox = New-Object Windows.Controls.CheckBox
$checkBox.Name = $entryInfo.Name $checkBox.Name = $entryInfo.Name
write-host $entryInfo.Name
$checkBox.HorizontalAlignment = "Right" $checkBox.HorizontalAlignment = "Right"
$dockPanel.Children.Add($checkBox) | Out-Null $dockPanel.Children.Add($checkBox) | Out-Null
$checkBox.Style = $window.FindResource("ColorfulToggleSwitchStyle") $checkBox.Style = $window.FindResource("ColorfulToggleSwitchStyle")
@ -185,8 +184,16 @@ function Invoke-WPFUIElements {
$label.FontSize = $theme.FontSize $label.FontSize = $theme.FontSize
# Implement for consistent theming later on $label.Style = $window.FindResource("labelfortweaks") # Implement for consistent theming later on $label.Style = $window.FindResource("labelfortweaks")
$dockPanel.Children.Add($label) | Out-Null $dockPanel.Children.Add($label) | Out-Null
$stackPanel.Children.Add($dockPanel) | Out-Null $stackPanel.Children.Add($dockPanel) | Out-Null
$sync["$entry"] = $checkBox
$sync["$entry"].IsChecked = Get-WinUtilToggleStatus $sync["$entry"].Name
$sync["$entry"].Add_Click({
[System.Object]$Sender = $args[0]
Invoke-WPFToggle $Sender.name
})
} }
"Combobox" { "Combobox" {
@ -218,6 +225,10 @@ function Invoke-WPFUIElements {
$horizontalStackPanel.Children.Add($comboBox) | Out-Null $horizontalStackPanel.Children.Add($comboBox) | Out-Null
$stackPanel.Children.Add($horizontalStackPanel) | Out-Null $stackPanel.Children.Add($horizontalStackPanel) | Out-Null
$comboBox.SelectedIndex = 0
$sync["$entry"] = $comboBox
} }
"Button" { "Button" {
@ -232,6 +243,13 @@ function Invoke-WPFUIElements {
$button.Width = $entryInfo.ButtonWidth $button.Width = $entryInfo.ButtonWidth
} }
$stackPanel.Children.Add($button) | Out-Null $stackPanel.Children.Add($button) | Out-Null
$sync["$entry"] = $button
$sync["$entry"].Add_Click({
[System.Object]$Sender = $args[0]
Invoke-WPFButton $Sender.name
})
} }
default { default {
@ -267,6 +285,8 @@ function Invoke-WPFUIElements {
} else { } else {
$stackPanel.Children.Add($checkBox) | Out-Null $stackPanel.Children.Add($checkBox) | Out-Null
} }
$sync["$entry"] = $checkBox
} }
} }
} }

View File

@ -95,19 +95,10 @@ Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "feat
#=========================================================================== #===========================================================================
$xaml.SelectNodes("//*[@Name]") | ForEach-Object {$sync["$("$($psitem.Name)")"] = $sync["Form"].FindName($psitem.Name)} $xaml.SelectNodes("//*[@Name]") | ForEach-Object {$sync["$("$($psitem.Name)")"] = $sync["Form"].FindName($psitem.Name)}
$xaml.SelectNodes("//*[@Name]") | ForEach-Object {write-host $($psitem.Name)}
$sync.keys | ForEach-Object { $sync.keys | ForEach-Object {
if($sync.$psitem){ if($sync.$psitem){
if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "CheckBox" `
-and $sync["$psitem"].Name -like "WPFToggle*"){
$sync["$psitem"].IsChecked = Get-WinUtilToggleStatus $sync["$psitem"].Name
$sync["$psitem"].Add_Click({
[System.Object]$Sender = $args[0]
Invoke-WPFToggle $Sender.name
})
}
if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "ToggleButton"){ if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "ToggleButton"){
$sync["$psitem"].Add_Click({ $sync["$psitem"].Add_Click({
[System.Object]$Sender = $args[0] [System.Object]$Sender = $args[0]