mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45:52 -06:00
run preprocessing
This commit is contained in:
parent
c46a7eaa40
commit
5514025577
@ -1,23 +1,23 @@
|
|||||||
function Add-SelectedAppsMenuItem {
|
function Add-SelectedAppsMenuItem {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
This is a helper function that generates and adds the Menu Items to the Selected Apps Popup.
|
This is a helper function that generates and adds the Menu Items to the Selected Apps Popup.
|
||||||
|
|
||||||
.Parameter name
|
.Parameter name
|
||||||
The actual Name of an App like "Chrome" or "Brave"
|
The actual Name of an App like "Chrome" or "Brave"
|
||||||
This name is contained in the "Content" property inside the applications.json
|
This name is contained in the "Content" property inside the applications.json
|
||||||
.PARAMETER key
|
.PARAMETER key
|
||||||
The key which identifies an app object in applications.json
|
The key which identifies an app object in applications.json
|
||||||
For Chrome this would be "WPFInstallchrome" because "WPFInstall" is prepended automatically for each key in applications.json
|
For Chrome this would be "WPFInstallchrome" because "WPFInstall" is prepended automatically for each key in applications.json
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param ([string]$name, [string]$key)
|
param ([string]$name, [string]$key)
|
||||||
|
|
||||||
$selectedAppGrid = New-Object Windows.Controls.Grid
|
$selectedAppGrid = New-Object Windows.Controls.Grid
|
||||||
|
|
||||||
$selectedAppGrid.ColumnDefinitions.Add((New-Object System.Windows.Controls.ColumnDefinition -Property @{Width = "*"}))
|
$selectedAppGrid.ColumnDefinitions.Add((New-Object System.Windows.Controls.ColumnDefinition -Property @{Width = "*"}))
|
||||||
$selectedAppGrid.ColumnDefinitions.Add((New-Object System.Windows.Controls.ColumnDefinition -Property @{Width = "30"}))
|
$selectedAppGrid.ColumnDefinitions.Add((New-Object System.Windows.Controls.ColumnDefinition -Property @{Width = "30"}))
|
||||||
|
|
||||||
# Sets the name to the Content as well as the Tooltip, because the parent Popup Border has a fixed width and text could "overflow".
|
# Sets the name to the Content as well as the Tooltip, because the parent Popup Border has a fixed width and text could "overflow".
|
||||||
# With the tooltip, you can still read the whole entry on hover
|
# With the tooltip, you can still read the whole entry on hover
|
||||||
$selectedAppLabel = New-Object Windows.Controls.Label
|
$selectedAppLabel = New-Object Windows.Controls.Label
|
||||||
@ -30,13 +30,13 @@
|
|||||||
|
|
||||||
$selectedAppRemoveButton = New-Object Windows.Controls.Button
|
$selectedAppRemoveButton = New-Object Windows.Controls.Button
|
||||||
$selectedAppRemoveButton.FontFamily = "Segoe MDL2 Assets"
|
$selectedAppRemoveButton.FontFamily = "Segoe MDL2 Assets"
|
||||||
$selectedAppRemoveButton.Content = [string]([char]0xE711)
|
$selectedAppRemoveButton.Content = [string]([char]0xE711)
|
||||||
$selectedAppRemoveButton.HorizontalAlignment = "Center"
|
$selectedAppRemoveButton.HorizontalAlignment = "Center"
|
||||||
$selectedAppRemoveButton.Tag = $key
|
$selectedAppRemoveButton.Tag = $key
|
||||||
$selectedAppRemoveButton.ToolTip = "Remove the App from Selection"
|
$selectedAppRemoveButton.ToolTip = "Remove the App from Selection"
|
||||||
$selectedAppRemoveButton.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor")
|
$selectedAppRemoveButton.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor")
|
||||||
$selectedAppRemoveButton.SetResourceReference([Windows.Controls.Control]::StyleProperty, "HoverButtonStyle")
|
$selectedAppRemoveButton.SetResourceReference([Windows.Controls.Control]::StyleProperty, "HoverButtonStyle")
|
||||||
|
|
||||||
# Highlight the Remove icon on Hover
|
# Highlight the Remove icon on Hover
|
||||||
$selectedAppRemoveButton.Add_MouseEnter({ $this.Foreground = "Red" })
|
$selectedAppRemoveButton.Add_MouseEnter({ $this.Foreground = "Red" })
|
||||||
$selectedAppRemoveButton.Add_MouseLeave({ $this.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor") })
|
$selectedAppRemoveButton.Add_MouseLeave({ $this.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor") })
|
||||||
@ -46,5 +46,5 @@
|
|||||||
[System.Windows.Controls.Grid]::SetColumn($selectedAppRemoveButton, 1)
|
[System.Windows.Controls.Grid]::SetColumn($selectedAppRemoveButton, 1)
|
||||||
$selectedAppGrid.Children.Add($selectedAppRemoveButton)
|
$selectedAppGrid.Children.Add($selectedAppRemoveButton)
|
||||||
# Add new Element to Popup
|
# Add new Element to Popup
|
||||||
$sync.selectedAppsstackPanel.Children.Add($selectedAppGrid)
|
$sync.selectedAppsstackPanel.Children.Add($selectedAppGrid)
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
function Find-AppsByNameOrDescription {
|
function Find-AppsByNameOrDescription {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Searches through the Apps on the Install Tab and hides all entries that do not match the string
|
Searches through the Apps on the Install Tab and hides all entries that do not match the string
|
||||||
|
|
||||||
.PARAMETER SearchString
|
.PARAMETER SearchString
|
||||||
The string to be searched for
|
The string to be searched for
|
||||||
#>
|
#>
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$SearchString = ""
|
[string]$SearchString = ""
|
||||||
)
|
)
|
||||||
# Reset the visibility if the search string is empty or the search is cleared
|
# Reset the visibility if the search string is empty or the search is cleared
|
||||||
if ([string]::IsNullOrWhiteSpace($SearchString)) {
|
if ([string]::IsNullOrWhiteSpace($SearchString)) {
|
||||||
@ -31,5 +31,5 @@ function Find-AppsByNameOrDescription {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
function Initialize-InstallAppEntry {
|
function Initialize-InstallAppEntry {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Creates the app entry to be placed on the isntall tab for a given app
|
Creates the app entry to be placed on the isntall tab for a given app
|
||||||
Used to as part of the Install Tab UI generation
|
Used to as part of the Install Tab UI generation
|
||||||
.PARAMETER TargetElement
|
.PARAMETER TargetElement
|
||||||
The Element into which the Apps should be placed
|
The Element into which the Apps should be placed
|
||||||
.PARAMETER AppKey
|
.PARAMETER AppKey
|
||||||
The Key of the app inside the $sync.configs.applicationsHashtable
|
The Key of the app inside the $sync.configs.applicationsHashtable
|
||||||
#>
|
#>
|
||||||
param(
|
param(
|
||||||
[Windows.Controls.WrapPanel]$TargetElement,
|
[Windows.Controls.WrapPanel]$TargetElement,
|
||||||
@ -194,4 +194,4 @@ function Initialize-InstallAppEntry {
|
|||||||
|
|
||||||
# Add the border to the corresponding Category
|
# Add the border to the corresponding Category
|
||||||
$TargetElement.Children.Add($border) | Out-Null
|
$TargetElement.Children.Add($border) | Out-Null
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Creates a [Windows.Controls.ScrollViewer] containing a [Windows.Controls.ItemsControl] which is setup to use Virtualization to only load the visible elements for performance reasons.
|
Creates a [Windows.Controls.ScrollViewer] containing a [Windows.Controls.ItemsControl] which is setup to use Virtualization to only load the visible elements for performance reasons.
|
||||||
This is used as the parent object for all category and app entries on the install tab
|
This is used as the parent object for all category and app entries on the install tab
|
||||||
Used to as part of the Install Tab UI generation
|
Used to as part of the Install Tab UI generation
|
||||||
|
|
||||||
.PARAMETER TargetElement
|
.PARAMETER TargetElement
|
||||||
The element to which the AppArea shoud be added
|
The element to which the AppArea shoud be added
|
||||||
|
|
||||||
#>
|
#>
|
||||||
param($TargetElement)
|
param($TargetElement)
|
||||||
@ -33,4 +33,4 @@
|
|||||||
[Windows.Controls.DockPanel]::SetDock($scrollViewer, [Windows.Controls.Dock]::Bottom)
|
[Windows.Controls.DockPanel]::SetDock($scrollViewer, [Windows.Controls.Dock]::Bottom)
|
||||||
$null = $TargetElement.Children.Add($scrollViewer)
|
$null = $TargetElement.Children.Add($scrollViewer)
|
||||||
return $itemsControl
|
return $itemsControl
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ function Initialize-InstallAppsMainElement {
|
|||||||
Clears the given WPF Grid and creates a [Windows.Controls.Border] containing a [Windows.Controls.StackPanel]
|
Clears the given WPF Grid and creates a [Windows.Controls.Border] containing a [Windows.Controls.StackPanel]
|
||||||
Used to as part of the Install Tab UI generation
|
Used to as part of the Install Tab UI generation
|
||||||
.PARAMETER TargetGridName
|
.PARAMETER TargetGridName
|
||||||
The WPF Grid name
|
The WPF Grid name
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
Returns the created [Windows.Controls.StackPanel] element
|
Returns the created [Windows.Controls.StackPanel] element
|
||||||
#>
|
#>
|
||||||
@ -12,7 +12,7 @@ function Initialize-InstallAppsMainElement {
|
|||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[string]$TargetGridName
|
[string]$TargetGridName
|
||||||
)
|
)
|
||||||
$targetGrid = $sync.Form.FindName($TargetGridName)
|
$targetGrid = $sync.Form.FindName($TargetGridName)
|
||||||
$null = $targetGrid.Children.Clear()
|
$null = $targetGrid.Children.Clear()
|
||||||
|
|
||||||
$Border = New-Object Windows.Controls.Border
|
$Border = New-Object Windows.Controls.Border
|
||||||
@ -25,4 +25,4 @@ function Initialize-InstallAppsMainElement {
|
|||||||
$null = $targetGrid.Children.Add($Border)
|
$null = $targetGrid.Children.Add($Border)
|
||||||
|
|
||||||
return $dockPanel
|
return $dockPanel
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,14 @@ function Initialize-InstallCategoryAppList {
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Clears the Target Element and sets up a "Loading" message. This is done, because loading of all apps can take a bit of time in some scenarios
|
Clears the Target Element and sets up a "Loading" message. This is done, because loading of all apps can take a bit of time in some scenarios
|
||||||
Iterates through all Categories and Apps and adds them to the UI
|
Iterates through all Categories and Apps and adds them to the UI
|
||||||
Used to as part of the Install Tab UI generation
|
Used to as part of the Install Tab UI generation
|
||||||
.PARAMETER TargetElement
|
.PARAMETER TargetElement
|
||||||
The Element into which the Categories and Apps should be placed
|
The Element into which the Categories and Apps should be placed
|
||||||
.PARAMETER Apps
|
.PARAMETER Apps
|
||||||
The Hashtable of Apps to be added to the UI
|
The Hashtable of Apps to be added to the UI
|
||||||
The Categories are also extracted from the Apps Hashtable
|
The Categories are also extracted from the Apps Hashtable
|
||||||
|
|
||||||
#>
|
#>
|
||||||
param(
|
param(
|
||||||
$TargetElement,
|
$TargetElement,
|
||||||
@ -20,7 +20,7 @@ function Initialize-InstallCategoryAppList {
|
|||||||
[string]$Category,
|
[string]$Category,
|
||||||
[Windows.Controls.ItemsControl]$TargetElement
|
[Windows.Controls.ItemsControl]$TargetElement
|
||||||
)
|
)
|
||||||
|
|
||||||
$toggleButton = New-Object Windows.Controls.Primitives.ToggleButton
|
$toggleButton = New-Object Windows.Controls.Primitives.ToggleButton
|
||||||
$toggleButton.Content = "$Category"
|
$toggleButton.Content = "$Category"
|
||||||
$toggleButton.Tag = "CategoryToggleButton"
|
$toggleButton.Tag = "CategoryToggleButton"
|
||||||
@ -51,7 +51,7 @@ function Initialize-InstallCategoryAppList {
|
|||||||
$null = $TargetElement.Items.Add($sync.LoadingLabel)
|
$null = $TargetElement.Items.Add($sync.LoadingLabel)
|
||||||
# Use the Dispatcher to make sure the Loading message is shown before the logic loading the apps starts, and only is removed when the loading is complete and the apps are added to the UI
|
# Use the Dispatcher to make sure the Loading message is shown before the logic loading the apps starts, and only is removed when the loading is complete and the apps are added to the UI
|
||||||
$TargetElement.Dispatcher.Invoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{
|
$TargetElement.Dispatcher.Invoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{
|
||||||
|
|
||||||
$TargetElement.Items.Clear() # Remove the loading message
|
$TargetElement.Items.Clear() # Remove the loading message
|
||||||
$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) {
|
||||||
@ -69,4 +69,4 @@ function Initialize-InstallCategoryAppList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ function Initialize-InstallHeader {
|
|||||||
$selectedAppsButton.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor")
|
$selectedAppsButton.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor")
|
||||||
$selectedAppsButton.HorizontalAlignment = "Center"
|
$selectedAppsButton.HorizontalAlignment = "Center"
|
||||||
$selectedAppsButton.VerticalAlignment = "Center"
|
$selectedAppsButton.VerticalAlignment = "Center"
|
||||||
|
|
||||||
$selectedAppsPopup = New-Object Windows.Controls.Primitives.Popup
|
$selectedAppsPopup = New-Object Windows.Controls.Primitives.Popup
|
||||||
$selectedAppsPopup.IsOpen = $false
|
$selectedAppsPopup.IsOpen = $false
|
||||||
$selectedAppsPopup.PlacementTarget = $selectedAppsButton
|
$selectedAppsPopup.PlacementTarget = $selectedAppsButton
|
||||||
@ -61,7 +61,7 @@ function Initialize-InstallHeader {
|
|||||||
$selectedAppsBorder.Padding = 5
|
$selectedAppsBorder.Padding = 5
|
||||||
$selectedAppsPopup.Child = $selectedAppsBorder
|
$selectedAppsPopup.Child = $selectedAppsBorder
|
||||||
$sync.selectedAppsPopup = $selectedAppsPopup
|
$sync.selectedAppsPopup = $selectedAppsPopup
|
||||||
|
|
||||||
$sync.selectedAppsstackPanel = New-Object Windows.Controls.StackPanel
|
$sync.selectedAppsstackPanel = New-Object Windows.Controls.StackPanel
|
||||||
$selectedAppsBorder.Child = $sync.selectedAppsstackPanel
|
$selectedAppsBorder.Child = $sync.selectedAppsstackPanel
|
||||||
|
|
||||||
@ -86,4 +86,4 @@ function Initialize-InstallHeader {
|
|||||||
|
|
||||||
[Windows.Controls.DockPanel]::SetDock($wrapPanelTop, [Windows.Controls.Dock]::Top)
|
[Windows.Controls.DockPanel]::SetDock($wrapPanelTop, [Windows.Controls.Dock]::Top)
|
||||||
$null = $TargetElement.Children.Add($wrapPanelTop)
|
$null = $TargetElement.Children.Add($wrapPanelTop)
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ function Set-CategoryVisibility {
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Used to expand or collapse categories and corresponding apps on the install tab
|
Used to expand or collapse categories and corresponding apps on the install tab
|
||||||
|
|
||||||
.PARAMETER Category
|
.PARAMETER Category
|
||||||
Can eigther be a specific category name like "Browsers" OR "*" to affect all categories at once
|
Can eigther be a specific category name like "Browsers" OR "*" to affect all categories at once
|
||||||
|
|
||||||
.PARAMETER overrideState
|
.PARAMETER overrideState
|
||||||
"Expand" => expands the corresponding elements
|
"Expand" => expands the corresponding elements
|
||||||
"Collapse" => collapses the corresponding elements
|
"Collapse" => collapses the corresponding elements
|
||||||
@ -17,8 +17,8 @@ function Set-CategoryVisibility {
|
|||||||
[ValidateSet("Expand", "Collapse")]
|
[ValidateSet("Expand", "Collapse")]
|
||||||
[string]$overrideState
|
[string]$overrideState
|
||||||
)
|
)
|
||||||
|
|
||||||
switch ($overrideState){
|
switch ($overrideState) {
|
||||||
"Expand" {$state = $true}
|
"Expand" {$state = $true}
|
||||||
"Collapse" {$state = $false}
|
"Collapse" {$state = $false}
|
||||||
default {$state = $sync.CompactView}
|
default {$state = $sync.CompactView}
|
||||||
@ -29,7 +29,7 @@ function Set-CategoryVisibility {
|
|||||||
if ($category -eq "*") {
|
if ($category -eq "*") {
|
||||||
$items = $sync.ItemsControl.Items | Where-Object {($_.Tag -like "CategoryWrapPanel_*")}
|
$items = $sync.ItemsControl.Items | Where-Object {($_.Tag -like "CategoryWrapPanel_*")}
|
||||||
$sync.ItemsControl.Items | Where-Object {($_.Tag -eq "CategoryToggleButton")} | Foreach-Object { $_.Visibility = [Windows.Visibility]::Visible; $_.IsChecked = $state }
|
$sync.ItemsControl.Items | Where-Object {($_.Tag -eq "CategoryToggleButton")} | Foreach-Object { $_.Visibility = [Windows.Visibility]::Visible; $_.IsChecked = $state }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$items = $sync.ItemsControl.Items | Where-Object {($_.Tag -eq "CategoryWrapPanel_$Category")}
|
$items = $sync.ItemsControl.Items | Where-Object {($_.Tag -eq "CategoryWrapPanel_$Category")}
|
||||||
}
|
}
|
||||||
@ -41,4 +41,4 @@ function Set-CategoryVisibility {
|
|||||||
$items.Children | ForEach-Object {
|
$items.Children | ForEach-Object {
|
||||||
$_.Visibility = $elementVisibility
|
$_.Visibility = $elementVisibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,4 +51,4 @@ function Show-OnlyCheckedApps {
|
|||||||
}
|
}
|
||||||
Set-CategoryVisibility -Category "*"
|
Set-CategoryVisibility -Category "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ function Invoke-WPFSelectedAppsUpdate {
|
|||||||
$sync.selectedApps.Add($appKey)
|
$sync.selectedApps.Add($appKey)
|
||||||
# The List type needs to be specified again, because otherwise Sort-Object will convert the list to a string if there is only a single entry
|
# The List type needs to be specified again, because otherwise Sort-Object will convert the list to a string if there is only a single entry
|
||||||
[System.Collections.Generic.List[pscustomobject]]$sync.selectedApps = $sync.SelectedApps | Sort-Object
|
[System.Collections.Generic.List[pscustomobject]]$sync.selectedApps = $sync.SelectedApps | Sort-Object
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif ($type -eq "Remove") {
|
elseif ($type -eq "Remove") {
|
||||||
$sync.SelectedApps.Remove($appKey)
|
$sync.SelectedApps.Remove($appKey)
|
||||||
@ -33,11 +33,11 @@ function Invoke-WPFSelectedAppsUpdate {
|
|||||||
else{
|
else{
|
||||||
Write-Error "Type: $type not implemented"
|
Write-Error "Type: $type not implemented"
|
||||||
}
|
}
|
||||||
|
|
||||||
$count = $sync.SelectedApps.Count
|
$count = $sync.SelectedApps.Count
|
||||||
$selectedAppsButton.Content = "Selected Apps: $count"
|
$selectedAppsButton.Content = "Selected Apps: $count"
|
||||||
# On every change, remove all entries inside the Popup Menu. This is done, so we can keep the alphabetical order even if elements are selected in a random way
|
# On every change, remove all entries inside the Popup Menu. This is done, so we can keep the alphabetical order even if elements are selected in a random way
|
||||||
$sync.selectedAppsstackPanel.Children.Clear()
|
$sync.selectedAppsstackPanel.Children.Clear()
|
||||||
$sync.SelectedApps | Foreach-Object { Add-SelectedAppsMenuItem -name $($sync.configs.applicationsHashtable.$_.Content) -key $_ }
|
$sync.SelectedApps | Foreach-Object { Add-SelectedAppsMenuItem -name $($sync.configs.applicationsHashtable.$_.Content) -key $_ }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ function Invoke-WPFUIApps {
|
|||||||
switch ($TargetGridName) {
|
switch ($TargetGridName) {
|
||||||
"appspanel" {
|
"appspanel" {
|
||||||
$dockPanel = Initialize-InstallAppsMainElement -TargetGridName $TargetGridName
|
$dockPanel = Initialize-InstallAppsMainElement -TargetGridName $TargetGridName
|
||||||
$null = Initialize-InstallHeader -TargetElement $dockPanel
|
$null = Initialize-InstallHeader -TargetElement $dockPanel
|
||||||
$sync.ItemsControl = Initialize-InstallAppArea -TargetElement $dockPanel
|
$sync.ItemsControl = Initialize-InstallAppArea -TargetElement $dockPanel
|
||||||
Initialize-InstallCategoryAppList -TargetElement $sync.ItemsControl -Apps $Apps
|
Initialize-InstallCategoryAppList -TargetElement $sync.ItemsControl -Apps $Apps
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user