public void RocketCommanderGame_Mouse_Test()
        {
            var game = new TestGame();

            Layout layout = null;
            game.Initialized += (o, e) =>
                {
                    layout = new Layout("MouseState", game.Framework.AssetManager)
                    {
                        DestRect = new Rectangle(0.0f, 0.1f, 1.0f, 1.0f)
                    };

                    var mouseBlock = new TextBlock(layout, game.Framework.AssetManager)
                    {
                        Font = game.Framework.AssetManager.DefaultFont,
                        Foreground = Color.Red,
                        Name = "MouseBlock"
                    };

                    game.AddLayout(layout);
                };
            game.Mouse.MouseMove += (o, e) =>
                {
                    var mouseBlock = layout.GetElement("MouseBlock") as TextBlock;
                    mouseBlock.Text = game.Mouse.Position.ToString();
                };

            game.Run();
        }
Example #2
0
        public void Layout_Test()
        {
            var game = new TestGame();
            Layout layout = null;
            game.Updated += (o, e) =>
                {
                    game.DebugText += "\n\nPress key 1~ to watch each layout";

                    string[] layoutNames =
                    {
                        @"RocketCommander\GUI\MainMenu.layout",
                        @"RocketCommander\GUI\Help.layout",
                        @"RocketCommander\GUI\MissionSelection.layout"
                    };
                    for (int i = 0; i < layoutNames.Length; ++i)
                    {
                        if (game.Keyboard.IsKeyDown(Key.D1 + i) == false)
                            continue;

                        if (layout != null)
                            game.RemoveLayout(layout);

                        layout = game.Framework.AssetManager.Load(layoutNames[i]) as Layout;
                        game.AddLayout(layout);
                    }
                };
            game.Run();
        }