Example #1
0
        /// <summary>
        /// Finds an specified TreeItem that asserts a condition.
        /// </summary>
        /// <param name="pFindMethod">Delegate used to specify if a TreeItem reaches the condition.
        /// Must return true if the TreeItem reaches the condition.</param>
        /// <param name="data">Object passed to delegate method</param>
        /// <param name="nItem">The ordinal of TreeItem that reaches the condition (i.e. if nItem equals 2 the
        /// second TreeItem that reaches the condition will be returned).</param>
        /// <returns>The nItem-nth TreeItem that reaches the condition (or NULL if none)</returns>
        public TreeItem FindItem(FindItemDelegate pFindMethod, object data, int nItem)
        {
            int nfind = 0;

            foreach (object o in _items)
            {
                if (pFindMethod((TreeItem)o, data) && ++nfind == nItem)
                {
                    return((TreeItem)o);
                }
            }
            return(null);
        }
Example #2
0
 /// <summary>
 /// Finds an specified TreeItem that asserts a condition.
 /// </summary>
 /// <param name="pFindMethod">Delegate used to specify if a TreeItem reaches the condition.
 /// Must return true if the TreeItem reaches the condition.</param>
 /// <param name="data">Object passed to delegate method</param>
 /// <returns>The 1st TreeItem that reaches the condition (or NULL if none)</returns>
 public TreeItem FindItem(FindItemDelegate pFindMethod, object data)
 {
     return(FindItem(pFindMethod, data, 1));
 }