Example #1
0
        /// <summary>
        /// Get the rectangle that completely encompasses all child sprites (and optionally their children)
        /// </summary>
        /// <returns></returns>
        public ERectangleF GetBoundingRectangle(bool includeChildrensBounds, bool onlyThoseWithMembers, bool includeThis)
        {
            ERectangleF rct = ERectangleF.FromLTRB(9999999, 9999999, -9999999, -9999999);

            if (includeThis)
            {
                if ((onlyThoseWithMembers && this.Member != null) || !onlyThoseWithMembers)
                {
                    rct.Expand(this.Rect);
                }
            }

            for (int i = this.ChildCount - 1; i >= 0; i--)
            {
                Sprite sp = this.GetChildByIndex(i);

                if ((onlyThoseWithMembers && this.Member != null) || !onlyThoseWithMembers)
                {
                    rct.Expand(sp.Rect);
                }

                if (includeChildrensBounds)
                {
                    rct.Expand(sp.GetBoundingRectangle(true, onlyThoseWithMembers, false));
                }
            }
            return(rct);
        }