Ejemplo n.º 1
0
        /// <summary>
        /// Copies just the node's value
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>Menu item Viewer > Copy Value</remarks>
        /// <!-- JsonViewerTreeNode had to be made public to be accessible here -->
        private void copyValueToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Control            c    = JsonViewer.Controls.Find("tvJson", true)[0];
            JsonViewerTreeNode node = (JsonViewerTreeNode)((TreeView)c).SelectedNode;

            if (node?.JsonObject.Value != null)
            {
                Clipboard.SetText(node.JsonObject.Value.ToString());
            }
        }
Ejemplo n.º 2
0
        private void VisualizeJsonTree(TreeView treeView, JsonObjectTree tree)
        {
            //levelNodesCount = new int[20];

            treeView.Nodes.Clear();
            AddNode(treeView.Nodes, tree.Root);
            JsonViewerTreeNode node = (JsonViewerTreeNode)treeView.Nodes[0];

            //JsonViewer.expandSubNodes(node, index - 1 < 0 ? 0 : index - 1);
            node.Expand();
            compTreeViewLeft.SelectedNode = node;
        }
Ejemplo n.º 3
0
        //private int[] levelNodesCount;

        private void AddNode(TreeNodeCollection nodes, JsonObject jsonObject)
        {
            JsonViewerTreeNode newNode = new JsonViewerTreeNode(jsonObject);

            nodes.Add(newNode);
            newNode.Text               = jsonObject.Text;
            newNode.Tag                = jsonObject;
            newNode.ImageIndex         = (int)jsonObject.JsonType;
            newNode.SelectedImageIndex = newNode.ImageIndex;
            foreach (JsonObject field in jsonObject.Fields)
            {
                AddNode(newNode.Nodes, field);
            }

            //levelNodesCount[newNode.Level]++;
        }