Skip to content

Commit b12ad70

Browse files
committed
Track grid tool tips now display header info from .raw files.
1 parent bd9d5da commit b12ad70

File tree

15 files changed

+383
-120
lines changed

15 files changed

+383
-120
lines changed

DiskImageTool/Controls/FloppyTrackGrid.vb

Lines changed: 147 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Public Class FloppyTrackGrid
2121
Private ReadOnly _ToolTip As ToolTip
2222
Private _ActiveTrackCount As Integer
2323
Private _Cells As List(Of CellInfo)
24-
2524
Private _Disabled As Boolean = False
2625
Private _FocusedTrack As Integer = -1
2726
Private _FooterCheckRect As Rectangle
@@ -60,8 +59,8 @@ Public Class FloppyTrackGrid
6059
Me.New()
6160

6261
_ActiveTrackCount = TrackCount
63-
Me.TrackCount = TrackCount
6462
Me.Side = Side
63+
Me.TrackCount = TrackCount
6564
End Sub
6665

6766
<Browsable(True)>
@@ -340,6 +339,18 @@ Public Class FloppyTrackGrid
340339
SetCell(TrackIndex, BackColor:=BackColor)
341340
End Sub
342341

342+
Public Sub SetCellFluxHeader(TrackIndex As Integer, Name As String, Version As String, HostDate As String, HostTime As String)
343+
If TrackIndex < 0 OrElse TrackIndex >= _TrackCount Then
344+
Throw New ArgumentOutOfRangeException(NameOf(TrackIndex))
345+
End If
346+
347+
Dim Cell = _Cells(TrackIndex)
348+
349+
Cell.SetFluxHeader(Name, Version, HostDate, HostTime)
350+
351+
_Cells(TrackIndex) = Cell
352+
End Sub
353+
343354
Public Sub SetCellSelected(TrackIndex As Integer, Selected As Boolean, Optional NoEvent As Boolean = False)
344355
If NoEvent Then
345356
_NoEventSelectionChanged = True
@@ -418,6 +429,7 @@ Public Class FloppyTrackGrid
418429

419430
Invalidate()
420431
End Sub
432+
421433
Protected Overrides Function IsInputKey(keyData As Keys) As Boolean
422434
Dim key = keyData And Keys.KeyCode
423435

@@ -688,8 +700,9 @@ Public Class FloppyTrackGrid
688700
Dim rect = GetCellRectangle(TrackIndex)
689701
Dim cell As CellInfo
690702
If TrackIndex >= _ActiveTrackCount Then
691-
cell = CreateDefaultCell()
692-
cell.BackColor = DISABLED_COLOR
703+
cell = New CellInfo(TrackIndex) With {
704+
.BackColor = DISABLED_COLOR
705+
}
693706
Else
694707
cell = _Cells(TrackIndex)
695708
End If
@@ -759,16 +772,6 @@ Public Class FloppyTrackGrid
759772
_LastSelected = (-1, False)
760773
End Sub
761774

762-
Private Function CreateDefaultCell() As CellInfo
763-
Dim c As New CellInfo With {
764-
.BackColor = DEFAULT_BACKCOLOR,
765-
.ForeColor = DEFAULT_FORECOLOR,
766-
.Text = String.Empty,
767-
.Selected = False
768-
}
769-
Return c
770-
End Function
771-
772775
Private Sub DrawFooter(g As Graphics)
773776
Dim rows = RowCount
774777
Dim totalCols As Integer = COLUMNS + 1
@@ -916,17 +919,26 @@ Public Class FloppyTrackGrid
916919

917920
Private Sub FloppyTrackGrid_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
918921
Dim TooltipText As String = ""
919-
920-
Dim Response = HitTestCell(e.Location)
921-
If Response.Result Then
922-
TooltipText = _Cells(Response.TrackIndex).Tooltip
923-
If TooltipText = "" Then
924-
TooltipText = My.Resources.Label_Track & ": " & Response.TrackIndex.ToString & "." & _Side.ToString
922+
Dim TooltipTitle As String = ""
923+
924+
If Not _Disabled Then
925+
Dim Response = HitTestCell(e.Location)
926+
If Response.Result Then
927+
Dim Cell = _Cells(Response.TrackIndex)
928+
TooltipTitle = GetToolTipTitle(Response.TrackIndex)
929+
TooltipText = Cell.FullTooltip
930+
If String.IsNullOrEmpty(TooltipText) Then
931+
TooltipText = TooltipTitle
932+
TooltipTitle = ""
933+
End If
925934
End If
935+
End If
926936

937+
If TooltipTitle <> _ToolTip.ToolTipTitle Then
938+
_ToolTip.ToolTipTitle = TooltipTitle
927939
End If
928940

929-
If TooltipText <> _ToolTip.GetToolTip(Me) Then
941+
If TooltipText <> _ToolTip.GetToolTip(Me) Then
930942
_ToolTip.SetToolTip(Me, TooltipText)
931943
End If
932944
End Sub
@@ -942,6 +954,9 @@ Public Class FloppyTrackGrid
942954
Return New Rectangle(x, y, CELL_WIDTH, CELL_HEIGHT)
943955
End Function
944956

957+
Private Function GetToolTipTitle(Track As Integer) As String
958+
Return My.Resources.Label_Track & " " & Track.ToString & "." & _Side.ToString
959+
End Function
945960
Private Function HitTestCell(p As Point) As (Result As Boolean, TrackIndex As Integer, Row As Integer, Col As Integer)
946961
Dim Response As (Result As Boolean, TrackIndex As Integer, Row As Integer, Col As Integer)
947962

@@ -988,7 +1003,7 @@ Public Class FloppyTrackGrid
9881003
End Sub
9891004

9901005
Private Sub ResetCellInternal(trackIndex As Integer)
991-
SetCell(trackIndex, Text:="", BackColor:=DEFAULT_BACKCOLOR, ForeColor:=DEFAULT_FORECOLOR)
1006+
SetCell(trackIndex, Text:="", BackColor:=DEFAULT_BACKCOLOR, ForeColor:=DEFAULT_FORECOLOR, Tooltip:="")
9921007
End Sub
9931008
Private Sub ResizeCellList(NewCount As Integer)
9941009
If _Cells Is Nothing Then
@@ -998,7 +1013,7 @@ Public Class FloppyTrackGrid
9981013
' Grow: add default cells
9991014
If NewCount > _Cells.Count Then
10001015
For i = _Cells.Count To NewCount - 1
1001-
_Cells.Add(CreateDefaultCell())
1016+
_Cells.Add(New CellInfo(i))
10021017
Next
10031018
ElseIf NewCount < _Cells.Count Then
10041019
' Shrink: remove extra cells
@@ -1042,11 +1057,119 @@ Public Class FloppyTrackGrid
10421057
End Sub
10431058
'=== Per-cell state ===
10441059
Public Structure CellInfo
1060+
Public ReadOnly Track As UShort
10451061
Public BackColor As Color
10461062
Public ForeColor As Color
10471063
Public Selected As Boolean
10481064
Public Text As String
1049-
Public Tooltip As String
1065+
Private _FluxHostDate As String
1066+
Private _FluxHostTime As String
1067+
Private _FluxName As String
1068+
Private _FluxVersion As String
1069+
Private _FullTooltip As String
1070+
Private _Tooltip As String
1071+
1072+
Public Sub New(Track As UShort)
1073+
Me.Track = Track
1074+
Me.BackColor = DEFAULT_BACKCOLOR
1075+
Me.ForeColor = DEFAULT_FORECOLOR
1076+
Me.Text = String.Empty
1077+
Me.Selected = False
1078+
_Tooltip = String.Empty
1079+
_FluxName = String.Empty
1080+
_FluxVersion = String.Empty
1081+
_FluxHostDate = String.Empty
1082+
_FluxHostTime = String.Empty
1083+
_FullTooltip = GetFullTooltip()
1084+
End Sub
1085+
1086+
Public ReadOnly Property FluxHostDate As String
1087+
Get
1088+
Return _FluxHostDate
1089+
End Get
1090+
End Property
1091+
1092+
Public ReadOnly Property FluxHostTime As String
1093+
Get
1094+
Return _FluxHostTime
1095+
End Get
1096+
End Property
1097+
1098+
Public ReadOnly Property FluxName As String
1099+
Get
1100+
Return _FluxName
1101+
End Get
1102+
End Property
1103+
1104+
Public ReadOnly Property FluxVersion As String
1105+
Get
1106+
Return _FluxVersion
1107+
End Get
1108+
End Property
1109+
1110+
Public ReadOnly Property FullTooltip As String
1111+
Get
1112+
Return _FullTooltip
1113+
End Get
1114+
End Property
1115+
1116+
Public Property Tooltip As String
1117+
Get
1118+
Return _Tooltip
1119+
End Get
1120+
Set(value As String)
1121+
If _Tooltip <> value Then
1122+
_Tooltip = value
1123+
_FullTooltip = GetFullTooltip()
1124+
End If
1125+
End Set
1126+
End Property
1127+
1128+
Public Sub SetFluxHeader(Name As String, Version As String, HostDate As String, HostTime As String)
1129+
_FluxName = Name
1130+
_FluxVersion = Version
1131+
_FluxHostDate = HostDate
1132+
_FluxHostTime = HostTime
1133+
1134+
_FullTooltip = GetFullTooltip()
1135+
End Sub
1136+
1137+
Private Function GetFluxInfo() As String
1138+
Dim FluxInfo As String = ""
1139+
1140+
If Not String.IsNullOrEmpty(_FluxName) Then
1141+
FluxInfo = _FluxName
1142+
If Not String.IsNullOrEmpty(_FluxVersion) Then
1143+
FluxInfo &= " v" & _FluxVersion
1144+
End If
1145+
End If
1146+
1147+
If Not String.IsNullOrEmpty(_FluxHostDate) Then
1148+
If Not String.IsNullOrEmpty(FluxInfo) Then
1149+
FluxInfo &= vbNewLine
1150+
End If
1151+
FluxInfo &= _FluxHostDate
1152+
If Not String.IsNullOrEmpty(_FluxHostTime) Then
1153+
FluxInfo &= " " & _FluxHostTime
1154+
End If
1155+
End If
1156+
1157+
Return FluxInfo
1158+
End Function
1159+
1160+
Private Function GetFullTooltip() As String
1161+
Dim TooltipText = GetFluxInfo()
1162+
1163+
If Not String.IsNullOrWhiteSpace(_Tooltip) Then
1164+
If Not String.IsNullOrEmpty(TooltipText) Then
1165+
TooltipText &= vbNewLine
1166+
End If
1167+
1168+
TooltipText &= _Tooltip
1169+
End If
1170+
1171+
Return TooltipText
1172+
End Function
10501173
End Structure
10511174

10521175
Public Structure TrackState

DiskImageTool/DiskImageTool.vbproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<ProductName>DiskImageTool</ProductName>
3232
<PublisherName>Digitoxin</PublisherName>
3333
<ApplicationRevision>0</ApplicationRevision>
34-
<ApplicationVersion>2.31.0.%2a</ApplicationVersion>
34+
<ApplicationVersion>2.32.0.%2a</ApplicationVersion>
3535
<UseApplicationTrust>false</UseApplicationTrust>
3636
<PublishWizardCompleted>true</PublishWizardCompleted>
3737
<BootstrapperEnabled>true</BootstrapperEnabled>
@@ -150,9 +150,6 @@
150150
<Compile Include="Controls\ListViewEx.vb">
151151
<SubType>Component</SubType>
152152
</Compile>
153-
<Compile Include="Controls\ReadOnlyCheckbox.vb">
154-
<SubType>Component</SubType>
155-
</Compile>
156153
<Compile Include="Controls\SelectablePanel.vb">
157154
<SubType>Component</SubType>
158155
</Compile>

DiskImageTool/Flux/Forms/BaseFluxForm.Designer.vb

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DiskImageTool/Flux/Forms/BaseFluxForm.vb

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Private WithEvents TS0 As FloppyTrackGrid
66
Private WithEvents TS1 As FloppyTrackGrid
77
Private Const TOTAL_TRACKS As UShort = 84
8+
Private _FluxHeaders As Dictionary(Of TrackSide, Dictionary(Of String, String))
89
Private _LogFileName As String = ""
910
Private _LogStripPath As Boolean = False
1011
Private _Sides As Byte
@@ -132,15 +133,20 @@
132133
End Function
133134

134135
Public Sub GridReset()
135-
GridReset(_Tracks, _Sides)
136+
GridReset(_Tracks, _Sides, _FluxHeaders)
136137
End Sub
137138

138-
Public Sub GridReset(Tracks As UShort, Sides As Byte, Optional ResetSelected As Boolean = True)
139+
Friend Sub GridReset(Tracks As UShort, Sides As Byte, Optional FluxHeaders As Dictionary(Of TrackSide, Dictionary(Of String, String)) = Nothing, Optional ResetSelected As Boolean = True)
139140
_Tracks = Tracks
140141
_Sides = Sides
141142

142143
GridResetTracks(TS0, Tracks, False, ResetSelected)
143144
GridResetTracks(TS1, Tracks, Sides < 2, ResetSelected)
145+
146+
If _FluxHeaders IsNot FluxHeaders Then
147+
_FluxHeaders = FluxHeaders
148+
GridUpdateFluxHeaders()
149+
End If
144150
End Sub
145151

146152
Public Overridable Sub SaveLog(RemovePath As Boolean, Optional InitialDirectory As String = "")
@@ -252,6 +258,32 @@
252258
Table?.SetCellTooltip(Track, Tooltip)
253259
End Sub
254260

261+
Private Sub GridUpdateFluxHeaders()
262+
For Track = 0 To _Tracks - 1
263+
For Side = 0 To _Sides - 1
264+
Dim Table = GridGetTable(Side)
265+
266+
If Table IsNot Nothing Then
267+
Dim Name As String = ""
268+
Dim Version As String = ""
269+
Dim HostDate As String = ""
270+
Dim HostTime As String = ""
271+
If _FluxHeaders IsNot Nothing Then
272+
Dim Headers As Dictionary(Of String, String) = Nothing
273+
_FluxHeaders.TryGetValue(New TrackSide(Track, Side), Headers)
274+
If Headers IsNot Nothing Then
275+
Headers.TryGetValue("name", Name)
276+
Headers.TryGetValue("version", Version)
277+
Headers.TryGetValue("host_date", HostDate)
278+
Headers.TryGetValue("host_time", HostTime)
279+
End If
280+
End If
281+
Table.SetCellFluxHeader(Track, Name, Version, HostDate, HostTime)
282+
End If
283+
Next
284+
Next
285+
End Sub
286+
255287
Private Sub LocalizeForm()
256288
ButtonCancel.Text = My.Resources.Menu_Cancel
257289
ButtonSaveLog.Text = My.Resources.Label_SaveLog

0 commit comments

Comments
 (0)