Remove Alphabetical List, Sort Apps inside Category Alphabetically

This commit is contained in:
Marterich
2024-10-14 19:17:12 +02:00
parent a839acd949
commit dcf752fdeb
7 changed files with 23 additions and 62 deletions

View File

@ -1,7 +1,7 @@
function Invoke-WPFInstall {
param (
[Parameter(Mandatory=$false)]
[PSObject[]]$PackagesToInstall = $($sync.selectedApps | Foreach-Object { $SortedAppsHashtable.$_ })
[PSObject[]]$PackagesToInstall = $($sync.selectedApps | Foreach-Object { $sync.configs.applicationsHashtable.$_ })
)
<#

View File

@ -34,7 +34,7 @@ function Invoke-WPFSelectedLabelUpdate {
$count = $sync.SelectedApps.Count
$SelectedLabel.Content = "Selected Apps: $count"
if ($count -gt 0) {
$SelectedLabel.ToolTip = $($sync.SelectedApps | Foreach-Object { $SortedAppsHashtable.$_.Content }) -join "`n"
$SelectedLabel.ToolTip = $($sync.SelectedApps | Foreach-Object { $sync.configs.applicationsHashtable.$_.Content }) -join "`n"
} else {
$SelectedLabel.ToolTip = $Null
}

View File

@ -8,7 +8,7 @@ function Toggle-CategoryVisibility {
$appsInCategory = $ItemsControl.Items | Where-Object {
if ($null -ne $_.Tag){
$SortedAppsHashtable.$($_.Tag).Category -eq $Category
$sync.configs.applicationsHashtable.$($_.Tag).Category -eq $Category
}
}
$isCollapsed = $appsInCategory[0].Visibility -eq [Windows.Visibility]::Visible
@ -39,7 +39,7 @@ function Search-AppsByNameOrDescription {
} else {
$Apps | ForEach-Object {
if ($null -ne $_.Tag) {
if ($SortedAppsHashtable.$($_.Tag).Content -like "*$SearchString*") {
if ($sync.configs.applicationsHashtable.$($_.Tag).Content -like "*$SearchString*") {
$_.Visibility = 'Visible'
} else {
$_.Visibility = 'Collapsed'
@ -76,9 +76,7 @@ function Invoke-WPFUIApps {
[Parameter(Mandatory, Position = 0)]
[PSCustomObject[]]$Apps,
[Parameter(Mandatory, Position = 1)]
[string]$TargetGridName,
[Parameter()]
[System.Boolean]$Alphabetical = $false
[string]$TargetGridName
)
function Initialize-StackPanel {
@ -219,8 +217,7 @@ function Invoke-WPFUIApps {
function New-CategoryAppList {
param(
$TargetGrid,
$Apps,
[System.Boolean]$Alphabetical
$Apps
)
$loadingLabel = New-Object Windows.Controls.Label
$loadingLabel.Content = "Loading, please wait..."
@ -237,17 +234,11 @@ function Invoke-WPFUIApps {
$itemsControl.Dispatcher.Invoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{
$itemsControl.Items.Clear()
if (-not ($Alphabetical)) {
$categories = $Apps.Values | Select-Object -ExpandProperty category -Unique | Sort-Object
foreach ($category in $categories) {
Add-CategoryLabel -Category $category -ItemsControl $itemsControl
$Apps.Keys | Where-Object { $Apps.$_.Category -eq $category } | ForEach-Object {
New-AppEntry -ItemsControl $itemsControl -AppKey $_ -Hidden $true
}
}
} else {
foreach ($appKey in $Apps.Keys) {
New-AppEntry -ItemsControl $itemsControl -AppKey $appKey -Hidden $false
$categories = $Apps.Values | Select-Object -ExpandProperty category -Unique | Sort-Object
foreach ($category in $categories) {
Add-CategoryLabel -Category $category -ItemsControl $itemsControl
$Apps.Keys | Where-Object { $Apps.$_.Category -eq $category } | Sort-Object | ForEach-Object {
New-AppEntry -ItemsControl $itemsControl -AppKey $_ -Hidden $true
}
}
})
@ -369,7 +360,7 @@ function Invoke-WPFUIApps {
# Add Click event for the "Install" button
$installButton.Add_Click({
$appKey = $this.Parent.Parent.Parent.Tag
$appObject = $SortedAppsHashtable.$appKey
$appObject = $sync.configs.applicationsHashtable.$appKey
Invoke-WPFInstall -PackagesToInstall $appObject
})
@ -393,7 +384,7 @@ function Invoke-WPFUIApps {
$uninstallButton.ToolTip = "Uninstall the application"
$uninstallButton.Add_Click({
$appKey = $this.Parent.Parent.Parent.Tag
$appObject = $SortedAppsHashtable.$appKey
$appObject = $sync.configs.applicationsHashtable.$appKey
Invoke-WPFUnInstall -PackagesToUninstall $appObject
})
@ -418,7 +409,7 @@ function Invoke-WPFUIApps {
$infoButton.Add_Click({
$appKey = $this.Parent.Parent.Parent.Tag
$appObject = $SortedAppsHashtable.$appKey
$appObject = $sync.configs.applicationsHashtable.$appKey
Start-Process $appObject.link
})
@ -438,7 +429,7 @@ function Invoke-WPFUIApps {
$dockPanelContainer = Initialize-Header -TargetGrid $targetGrid
$itemsControl = Initialize-AppArea -TargetGrid $dockPanelContainer
$sync.ItemsControl = $itemsControl
New-CategoryAppList -TargetGrid $itemsControl -Apps $Apps -Alphabetical $Alphabetical
New-CategoryAppList -TargetGrid $itemsControl -Apps $Apps
}
default {
Write-Output "$TargetGridName not yet implemented"

View File

@ -1,7 +1,7 @@
function Invoke-WPFUnInstall {
param(
[Parameter(Mandatory=$false)]
[PSObject[]]$PackagesToUninstall = $($sync.selectedApps | Foreach-Object { $SortedAppsHashtable.$_ })
[PSObject[]]$PackagesToUninstall = $($sync.selectedApps | Foreach-Object { $sync.configs.applicationsHashtable.$_ })
)
<#