Skip to content

Commit

Permalink
New Theme support, initial functions. (#878)
Browse files Browse the repository at this point in the history
* Fix power profile (#766)

* Fix power profile query

* fix syntax

* fix

* Update Invoke-WPFUltimatePerformance.ps1

* Update winutil.ps1

* power profile fix

* Adding Nomacs Opensource free and fast Image viewer

* Adding theme support

Later when this is tested well, we can do one of 2 things.
1. Pass theme on a command line so people with bad vision will have an option to have a better (more visible theme)
2. Create a drop down with themes and a save button which would save it ti some local config file

* Fix for the compile script

---------

Co-authored-by: Chris Titus <[email protected]>
  • Loading branch information
KonTy and ChrisTitusTech authored Jul 13, 2023
1 parent 836c34f commit 781ba4e
Show file tree
Hide file tree
Showing 7 changed files with 553 additions and 179 deletions.
5 changes: 4 additions & 1 deletion Compile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ $OFS = "`r`n"
$scriptname = "winutil.ps1"


Remove-Item .\$scriptname
if (Test-Path -Path "$($scriptname)")
{
Remove-Item -Force "$($scriptname)"
}

Write-output '
################################################################################################################
Expand Down
4 changes: 4 additions & 0 deletions config/applications.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
"winget": "REALiX.HWiNFO",
"choco": "hwinfo"
},
"WPFInstallnomacs": {
"winget": "nomacs.nomacs",
"choco": "nomacs"
},
"WPFInstallimageglass": {
"winget": "DuongDieuPhap.ImageGlass",
"choco": "imageglass"
Expand Down
42 changes: 42 additions & 0 deletions config/themes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"Classic": {
"ComboBoxBackgroundColor": "#777777",
"LabelboxForegroundColor": "#000000",
"MainForegroundColor": "#000000",
"MainBackgroundColor": "#777777",
"LabelBackgroundColor": "#777777",
"ComboBoxForegroundColor": "#000000",
"ButtonInstallBackgroundColor": "#222222",
"ButtonTweaksBackgroundColor": "#333333",
"ButtonConfigBackgroundColor": "#444444",
"ButtonUpdatesBackgroundColor": "#555555",
"ButtonInstallForegroundColor": "#FFFFFF",
"ButtonBackgroundColor": "#CACACA",
"ButtonBackgroundPressedColor": "#FFFFFF",
"ButtonBackgroundMouseoverColor": "AliceBlue",
"ButtonForegroundColor": "#000000",
"ButtonBorderThickness": "0",
"ButtonMargin": "0,3,0,3",
"ButtonCornerRadius": "0"
},
"Matrix": {
"ComboBoxBackgroundColor": "#000000",
"LabelboxForegroundColor": "#FFEE58",
"MainForegroundColor": "#9CCC65",
"MainBackgroundColor": "#000000",
"LabelBackgroundColor": "#000000",
"ComboBoxForegroundColor": "#FFEE58",
"ButtonInstallBackgroundColor": "#222222",
"ButtonTweaksBackgroundColor": "#333333",
"ButtonConfigBackgroundColor": "#444444",
"ButtonUpdatesBackgroundColor": "#555555",
"ButtonInstallForegroundColor": "#FFFFFF",
"ButtonBackgroundColor": "#000000",
"ButtonBackgroundPressedColor": "#FFFFFF",
"ButtonBackgroundMouseoverColor": "#A55A64",
"ButtonForegroundColor": "#9CCC65",
"ButtonBorderThickness": "3",
"ButtonMargin": "2",
"ButtonCornerRadius": "4"
}
}
48 changes: 48 additions & 0 deletions functions/private/Set-WinUtilUiTheme.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
function Set-WinUtilUITheme {
<#
.DESCRIPTION
This function will set theme to the XAML file
.EXAMPLE
Set-WinUtilUITheme -inputXAML $inputXAML
#>
param
(
[Parameter(Mandatory=$true, Position=0)]
[string] $inputXML,
[Parameter(Mandatory=$false, Position=1)]
[string] $themeName = 'matrix'
)

try {
# Convert the JSON to a PowerShell object
$themes = $sync.configs.themes
# Select the specified theme
$selectedTheme = $themes.$themeName

if ($selectedTheme) {
# Loop through all key-value pairs in the selected theme
foreach ($property in $selectedTheme.PSObject.Properties) {
$key = $property.Name
$value = $property.Value
# Add curly braces around the key
$formattedKey = "{$key}"
# Replace the key with the value in the input XML
$inputXML = $inputXML.Replace($formattedKey, $value)
}
}
else {
Write-Host "Theme '$themeName' not found."
}

}
catch {
Write-Warning "Unable to apply theme"
Write-Warning $psitem.Exception.StackTrace
}

return $inputXML;
}
2 changes: 2 additions & 0 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ $sync.runspace.Open()
#endregion exception classes

$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
$inputXML = Set-WinUtilUITheme -inputXML $inputXML -themeName 'classic'

[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
[xml]$XAML = $inputXML
#Read XAML
Expand Down
Loading

0 comments on commit 781ba4e

Please sign in to comment.