private static bool TryAddChild(ResourceNode dragging, ResourceNode dropping) { bool good = false; Type dt = dragging.GetType(); if (dropping.Children.Count != 0) good = CompareTypes(dropping.Children[0].GetType(), dt); else foreach (Type t in dropping.AllowedChildTypes) if (good = CompareToType(dt, t)) break; if (good) { if (dragging.Parent != null) dragging.Parent.RemoveChild(dragging); dropping.AddChild(dragging); if (dragging is MDL0BoneNode) ((MDL0BoneNode)dragging).Moved = true; } return good; }
private static bool TryDrop(ResourceNode dragging, ResourceNode dropping) { if (dropping.Parent == null) return false; bool good = false; int destIndex = dropping.Index; good = CompareTypes(dragging, dropping); if (dropping.Parent is BRESGroupNode) foreach (Type t in dropping.Parent.AllowedChildTypes) if (good = CompareToType(dragging.GetType(), t)) break; if (good) { if (dragging.Parent != null) dragging.Parent.RemoveChild(dragging); if (destIndex < dropping.Parent.Children.Count) dropping.Parent.InsertChild(dragging, true, destIndex); else dropping.Parent.AddChild(dragging, true); if (dragging is MDL0BoneNode) ((MDL0BoneNode)dragging).Moved = true; } return good; }
private static bool CompareTypes(ResourceNode r1, ResourceNode r2) { return CompareTypes(r1.GetType(), r2.GetType()); }