mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-28 00:54:47 -05:00
[02] Refactoring code (Reopening of PR #2469, plus some modifications to make PR #2629 merge easily without any problem) (#2630)
* Remove leftover comment & update another comment in 'Get-TabXaml' Private Function
* Add new 'CloseIconFontSize' Theme Option
This's done to fix the Visual Issue of the Close Button being smaller than the Settings Button.
* Rename 'CheckBoxBulletDecoratorFontSize' to 'CheckBoxBulletDecoratorSize'
* Experiment with DPI Aware Units
* Remove extra whitespace characters in 'theme.json'
* Implement Default Theming - Add Error Checking & Quitting Early upon XML Related Failures - Simple Code Formatting here & there
* Replace Tabs with Spaces to follow the conventions
* Fix some logic issue in 'Set-WinUtilUITheme.ps1' Private Function - Rename 'Set-WinUtilUiTheme.ps1' -> 'Set-WinUtilUITheme.ps1'
* Change output info from 'Write-Warning' to 'Write-Host' to make sure it's displayed even in RunSpaces as well as PowerShell 5 Environments
* Revert back to default Unit of Measuring for WPF (1/96 in)
* Revert "Remove leftover comment & update another comment in 'Get-TabXaml' Private Function"
This reverts commit 368e5980df
.
* Update 'themes.json' so the general changes will work with PR #2629
* Support the fallback to default theme (if it exists)
* Update 'Set-WinUtilUITheme' Documentation
---------
Co-authored-by: MyDrift <personal@mdiana.ch>
This commit is contained in:
@ -52,6 +52,7 @@ $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'
|
||||
@ -61,15 +62,28 @@ if ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True) {
|
||||
} else {
|
||||
$ctttheme = 'Classic'
|
||||
}
|
||||
$inputXML = Set-WinUtilUITheme -inputXML $inputXML -themeName $ctttheme
|
||||
|
||||
$returnVal = Set-WinUtilUITheme -inputXML $inputXML -customThemeName $ctttheme -defaultThemeName $defaulttheme
|
||||
if ($returnVal[0] -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()
|
||||
$sync.runspace.Close()
|
||||
[System.GC]::Collect()
|
||||
exit 1
|
||||
}
|
||||
$inputXML = $returnVal[0]
|
||||
$ctttheme = $returnVal[1]
|
||||
|
||||
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
|
||||
[xml]$XAML = $inputXML
|
||||
|
||||
# Read the XAML file
|
||||
$readerOperationSuccessful = $false # There's more cases of failure then success.
|
||||
$reader = (New-Object System.Xml.XmlNodeReader $xaml)
|
||||
try {
|
||||
$sync["Form"] = [Windows.Markup.XamlReader]::Load( $reader )
|
||||
$readerOperationSuccessful = $true
|
||||
} catch [System.Management.Automation.MethodInvocationException] {
|
||||
Write-Warning "We ran into a problem with the XAML code. Check the syntax for this control..."
|
||||
Write-Host $error[0].Exception.Message -ForegroundColor Red
|
||||
@ -81,6 +95,15 @@ try {
|
||||
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
|
||||
}
|
||||
|
||||
if (-NOT ($readerOperationSuccessful)) {
|
||||
Write-Host "Failed to parse xaml content using Windows.Markup.XamlReader's Load Method." -ForegroundColor Red
|
||||
Write-Host "Quitting winutil..." -ForegroundColor Red
|
||||
$sync.runspace.Dispose()
|
||||
$sync.runspace.Close()
|
||||
[System.GC]::Collect()
|
||||
exit 1
|
||||
}
|
||||
|
||||
#===========================================================================
|
||||
# Store Form Objects In PowerShell
|
||||
#===========================================================================
|
||||
|
Reference in New Issue
Block a user