can't add a controle to the manager

May 11, 2013 at 12:27 PM
Hi there,

i like so much the design and all what the bib give as controles.

here is my mistake, i don't want to add my controles inside the RamGecXnaControles.Window classe, i mean i want to add it directly to the manager, no need to show a window in my game just to make apear a button or image.

here is my code
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using RamGecXNAControls;
using RamGecXNAControls.ExtendedControls;

namespace WindowsGame1
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        GUIManager guiManager;
        Image background;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
        }

        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            guiManager = new GUIManager(this);

            Button myButton = new Button(new Rectangle(0, 0, 0, 0), "My Button Text");
            myButton.Icon = guiManager.Theme.IconHome;
            myButton.OnClick += (sender) => { this.Exit(); };
            guiManager.Controls.Add(myButton);
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            guiManager.Update(gameTime);
            base.Update(gameTime);   
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            guiManager.Draw(spriteBatch);
            spriteBatch.End();
            base.Draw(gameTime);
        }
this code does not show anything, just the game window, but if i add a container like this it work :
Window myWindow = new Window(new Rectangle(10, 10, 300, 200), "Window Title");
guiManager.Controls.Add(myWindow);

Button myButton = new Button(new Rectangle(0, 0, 0, 0), "My Button Text");
myButton.Icon = guiManager.Theme.IconHome;
myButton.OnClick += (sender) => { this.Exit(); };
myWindow.Controls.Add(myButton);
thx in advance
May 11, 2013 at 12:50 PM
Hi,
Well, i've found another solution a bit ugly but it work ^^
i changed the position of the withdow to pos X = -10 and pos Y = -10 and with/height =0 that make a window out of the window.

but i still prefer to be clean as i said in my previouse message.