@@ -10,6 +10,7 @@ Namespace Flux.Greaseweazle
1010 Private WithEvents ButtonDetect As Button
1111 Private WithEvents ButtonDiscard As Button
1212 Private WithEvents ButtonImport As Button
13+ Private WithEvents ButtonPreview As Button
1314 Private WithEvents ButtonProcess As Button
1415 Private WithEvents ButtonReset As Button
1516 Private WithEvents CheckBoxDoublestep As CheckBox
@@ -279,6 +280,41 @@ Namespace Flux.Greaseweazle
279280 Return FileName & Item.Extension
280281 End Function
281282
283+ Private Sub PreviewImage()
284+ Dim ImageParams As FloppyDiskParams = ComboImageFormat.SelectedValue
285+ Dim Opt As DriveOption = ComboImageDrives.SelectedValue
286+ Dim HasOutputfile As Boolean = Not String .IsNullOrEmpty(_OutputFilePath)
287+ Dim IsFluxOutput = CheckIsFluxOutput()
288+
289+ If HasOutputfile AndAlso Not IsFluxOutput Then
290+ Dim ImageData = New ImageData(_OutputFilePath)
291+
292+ Dim Caption As String = TextBoxFileName.Text
293+
294+ If Not ImagePreview.Display(ImageData, Caption, Me ) Then
295+ MsgBox(My.Resources.Dialog_ImagePreviewFail, MsgBoxStyle.Exclamation)
296+ End If
297+ Else
298+ If ImageParams.IsNonImage OrElse Opt.Id = "" Then
299+ Exit Sub
300+ End If
301+
302+ Dim Response = ReadFirstTrack(Opt.Id, True , ImageParams)
303+
304+ If Not Response.Result Then
305+ MsgBox(My.Resources.Dialog_ImagePreviewFail, MsgBoxStyle.Exclamation)
306+ End If
307+
308+ Dim Caption As String = TextBoxFileName.Text
309+
310+ If Not ImagePreview.Display(Response.FileName, ImageParams, Caption, Me ) Then
311+ MsgBox(My.Resources.Dialog_ImagePreviewFail, MsgBoxStyle.Exclamation)
312+ End If
313+
314+ DeleteTempFileIfExists(Response.FileName)
315+ End If
316+ End Sub
317+
282318 Private Function GetOutputFilePaths() As (FilePath As String , LogFilePath As String , IsFlux As Boolean )
283319 Dim Response As (FilePath As String , LogFilePath As String , IsFlux As Boolean )
284320 Response.LogFilePath = ""
@@ -466,8 +502,16 @@ Namespace Flux.Greaseweazle
466502 .Margin = New Padding( 12 , 24 , 3 , 3 )
467503 }
468504
469- ButtonProcess = New Button With {
505+ ButtonPreview = New Button With {
470506 .Margin = New Padding( 3 , 0 , 3 , 3 ),
507+ .Text = My.Resources.Label_Preview,
508+ .MinimumSize = New Size( 75 , 0 ),
509+ .AutoSize = True ,
510+ .Anchor = AnchorStyles.Left Or AnchorStyles.Right
511+ }
512+
513+ ButtonProcess = New Button With {
514+ .Margin = New Padding( 3 , 12 , 3 , 3 ),
471515 .Text = My.Resources.Label_Write,
472516 .MinimumSize = New Size( 75 , 0 ),
473517 .AutoSize = True ,
@@ -519,6 +563,7 @@ Namespace Flux.Greaseweazle
519563 .Text = My.Resources.Label_Detect
520564 }
521565
566+ ButtonContainer.Controls.Add(ButtonPreview)
522567 ButtonContainer.Controls.Add(ButtonProcess)
523568 ButtonContainer.Controls.Add(ButtonConvert)
524569 ButtonContainer.Controls.Add(ButtonDiscard)
@@ -803,7 +848,7 @@ Namespace Flux.Greaseweazle
803848 End Sub
804849
805850 Private Function ReadImageFormat(DriveId As String ) As DiskImage.FloppyDiskFormat
806- Dim Response = ReadFirstTrack(DriveId)
851+ Dim Response = ReadFirstTrack(DriveId, False )
807852
808853 TextBoxConsole.Text = Response.Output
809854
@@ -860,6 +905,8 @@ Namespace Flux.Greaseweazle
860905
861906 ButtonCancel.Text = If (IsRunning OrElse HasOutputfile, WithoutHotkey(My.Resources.Menu_Cancel), WithoutHotkey(My.Resources.Menu_Close))
862907
908+ ButtonPreview.Enabled = IsIdle AndAlso DriveSelected AndAlso Not ImageParams.IsNonImage
909+
863910 RefreshProcessButtonState()
864911 RefreshImportButtonState()
865912 ToggleRootFolderControls()
@@ -1254,6 +1301,10 @@ Namespace Flux.Greaseweazle
12541301 FluxFolderBrowse()
12551302 End If
12561303 End Sub
1304+
1305+ Private Sub ButtonPreview_Click(sender As Object , e As EventArgs) Handles ButtonPreview.Click
1306+ PreviewImage()
1307+ End Sub
12571308# End Region
12581309 End Class
12591310End Namespace
0 commit comments