mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-25 07:21:30 -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",
|
"Order": "2",
|
||||||
"Description": "Clear the selection of applications"
|
"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": {
|
"WingetRadioButton": {
|
||||||
"Content": "Winget",
|
"Content": "Winget",
|
||||||
"Category": "__Package Manager",
|
"Category": "__Package Manager",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
function Invoke-WPFInstall {
|
function Invoke-WPFInstall {
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory=$false)]
|
[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
|
$count = $sync.SelectedApps.Count
|
||||||
$SelectedLabel.Content = "Selected Apps: $count"
|
$SelectedLabel.Content = "Selected Apps: $count"
|
||||||
if ($count -gt 0) {
|
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 {
|
} else {
|
||||||
$SelectedLabel.ToolTip = $Null
|
$SelectedLabel.ToolTip = $Null
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ function Toggle-CategoryVisibility {
|
|||||||
|
|
||||||
$appsInCategory = $ItemsControl.Items | Where-Object {
|
$appsInCategory = $ItemsControl.Items | Where-Object {
|
||||||
if ($null -ne $_.Tag){
|
if ($null -ne $_.Tag){
|
||||||
$SortedAppsHashtable.$($_.Tag).Category -eq $Category
|
$sync.configs.applicationsHashtable.$($_.Tag).Category -eq $Category
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$isCollapsed = $appsInCategory[0].Visibility -eq [Windows.Visibility]::Visible
|
$isCollapsed = $appsInCategory[0].Visibility -eq [Windows.Visibility]::Visible
|
||||||
@ -39,7 +39,7 @@ function Search-AppsByNameOrDescription {
|
|||||||
} else {
|
} else {
|
||||||
$Apps | ForEach-Object {
|
$Apps | ForEach-Object {
|
||||||
if ($null -ne $_.Tag) {
|
if ($null -ne $_.Tag) {
|
||||||
if ($SortedAppsHashtable.$($_.Tag).Content -like "*$SearchString*") {
|
if ($sync.configs.applicationsHashtable.$($_.Tag).Content -like "*$SearchString*") {
|
||||||
$_.Visibility = 'Visible'
|
$_.Visibility = 'Visible'
|
||||||
} else {
|
} else {
|
||||||
$_.Visibility = 'Collapsed'
|
$_.Visibility = 'Collapsed'
|
||||||
@ -76,9 +76,7 @@ function Invoke-WPFUIApps {
|
|||||||
[Parameter(Mandatory, Position = 0)]
|
[Parameter(Mandatory, Position = 0)]
|
||||||
[PSCustomObject[]]$Apps,
|
[PSCustomObject[]]$Apps,
|
||||||
[Parameter(Mandatory, Position = 1)]
|
[Parameter(Mandatory, Position = 1)]
|
||||||
[string]$TargetGridName,
|
[string]$TargetGridName
|
||||||
[Parameter()]
|
|
||||||
[System.Boolean]$Alphabetical = $false
|
|
||||||
)
|
)
|
||||||
|
|
||||||
function Initialize-StackPanel {
|
function Initialize-StackPanel {
|
||||||
@ -219,8 +217,7 @@ function Invoke-WPFUIApps {
|
|||||||
function New-CategoryAppList {
|
function New-CategoryAppList {
|
||||||
param(
|
param(
|
||||||
$TargetGrid,
|
$TargetGrid,
|
||||||
$Apps,
|
$Apps
|
||||||
[System.Boolean]$Alphabetical
|
|
||||||
)
|
)
|
||||||
$loadingLabel = New-Object Windows.Controls.Label
|
$loadingLabel = New-Object Windows.Controls.Label
|
||||||
$loadingLabel.Content = "Loading, please wait..."
|
$loadingLabel.Content = "Loading, please wait..."
|
||||||
@ -237,19 +234,13 @@ function Invoke-WPFUIApps {
|
|||||||
$itemsControl.Dispatcher.Invoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{
|
$itemsControl.Dispatcher.Invoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{
|
||||||
$itemsControl.Items.Clear()
|
$itemsControl.Items.Clear()
|
||||||
|
|
||||||
if (-not ($Alphabetical)) {
|
|
||||||
$categories = $Apps.Values | Select-Object -ExpandProperty category -Unique | Sort-Object
|
$categories = $Apps.Values | Select-Object -ExpandProperty category -Unique | Sort-Object
|
||||||
foreach ($category in $categories) {
|
foreach ($category in $categories) {
|
||||||
Add-CategoryLabel -Category $category -ItemsControl $itemsControl
|
Add-CategoryLabel -Category $category -ItemsControl $itemsControl
|
||||||
$Apps.Keys | Where-Object { $Apps.$_.Category -eq $category } | ForEach-Object {
|
$Apps.Keys | Where-Object { $Apps.$_.Category -eq $category } | Sort-Object | ForEach-Object {
|
||||||
New-AppEntry -ItemsControl $itemsControl -AppKey $_ -Hidden $true
|
New-AppEntry -ItemsControl $itemsControl -AppKey $_ -Hidden $true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
foreach ($appKey in $Apps.Keys) {
|
|
||||||
New-AppEntry -ItemsControl $itemsControl -AppKey $appKey -Hidden $false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +360,7 @@ function Invoke-WPFUIApps {
|
|||||||
# Add Click event for the "Install" button
|
# Add Click event for the "Install" button
|
||||||
$installButton.Add_Click({
|
$installButton.Add_Click({
|
||||||
$appKey = $this.Parent.Parent.Parent.Tag
|
$appKey = $this.Parent.Parent.Parent.Tag
|
||||||
$appObject = $SortedAppsHashtable.$appKey
|
$appObject = $sync.configs.applicationsHashtable.$appKey
|
||||||
Invoke-WPFInstall -PackagesToInstall $appObject
|
Invoke-WPFInstall -PackagesToInstall $appObject
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -393,7 +384,7 @@ function Invoke-WPFUIApps {
|
|||||||
$uninstallButton.ToolTip = "Uninstall the application"
|
$uninstallButton.ToolTip = "Uninstall the application"
|
||||||
$uninstallButton.Add_Click({
|
$uninstallButton.Add_Click({
|
||||||
$appKey = $this.Parent.Parent.Parent.Tag
|
$appKey = $this.Parent.Parent.Parent.Tag
|
||||||
$appObject = $SortedAppsHashtable.$appKey
|
$appObject = $sync.configs.applicationsHashtable.$appKey
|
||||||
Invoke-WPFUnInstall -PackagesToUninstall $appObject
|
Invoke-WPFUnInstall -PackagesToUninstall $appObject
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -418,7 +409,7 @@ function Invoke-WPFUIApps {
|
|||||||
|
|
||||||
$infoButton.Add_Click({
|
$infoButton.Add_Click({
|
||||||
$appKey = $this.Parent.Parent.Parent.Tag
|
$appKey = $this.Parent.Parent.Parent.Tag
|
||||||
$appObject = $SortedAppsHashtable.$appKey
|
$appObject = $sync.configs.applicationsHashtable.$appKey
|
||||||
Start-Process $appObject.link
|
Start-Process $appObject.link
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -438,7 +429,7 @@ function Invoke-WPFUIApps {
|
|||||||
$dockPanelContainer = Initialize-Header -TargetGrid $targetGrid
|
$dockPanelContainer = Initialize-Header -TargetGrid $targetGrid
|
||||||
$itemsControl = Initialize-AppArea -TargetGrid $dockPanelContainer
|
$itemsControl = Initialize-AppArea -TargetGrid $dockPanelContainer
|
||||||
$sync.ItemsControl = $itemsControl
|
$sync.ItemsControl = $itemsControl
|
||||||
New-CategoryAppList -TargetGrid $itemsControl -Apps $Apps -Alphabetical $Alphabetical
|
New-CategoryAppList -TargetGrid $itemsControl -Apps $Apps
|
||||||
}
|
}
|
||||||
default {
|
default {
|
||||||
Write-Output "$TargetGridName not yet implemented"
|
Write-Output "$TargetGridName not yet implemented"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
function Invoke-WPFUnInstall {
|
function Invoke-WPFUnInstall {
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$false)]
|
[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 = "https://images.emojiterra.com/google/noto-emoji/unicode-15/color/512px/1f4e6.png"
|
||||||
$noimage = [Windows.Media.Imaging.BitmapImage]::new([Uri]::new($noimage))
|
$noimage = [Windows.Media.Imaging.BitmapImage]::new([Uri]::new($noimage))
|
||||||
$sync.Buttons = @{}
|
|
||||||
$SortedAppsHashtable = [ordered]@{}
|
$sync.configs.applicationsHashtable = @{}
|
||||||
$sortedProperties = $sync.configs.applications.PSObject.Properties | Sort-Object { $_.Value.Content }
|
$sync.configs.applications.PSObject.Properties | ForEach-Object {
|
||||||
$sortedProperties | ForEach-Object {
|
$sync.configs.applicationsHashtable[$_.Name] = $_.Value
|
||||||
$SortedAppsHashtable[$_.Name] = $_.Value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Now call the function with the final merged config
|
# Now call the function with the final merged config
|
||||||
Invoke-WPFUIElements -configVariable $sync.configs.appnavigation -targetGridName "appscategory" -columncount 1
|
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.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
|
||||||
|
|
||||||
$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
|
# Store Form Objects In PowerShell
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
|
@ -37,11 +37,13 @@ $sync = [Hashtable]::Synchronized(@{})
|
|||||||
$sync.PSScriptRoot = $PSScriptRoot
|
$sync.PSScriptRoot = $PSScriptRoot
|
||||||
$sync.version = "#{replaceme}"
|
$sync.version = "#{replaceme}"
|
||||||
$sync.configs = @{}
|
$sync.configs = @{}
|
||||||
|
$sync.Buttons = @{}
|
||||||
$sync.ProcessRunning = $false
|
$sync.ProcessRunning = $false
|
||||||
$sync.selectedApps = [System.Collections.Generic.List[string]]::new()
|
$sync.selectedApps = [System.Collections.Generic.List[string]]::new()
|
||||||
$sync.ShowOnlySeleced = $false
|
$sync.ShowOnlySeleced = $false
|
||||||
$sync.currentTab = "Install"
|
$sync.currentTab = "Install"
|
||||||
|
|
||||||
|
|
||||||
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
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."
|
Write-Output "Winutil needs to be run as Administrator. Attempting to relaunch."
|
||||||
$argList = @()
|
$argList = @()
|
||||||
|
Loading…
Reference in New Issue
Block a user