mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-24 23:11:31 -06:00
Remove Alphabetical List, Sort Apps inside Category Alphabetically
This commit is contained in:
parent
a839acd949
commit
dcf752fdeb
@ -13,24 +13,6 @@
|
||||
"Order": "2",
|
||||
"Description": "Clear the selection of applications"
|
||||
},
|
||||
"SortbyCategory": {
|
||||
"Content": "Category",
|
||||
"Category": "___Sort by",
|
||||
"Type": "RadioButton",
|
||||
"GroupName": "SortAppsByGroup",
|
||||
"Checked": true,
|
||||
"Order": "1",
|
||||
"Description": ""
|
||||
},
|
||||
"SortbyAlphabet": {
|
||||
"Content": "Alphabetical Order",
|
||||
"Category": "___Sort by",
|
||||
"Type": "RadioButton",
|
||||
"GroupName": "SortAppsByGroup",
|
||||
"Checked": false,
|
||||
"Order": "2",
|
||||
"Description": ""
|
||||
},
|
||||
"WingetRadioButton": {
|
||||
"Content": "Winget",
|
||||
"Category": "__Package Manager",
|
||||
|
@ -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.$_ })
|
||||
)
|
||||
<#
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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.$_ })
|
||||
)
|
||||
<#
|
||||
|
||||
|
@ -114,34 +114,20 @@ Invoke-WinutilThemeChange -init $true
|
||||
|
||||
$noimage = "https://images.emojiterra.com/google/noto-emoji/unicode-15/color/512px/1f4e6.png"
|
||||
$noimage = [Windows.Media.Imaging.BitmapImage]::new([Uri]::new($noimage))
|
||||
$sync.Buttons = @{}
|
||||
$SortedAppsHashtable = [ordered]@{}
|
||||
$sortedProperties = $sync.configs.applications.PSObject.Properties | Sort-Object { $_.Value.Content }
|
||||
$sortedProperties | ForEach-Object {
|
||||
$SortedAppsHashtable[$_.Name] = $_.Value
|
||||
|
||||
$sync.configs.applicationsHashtable = @{}
|
||||
$sync.configs.applications.PSObject.Properties | ForEach-Object {
|
||||
$sync.configs.applicationsHashtable[$_.Name] = $_.Value
|
||||
}
|
||||
|
||||
# Now call the function with the final merged config
|
||||
Invoke-WPFUIElements -configVariable $sync.configs.appnavigation -targetGridName "appscategory" -columncount 1
|
||||
Invoke-WPFUIApps -Apps $SortedAppsHashtable -targetGridName "appspanel"
|
||||
Invoke-WPFUIApps -Apps $sync.configs.applicationsHashtable -targetGridName "appspanel"
|
||||
|
||||
|
||||
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
|
||||
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2
|
||||
|
||||
$sync.SortbyCategory.Add_Checked({
|
||||
Write-Host "Sort By Category"
|
||||
$sync.Form.Dispatcher.BeginInvoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{
|
||||
Invoke-WPFUIApps -Apps $SortedAppsHashtable -targetGridName "appspanel"
|
||||
}) | Out-Null
|
||||
})
|
||||
$sync.SortbyAlphabet.Add_Checked({
|
||||
Write-Host "Sort By Alphabet"
|
||||
$sync.Form.Dispatcher.BeginInvoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{
|
||||
Invoke-WPFUIApps -Apps $SortedAppsHashtable -targetGridName "appspanel" -alphabetical $true
|
||||
})
|
||||
})
|
||||
|
||||
#===========================================================================
|
||||
# Store Form Objects In PowerShell
|
||||
#===========================================================================
|
||||
|
@ -37,11 +37,13 @@ $sync = [Hashtable]::Synchronized(@{})
|
||||
$sync.PSScriptRoot = $PSScriptRoot
|
||||
$sync.version = "#{replaceme}"
|
||||
$sync.configs = @{}
|
||||
$sync.Buttons = @{}
|
||||
$sync.ProcessRunning = $false
|
||||
$sync.selectedApps = [System.Collections.Generic.List[string]]::new()
|
||||
$sync.ShowOnlySeleced = $false
|
||||
$sync.currentTab = "Install"
|
||||
|
||||
|
||||
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||
Write-Output "Winutil needs to be run as Administrator. Attempting to relaunch."
|
||||
$argList = @()
|
||||
|
Loading…
Reference in New Issue
Block a user