private void UpdateHexViewerData() { byte[] data; if (rootNode != null) { using (MemoryStream ms = new MemoryStream()) { Asn1.Encode(ms, rootNode); data = ms.ToArray(); } } else { data = new byte[0]; } hexViewer.View(data); Asn1TreeNode selectedNode = treeView1.SelectedNode as Asn1TreeNode; if (selectedNode != null) { // TODO: length is incorrect for indefinite length nodes hexViewer.Highlight((int)selectedNode.Asn1Node.StartByte, (int)(Asn1.GetTotalByteCount(selectedNode.Asn1Node))); } }
public void ShowAsn1(Asn1Tag root) { treeView1.Nodes.Clear(); Asn1TreeNode treeNode = new Asn1TreeNode(root); treeView1.Nodes.Add(treeNode); AddSubNodes(treeNode, root); treeView1.ExpandAll(); }
private void AddSubNodes(TreeNode rootTree, Asn1Tag rootAsn1) { foreach (Asn1Tag subAsn1 in rootAsn1) { Asn1TreeNode subTree = new Asn1TreeNode(subAsn1); rootTree.Nodes.Add(subTree); AddSubNodes(subTree, subAsn1); } }