mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-23 14:31:30 -06:00
add compatibility for every app
This commit is contained in:
parent
db521534bc
commit
71c35eccd6
@ -171,7 +171,6 @@
|
||||
"category": "Browsers",
|
||||
"choco": "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.",
|
||||
"link": "https://www.brave.com",
|
||||
"winget": "Brave.Brave"
|
||||
@ -234,7 +233,6 @@
|
||||
},
|
||||
"chrome": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "googlechrome",
|
||||
"content": "Chrome",
|
||||
"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": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "chromium",
|
||||
"content": "Chromium",
|
||||
"description": "Chromium is the open-source project that serves as the foundation for various web browsers, including Chrome.",
|
||||
@ -252,7 +249,6 @@
|
||||
},
|
||||
"arc": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "na",
|
||||
"content": "Arc",
|
||||
"description": "Arc is a Chromium based browser, known for it's clean and modern design.",
|
||||
@ -477,7 +473,6 @@
|
||||
},
|
||||
"edge": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "microsoft-edge",
|
||||
"content": "Edge",
|
||||
"description": "Microsoft Edge is a modern web browser built on Chromium, offering performance, security, and integration with Microsoft services.",
|
||||
@ -534,7 +529,6 @@
|
||||
},
|
||||
"falkon": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "falkon",
|
||||
"content": "Falkon",
|
||||
"description": "Falkon is a lightweight and fast web browser with a focus on user privacy and efficiency.",
|
||||
@ -591,7 +585,6 @@
|
||||
},
|
||||
"firefox": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "firefox",
|
||||
"content": "Firefox",
|
||||
"description": "Mozilla Firefox is an open-source web browser known for its customization options, privacy features, and extensions.",
|
||||
@ -600,7 +593,6 @@
|
||||
},
|
||||
"firefoxesr": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "FirefoxESR",
|
||||
"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.",
|
||||
@ -625,7 +617,6 @@
|
||||
},
|
||||
"floorp": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "na",
|
||||
"content": "Floorp",
|
||||
"description": "Floorp is an open-source web browser project that aims to provide a simple and fast browsing experience.",
|
||||
@ -1098,7 +1089,6 @@
|
||||
},
|
||||
"librewolf": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "librewolf",
|
||||
"content": "LibreWolf",
|
||||
"description": "LibreWolf is a privacy-focused web browser based on Firefox, with additional privacy and security enhancements.",
|
||||
@ -1291,7 +1281,6 @@
|
||||
},
|
||||
"mullvadbrowser": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "na",
|
||||
"content": "Mullvad Browser",
|
||||
"description": "Mullvad Browser is a privacy-focused web browser, developed in partnership with the Tor Project.",
|
||||
@ -2204,7 +2193,6 @@
|
||||
},
|
||||
"thorium": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "na",
|
||||
"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.",
|
||||
@ -2237,7 +2225,6 @@
|
||||
},
|
||||
"tor": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "tor-browser",
|
||||
"content": "Tor Browser",
|
||||
"description": "Tor Browser is designed for anonymous web browsing, utilizing the Tor network to protect user privacy and security.",
|
||||
@ -2286,7 +2273,6 @@
|
||||
},
|
||||
"ungoogled": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "ungoogled-chromium",
|
||||
"content": "Ungoogled",
|
||||
"description": "Ungoogled Chromium is a version of Chromium without Google's integration for enhanced privacy and control.",
|
||||
@ -2367,7 +2353,6 @@
|
||||
},
|
||||
"vivaldi": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "vivaldi",
|
||||
"content": "Vivaldi",
|
||||
"description": "Vivaldi is a highly customizable web browser with a focus on user personalization and productivity features.",
|
||||
@ -2424,7 +2409,6 @@
|
||||
},
|
||||
"waterfox": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "waterfox",
|
||||
"content": "Waterfox",
|
||||
"description": "Waterfox is a fast, privacy-focused web browser based on Firefox, designed to preserve user choice and privacy.",
|
||||
@ -2897,7 +2881,6 @@
|
||||
},
|
||||
"PaleMoon": {
|
||||
"category": "Browsers",
|
||||
"Type": "application",
|
||||
"choco": "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.",
|
||||
|
@ -134,314 +134,315 @@ function Invoke-WPFUIElements {
|
||||
foreach ($entryInfo in $entries) {
|
||||
$count++
|
||||
|
||||
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
|
||||
if ($configVariable -eq $sync.configs.applications) {
|
||||
# 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)
|
||||
|
||||
$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
|
||||
# Create a DockPanel inside the Border
|
||||
$dockPanel = New-Object Windows.Controls.DockPanel
|
||||
$dockPanel.LastChildFill = $true
|
||||
$border.Child = $dockPanel
|
||||
|
||||
$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({
|
||||
[System.Object]$Sender = $args[0]
|
||||
Invoke-WPFToggle $Sender.name
|
||||
})
|
||||
}
|
||||
# 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($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" {
|
||||
$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
|
||||
$webimage = Invoke-WebRequest -Uri $finishediconlink -Method Head -ErrorAction SilentlyContinue
|
||||
|
||||
$textBlock = New-Object Windows.Controls.TextBlock
|
||||
$textBlock.FontSize = $theme.TabButtonFontSize
|
||||
$textBlock.Background = [Windows.Media.Brushes]::Transparent
|
||||
$textBlock.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "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
|
||||
}
|
||||
|
||||
"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 {
|
||||
if ($webimage.StatusCode -eq 200) {
|
||||
$image.Source = [Windows.Media.Imaging.BitmapImage]::new([Uri]::new($finishediconlink))
|
||||
} else {
|
||||
$finishediconlink = $iconlink + ".svg"
|
||||
$image.Source = $noimage
|
||||
}
|
||||
} else {
|
||||
|
||||
} catch {
|
||||
$image.Source = $noimage
|
||||
}
|
||||
$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
|
||||
|
||||
$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
|
||||
} else {
|
||||
$image.Source = $noimage
|
||||
}
|
||||
$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 {
|
||||
$horizontalStackPanel = New-Object Windows.Controls.StackPanel
|
||||
$horizontalStackPanel.Orientation = "Horizontal"
|
||||
$imageAndNamePanel.Children.Add($image) | Out-Null
|
||||
|
||||
$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
|
||||
# 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
|
||||
} 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.Name = $checkBox.Name + "Link"
|
||||
$textBlock.Text = "(?)"
|
||||
$textBlock.ToolTip = $entryInfo.Link
|
||||
$textBlock.Style = $HoverTextBlockStyle
|
||||
$textBlock.FontSize = $theme.TabButtonFontSize
|
||||
$textBlock.Background = [Windows.Media.Brushes]::Transparent
|
||||
$textBlock.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "ButtonInstallForegroundColor")
|
||||
|
||||
$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
|
||||
$sync[$entryInfo.Name] = $checkBox
|
||||
"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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user