Customizing the Forms background

Lets face it, out of the box, the Forms are pretty ugly. You'll want to add some customization to them in order to make them look better. Luckily, that's simple to do.

The default color of a Form is a gray color. Let's change it to Brown with the following example.

        protected override void Initialize()
        {
            StandardForm form = new StandardForm(this, "New Form");
            this.Components.Add(form);

            base.Initialize();

            form.SetBackgroundColor(Color.Brown);
            form.Show();
        }

Changing the background can be useful if you want to use the Form as a fullscreen back drop to your game menu like the following picture.
fullscreen.png

Now what if you have a texture that you've created and want to set as your background? You can do that too! Instead of calling SetBackgroundColor() you call SetBackgroundMaterial().

        protected override void Initialize()
        {
            StandardForm form = new StandardForm(this, "New Form");
            this.Components.Add(form);

            base.Initialize();

            form.HasTitleBar = false;
            form.Text = String.Empty;
            form.SetBackgroundMaterial("MenuBackgroundExample");
            form.Show();
        }

Using an example picture, the end result is shown below.
BackgroundExample.png

Here we disabled the title bar and cleared the title text, but notice how the Form is still pretty small? We can fix that and make it full screen just like the previous picture by calling SetFullscreen().

        protected override void Initialize()
        {
            StandardForm form = new StandardForm(this, "New Form");
            this.Components.Add(form);

            base.Initialize();

            form.HasTitleBar = false;
            form.Text = String.Empty;

            //Set the form to fullscreen
            form.SetFullScreen(true);
            form.SetBackgroundMaterial("MenuBackgroundExample");
            form.Show();
        }

fullscreen2.png

Pretty simple right? Finally, if you create a background material with a transparent background, you can create a menu that is overlayed on top of a 2D or 3D scene.
fullscreen3.png

Last edited Jan 19, 2012 at 11:04 PM by Scionwest, version 7

Comments

No comments yet.