diff --git a/Compile.ps1 b/Compile.ps1
index 1bb5b03f..c04c600b 100644
--- a/Compile.ps1
+++ b/Compile.ps1
@@ -1,6 +1,9 @@
$OFS = "`r`n"
$scriptname = "winutil.ps1"
-
+# Variable to sync between runspaces
+$sync = [Hashtable]::Synchronized(@{})
+$sync.PSScriptRoot = $PSScriptRoot
+$sync.configs = @{}
if (Test-Path -Path "$($scriptname)")
{
@@ -21,15 +24,20 @@ Get-ChildItem .\functions -Recurse -File | ForEach-Object {
Get-Content $psitem.FullName | Out-File ./$scriptname -Append -Encoding ascii
}
-Get-ChildItem .\xaml | ForEach-Object {
- $xaml = (Get-Content $psitem.FullName).replace("'","''")
- Write-output "`$$($psitem.BaseName) = '$xaml'" | Out-File ./$scriptname -Append -Encoding ascii
-}
+$xaml = (Get-Content .\xaml\inputXML.xaml).replace("'","''")
+Write-output "`$inputXML = '$xaml'" | Out-File ./$scriptname -Append -Encoding ascii
Get-ChildItem .\config | Where-Object {$psitem.extension -eq ".json"} | ForEach-Object {
$json = (Get-Content $psitem.FullName).replace("'","''")
-
+ $sync.configs.$($psitem.BaseName) = $json | convertfrom-json
Write-output "`$sync.configs.$($psitem.BaseName) = '$json' `| convertfrom-json" | Out-File ./$scriptname -Append -Encoding ascii
}
-Get-Content .\scripts\main.ps1 | Out-File ./$scriptname -Append -Encoding ascii
+# Dot-source the Get-TabXaml function
+. .\functions\private\Get-TabXaml.ps1
+
+## Xaml Manipulation
+$tabColumns = Get-TabXaml "applications" 5
+$tabColumns | Out-File -FilePath ".\xaml\inputApp.xaml" -Encoding ascii
+
+Get-Content .\scripts\main.ps1 | Out-File ./$scriptname -Append -Encoding ascii
\ No newline at end of file
diff --git a/functions/private/Get-TabXaml.ps1 b/functions/private/Get-TabXaml.ps1
new file mode 100644
index 00000000..a420e344
--- /dev/null
+++ b/functions/private/Get-TabXaml.ps1
@@ -0,0 +1,125 @@
+function Get-TabXaml {
+ <#
+ .SYNOPSIS
+ Generates XAML for a tab in the WinUtil GUI
+ This function is used to generate the XAML for the applications tab in the WinUtil GUI
+ It takes the tabname and the number of columns to display the applications in as input and returns the XAML for the tab as output
+ .PARAMETER tabname
+ The name of the tab to generate XAML for
+ .PARAMETER columncount
+ The number of columns to display the applications in
+ .OUTPUTS
+ The XAML for the tab
+ .EXAMPLE
+ Get-TabXaml "applications" 3
+ #>
+
+
+ param( [Parameter(Mandatory=$true)]
+ $tabname,
+ $columncount = 0
+ )
+ $organizedData = @{}
+ # Iterate through JSON data and organize by panel and category
+ foreach ($appName in $sync.configs.$tabname.PSObject.Properties.Name) {
+ $appInfo = $sync.configs.$tabname.$appName
+
+ # Create an object for the application
+ $appObject = [PSCustomObject]@{
+ Name = $appName
+ Category = $appInfo.Category
+ Content = $appInfo.Content
+ Choco = $appInfo.choco
+ Winget = $appInfo.winget
+ Panel = if ($columncount -gt 0 ) { "0" } else {$appInfo.panel}
+ Link = $appInfo.link
+ Description = $appInfo.description
+ # Type is (Checkbox,Toggle,Button,Combobox ) (Default is Checkbox)
+ Type = $appInfo.type
+ ComboItems = $appInfo.ComboItems
+ # Checked is the property to set startup checked status of checkbox (Default is false)
+ Checked = $appInfo.Checked
+ }
+
+ if (-not $organizedData.ContainsKey($appObject.panel)) {
+ $organizedData[$appObject.panel] = @{}
+ }
+
+ if (-not $organizedData[$appObject.panel].ContainsKey($appObject.Category)) {
+ $organizedData[$appObject.panel][$appObject.Category] = @{}
+ }
+
+ # Store application data in a sub-array under the category
+ # Add Order property to keep the original order of tweaks and features
+ $organizedData[$appObject.panel][$appInfo.Category]["$($appInfo.order)$appName"] = $appObject
+ }
+ $panelcount=0
+ $paneltotal = $organizedData.Keys.Count
+ if ($columncount -gt 0) {
+ $appcount = $sync.configs.$tabname.PSObject.Properties.Name.count + $organizedData["0"].Keys.count
+ $maxcount = [Math]::Round( $appcount / $columncount + 0.5)
+ $paneltotal = $columncount
+ }
+ # add ColumnDefinitions to evenly draw colums
+ $blockXml="`n"+("`n"*($paneltotal))+"`n"
+ # Iterate through organizedData by panel, category, and application
+ $count = 0
+ foreach ($panel in ($organizedData.Keys | Sort-Object)) {
+ $blockXml += "`n`n"
+ $panelcount++
+ foreach ($category in ($organizedData[$panel].Keys | Sort-Object)) {
+ $count++
+ if ($columncount -gt 0) {
+ $panelcount2 = [Int](($count)/$maxcount-0.5)
+ if ($panelcount -eq $panelcount2 ) {
+ $blockXml +="`n`n`n"
+ $blockXml += "`n`n"
+ $panelcount++
+ }
+ }
+ $blockXml += "`n"
+ $sortedApps = $organizedData[$panel][$category].Keys | Sort-Object
+ foreach ($appName in $sortedApps) {
+ $count++
+ if ($columncount -gt 0) {
+ $panelcount2 = [Int](($count)/$maxcount-0.5)
+ if ($panelcount -eq $panelcount2 ) {
+ $blockXml +="`n`n`n"
+ $blockXml += "`n`n"
+ $panelcount++
+ }
+ }
+ $appInfo = $organizedData[$panel][$category][$appName]
+ if ("Toggle" -eq $appInfo.Type) {
+ $blockXml += "`n`n"
+ $blockXml += "`n`n"
+ } elseif ("Combobox" -eq $appInfo.Type) {
+ $blockXml += "`n"
+ # If it is a digit, type is button and button length is digits
+ } elseif ($appInfo.Type -match "^[\d\.]+$") {
+ $blockXml += "`n"
+ # else it is a checkbox
+ } else {
+ $checkedStatus = If ($null -eq $appInfo.Checked) {""} Else {"IsChecked=`"$($appInfo.Checked)`" "}
+ if ($null -eq $appInfo.Link)
+ {
+ $blockXml += "`n"
+ }
+ else
+ {
+ $blockXml += "`n`n`n"
+ }
+ }
+ }
+ }
+ $blockXml +="`n`n`n"
+ }
+ return ($blockXml)
+}
diff --git a/scripts/main.ps1 b/scripts/main.ps1
index 7549acaf..fc9d9493 100644
--- a/scripts/main.ps1
+++ b/scripts/main.ps1
@@ -52,118 +52,15 @@ $sync.runspace.Open()
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^`n"+("`n"*($paneltotal))+"`n"
- # Iterate through organizedData by panel, category, and application
- $count = 0
- foreach ($panel in ($organizedData.Keys | Sort-Object)) {
- $blockXml += "`n`n"
- $panelcount++
- foreach ($category in ($organizedData[$panel].Keys | Sort-Object)) {
- $count++
- if ($columncount -gt 0) {
- $panelcount2 = [Int](($count)/$maxcount-0.5)
- if ($panelcount -eq $panelcount2 ) {
- $blockXml +="`n`n`n"
- $blockXml += "`n`n"
- $panelcount++
- }
- }
- $blockXml += "`n"
- $sortedApps = $organizedData[$panel][$category].Keys | Sort-Object
- foreach ($appName in $sortedApps) {
- $count++
- if ($columncount -gt 0) {
- $panelcount2 = [Int](($count)/$maxcount-0.5)
- if ($panelcount -eq $panelcount2 ) {
- $blockXml +="`n`n`n"
- $blockXml += "`n`n"
- $panelcount++
- }
- }
- $appInfo = $organizedData[$panel][$category][$appName]
- if ("Toggle" -eq $appInfo.Type) {
- $blockXml += "`n`n"
- $blockXml += "`n`n"
- } elseif ("Combobox" -eq $appInfo.Type) {
- $blockXml += "`n"
- # If it is a digit, type is button and button length is digits
- } elseif ($appInfo.Type -match "^[\d\.]+$") {
- $blockXml += "`n"
- # else it is a checkbox
- } else {
- $checkedStatus = If ($null -eq $appInfo.Checked) {""} Else {"IsChecked=`"$($appInfo.Checked)`" "}
- if ($null -eq $appInfo.Link)
- {
- $blockXml += "`n"
- }
- else
- {
- $blockXml += "`n`n`n"
- }
- }
- }
- }
- $blockXml +="`n`n`n"
- }
- return ($blockXml)
-}
-
-$tabcolums=Get-TabXaml "applications" 5
-$inputXML = $inputXML -replace "{{InstallPanel_applications}}", ($tabcolums)
$tabcolums=Get-TabXaml "tweaks"
$inputXML = $inputXML -replace "{{InstallPanel_tweaks}}", ($tabcolums)
$tabcolums=Get-TabXaml "feature"
diff --git a/winutil.ps1 b/winutil.ps1
index 9e279b50..45199f36 100644
--- a/winutil.ps1
+++ b/winutil.ps1
@@ -258,6 +258,131 @@ function Get-Oscdimg {
Write-Host "Hashes do not match. File may be corrupted or tampered with."
}
}
+function Get-TabXaml {
+ <#
+ .SYNOPSIS
+ Generates XAML for a tab in the WinUtil GUI
+ This function is used to generate the XAML for the applications tab in the WinUtil GUI
+ It takes the tabname and the number of columns to display the applications in as input and returns the XAML for the tab as output
+ .PARAMETER tabname
+ The name of the tab to generate XAML for
+ .PARAMETER columncount
+ The number of columns to display the applications in
+ .OUTPUTS
+ The XAML for the tab
+ .EXAMPLE
+ Get-TabXaml "applications" 3
+ #>
+
+
+ param( [Parameter(Mandatory=$true)]
+ $tabname,
+ $columncount = 0
+ )
+ $organizedData = @{}
+ # Iterate through JSON data and organize by panel and category
+ foreach ($appName in $sync.configs.$tabname.PSObject.Properties.Name) {
+ $appInfo = $sync.configs.$tabname.$appName
+
+ # Create an object for the application
+ $appObject = [PSCustomObject]@{
+ Name = $appName
+ Category = $appInfo.Category
+ Content = $appInfo.Content
+ Choco = $appInfo.choco
+ Winget = $appInfo.winget
+ Panel = if ($columncount -gt 0 ) { "0" } else {$appInfo.panel}
+ Link = $appInfo.link
+ Description = $appInfo.description
+ # Type is (Checkbox,Toggle,Button,Combobox ) (Default is Checkbox)
+ Type = $appInfo.type
+ ComboItems = $appInfo.ComboItems
+ # Checked is the property to set startup checked status of checkbox (Default is false)
+ Checked = $appInfo.Checked
+ }
+
+ if (-not $organizedData.ContainsKey($appObject.panel)) {
+ $organizedData[$appObject.panel] = @{}
+ }
+
+ if (-not $organizedData[$appObject.panel].ContainsKey($appObject.Category)) {
+ $organizedData[$appObject.panel][$appObject.Category] = @{}
+ }
+
+ # Store application data in a sub-array under the category
+ # Add Order property to keep the original order of tweaks and features
+ $organizedData[$appObject.panel][$appInfo.Category]["$($appInfo.order)$appName"] = $appObject
+ }
+ $panelcount=0
+ $paneltotal = $organizedData.Keys.Count
+ if ($columncount -gt 0) {
+ $appcount = $sync.configs.$tabname.PSObject.Properties.Name.count + $organizedData["0"].Keys.count
+ $maxcount = [Math]::Round( $appcount / $columncount + 0.5)
+ $paneltotal = $columncount
+ }
+ # add ColumnDefinitions to evenly draw colums
+ $blockXml="`n"+("`n"*($paneltotal))+"`n"
+ # Iterate through organizedData by panel, category, and application
+ $count = 0
+ foreach ($panel in ($organizedData.Keys | Sort-Object)) {
+ $blockXml += "`n`n"
+ $panelcount++
+ foreach ($category in ($organizedData[$panel].Keys | Sort-Object)) {
+ $count++
+ if ($columncount -gt 0) {
+ $panelcount2 = [Int](($count)/$maxcount-0.5)
+ if ($panelcount -eq $panelcount2 ) {
+ $blockXml +="`n`n`n"
+ $blockXml += "`n`n"
+ $panelcount++
+ }
+ }
+ $blockXml += "`n"
+ $sortedApps = $organizedData[$panel][$category].Keys | Sort-Object
+ foreach ($appName in $sortedApps) {
+ $count++
+ if ($columncount -gt 0) {
+ $panelcount2 = [Int](($count)/$maxcount-0.5)
+ if ($panelcount -eq $panelcount2 ) {
+ $blockXml +="`n`n`n"
+ $blockXml += "`n`n"
+ $panelcount++
+ }
+ }
+ $appInfo = $organizedData[$panel][$category][$appName]
+ if ("Toggle" -eq $appInfo.Type) {
+ $blockXml += "`n`n"
+ $blockXml += "`n`n"
+ } elseif ("Combobox" -eq $appInfo.Type) {
+ $blockXml += "`n"
+ # If it is a digit, type is button and button length is digits
+ } elseif ($appInfo.Type -match "^[\d\.]+$") {
+ $blockXml += "`n"
+ # else it is a checkbox
+ } else {
+ $checkedStatus = If ($null -eq $appInfo.Checked) {""} Else {"IsChecked=`"$($appInfo.Checked)`" "}
+ if ($null -eq $appInfo.Link)
+ {
+ $blockXml += "`n"
+ }
+ else
+ {
+ $blockXml += "`n`n`n"
+ }
+ }
+ }
+ }
+ $blockXml +="`n`n`n"
+ }
+ return ($blockXml)
+}
Function Get-WinUtilCheckBoxes {
<#
@@ -4453,7 +4578,7 @@ function Invoke-WPFUpdatessecurity {
Write-Host "-- Updates Set to Recommended ---"
Write-Host "================================="
}
-$inputXML = '`n"+("`n"*($paneltotal))+"`n"
- # Iterate through organizedData by panel, category, and application
- $count = 0
- foreach ($panel in ($organizedData.Keys | Sort-Object)) {
- $blockXml += "`n`n"
- $panelcount++
- foreach ($category in ($organizedData[$panel].Keys | Sort-Object)) {
- $count++
- if ($columncount -gt 0) {
- $panelcount2 = [Int](($count)/$maxcount-0.5)
- if ($panelcount -eq $panelcount2 ) {
- $blockXml +="`n`n`n"
- $blockXml += "`n`n"
- $panelcount++
- }
- }
- $blockXml += "`n"
- $sortedApps = $organizedData[$panel][$category].Keys | Sort-Object
- foreach ($appName in $sortedApps) {
- $count++
- if ($columncount -gt 0) {
- $panelcount2 = [Int](($count)/$maxcount-0.5)
- if ($panelcount -eq $panelcount2 ) {
- $blockXml +="`n`n`n"
- $blockXml += "`n`n"
- $panelcount++
- }
- }
- $appInfo = $organizedData[$panel][$category][$appName]
- if ("Toggle" -eq $appInfo.Type) {
- $blockXml += "`n`n"
- $blockXml += "`n`n"
- } elseif ("Combobox" -eq $appInfo.Type) {
- $blockXml += "`n"
- # If it is a digit, type is button and button length is digits
- } elseif ($appInfo.Type -match "^[\d\.]+$") {
- $blockXml += "`n"
- # else it is a checkbox
- } else {
- $checkedStatus = If ($null -eq $appInfo.Checked) {""} Else {"IsChecked=`"$($appInfo.Checked)`" "}
- if ($null -eq $appInfo.Link)
- {
- $blockXml += "`n"
- }
- else
- {
- $blockXml += "`n`n`n"
- }
- }
- }
- }
- $blockXml +="`n`n`n"
- }
- return ($blockXml)
-}
-
-$tabcolums=Get-TabXaml "applications" 5
-$inputXML = $inputXML -replace "{{InstallPanel_applications}}", ($tabcolums)
$tabcolums=Get-TabXaml "tweaks"
$inputXML = $inputXML -replace "{{InstallPanel_tweaks}}", ($tabcolums)
$tabcolums=Get-TabXaml "feature"
diff --git a/xaml/inputApp.xaml b/xaml/inputApp.xaml
new file mode 100644
index 00000000..de3c71c5
--- /dev/null
+++ b/xaml/inputApp.xaml
@@ -0,0 +1,894 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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