public bool MoveChild(CsgNodeWrapper child, int toIndex)
        {
            bool success = Group.MoveChild(child.Node, toIndex);

            UpdateChildren();
            return(success);
        }
        public bool RemoveChild(CsgNodeWrapper child)
        {
            bool success = Group.RemoveChild(child.Node);

            child.OnDisplayNameChanged();
            UpdateChildren();
            return(success);
        }
 public void RemoveNode(CsgNodeWrapper wrapper)
 {
     wrapper.PropertyChanged -= WrapperPropertyChanged;
     Wrappers.Remove(wrapper.Node);
     WrapperIds.Remove(wrapper.Id);
     if (wrapper.IsObjectRoot)
     {
         OnObjectRootsChanged();
     }
 }
        public CsgNodeWrapper GetWrapper(CsgNode node)
        {
            CsgNodeWrapper wrapper;

            if (!Wrappers.TryGetValue(node, out wrapper))
            {
                if (node is CsgCube)
                {
                    wrapper = new CsgCubeWrapper(this, (CsgCube)node);
                }
                else if (node is CsgTranslate)
                {
                    wrapper = new CsgTranslateWrapper(this, (CsgTranslate)node);
                }
                else if (node is CsgScale)
                {
                    wrapper = new CsgScaleWrapper(this, (CsgScale)node);
                }
                else if (node is CsgRotate)
                {
                    wrapper = new CsgRotateWrapper(this, (CsgRotate)node);
                }
                else if (node is CsgUnion)
                {
                    wrapper = new CsgUnionWrapper(this, (CsgUnion)node);
                }
                else if (node is CsgSubtract)
                {
                    wrapper = new CsgSubtractWrapper(this, (CsgSubtract)node);
                }
                else if (node is CsgIntersect)
                {
                    wrapper = new CsgIntersectWrapper(this, (CsgIntersect)node);
                }
                else if (node is CsgGroup)
                {
                    wrapper = new CsgGroupWrapper(this, (CsgGroup)node);
                }
                else
                {
                    wrapper = new CsgNodeWrapper(this, node);
                }
                Wrappers[node]           = wrapper;
                WrapperIds[wrapper.Id]   = wrapper;
                wrapper.PropertyChanged += WrapperPropertyChanged;
                OnObjectRootsChanged();
                SetDirty();
            }
            return(wrapper);
        }
        private void UpdateChildren()
        {
            bool changed  = false;
            int  oldCount = ChildrenCount;
            int  newCount = Group.ChildrenCount;

            if (oldCount != newCount)
            {
                changed = true;
            }
            else
            {
                for (int i = oldCount - 1; i >= 0; i--)
                {
                    if (children[i].Node != Group[i])
                    {
                        changed = true; break;
                    }
                }
            }
            if (changed)
            {
                for (int i = 0; i < children.Count; i++)
                {
                    children[i].MeshChanged -= ChildMeshChanged;
                }
                children = new List <CsgNodeWrapper>();
                for (int i = 0; i < newCount; i++)
                {
                    CsgNodeWrapper wrapper = Repository.GetWrapper(Group[i]);
                    wrapper.MeshChanged += ChildMeshChanged;
                    children.Add(wrapper);
                }
                if (oldCount != newCount)
                {
                    OnPropertyChanged("ChildrenCount");
                }
                OnPropertyChanged("Children");
                OnMeshChanged();
            }
        }