Esempio n. 1
0
        /// <summary>
        /// 获取最大排序号兄弟节点(可能为自身)
        /// </summary>
        /// <returns></returns>
        protected virtual T GetLastSibling()
        {
            if (SiblingNodes.Count() > 0)
            {
                return(SiblingNodes.Last());
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取所有后继兄弟节点
        /// </summary>
        /// <returns></returns>
        protected virtual IList <T> GetNextSiblingNodes()
        {
            if (SiblingNodes != null)
            {
                IEnumerable <T> nsibs = SiblingNodes.Where(tent => tent.SortIndex > this.SortIndex);

                if (nsibs.Count() > 0)
                {
                    return(nsibs.ToList());
                }
            }

            return(null);
        }
Esempio n. 3
0
        public IEnumerable <MoveTreeNode <PostMoveState> > FlattenToPgnOrder()
        {
            if (!string.IsNullOrWhiteSpace(Value.Value.San))
            {
                yield return(Value);
            }

            foreach (var siblingNode in SiblingNodes.Concat(new[] { Next }).Where(x => x != null))
            {
                foreach (var siblingInfo in siblingNode.FlattenToPgnOrder())
                {
                    yield return(siblingInfo);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 获取后继兄弟节点
        /// </summary>
        /// <returns></returns>
        protected virtual T GetNextSibling()
        {
            if (SiblingNodes != null)
            {
                IEnumerable <T> psibs = SiblingNodes.Where(tent => tent.SortIndex > this.SortIndex);
                if (psibs.Count() > 0)
                {
                    // 从小到大排序的第一个
                    return(psibs.OrderBy(tent => tent.SortIndex).First());
                }

                return(null);
            }

            return(null);
        }
Esempio n. 5
0
        /// <summary>
        /// 获取前置兄弟节点
        /// </summary>
        /// <returns></returns>
        protected virtual T GetPrevSibling()
        {
            if (SiblingNodes != null)
            {
                IEnumerable <T> psibs = SiblingNodes.Where(tent => tent.SortIndex < this.SortIndex);
                if (psibs.Count() > 0)
                {
                    // 从大到小排序的第一个
                    return(psibs.OrderByDescending(tent => tent.SortIndex).First());
                }

                return(null);
            }

            return(null);
        }