Ejemplo n.º 1
0
 /// <summary>
 /// Destroy this <see cref="Texture2D"/>.
 /// </summary>
 public void Dispose()
 {
     TopLeft.Dispose();
     TopCenter.Dispose();
     TopRight.Dispose();
     MiddleLeft.Dispose();
     MiddleCenter.Dispose();
     MiddleRight.Dispose();
     BottomLeft.Dispose();
     BottomCenter.Dispose();
     BottomRight.Dispose();
 }
Ejemplo n.º 2
0
        public void Draw(SpriteBatch spr, Rectangle bounds, Color color)
        {
            if (spr == null)
            {
                throw new ArgumentNullException(nameof(spr));
            }

            Point pos  = bounds.Location;
            Point size = bounds.Size;

            if (size.X < 0)
            {
                size.X = 0;
            }
            if (size.Y < 0)
            {
                size.Y = 0;
            }

            int minWidth   = TopLeft.Region.Width + TopRight.Region.Width;
            int innerWidth = size.X - minWidth;

            if (innerWidth < 0)
            {
                innerWidth = 0;
            }

            int minHeight   = TopLeft.Region.Height + BottomLeft.Region.Height;
            int innerHeight = size.Y - minHeight;

            if (innerHeight < 0)
            {
                innerHeight = 0;
            }

            // Top left.
            TopLeft.Draw(spr, pos, color);

            //// Top center.
            if (innerWidth != 0)
            {
                TopCenter.Draw(spr, new Rectangle(pos + new Point(TopLeft.Region.Width, 0), new Point(innerWidth, TopCenter.Region.Height)), color);
            }

            //// Top right.
            TopRight.Draw(spr, pos + new Point(TopLeft.Region.Width + innerWidth, 0), color);

            // Center left.
            if (innerHeight != 0)
            {
                CenterLeft.Draw(spr, new Rectangle(pos + new Point(0, TopLeft.Region.Height), new Point(TopLeft.Region.Width, innerHeight)), color);
            }

            // Center.
            if (innerWidth != 0 && innerHeight != 0)
            {
                Center.Draw(spr, new Rectangle(pos + TopLeft.Region.Size, new Point(innerWidth, innerHeight)), color);
            }

            // Center right.
            if (innerHeight != 0)
            {
                CenterRight.Draw(spr, new Rectangle(pos + new Point(TopLeft.Region.Width + innerWidth, TopLeft.Region.Height), new Point(CenterRight.Region.Width, innerHeight)), color);
            }

            // Bottom left.
            BottomLeft.Draw(spr, pos + new Point(0, TopLeft.Region.Height + innerHeight), color);

            // Bottom center.
            if (innerWidth != 0)
            {
                BottomCenter.Draw(spr, new Rectangle(pos + new Point(TopLeft.Region.Width, TopLeft.Region.Height + innerHeight), new Point(innerWidth, BottomCenter.Region.Height)), color);
            }

            // Bottom right.
            BottomRight.Draw(spr, pos + new Point(innerWidth, innerHeight) + TopLeft.Region.Size, color);
        }