Пример #1
0
        Topic GetSibling(Topic from, bool forward, int level, Vector4 vector)
        {
            if (this.Level == level && this.Vector == vector)
            {
                return(this);
            }

            if (forward)
            {
                if (HasChildren)
                {
                    if (Children.Contains(from) && from != LastChild)
                    {
                        return(from.NextSibling.GetSibling(this, forward, level, vector));
                    }
                    else if (from == ParentTopic)
                    {
                        return(FirstChild.GetSibling(this, forward, level, vector));
                    }
                }
            }
            else
            {
                if (HasChildren)
                {
                    if (Children.Contains(from) && from != FirstChild)
                    {
                        return(from.PreviousSibling.GetSibling(this, forward, level, vector));
                    }
                    else if (from == ParentTopic)
                    {
                        return(LastChild.GetSibling(this, forward, level, vector));
                    }
                }
            }

            if (ParentTopic == null)
            {
                return(null);
            }
            else
            {
                return(ParentTopic.GetSibling(this, forward, level, vector));
            }
        }
Пример #2
0
        Topic GetFirstTopic(bool front, int level, Vector4 vector)
        {
            if (this.Level == level && Vector != vector)
            {
                return(this);
            }

            if (HasChildren)
            {
                if (front)
                {
                    return(FirstChild.GetSibling(this, true, level, vector));
                }
                else
                {
                    return(LastChild.GetSibling(this, false, level, vector));
                }
            }
            else
            {
                return(null);
            }
        }