Skip to content

Commit 80c0165

Browse files
committed
Added Image Preview when reading a disk
1 parent 2d9daa4 commit 80c0165

File tree

6 files changed

+71
-10
lines changed

6 files changed

+71
-10
lines changed

DiskImageTool/DiskImageTool.vbproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
<TargetCulture>en-US</TargetCulture>
3131
<ProductName>DiskImageTool</ProductName>
3232
<PublisherName>Digitoxin</PublisherName>
33-
<ApplicationRevision>3</ApplicationRevision>
34-
<ApplicationVersion>2.30.0.%2a</ApplicationVersion>
33+
<ApplicationRevision>0</ApplicationRevision>
34+
<ApplicationVersion>2.31.0.%2a</ApplicationVersion>
3535
<UseApplicationTrust>false</UseApplicationTrust>
3636
<PublishWizardCompleted>true</PublishWizardCompleted>
3737
<BootstrapperEnabled>true</BootstrapperEnabled>

DiskImageTool/Flux/Forms/ConvertImageForm.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Namespace Flux
9191
Return TextBoxFileName.Text & Extension
9292
End Function
9393

94-
Public Sub PreviewImage()
94+
Private Sub PreviewImage()
9595
If _SelectedDevice Is Nothing Then
9696
Exit Sub
9797
End If

DiskImageTool/Flux/Greaseweazle/Forms/ReadDiskForm.vb

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
12591310
End Namespace

DiskImageTool/Flux/Greaseweazle/GreaseweazleLib.vb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Namespace Flux.Greaseweazle
303303
End With
304304
End Sub
305305

306-
Public Function ReadFirstTrack(DriveId As String) As (Result As Boolean, FileName As String, Output As String)
306+
Public Function ReadFirstTrack(DriveId As String, BothSides As Boolean, Optional ImageParams As FloppyDiskParams? = Nothing) As (Result As Boolean, FileName As String, Output As String)
307307
Dim TempPath = InitTempImagePath()
308308

309309
If TempPath = "" Then
@@ -312,12 +312,19 @@ Namespace Flux.Greaseweazle
312312

313313
Dim FileName = GenerateUniqueFileName(TempPath, "temp.ima")
314314

315+
Dim Format As String = "ibm.scan"
316+
317+
If ImageParams.HasValue Then
318+
Dim ImageFormat = GreaseweazleImageFormatFromFloppyDiskFormat(ImageParams.Value.Format)
319+
Format = GreaseweazleImageFormatCommandLine(ImageFormat)
320+
End If
321+
315322
Dim Builder As New CommandLineBuilder(CommandLineBuilder.CommandAction.read) With {
316323
.Device = Settings.ComPort,
317324
.Drive = DriveId,
318325
.File = FileName,
319-
.Format = "ibm.scan",
320-
.Heads = TrackHeads.head0
326+
.Format = Format,
327+
.Heads = If(BothSides, TrackHeads.both, TrackHeads.head0)
321328
}
322329
Builder.AddCylinder(0)
323330

DiskImageTool/Forms/ImagePreview.vb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
_SummaryPanel = New SummaryPanel(ListViewSummary)
1313
FilePanelMain = New FilePanel(ListViewFiles, True, FullDisplay)
1414

15-
Me.Text = My.Resources.Label_ImagePreview & " - " & Caption
15+
Me.Text = My.Resources.Label_ImagePreview
16+
If Not String.IsNullOrEmpty(Caption) Then
17+
Me.Text &= " - " & Caption
18+
End If
1619

1720
Dim CurrentImage = New DiskImageContainer(_Disk, New ImageData(""))
1821

DiskImageTool/My Project/AssemblyInfo.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ Imports System.Runtime.InteropServices
3131
' <Assembly: AssemblyVersion("1.0.*")>
3232

3333
<Assembly: AssemblyVersion("1.0.0.0")>
34-
<Assembly: AssemblyFileVersion("2.30.0.3")>
34+
<Assembly: AssemblyFileVersion("2.31.0.0")>

0 commit comments

Comments
 (0)