Skip to content

Commit 94178b0

Browse files
committed
Files can now be viewed using a double click
Improvements to bitstream hex viewer
1 parent baeae0e commit 94178b0

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

DiskImageTool/Bitstream/IBM_MFM/IBM_MFM_Tools.vb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
Dim Aligned As Boolean
4949
Dim Gap4A As UShort
5050
Dim Gap1 As UShort
51+
Dim Encoding As String
5152
End Structure
5253

5354
Module IBM_MFM_Tools
@@ -230,6 +231,13 @@
230231
RegionData.Aligned = True
231232
RegionData.Gap4A = 0
232233
RegionData.Gap1 = 0
234+
If TrackType = BitstreamTrackType.MFM Then
235+
RegionData.Encoding = "MFM"
236+
ElseIf TrackType = BitstreamTrackType.FM Then
237+
RegionData.Encoding = "FM"
238+
Else
239+
RegionData.Encoding = ""
240+
End If
233241

234242
Dim Pattern As BitArray
235243
If TrackType = BitstreamTrackType.MFM Then

DiskImageTool/Forms/HexViewRawForm.vb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Public Class HexViewRawForm
3030
Private _LabelBitOffsetAligned As ToolStripLabel
3131
Private _LabelGap4A As ToolStripLabel
3232
Private _LabelGap1 As ToolStripLabel
33+
Private _labelEncoding As ToolStripLabel
3334
Private _LastSearch As HexSearch
3435
Private _RegionData As RegionData
3536
Private _RegionMap() As BitstreamRegion
@@ -516,18 +517,24 @@ Public Class HexViewRawForm
516517
End Sub
517518

518519
Private Sub InitializeToolstripLabels()
520+
_labelEncoding = New ToolStripLabel("") With {
521+
.Alignment = ToolStripItemAlignment.Right,
522+
.Padding = New Padding(10, 0, 0, 0)
523+
}
524+
519525
_LabelGap4A = New ToolStripLabel("Gap 4A: 0") With {
520526
.Alignment = ToolStripItemAlignment.Right,
521-
.Padding = New Padding(12, 0, 0, 0)
527+
.Padding = New Padding(10, 0, 0, 0)
522528
}
523529

524530
_LabelGap1 = New ToolStripLabel("Gap 1: 0") With {
525531
.Alignment = ToolStripItemAlignment.Right,
526-
.Padding = New Padding(12, 0, 0, 0)
532+
.Padding = New Padding(10, 0, 0, 0)
527533
}
528534

529535
ToolStripMain.Items.Add(_LabelGap1)
530536
ToolStripMain.Items.Add(_LabelGap4A)
537+
ToolStripMain.Items.Add(_labelEncoding)
531538
End Sub
532539

533540
Private Sub InitializeTrackNavigator()
@@ -626,6 +633,10 @@ Public Class HexViewRawForm
626633

627634
_LabelGap4A.Text = "Gap 4A: " & RegionData.Gap4A
628635
_LabelGap1.Text = "Gap 1: " & RegionData.Gap1
636+
_labelEncoding.Text = "Encoding: " & RegionData.Encoding
637+
_labelEncoding.Visible = RegionData.Encoding.Length > 0
638+
_LabelGap4A.Visible = RegionData.Encoding = "MFM"
639+
_LabelGap1.Visible = RegionData.Encoding = "MFM"
629640

630641
RefreshSize()
631642
InitRegionMap()

DiskImageTool/MainForm.vb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,6 +2461,21 @@ Public Class MainForm
24612461
End If
24622462
End Sub
24632463

2464+
Private Function IsBinaryData(data As Byte()) As Boolean
2465+
Dim allowedControlChars As Byte() = {7, 9, 10, 13, 26}
2466+
Dim maxBytesToCheck As Integer = Math.Min(4096, data.Length)
2467+
2468+
For i As Integer = 0 To maxBytesToCheck - 1
2469+
Dim b As Byte = data(i)
2470+
2471+
If (b < 32 AndAlso Not allowedControlChars.Contains(b)) OrElse b = 0 Then
2472+
Return True
2473+
End If
2474+
Next
2475+
2476+
Return False
2477+
End Function
2478+
24642479
Private Sub ItemFiltersRemove(ImageData As ImageData)
24652480
ImageFiltersScan(Nothing, ImageData, True)
24662481
End Sub
@@ -4185,6 +4200,23 @@ Public Class MainForm
41854200
e.Cancel = True
41864201
End Sub
41874202

4203+
Private Sub ListViewFiles_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles ListViewFiles.MouseDoubleClick
4204+
If e.Button = MouseButtons.Left Then
4205+
If ListViewFiles.SelectedItems.Count = 1 Then
4206+
Dim FileData As FileData = ListViewFiles.SelectedItems(0).Tag
4207+
If FileData IsNot Nothing Then
4208+
If FileData.DirectoryEntry.IsValidFile And FileData.DirectoryEntry.FileSize > 0 Then
4209+
If IsBinaryData(FileData.DirectoryEntry.GetContent) Then
4210+
HexDisplayDirectoryEntry(_CurrentImage, FileData.DirectoryEntry)
4211+
Else
4212+
DirectoryEntryDisplayText(FileData.DirectoryEntry)
4213+
End If
4214+
End If
4215+
End If
4216+
End If
4217+
End If
4218+
End Sub
4219+
41884220
Private Sub ListViewFiles_DrawColumnHeader(sender As Object, e As DrawListViewColumnHeaderEventArgs) Handles ListViewFiles.DrawColumnHeader
41894221
If e.ColumnIndex = 0 Then
41904222
'Dim Offset As Integer

0 commit comments

Comments
 (0)