This commit is contained in:
MyDrift 2024-08-17 20:33:11 +02:00
parent 3dd51a6c3c
commit 86a0b9bd03
3 changed files with 93 additions and 11 deletions

View File

@ -62,17 +62,28 @@ 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["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
$Win = "Win11"
$Rel = "23H2"
$Outpath = "$env:TEMP\$Win" + "_$Rel.iso"
Invoke-Webrequest -Uri $finalurl -OutFile $Outpath
$filePath = $Outpath
if ([string]::IsNullOrEmpty($filePath)) {
Write-Host "No ISO is chosen"
$sync.BusyMessage.Visibility="Hidden"
return
}
Write-Host "File path $($filePath)"

View File

@ -356,6 +356,31 @@ Add-Type @"
})
$sync["ISORelease"].Items.Add("23H2")
$sync["ISORelease"].Items.Add("22H2")
$sync["ISORelease"].Items.Add("21H2")
$sync["ISORelease"].SelectedItem = "23H2"
$sync["ISOLanguage"].Items.Add((Get-Culture).Name)
if ((Get-Culture).Name -ne "en-US") {
$sync["ISOLanguage"].Items.Add("en-US")
}
$sync["ISOLanguage"].SelectedItem = (Get-Culture).Name
$sync["ISOArchitecture"].Items.Add("64-bit")
$sync["ISOArchitecture"].Items.Add("86-bit")
$sync["ISOArchitecture"].SelectedItem = (Get-WmiObject -Class Win32_OperatingSystem).OSArchitecture
if ($sync["ISOoption1"].IsChecked) {
$sync["ISORelease"].Visibility = [System.Windows.Visibility]::Visible
$sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Visible
$sync["ISOArchitecture"].Visibility = [System.Windows.Visibility]::Visible
} else {
$sync["ISORelease"].Visibility = [System.Windows.Visibility]::Collapsed
$sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Collapsed
$sync["ISOArchitecture"].Visibility = [System.Windows.Visibility]::Collapsed
}
# 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 }

View File

@ -340,6 +340,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="{ButtonBackgroundPressedColor}"
Fill="{ButtonBackgroundColor}"
StrokeThickness="1"
Width="14"
Height="14"
SnapsToDevicePixels="True"/>
<Ellipse x:Name="InnerCircle"
Fill="{MainForegroundColor}"
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>
@ -895,10 +936,15 @@
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"/>
<ComboBox x:Name="ISOArchitecture"/>
<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>