protected override void LoadContent() { SpriteFont Font = Content.Load<SpriteFont>("Courier New"); Form = new Container(GraphicsDevice, new Rectangle(50, 50, 300, 200), Color.Black); Label TestLabel = new Label(Form, new Point(10, 20), Font, Color.Red, "Label"); Button TestButton = new Button(Form, new Rectangle(10, 50, 100, 50), Font, Color.Green, "Button", Color.Red); TestButton.MouseClicked += (object Source, MouseClickedEventArgs Args) => { Console.WriteLine("Button clicked (Mouse: {0})", Args.Button.ToString()); }; CheckBox TestBox = new CheckBox(Form, false, Color.White, Color.Red, Color.Green, new Point(50, 120)); TestBox.ValueChanged += (object Source, CheckBoxEventArgs Args) => { Console.WriteLine("Checkbox value: "+Args.Value); }; TitleBar TestBar = new TitleBar(Form, "TitleBar", Font, Color.Green, Color.Red); ProgressBar TestProgress = new ProgressBar(Form, Color.Red, Color.Green, new Rectangle(150,100,100,20)); TestProgress.MouseClicked += delegate { TestProgress.Progress = Mouse.GetState().X - TestProgress.RealX; Console.WriteLine("ProgressBar: " + TestProgress.Progress); }; TextBox TestText = new TextBox(Form, Font, Color.White, Color.Red, new Rectangle(150, 130, 100, 20), "Hey"); Form.Controls.Add(TestLabel); Form.Controls.Add(TestButton); Form.Controls.Add(TestBox); Form.Controls.Add(TestBar); Form.Controls.Add(TestProgress); Form.Controls.Add(TestText); spriteBatch = new SpriteBatch(GraphicsDevice); }
public PictureBox(Container Parent, Point Position, Texture2D Picture) : base(Parent) { this.X = Position.X; this.Y = Position.Y; this.Picture = Picture; this.Width = Picture.Width; this.Height = Picture.Height; }
public PictureBox(Container Parent, Rectangle Bounds, Texture2D Picture) : base(Parent) { this.X = Bounds.X; this.Y = Bounds.Y; this.Picture = Picture; this.Width = Bounds.Width; this.Height = Bounds.Height; }
public ProgressBar(Container Parent, Texture2D Background, Texture2D Foreground, Rectangle Bounds) : base(Parent) { this.BackgroundTexture = Background; this.ForegroundTexture = Foreground; this.X = Bounds.X; this.Y = Bounds.Y; this.Width = Bounds.Width; this.Height = Bounds.Height; this.Progress = 0; }
public Button(Container Parent, Rectangle Bounds, SpriteFont Font, Color TextColor, string Text, Texture2D ButtonTexture) : base(Parent) { this.Font = Font; this.TextColor = TextColor; this.Text = Text; this.X = Bounds.X; this.Y = Bounds.Y; this.Width = Bounds.Width; this.Height = Bounds.Height; this.ButtonTexture = ButtonTexture; }
public ProgressBar(Container Parent, Color BackgroundColor, Texture2D Foreground, Rectangle Bounds) : base(Parent) { Texture2D Blank = new Texture2D(Parent.Main, 1, 1); Blank.SetData<Color>(new Color[] { BackgroundColor }); this.BackgroundTexture = Blank; this.ForegroundTexture = Foreground; this.X = Bounds.X; this.Y = Bounds.Y; this.Width = Bounds.Width; this.Height = Bounds.Height; this.Progress = 0; }
public Button(Container Parent, Rectangle Bounds, SpriteFont Font, Color TextColor, string Text, Color ButtonColor) : base(Parent) { this.Font = Font; this.TextColor = TextColor; this.Text = Text; this.X = Bounds.X; this.Y = Bounds.Y; this.Width = Bounds.Width; this.Height = Bounds.Height; Texture2D Blank = new Texture2D(Parent.Main, 1, 1); Blank.SetData<Color>(new Color[] { ButtonColor }); this.ButtonTexture = Blank; }
public TextBox(Container Parent, SpriteFont Font, Texture2D BoxTexture, Color TextColor, Rectangle Bounds, string Text) : base(Parent) { this.Font = Font; this.BoxTexture = BoxTexture; this.TextColor = TextColor; this.HasFocus = false; this.X = Bounds.X; this.Y = Bounds.Y; this.Width = Bounds.Width; this.Height = Bounds.Height; this.Text = Text; this.PreviousState = Keyboard.GetState(); this.MouseClicked += (object Source, MouseClickedEventArgs Args) => { if (Args.Button == MouseButton.Left) HasFocus = true; }; }
public TitleBar(Container Parent, string Title, SpriteFont Font, Texture2D Texture, Color TextColor, bool InsideContainer = false) : base(Parent) { this.Font = Font; this.Title = Title; this.X = 0; this.Width = Parent.Width; this.Height = (int)Font.MeasureString(Title).Y; this.Texture = Texture; this.TextColor = TextColor; if (InsideContainer) this.Y = 0; else this.Y = -Height; this.MouseClicked += (object Source, MouseClickedEventArgs Args) => { if (Args.Button == MouseButton.Left) { Moving = true; DragOffset = new Point(Mouse.GetState().X - Parent.X, Mouse.GetState().Y - Parent.Y); } }; }
public CheckBox(Container Parent, bool InitialValue, Color BoxColor, Color IndicatorColor, Color BorderColor, Point Position) : base(Parent) { this.Checked = InitialValue; this.BoxColor = BoxColor; this.IndicatorColor = IndicatorColor; this.BorderColor = BorderColor; this.X = Position.X; this.Y = Position.Y; this.Width = 10; this.Height = 10; Texture2D Blank = new Texture2D(Parent.Main, 1, 1); Blank.SetData<Color>(new Color[] { Color.White }); this.Blank = Blank; this.MouseClicked += (object Source, MouseClickedEventArgs Args) => { if (Args.Button == MouseButton.Left) Checked = !Checked; }; this.PreviousState = Checked; }
public TitleBar(Container Parent, int Height, SpriteFont Font, Color BarColor, Color TextColor, bool InsideContainer = false) : base(Parent) { this.Font = Font; this.Title = Title; this.X = 0; this.Width = Parent.Width; this.Height = Height; this.TextColor = TextColor; if (InsideContainer) this.Y = 0; else this.Y = -Height; Texture2D Blank = new Texture2D(Parent.Main, 1, 1); Blank.SetData<Color>(new Color[] { BarColor }); Texture = Blank; this.MouseClicked += (object Source, MouseClickedEventArgs Args) => { if (Args.Button == MouseButton.Left) { Moving = true; DragOffset = new Point(Mouse.GetState().X - Parent.X, Mouse.GetState().Y - Parent.Y); } }; }
public Control(Container Parent) { this.Parent = Parent; this.Active = true; PreviousMouseState = Mouse.GetState(); }