mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-01 02:22:34 -05:00
Compare commits
9 Commits
25.05.05
...
3be1999c22
Author | SHA1 | Date | |
---|---|---|---|
3be1999c22 | |||
b15f31fdf8 | |||
47e80010d1 | |||
1132d53944 | |||
bb39be794b | |||
ec4cb1d520 | |||
eaa19eba8a | |||
dfe7dc4044 | |||
4402c5cf31 |
13
Compile.ps1
13
Compile.ps1
@ -97,20 +97,7 @@ Get-ChildItem .\config | Where-Object {$psitem.extension -eq ".json"} | ForEach-
|
|||||||
|
|
||||||
$xaml = (Get-Content .\xaml\inputXML.xaml).replace("'","''")
|
$xaml = (Get-Content .\xaml\inputXML.xaml).replace("'","''")
|
||||||
|
|
||||||
# Dot-source the Get-TabXaml function
|
|
||||||
. .\functions\private\Get-TabXaml.ps1
|
|
||||||
|
|
||||||
Update-Progress "Building: Xaml " 75
|
|
||||||
$appXamlContent = Get-TabXaml "applications" 5
|
|
||||||
$tweaksXamlContent = Get-TabXaml "tweaks"
|
|
||||||
$featuresXamlContent = Get-TabXaml "feature"
|
|
||||||
|
|
||||||
|
|
||||||
Update-Progress "Adding: Xaml " 90
|
Update-Progress "Adding: Xaml " 90
|
||||||
# Replace the placeholder in $inputXML with the content of inputApp.xaml
|
|
||||||
$xaml = $xaml -replace "{{InstallPanel_applications}}", $appXamlContent
|
|
||||||
$xaml = $xaml -replace "{{InstallPanel_tweaks}}", $tweaksXamlContent
|
|
||||||
$xaml = $xaml -replace "{{InstallPanel_features}}", $featuresXamlContent
|
|
||||||
|
|
||||||
$script_content.Add($(Write-output "`$inputXML = '$xaml'"))
|
$script_content.Add($(Write-output "`$inputXML = '$xaml'"))
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"HeaderFontFamily": "Consolas, Monaco",
|
"HeaderFontFamily": "Consolas, Monaco",
|
||||||
|
|
||||||
"CheckBoxBulletDecoratorFontSize": "14",
|
"CheckBoxBulletDecoratorFontSize": "14",
|
||||||
"CheckBoxMargin": "15,0,0,2",
|
"CheckBoxMargin": "5,0,0,2",
|
||||||
|
|
||||||
"TabButtonFontSize": "14",
|
"TabButtonFontSize": "14",
|
||||||
"TabButtonWidth": "100",
|
"TabButtonWidth": "100",
|
||||||
@ -86,7 +86,7 @@
|
|||||||
"HeaderFontFamily": "Consolas, Monaco",
|
"HeaderFontFamily": "Consolas, Monaco",
|
||||||
|
|
||||||
"CheckBoxBulletDecoratorFontSize": "14",
|
"CheckBoxBulletDecoratorFontSize": "14",
|
||||||
"CheckBoxMargin": "15,0,0,2",
|
"CheckBoxMargin": "5,0,0,2",
|
||||||
|
|
||||||
"TabButtonFontSize": "14",
|
"TabButtonFontSize": "14",
|
||||||
"TabButtonWidth": "100",
|
"TabButtonWidth": "100",
|
||||||
@ -158,7 +158,7 @@
|
|||||||
"HeaderFontFamily": "Consolas, Monaco",
|
"HeaderFontFamily": "Consolas, Monaco",
|
||||||
|
|
||||||
"CheckBoxBulletDecoratorFontSize": "14",
|
"CheckBoxBulletDecoratorFontSize": "14",
|
||||||
"CheckBoxMargin": "15,0,0,2",
|
"CheckBoxMargin": "5,0,0,2",
|
||||||
|
|
||||||
"TabButtonFontSize": "14",
|
"TabButtonFontSize": "14",
|
||||||
"TabButtonWidth": "100",
|
"TabButtonWidth": "100",
|
||||||
|
@ -1,217 +0,0 @@
|
|||||||
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
|
|
||||||
Note: the 'tabname' parameter must equal one of the json files found in $sync.configs variable
|
|
||||||
Otherwise, it'll throw an exception
|
|
||||||
.PARAMETER columncount
|
|
||||||
The number of columns to display the applications in, default is 0
|
|
||||||
.OUTPUTS
|
|
||||||
The XAML for the tab
|
|
||||||
.EXAMPLE
|
|
||||||
Get-TabXaml "applications" 3
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
param(
|
|
||||||
[Parameter(Mandatory, position=0)]
|
|
||||||
[string]$tabname,
|
|
||||||
|
|
||||||
[Parameter(position=1)]
|
|
||||||
[ValidateRange(0,10)] # 10 panels as max number is more then enough
|
|
||||||
[int]$columncount = 0
|
|
||||||
)
|
|
||||||
|
|
||||||
# Validate tabname
|
|
||||||
if ($sync.configs.$tabname -eq $null) {
|
|
||||||
throw "Invalid parameter passed, can't find '$tabname' in '`$sync.configs' variable, please double check any calls to 'Get-TabXaml' function."
|
|
||||||
}
|
|
||||||
|
|
||||||
$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
|
|
||||||
ButtonWidth = $appInfo.ButtonWidth
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
# Same tab amount in last line of 'inputXML.xaml' file
|
|
||||||
# TODO: Get the base repeat (amount) of tabs from last line (or even lines)
|
|
||||||
# so it can dynamicly react to whatever is before this generated XML string.
|
|
||||||
# .. may be solve this even before calling this function, and pass the result as a parameter?
|
|
||||||
$tab_repeat = 7
|
|
||||||
$spaces_per_tab = 4 # The convenction used across the code base
|
|
||||||
$tab_as_spaces = $(" " * $spaces_per_tab)
|
|
||||||
$precal_indent = $($tab_as_spaces * $tab_repeat)
|
|
||||||
$precal_indent_p1 = $($tab_as_spaces * ($tab_repeat + 1))
|
|
||||||
$precal_indent_p2 = $($tab_as_spaces * ($tab_repeat + 2))
|
|
||||||
$precal_indent_m1 = $($tab_as_spaces * ($tab_repeat - 1))
|
|
||||||
$precal_indent_m2 = $($tab_as_spaces * ($tab_repeat - 2))
|
|
||||||
|
|
||||||
# Calculate the needed number of panels
|
|
||||||
$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 = "<Grid.ColumnDefinitions>"
|
|
||||||
$blockXml += $("`r`n" + " " * ($spaces_per_tab * $tab_repeat) +
|
|
||||||
"<ColumnDefinition Width=""*""/>") * $paneltotal
|
|
||||||
$blockXml += $("`r`n" + " " * ($spaces_per_tab * ($tab_repeat - 1))) +
|
|
||||||
"</Grid.ColumnDefinitions>" + "`r`n"
|
|
||||||
|
|
||||||
# Iterate through 'organizedData' by panel, category, and application
|
|
||||||
$count = 0
|
|
||||||
foreach ($panel in ($organizedData.Keys | Sort-Object)) {
|
|
||||||
$blockXml += $precal_indent_m1 + "<Border Grid.Row=""1"" Grid.Column=""$panelcount"">" + "`r`n"
|
|
||||||
$blockXml += $precal_indent + "<StackPanel Background=""{MainBackgroundColor}"" SnapsToDevicePixels=""True"">" + "`r`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 += $precal_indent_p2 + "</StackPanel>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent_p1 + "</Border>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent_p1 + "<Border Grid.Row=""1"" Grid.Column=""$panelcount"">" + "`r`n"
|
|
||||||
$blockXml += $precal_indent_p2 + "<StackPanel Background=""{MainBackgroundColor}"" SnapsToDevicePixels=""True"">" + "`r`n"
|
|
||||||
$panelcount++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Dot-source the Get-WPFObjectName function
|
|
||||||
. .\functions\private\Get-WPFObjectName
|
|
||||||
|
|
||||||
$categorycontent = $($category -replace '^.__', '')
|
|
||||||
$categoryname = Get-WPFObjectName -type "Label" -name $categorycontent
|
|
||||||
$blockXml += $("`r`n" + " " * ($spaces_per_tab * $tab_repeat)) +
|
|
||||||
"<Label Name=""$categoryname"" Content=""$categorycontent""" + " " +
|
|
||||||
"FontSize=""{FontSizeHeading}"" FontFamily=""{HeaderFontFamily}""/>" + "`r`n" + "`r`n"
|
|
||||||
$sortedApps = $organizedData[$panel][$category].Keys | Sort-Object
|
|
||||||
foreach ($appName in $sortedApps) {
|
|
||||||
$count++
|
|
||||||
|
|
||||||
if ($columncount -gt 0) {
|
|
||||||
$panelcount2 = [Int](($count)/$maxcount-0.5)
|
|
||||||
# Verify the indentation actually works...
|
|
||||||
if ($panelcount -eq $panelcount2 ) {
|
|
||||||
$blockXml += $precal_indent_m1 +
|
|
||||||
"</StackPanel>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent_m2 +
|
|
||||||
"</Border>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent_m2 +
|
|
||||||
"<Border Grid.Row=""1"" Grid.Column=""$panelcount"">" + "`r`n"
|
|
||||||
$blockXml += $precal_indent_m1 +
|
|
||||||
"<StackPanel Background=""{MainBackgroundColor}"" SnapsToDevicePixels=""True"">" + "`r`n"
|
|
||||||
$panelcount++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$appInfo = $organizedData[$panel][$category][$appName]
|
|
||||||
switch ($appInfo.Type) {
|
|
||||||
"Toggle" {
|
|
||||||
$blockXml += $precal_indent_m1 +
|
|
||||||
"<DockPanel LastChildFill=""True"">" + "`r`n"
|
|
||||||
$blockXml += $precal_indent +
|
|
||||||
"<CheckBox Name=""$($appInfo.Name)"" Style=""{StaticResource ColorfulToggleSwitchStyle}"" Margin=""4,0""" + " " +
|
|
||||||
"HorizontalAlignment=""Right"" FontSize=""{FontSize}""/>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent +
|
|
||||||
"<Label Content=""$($appInfo.Content)"" ToolTip=""$($appInfo.Description)""" + " " +
|
|
||||||
"HorizontalAlignment=""Left"" FontSize=""{FontSize}""/>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent_m1 +
|
|
||||||
"</DockPanel>" + "`r`n"
|
|
||||||
}
|
|
||||||
|
|
||||||
"Combobox" {
|
|
||||||
$blockXml += $precal_indent_m1 +
|
|
||||||
"<StackPanel Orientation=""Horizontal"" Margin=""0,5,0,0"">" + "`r`n"
|
|
||||||
$blockXml += $precal_indent + "<Label Content=""$($appInfo.Content)"" HorizontalAlignment=""Left""" + " " +
|
|
||||||
"VerticalAlignment=""Center"" FontSize=""{FontSize}""/>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent +
|
|
||||||
"<ComboBox Name=""$($appInfo.Name)"" Height=""32"" Width=""186"" HorizontalAlignment=""Left""" + " " +
|
|
||||||
"VerticalAlignment=""Center"" Margin=""5,5"" FontSize=""{FontSize}"">" + "`r`n"
|
|
||||||
|
|
||||||
$addfirst="IsSelected=""True"""
|
|
||||||
foreach ($comboitem in ($appInfo.ComboItems -split " ")) {
|
|
||||||
$blockXml += $precal_indent_p1 +
|
|
||||||
"<ComboBoxItem $addfirst Content=""$comboitem"" FontSize=""{FontSize}""/>" + "`r`n"
|
|
||||||
$addfirst=""
|
|
||||||
}
|
|
||||||
|
|
||||||
$blockXml += $precal_indent_p1 + "</ComboBox>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent + "</StackPanel>" + "`r`n"
|
|
||||||
}
|
|
||||||
|
|
||||||
"Button" {
|
|
||||||
if ($appInfo.ButtonWidth -ne $null) {
|
|
||||||
$ButtonWidthStr = "Width=""$($appInfo.ButtonWidth)"""
|
|
||||||
}
|
|
||||||
$blockXml += $precal_indent +
|
|
||||||
"<Button Name=""$($appInfo.Name)"" Content=""$($appInfo.Content)""" + " " +
|
|
||||||
"HorizontalAlignment=""Left"" Margin=""5"" Padding=""20,5"" $($ButtonWidthStr)/>" + "`r`n"
|
|
||||||
}
|
|
||||||
|
|
||||||
# else it is a checkbox
|
|
||||||
default {
|
|
||||||
$checkedStatus = If ($appInfo.Checked -eq $null) {""} Else {" IsChecked=""$($appInfo.Checked)"""}
|
|
||||||
if ($appInfo.Link -eq $null) {
|
|
||||||
$blockXml += $precal_indent +
|
|
||||||
"<CheckBox Name=""$($appInfo.Name)"" Content=""$($appInfo.Content)""$($checkedStatus) Margin=""5,0""" + " " +
|
|
||||||
"ToolTip=""$($appInfo.Description)""/>" + "`r`n"
|
|
||||||
} else {
|
|
||||||
$blockXml += $precal_indent +
|
|
||||||
"<StackPanel Orientation=""Horizontal"">" + "`r`n"
|
|
||||||
$blockXml += $precal_indent_p1 +
|
|
||||||
"<CheckBox Name=""$($appInfo.Name)"" Content=""$($appInfo.Content)""$($checkedStatus)" + " " +
|
|
||||||
"ToolTip=""$($appInfo.Description)"" Margin=""0,0,2,0""/>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent_p1 +
|
|
||||||
"<TextBlock Name=""$($appInfo.Name)Link"" Style=""{StaticResource HoverTextBlockStyle}"" Text=""(?)""" + " " +
|
|
||||||
"ToolTip=""$($appInfo.Link)""/>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent +
|
|
||||||
"</StackPanel>" + "`r`n"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$blockXml += $precal_indent_p1 + "</StackPanel>" + "`r`n"
|
|
||||||
$blockXml += $precal_indent + "</Border>" + "`r`n"
|
|
||||||
}
|
|
||||||
return ($blockXml)
|
|
||||||
}
|
|
275
functions/public/Invoke-WPFUIElements.ps1
Normal file
275
functions/public/Invoke-WPFUIElements.ps1
Normal file
@ -0,0 +1,275 @@
|
|||||||
|
function Invoke-WPFUIElements {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Adds UI elements to a specified Grid in the WinUtil GUI based on a JSON configuration.
|
||||||
|
.PARAMETER configVariable
|
||||||
|
The variable/link containing the JSON configuration.
|
||||||
|
.PARAMETER targetGridName
|
||||||
|
The name of the grid to which the UI elements should be added.
|
||||||
|
.PARAMETER columncount
|
||||||
|
The number of columns to be used in the Grid. If not provided, a default value is used based on the panel.
|
||||||
|
.EXAMPLE
|
||||||
|
$categoryPanelMap = @{
|
||||||
|
"Essential Tweaks" = 0
|
||||||
|
"Customize Preferences" = 1
|
||||||
|
}
|
||||||
|
Invoke-WPFUIElements -configVariable $sync.configs.applications -targetGridName "install" -columncount 5
|
||||||
|
#>
|
||||||
|
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[PSCustomObject]$configVariable,
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$targetGridName,
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[int]$columncount
|
||||||
|
)
|
||||||
|
|
||||||
|
$theme = $sync.configs.themes.$ctttheme
|
||||||
|
|
||||||
|
# Convert PSCustomObject to Hashtable
|
||||||
|
$configHashtable = @{}
|
||||||
|
$configVariable.PSObject.Properties.Name | ForEach-Object {
|
||||||
|
$configHashtable[$_] = $configVariable.$_
|
||||||
|
}
|
||||||
|
|
||||||
|
$organizedData = @{}
|
||||||
|
# Iterate through JSON data and organize by panel and category
|
||||||
|
foreach ($entry in $configHashtable.Keys) {
|
||||||
|
$entryInfo = $configHashtable[$entry]
|
||||||
|
|
||||||
|
# Create an object for the application
|
||||||
|
$entryObject = [PSCustomObject]@{
|
||||||
|
Name = $entry.Name
|
||||||
|
Category = $entryInfo.Category
|
||||||
|
Content = $entryInfo.Content
|
||||||
|
Choco = $entryInfo.choco
|
||||||
|
Winget = $entryInfo.winget
|
||||||
|
Panel = if ($entryInfo.Panel -ne $null) { $entryInfo.Panel } else { "0" }
|
||||||
|
Link = $entryInfo.link
|
||||||
|
Description = $entryInfo.description
|
||||||
|
Type = $entryInfo.type
|
||||||
|
ComboItems = $entryInfo.ComboItems
|
||||||
|
Checked = $entryInfo.Checked
|
||||||
|
ButtonWidth = $entryInfo.ButtonWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $organizedData.ContainsKey($entryObject.Panel)) {
|
||||||
|
$organizedData[$entryObject.Panel] = @{}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $organizedData[$entryObject.Panel].ContainsKey($entryObject.Category)) {
|
||||||
|
$organizedData[$entryObject.Panel][$entryObject.Category] = @{}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Store application data in a sub-array under the category
|
||||||
|
$organizedData[$entryObject.Panel][$entryInfo.Category]["$($entryInfo.order)$entry"] = $entryObject
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Retrieve the main window and the target Grid by name
|
||||||
|
$window = $sync["Form"]
|
||||||
|
$targetGrid = $window.FindName($targetGridName)
|
||||||
|
|
||||||
|
# Clear existing ColumnDefinitions and Children
|
||||||
|
$targetGrid.ColumnDefinitions.Clear() | Out-Null
|
||||||
|
$targetGrid.Children.Clear() | Out-Null
|
||||||
|
|
||||||
|
# Add ColumnDefinitions to the target Grid
|
||||||
|
for ($i = 0; $i -lt $columncount; $i++) {
|
||||||
|
$colDef = New-Object Windows.Controls.ColumnDefinition
|
||||||
|
$colDef.Width = New-Object Windows.GridLength(1, [Windows.GridUnitType]::Star)
|
||||||
|
$targetGrid.ColumnDefinitions.Add($colDef) | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only apply the logic for distributing entries across columns if the targetGridName is "appspanel"
|
||||||
|
if ($targetGridName -eq "appspanel") {
|
||||||
|
$panelcount = 0
|
||||||
|
$paneltotal = $columncount # Use columncount for even distribution
|
||||||
|
$entrycount = $configHashtable.Keys.Count + $organizedData["0"].Keys.Count
|
||||||
|
$maxcount = [Math]::Round($entrycount / $columncount + 0.5)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Iterate through 'organizedData' by panel, category, and application
|
||||||
|
$count = 0
|
||||||
|
foreach ($panelKey in ($organizedData.Keys | Sort-Object)) {
|
||||||
|
# Create a Border for each column
|
||||||
|
$border = New-Object Windows.Controls.Border
|
||||||
|
$border.BorderBrush = [Windows.Media.Brushes]::Gray
|
||||||
|
$border.BorderThickness = [Windows.Thickness]::new(1)
|
||||||
|
$border.Margin = [Windows.Thickness]::new(5)
|
||||||
|
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
|
||||||
|
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
|
||||||
|
$targetGrid.Children.Add($border) | Out-Null
|
||||||
|
|
||||||
|
# Create a StackPanel inside the Border
|
||||||
|
$stackPanel = New-Object Windows.Controls.StackPanel
|
||||||
|
$stackPanel.Background = [Windows.Media.Brushes]::Transparent
|
||||||
|
$stackPanel.SnapsToDevicePixels = $true
|
||||||
|
$stackPanel.VerticalAlignment = "Stretch" # Ensure the stack panel stretches vertically
|
||||||
|
$border.Child = $stackPanel
|
||||||
|
$panelcount++
|
||||||
|
|
||||||
|
foreach ($category in ($organizedData[$panelKey].Keys | Sort-Object)) {
|
||||||
|
$count++
|
||||||
|
if ($targetGridName -eq "appspanel" -and $columncount -gt 0) {
|
||||||
|
$panelcount2 = [Int](($count) / $maxcount - 0.5)
|
||||||
|
if ($panelcount -eq $panelcount2) {
|
||||||
|
# Create a new Border for the new column
|
||||||
|
$border = New-Object Windows.Controls.Border
|
||||||
|
$border.BorderBrush = [Windows.Media.Brushes]::Gray
|
||||||
|
$border.BorderThickness = [Windows.Thickness]::new(1)
|
||||||
|
$border.Margin = [Windows.Thickness]::new(5)
|
||||||
|
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
|
||||||
|
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
|
||||||
|
$targetGrid.Children.Add($border) | Out-Null
|
||||||
|
|
||||||
|
# Create a new StackPanel inside the Border
|
||||||
|
$stackPanel = New-Object Windows.Controls.StackPanel
|
||||||
|
$stackPanel.Background = [Windows.Media.Brushes]::Transparent
|
||||||
|
$stackPanel.SnapsToDevicePixels = $true
|
||||||
|
$stackPanel.VerticalAlignment = "Stretch" # Ensure the stack panel stretches vertically
|
||||||
|
$border.Child = $stackPanel
|
||||||
|
$panelcount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$label = New-Object Windows.Controls.Label
|
||||||
|
$label.Content = $category -replace ".*__"
|
||||||
|
$label.FontSize = $theme.FontSizeHeading
|
||||||
|
$label.FontFamily = $theme.HeaderFontFamily
|
||||||
|
$stackPanel.Children.Add($label) | Out-Null
|
||||||
|
|
||||||
|
$entries = $organizedData[$panelKey][$category].Keys | Sort-Object
|
||||||
|
foreach ($entry in $entries) {
|
||||||
|
$count++
|
||||||
|
if ($targetGridName -eq "appspanel" -and $columncount -gt 0) {
|
||||||
|
$panelcount2 = [Int](($count) / $maxcount - 0.5)
|
||||||
|
if ($panelcount -eq $panelcount2) {
|
||||||
|
# Create a new Border for the new column
|
||||||
|
$border = New-Object Windows.Controls.Border
|
||||||
|
$border.BorderBrush = [Windows.Media.Brushes]::Gray
|
||||||
|
$border.BorderThickness = [Windows.Thickness]::new(1)
|
||||||
|
$border.Margin = [Windows.Thickness]::new(5)
|
||||||
|
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
|
||||||
|
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
|
||||||
|
$targetGrid.Children.Add($border) | Out-Null
|
||||||
|
|
||||||
|
# Create a new StackPanel inside the Border
|
||||||
|
$stackPanel = New-Object Windows.Controls.StackPanel
|
||||||
|
$stackPanel.Background = [Windows.Media.Brushes]::Transparent
|
||||||
|
$stackPanel.SnapsToDevicePixels = $true
|
||||||
|
$stackPanel.VerticalAlignment = "Stretch" # Ensure the stack panel stretches vertically
|
||||||
|
$border.Child = $stackPanel
|
||||||
|
$panelcount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$entryInfo = $organizedData[$panelKey][$category][$entry]
|
||||||
|
switch ($entryInfo.Type) {
|
||||||
|
"Toggle" {
|
||||||
|
$dockPanel = New-Object Windows.Controls.DockPanel
|
||||||
|
$checkBox = New-Object Windows.Controls.CheckBox
|
||||||
|
$checkBox.Name = $entryInfo.Name
|
||||||
|
write-host $entryInfo.Name
|
||||||
|
$checkBox.HorizontalAlignment = "Right"
|
||||||
|
$dockPanel.Children.Add($checkBox) | Out-Null
|
||||||
|
$checkBox.Style = $window.FindResource("ColorfulToggleSwitchStyle")
|
||||||
|
|
||||||
|
$label = New-Object Windows.Controls.Label
|
||||||
|
$label.Content = $entryInfo.Content
|
||||||
|
$label.ToolTip = $entryInfo.Description
|
||||||
|
$label.HorizontalAlignment = "Left"
|
||||||
|
$label.FontSize = $theme.FontSize
|
||||||
|
# Implement for consistent theming later on $label.Style = $window.FindResource("labelfortweaks")
|
||||||
|
$dockPanel.Children.Add($label) | Out-Null
|
||||||
|
|
||||||
|
$stackPanel.Children.Add($dockPanel) | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
"Combobox" {
|
||||||
|
$horizontalStackPanel = New-Object Windows.Controls.StackPanel
|
||||||
|
$horizontalStackPanel.Orientation = "Horizontal"
|
||||||
|
$horizontalStackPanel.Margin = "0,5,0,0"
|
||||||
|
|
||||||
|
$label = New-Object Windows.Controls.Label
|
||||||
|
$label.Content = $entryInfo.Content
|
||||||
|
$label.HorizontalAlignment = "Left"
|
||||||
|
$label.VerticalAlignment = "Center"
|
||||||
|
$label.FontSize = $theme.ButtonFontSize
|
||||||
|
$horizontalStackPanel.Children.Add($label) | Out-Null
|
||||||
|
|
||||||
|
$comboBox = New-Object Windows.Controls.ComboBox
|
||||||
|
$comboBox.Name = $entryInfo.Name
|
||||||
|
$comboBox.Height = $theme.ButtonHeight
|
||||||
|
$comboBox.Width = $theme.ButtonWidth
|
||||||
|
$comboBox.HorizontalAlignment = "Left"
|
||||||
|
$comboBox.VerticalAlignment = "Center"
|
||||||
|
$comboBox.Margin = "5,5"
|
||||||
|
|
||||||
|
foreach ($comboitem in ($entryInfo.ComboItems -split " ")) {
|
||||||
|
$comboBoxItem = New-Object Windows.Controls.ComboBoxItem
|
||||||
|
$comboBoxItem.Content = $comboitem
|
||||||
|
$comboBoxItem.FontSize = $theme.ButtonFontSize
|
||||||
|
$comboBox.Items.Add($comboBoxItem) | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
$horizontalStackPanel.Children.Add($comboBox) | Out-Null
|
||||||
|
$stackPanel.Children.Add($horizontalStackPanel) | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
"Button" {
|
||||||
|
$button = New-Object Windows.Controls.Button
|
||||||
|
$button.Name = $entryInfo.Name
|
||||||
|
$button.Content = $entryInfo.Content
|
||||||
|
$button.HorizontalAlignment = "Left"
|
||||||
|
$button.Margin = "5"
|
||||||
|
$button.Padding = "20,5"
|
||||||
|
$button.FontSize = $theme.ButtonFontSize
|
||||||
|
if ($entryInfo.ButtonWidth -ne $null) {
|
||||||
|
$button.Width = $entryInfo.ButtonWidth
|
||||||
|
}
|
||||||
|
$stackPanel.Children.Add($button) | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$checkBox = New-Object Windows.Controls.CheckBox
|
||||||
|
$checkBox.Name = $entryInfo.Name
|
||||||
|
$checkBox.Content = $entryInfo.Content
|
||||||
|
$checkBox.FontSize = $theme.FontSize
|
||||||
|
$checkBox.ToolTip = $entryInfo.Description
|
||||||
|
$checkBox.Margin = $theme.CheckBoxMargin
|
||||||
|
if ($entryInfo.Checked -ne $null) {
|
||||||
|
$checkBox.IsChecked = $entryInfo.Checked
|
||||||
|
}
|
||||||
|
if ($entryInfo.Link -ne $null) {
|
||||||
|
$horizontalStackPanel = New-Object Windows.Controls.StackPanel
|
||||||
|
$horizontalStackPanel.Orientation = "Horizontal"
|
||||||
|
$horizontalStackPanel.Children.Add($checkBox) | Out-Null
|
||||||
|
|
||||||
|
$textBlock = New-Object Windows.Controls.TextBlock
|
||||||
|
$textBlock.Text = "(?)"
|
||||||
|
$textBlock.ToolTip = $entryInfo.Link
|
||||||
|
$textBlock.Style = $window.FindResource("HoverTextBlockStyle")
|
||||||
|
|
||||||
|
# Add event handler for click to open link
|
||||||
|
$handler = [System.Windows.Input.MouseButtonEventHandler]{
|
||||||
|
param($sender, $e)
|
||||||
|
Start-Process $sender.ToolTip.ToString()
|
||||||
|
}
|
||||||
|
$textBlock.AddHandler([Windows.Controls.TextBlock]::MouseLeftButtonUpEvent, $handler)
|
||||||
|
|
||||||
|
$horizontalStackPanel.Children.Add($textBlock) | Out-Null
|
||||||
|
|
||||||
|
$stackPanel.Children.Add($horizontalStackPanel) | Out-Null
|
||||||
|
} else {
|
||||||
|
$stackPanel.Children.Add($checkBox) | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -83,6 +83,13 @@ try {
|
|||||||
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
|
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Load the configuration files
|
||||||
|
Invoke-WPFUIElements -configVariable $sync.configs.applications -targetGridName "appspanel" -columncount 5
|
||||||
|
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
|
||||||
|
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2
|
||||||
|
|
||||||
|
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Store Form Objects In PowerShell
|
# Store Form Objects In PowerShell
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
|
@ -764,8 +764,7 @@
|
|||||||
|
|
||||||
<ScrollViewer x:Name="scrollViewer" Grid.Row="1" Grid.Column="0" Padding="-1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
|
<ScrollViewer x:Name="scrollViewer" Grid.Row="1" Grid.Column="0" Padding="-1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
|
||||||
BorderBrush="Transparent" BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
BorderBrush="Transparent" BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
<Grid Name="appspanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||||
{{InstallPanel_applications}}
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
@ -781,7 +780,6 @@
|
|||||||
<RowDefinition Height=".70*"/>
|
<RowDefinition Height=".70*"/>
|
||||||
<RowDefinition Height=".10*"/>
|
<RowDefinition Height=".10*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
{{InstallPanel_tweaks}}
|
|
||||||
<StackPanel Background="{MainBackgroundColor}" Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="5">
|
<StackPanel Background="{MainBackgroundColor}" Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="5">
|
||||||
<Label Content="Recommended Selections:" FontSize="{FontSize}" VerticalAlignment="Center" Margin="2"/>
|
<Label Content="Recommended Selections:" FontSize="{FontSize}" VerticalAlignment="Center" Margin="2"/>
|
||||||
<Button Name="WPFstandard" Content=" Standard " Margin="2"/>
|
<Button Name="WPFstandard" Content=" Standard " Margin="2"/>
|
||||||
@ -789,6 +787,8 @@
|
|||||||
<Button Name="WPFclear" Content=" Clear " Margin="2"/>
|
<Button Name="WPFclear" Content=" Clear " Margin="2"/>
|
||||||
<Button Name="WPFGetInstalledTweaks" Content=" Get Installed " Margin="2"/>
|
<Button Name="WPFGetInstalledTweaks" Content=" Get Installed " Margin="2"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<Grid Name="tweakspanel" Grid.Row="1">
|
||||||
|
</Grid>
|
||||||
<Border Grid.ColumnSpan="2" Grid.Row="2" Grid.Column="0">
|
<Border Grid.ColumnSpan="2" Grid.Row="2" Grid.Column="0">
|
||||||
<StackPanel Background="{MainBackgroundColor}" Orientation="Horizontal" HorizontalAlignment="Left">
|
<StackPanel Background="{MainBackgroundColor}" Orientation="Horizontal" HorizontalAlignment="Left">
|
||||||
<TextBlock Padding="10">
|
<TextBlock Padding="10">
|
||||||
@ -797,14 +797,12 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Config" Visibility="Collapsed" Name="WPFTab3">
|
<TabItem Header="Config" Visibility="Collapsed" Name="WPFTab3">
|
||||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
<Grid Background="Transparent">
|
<Grid Name="featurespanel" Grid.Row="1" Background="Transparent">
|
||||||
{{InstallPanel_features}}
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
Reference in New Issue
Block a user