コード例 #1
0
        public ProjectNodeViewModel GetSelectedNode()
        {
            if (IsSelected)
            {
                return(this);
            }

            foreach (ProjectNodeViewModel node in Children)
            {
                ProjectNodeViewModel selectedNode = node.GetSelectedNode();
                if (selectedNode != null)
                {
                    return(selectedNode);
                }
            }

            return(null);
        }
コード例 #2
0
        public bool FindAndRemoveNode(ProjectNodeViewModel node)
        {
            if (Children.Contains(node))
            {
                Children.Remove(node);
                return(true);
            }

            foreach (ProjectNodeViewModel child in Children)
            {
                if (child.FindAndRemoveNode(node))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        public void InsertChildNode(ProjectNodeViewModel node)
        {
            for (int i = 0; i < Children.Count; i++)
            {
                var child = Children[i];

                if (node is ProjectFileNodeViewModel && child is ProjectFolderNodeViewModel)
                {
                    continue;
                }
                else if (node is ProjectFolderNodeViewModel && child is ProjectFileNodeViewModel)
                {
                    Children.Insert(i, node);
                    return;
                }
                else if (string.Compare(child.DisplayName, node.DisplayName, true) > 0)
                {
                    Children.Insert(i, node);
                    return;
                }
            }

            Children.Add(node);
        }