public virtual void DrawUnder(IRenderTarget renderTarget) { if (this.BackgroundColor != null) renderTarget.Fill(new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height), this.BackgroundColor.Value); if (Skinnable != null) { Rectangle region; ITexture texture; switch (State) { case ControlState.Base: if (!this.Active) { region = Skinnable.TextureBaseRegion; texture = this.TextureBase; } else { region = Skinnable.TextureBaseActiveRegion; texture = this.TextureBaseActive; } break; case ControlState.Disabled: if (!this.Active) { region = Skinnable.TextureDisabledRegion; texture = this.TextureDisabled; } else { region = Skinnable.TextureDisabledActiveRegion; texture = this.TextureDisabledActive; } break; case ControlState.Hover: if (!this.Active) { region = Skinnable.TextureHoverRegion; texture = this.TextureHover; } else { region = Skinnable.TextureHoverActiveRegion; texture = this.TextureHoverActive; } break; case ControlState.Down: if (!this.Active) { region = Skinnable.TextureDownRegion; texture = this.TextureDown; } else { region = Skinnable.TextureDownActiveRegion; texture = this.TextureDownActive; } break; default: region = new Rectangle(0, 0, 0, 0); texture = null; break; } if (texture != null) { region = new Rectangle(0, 0, texture.Width, texture.Height); } else { texture = GUI.Instance.Skin.SkinTexture.Texture; } if (Skinnable.SubRegions.Length != 1) { for (int i = 0; i < Skinnable.SubRegions.Length; i++) { renderTarget.DrawStretched(texture, subRegionsStretched[i], new Rectangle( region.X + Skinnable.SubRegions[i].X, region.Y + Skinnable.SubRegions[i].Y, Skinnable.SubRegions[i].Width, Skinnable.SubRegions[i].Height)); } } else { renderTarget.DrawStretched(texture, new Rectangle(0, 0, Bounds.Width, Bounds.Height), region); } } }