I currently have a GUi that works with a zip file, that contains a few thousand .zip files of .csv data
My script currently works correctly, but im looking to add a gif that is displayed while the job is running.
When the job is running the gif will freeze, and the only way i have found (by googling) is to display the gif file in a seperate runspace, seen in the code below.
However the GIF is displayed all the time, and im looking to have the gif closed after the job has completed.
If possible, I would like all controls added to the single form so the manipulation of the images can be controlled.
I have spent a few days looking into this, but i am no further forward, If anyone here can help please
$YEETpictureBox.FlatStyle
$YEETpictureBox.Visible = $true
$YEETpictureBox.add_MouseHover($ShowHelp)
$YEETpictureBox.add_Click({
$saveGAZ = Save-Gaz
$ButtonType = [System.Windows.MessageBoxButton]::YesNo
$MessageIcon = [System.Windows.MessageBoxImage]::Question
$MessageBody = "Are you sure you want to extract all files`n`nFrom: $Script:Gazfile`n`nTo: $($saveGAZ)"
$MessageTitle = "Selected Connections"
$Result = [System.Windows.Forms.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
switch ($Result)
{
'Yes' {
# Create runspace
$runspace = [RunspaceFactory]::CreateRunspace()
$runspace.Open()
# Add script and run asynchronously
$runspace.CreatePipeline{
Add-Type -AssemblyName System.Windows.Forms
$image = [Drawing.Bitmap]"C:path2filespaceman.gif"
$pictureBox = [Windows.Forms.PictureBox]@{
Dock = "Fill"
Image = $image
Size = '99,97'
}
$form = [Windows.Forms.Form]@{
Size = '99,95'
FormBorderStyle = "None"
Owner = $ApplicationForm
StartPosition = 'CenterParent'
}
$form.Controls.Add($pictureBox)
$form.ShowDialog()
}.InvokeAsync()
start-job -Name "Gaz Extraction" -ScriptBlock{
ShowBalloonTipInfo -Text "Gazetteer Extraction Started..." -Title "Gazetteer" -Icon None
Expand-Archive $using:Script:Gazfile -DestinationPath C:programdataArchiveDetectiveGazTEMP -ErrorAction Stop -Force
Get-ChildItem -Path "C:programdataArchiveDetectiveGazTEMP" -Recurse | ForEach-Object {
Expand-Archive -Path $_.FullName -DestinationPath (-join $using:saveGAZ + "CSV") -Force
Remove-item $_.FullName
}
} -InitializationScript $initscript
$YEETpictureBox.Visible = $false
ShowBalloonTipInfo -Text "Gazetteer Extraction Completed`n`n$($saveGAZ)" -Title "Gazetteer" -Icon None
}
}
})
$ApplicationForm.Controls.Add($YEETpictureBox)