Compare commits

..

No commits in common. "5ee515e5f87a79fa3b42a9284b1e4995780db816" and "591675e8324b0ccdd0fd9599fe550bba8cfdd4bf" have entirely different histories.

2 changed files with 9 additions and 21 deletions

View File

@ -13,14 +13,7 @@ function Set-WinUtilUITheme {
The name of the default theme to use when setting the XAML. Defaults to '_default'
.EXAMPLE
$returnVal = Set-WinUtilUITheme -inputXAML $inputXAML
if ($returnVal[0] -eq "") {
Write-Host "Failed to process inputXML"
} else {
$inputXML = $returnVal[0]
}
# to know which theme this function has used, access the second item in returned value.
Write-Host "Theme used in processing: $($returnVal[1])"
Set-WinUtilUITheme -inputXAML $inputXAML
#>
param (
@ -48,23 +41,21 @@ function Set-WinUtilUITheme {
throw [GenericException]::new("[Set-WinUtilTheme] Did not find '$defaultThemeName' theme in the themes config file.")
}
$themeToUse = $customThemeName
if ($sync.configs.themes.$themeToUse) {
if ($sync.configs.themes.$customThemeName) {
# Loop through every default theme option, and modify the custom theme in $sync variable,
# so that it has full options available for other functions to use.
foreach ($option in $sync.configs.themes.$defaultThemeName.PSObject.Properties) {
$optionName = $option.Name
$optionValue = $option.Value
if (-NOT $sync.configs.themes.$themeToUse.$optionName) {
$sync.configs.themes.$themeToUse | Add-Member -MemberType NoteProperty -Name $optionName -Value $optionValue
if (-NOT $sync.configs.themes.$customThemeName.$optionName) {
$sync.configs.themes.$customThemeName | Add-Member -MemberType NoteProperty -Name $optionName -Value $optionValue
}
}
} else {
Write-Debug "[Set-WinUtilTheme] Theme '$customThemeName' was not found, using '$defaultThemeName' instead."
$themeToUse = $defaultThemeName
Write-Debug "[Set-WinUtilTheme] Theme '$customThemeName' was not found."
}
foreach ($property in $sync.configs.themes.$themeToUse.PSObject.Properties) {
foreach ($property in $sync.configs.themes.$customThemeName.PSObject.Properties) {
$key = $property.Name
$value = $property.Value
# Add curly braces around the key
@ -79,5 +70,5 @@ function Set-WinUtilUITheme {
$inputXML = "" # Make inputXML equal an empty string, indicating something went wrong to the function caller.
}
return @($inputXML, $themeToUse);
return $inputXML;
}

View File

@ -52,7 +52,6 @@ $sync.runspace.Open()
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
$defaulttheme = '_default'
if ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True) {
if (Invoke-WinUtilGPU -eq $True) {
$ctttheme = 'Matrix'
@ -63,8 +62,8 @@ if ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True) {
$ctttheme = 'Classic'
}
$returnVal = Set-WinUtilUITheme -inputXML $inputXML -customThemeName $ctttheme -defaultThemeName $defaulttheme
if ($returnVal[0] -eq "") {
$inputXML = Set-WinUtilUITheme -inputXML $inputXML -customThemeName $ctttheme
if ($inputXML -eq "") {
Write-Host "Failed to statically apply theming to xaml content using Set-WinUtilTheme, please check previous Error/Warning messages." -ForegroundColor Red
Write-Host "Quitting winutil..." -ForegroundColor Red
$sync.runspace.Dispose()
@ -72,8 +71,6 @@ if ($returnVal[0] -eq "") {
[System.GC]::Collect()
exit 1
}
$inputXML = $returnVal[0]
$ctttheme = $returnVal[1]
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
[xml]$XAML = $inputXML