mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 17:30:37 -06:00
First Selector and Logic
This commit is contained in:
parent
2748767a47
commit
bd730b5418
28
functions/private/Set-DownloadEngine.ps1
Normal file
28
functions/private/Set-DownloadEngine.ps1
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
function Set-DownloadEngine {
|
||||||
|
$CheckBoxes = $sync.GetEnumerator() | Where-Object { $_.Value -is [System.Windows.Controls.CheckBox] }
|
||||||
|
foreach ($CheckBox in $CheckBoxes) {
|
||||||
|
if ($CheckBox.Key.StartsWith("WPFInstall")) {
|
||||||
|
Switch ($sync.DownloadEngine) {
|
||||||
|
"Winget" {
|
||||||
|
if ($($sync.configs.applications.$($CheckBox.Name).winget) -eq "na"){
|
||||||
|
$CheckBox.Value.Visibility = "Collapsed"
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$CheckBox.Value.Visibility = "Visible"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"Chocolatey"{
|
||||||
|
if ($($sync.configs.applications.$($CheckBox.Name).chocolatey) -eq "na"){
|
||||||
|
$CheckBox.Value.Visibility = "Collapsed"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$CheckBox.Value.Visibility = "Visible"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default{
|
||||||
|
$CheckBox.Value.Visibility = "Visible"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -87,6 +87,19 @@ try {
|
|||||||
|
|
||||||
$xaml.SelectNodes("//*[@Name]") | ForEach-Object {$sync["$("$($psitem.Name)")"] = $sync["Form"].FindName($psitem.Name)}
|
$xaml.SelectNodes("//*[@Name]") | ForEach-Object {$sync["$("$($psitem.Name)")"] = $sync["Form"].FindName($psitem.Name)}
|
||||||
|
|
||||||
|
#Initialize Download Engine
|
||||||
|
$selectedItem = $sync.WPFselectDownloadEngine.SelectedItem
|
||||||
|
$selectedText = $selectedItem.Content
|
||||||
|
$sync.DownloadEngine = $selectedText
|
||||||
|
Set-DownloadEngine
|
||||||
|
|
||||||
|
$sync.WPFselectDownloadEngine.Add_SelectionChanged({
|
||||||
|
$selectedItem = $sync.WPFselectDownloadEngine.SelectedItem
|
||||||
|
$selectedText = $selectedItem.Content
|
||||||
|
$sync.DownloadEngine = $selectedText
|
||||||
|
Set-DownloadEngine
|
||||||
|
})
|
||||||
|
|
||||||
$sync.keys | ForEach-Object {
|
$sync.keys | ForEach-Object {
|
||||||
if($sync.$psitem) {
|
if($sync.$psitem) {
|
||||||
if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "CheckBox" `
|
if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "CheckBox" `
|
||||||
|
@ -793,6 +793,11 @@
|
|||||||
<Button Name="WPFuninstall" Content=" Uninstall Selected" Margin="2"/>
|
<Button Name="WPFuninstall" Content=" Uninstall Selected" Margin="2"/>
|
||||||
<Button Name="WPFGetInstalled" Content=" Get Installed" Margin="2"/>
|
<Button Name="WPFGetInstalled" Content=" Get Installed" Margin="2"/>
|
||||||
<Button Name="WPFclearWinget" Content=" Clear Selection" Margin="2"/>
|
<Button Name="WPFclearWinget" Content=" Clear Selection" Margin="2"/>
|
||||||
|
<ComboBox Name="WPFselectDownloadEngine" SelectedIndex="0" Margin="2">
|
||||||
|
<ComboBoxItem Content="Auto" />
|
||||||
|
<ComboBoxItem Content="Winget"/>
|
||||||
|
<ComboBoxItem Content="Chocolatey"/>
|
||||||
|
</ComboBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<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"
|
||||||
|
Loading…
Reference in New Issue
Block a user