diff --git a/Resources/NetHookAnalyzer2/NetHookAnalyzer2/MainForm.Designer.cs b/Resources/NetHookAnalyzer2/NetHookAnalyzer2/MainForm.Designer.cs index ff90a568f..763651a02 100644 --- a/Resources/NetHookAnalyzer2/NetHookAnalyzer2/MainForm.Designer.cs +++ b/Resources/NetHookAnalyzer2/NetHookAnalyzer2/MainForm.Designer.cs @@ -300,6 +300,7 @@ private void InitializeComponent() this.itemExplorerTreeView.Name = "itemExplorerTreeView"; this.itemExplorerTreeView.Size = new System.Drawing.Size(455, 426); this.itemExplorerTreeView.TabIndex = 0; + this.itemExplorerTreeView.ShowRootLines = false; // // timestampColumnHeader // diff --git a/Resources/NetHookAnalyzer2/NetHookAnalyzer2/MainForm.cs b/Resources/NetHookAnalyzer2/NetHookAnalyzer2/MainForm.cs index ca7c14824..4dbf906fb 100644 --- a/Resources/NetHookAnalyzer2/NetHookAnalyzer2/MainForm.cs +++ b/Resources/NetHookAnalyzer2/NetHookAnalyzer2/MainForm.cs @@ -388,7 +388,7 @@ void RepopulateTreeView() } itemExplorerTreeView.Nodes.Clear(); - itemExplorerTreeView.Nodes.AddRange(BuildTree(item).Nodes.Cast().ToArray()); + itemExplorerTreeView.Nodes.Add(BuildTree(item)); itemExplorerTreeView.Nodes[0].EnsureVisible(); // Scroll to top } diff --git a/Resources/NetHookAnalyzer2/NetHookAnalyzer2/NetHookItemTreeBuilder.cs b/Resources/NetHookAnalyzer2/NetHookAnalyzer2/NetHookItemTreeBuilder.cs index 479ae6f62..dd9517a88 100644 --- a/Resources/NetHookAnalyzer2/NetHookAnalyzer2/NetHookItemTreeBuilder.cs +++ b/Resources/NetHookAnalyzer2/NetHookAnalyzer2/NetHookItemTreeBuilder.cs @@ -55,47 +55,44 @@ TreeNode CreateTreeNodeCore(bool displayUnsetFields) { var configuration = new TreeNodeObjectExplorerConfiguration { ShowUnsetFields = displayUnsetFields }; - var node = new TreeNode(); + using var stream = item.OpenStream(); - using (var stream = item.OpenStream()) - { - var rawEMsg = PeekUInt(stream); + var rawEMsg = PeekUInt(stream); + var node = BuildInfoNode(rawEMsg); + node.Expand(); - node.Nodes.Add(BuildInfoNode(rawEMsg)); + var header = ReadHeader(rawEMsg, stream); + node.Nodes.Add(new TreeNodeObjectExplorer("Header", header, configuration).TreeNode); - var header = ReadHeader(rawEMsg, stream); - node.Nodes.Add(new TreeNodeObjectExplorer("Header", header, configuration).TreeNode); + var body = ReadBody(rawEMsg, stream, header); + var bodyNode = new TreeNodeObjectExplorer("Body", body, configuration).TreeNode; + node.Nodes.Add(bodyNode); - var body = ReadBody(rawEMsg, stream, header); - var bodyNode = new TreeNodeObjectExplorer("Body", body, configuration).TreeNode; - node.Nodes.Add(bodyNode); + var payload = ReadPayload(stream); + if (payload != null && payload.Length > 0) + { + node.Nodes.Add(new TreeNodeObjectExplorer("Payload", payload, configuration).TreeNode); + } - var payload = ReadPayload(stream); - if (payload != null && payload.Length > 0) + if (Specializations != null) + { + var objectsToSpecialize = new[] { body }; + while (objectsToSpecialize.Any()) { - node.Nodes.Add(new TreeNodeObjectExplorer("Payload", payload, configuration).TreeNode); - } + var specializations = objectsToSpecialize.SelectMany(o => Specializations.SelectMany(x => x.ReadExtraObjects(o))); - if (Specializations != null) - { - var objectsToSpecialize = new[] { body }; - while (objectsToSpecialize.Any()) + if (!specializations.Any()) { - var specializations = objectsToSpecialize.SelectMany(o => Specializations.SelectMany(x => x.ReadExtraObjects(o))); - - if (!specializations.Any()) - { - break; - } + break; + } - bodyNode.Collapse(ignoreChildren: true); + bodyNode.Collapse(ignoreChildren: true); - var extraNodes = specializations.Select(x => new TreeNodeObjectExplorer(x.Key, x.Value, configuration).TreeNode).ToArray(); - node.Nodes.AddRange(extraNodes); + var extraNodes = specializations.Select(x => new TreeNodeObjectExplorer(x.Key, x.Value, configuration).TreeNode).ToArray(); + node.Nodes.AddRange(extraNodes); - // Let the specializers examine any new message objects. - objectsToSpecialize = specializations.Select(x => x.Value).ToArray(); - } + // Let the specializers examine any new message objects. + objectsToSpecialize = specializations.Select(x => x.Value).ToArray(); } }