예제 #1
0
 private void tvStructureTree_AfterSelect(object sender, TreeViewEventArgs e)
 {
     // we've selected a node, highlight its details in the hex view
     if (tvStructureTree.SelectedNode != null)
     {
         GraphTreeNode node = (GraphTreeNode)tvStructureTree.SelectedNode;
         ShowFileContents(node.Data.FilePositionStart, node.Data.FilePositionEnd);
     }
 }
예제 #2
0
        private void AddDisplayNodeToTree(TreeNodeCollection nodes, GraphNode graphNode, int level)
        {
            // create the display for the node
            GraphTreeNode subNode = new GraphTreeNode();

            subNode.Text = String.Format("{0}", graphNode.Name);
            subNode.Data = graphNode;

            switch (graphNode.NodeType)
            {
            case NodeType.Primitive_uint16:
                subNode.Text = String.Format("{0} - 0x{1:X}", graphNode.Name, (UInt16)graphNode.Value);
                break;

            case NodeType.Primitive_uint32:
                subNode.Text = String.Format("{0} - 0x{1:X}", graphNode.Name, (uint)graphNode.Value);
                break;

            case NodeType.Primitive_single:
                subNode.Text = String.Format("{0} - {1:0.0000}", graphNode.Name, (float)graphNode.Value);
                break;

            case NodeType.Empty:
                subNode.Text = String.Format("{0} - {1} bytes", graphNode.Name, (int)graphNode.Value);
                break;

            case NodeType.Vector:
                subNode.Text = String.Format("{0} - vector of {1}", graphNode.Name, graphNode.SubNodes.Count);
                break;

            case NodeType.Complex:
                subNode.Text = String.Format("{0} - (complex)", graphNode.Name);
                break;

            default:
                throw new NotImplementedException();
            }

            nodes.Add(subNode);

            // show the children of this node
            foreach (GraphNode subGraphNode in graphNode.SubNodes)
            {
                AddDisplayNodeToTree(subNode.Nodes, subGraphNode, level + 1);
            }

            if (level <= 1)
            {
                subNode.Expand();
            }
            else
            {
                subNode.Collapse();
            }
        }