@@ -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
0 commit comments