Пример #1
0
        // JArray 삽입시 인덱스 수정
        void refreshIndex()
        {
            if (this.value_token_type != JTokenType.Array)
            {
                return;
            }

            //if(start_idx < 0 || start_new_idx < 0)
            //	return;

            int cnt = this.Items.Count;

            for (int i = 0, newidx = 0; i < cnt; i++)
            {
                JsonTreeViewItem tvi = this.Items[i] as JsonTreeViewItem;
                if (tvi == null)
                {
                    continue;
                }

                KeyTextBox tb = tvi.Header.Children[0] as KeyTextBox;
                if (tb == null)
                {
                    continue;
                }

                tb.Text = newidx.ToString();
                newidx++;
            }
        }
Пример #2
0
        // Json 버튼은 JsonTreeViewItem.Header.children 에 존재
        protected override void OnClick()
        {
            base.OnClick();
            JsonTreeViewItem this_jtvi = (this.Parent as Grid).Parent as JsonTreeViewItem;

            if (this_jtvi == null)
            {
                return;
            }

            if (this_jtvi.value_token_type == JTokenType.Array)
            {
                JsonTreeViewItem child_tvi = new JsonTreeViewItem();
                KeyTextBox       tb_key    = new KeyTextBox(this_jtvi.Actual_child_count.ToString(), false);
                child_tvi.Header.AddItem(tb_key);
                KeyTextBox tb_type = new KeyTextBox("object", false);
                child_tvi.Header.AddItem(tb_type);
                child_tvi.value_token_type = JTokenType.Object;

                this_jtvi.ChildAddItem(child_tvi);
            }
            else
            {
                // window_addJson showdialog()
                Window_AddJsonItem wnd_add = new Window_AddJsonItem();
                Point pt = this.PointToScreen(new Point(0, 0));
                wnd_add.Left = pt.X;
                wnd_add.Top  = pt.Y;

                // cancel return
                if (wnd_add.ShowDialog() != true)
                {
                    return;
                }

                JsonTreeViewItem.convertToTreeView_recursive(this_jtvi, new JProperty(wnd_add.key, wnd_add.value));
            }
        }
Пример #3
0
        static JsonTreeViewItem addUIToJsonTreeItem(JsonTreeViewItem parent_tvi, JToken jtok)
        {
            if (jtok is JObject)
            {
                JObject jobj = jtok as JObject;
                if (jobj.Parent == null)
                {
                    return(parent_tvi);
                }
                if (jobj.Parent != null && jobj.Parent is JArray)
                {
                    JsonTreeViewItem child_tvi = new JsonTreeViewItem();
                    parent_tvi.ChildAddItem(child_tvi);
                    KeyTextBox tb_key = new KeyTextBox((jobj.Parent as JArray).IndexOf(jobj).ToString(), false);
                    child_tvi.Header.AddItem(tb_key);
                    child_tvi.value_token_type = JTokenType.Object;
                    parent_tvi = child_tvi;
                }

                //KeyTextBox tb_type = new KeyTextBox("object", false);
                //parent_tvi.Header.AddItem(tb_type);
                //parent_tvi.value_token_type = JTokenType.Object;
                //return parent_tvi;
                ValuePanel panel_value = new ValuePanel(JTokenType.Object, "Object");
                parent_tvi.Header.AddItem(panel_value);
                parent_tvi.value_token_type = JTokenType.Object;
                return(parent_tvi);
            }
            else if (jtok is JProperty)
            {
                JProperty        jprop     = jtok as JProperty;
                JsonTreeViewItem child_tvi = new JsonTreeViewItem();
                parent_tvi.ChildAddItem(child_tvi);

                KeyTextBox tb_key = new KeyTextBox(jprop.Name);
                child_tvi.Header.AddItem(tb_key);

                return(child_tvi);
            }
            else if (jtok is JValue)
            {
                JValue     jval        = jtok as JValue;
                ValuePanel panel_value = new ValuePanel(jval.Type, jval.Value);
                parent_tvi.Header.AddItem(panel_value);
                parent_tvi.value_token_type = jval.Type;

                parent_tvi.Header.addButtn.Visibility = Visibility.Hidden;
                //parent_tvi.Items.Clear();
                return(parent_tvi);
            }
            else if (jtok is JArray)
            {
                //KeyTextBox tb_type = new KeyTextBox("array", false);
                //parent_tvi.Header.AddItem(tb_type);
                //parent_tvi.value_token_type = JTokenType.Array;
                //return parent_tvi;
                ValuePanel panel_value = new ValuePanel(JTokenType.Array, "Array");
                parent_tvi.Header.AddItem(panel_value);
                parent_tvi.value_token_type = JTokenType.Array;
                return(parent_tvi);
            }
            else
            {
                Log.PrintLog("undefined json type = " + jtok.GetType(), "UserControls.JsonTreeViewItem.addUIToJsonTreeItem");
                return(parent_tvi);
            }
        }