예제 #1
0
        // ----------------------------------------------------------------------
        public static void DeleteKeepChildren(iCS_EditorObject obj)
        {
            if (!IsDeletionAllowed())
            {
                return;
            }
            var iStorage = obj.IStorage;

            OpenTransaction(iStorage);
            try {
                var newParent  = obj.ParentNode;
                var childNodes = obj.BuildListOfChildNodes(_ => true);
                var childPos   = P.map(n => n.GlobalPosition, childNodes);
                iStorage.AnimateGraph(obj,
                                      _ => {
                    // Move the selection to the parent node
                    var parent = obj.ParentNode;
                    iStorage.SelectedObject = parent;

                    P.forEach(n => { iStorage.ChangeParent(n, newParent); }, childNodes);
                    SystemEvents.AnnounceVisualScriptElementWillBeRemoved(obj);
                    iStorage.DestroyInstance(obj.InstanceId);
                    P.zipWith((n, p) => { n.LocalAnchorFromGlobalPosition = p; }, childNodes, childPos);
                    iStorage.ForcedRelayoutOfTree();
                }
                                      );
            }
            catch (System.Exception) {
                CancelTransaction(iStorage);
                return;
            }
            CloseTransaction(iStorage, "Delete " + obj.DisplayName);
        }