add compatibility for every app

This commit is contained in:
MyDrift 2024-09-28 00:43:56 +02:00
parent db521534bc
commit 71c35eccd6
2 changed files with 289 additions and 305 deletions

View File

@ -171,7 +171,6 @@
"category": "Browsers", "category": "Browsers",
"choco": "brave", "choco": "brave",
"content": "Brave", "content": "Brave",
"Type": "application",
"description": "Brave is a privacy-focused web browser that blocks ads and trackers, offering a faster and safer browsing experience.", "description": "Brave is a privacy-focused web browser that blocks ads and trackers, offering a faster and safer browsing experience.",
"link": "https://www.brave.com", "link": "https://www.brave.com",
"winget": "Brave.Brave" "winget": "Brave.Brave"
@ -234,7 +233,6 @@
}, },
"chrome": { "chrome": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "googlechrome", "choco": "googlechrome",
"content": "Chrome", "content": "Chrome",
"description": "Google Chrome is a widely used web browser known for its speed, simplicity, and seamless integration with Google services.", "description": "Google Chrome is a widely used web browser known for its speed, simplicity, and seamless integration with Google services.",
@ -243,7 +241,6 @@
}, },
"chromium": { "chromium": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "chromium", "choco": "chromium",
"content": "Chromium", "content": "Chromium",
"description": "Chromium is the open-source project that serves as the foundation for various web browsers, including Chrome.", "description": "Chromium is the open-source project that serves as the foundation for various web browsers, including Chrome.",
@ -252,7 +249,6 @@
}, },
"arc": { "arc": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "na", "choco": "na",
"content": "Arc", "content": "Arc",
"description": "Arc is a Chromium based browser, known for it's clean and modern design.", "description": "Arc is a Chromium based browser, known for it's clean and modern design.",
@ -477,7 +473,6 @@
}, },
"edge": { "edge": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "microsoft-edge", "choco": "microsoft-edge",
"content": "Edge", "content": "Edge",
"description": "Microsoft Edge is a modern web browser built on Chromium, offering performance, security, and integration with Microsoft services.", "description": "Microsoft Edge is a modern web browser built on Chromium, offering performance, security, and integration with Microsoft services.",
@ -534,7 +529,6 @@
}, },
"falkon": { "falkon": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "falkon", "choco": "falkon",
"content": "Falkon", "content": "Falkon",
"description": "Falkon is a lightweight and fast web browser with a focus on user privacy and efficiency.", "description": "Falkon is a lightweight and fast web browser with a focus on user privacy and efficiency.",
@ -591,7 +585,6 @@
}, },
"firefox": { "firefox": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "firefox", "choco": "firefox",
"content": "Firefox", "content": "Firefox",
"description": "Mozilla Firefox is an open-source web browser known for its customization options, privacy features, and extensions.", "description": "Mozilla Firefox is an open-source web browser known for its customization options, privacy features, and extensions.",
@ -600,7 +593,6 @@
}, },
"firefoxesr": { "firefoxesr": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "FirefoxESR", "choco": "FirefoxESR",
"content": "Firefox ESR", "content": "Firefox ESR",
"description": "Mozilla Firefox is an open-source web browser known for its customization options, privacy features, and extensions. Firefox ESR (Extended Support Release) receives major updates every 42 weeks with minor updates such as crash fixes, security fixes and policy updates as needed, but at least every four weeks.", "description": "Mozilla Firefox is an open-source web browser known for its customization options, privacy features, and extensions. Firefox ESR (Extended Support Release) receives major updates every 42 weeks with minor updates such as crash fixes, security fixes and policy updates as needed, but at least every four weeks.",
@ -625,7 +617,6 @@
}, },
"floorp": { "floorp": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "na", "choco": "na",
"content": "Floorp", "content": "Floorp",
"description": "Floorp is an open-source web browser project that aims to provide a simple and fast browsing experience.", "description": "Floorp is an open-source web browser project that aims to provide a simple and fast browsing experience.",
@ -1098,7 +1089,6 @@
}, },
"librewolf": { "librewolf": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "librewolf", "choco": "librewolf",
"content": "LibreWolf", "content": "LibreWolf",
"description": "LibreWolf is a privacy-focused web browser based on Firefox, with additional privacy and security enhancements.", "description": "LibreWolf is a privacy-focused web browser based on Firefox, with additional privacy and security enhancements.",
@ -1291,7 +1281,6 @@
}, },
"mullvadbrowser": { "mullvadbrowser": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "na", "choco": "na",
"content": "Mullvad Browser", "content": "Mullvad Browser",
"description": "Mullvad Browser is a privacy-focused web browser, developed in partnership with the Tor Project.", "description": "Mullvad Browser is a privacy-focused web browser, developed in partnership with the Tor Project.",
@ -2204,7 +2193,6 @@
}, },
"thorium": { "thorium": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "na", "choco": "na",
"content": "Thorium Browser AVX2", "content": "Thorium Browser AVX2",
"description": "Browser built for speed over vanilla chromium. It is built with AVX2 optimizations and is the fastest browser on the market.", "description": "Browser built for speed over vanilla chromium. It is built with AVX2 optimizations and is the fastest browser on the market.",
@ -2237,7 +2225,6 @@
}, },
"tor": { "tor": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "tor-browser", "choco": "tor-browser",
"content": "Tor Browser", "content": "Tor Browser",
"description": "Tor Browser is designed for anonymous web browsing, utilizing the Tor network to protect user privacy and security.", "description": "Tor Browser is designed for anonymous web browsing, utilizing the Tor network to protect user privacy and security.",
@ -2286,7 +2273,6 @@
}, },
"ungoogled": { "ungoogled": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "ungoogled-chromium", "choco": "ungoogled-chromium",
"content": "Ungoogled", "content": "Ungoogled",
"description": "Ungoogled Chromium is a version of Chromium without Google's integration for enhanced privacy and control.", "description": "Ungoogled Chromium is a version of Chromium without Google's integration for enhanced privacy and control.",
@ -2367,7 +2353,6 @@
}, },
"vivaldi": { "vivaldi": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "vivaldi", "choco": "vivaldi",
"content": "Vivaldi", "content": "Vivaldi",
"description": "Vivaldi is a highly customizable web browser with a focus on user personalization and productivity features.", "description": "Vivaldi is a highly customizable web browser with a focus on user personalization and productivity features.",
@ -2424,7 +2409,6 @@
}, },
"waterfox": { "waterfox": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "waterfox", "choco": "waterfox",
"content": "Waterfox", "content": "Waterfox",
"description": "Waterfox is a fast, privacy-focused web browser based on Firefox, designed to preserve user choice and privacy.", "description": "Waterfox is a fast, privacy-focused web browser based on Firefox, designed to preserve user choice and privacy.",
@ -2897,7 +2881,6 @@
}, },
"PaleMoon": { "PaleMoon": {
"category": "Browsers", "category": "Browsers",
"Type": "application",
"choco": "paleMoon", "choco": "paleMoon",
"content": "PaleMoon", "content": "PaleMoon",
"description":"Pale Moon is an Open Source, Goanna-based web browser available for Microsoft Windows and Linux (with other operating systems in development), focusing on efficiency and ease of use.", "description":"Pale Moon is an Open Source, Goanna-based web browser available for Microsoft Windows and Linux (with other operating systems in development), focusing on efficiency and ease of use.",

View File

@ -134,314 +134,315 @@ function Invoke-WPFUIElements {
foreach ($entryInfo in $entries) { foreach ($entryInfo in $entries) {
$count++ $count++
switch ($entryInfo.Type) { if ($configVariable -eq $sync.configs.applications) {
"Toggle" { # Create the outer Border for the application type
$dockPanel = New-Object Windows.Controls.DockPanel $border = New-Object Windows.Controls.Border
$checkBox = New-Object Windows.Controls.CheckBox $border.BorderBrush = [Windows.Media.Brushes]::Gray
$checkBox.Name = $entryInfo.Name $border.BorderThickness = 1
$checkBox.HorizontalAlignment = "Right" $border.CornerRadius = 5
$dockPanel.Children.Add($checkBox) | Out-Null $border.Padding = New-Object Windows.Thickness(10)
$checkBox.Style = $ColorfulToggleSwitchStyle $border.HorizontalAlignment = "Stretch"
$border.VerticalAlignment = "Top"
$border.Margin = New-Object Windows.Thickness(0, 10, 0, 0)
$label = New-Object Windows.Controls.Label # Create a DockPanel inside the Border
$label.Content = $entryInfo.Content $dockPanel = New-Object Windows.Controls.DockPanel
$label.ToolTip = $entryInfo.Description $dockPanel.LastChildFill = $true
$label.HorizontalAlignment = "Left" $border.Child = $dockPanel
$label.FontSize = $theme.FontSize
$label.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor")
$dockPanel.Children.Add($label) | Out-Null
$stackPanel.Children.Add($dockPanel) | Out-Null
$sync[$entryInfo.Name] = $checkBox # Create the CheckBox, vertically centered
$checkBox = New-Object Windows.Controls.CheckBox
$checkBox.Name = $entryInfo.Name
$checkBox.HorizontalAlignment = "Left"
$checkBox.VerticalAlignment = "Center"
$checkBox.Margin = New-Object Windows.Thickness(5, 0, 10, 0)
[Windows.Controls.DockPanel]::SetDock($checkBox, [Windows.Controls.Dock]::Left)
$dockPanel.Children.Add($checkBox) | Out-Null
$sync[$entryInfo.Name].IsChecked = Get-WinUtilToggleStatus $sync[$entryInfo.Name].Name # Create a StackPanel for the image and name (for better alignment)
$imageAndNamePanel = New-Object Windows.Controls.StackPanel
$imageAndNamePanel.Orientation = "Horizontal"
$imageAndNamePanel.VerticalAlignment = "Center"
$sync[$entryInfo.Name].Add_Click({ # Create the Image and load it from the local path
[System.Object]$Sender = $args[0] $image = New-Object Windows.Controls.Image
Invoke-WPFToggle $Sender.name $image.Width = 40
}) $image.Height = 40
} $image.Margin = New-Object Windows.Thickness(0, 0, 10, 0)
if (-not [string]::IsNullOrEmpty($kaka)) {
try {
$packageinfo = (choco info $entryInfo.choco --limit-output).Split(' ')[0]
$packageinfo = $packageinfo -replace '\|', '.'
$iconlink = "https://community.chocolatey.org/content/packageimages/" + $packageinfo
$finishediconlink = $iconlink + ".png"
"ToggleButton" { $webimage = Invoke-WebRequest -Uri $finishediconlink -Method Head -ErrorAction SilentlyContinue
$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.SetResourceReference([Windows.Controls.Control]::BackgroundProperty, "ButtonInstallBackgroundColor")
$toggleButton.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor")
$toggleButton.FontWeight = [Windows.FontWeights]::Bold
$textBlock = New-Object Windows.Controls.TextBlock if ($webimage.StatusCode -eq 200) {
$textBlock.FontSize = $theme.TabButtonFontSize $image.Source = [Windows.Media.Imaging.BitmapImage]::new([Uri]::new($finishediconlink))
$textBlock.Background = [Windows.Media.Brushes]::Transparent } else {
$textBlock.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "ButtonInstallForegroundColor") $finishediconlink = $iconlink + ".svg"
$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
}
"RadioButton" {
$radioButton = New-Object Windows.Controls.RadioButton
$radioButton.Name = $entryInfo.Name
$radioButton.GroupName = $entryInfo.GroupName
$radioButton.Content = $entryInfo.Content
$radioButton.HorizontalAlignment = "Left"
$radioButton.Margin = $theme.CheckBoxMargin
$radioButton.FontSize = $theme.ButtonFontSize
$radioButton.ToolTip = $entryInfo.Description
if ($entryInfo.Checked -eq $true) {
$radioButton.IsChecked = $true
}
$stackPanel.Children.Add($radioButton) | Out-Null
$sync[$entryInfo.Name] = $radioButton
}
"application" {
# Create the outer Border for the application type
$border = New-Object Windows.Controls.Border
$border.BorderBrush = [Windows.Media.Brushes]::Gray
$border.BorderThickness = 1
$border.CornerRadius = 5
$border.Padding = New-Object Windows.Thickness(10)
$border.HorizontalAlignment = "Stretch"
$border.VerticalAlignment = "Top"
$border.Margin = New-Object Windows.Thickness(0, 10, 0, 0)
# Create a DockPanel inside the Border
$dockPanel = New-Object Windows.Controls.DockPanel
$dockPanel.LastChildFill = $true
$border.Child = $dockPanel
# Create the CheckBox, vertically centered
$checkBox = New-Object Windows.Controls.CheckBox
$checkBox.Name = $entryInfo.Name
$checkBox.HorizontalAlignment = "Left"
$checkBox.VerticalAlignment = "Center"
$checkBox.Margin = New-Object Windows.Thickness(5, 0, 10, 0)
[Windows.Controls.DockPanel]::SetDock($checkBox, [Windows.Controls.Dock]::Left)
$dockPanel.Children.Add($checkBox) | Out-Null
# Create a StackPanel for the image and name (for better alignment)
$imageAndNamePanel = New-Object Windows.Controls.StackPanel
$imageAndNamePanel.Orientation = "Horizontal"
$imageAndNamePanel.VerticalAlignment = "Center"
# Create the Image and load it from the local path
$image = New-Object Windows.Controls.Image
$image.Width = 40
$image.Height = 40
$image.Margin = New-Object Windows.Thickness(0, 0, 10, 0)
if (-not [string]::IsNullOrEmpty($entryInfo.choco)) {
try {
$packageinfo = (choco info $entryInfo.choco --limit-output).Split(' ')[0]
$packageinfo = $packageinfo -replace '\|', '.'
$iconlink = "https://community.chocolatey.org/content/packageimages/" + $packageinfo
$finishediconlink = $iconlink + ".png"
$webimage = Invoke-WebRequest -Uri $finishediconlink -Method Head -ErrorAction SilentlyContinue
if ($webimage.StatusCode -eq 200) {
$image.Source = [Windows.Media.Imaging.BitmapImage]::new([Uri]::new($finishediconlink))
} else {
$finishediconlink = $iconlink + ".svg"
$image.Source = $noimage
}
} catch {
$image.Source = $noimage $image.Source = $noimage
} }
} else {
} catch {
$image.Source = $noimage $image.Source = $noimage
} }
$image.Clip = New-Object Windows.Media.RectangleGeometry } else {
$image.Clip.Rect = New-Object Windows.Rect(0, 0, $image.Width, $image.Height) $image.Source = $noimage
$image.Clip.RadiusX = 5
$image.Clip.RadiusY = 5
$imageAndNamePanel.Children.Add($image) | Out-Null
# Create the TextBlock for the application name (bigger and bold)
$appName = New-Object Windows.Controls.TextBlock
$appName.Text = $entryInfo.Content
$appName.FontSize = 16
$appName.FontWeight = [Windows.FontWeights]::Bold
$appName.VerticalAlignment = "Center"
$appName.Margin = New-Object Windows.Thickness(5, 0, 0, 0)
$imageAndNamePanel.Children.Add($appName) | Out-Null
# Add the image and name panel to the dock panel (after the checkbox)
[Windows.Controls.DockPanel]::SetDock($imageAndNamePanel, [Windows.Controls.Dock]::Left)
$dockPanel.Children.Add($imageAndNamePanel) | Out-Null
# Create the StackPanel for the buttons and dock it to the right
$buttonPanel = New-Object Windows.Controls.StackPanel
$buttonPanel.Orientation = "Horizontal"
$buttonPanel.HorizontalAlignment = "Right"
$buttonPanel.VerticalAlignment = "Center"
$buttonPanel.Margin = New-Object Windows.Thickness(10, 0, 0, 0)
[Windows.Controls.DockPanel]::SetDock($buttonPanel, [Windows.Controls.Dock]::Right)
# Create the "Install" button with the install icon from Segoe MDL2 Assets
$button1 = New-Object Windows.Controls.Button
$button1.Width = 45
$button1.Height = 35
$button1.Margin = New-Object Windows.Thickness(0, 0, 10, 0)
$installIcon = New-Object Windows.Controls.TextBlock
$installIcon.Text = [char]0xE118 # Install Icon
$installIcon.FontFamily = "Segoe MDL2 Assets"
$installIcon.FontSize = 20
$installIcon.Foreground = $theme.MainForegroundColor
$installIcon.Background = "Transparent"
$installIcon.HorizontalAlignment = "Center"
$installIcon.VerticalAlignment = "Center"
$button1.Content = $installIcon
$buttonPanel.Children.Add($button1) | Out-Null
# Create the "Uninstall" button with the uninstall icon from Segoe MDL2 Assets
$button2 = New-Object Windows.Controls.Button
$button2.Width = 45
$button2.Height = 35
$uninstallIcon = New-Object Windows.Controls.TextBlock
$uninstallIcon.Text = [char]0xE74D # Uninstall Icon
$uninstallIcon.FontFamily = "Segoe MDL2 Assets"
$uninstallIcon.FontSize = 20
$uninstallIcon.Foreground = $theme.MainForegroundColor
$uninstallIcon.Background = "Transparent"
$uninstallIcon.HorizontalAlignment = "Center"
$uninstallIcon.VerticalAlignment = "Center"
$button2.Content = $uninstallIcon
$buttonPanel.Children.Add($button2) | Out-Null
# Create the "Info" button with the info icon from Segoe MDL2 Assets
$infoButton = New-Object Windows.Controls.Button
$infoButton.Width = 45
$infoButton.Height = 35
$infoButton.Margin = New-Object Windows.Thickness(10, 0, 0, 0)
$infoIcon = New-Object Windows.Controls.TextBlock
$infoIcon.Text = [char]0xE946 # Info Icon
$infoIcon.FontFamily = "Segoe MDL2 Assets"
$infoIcon.FontSize = 20
$infoIcon.Foreground = $theme.MainForegroundColor
$infoIcon.Background = "Transparent"
$infoIcon.HorizontalAlignment = "Center"
$infoIcon.VerticalAlignment = "Center"
$infoButton.Content = $infoIcon
$buttonPanel.Children.Add($infoButton) | Out-Null
# Add the button panel to the DockPanel
$dockPanel.Children.Add($buttonPanel) | Out-Null
# Add the border to the main stack panel in the grid
$stackPanel.Children.Add($border) | Out-Null
# Sync the CheckBox, buttons, and info to the sync object for further use
$sync[$entryInfo.Name] = $checkBox
$sync[$entryInfo.Name + "_InstallButton"] = $button1
$sync[$entryInfo.Name + "_UninstallButton"] = $button2
$sync[$entryInfo.Name + "_InfoButton"] = $infoButton
} }
$image.Clip = New-Object Windows.Media.RectangleGeometry
$image.Clip.Rect = New-Object Windows.Rect(0, 0, $image.Width, $image.Height)
$image.Clip.RadiusX = 5
$image.Clip.RadiusY = 5
default { $imageAndNamePanel.Children.Add($image) | Out-Null
$horizontalStackPanel = New-Object Windows.Controls.StackPanel
$horizontalStackPanel.Orientation = "Horizontal"
$checkBox = New-Object Windows.Controls.CheckBox # Create the TextBlock for the application name (bigger and bold)
$checkBox.Name = $entryInfo.Name $appName = New-Object Windows.Controls.TextBlock
$checkBox.Content = $entryInfo.Content $appName.Text = $entryInfo.Content
$checkBox.FontSize = $theme.FontSize $appName.FontSize = 16
$checkBox.ToolTip = $entryInfo.Description $appName.FontWeight = [Windows.FontWeights]::Bold
$checkBox.Margin = $theme.CheckBoxMargin $appName.VerticalAlignment = "Center"
if ($entryInfo.Checked -eq $true) { $appName.Margin = New-Object Windows.Thickness(5, 0, 0, 0)
$checkBox.IsChecked = $entryInfo.Checked $imageAndNamePanel.Children.Add($appName) | Out-Null
# Add the image and name panel to the dock panel (after the checkbox)
[Windows.Controls.DockPanel]::SetDock($imageAndNamePanel, [Windows.Controls.Dock]::Left)
$dockPanel.Children.Add($imageAndNamePanel) | Out-Null
# Create the StackPanel for the buttons and dock it to the right
$buttonPanel = New-Object Windows.Controls.StackPanel
$buttonPanel.Orientation = "Horizontal"
$buttonPanel.HorizontalAlignment = "Right"
$buttonPanel.VerticalAlignment = "Center"
$buttonPanel.Margin = New-Object Windows.Thickness(10, 0, 0, 0)
[Windows.Controls.DockPanel]::SetDock($buttonPanel, [Windows.Controls.Dock]::Right)
# Create the "Install" button with the install icon from Segoe MDL2 Assets
$button1 = New-Object Windows.Controls.Button
$button1.Width = 45
$button1.Height = 35
$button1.Margin = New-Object Windows.Thickness(0, 0, 10, 0)
$installIcon = New-Object Windows.Controls.TextBlock
$installIcon.Text = [char]0xE118 # Install Icon
$installIcon.FontFamily = "Segoe MDL2 Assets"
$installIcon.FontSize = 20
$installIcon.Foreground = $theme.MainForegroundColor
$installIcon.Background = "Transparent"
$installIcon.HorizontalAlignment = "Center"
$installIcon.VerticalAlignment = "Center"
$button1.Content = $installIcon
$buttonPanel.Children.Add($button1) | Out-Null
# Create the "Uninstall" button with the uninstall icon from Segoe MDL2 Assets
$button2 = New-Object Windows.Controls.Button
$button2.Width = 45
$button2.Height = 35
$uninstallIcon = New-Object Windows.Controls.TextBlock
$uninstallIcon.Text = [char]0xE74D # Uninstall Icon
$uninstallIcon.FontFamily = "Segoe MDL2 Assets"
$uninstallIcon.FontSize = 20
$uninstallIcon.Foreground = $theme.MainForegroundColor
$uninstallIcon.Background = "Transparent"
$uninstallIcon.HorizontalAlignment = "Center"
$uninstallIcon.VerticalAlignment = "Center"
$button2.Content = $uninstallIcon
$buttonPanel.Children.Add($button2) | Out-Null
# Create the "Info" button with the info icon from Segoe MDL2 Assets
$infoButton = New-Object Windows.Controls.Button
$infoButton.Width = 45
$infoButton.Height = 35
$infoButton.Margin = New-Object Windows.Thickness(10, 0, 0, 0)
$infoIcon = New-Object Windows.Controls.TextBlock
$infoIcon.Text = [char]0xE946 # Info Icon
$infoIcon.FontFamily = "Segoe MDL2 Assets"
$infoIcon.FontSize = 20
$infoIcon.Foreground = $theme.MainForegroundColor
$infoIcon.Background = "Transparent"
$infoIcon.HorizontalAlignment = "Center"
$infoIcon.VerticalAlignment = "Center"
$infoButton.Content = $infoIcon
$buttonPanel.Children.Add($infoButton) | Out-Null
# Add the button panel to the DockPanel
$dockPanel.Children.Add($buttonPanel) | Out-Null
# Add the border to the main stack panel in the grid
$stackPanel.Children.Add($border) | Out-Null
# Sync the CheckBox, buttons, and info to the sync object for further use
$sync[$entryInfo.Name] = $checkBox
$sync[$entryInfo.Name + "_InstallButton"] = $button1
$sync[$entryInfo.Name + "_UninstallButton"] = $button2
$sync[$entryInfo.Name + "_InfoButton"] = $infoButton
} else {
# Create the UI elements based on the entry type
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
$label.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor")
$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
})
} }
$horizontalStackPanel.Children.Add($checkBox) | Out-Null
if ($entryInfo.Link) { "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.SetResourceReference([Windows.Controls.Control]::BackgroundProperty, "ButtonInstallBackgroundColor")
$toggleButton.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "MainForegroundColor")
$toggleButton.FontWeight = [Windows.FontWeights]::Bold
$textBlock = New-Object Windows.Controls.TextBlock $textBlock = New-Object Windows.Controls.TextBlock
$textBlock.Name = $checkBox.Name + "Link" $textBlock.FontSize = $theme.TabButtonFontSize
$textBlock.Text = "(?)" $textBlock.Background = [Windows.Media.Brushes]::Transparent
$textBlock.ToolTip = $entryInfo.Link $textBlock.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "ButtonInstallForegroundColor")
$textBlock.Style = $HoverTextBlockStyle
$horizontalStackPanel.Children.Add($textBlock) | Out-Null $underline = New-Object Windows.Documents.Underline
$underline.Inlines.Add($entryInfo.name -replace "(.).*", "`$1")
$sync[$textBlock.Name] = $textBlock $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
} }
$stackPanel.Children.Add($horizontalStackPanel) | Out-Null "Combobox" {
$sync[$entryInfo.Name] = $checkBox $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
}
"RadioButton" {
$radioButton = New-Object Windows.Controls.RadioButton
$radioButton.Name = $entryInfo.Name
$radioButton.GroupName = $entryInfo.GroupName
$radioButton.Content = $entryInfo.Content
$radioButton.HorizontalAlignment = "Left"
$radioButton.Margin = $theme.CheckBoxMargin
$radioButton.FontSize = $theme.ButtonFontSize
$radioButton.ToolTip = $entryInfo.Description
if ($entryInfo.Checked -eq $true) {
$radioButton.IsChecked = $true
}
$stackPanel.Children.Add($radioButton) | Out-Null
$sync[$entryInfo.Name] = $radioButton
}
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 -eq $true) {
$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
$horizontalStackPanel.Children.Add($textBlock) | Out-Null
$sync[$textBlock.Name] = $textBlock
}
$stackPanel.Children.Add($horizontalStackPanel) | Out-Null
$sync[$entryInfo.Name] = $checkBox
}
} }
} }
} }