コード例 #1
0
 public IBoxTexture ProcessTexture(IBoxTexture texture)
 {
     return((IBoxTexture)ProcessTexture((IUITexture)texture));
 }
コード例 #2
0
 public IBoxTexture ProcessTexture(IBoxTexture texture)
 {
     return(texture);
 }
コード例 #3
0
        public static void DrawBox([NotNull] this IBatchedDrawingService ds,
                                   [CanBeNull] IBoxTexture tex,
                                   Rectangle layoutArea,
                                   Color color)
        {
            if (tex == null)
            {
                return;
            }

            var boxArea = layoutArea.ReduceRectBy(tex.Margins);

            var corners = tex.CornerArea;

            if (corners.Top > 0)
            {
                if (corners.Left > 0)
                {
                    DrawImageFromAtlas(ds, tex,
                                       new Rectangle(boxArea.Left, boxArea.Top, corners.Top, corners.Left),
                                       tex.Bounds.ClipBy(new Rectangle(0, 0, corners.Top, corners.Left)),
                                       color);
                }

                if (corners.Right > 0)
                {
                    DrawImageFromAtlas(
                        ds,
                        tex,
                        new Rectangle(boxArea.Right - corners.Right, boxArea.Top, corners.Right, corners.Top),
                        tex.Bounds.ClipBy(new Rectangle(tex.Width - corners.Right, 0, corners.Right, corners.Top)),
                        color);
                }

                DrawImageFromAtlas(
                    ds,
                    tex,
                    new Rectangle(boxArea.Left + corners.Left, boxArea.Top, boxArea.Width - corners.Horizontal, corners.Top),
                    tex.Bounds.ClipBy(new Rectangle(corners.Left, 0, tex.Width - corners.Horizontal, corners.Top)),
                    color);
            }
            if (corners.Bottom > 0)
            {
                if (corners.Left > 0)
                {
                    DrawImageFromAtlas(
                        ds,
                        tex,
                        new Rectangle(boxArea.Left, boxArea.Bottom - corners.Bottom, corners.Left, corners.Bottom),
                        tex.Bounds.ClipBy(new Rectangle(0, tex.Height - corners.Bottom, corners.Left, corners.Bottom)),
                        color);
                }
                if (corners.Right > 0)
                {
                    DrawImageFromAtlas(
                        ds,
                        tex,
                        new Rectangle(boxArea.Right - corners.Right, boxArea.Bottom - corners.Bottom, corners.Right,
                                      corners.Bottom),
                        tex.Bounds.ClipBy(new Rectangle(tex.Width - corners.Right, tex.Height - corners.Bottom, corners.Right, corners.Bottom)),
                        color);
                }

                DrawImageFromAtlas(
                    ds,
                    tex,
                    new Rectangle(boxArea.Left + corners.Left, boxArea.Bottom - corners.Bottom,
                                  boxArea.Width - corners.Horizontal, corners.Bottom),
                    tex.Bounds.ClipBy(new Rectangle(corners.Left, tex.Height - corners.Bottom, tex.Width - corners.Horizontal, corners.Bottom)),
                    color);
            }

            if (corners.Left > 0)
            {
                DrawImageFromAtlas(
                    ds,
                    tex,
                    new Rectangle(boxArea.Left, boxArea.Top + corners.Top, corners.Left, boxArea.Height - corners.Vertical),
                    tex.Bounds.ClipBy(new Rectangle(0, corners.Left, corners.Top, tex.Height - corners.Vertical)),
                    color);
            }
            if (corners.Right > 0)
            {
                DrawImageFromAtlas(
                    ds,
                    tex,
                    new Rectangle(boxArea.Right - corners.Right, boxArea.Top + corners.Top, corners.Right,
                                  boxArea.Height - corners.Vertical),
                    tex.Bounds.ClipBy(new Rectangle(tex.Width - corners.Right, corners.Top, corners.Right, tex.Height - corners.Vertical)),
                    color);
            }

            // Content
            DrawImageFromAtlas(
                ds,
                tex,
                new Rectangle(boxArea.Left + corners.Left, boxArea.Top + corners.Top, boxArea.Width - corners.Horizontal,
                              boxArea.Height - corners.Vertical),
                tex.Bounds.ClipBy(new Rectangle(corners.Left, corners.Top, tex.Width - corners.Horizontal, tex.Height - corners.Vertical)),
                color);
        }