예제 #1
0
        /// <summary>Draws an entire GUI hierarchy</summary>
        /// <param name="screen">Screen containing the GUI that will be drawn</param>
        public void Draw(GuiScreen screen)
        {
            _flatGuiGraphics.BeginDrawing();
            try
            {
                _controlStack.Push(ControlWithBounds.FromScreen(screen));

                while (_controlStack.Count > 0)
                {
                    var controlWithBounds = _controlStack.Pop();

                    var currentControl = controlWithBounds.Control;
                    var currentBounds  = controlWithBounds.Bounds;

                    // Add the controls in normal order, so the first control in the collection will
                    // be taken off the stack last, ensuring it's rendered on top of all others.
                    for (var index = 0; index < currentControl.Children.Count; ++index)
                    {
                        _controlStack.Push(ControlWithBounds.FromControl(currentControl.Children[index], currentBounds));
                    }

                    RenderControl(currentControl);
                }
            }
            finally
            {
                _flatGuiGraphics.EndDrawing();
            }
        }
예제 #2
0
        /// <summary>Draws an entire GUI hierarchy</summary>
        /// <param name="screen">Screen containing the GUI that will be drawn</param>
        public void Draw(MainScreen screen)
        {
            this.flatGuiGraphics.BeginDrawing();
            try
            {
                this.controlStack.Push(ControlWithBounds.FromScreen(screen));

                while (controlStack.Count > 0)
                {
                    ControlWithBounds controlWithBounds = this.controlStack.Pop();

                    Controls.Control currentControl = controlWithBounds.Control;
                    RectangleF       currentBounds  = controlWithBounds.Bounds;

                    // Add the controls in normal order, so the first control in the collection will
                    // be taken off the stack last, ensuring it's rendered on top of all others.
                    for (int index = 0; index < currentControl.Children.Count; ++index)
                    {
                        Control control2Render = currentControl.Children[index];
                        if (control2Render.IsVisible)
                        {
                            this.controlStack.Push(ControlWithBounds.FromControl(control2Render, currentBounds));
                        }
                    }

                    if (currentControl.IsRendable)
                    {
                        renderControl(currentControl);
                    }
                }
            }
            finally
            {
                this.flatGuiGraphics.EndDrawing();
            }
        }