Exemplo n.º 1
0
        /// <summary>
        /// Registers a new Panel to draw
        /// </summary>
        /// <param name="panel"></param>
        public void RegisterPanel(UIPanel panel)
        {
            //Maybe Panels should register here which Events they are interested in (Mouse, Keyboard)

            //Calculate Positions for added Panel
            CalculatePosition(panel);

            _panels.Add(panel);
        }
Exemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            Logger.Debug("Create GUI Elements");
            //Create Test User Interface
            UIPanel panel = new UIPanel { VerticalPosition = UIVerticalPosition.Bottom, Height = 400 };
            //Create Container for 2 TestButtons
            UIVerticalContainer vContainer = new UIVerticalContainer { HorizontalPosition = UIHorizontalPosition.Left, VerticalPosition = UIVerticalPosition.Top };
            vContainer.add(new UiButton { Text = "Hallo Welt", HorizontalPosition = UIHorizontalPosition.Center });
            UiButton exitButton = new UiButton { Text = "Exit Game", HorizontalPosition = UIHorizontalPosition.Center };
            exitButton.Clicked += OnExitGameClick;
            vContainer.add(exitButton);

            panel.setContainingPanel(vContainer);

            //Add Panel to UiController
            UiController.RegisterPanel(panel);

            //Register Scene
            IScene scene = new BlockTestScene(this);
            addScene("blockTest", scene);
            switchScene("blockTest");
        }
Exemplo n.º 3
0
        private void CalculatePosition(UIPanel panel)
        {
            if (panel.Width == 0)
            {
                panel.Width = _engine.Width;
            }

            if (panel.Height == 0)
            {
                panel.Height = _engine.Height;
            }

            panel.StartX = PositionHelper.CalculateStartX(panel, _engine.Width);
            panel.StartY = PositionHelper.CalculateStartY(panel, _engine.Height);

            //At the end call the panels own resize method to calculate positions for his Children
            panel.Resize();
        }