Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve 'Invoke-WPFPresets' Public Function - Made applying tweaks presets go blazingly fast - Made Clearing Selection work properly #2608

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions functions/public/Invoke-WPFButton.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ function Invoke-WPFButton {
Switch -Wildcard ($Button) {

"WPFTab?BT" {Invoke-WPFTab $Button}
"WPFinstall" {Invoke-WPFInstall}
"WPFuninstall" {Invoke-WPFUnInstall}
"WPFInstall" {Invoke-WPFInstall}
"WPFUninstall" {Invoke-WPFUnInstall}
"WPFInstallUpgrade" {Invoke-WPFInstallUpgrade}
"WPFstandard" {Invoke-WPFPresets "Standard"}
"WPFminimal" {Invoke-WPFPresets "Minimal"}
"WPFclear" {Invoke-WPFPresets -preset $null -imported $true}
"WPFclearWinget" {Invoke-WPFPresets -preset $null -imported $true -CheckBox "WPFInstall"}
"WPFStandard" {Invoke-WPFPresets "Standard" -checkboxfilterpattern "WPFTweak*"}
"WPFMinimal" {Invoke-WPFPresets "Minimal" -checkboxfilterpattern "WPFTweak*"}
"WPFClearTweaksSelection" {Invoke-WPFPresets -imported $true -checkboxfilterpattern "WPFTweak*"}
"WPFClearInstallSelection" {Invoke-WPFPresets -imported $true -checkboxfilterpattern "WPFInstall*"}
"WPFtweaksbutton" {Invoke-WPFtweaksbutton}
"WPFOOSUbutton" {Invoke-WPFOOSU}
"WPFAddUltPerf" {Invoke-WPFUltimatePerformance -State "Enable"}
Expand Down
31 changes: 19 additions & 12 deletions functions/public/Invoke-WPFPresets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,36 @@ function Invoke-WPFPresets {
.PARAMETER imported
If the preset is imported from a file, defaults to false

.PARAMETER checkbox
The checkbox to set the options to, defaults to 'WPFTweaks'
.PARAMETER checkboxfilterpattern
The Pattern to use when filtering through CheckBoxes, defaults to "**"

#>

param(
$preset,
[bool]$imported = $false
param (
[Parameter(position=0)]
[string]$preset = "",

[Parameter(position=1)]
[bool]$imported = $false,

[Parameter(position=2)]
[string]$checkboxfilterpattern = "**"
)

if($imported -eq $true) {
if ($imported -eq $true) {
$CheckBoxesToCheck = $preset
} else {
$CheckBoxesToCheck = $sync.configs.preset.$preset
}

$CheckBoxes = $sync.GetEnumerator() | Where-Object { $_.Value -is [System.Windows.Controls.CheckBox] -and $_.Name -notlike "WPFToggle*" }
Write-Debug "Getting checkboxes to set $($CheckBoxes.Count)"
$CheckBoxes = ($sync.GetEnumerator()).where{ $_.Value -is [System.Windows.Controls.CheckBox] -and $_.Name -notlike "WPFToggle*" -and $_.Name -like "$checkboxfilterpattern"}
Write-Debug "Getting checkboxes to set, number of checkboxes: $($CheckBoxes.Count)"

$CheckBoxesToCheck | ForEach-Object {
if ($_ -ne $null) {
Write-Debug $_
}
if ($CheckBoxesToCheck -ne "") {
$debugMsg = "CheckBoxes to Check are: "
$CheckBoxesToCheck | ForEach-Object { $debugMsg += "$_, " }
$debugMsg = $debugMsg -replace (',\s*$', '')
Write-Debug "$debugMsg"
}

foreach ($CheckBox in $CheckBoxes) {
Expand Down
6 changes: 3 additions & 3 deletions xaml/inputXML.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -787,11 +787,11 @@
<RowDefinition Height="0.95*"/>
</Grid.RowDefinitions>
<StackPanel Background="{MainBackgroundColor}" Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Grid.ColumnSpan="3" Margin="{TabContentMargin}">
<Button Name="WPFinstall" Content=" Install/Upgrade Selected" Margin="2" />
<Button Name="WPFInstall" Content=" Install/Upgrade Selected" Margin="2" />
<Button Name="WPFInstallUpgrade" Content=" Upgrade All" Margin="2"/>
<Button Name="WPFuninstall" Content=" Uninstall Selected" Margin="2"/>
<Button Name="WPFUninstall" Content=" Uninstall Selected" Margin="2"/>
<Button Name="WPFGetInstalled" Content=" Get Installed" Margin="2"/>
<Button Name="WPFclearWinget" Content=" Clear Selection" Margin="2"/>
<Button Name="WPFClearInstallSelection" Content=" Clear Selection" Margin="2"/>
</StackPanel>

<ScrollViewer x:Name="scrollViewer" Grid.Row="1" Grid.Column="0" Margin="{TabContentMargin}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
Expand Down
Loading