TreeNode CreateTreeNodeCore(bool displayUnsetFields) { var configuration = new TreeNodeObjectExplorerConfiguration { ShowUnsetFields = displayUnsetFields }; using var stream = item.OpenStream(); var rawEMsg = PeekUInt(stream); var node = BuildInfoNode(rawEMsg); node.Expand(); 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 payload = ReadPayload(stream); if (payload != null && payload.Length > 0) { node.Nodes.Add(new TreeNodeObjectExplorer("Payload", payload, configuration).TreeNode); } if (Specializations != null) { var objectsToSpecialize = new[] { body }; while (objectsToSpecialize.Any()) { var specializations = objectsToSpecialize.SelectMany(o => Specializations.SelectMany(x => x.ReadExtraObjects(o))); if (!specializations.Any()) { break; } bodyNode.Collapse(ignoreChildren: true); 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(); } } return(node); }
static TreeNode BuildInfoNode(uint rawEMsg, TreeNodeObjectExplorerConfiguration configuration) { var eMsg = MsgUtil.GetMsg(rawEMsg); var eMsgExplorer = new TreeNodeObjectExplorer("EMsg", eMsg, configuration); return(new TreeNode("Info", new[] { eMsgExplorer.TreeNode, new TreeNodeObjectExplorer("Is Protobuf", MsgUtil.IsProtoBuf(rawEMsg), configuration).TreeNode })); }
public TreeNodeObjectExplorer(string name, object value, TreeNodeObjectExplorerConfiguration configuration) { this.name = name; this.value = value; this.configuration = configuration; this.treeNode = new TreeNode(); if (configuration.IsUnsetField) { treeNode.ForeColor = System.Drawing.Color.DarkGray; } this.treeNode.ContextMenuStrip = new ContextMenuStrip(); this.treeNode.ContextMenuStrip.Opening += OnContextMenuStripOpening; Initialize(); }