/// <summary> /// 拖拽事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void XTreeView_Drop(object sender, DragEventArgs e) { try { ItemBox tobox = getStackBoxOnDrap(e.OriginalSource as UIElement); ItemBox frombox = XTreeView.SelectedItem as ItemBox; if (tobox != null && frombox != null && tobox != frombox && tobox.BoxType != ItemBoxEnum.IF && (tobox.BoxType == ItemBoxEnum.ELSE || tobox.BoxType == ItemBoxEnum.WHILE)) { if (frombox.ParentNode == null) { Itemboxs.Remove(frombox); tobox.Add(frombox); } else { frombox.ParentNode.Del(frombox); tobox.Add(frombox); } } else if (tobox != null && frombox != null && tobox.BoxType == ItemBoxEnum.FUNCTION) { if (frombox.ParentNode == null) { Itemboxs.Remove(frombox); } else { frombox.ParentNode.Del(frombox); } if (tobox.ParentNode == null) { Itemboxs.Insert(Itemboxs.IndexOf(tobox), frombox); } else { tobox.ParentNode.Children.Insert(tobox.ParentNode.Children.IndexOf(tobox), frombox); } } } catch (Exception ex) { Log.ScriptLog.Log.Write(ex); } }