51 lines
2.1 KiB
C#
51 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
namespace MrAG
|
|
{
|
|
public partial class Gui
|
|
{
|
|
public class GroupBox : Base
|
|
{
|
|
public string Text = "";
|
|
public SpriteFont Font = MrAG.Draw.Font;
|
|
|
|
public Color TextColor = Color.Black;
|
|
public Color LineColor = Color.Green;
|
|
public Color BackColor = Color.White;
|
|
|
|
public bool DrawLines = true;
|
|
public int LineSize = 2;
|
|
public int TextSpace = 5;
|
|
public int Padding = 2;
|
|
|
|
public override void Draw()
|
|
{
|
|
MrAG.Draw.Box(this.X, this.Y, this.Width, this.Height, this.BackColor);
|
|
|
|
if (DrawLines) {
|
|
Vector2 s = this.Font.MeasureString(this.Text);
|
|
|
|
MrAG.Draw.Box(this.X + this.Padding, this.Y + this.Padding, this.Padding * 2, this.LineSize, this.LineColor); // u1
|
|
MrAG.Draw.Box(this.X + this.Padding + (int)s.X + (this.TextSpace * 2), this.Y + this.Padding, this.Width - (this.Padding * 2) - (this.TextSpace * 2) - (int)s.X, this.LineSize, this.LineColor); // u2
|
|
|
|
MrAG.Draw.Box(this.X + this.Padding, this.Y + this.Padding, this.LineSize, this.Height - (this.Padding * 2), this.LineColor); // l
|
|
MrAG.Draw.Box(this.X + this.Width - this.Padding - this.LineSize, this.Y + this.Padding, this.LineSize, this.Height - (this.Padding * 2), this.LineColor); // r
|
|
MrAG.Draw.Box(this.X + this.Padding, this.Y + this.Height - this.Padding - this.LineSize, this.Width - (this.Padding * 2), this.LineSize, this.LineColor); // d
|
|
}
|
|
|
|
if (this.Text.Length > 0) {
|
|
MrAG.Draw.SetFont(this.Font);
|
|
MrAG.Draw.Text(this.Text, this.X + this.Padding + this.TextSpace, this.Y + this.Padding, this.TextColor, MrAG.Draw.TextAlignmentX.Left, MrAG.Draw.TextAlignmentY.Center, 0);
|
|
}
|
|
|
|
base.Draw();
|
|
}
|
|
}
|
|
}
|
|
}
|