mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 09:20:36 -06:00
Compare commits
2 Commits
3be1999c22
...
e6e449af94
Author | SHA1 | Date | |
---|---|---|---|
|
e6e449af94 | ||
|
506c015496 |
@ -42,7 +42,8 @@ function Invoke-WPFUIElements {
|
|||||||
|
|
||||||
# Create an object for the application
|
# Create an object for the application
|
||||||
$entryObject = [PSCustomObject]@{
|
$entryObject = [PSCustomObject]@{
|
||||||
Name = $entry.Name
|
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,13 +162,11 @@ 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
|
||||||
$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 +178,48 @@ 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[$entryInfo.Name] = $checkBox
|
||||||
|
|
||||||
|
$sync[$entryInfo.Name].IsChecked = Get-WinUtilToggleStatus $sync[$entryInfo.Name].Name
|
||||||
|
|
||||||
|
$sync[$entryInfo.Name].Add_Click({
|
||||||
|
[System.Object]$Sender = $args[0]
|
||||||
|
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" {
|
||||||
@ -218,6 +251,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[$entryInfo.Name] = $comboBox
|
||||||
}
|
}
|
||||||
|
|
||||||
"Button" {
|
"Button" {
|
||||||
@ -232,6 +269,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[$entryInfo.Name] = $button
|
||||||
|
|
||||||
|
$sync[$entryInfo.Name].Add_Click({
|
||||||
|
[System.Object]$Sender = $args[0]
|
||||||
|
Invoke-WPFButton $Sender.name
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
@ -267,6 +311,8 @@ function Invoke-WPFUIElements {
|
|||||||
} else {
|
} else {
|
||||||
$stackPanel.Children.Add($checkBox) | Out-Null
|
$stackPanel.Children.Add($checkBox) | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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
|
||||||
@ -98,16 +99,6 @@ $xaml.SelectNodes("//*[@Name]") | ForEach-Object {$sync["$("$($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]
|
||||||
|
@ -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