diff --git a/Compile.ps1 b/Compile.ps1 index f86fbce62e..6f7a031381 100644 --- a/Compile.ps1 +++ b/Compile.ps1 @@ -64,38 +64,14 @@ Get-ChildItem "$workingdir\functions" -Recurse -File | ForEach-Object { } Update-Progress "Adding: Config *.json" 40 Get-ChildItem "$workingdir\config" | Where-Object {$psitem.extension -eq ".json"} | ForEach-Object { - $json = (Get-Content $psitem.FullName).replace("'","''") - - # Replace every XML Special Character so it'll render correctly in final build - # Only do so if json files has content to be displayed (for example the applications, tweaks, features json files) - # Make an Array List containing every name at first level of Json File - $jsonAsObject = $json | convertfrom-json - $firstLevelJsonList = [System.Collections.ArrayList]::new() - $jsonAsObject.PSObject.Properties.Name | ForEach-Object {$null = $firstLevelJsonList.Add($_)} - # Note: - # Avoid using HTML Entity Codes, for example '”' (stands for "Right Double Quotation Mark"), - # Use **HTML decimal/hex codes instead**, as using HTML Entity Codes will result in XML parse Error when running the compiled script. - for ($i = 0; $i -lt $firstLevelJsonList.Count; $i += 1) { - $firstLevelName = $firstLevelJsonList[$i] - if ($jsonAsObject.$firstLevelName.content -ne $null) { - $jsonAsObject.$firstLevelName.content = $jsonAsObject.$firstLevelName.content.replace('&','&').replace('“','“').replace('”','”').replace("'",''').replace('<','<').replace('>','>').replace('—','—') - $jsonAsObject.$firstLevelName.content = $jsonAsObject.$firstLevelName.content.replace('''',"'") # resolves the Double Apostrophe caused by the first replace function in the main loop - } - if ($jsonAsObject.$firstLevelName.description -ne $null) { - $jsonAsObject.$firstLevelName.description = $jsonAsObject.$firstLevelName.description.replace('&','&').replace('“','“').replace('”','”').replace("'",''').replace('<','<').replace('>','>').replace('—','—') - $jsonAsObject.$firstLevelName.description = $jsonAsObject.$firstLevelName.description.replace('''',"'") # resolves the Double Apostrophe caused by the first replace function in the main loop - } - } + $jsonAsObject = $json | convertfrom-json # Add 'WPFInstall' as a prefix to every entry-name in 'applications.json' file if ($psitem.Name -eq "applications.json") { - for ($i = 0; $i -lt $firstLevelJsonList.Count; $i += 1) { - $appEntryName = $firstLevelJsonList[$i] + foreach ($appEntryName in $jsonAsObject.PSObject.Properties.Name) { $appEntryContent = $jsonAsObject.$appEntryName - # Remove the entire app entry, so we could add it later with a different name $jsonAsObject.PSObject.Properties.Remove($appEntryName) - # Add the app entry, but with a different name (WPFInstall + The App Entry Name) $jsonAsObject | Add-Member -MemberType NoteProperty -Name "WPFInstall$appEntryName" -Value $appEntryContent } } @@ -110,20 +86,7 @@ Get-ChildItem "$workingdir\config" | Where-Object {$psitem.extension -eq ".json" $xaml = (Get-Content "$workingdir\xaml\inputXML.xaml").replace("'","''") -# Dot-source the Get-TabXaml function -. "$workingdir\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 -# 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'")) diff --git a/config/themes.json b/config/themes.json index 5947ced7c2..261227ce12 100644 --- a/config/themes.json +++ b/config/themes.json @@ -11,6 +11,7 @@ "FontSizeHeading": "16", "HeaderFontFamily": "Consolas, Monaco", +<<<<<<< HEAD "CheckBoxBulletDecoratorSize": "14", "CheckBoxMargin": "15,0,0,2", @@ -23,6 +24,20 @@ "WinUtilIconSize": "Auto", "SettingsIconFontSize": "18", "CloseIconFontSize": "18", +======= + "CheckBoxBulletDecoratorFontSize": "14", + "CheckBoxMargin": "5,0,0,1", + + "TabContentMargin": "5", + "TabButtonFontSize": "14", + "TabButtonWidth": "100", + "TabButtonHeight": "25", + "TabRowHeightInPixels": "50", + "IconFontSize": "14", + "IconButtonSize": "35", + "WinUtilIconSize": "Auto", + "SettingsIconFontSize": "18", +>>>>>>> c5c7b6c11ee3046ce5db45135a8a2310a2cd9330 "MicroWinLogoSize": "10", @@ -46,10 +61,17 @@ "ButtonHeight": "25", "ConfigTabButtonFontSize": "16", +<<<<<<< HEAD "SearchBarWidth": "200", "SearchBarHeight": "25", "SearchBarTextBoxFontSize": "16", "SearchBarClearButtonFontSize": "14", +======= + "SearchBarWidth": "200", + "SearchBarHeight": "25", + "SearchBarTextBoxFontSize": "12", + "SearchBarClearButtonFontSize": "14", +>>>>>>> c5c7b6c11ee3046ce5db45135a8a2310a2cd9330 "ButtonInstallBackgroundColor": "#FFFFFF", "ButtonTweaksBackgroundColor": "#FFFFFF", @@ -111,6 +133,7 @@ "LinkHoverForegroundColor": "#FFFFFF", "ComboBoxForegroundColor": "#FFEE58", +<<<<<<< HEAD "ProgressBarForegroundColor": "#222222", "ProgressBarBackgroundColor": "Transparent", "ProgressBarTextColor": "#cccccc", @@ -129,6 +152,20 @@ "ButtonBackgroundSelectedColor": "#FF5733", "ButtonForegroundColor": "#9CCC65", "ToggleButtonOnColor": "#2e77ff", +======= + "CheckBoxBulletDecoratorFontSize": "14", + "CheckBoxMargin": "5,0,0,1", + + "TabContentMargin": "5", + "TabButtonFontSize": "14", + "TabButtonWidth": "100", + "TabButtonHeight": "25", + "TabRowHeightInPixels": "50", + "IconFontSize": "14", + "IconButtonSize": "35", + "WinUtilIconSize": "Auto", + "SettingsIconFontSize": "18", +>>>>>>> c5c7b6c11ee3046ce5db45135a8a2310a2cd9330 "BorderColor": "#FFAC1C", "BorderOpacity": "0.8", @@ -163,6 +200,115 @@ "ButtonForegroundColor": "#9CCC65", "ToggleButtonOnColor": "#2e77ff", +<<<<<<< HEAD "BorderColor": "#FFAC1C" } +======= + "ButtonFontSize": "12", + "ButtonFontFamily": "Arial", + "ButtonWidth": "200", + "ButtonHeight": "25", + "ConfigTabButtonFontSize": "16", + + "SearchBarWidth": "200", + "SearchBarHeight": "25", + "SearchBarTextBoxFontSize": "12", + "SearchBarClearButtonFontSize": "14", + + "ButtonInstallBackgroundColor": "#222222", + "ButtonTweaksBackgroundColor": "#333333", + "ButtonConfigBackgroundColor": "#444444", + "ButtonUpdatesBackgroundColor": "#555555", + "ButtonInstallForegroundColor": "#FFFFFF", + "ButtonTweaksForegroundColor": "#FFFFFF", + "ButtonConfigForegroundColor": "#FFFFFF", + "ButtonUpdatesForegroundColor": "#FFFFFF", + "ButtonBackgroundColor": "#000019", + "ButtonBackgroundPressedColor": "#FFFFFF", + "ButtonBackgroundMouseoverColor": "#A55A64", + "ButtonBackgroundSelectedColor": "#FF5733", + "ButtonForegroundColor": "#9CCC65", + "ToggleButtonOnColor": "#2e77ff", + + "ButtonBorderThickness": "1", + "ButtonMargin": "1", + "ButtonCornerRadius": "2", + "BorderColor": "#FFAC1C", + "BorderOpacity": "0.8", + "ShadowPulse": "0:0:3" + }, + "Dark": { + "CustomDialogFontSize": "12", + "CustomDialogFontSizeHeader": "14", + "CustomDialogIconSize": "25", + "CustomDialogWidth": "400", + "CustomDialogHeight": "200", + + "FontSize": "12", + "FontFamily": "Arial", + "FontSizeHeading": "14", + "HeaderFontFamily": "Consolas, Monaco", + + "CheckBoxBulletDecoratorFontSize": "14", + "CheckBoxMargin": "5,0,0,1", + + "TabContentMargin": "5", + "TabButtonFontSize": "14", + "TabButtonWidth": "100", + "TabButtonHeight": "25", + "TabRowHeightInPixels": "50", + "IconFontSize": "14", + "IconButtonSize": "35", + "WinUtilIconSize": "Auto", + "SettingsIconFontSize": "18", + + "MicroWinLogoSize": "10", + + "ProgressBarForegroundColor": "#222222", + "ProgressBarBackgroundColor": "Transparent", + "ProgressBarTextColor": "#FFFFFF", + + "ComboBoxBackgroundColor": "#000000", + "LabelboxForegroundColor": "#FFEE58", + "MainForegroundColor": "#9CCC65", + "MainBackgroundColor": "#000000", + "LabelBackgroundColor": "#000000", + "LinkForegroundColor": "#add8e6", + "LinkHoverForegroundColor": "#FFFFFF", + "ComboBoxForegroundColor": "#FFEE58", + + "ButtonFontSize": "12", + "ButtonFontFamily": "Arial", + "ButtonWidth": "200", + "ButtonHeight": "25", + "ConfigTabButtonFontSize": "16", + + "SearchBarWidth": "200", + "SearchBarHeight": "25", + "SearchBarTextBoxFontSize": "12", + "SearchBarClearButtonFontSize": "14", + + "ButtonInstallBackgroundColor": "#222222", + "ButtonTweaksBackgroundColor": "#333333", + "ButtonConfigBackgroundColor": "#444444", + "ButtonUpdatesBackgroundColor": "#555555", + "ButtonInstallForegroundColor": "#FFFFFF", + "ButtonTweaksForegroundColor": "#FFFFFF", + "ButtonConfigForegroundColor": "#FFFFFF", + "ButtonUpdatesForegroundColor": "#FFFFFF", + "ButtonBackgroundColor": "#000019", + "ButtonBackgroundPressedColor": "#9CCC65", + "ButtonBackgroundMouseoverColor": "#FF5733", + "ButtonBackgroundSelectedColor": "#FF5733", + "ButtonForegroundColor": "#9CCC65", + "ToggleButtonOnColor": "#2e77ff", + + "ButtonBorderThickness": "1", + "ButtonMargin": "1", + "ButtonCornerRadius": "2", + "BorderColor": "#FFAC1C", + "BorderOpacity": "0.2", + "ShadowPulse": "Forever" + } +>>>>>>> c5c7b6c11ee3046ce5db45135a8a2310a2cd9330 } diff --git a/functions/public/Invoke-WPFUIElements.ps1 b/functions/public/Invoke-WPFUIElements.ps1 new file mode 100644 index 0000000000..2319d6fe5a --- /dev/null +++ b/functions/public/Invoke-WPFUIElements.ps1 @@ -0,0 +1,325 @@ +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 + Invoke-WPFUIElements -configVariable $sync.configs.applications -targetGridName "install" -columncount 5 + .NOTES + Future me/contributer: If possible please wrap this into a runspace to make it load all panels at the same time. + #> + + param( + [Parameter(Mandatory, position=0)] + [PSCustomObject]$configVariable, + + [Parameter(Mandatory, position=1)] + [string]$targetGridName, + + [Parameter(Mandatory, position=2)] + [int]$columncount + ) + + $window = $sync["Form"] + + $theme = $sync.configs.themes.$ctttheme + $borderstyle = $window.FindResource("BorderStyle") + $HoverTextBlockStyle = $window.FindResource("HoverTextBlockStyle") + $ColorfulToggleSwitchStyle = $window.FindResource("ColorfulToggleSwitchStyle") + + if (!$borderstyle -or !$HoverTextBlockStyle -or !$ColorfulToggleSwitchStyle) { + throw "Failed to retrieve Styles using 'FindResource' from main window element." + } + + $targetGrid = $window.FindName($targetGridName) + + if (!$targetGrid) { + throw "Failed to retrieve Target Grid by name, provided name: $targetGrid" + } + + # 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 + } + + # 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 + Order = $entryInfo.order + Category = $entryInfo.Category + Content = $entryInfo.Content + Choco = $entryInfo.choco + Winget = $entryInfo.winget + Panel = if ($entryInfo.Panel) { $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 an array under the category + $organizedData[$entryObject.Panel][$entryObject.Category] += $entryObject + + # Only apply the logic for distributing entries across columns if the targetGridName is "appspanel" + if ($targetGridName -eq "appspanel") { + $panelcount = 0 + $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.VerticalAlignment = "Stretch" # Ensure the border stretches vertically + [System.Windows.Controls.Grid]::SetColumn($border, $panelcount) + $border.style = $borderstyle + $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.VerticalAlignment = "Stretch" # Ensure the border stretches vertically + [System.Windows.Controls.Grid]::SetColumn($border, $panelcount) + $border.style = $borderstyle + $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 + + $sync[$category] = $label + + # Sort entries by Order and then by Name, but only display Name + $entries = $organizedData[$panelKey][$category] | Sort-Object Order, Name + foreach ($entryInfo 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.VerticalAlignment = "Stretch" # Ensure the border stretches vertically + [System.Windows.Controls.Grid]::SetColumn($border, $panelcount) + $border.style = $borderstyle + $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++ + } + } + + switch ($entryInfo.Type) { + "Toggle" { + $dockPanel = New-Object Windows.Controls.DockPanel + $checkBox = New-Object Windows.Controls.CheckBox + $checkBox.Name = $entryInfo.Name + $checkBox.HorizontalAlignment = "Right" + $dockPanel.Children.Add($checkBox) | Out-Null + $checkBox.Style = $ColorfulToggleSwitchStyle + + $label = New-Object Windows.Controls.Label + $label.Content = $entryInfo.Content + $label.ToolTip = $entryInfo.Description + $label.HorizontalAlignment = "Left" + $label.FontSize = $theme.FontSize + $dockPanel.Children.Add($label) | Out-Null + $stackPanel.Children.Add($dockPanel) | Out-Null + + $sync[$entryInfo.Name] = $checkBox + + $sync[$entryInfo.Name].IsChecked = Get-WinUtilToggleStatus $sync[$entryInfo.Name].Name + + $sync[$entryInfo.Name].Add_Click({ + [System.Object]$Sender = $args[0] + Invoke-WPFToggle $Sender.name + }) + } + + "ToggleButton" { + $toggleButton = New-Object Windows.Controls.ToggleButton + $toggleButton.Name = $entryInfo.Name + $toggleButton.Name = "WPFTab" + ($stackPanel.Children.Count + 1) + "BT" + $toggleButton.HorizontalAlignment = "Left" + $toggleButton.Height = $theme.TabButtonHeight + $toggleButton.Width = $theme.TabButtonWidth + $toggleButton.Background = $theme.ButtonInstallBackgroundColor + $toggleButton.Foreground = [Windows.Media.Brushes]::White + $toggleButton.FontWeight = [Windows.FontWeights]::Bold + + $textBlock = New-Object Windows.Controls.TextBlock + $textBlock.FontSize = $theme.TabButtonFontSize + $textBlock.Background = [Windows.Media.Brushes]::Transparent + $textBlock.Foreground = $theme.ButtonInstallForegroundColor + + $underline = New-Object Windows.Documents.Underline + $underline.Inlines.Add($entryInfo.name -replace "(.).*", "`$1") + + $run = New-Object Windows.Documents.Run + $run.Text = $entryInfo.name -replace "^.", "" + + $textBlock.Inlines.Add($underline) + $textBlock.Inlines.Add($run) + + $toggleButton.Content = $textBlock + + $stackPanel.Children.Add($toggleButton) | Out-Null + + $sync[$entryInfo.Name] = $toggleButton + } + + "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 = $theme.ButtonMargin + + 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 + + $comboBox.SelectedIndex = 0 + + $sync[$entryInfo.Name] = $comboBox + } + + "Button" { + $button = New-Object Windows.Controls.Button + $button.Name = $entryInfo.Name + $button.Content = $entryInfo.Content + $button.HorizontalAlignment = "Left" + $button.Margin = $theme.ButtonMargin + $button.FontSize = $theme.ButtonFontSize + if ($entryInfo.ButtonWidth) { + $button.Width = $entryInfo.ButtonWidth + } + $stackPanel.Children.Add($button) | Out-Null + + $sync[$entryInfo.Name] = $button + } + + default { + $horizontalStackPanel = New-Object Windows.Controls.StackPanel + $horizontalStackPanel.Orientation = "Horizontal" + + $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) { + $checkBox.IsChecked = $entryInfo.Checked + } + $horizontalStackPanel.Children.Add($checkBox) | Out-Null + + if ($entryInfo.Link) { + $textBlock = New-Object Windows.Controls.TextBlock + $textBlock.Name = $checkBox.Name + "Link" + $textBlock.Text = "(?)" + $textBlock.ToolTip = $entryInfo.Link + $textBlock.Style = $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 + + $sync[$textBlock.Name] = $textBlock + } + + $stackPanel.Children.Add($horizontalStackPanel) | Out-Null + $sync[$entryInfo.Name] = $checkBox + } + } + } + } + } +} diff --git a/scripts/main.ps1 b/scripts/main.ps1 index b1e436aa6e..3ac47ef3b4 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -92,6 +92,7 @@ try { Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed." } +<<<<<<< HEAD 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 @@ -100,6 +101,15 @@ if (-NOT ($readerOperationSuccessful)) { [System.GC]::Collect() exit 1 } +======= + +# Load the configuration files +#Invoke-WPFUIElements -configVariable $sync.configs.nav -targetGridName "WPFMainGrid" +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 + +>>>>>>> c5c7b6c11ee3046ce5db45135a8a2310a2cd9330 #=========================================================================== # Store Form Objects In PowerShell @@ -109,16 +119,6 @@ $xaml.SelectNodes("//*[@Name]") | ForEach-Object {$sync["$("$($psitem.Name)")"] $sync.keys | ForEach-Object { if($sync.$psitem) { - if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "CheckBox" ` - -and $sync["$psitem"].Name -like "WPFToggle*") { - $sync["$psitem"].IsChecked = Get-WinUtilToggleStatus $sync["$psitem"].Name - - $sync["$psitem"].Add_Click({ - [System.Object]$Sender = $args[0] - Invoke-WPFToggle $Sender.name - }) - } - if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "ToggleButton") { $sync["$psitem"].Add_Click({ [System.Object]$Sender = $args[0] @@ -387,7 +387,6 @@ $labels = @{} $allCategories = $checkBoxes.Name | ForEach-Object {$sync.configs.applications.$_} | Select-Object -Unique -ExpandProperty category $sync["SearchBar"].Add_TextChanged({ - if ($sync.SearchBar.Text -ne "") { $sync.SearchBarClearButton.Visibility = "Visible" } else { @@ -396,13 +395,14 @@ $sync["SearchBar"].Add_TextChanged({ $activeApplications = @() + $textToSearch = $sync.SearchBar.Text.ToLower() + foreach ($CheckBox in $CheckBoxes) { # Check if the checkbox is null or if it doesn't have content if ($CheckBox -eq $null -or $CheckBox.Value -eq $null -or $CheckBox.Value.Content -eq $null) { continue } - $textToSearch = $sync.SearchBar.Text.ToLower() $checkBoxName = $CheckBox.Key $textBlockName = $checkBoxName + "Link" @@ -412,23 +412,23 @@ $sync["SearchBar"].Add_TextChanged({ if ($CheckBox.Value.Content.ToLower().Contains($textToSearch)) { $CheckBox.Value.Visibility = "Visible" $activeApplications += $sync.configs.applications.$checkboxName - # Set the corresponding text block visibility - if ($textBlock -ne $null) { + # Set the corresponding text block visibility + if ($textBlock -ne $null -and $textBlock -is [System.Windows.Controls.TextBlock]) { $textBlock.Visibility = "Visible" } } else { - $CheckBox.Value.Visibility = "Collapsed" + $CheckBox.Value.Visibility = "Collapsed" # Set the corresponding text block visibility - if ($textBlock -ne $null) { + if ($textBlock -ne $null -and $textBlock -is [System.Windows.Controls.TextBlock]) { $textBlock.Visibility = "Collapsed" } } } + $activeCategories = $activeApplications | Select-Object -ExpandProperty category -Unique foreach ($category in $activeCategories) { - $label = $labels[$(Get-WPFObjectName -type "Label" -name $category)] - $label.Visibility = "Visible" + $sync[$category].Visibility = "Visible" } if ($activeCategories) { $inactiveCategories = Compare-Object -ReferenceObject $allCategories -DifferenceObject $activeCategories -PassThru @@ -436,8 +436,8 @@ $sync["SearchBar"].Add_TextChanged({ $inactiveCategories = $allCategories } foreach ($category in $inactiveCategories) { - $label = $labels[$(Get-WPFObjectName -type "Label" -name $category)] - $label.Visibility = "Collapsed"} + $sync[$category].Visibility = "Collapsed" + } }) # Initialize the hashtable diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml index acedd9cb7b..db4be1a9bf 100644 --- a/xaml/inputXML.xaml +++ b/xaml/inputXML.xaml @@ -284,12 +284,12 @@ - + @@ -502,7 +502,7 @@ -