/// <summary> /// Invalidates the control. /// </summary> public override void Invalidate() { if (m_Texture != null) { m_Texture.Dispose(); m_Texture = null; } base.Invalidate(); }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(Gwen.Skin.Base skin) { if (m_Texture == null) { byte[] pixelData = new byte[Width*Height*4]; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { Color c = GetColorAt(x, y); pixelData[4*(x + y*Width)] = c.R; pixelData[4*(x + y*Width) + 1] = c.G; pixelData[4*(x + y*Width) + 2] = c.B; pixelData[4*(x + y*Width) + 3] = c.A; } } m_Texture = new Texture(skin.Renderer); m_Texture.Width = Width; m_Texture.Height = Height; m_Texture.LoadRaw(Width, Height, pixelData); } skin.Renderer.DrawColor = Color.White; skin.Renderer.DrawTexturedRect(m_Texture, RenderBounds); skin.Renderer.DrawColor = Color.Black; skin.Renderer.DrawLinedRect(RenderBounds); base.Render(skin); }