diff --git a/config/themes.json b/config/themes.json index 0a370715..63817890 100644 --- a/config/themes.json +++ b/config/themes.json @@ -67,6 +67,7 @@ "ButtonBackgroundSelectedColor": "#F0F0F0", "ButtonForegroundColor": "#232629", "ToggleButtonOnColor": "#2e77ff", + "ToggleButtonOffColor": "#707070", "BorderColor": "#232629", "BorderOpacity": "0.2" @@ -100,7 +101,8 @@ "ButtonBackgroundMouseoverColor": "#3B4252", "ButtonBackgroundSelectedColor": "#5E81AC", "ButtonForegroundColor": "#F7F7F7", - "ToggleButtonOnColor": "#2e77ff", + "ToggleButtonOnColor": "#2e77ff", + "ToggleButtonOffColor": "#707070", "BorderColor": "#2F373D", "BorderOpacity": "0.2" } diff --git a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 index 32d9e02b..c607ad69 100644 --- a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 +++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 @@ -25,6 +25,56 @@ function Test-CompatibleImage() { } } +function Get-FidoLangFromCulture { + + param ( + [Parameter(Mandatory, Position = 0)] [string] $langName + ) + + switch -Wildcard ($langName) + { + "ar*" { return "Arabic" } + "pt-BR" { return "Brazilian Portuguese" } + "bg*" { return "Bulgarian" } + {($_ -eq "zh-CH") -or ($_ -like "zh-Hans*") -or ($_ -eq "zh-SG") -or ($_ -eq "zh-CHS")} { return "Chinese (Simplified)" } + {($_ -eq "zh") -or ($_ -eq "zh-Hant") -or ($_ -eq "zh-HK") -or ($_ -eq "zh-MO") -or ($_ -eq "zh-TW") -or ($_ -eq "zh-CHT")} { return "Chinese (Traditional)" } + "hr*" { return "Croatian" } + "cs*" { return "Czech" } + "da*" { return "Danish" } + "nl*" { return "Dutch" } + "en-US" { return "English" } + {($_ -like "en*") -and ($_ -ne "en-US")} { return "English International" } + "et*" { return "Estonian" } + "fi*" { return "Finnish" } + {($_ -like "fr*") -and ($_ -ne "fr-CA")} { return "French" } + "fr-CA" { return "French Canadian" } + "de*" { return "German" } + "el*" { return "Greek" } + "he*" { return "Hebrew" } + "hu*" { return "Hungarian" } + "it*" { return "Italian" } + "ja*" { return "Japanese" } + "ko*" { return "Korean" } + "lv*" { return "Latvian" } + "lt*" { return "Lituanian" } + "nb*" { return "Norwegian" } + "pl*" { return "Polish" } + {($_ -like "pt*") -and ($_ -ne "pt-BR")} { return "Portuguese" } + "ro*" { return "Romanian" } + "ru*" { return "Russian" } + "sr-Latn*" { return "Serbian Latin" } + "sk*" { return "Slovak" } + "sl*" { return "Slovenian" } + {($_ -like "es*") -and ($_ -ne "es-MX")} { return "Spanish" } + "es-MX" { return "Spanish (Mexico)" } + "sv*" { return "Swedish" } + "th*" { return "Thai" } + "tr*" { return "Turkish" } + "uk*" { return "Ukrainian" } + default { return "English" } + } +} + function Remove-Features() { <# .SYNOPSIS diff --git a/functions/public/Invoke-WPFGetIso.ps1 b/functions/public/Invoke-WPFGetIso.ps1 index 31a37e4f..98b653d5 100644 --- a/functions/public/Invoke-WPFGetIso.ps1 +++ b/functions/public/Invoke-WPFGetIso.ps1 @@ -62,17 +62,32 @@ function Invoke-WPFGetIso { } } - [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null - $openFileDialog = New-Object System.Windows.Forms.OpenFileDialog - $openFileDialog.initialDirectory = $initialDirectory - $openFileDialog.filter = "ISO files (*.iso)| *.iso" - $openFileDialog.ShowDialog() | Out-Null - $filePath = $openFileDialog.FileName + if ($sync["ISOmanual"].IsChecked) { + # Open file dialog to let user choose the ISO file + [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null + $openFileDialog = New-Object System.Windows.Forms.OpenFileDialog + $openFileDialog.initialDirectory = $initialDirectory + $openFileDialog.filter = "ISO files (*.iso)| *.iso" + $openFileDialog.ShowDialog() | Out-Null + $filePath = $openFileDialog.FileName - if ([string]::IsNullOrEmpty($filePath)) { - Write-Host "No ISO is chosen" - $sync.BusyMessage.Visibility="Hidden" - return + if ([string]::IsNullOrEmpty($filePath)) { + Write-Host "No ISO is chosen" + $sync.BusyMessage.Visibility="Hidden" + return + } + } elseif ($sync["ISOdownloader"].IsChecked) { + # Auto download newest ISO + # Credit: https://github.com/pbatard/Fido + $fidopath = "$env:temp\Fido.ps1" + $originalLocation = Get-Location + + Invoke-WebRequest "https://github.com/pbatard/Fido/raw/master/Fido.ps1" -OutFile $fidopath + + Set-Location -Path $env:temp + & $fidopath -Win 'Windows 11' -Rel $sync["ISORelease"].SelectedItem -Arch "x64" -Lang $sync["ISOLanguage"].SelectedItem -Ed "Windows 11 Home/Pro/Edu" + Set-Location $originalLocation + $filePath = Get-ChildItem -Path "$env:temp" -Filter "Win11*.iso" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 } Write-Host "File path $($filePath)" diff --git a/scripts/main.ps1 b/scripts/main.ps1 index da45b3be..d1613b95 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -370,6 +370,37 @@ Add-Type @" }) +# Add event handlers for the RadioButtons +$sync["ISOdownloader"].add_Checked({ + $sync["ISORelease"].Visibility = [System.Windows.Visibility]::Visible + $sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Visible +}) + +$sync["ISOmanual"].add_Checked({ + $sync["ISORelease"].Visibility = [System.Windows.Visibility]::Collapsed + $sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Collapsed +}) + +$sync["ISORelease"].Items.Add("23H2") | Out-Null +$sync["ISORelease"].Items.Add("22H2") | Out-Null +$sync["ISORelease"].Items.Add("21H2") | Out-Null +$sync["ISORelease"].SelectedItem = "23H2" + +$currentCulture = Get-FidoLangFromCulture -langName (Get-Culture).Name + +$sync["ISOLanguage"].Items.Add($currentCulture) | Out-Null +if ($currentCulture -ne "English International") { + $sync["ISOLanguage"].Items.Add("English International") | Out-Null +} +if ($currentCulture -ne "English") { + $sync["ISOLanguage"].Items.Add("English") | Out-Null +} +if ($sync["ISOLanguage"].Items.Count -eq 1) { + $sync["ISOLanguage"].IsEnabled = $false +} +$sync["ISOLanguage"].SelectedItem = $currentCulture + + # Load Checkboxes and Labels outside of the Filter function only once on startup for performance reasons $filter = Get-WinUtilVariables -Type CheckBox $CheckBoxes = ($sync.GetEnumerator()).where{ $psitem.Key -in $filter } diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml index c40be1e0..3009e1fe 100644 --- a/xaml/inputXML.xaml +++ b/xaml/inputXML.xaml @@ -366,6 +366,47 @@ +