diff --git a/functions/public/Invoke-ScratchDialog.ps1 b/functions/public/Invoke-ScratchDialog.ps1 new file mode 100644 index 00000000..46eb82e0 --- /dev/null +++ b/functions/public/Invoke-ScratchDialog.ps1 @@ -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 "\" + +} diff --git a/functions/public/Invoke-WPFButton.ps1 b/functions/public/Invoke-WPFButton.ps1 index 1460a6be..0d87069f 100644 --- a/functions/public/Invoke-WPFButton.ps1 +++ b/functions/public/Invoke-WPFButton.ps1 @@ -52,5 +52,6 @@ function Invoke-WPFButton { "WPFGetIso" {Invoke-WPFGetIso} "WPFMicrowin" {Invoke-WPFMicrowin} "WPFCloseButton" {Invoke-WPFCloseButton} + "MicrowinScratchDirBT" {Invoke-ScratchDialog} } } \ No newline at end of file diff --git a/functions/public/Invoke-WPFGetIso.ps1 b/functions/public/Invoke-WPFGetIso.ps1 index dfa5038c..570cad74 100644 --- a/functions/public/Invoke-WPFGetIso.ps1 +++ b/functions/public/Invoke-WPFGetIso.ps1 @@ -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 } diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml index 91e3338a..2b99468e 100644 --- a/xaml/inputXML.xaml +++ b/xaml/inputXML.xaml @@ -792,6 +792,22 @@ Choose a Windows ISO file that you've downloaded Check the status in the console + + + + + + + +