Ejemplo n.º 1
0
 /// <summary>
 /// Creates a proper item for a tree view
 /// </summary>
 /// <param name="key">Key if inside an object</param>
 /// <param name="index">Index if inside an array</param>
 /// <param name="value">JSON value this item represents</param>
 /// <param name="treeView">Tree view reference</param>
 public static StringTreeViewItem CreateJsonValueItem(
     string key, int index, JsonValue value, JsonTreeView treeView
     )
 {
     if (value.IsJsonObject)
     {
         return new ObjectTreeViewItem(treeView, value.AsJsonObject)
                {
                    Key   = key,
                    Index = index
                }
     }
     ;
     else if (value.IsJsonArray)
     {
         return new ArrayTreeViewItem(treeView, value.AsJsonArray)
                {
                    Key   = key,
                    Index = index
                }
     }
     ;
     else if (value.IsNull)
     {
         return new NullTreeViewItem(treeView)
                {
                    Key   = key,
                    Index = index
                }
     }
     ;
     else if (value.IsBoolean)
     {
         return new BoolTreeViewItem(treeView, value.AsBoolean)
                {
                    Key   = key,
                    Index = index
                }
     }
     ;
     else if (value.IsNumber)
     {
         return new NumberTreeViewItem(treeView, value.AsNumber)
                {
                    Key   = key,
                    Index = index
                }
     }
     ;
     else
     {
         return new StringTreeViewItem(treeView, value.AsString)
                {
                    Key   = key,
                    Index = index
                }
     };
 }
Ejemplo n.º 2
0
        public ObjectTreeViewItem(JsonTreeView treeView, JsonObject objectValue) : base(treeView, null)
        {
            foreach (var pair in objectValue)
            {
                AddChild(JsonTreeViewUtils.CreateJsonValueItem(pair.Key, 0, pair.Value, treeView));
            }

            RepairChildStructure();
        }
Ejemplo n.º 3
0
        public ArrayTreeViewItem(JsonTreeView treeView, JsonArray arrayValue) : base(treeView, null)
        {
            for (int i = 0; i < arrayValue.Count; i++)
            {
                AddChild(JsonTreeViewUtils.CreateJsonValueItem(null, i, arrayValue[i], treeView));
            }

            RepairChildStructure();
        }
Ejemplo n.º 4
0
        public JsonEditor()
        {
            treeViewState = new TreeViewState();
            jsonTreeView  = new JsonTreeView(treeViewState);
            jsonTreeView.ExpandAll();

            jsonTreeView.OnChange += () => {
                OnChange?.Invoke();
            };
        }
Ejemplo n.º 5
0
 public StringTreeViewItem(JsonTreeView treeView, string initialValue) : base()
 {
     this.treeView    = treeView;
     this.StringValue = initialValue;
     id = treeView.NextId();
 }
Ejemplo n.º 6
0
 public AddTreeViewItem(JsonTreeView treeView) : base(treeView, null)
 {
 }