Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microwin ISO downloader #2581

Merged
merged 30 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
86a0b9b
try1
MyDrift-user Aug 17, 2024
0ee9972
little fix
MyDrift-user Aug 19, 2024
7cc5725
change back to using Fido
MyDrift-user Aug 19, 2024
838716e
little update
MyDrift-user Aug 19, 2024
07b20cd
fix some stuff
MyDrift-user Aug 19, 2024
ea2a92f
Merge branch 'main' into microwinisodownloader
MyDrift-user Aug 19, 2024
fcd339d
fix (maybe?)
MyDrift-user Aug 19, 2024
f63c312
remove architecture selection
MyDrift-user Aug 20, 2024
c8ccb85
Merge branch 'ChrisTitusTech:main' into microwinisodownloader
MyDrift-user Aug 22, 2024
6ab99d5
add somewhat of a lang support (needs improvement)
MyDrift-user Aug 24, 2024
4b9a9b2
Merge branch 'ChrisTitusTech:main' into microwinisodownloader
MyDrift-user Sep 1, 2024
6dbdfa6
WIP: refractor of existing logic & addition of language selection
MyDrift-user Sep 3, 2024
084ac94
WIP: correct lang display (not working rn)
MyDrift-user Sep 5, 2024
34e2ee4
improve, fix and more
MyDrift-user Sep 9, 2024
c89302a
Merge branch 'ChrisTitusTech:main' into microwinisodownloader
MyDrift-user Sep 9, 2024
f31c08f
little output fix
MyDrift-user Sep 9, 2024
1ed4676
improve coloring
MyDrift-user Sep 9, 2024
6734009
fix lang
MyDrift-user Sep 9, 2024
fec9cba
fix "en-" lang
MyDrift-user Sep 10, 2024
c86d3cd
always add "English"
MyDrift-user Sep 10, 2024
f2413a4
Merge branch 'ChrisTitusTech:main' into microwinisodownloader
MyDrift-user Sep 10, 2024
9d6b35b
fix theming
MyDrift-user Sep 10, 2024
c868546
Merge branch 'main' into microwinisodownloader
MyDrift-user Sep 10, 2024
ef0ac78
fix merge issue
MyDrift-user Sep 10, 2024
adc2bd3
update instructions
MyDrift-user Sep 12, 2024
c265286
Merge branch 'main' into microwinisodownloader
MyDrift-user Sep 12, 2024
a8b9128
update ui
MyDrift-user Sep 15, 2024
7a49132
fix by adding line break to instructions
MyDrift-user Sep 15, 2024
8a47ba4
Merge branch 'main' into microwinisodownloader
MyDrift-user Sep 20, 2024
790e16c
fix merge issues
MyDrift-user Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config/themes.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"ButtonBackgroundSelectedColor": "#F0F0F0",
"ButtonForegroundColor": "#000000",
"ToggleButtonOnColor": "#2e77ff",
"ToggleButtonOffColor": "#707070",

"ButtonBorderThickness": "1",
"ButtonMargin": "1",
Expand Down Expand Up @@ -100,7 +101,8 @@
"ButtonBackgroundMouseoverColor": "#C2C2C2",
"ButtonBackgroundSelectedColor": "#F0F0F0",
"ButtonForegroundColor": "#000000",
"ToggleButtonOnColor": "#2e77ff"
"ToggleButtonOnColor": "#2e77ff",
"ToggleButtonOffColor": "#707070"
},
"Matrix": {
"ComboBoxBackgroundColor": "#000000",
Expand Down Expand Up @@ -130,6 +132,7 @@
"ButtonBackgroundSelectedColor": "#FF5733",
"ButtonForegroundColor": "#9CCC65",
"ToggleButtonOnColor": "#2e77ff",
"ToggleButtonOffColor": "#707070",

"BorderColor": "#FFAC1C",
"BorderOpacity": "0.8",
Expand Down Expand Up @@ -163,6 +166,7 @@
"ButtonBackgroundSelectedColor": "#FF5733",
"ButtonForegroundColor": "#9CCC65",
"ToggleButtonOnColor": "#2e77ff",
"ToggleButtonOffColor": "#707070",

"BorderColor": "#FFAC1C"
}
Expand Down
50 changes: 50 additions & 0 deletions functions/private/Invoke-WinUtilMicroWin-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 26 additions & 11 deletions functions/public/Invoke-WPFGetIso.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 ([string]::IsNullOrEmpty($filePath)) {
Write-Host "No ISO is chosen"
$sync.BusyMessage.Visibility="Hidden"
return
if ($sync["ISOoption2"].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
}
} elseif ($sync["ISOoption1"].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)"
Expand Down
31 changes: 31 additions & 0 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,37 @@ Add-Type @"

})

# Add event handlers for the RadioButtons
$sync["ISOoption1"].add_Checked({
$sync["ISORelease"].Visibility = [System.Windows.Visibility]::Visible
$sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Visible
})

$sync["ISOoption2"].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 }
Expand Down
51 changes: 48 additions & 3 deletions xaml/inputXML.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,47 @@
</Setter.Value>
</Setter>
</Style>
<Style TargetType="RadioButton">
<Setter Property="Foreground" Value="{MainForegroundColor}"/>
<Setter Property="Background" Value="{MainBackgroundColor}"/>
<Setter Property="FontSize" Value="{FontSize}" />
<Setter Property="FontFamily" Value="{FontFamily}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<StackPanel Orientation="Horizontal" Margin="{CheckBoxMargin}">
<Grid Width="14" Height="14">
<Ellipse x:Name="OuterCircle"
Stroke="{ToggleButtonOffColor}"
Fill="{ButtonBackgroundColor}"
StrokeThickness="1"
Width="14"
Height="14"
SnapsToDevicePixels="True"/>
<Ellipse x:Name="InnerCircle"
Fill="{ToggleButtonOnColor}"
Width="8"
Height="8"
Visibility="Collapsed"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
<ContentPresenter Margin="4,0,0,0"
VerticalAlignment="Center"
RecognizesAccessKey="True"/>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="InnerCircle" Property="Visibility" Value="Visible"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="OuterCircle" Property="Stroke" Value="{BorderColor}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ToggleSwitchStyle" TargetType="CheckBox">
<Setter Property="Template">
<Setter.Value>
Expand Down Expand Up @@ -473,8 +514,8 @@
</Trigger>
<Trigger Property="ToggleButton.IsChecked" Value="False">
<Setter TargetName="Border" Property="Background" Value="{MainBackgroundColor}" />
<Setter TargetName="Border" Property="BorderBrush" Value="#707070" />
<Setter TargetName="Ellipse" Property="Fill" Value="#707070" />
<Setter TargetName="Border" Property="BorderBrush" Value="{ToggleButtonOffColor}" />
<Setter TargetName="Ellipse" Property="Fill" Value="{ToggleButtonOffColor}" />
</Trigger>

<Trigger Property="ToggleButton.IsChecked" Value="True">
Expand Down Expand Up @@ -982,10 +1023,14 @@
TextWrapping="Wrap"
Foreground="{LabelboxForegroundColor}"
/>
<RadioButton x:Name="ISOoption1" Content="Get newest ISO automatically" GroupName="Options" IsChecked="True"/>
<ComboBox x:Name="ISORelease"/>
<ComboBox x:Name="ISOLanguage"/>
<RadioButton x:Name="ISOoption2" Content="Select your own ISO" GroupName="Options"/>
<Button Name="WPFGetIso" Margin="2" Padding="15">
<Button.Content>
<TextBlock Background="Transparent" Foreground="{ButtonForegroundColor}">
Select Windows <Underline>I</Underline>SO
Get Windows <Underline>I</Underline>SO
</TextBlock>
</Button.Content>
</Button>
Expand Down