private void Load(TextureRegion[] patches)
{
Color color = Color.White;
if (patches[BottomLeft] != null) {
_bottomLeft = Add(patches[BottomLeft], color);
LeftWidth = patches[BottomLeft].RegionWidth;
BottomHeight = patches[BottomLeft].RegionHeight;
}
if (patches[BottomCenter] != null) {
_bottomCenter = Add(patches[BottomCenter], color);
MiddleWidth = Math.Max(MiddleWidth, patches[BottomCenter].RegionWidth);
BottomHeight = Math.Max(BottomHeight, patches[BottomCenter].RegionHeight);
}
if (patches[BottomRight] != null) {
_bottomRight = Add(patches[BottomRight], color);
RightWidth = Math.Max(RightWidth, patches[BottomRight].RegionWidth);
BottomHeight = Math.Max(BottomHeight,patches[BottomRight].RegionHeight);
}
if (patches[MiddleLeft] != null) {
_middleLeft = Add(patches[MiddleLeft], color);
LeftWidth = Math.Max(LeftWidth, patches[MiddleLeft].RegionWidth);
MiddleHeight = Math.Max(MiddleHeight, patches[MiddleLeft].RegionHeight);
}
if (patches[MiddleCenter] != null) {
_middleCenter = Add(patches[MiddleCenter], color);
MiddleWidth = Math.Max(MiddleWidth, patches[MiddleCenter].RegionWidth);
MiddleHeight = Math.Max(MiddleHeight, patches[MiddleCenter].RegionHeight);
}
if (patches[MiddleRight] != null) {
_middleRight = Add(patches[MiddleRight], color);
RightWidth = Math.Max(RightWidth, patches[MiddleRight].RegionWidth);
MiddleHeight = Math.Max(MiddleHeight, patches[MiddleRight].RegionHeight);
}
if (patches[TopLeft] != null) {
_topLeft = Add(patches[TopLeft], color);
LeftWidth = Math.Max(LeftWidth, patches[TopLeft].RegionWidth);
TopHeight = Math.Max(TopHeight, patches[TopLeft].RegionHeight);
}
if (patches[TopCenter] != null) {
_topCenter = Add(patches[TopCenter], color);
MiddleWidth = Math.Max(MiddleWidth, patches[TopCenter].RegionWidth);
TopHeight = Math.Max(TopHeight, patches[TopCenter].RegionHeight);
}
if (patches[TopRight] != null) {
_topRight = Add(patches[TopRight], color);
RightWidth = Math.Max(RightWidth, patches[TopRight].RegionWidth);
TopHeight = Math.Max(TopHeight, patches[TopRight].RegionHeight);
}
if (_index < _vertices.Length) {
VertexPositionColorTexture[] newVertices = new VertexPositionColorTexture[_index];
Array.Copy(_vertices, newVertices, _index);
_vertices = newVertices;
}
}