コード例 #1
0
ファイル: ProjectTreeView.cs プロジェクト: lbm7926/Imp
        public void ChangeParent(ProjectItem projectItem, ProjectItem oldParent)
        {
            if (!m_treeView.IsDropInProgress && m_treeView.GetItemContainerData(projectItem) != null)
            {
                m_treeView.ChangeParent(projectItem.Parent, projectItem);
            }

            VirtualizingTreeViewItem tvOldParent = m_treeView.GetTreeViewItem(oldParent);
            if (tvOldParent != null)
            {
                tvOldParent.CanExpand = oldParent.Children != null && oldParent.Children.Any(c => c.IsFolder);
            }

            VirtualizingTreeViewItem tvNewParent = m_treeView.GetTreeViewItem(projectItem.Parent);
            if (tvNewParent != null)
            {
                tvNewParent.CanExpand = true;
            }
        }
コード例 #2
0
ファイル: HierarchyViewImpl.cs プロジェクト: lbm7926/Imp
        protected virtual void OnParentChanged(ExposeToEditor obj, ExposeToEditor oldParent, ExposeToEditor newParent)
        {
            if (Editor.IsPlaymodeStateChanging)
            {
                return;
            }

            bool isNewParentExpanded = true;
            bool isOldParentExpanded = true;
            bool isLastChild         = false;

            if (newParent != null)
            {
                isNewParentExpanded = m_treeView.IsExpanded(newParent);
            }

            if (oldParent != null)
            {
                TreeViewItemContainerData itemContainerData = (TreeViewItemContainerData)m_treeView.GetItemContainerData(oldParent);

                isLastChild = !oldParent.HasChildren(); //!itemContainerData.HasChildren(m_treeView);

                isOldParentExpanded = m_treeView.IsExpanded(oldParent);
            }

            if (isNewParentExpanded)
            {
                m_treeView.ChangeParent(newParent, obj);

                if (!isOldParentExpanded)
                {
                    if (isLastChild)
                    {
                        VirtualizingTreeViewItem oldParentContainer = m_treeView.GetTreeViewItem(oldParent);
                        if (oldParentContainer)
                        {
                            oldParentContainer.CanExpand = false;
                        }
                    }
                }
            }
            else
            {
                if (newParent != null)
                {
                    VirtualizingTreeViewItem newParentTreeViewItem = m_treeView.GetTreeViewItem(newParent);
                    if (newParentTreeViewItem != null)
                    {
                        newParentTreeViewItem.CanExpand = true;
                    }
                }

                m_treeView.RemoveChild(oldParent, obj);
            }
        }