/// <summary> /// Render /// </summary> /// <param name="batch"></param> public override void Draw(UISpriteBatch batch) { if (m_Slider != null) { m_Slider.Visible = Visible; } if (!Visible) { return; } if (m_DrawDirty) { ComputeDrawingCommands(); } /** Can have a text box without a background **/ if (m_BackgroundTex != null && NineSliceMargins != null) { NineSliceMargins.DrawOnto(batch, this, m_BackgroundTex, m_Width, m_Height); } if (m_BackgroundTexRef != null) { m_BackgroundTexRef.Draw(batch, this, 0, 0, m_Width, m_Height); } /** * Draw border */ if (m_frameBlinkOn && m_frameBlink) { DrawingUtils.DrawBorder(batch, LocalRect(0, 0, m_Width, m_Height), 1, m_FrameTexture, m_FrameColor); } /** * Draw text */ foreach (var cmd in m_DrawCmds) { cmd.Draw(this, batch); } }
public override void Draw(UISpriteBatch SBatch) { if (!Visible) { return; } if (NineSlice) { if (m_Texture == null) { return; } /** * We need to draw 9 pieces */ /** TL **/ DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.TL, Vector2.Zero); /** TC **/ DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.TC, new Vector2(NineSliceMargins.Left, 0), NineSliceMargins.TC_Scale); /** TR **/ DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.TR, new Vector2(Width - NineSliceMargins.Right, 0)); /** ML **/ DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.ML, new Vector2(0, NineSliceMargins.Top), NineSliceMargins.ML_Scale); /** MC **/ DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.MC, new Vector2(NineSliceMargins.Left, NineSliceMargins.Top), NineSliceMargins.MC_Scale); /** MR **/ DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.MR, new Vector2(Width - NineSliceMargins.Right, NineSliceMargins.Top), NineSliceMargins.MR_Scale); /** BL **/ var bottomY = Height - NineSliceMargins.Bottom; DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.BL, new Vector2(0, bottomY)); /** BC **/ DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.BC, new Vector2(NineSliceMargins.Left, bottomY), NineSliceMargins.BC_Scale); /** BR **/ DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.BR, new Vector2(Width - NineSliceMargins.Right, bottomY)); } else if (m_TextureRef != null) { m_TextureRef.Draw(SBatch, this, 0, 0, m_Width, m_Height); } else { if (m_Texture == null) { return; } if (m_Width != 0 && m_Height != 0) { DrawLocalTexture(SBatch, m_Texture, null, Vector2.Zero, new Vector2(m_Width / m_Texture.Width, m_Height / m_Texture.Height)); } else { DrawLocalTexture(SBatch, m_Texture, Vector2.Zero); } } }