Exemplo n.º 1
0
        public bool ChangePosition <T>(ObservableList <TreeNode <T> > nodes, Predicate <TreeNode <T> > match, int position)
        {
            var findedNode = nodes.Find(match);

            if (findedNode != null)
            {
                nodes.BeginUpdate();
                nodes.Remove(findedNode);
                nodes.Insert(position, findedNode);
                nodes.EndUpdate();
                return(true);
            }
            foreach (var node in nodes)
            {
                if (node.Nodes == null)
                {
                    continue;
                }
                if (ChangePosition(node.Nodes as ObservableList <TreeNode <T> >, match, position))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Remove node if it's match specified function.
        /// </summary>
        /// <typeparam name="T">Node type.</typeparam>
        /// <param name="nodes">Nodes.</param>
        /// <param name="match">Match function.</param>
        /// <returns>true if node removed; otherwise, false.</returns>
        public static bool Remove <T>(ObservableList <TreeNode <T> > nodes, Predicate <TreeNode <T> > match)
        {
            var findedNode = nodes.Find(match);

            if (findedNode != null)
            {
                findedNode.Parent = null;

                // this.nodes.Add(findedNode as TreeNode<TreeViewItem>);
                return(true);
            }

            foreach (var node in nodes)
            {
                if (node.Nodes == null)
                {
                    continue;
                }

                if (Remove(node.Nodes, match))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
 public T Find(Func <T, bool> condition)
 {
     return(_list.Find(condition));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Finds child named childWord. If not found, returns null.
        /// </summary>
        /// <param name="childWord">Word to find</param>
        /// <returns>Found node</returns>
        public WordMapNode FindChild(string childWord)
        {
            WordMapNode foundNode = Next.Find(x => x.Word == childWord);

            return(foundNode);
        }