// 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 != null) { this_jtvi.Remove(); } //FileContoller.write(JsonInfo.current.filename, JsonInfo.current.jtok_root.ToString()); }
public void PublicDrop(DragEventArgs e) { base.OnDrop(e); // bubble (자식부터 부모요소로 이벤트 전달 방식) 이므로 처음 수행할때 (제일 자식에서 이벤트를 받았을 때), 이벤트 수행처리. e.Handled = true; // If the DataObject contains string data, extract it. if (e.Data.GetDataPresent("Object")) { Object data_obj = (Object)e.Data.GetData("Object"); JsonTreeViewItem tvi_src = data_obj as JsonTreeViewItem; if (tvi_src == null) { return; } // dst 의 조상중에 src 가 있나 체크 & dst == src 인지 체크 JsonTreeViewItem tmp_parent = this; while (tmp_parent != null) { if (tmp_parent == tvi_src) { return; } tmp_parent = tmp_parent.Parent as JsonTreeViewItem; } JsonTreeViewItem tvi_parent = this.Parent as JsonTreeViewItem; JsonTreeViewItem tvi_src_parent = tvi_src.Parent as JsonTreeViewItem; if (tvi_parent == null || tvi_src_parent == null) { return; } // JArray 타입과 다른타입과는 드래그앤드롭 불가. (src==JArray && dst==JArray) 이거나 (src != JArray && dst==JArray) 일떄 수행 if ((tvi_parent.value_token_type == JTokenType.Array && tvi_src_parent.value_token_type != JTokenType.Array) || (tvi_parent.value_token_type != JTokenType.Array && tvi_src_parent.value_token_type == JTokenType.Array)) { return; } // 중복 체크 if (tvi_parent.value_token_type != JTokenType.Array && tvi_src_parent.value_token_type != JTokenType.Array && tvi_parent != tvi_src_parent && tvi_parent.checkDuplication(tvi_src) < 0) { return; } // remove bool ischecked_more_button = false; if (tvi_parent.button_more != null) { ischecked_more_button = tvi_parent.button_more.IsChecked.Value; } int idx_insert = tvi_parent.Items.IndexOf(this); tvi_src.Remove(); // insert tvi_parent.ChildAddItem(tvi_src, idx_insert); if (tvi_parent.button_more != null) { tvi_parent.button_more.IsChecked = ischecked_more_button; } } }