mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 09:20:36 -06:00
hotfixes
This commit is contained in:
parent
506c015496
commit
e6e449af94
@ -43,6 +43,7 @@ function Invoke-WPFUIElements {
|
|||||||
# Create an object for the application
|
# Create an object for the application
|
||||||
$entryObject = [PSCustomObject]@{
|
$entryObject = [PSCustomObject]@{
|
||||||
Name = $entry
|
Name = $entry
|
||||||
|
Order = $entryInfo.order
|
||||||
Category = $entryInfo.Category
|
Category = $entryInfo.Category
|
||||||
Content = $entryInfo.Content
|
Content = $entryInfo.Content
|
||||||
Choco = $entryInfo.choco
|
Choco = $entryInfo.choco
|
||||||
@ -61,12 +62,11 @@ function Invoke-WPFUIElements {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (-not $organizedData[$entryObject.Panel].ContainsKey($entryObject.Category)) {
|
if (-not $organizedData[$entryObject.Panel].ContainsKey($entryObject.Category)) {
|
||||||
$organizedData[$entryObject.Panel][$entryObject.Category] = @{}
|
$organizedData[$entryObject.Panel][$entryObject.Category] = @()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Store application data in a sub-array under the category
|
# Store application data in an array under the category
|
||||||
$organizedData[$entryObject.Panel][$entryInfo.Category]["$($entryInfo.order)$entry"] = $entryObject
|
$organizedData[$entryObject.Panel][$entryObject.Category] += $entryObject
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retrieve the main window and the target Grid by name
|
# Retrieve the main window and the target Grid by name
|
||||||
@ -97,11 +97,9 @@ function Invoke-WPFUIElements {
|
|||||||
foreach ($panelKey in ($organizedData.Keys | Sort-Object)) {
|
foreach ($panelKey in ($organizedData.Keys | Sort-Object)) {
|
||||||
# Create a Border for each column
|
# Create a Border for each column
|
||||||
$border = New-Object Windows.Controls.Border
|
$border = New-Object Windows.Controls.Border
|
||||||
$border.BorderBrush = [Windows.Media.Brushes]::Gray
|
|
||||||
$border.BorderThickness = [Windows.Thickness]::new(1)
|
|
||||||
$border.Margin = [Windows.Thickness]::new(5)
|
|
||||||
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
|
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
|
||||||
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
|
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
|
||||||
|
$border.style = $window.FindResource("BorderStyle")
|
||||||
$targetGrid.Children.Add($border) | Out-Null
|
$targetGrid.Children.Add($border) | Out-Null
|
||||||
|
|
||||||
# Create a StackPanel inside the Border
|
# Create a StackPanel inside the Border
|
||||||
@ -119,11 +117,9 @@ function Invoke-WPFUIElements {
|
|||||||
if ($panelcount -eq $panelcount2) {
|
if ($panelcount -eq $panelcount2) {
|
||||||
# Create a new Border for the new column
|
# Create a new Border for the new column
|
||||||
$border = New-Object Windows.Controls.Border
|
$border = New-Object Windows.Controls.Border
|
||||||
$border.BorderBrush = [Windows.Media.Brushes]::Gray
|
|
||||||
$border.BorderThickness = [Windows.Thickness]::new(1)
|
|
||||||
$border.Margin = [Windows.Thickness]::new(5)
|
|
||||||
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
|
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
|
||||||
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
|
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
|
||||||
|
$border.style = $window.FindResource("BorderStyle")
|
||||||
$targetGrid.Children.Add($border) | Out-Null
|
$targetGrid.Children.Add($border) | Out-Null
|
||||||
|
|
||||||
# Create a new StackPanel inside the Border
|
# Create a new StackPanel inside the Border
|
||||||
@ -142,19 +138,18 @@ function Invoke-WPFUIElements {
|
|||||||
$label.FontFamily = $theme.HeaderFontFamily
|
$label.FontFamily = $theme.HeaderFontFamily
|
||||||
$stackPanel.Children.Add($label) | Out-Null
|
$stackPanel.Children.Add($label) | Out-Null
|
||||||
|
|
||||||
$entries = $organizedData[$panelKey][$category].Keys | Sort-Object
|
# Sort entries by Order and then by Name, but only display Name
|
||||||
foreach ($entry in $entries) {
|
$entries = $organizedData[$panelKey][$category] | Sort-Object Order, Name
|
||||||
|
foreach ($entryInfo in $entries) {
|
||||||
$count++
|
$count++
|
||||||
if ($targetGridName -eq "appspanel" -and $columncount -gt 0) {
|
if ($targetGridName -eq "appspanel" -and $columncount -gt 0) {
|
||||||
$panelcount2 = [Int](($count) / $maxcount - 0.5)
|
$panelcount2 = [Int](($count) / $maxcount - 0.5)
|
||||||
if ($panelcount -eq $panelcount2) {
|
if ($panelcount -eq $panelcount2) {
|
||||||
# Create a new Border for the new column
|
# Create a new Border for the new column
|
||||||
$border = New-Object Windows.Controls.Border
|
$border = New-Object Windows.Controls.Border
|
||||||
$border.BorderBrush = [Windows.Media.Brushes]::Gray
|
|
||||||
$border.BorderThickness = [Windows.Thickness]::new(1)
|
|
||||||
$border.Margin = [Windows.Thickness]::new(5)
|
|
||||||
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
|
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
|
||||||
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
|
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
|
||||||
|
$border.style = $window.FindResource("BorderStyle")
|
||||||
$targetGrid.Children.Add($border) | Out-Null
|
$targetGrid.Children.Add($border) | Out-Null
|
||||||
|
|
||||||
# Create a new StackPanel inside the Border
|
# Create a new StackPanel inside the Border
|
||||||
@ -167,7 +162,6 @@ function Invoke-WPFUIElements {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$entryInfo = $organizedData[$panelKey][$category][$entry]
|
|
||||||
switch ($entryInfo.Type) {
|
switch ($entryInfo.Type) {
|
||||||
"Toggle" {
|
"Toggle" {
|
||||||
$dockPanel = New-Object Windows.Controls.DockPanel
|
$dockPanel = New-Object Windows.Controls.DockPanel
|
||||||
@ -186,16 +180,48 @@ function Invoke-WPFUIElements {
|
|||||||
$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[$entryInfo.Name] = $checkBox
|
||||||
|
|
||||||
$sync["$entry"].IsChecked = Get-WinUtilToggleStatus $sync["$entry"].Name
|
$sync[$entryInfo.Name].IsChecked = Get-WinUtilToggleStatus $sync[$entryInfo.Name].Name
|
||||||
|
|
||||||
$sync["$entry"].Add_Click({
|
$sync[$entryInfo.Name].Add_Click({
|
||||||
[System.Object]$Sender = $args[0]
|
[System.Object]$Sender = $args[0]
|
||||||
Invoke-WPFToggle $Sender.name
|
Invoke-WPFToggle $Sender.name
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"ToggleButton" {
|
||||||
|
$toggleButton = New-Object Windows.Controls.ToggleButton
|
||||||
|
$toggleButton.Name = $entryInfo.Name
|
||||||
|
$toggleButton.Name = "WPFTab" + ($stackPanel.Children.Count + 1) + "BT"
|
||||||
|
$toggleButton.HorizontalAlignment = "Left"
|
||||||
|
$toggleButton.Height = $theme.TabButtonHeight
|
||||||
|
$toggleButton.Width = $theme.TabButtonWidth
|
||||||
|
$toggleButton.Background = $theme.ButtonInstallBackgroundColor
|
||||||
|
$toggleButton.Foreground = [Windows.Media.Brushes]::White
|
||||||
|
$toggleButton.FontWeight = [Windows.FontWeights]::Bold
|
||||||
|
|
||||||
|
$textBlock = New-Object Windows.Controls.TextBlock
|
||||||
|
$textBlock.FontSize = $theme.TabButtonFontSize
|
||||||
|
$textBlock.Background = [Windows.Media.Brushes]::Transparent
|
||||||
|
$textBlock.Foreground = $theme.ButtonInstallForegroundColor
|
||||||
|
|
||||||
|
$underline = New-Object Windows.Documents.Underline
|
||||||
|
$underline.Inlines.Add($entryInfo.name -replace "(.).*", "`$1")
|
||||||
|
|
||||||
|
$run = New-Object Windows.Documents.Run
|
||||||
|
$run.Text = $entryInfo.name -replace "^.", ""
|
||||||
|
|
||||||
|
$textBlock.Inlines.Add($underline)
|
||||||
|
$textBlock.Inlines.Add($run)
|
||||||
|
|
||||||
|
$toggleButton.Content = $textBlock
|
||||||
|
|
||||||
|
$stackPanel.Children.Add($toggleButton) | Out-Null
|
||||||
|
|
||||||
|
$sync[$entryInfo.Name] = $toggleButton
|
||||||
|
}
|
||||||
|
|
||||||
"Combobox" {
|
"Combobox" {
|
||||||
$horizontalStackPanel = New-Object Windows.Controls.StackPanel
|
$horizontalStackPanel = New-Object Windows.Controls.StackPanel
|
||||||
$horizontalStackPanel.Orientation = "Horizontal"
|
$horizontalStackPanel.Orientation = "Horizontal"
|
||||||
@ -228,7 +254,7 @@ function Invoke-WPFUIElements {
|
|||||||
|
|
||||||
$comboBox.SelectedIndex = 0
|
$comboBox.SelectedIndex = 0
|
||||||
|
|
||||||
$sync["$entry"] = $comboBox
|
$sync[$entryInfo.Name] = $comboBox
|
||||||
}
|
}
|
||||||
|
|
||||||
"Button" {
|
"Button" {
|
||||||
@ -244,9 +270,9 @@ function Invoke-WPFUIElements {
|
|||||||
}
|
}
|
||||||
$stackPanel.Children.Add($button) | Out-Null
|
$stackPanel.Children.Add($button) | Out-Null
|
||||||
|
|
||||||
$sync["$entry"] = $button
|
$sync[$entryInfo.Name] = $button
|
||||||
|
|
||||||
$sync["$entry"].Add_Click({
|
$sync[$entryInfo.Name].Add_Click({
|
||||||
[System.Object]$Sender = $args[0]
|
[System.Object]$Sender = $args[0]
|
||||||
Invoke-WPFButton $Sender.name
|
Invoke-WPFButton $Sender.name
|
||||||
})
|
})
|
||||||
@ -286,7 +312,7 @@ function Invoke-WPFUIElements {
|
|||||||
$stackPanel.Children.Add($checkBox) | Out-Null
|
$stackPanel.Children.Add($checkBox) | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
$sync["$entry"] = $checkBox
|
$sync[$entryInfo.Name] = $checkBox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ try {
|
|||||||
|
|
||||||
|
|
||||||
# Load the configuration files
|
# 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.applications -targetGridName "appspanel" -columncount 5
|
||||||
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
|
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
|
||||||
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2
|
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2
|
||||||
@ -95,7 +96,6 @@ 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){
|
||||||
|
@ -502,7 +502,7 @@
|
|||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style TargetType="Border">
|
<Style x:Key="BorderStyle" TargetType="Border">
|
||||||
<Setter Property="Background" Value="{MainBackgroundColor}"/>
|
<Setter Property="Background" Value="{MainBackgroundColor}"/>
|
||||||
<Setter Property="BorderBrush" Value="{BorderColor}"/>
|
<Setter Property="BorderBrush" Value="{BorderColor}"/>
|
||||||
<Setter Property="BorderThickness" Value="1"/>
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user