Skip to content

Commit 5525e69

Browse files
committed
Adjusted summary panel size and translations to mitigate truncated text.
Fixed some display issues when using a language other than English.
1 parent 5e344d5 commit 5525e69

File tree

10 files changed

+277
-91
lines changed

10 files changed

+277
-91
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Public Class TwoColumnToolTip
2+
Inherits ToolTip
3+
4+
Private Const PADDING As Integer = 4
5+
Private Const GAP As Integer = 8
6+
Private _CachedMaxLeftWidth As Integer = 0
7+
8+
Public Sub New()
9+
MyBase.New()
10+
Me.OwnerDraw = True
11+
AddHandler Me.Popup, AddressOf OnPopup
12+
AddHandler Me.Draw, AddressOf OnDraw
13+
End Sub
14+
15+
Private Sub OnPopup(sender As Object, e As PopupEventArgs)
16+
Dim tooltipText As String = Me.GetToolTip(e.AssociatedControl)
17+
Dim font As Font = SystemFonts.StatusFont
18+
19+
Dim lines = tooltipText.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
20+
21+
Dim maxLeftWidth = 0
22+
Dim maxRightWidth = 0
23+
Dim totalHeight = 0
24+
25+
Using g = e.AssociatedControl.CreateGraphics()
26+
For Each line In lines
27+
Dim parts = line.Split({vbTab}, 2, StringSplitOptions.None)
28+
Dim left = If(parts.Length > 0, parts(0), "")
29+
Dim right = If(parts.Length > 1, parts(1), "")
30+
Dim szLeft = TextRenderer.MeasureText(g, left, font)
31+
Dim szRight = TextRenderer.MeasureText(g, right, font)
32+
33+
maxLeftWidth = Math.Max(maxLeftWidth, szLeft.Width)
34+
maxRightWidth = Math.Max(maxRightWidth, szRight.Width)
35+
totalHeight += Math.Max(szLeft.Height, szRight.Height)
36+
Next
37+
End Using
38+
39+
e.ToolTipSize = New Size(maxLeftWidth + maxRightWidth + PADDING * 2 + GAP, totalHeight + PADDING * 2)
40+
41+
_CachedMaxLeftWidth = maxLeftWidth
42+
End Sub
43+
44+
Private Sub OnDraw(sender As Object, e As DrawToolTipEventArgs)
45+
Dim font = e.Font
46+
Dim g = e.Graphics
47+
Dim tooltipText = e.ToolTipText
48+
49+
e.Graphics.Clear(SystemColors.Window)
50+
51+
Using borderPen As New Pen(Color.Gray)
52+
g.DrawRectangle(borderPen, New Rectangle(0, 0, e.Bounds.Width - 1, e.Bounds.Height - 1))
53+
End Using
54+
55+
Dim y = PADDING
56+
57+
Dim lines = tooltipText.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
58+
59+
For Each line In lines
60+
Dim parts = line.Split({vbTab}, 2, StringSplitOptions.None)
61+
Dim left = If(parts.Length > 0, parts(0), "")
62+
Dim right = If(parts.Length > 1, parts(1), "")
63+
64+
Dim sz = TextRenderer.MeasureText(g, left, font)
65+
TextRenderer.DrawText(g, left, font, New Point(PADDING, y), SystemColors.InfoText)
66+
TextRenderer.DrawText(g, right, font, New Point(PADDING + _CachedMaxLeftWidth + GAP, y), SystemColors.InfoText)
67+
y += sz.Height
68+
Next
69+
End Sub
70+
End Class

DiskImageTool/DiskImageTool.vbproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<TargetCulture>en-US</TargetCulture>
3131
<ProductName>DiskImageTool</ProductName>
3232
<PublisherName>Digitoxin</PublisherName>
33-
<ApplicationRevision>1</ApplicationRevision>
33+
<ApplicationRevision>2</ApplicationRevision>
3434
<ApplicationVersion>2.17.0.%2a</ApplicationVersion>
3535
<UseApplicationTrust>false</UseApplicationTrust>
3636
<PublishWizardCompleted>true</PublishWizardCompleted>
@@ -133,6 +133,9 @@
133133
<Compile Include="Controls\ToolStripSpringTextBox.vb">
134134
<SubType>Component</SubType>
135135
</Compile>
136+
<Compile Include="Controls\TwoColumnTooltip.vb">
137+
<SubType>Component</SubType>
138+
</Compile>
136139
<Compile Include="DiskImage\AddFileOptions.vb" />
137140
<Compile Include="DiskImage\Modules\EnumDescriptions.vb" />
138141
<Compile Include="DiskImage\MappedFloppyImage.vb" />
@@ -604,6 +607,7 @@
604607
</EmbeddedResource>
605608
<EmbeddedResource Include="Forms\ImportFileForm.resx">
606609
<DependentUpon>ImportFileForm.vb</DependentUpon>
610+
<SubType>Designer</SubType>
607611
</EmbeddedResource>
608612
<EmbeddedResource Include="Forms\ItemScanForm.resx">
609613
<DependentUpon>ItemScanForm.vb</DependentUpon>

DiskImageTool/Forms/HexViewRawForm.vb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Public Class HexViewRawForm
1313
Private Const PADDING_ROWS As Integer = 6
1414
Private Const SECTOR_HEIGHT As Integer = 16
1515
Private Const SECTOR_WIDTH As Integer = 24
16-
Private ReadOnly _ToolTip As ToolTip
16+
Private ReadOnly _ToolTip As TwoColumnToolTip
1717
Private _AllTracks As Boolean
1818
Private _Bitstream As BitArray
1919
Private _CachedSelectedLength As Long = -1
@@ -48,7 +48,7 @@ Public Class HexViewRawForm
4848
InitializeComponent()
4949

5050
' Add any initialization after the InitializeComponent() call.
51-
_ToolTip = New ToolTip()
51+
_ToolTip = New TwoColumnToolTip()
5252
_FloppyImage = Disk.Image
5353
_SectorsPerTrack = BuildBPB(Disk.DiskFormat).SectorsPerTrack
5454
_Track = Track
@@ -1397,21 +1397,21 @@ Public Class HexViewRawForm
13971397

13981398
If SectorIndex > -1 And SectorIndex < _RegionData.Sectors.Count Then
13991399
Dim Sector = _RegionData.Sectors(SectorIndex)
1400-
TooltipText = FormatLabelPair(My.Resources.Label_SectorId, vbTab & vbTab & Sector.SectorId)
1401-
TooltipText &= Environment.NewLine & FormatLabelPair(My.Resources.Label_Size, vbTab & vbTab & vbTab & Sector.DataLength)
1400+
TooltipText = FormatLabelPair(My.Resources.Label_SectorId, vbTab & Sector.SectorId)
1401+
TooltipText &= Environment.NewLine & FormatLabelPair(My.Resources.Label_Size, vbTab & Sector.DataLength)
14021402

14031403
If Sector.Track <> _Track Then
1404-
TooltipText &= Environment.NewLine & FormatLabelPair(My.Resources.Label_Track, vbTab & vbTab & vbTab & Sector.Track)
1404+
TooltipText &= Environment.NewLine & FormatLabelPair(My.Resources.Label_Track, vbTab & Sector.Track)
14051405
End If
14061406

14071407
If Sector.Side <> _Side Then
1408-
TooltipText &= Environment.NewLine & FormatLabelPair(My.Resources.Label_Side, vbTab & vbTab & vbTab & Sector.Side)
1408+
TooltipText &= Environment.NewLine & FormatLabelPair(My.Resources.Label_Side, vbTab & Sector.Side)
14091409
End If
14101410

14111411
TooltipText &= Environment.NewLine & FormatLabelPair(My.Resources.Bitstream_AddressChecksum, vbTab & If(Sector.IDAMChecksumValid, My.Resources.Label_Valid, My.Resources.Label_Invalid))
14121412

14131413
If Sector.HasData Then
1414-
TooltipText &= Environment.NewLine & FormatLabelPair(My.Resources.Bitstream_DataChecksum, vbTab & vbTab & If(Sector.DataChecksumValid, My.Resources.Label_Valid, My.Resources.Label_Invalid))
1414+
TooltipText &= Environment.NewLine & FormatLabelPair(My.Resources.Bitstream_DataChecksum, vbTab & If(Sector.DataChecksumValid, My.Resources.Label_Valid, My.Resources.Label_Invalid))
14151415
End If
14161416

14171417
Dim DAMText As String

DiskImageTool/MainForm.Designer.vb

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

0 commit comments

Comments
 (0)