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);

                dragging.OnMoved();
            }

            return(good);
        }
예제 #2
0
 private void DuplicateHelper(ResourceNode originalParent, ResourceNode duplicatedParent, string suffix)
 {
     foreach (ResourceNode n in originalParent.Children)
     {
         string tempPath = Path.GetTempFileName();
         _resource.Export(tempPath);
         // Initialize node in a way that will not cause crashes
         ResourceNode rNode2 = new MDL0BoneNode {
             _name = n.Name + suffix
         };
         rNode2.Replace(tempPath);
         duplicatedParent.AddChild(rNode2);
         DuplicateHelper(n, rNode2, suffix);
     }
 }