initial visual implementation

- remove idiotic border logic from Invoke-WPFUIElements
- add "application" type & style
- add "radiobutton" type & style
- remove prefer choco checkbox (did not modify logic outside of xaml, so i currently get errors due to that)
This commit is contained in:
MyDrift
2024-09-27 22:54:07 +02:00
parent 225e774f1e
commit a1188871f4
4 changed files with 273 additions and 46 deletions

View File

@ -111,8 +111,109 @@ $sync.Form.Add_Loaded({
Invoke-WinutilThemeChange -init $true
# 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 1
# Extract unique categories from the applications configuration
$uniqueCategories = $sync.configs.applications.PSObject.Properties.Value |
Where-Object { $_.Category } |
Select-Object -Unique -ExpandProperty Category
# Create a custom PSCustomObject to simulate category-level checkboxes
$categoryConfig = @{}
foreach ($category in $uniqueCategories) {
# Sanitize the category name for use in the Name property (remove spaces, special characters)
$sanitizedCategoryName = $category -replace '\W', '_'
$categoryConfig[$sanitizedCategoryName] = [PSCustomObject]@{
Category = "Categories"
Content = $category # Keep original category name for display
}
}
# Adding dynamically two radiobuttons for "Package Manager" category with GroupName
$packageManagerConfig = @{
"WPFWingetRadioButton" = [PSCustomObject]@{
Name = "WingetRadioButton"
Content = "Winget"
Category = "__Package Manager"
Type = "RadioButton"
GroupName = "PackageManagerGroup"
Checked = $true
Order = "1"
Description = "Use Winget for package management"
}
"WPFChocoRadioButton" = [PSCustomObject]@{
Name = "ChocoRadioButton"
Content = "Chocolatey"
Category = "__Package Manager"
Type = "RadioButton"
GroupName = "PackageManagerGroup"
Checked = $false
Order = "2"
Description = "Use Chocolatey for package management"
}
"WPFautofallback" = [PSCustomObject]@{
Name = "AutoRadioButton"
Content = "Auto Fallback"
Category = "__Package Manager"
Checked = $true
Order = "3"
Description = "If the selected package manager fails, automatically switch to the other one"
}
"WPFDefaultScope" = [PSCustomObject]@{
Name = "DefaultScope"
Content = "Default"
Category = "_Installation Scope"
Type = "RadioButton"
GroupName = "InstallationScopeGroup"
Checked = $true
Order = "1"
Description = "Use the default scope of the application"
}
"WPFUserScope" = [PSCustomObject]@{
Name = "UserScope"
Content = "User"
Category = "_Installation Scope"
Type = "RadioButton"
GroupName = "InstallationScopeGroup"
Checked = $false
Order = "2"
Description = "If possible, install the application only for the current user"
}
"WPFGlobalMachineScope" = [PSCustomObject]@{
Name = "GlobalMachineScope"
Content = "Global (Machine)"
Category = "_Installation Scope"
Type = "RadioButton"
GroupName = "InstallationScopeGroup"
Checked = $false
Order = "3"
Description = "If possible, install the application globally for all users"
}
}
# Merge the packageManagerConfig with the existing category config
$finalConfig = @{}
$categoryConfig.Keys | ForEach-Object {
$finalConfig[$_] = $categoryConfig[$_]
}
$packageManagerConfig.Keys | ForEach-Object {
$finalConfig[$_] = $packageManagerConfig[$_]
}
# Convert to PSCustomObject for function input
$finalConfigObject = [PSCustomObject]@{}
$finalConfig.Keys | ForEach-Object {
Add-Member -InputObject $finalConfigObject -MemberType NoteProperty -Name $_ -Value $finalConfig[$_]
}
# Now call the function with the final merged config
Invoke-WPFUIElements -configVariable $finalConfigObject -targetGridName "appscategory" -columncount 1
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2