-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataSRT.cs
150 lines (130 loc) · 7.93 KB
/
DataSRT.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using System.Text;
using System.Windows.Forms;
namespace GMExplorer {
class DataSRT : Data {
/// <summary>
/// Knoten für eine logische oder physische Datei anhängen
/// </summary>
/// <param name="tn"></param>
/// <param name="tre">wenn null, wird das Objekt erzeugt</param>
/// <param name="binreader"></param>
public static void AppendChildNodes(TreeNode tn, GarminCore.Files.StdFile_SRT srt, GarminCore.BinaryReaderWriter binreader) {
DeleteDummyChildNode(tn);
AppendNode(AppendNode(tn, NodeContent.NodeType.GarminCommonHeader, srt, "Garmin Common Header"));
AppendNode(AppendNode(tn, NodeContent.NodeType.GarminSpecialHeader, srt, "Garmin SRT-Header"));
if (srt.ContentsBlock.Length > 0)
AppendNode(tn, NodeContent.NodeType.SRT_ContentsBlock, srt, "ContentsBlock");
if (srt.DescriptionBlock.Length > 0)
AppendNode(tn, NodeContent.NodeType.SRT_DescriptionBlock, srt, "DescriptionBlock");
if (srt.CharacterLookupTableBlock.Length > 0)
AppendNode(AppendNode(tn, NodeContent.NodeType.SRT_CharacterLookupTableBlock, srt, "CharacterLookupTableBlock"));
}
/// <summary>
/// Knoten für eine Section anhängen
/// </summary>
/// <param name="tn"></param>
/// <param name="tre"></param>
/// <param name="nodetype"></param>
public static void AppendChildNodesOn_Sections(TreeNode tn, GarminCore.Files.StdFile_SRT srt, NodeContent.NodeType nodetype) {
DeleteDummyChildNode(tn);
int count;
TreeNode parent;
switch (nodetype) {
case NodeContent.NodeType.SRT_CharacterLookupTableBlock:
parent = AppendNode(tn, NodeContent.NodeType.SRT_CharTabBlock, srt, "CharTabBlock");
count = (int)(srt.Sortheader.CharTabBlock.Length / srt.Sortheader.CharTabBlock.Recordsize);
for (int i = 0; i < count; i++)
AppendNode(parent, NodeContent.NodeType.Index, i, "Char " + i.ToString());
parent = AppendNode(tn, NodeContent.NodeType.SRT_ExpansionsBlock, srt, "ExpansionsBlock");
count = (int)(srt.Sortheader.ExpansionsBlock.Length / srt.Sortheader.ExpansionsBlock.Recordsize);
for (int i = 0; i < count; i++)
AppendNode(parent, NodeContent.NodeType.Index, i, "Expansion " + i.ToString());
break;
}
}
/// <summary>
/// Knoten für einen Header anhängen
/// </summary>
/// <param name="tn"></param>
/// <param name="tre"></param>
public static void AppendChildNodesOn_GarminSpecialHeader(TreeNode tn, GarminCore.Files.StdFile_SRT srt) {
}
public static void SpecialHeader(StringBuilder info, GarminCore.Files.StdFile_SRT srt) {
info.AppendLine("Unknown 0x15: (2 Byte): " + HexString(srt.Unknown_x15));
info.AppendLine("ContentsBlock: (6 Byte): " + srt.ContentsBlock.ToString());
info.AppendLine("Unknown 0x1D: (" + srt.Unknown_x1D.Length.ToString() + " Byte): " + HexString(srt.Unknown_x1D));
}
/// <summary>
/// Funktion für alle Datei-Infos
/// </summary>
/// <param name="info"></param>
/// <param name="hex"></param>
/// <param name="firsthexadr"></param>
/// <param name="filedata"></param>
/// <param name="nodetype">"Thema" der Info</param>
/// <param name="idx">wenn größer oder gleich 0, dann der Index auf ein Objekt einer Tabelle</param>
/// <param name="tn"></param>
public static void SectionAndIndex(StringBuilder info, out byte[] hex, out long firsthexadr, NodeContent.Content4File filedata, NodeContent.NodeType nodetype, int idx, TreeViewData tvd) {
GarminCore.Files.StdFile_SRT srt = filedata.GetGarminFileAsSRT();
int hexlen = 0;
firsthexadr = 0;
hex = null;
switch (nodetype) {
case NodeContent.NodeType.SRT_ContentsBlock:
firsthexadr = srt.ContentsBlock.Offset;
hexlen = srt.ContentsBlock.Length;
info.AppendLine("ContentsBlock: (6 Byte): " + srt.ContentsBlock.ToString());
info.AppendLine(" DescriptionBlock: " + srt.DescriptionBlock.ToString());
info.AppendLine(" CharacterLookupTableBlock: " + srt.CharacterLookupTableBlock.ToString());
break;
case NodeContent.NodeType.SRT_DescriptionBlock:
firsthexadr = srt.DescriptionBlock.Offset;
hexlen = (int)srt.DescriptionBlock.Length;
info.AppendLine("Description: (" + srt.DescriptionBlock.Length.ToString() + " Byte): '" + srt.Description + "'");
break;
case NodeContent.NodeType.SRT_CharacterLookupTableBlock:
firsthexadr = srt.CharacterLookupTableBlock.Offset;
hexlen = (int)srt.CharacterLookupTableBlock.Length;
info.AppendLine("Headerlength (2 Byte): " + DecimalAndHexAndBinary(srt.Sortheader.Headerlength));
info.AppendLine("Id1 (2 Byte): " + DecimalAndHexAndBinary(srt.Sortheader.Id1));
info.AppendLine("Id2 (2 Byte): " + DecimalAndHexAndBinary(srt.Sortheader.Id2));
info.AppendLine("Codepage (2 Byte): " + DecimalAndHexAndBinary(srt.Sortheader.Codepage));
info.AppendLine("Unknown1 (" + srt.Sortheader.Unknown1.Length.ToString() + " Byte): " + HexString(srt.Sortheader.Unknown1));
info.AppendLine("Unknown2 (" + srt.Sortheader.Unknown2.Length.ToString() + " Byte): " + HexString(srt.Sortheader.Unknown2));
info.AppendLine("CharTabBlock (10 Byte): " + srt.Sortheader.CharTabBlock.ToString());
info.AppendLine("Unknown3 (" + srt.Sortheader.Unknown3.Length.ToString() + " Byte): " + HexString(srt.Sortheader.Unknown3));
info.AppendLine("ExpansionsBlock (10 Byte): " + srt.Sortheader.ExpansionsBlock.ToString());
info.AppendLine("Unknown4 (" + srt.Sortheader.Unknown4.Length.ToString() + " Byte): " + HexString(srt.Sortheader.Unknown4));
info.AppendLine("CharTabOffset (4 Byte): " + DecimalAndHexAndBinary(srt.Sortheader.CharTabOffset));
info.AppendLine("Unknown5 (" + srt.Sortheader.Unknown5.Length.ToString() + " Byte): " + HexString(srt.Sortheader.Unknown5));
info.AppendLine("Unknown6 (" + srt.Sortheader.Unknown6.Length.ToString() + " Byte): " + HexString(srt.Sortheader.Unknown6));
break;
case NodeContent.NodeType.SRT_CharTabBlock:
firsthexadr = srt.Sortheader.CharTabBlock.Offset;
hexlen = (int)srt.Sortheader.CharTabBlock.Length;
if (idx < 0)
info.AppendLine("Count: " + (srt.Sortheader.CharTabBlock.Length / srt.Sortheader.CharTabBlock.Recordsize).ToString());
else {
hexlen = srt.Sortheader.CharTabBlock.Recordsize;
firsthexadr = srt.Sortheader.CharTabBlock.Offset + idx * hexlen;
}
break;
case NodeContent.NodeType.SRT_ExpansionsBlock:
firsthexadr = srt.Sortheader.ExpansionsBlock.Offset;
hexlen = (int)srt.Sortheader.ExpansionsBlock.Length;
if (idx < 0)
info.AppendLine("Count: " + (srt.Sortheader.ExpansionsBlock.Length / srt.Sortheader.ExpansionsBlock.Recordsize).ToString());
else {
hexlen = srt.Sortheader.ExpansionsBlock.Recordsize;
firsthexadr = srt.Sortheader.ExpansionsBlock.Offset + idx * hexlen;
}
break;
default:
info.AppendLine("internal error: no info for nodetype '" + nodetype.ToString() + "'");
break;
}
if (hexlen > 0)
hex = HexRange(firsthexadr, filedata.BinaryReader, hexlen);
}
}
}