Choosing Alternate Scartch Path and Busy Messages

* Choosing Alternate Scartch Path and Busy Messages

* Change Selected index to be pro
This commit is contained in:
LeeDowA 2024-02-01 21:04:17 -02:00 committed by GitHub
parent 1d35d06c84
commit 26e117c5bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 90 additions and 1 deletions

View File

@ -0,0 +1,30 @@
function Invoke-ScratchDialog {
<#
.SYNOPSIS
Enable Editable Text box Alternate Scartch path
.PARAMETER Button
#>
$sync.WPFMicrowinISOScratchDir.IsChecked
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$Dialog = New-Object System.Windows.Forms.FolderBrowserDialog
$Dialog.SelectedPath = $sync.MicrowinScratchDirBox.Text
$DialogShowNewFolderButton = $true
$Dialog.ShowDialog()
$filePath = $Dialog.SelectedPath
Write-Host "No ISO is chosen+ $filePath"
if ([string]::IsNullOrEmpty($filePath))
{
Write-Host "No Folder had chosen"
return
}
$sync.MicrowinScratchDirBox.Text = Join-Path $filePath "\"
}

View File

@ -52,5 +52,6 @@ function Invoke-WPFButton {
"WPFGetIso" {Invoke-WPFGetIso}
"WPFMicrowin" {Invoke-WPFMicrowin}
"WPFCloseButton" {Invoke-WPFCloseButton}
"MicrowinScratchDirBT" {Invoke-ScratchDialog}
}
}

View File

@ -12,6 +12,10 @@ function Invoke-WPFGetIso {
return
}
$sync.BusyMessage.Visibility="Visible"
$sync.BusyText.Text="N Busy"
Write-Host " _ __ __ _ "
Write-Host " /\/\ (_) ___ _ __ ___ / / /\ \ \(_) _ __ "
Write-Host " / \ | | / __|| '__| / _ \ \ \/ \/ /| || '_ \ "
@ -19,12 +23,17 @@ function Invoke-WPFGetIso {
Write-Host "\/ \/|_| \___||_| \___/ \/ \/ |_||_| |_| "
$oscdimgPath = Join-Path $env:TEMP 'oscdimg.exe'
if( ! (Test-Path $oscdimgPath -PathType Leaf) ) {
$oscdimgPath = Join-Path '.\releases\' 'oscdimg.exe'
}
$oscdImgFound = [bool] (Get-Command -ErrorAction Ignore -Type Application oscdimg.exe) -or (Test-Path $oscdimgPath -PathType Leaf)
Write-Host "oscdimg.exe on system: $oscdImgFound"
if (!$oscdImgFound)
{
$downloadFromGitHub = $sync.WPFMicrowinDownloadFromGitHub.IsChecked
$sync.BusyMessage.Visibility="Hidden"
if (!$downloadFromGitHub)
{
@ -69,6 +78,7 @@ function Invoke-WPFGetIso {
if ([string]::IsNullOrEmpty($filePath))
{
Write-Host "No ISO is chosen"
$sync.BusyMessage.Visibility="Hidden"
return
}
@ -97,13 +107,38 @@ function Invoke-WPFGetIso {
# there is probably a better way of doing this, I don't have time to figure this out
$sync.MicrowinIsoDrive.Text = $driveLetter
$mountedISOPath = (Split-Path -Path $filePath)
if ($sync.MicrowinScratchDirBox.Text.Trim() -eq "Scratch") {
$sync.MicrowinScratchDirBox.Text =""
}
$UseISOScratchDir = $sync.WPFMicrowinISOScratchDir.IsChecked
if ($UseISOScratchDir) {
$sync.MicrowinScratchDirBox.Text=$mountedISOPath
}
if( -Not $sync.MicrowinScratchDirBox.Text.EndsWith('\') -And $sync.MicrowinScratchDirBox.Text.Length -gt 1) {
$sync.MicrowinScratchDirBox.Text = Join-Path $sync.MicrowinScratchDirBox.Text.Trim() '\'
}
Write-Host "Setting up mount dir and scratch dirs"
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$randomNumber = Get-Random -Minimum 1 -Maximum 9999
$randomMicrowin = "Microwin_${timestamp}_${randomNumber}"
$randomMicrowinScratch = "MicrowinScratch_${timestamp}_${randomNumber}"
$sync.BusyText.Text=" - Mounting"
Write-Host "Mounting Iso. Please wait."
if ($sync.MicrowinScratchDirBox.Text -eq "") {
$mountDir = Join-Path $env:TEMP $randomMicrowin
$scratchDir = Join-Path $env:TEMP $randomMicrowinScratch
} else {
$scratchDir = $sync.MicrowinScratchDirBox.Text+"Scrach"
$mountDir = $sync.MicrowinScratchDirBox.Text+"micro"
}
$sync.MicrowinMountDir.Text = $mountDir
$sync.MicrowinScratchDir.Text = $scratchDir
Write-Host "Done setting up mount dir and scratch dirs"
@ -138,7 +173,7 @@ function Invoke-WPFGetIso {
$imageName = $_.ImageName
$sync.MicrowinWindowsFlavors.Items.Add("$imageIdx : $imageName")
}
$sync.MicrowinWindowsFlavors.SelectedIndex = 0
$sync.MicrowinWindowsFlavors.SelectedIndex = 5
Get-Volume $driveLetter | Get-DiskImage | Dismount-DiskImage
Write-Host "Selected value '$($sync.MicrowinWindowsFlavors.SelectedValue)'....."
@ -155,6 +190,7 @@ function Invoke-WPFGetIso {
Write-Host "*********************************"
Write-Host "Check the UI for further steps!!!"
$sync.BusyMessage.Visibility="Hidden"
$sync.ProcessRunning = $false
}

View File

@ -792,6 +792,22 @@
Choose a Windows ISO file that you've downloaded <LineBreak/>
Check the status in the console
</TextBlock>
<CheckBox x:Name="WPFMicrowinISOScratchDir" Content="Use ISO directory for ScratchDir " IsChecked="False" Margin="1"
ToolTip="Use ISO directory for ScratchDir " />
<Button Name="MicrowinScratchDirBT" Margin="2" Padding="1">
<Button.Content>
<TextBox Name="MicrowinScratchDirBox" Background="Transparent" BorderBrush="{MainForegroundColor}"
Text="Scratch" Padding="0"
ToolTip="Alt Path For Scratch Directory" BorderThickness="1"
Margin="0,0,0,3" HorizontalAlignment="Left"
IsReadOnly="False"
Height="Auto"
Width="110"
Foreground="{ButtonForegroundColor}"
/>
</Button.Content>
</Button>
<TextBox Name="MicrowinFinalIsoLocation" Background="Transparent" BorderBrush="{MainForegroundColor}"
Text="ISO location will be printed here"
Margin="2"
@ -845,6 +861,12 @@
Grid.Row="0" Grid.Column="1">
<StackPanel HorizontalAlignment="Left" Background="{MainBackgroundColor}" SnapsToDevicePixels="True" Visibility="Visible">
<Grid Name = "BusyMessage" Visibility="Collapsed">
<TextBlock Name = "BusyText" Text="NBusy" Padding="22,2,1,1" />
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" FontFamily="Segoe MDL2 Assets"
FontSize="14" Margin="16,0,0,0">&#xE701;</TextBlock>
</Grid>
<TextBlock x:Name = "asciiTextBlock"
xml:space ="preserve"
HorizontalAlignment = "Center"