Ejemplo n.º 1
0
        protected override void Load(EntityGUI.GUIFactory factory)
        {
            //Note: Animations currently have no associated file format so
            //we build them manually in code.


            //Loads two atlases that will be the basis for our animations.
            var webIconsAtlas = this.Resourses.LoadAsset <TextureAtlas>("Atlases\\WebIcons.atlas");
            var osIconsAtlas  = this.Resourses.LoadAsset <TextureAtlas>("Atlases\\OsIcons.atlas");

            //Converts the atlases to arrays of frames.
            var anim0Frames = webIconsAtlas.Select((x) => x.Value).ToArray();
            var anim1Frames = osIconsAtlas.Select((x) => x.Value).ToArray();


            //Creates two animations from the animation frames.
            Animation anim0 = new Animation(anim0Frames, 5);
            Animation anim1 = new Animation(anim1Frames, 3);

            //Creates an animationbox with the anim0 animation.
            AnimationBox box0 = new AnimationBox(anim0);

            box0.Position        = new OpenTK.Vector2(50, 50);
            box0.Size            = new OpenTK.Vector2(256, 256);
            box0.BackgroundColor = Color.Purple * 0.1f;

            this.Panel.AddControl(box0);

            //Creates a second animationbox with the anim0 animation.
            //It should be noted that the animationbox clones the animation
            //so you can use the same animation on multiple boxes.
            AnimationBox box1 = new AnimationBox(anim0);

            box1.Position        = new OpenTK.Vector2(50, box0.Bounds.Bottom + 50);
            box1.Size            = new OpenTK.Vector2(256, 256);
            box1.BackgroundColor = Color.Yellow * 0.1f;

            this.Panel.AddControl(box1);


            AnimationBox box2 = new AnimationBox(anim1);

            box2.Position        = new OpenTK.Vector2(this.Width - 50, 50);
            box2.Size            = new OpenTK.Vector2(256, 256);
            box2.BackgroundColor = Color.Green * 0.1f;

            //Put the origin to the right to simplify placement.
            box2.Origin = Origin.TopRight;

            this.Panel.AddControl(box2);
        }
Ejemplo n.º 2
0
        protected override void Load(EntityGUI.GUIFactory factory)
        {
            this.particleProgram       = this.Resourses.LoadAsset <ShaderProgram>("Sin.effect");
            this.Panel.BackgroundColor = Color.Gray;

            this.Panel.MouseDown += new EventHandler <EntityGUI.MouseButtonEventArgs>(Panel_MouseDown);
            this.Panel.MouseMove += new EventHandler <EntityGUI.MouseMoveEventArgs>(Panel_MouseMove);

            particleAtlas = this.Resourses.LoadAsset <TextureAtlas>("Atlases\\Particles.atlas");


            this.systems = new ParticleSystem[10];
            this.emiters = new Emiter2D[10];
            this.Panel_MouseDown(null, null);
        }
Ejemplo n.º 3
0
        protected override void Load(EntityGUI.GUIFactory factory)
        {
            //An atlas is a large image containing lots of smaller images.
            var webIcons = this.Resourses.LoadAsset <TextureAtlas>("Atlases\\WebIcons.atlas");
            var font     = this.Resourses.LoadAsset <Font>("Fonts\\Metro.fnt");
            var bg       = this.Resourses.LoadAsset <Texture2D>("Backgrounds\\Rainbow-Colors-Wallpaper-wallpapers-28469135-2560-1600.jpg");

            this.Panel.BackgroundImage = new Frame(bg.Bounds, bg);

            //this.Resize += () => this.Panel.Size = new OpenTK.Vector2(500, 500);

            int i = 0;

            foreach (var icon in webIcons)
            {
                //An image box is simply a rectangle that has an image on it.
                ImageBox box = new ImageBox(icon.Value);
                box.Position        = new OpenTK.Vector2(128 + 130 * i, this.Height / 2 - 128);
                box.Size            = new OpenTK.Vector2(128, 128);
                box.BackgroundColor = Color.Blue * 0.3f;
                box.FocusIndex      = i;

                //Drawing the image box from a center position.
                box.Origin = Origin.Center;
                box.Name   = icon.Key + 1;

                //Registers to events on the image box.
                box.FocusGained += EnlargeButton;
                box.FocusLost   += ShrinkButton;
                //Lambda that writes what image box was pressed.
                box.Clicked += (s, e) => Console.WriteLine("WebIcon " + box.Name + " was just pressed");

                this.Panel.AddControl(box);

                //Standard button
                Button button = new Button(font, "Button " + i);
                button.Position        = new OpenTK.Vector2(box.Position.X, box.Position.Y + 130);
                button.Size            = new OpenTK.Vector2(128, 128);
                button.BackgroundColor = Color.Red * 0.5f;
                button.Origin          = Origin.Center;
                button.Icon            = icon.Value;
                button.FocusIndex      = 20 + i;

                button.FocusGained += EnlargeButton;
                button.FocusLost   += ShrinkButton;

                //Lambda that writes what button was pressed.
                button.Clicked += (s, e) => Console.WriteLine(button.Text + " was just pressed");

                this.Panel.AddControl(button);

                ImageBox box2 = new ImageBox(icon.Value);
                box2.Position        = new OpenTK.Vector2(button.Position.X, button.Position.Y + 130);
                box2.Size            = new OpenTK.Vector2(128, 128);
                box2.BackgroundColor = Color.Purple * 0.3f;
                box2.Origin          = Origin.Center;
                box2.Name            = icon.Key + 2;
                box2.FocusIndex      = 40 + i;

                box2.FocusGained += EnlargeButton;
                box2.FocusLost   += ShrinkButton;
                box2.Clicked     += (s, e) => Console.WriteLine("WebIcon " + box2.Name + " was just pressed");

                this.Panel.AddControl(box2);

                i++;
            }
        }
Ejemplo n.º 4
0
        protected override void Load(EntityGUI.GUIFactory factory)
        {
            var font    = this.Resourses.LoadAsset <Font>("Fonts\\Metro.fnt");
            var bigfont = this.Resourses.LoadAsset <Font>("Fonts\\BigMetro.fnt");

            this.Panel.BackgroundColor = Color.Black;

            //Creates a textbox with maxlength 20
            TextBox textBox0 = new TextBox(font, "", 20);

            textBox0.Position = new OpenTK.Vector2(50, 50);

            //It should be noted that a textbox height is always font.size + padding.y + padding.h since it would
            //i did it this way since a textbox of any other height would look bad.
            textBox0.Size = new OpenTK.Vector2(200, 20);

            //A hint is displayed if the textbox is empty.
            textBox0.Hint = "20 char text field!";

            this.Panel.AddControl(textBox0);

            //Creates a textbox with unlimited length.
            TextBox textBox1 = new TextBox(font, "");

            textBox1.BackgroundColor = Color.White;
            textBox1.TextColor       = Color.Red;
            textBox1.Position        = new OpenTK.Vector2(50, textBox0.Bounds.Bottom + 10);
            textBox1.Size            = new OpenTK.Vector2(200, 20);
            textBox1.Hint            = "Unlimited textbox.";

            this.Panel.AddControl(textBox1);

            //Creates a textbox with custom colors.
            TextBox textBox2 = new TextBox(font, "");

            textBox2.BackgroundColor = Color.Green;
            textBox2.TextColor       = Color.Gold;
            textBox2.SelectedColor   = Color.Red;
            textBox2.HintColor       = Color.RosyBrown;
            textBox2.Position        = new OpenTK.Vector2(50, textBox1.Bounds.Bottom + 10);
            textBox2.Size            = new OpenTK.Vector2(200, 20);
            textBox2.Hint            = "Unlimited textbox 2.";

            this.Panel.AddControl(textBox2);

            TextBox textBox3 = new TextBox(bigfont, "", 20);

            textBox3.Position = new OpenTK.Vector2(50, textBox2.Bounds.Bottom + 10);
            textBox3.Size     = new OpenTK.Vector2(300, 20);
            textBox3.Hint     = "Unlimited textbox 2.";

            this.Panel.AddControl(textBox3);

            //Create a numberbox startvalue 100 min 0 max 255
            NumberBox numberBox0 = new NumberBox(font, 100, byte.MinValue, byte.MaxValue);

            numberBox0.Position = new OpenTK.Vector2(50, textBox3.Bounds.Bottom + 10);
            numberBox0.Size     = new OpenTK.Vector2(200, 20);

            this.Panel.AddControl(numberBox0);

            TextArea area = new TextArea(font);

            area.Position = new OpenTK.Vector2(textBox3.Bounds.Right + 20, 50);
            area.Size     = new OpenTK.Vector2(400, 300);
            area.Text     = "This is a text area! This is not fully implemented! Yes true it is.";
            this.Panel.AddControl(area);

            ListBox <int> numbers = new ListBox <int>(font);

            numbers.Position = new OpenTK.Vector2(area.Bounds.Right + 20, 50);
            numbers.Size     = new OpenTK.Vector2(400, 300);

            for (int i = 0; i < 20; i++)
            {
                numbers.AddItem(i);
            }

            this.Panel.AddControl(numbers);
        }