internal override void Draw(DrawHelper helper, Vector2 offset) { var rectangle = HitBox; rectangle.Offset(offset); var start = Location + offset; var topLeftOffset = Vector2.Zero; var topRightOffset = Vector2.Zero; var hover = IsHovering ? new Color(255, 255, 255, 240) : Color.White; var blend = IsPressed ? new Color(205, 205, 205, 230) : hover; if (!string.IsNullOrEmpty(BtnLeftTexture)) { topLeftOffset = helper.DrawTextureWithOffset(start, BtnLeftTexture, blend); } if (!string.IsNullOrEmpty(BtnRightTexture)) { topRightOffset = helper.DrawTextureWithOffset(start + new Vector2(Size.X, 0), BtnRightTexture, blend, DrawHelper.AlignOffset.TopRight); } if (string.IsNullOrEmpty(BtnMiddleTexture)) { helper.DrawRectangle(rectangle, BackgroundColor.Blend(blend)); } else { helper.DrawTextureRepeat(start + new Vector2(topLeftOffset.X, 0), start + new Vector2(Size.X - topRightOffset.X, topLeftOffset.Y), BtnMiddleTexture, blend); } var txtSize = helper.MeasureString(FontName, Text); helper.DrawString(this, Location + AlignmentHelper.Align(Size, txtSize, TextAlign) + offset, Text, TextColor, Zoom); }
internal override void Draw(DrawHelper helper, Vector2 offset) { if (!IsVisible) { return; } var topLeftOffset = Vector2.Zero; var topRightOffset = Vector2.Zero; var bottomLeftOffset = Vector2.Zero; var bottomRightOffset = Vector2.Zero; if (!string.IsNullOrEmpty(WinTopLeftTexture)) { topLeftOffset = helper.DrawTextureWithOffset(Location, WinTopLeftTexture); } if (!string.IsNullOrEmpty(WinTopRightTexture)) { topRightOffset = helper.DrawTextureWithOffset(Location + new Vector2(Size.X, 0), WinTopRightTexture, DrawHelper.AlignOffset.TopRight); } if (!string.IsNullOrEmpty(WinBottomLeftTexture)) { bottomLeftOffset = helper.DrawTextureWithOffset(Location + new Vector2(0, Size.Y), WinBottomLeftTexture, DrawHelper.AlignOffset.BottomLeft); } if (!string.IsNullOrEmpty(WinBottomRightTexture)) { bottomRightOffset = helper.DrawTextureWithOffset(Location + new Vector2(Size.X, Size.Y), WinBottomRightTexture, DrawHelper.AlignOffset.BottomRight); } //Top if (!string.IsNullOrEmpty(WinTopTexture)) { helper.DrawTextureRepeat(Location + new Vector2(topLeftOffset.X, 0), Location + new Vector2(Size.X - topRightOffset.X, topLeftOffset.Y), WinTopTexture); } //Bottom if (!string.IsNullOrEmpty(WinBottomTexture)) { helper.DrawTextureRepeat(Location + new Vector2(topLeftOffset.X, Size.Y - bottomLeftOffset.Y), Location + new Vector2(Size.X - topRightOffset.X, Size.Y), WinBottomTexture); } //Left if (!string.IsNullOrEmpty(WinLeftTexture)) { helper.DrawTextureRepeat(Location + new Vector2(0, topLeftOffset.Y), Location + new Vector2(topLeftOffset.X, Size.Y - bottomLeftOffset.Y), WinLeftTexture); } //Right if (!string.IsNullOrEmpty(WinRightTexture)) { helper.DrawTextureRepeat(Location + new Vector2(Size.X - topRightOffset.X, topLeftOffset.Y), Location + new Vector2(Size.X, Size.Y - bottomLeftOffset.Y), WinRightTexture); } //Fill var rectangle = new Rectangle((int)(Location.X + topLeftOffset.X), (int)(Location.Y + topLeftOffset.Y), (int)(Size.X - topLeftOffset.X - topRightOffset.X), (int)(Size.Y - topLeftOffset.Y - bottomLeftOffset.Y)); helper.DrawRectangle(rectangle, BackgroundColor); helper.DrawString(this, Location + new Vector2(10, 6), Title, Color.White); foreach (var control in Controls) { if (control.IsVisible) { control.Draw(helper, Location); } } }