winutil/functions/public/Invoke-WPFPresets.ps1
Chris Titus bf271b89e9
Test 2024 01 15 (#1456)
* File Converter

* Adding wiki directory where we can start storing all the wikis for now (#1405)

* change logseq url and add .net 8 (#1385)

* Update applications.json

Add Official logseq url 
Add .net runtime 8.0

* compile with new logseq and .net 8 runtime

* add thorium avx2

* Compile Winutil

* Anoter one of those huge PRs
- Fix version inefficiency the version is already stored in sync, no need to slow down loading by one extra replace.
- Created custom dialog and About message
- Create a menu with Import/Export values
	- press on teh Settings cog in the right upper corner and save all the checkboxes
	- then you can either load them or load and run automatically
- Made Import Export load accross the whole app
- Optimized the way checkbox controls are looked up, it is 20% faster now
- Added a switch to load all the boxes from a config file
	- example: .winutil.ps1 -Config "C:UsersasdfDesktop\111.json"
- Added a switch to run all the action in unattended mode by passing -Run siwthc
	- example: .winutil.ps1 -Config "C:UsersasdfDesktop\111.json" -Run
	- This will run all the tweaks and install all the apps

* Fixing a couple of bugs and blur fonts, also menu now closes when focus is lost

* Remove Cider Music Player (#1400)

* Update winutil.ps1

* Update applications.json

* Compile Winutil

* Checking in wiki files. Once you get wiki going you will be able to just copy this content to the wiki. Or leave it as-is, which maybe better because than the community could edit it

* Adding microwin usage error wiki

* fixing link the the new wiki location

* Adding automation section to the readme

* Fixing doc errors

* Adding conda and a couple or tools used by scientists, also fixing a nesty bug with winget if you don't specify scope=machine tools like python will not work correctly

* fix application mismatch

* Update applications.json

---------

Co-authored-by: Cristian Negulescu <cristian@clamsen.com>
Co-authored-by: Chris Titus <dfm.titus@gmail.com>
Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>
Co-authored-by: KonTy <KonTy@github.com>
Co-authored-by: Tommi Pöntinen <98650216+hamburgerghini1@users.noreply.github.com>
Co-authored-by: Chris Titus <contact@christitus.com>

* Compile Winutil

* remove files application (#1408)

* Update README.md (#1421)

* Compile Winutil

* Update links, descriptions + add choco id for twinkle tray (#1426)

* update twinkle tray

* update wingetui

* update wisetoys link

* update floorp link

* Compile Winutil

* Add some useful programs and fix an app's url (#1427)

* fix the link for strawberry music player

The existing one opens a python library

* feat: add some useful apps

* changed the link in the wrong place

* Compile Winutil

* Added new toggle tweak button (#1434)

* add new ToggleSwitch

* add new function to disable/enable toggle button

* add new name of the button for the given toggle

* added new toggle tweak

* Compile Winutil

* Feat: Add Microsoft Power BI program (#1438)

* Compile Winutil

* Fix Fredium App Link (#1440)

* Update applications.json (#1448)

Updated the link to Prism Launcher to point to the correct url

* Compile Winutil

* fix for bug with selecting presets and toggle switches (#1447)

* Update Invoke-WPFPresets.ps1

* Update Invoke-WPFPresets.ps1

* Compile Winutil

* Update winutil.ps1

---------

Co-authored-by: KonTy <9524513+KonTy@users.noreply.github.com>
Co-authored-by: Cristian Negulescu <cristian@clamsen.com>
Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>
Co-authored-by: KonTy <KonTy@github.com>
Co-authored-by: Tommi Pöntinen <98650216+hamburgerghini1@users.noreply.github.com>
Co-authored-by: Munkk <152475628+munkk01@users.noreply.github.com>
Co-authored-by: DeveloperDurp <developerdurp@durp.info>
Co-authored-by: OmriOn <76548146+OmriOn@users.noreply.github.com>
Co-authored-by: Keshav S <55992029+Keshav13142@users.noreply.github.com>
Co-authored-by: Vuk Lekić <vuklekic22@gmail.com>
Co-authored-by: André Gonzalez <lopescg@gmail.com>
Co-authored-by: playgroundsskiff <149293245+playgroundsskiff@users.noreply.github.com>
Co-authored-by: BusterBean <73446417+BusterBean@users.noreply.github.com>
2024-01-25 14:44:51 -06:00

60 lines
1.6 KiB
PowerShell

function Invoke-WPFPresets {
<#
.SYNOPSIS
Sets the options in the tweaks panel to the given preset
.PARAMETER preset
The preset to set the options to
.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'
#>
param(
$preset,
[bool]$imported = $false
)
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)"
$CheckBoxesToCheck | ForEach-Object {
if ($_ -ne $null) {
Write-Debug $_
}
}
foreach ($CheckBox in $CheckBoxes) {
$checkboxName = $CheckBox.Key
if (-not $CheckBoxesToCheck)
{
$sync.$checkboxName.IsChecked = $false
continue
}
# Check if the checkbox name exists in the flattened JSON hashtable
if ($CheckBoxesToCheck.Contains($checkboxName)) {
# If it exists, set IsChecked to true
$sync.$checkboxName.IsChecked = $true
Write-Debug "$checkboxName is checked"
} else {
# If it doesn't exist, set IsChecked to false
$sync.$checkboxName.IsChecked = $false
Write-Debug "$checkboxName is not checked"
}
}
}