Beispiel #1
0
 /// <summary>
 /// Adds 1 depth level in given node.
 /// </summary>
 /// <param name="node"></param>
 private static void ExpandTreeNodeDepth(JTokenTreeNode node)
 {
     if (node.Nodes.Count > 0)
     {
         foreach (JTokenTreeNode childNode in node.Nodes)
         {
             ExpandTreeNodeDepth(childNode);
         }
     }
     else
     {
         foreach (var jToken in node.JTokenTag)
         {
             node.Nodes.Add(JsonTreeNodeFactory.Create(jToken, 1));
         }
     }
 }
Beispiel #2
0
        /// <inheritdoc />
        protected override void OnVisibleChanged(EventArgs e)
        {
            if (Visible)
            {
                JTokenNode = FindSourceTreeNode <JTokenTreeNode>();

                // Collapse item shown if node is expanded and has children
                CollapseAllToolStripItem.Visible = JTokenNode.IsExpanded &&
                                                   JTokenNode.Nodes.Cast <TreeNode>().Any();

                // Expand item shown if node if not expanded or has a children not expanded
                ExpandAllToolStripItem.Visible = !JTokenNode.IsExpanded ||
                                                 JTokenNode.Nodes.Cast <TreeNode>().Any(t => !t.IsExpanded);

                // Remove item enabled if it is not the root or the value of a property
                DeleteNodeToolStripItem.Enabled = (JTokenNode.Parent != null) &&
                                                  !(JTokenNode.Parent is JPropertyTreeNode);

                // Cut item enabled if delete is
                CutNodeToolStripItem.Enabled = DeleteNodeToolStripItem.Enabled;

                // Paste items enabled only when a copy or cut operation is pending
                PasteNodeAfterToolStripItem.Enabled = !EditorClipboard <JTokenTreeNode> .IsEmpty() &&
                                                      (JTokenNode.Parent != null) &&
                                                      !(JTokenNode.Parent is JPropertyTreeNode);

                PasteNodeBeforeToolStripItem.Enabled = !EditorClipboard <JTokenTreeNode> .IsEmpty() &&
                                                       (JTokenNode.Parent != null) &&
                                                       !(JTokenNode.Parent is JPropertyTreeNode);

                PasteNodeReplaceToolStripItem.Enabled = !EditorClipboard <JTokenTreeNode> .IsEmpty() &&
                                                        (JTokenNode.Parent != null);
            }

            base.OnVisibleChanged(e);
        }