Ejemplo n.º 1
0
        public override void Update(double secondsElapsed, InputUtilities keyUtils, SharpDX.Vector2 cursorPoint, bool checkMouse = false)
        {
            base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse);
            if (this.Visible)
            {
                this.ContentLayout.ApplyLayout(this);
                float width = 0, height = 0;
                Control <SharpDXRenderer, Color, Vector2, TextFormat> lastControl = null;

                for (int i = 0; i < this.ChildControls.Count; i++)
                {
                    var control = this.ChildControls[i];
                    if (!control.Visible)
                    {
                        continue;
                    }

                    lastControl = control;
                    if (this.DynamicWidth)
                    {
                        if (control.Width + control.MarginLeft + control.MarginRight > width)
                        {
                            width = control.Width + control.MarginLeft + control.MarginRight;
                        }
                    }
                }

                if (this.DynamicHeight)
                {
                    if (ChildControls.Count(x => x.Visible) > 0)
                    {
                        height = ChildControls.Where(x => x.Visible).Max(x => x.Y + x.Height);
                    }
                }
                //if (lastControl != null)
                //    height = lastControl.Y + lastControl.Height + lastControl.MarginBottom;
                if (this.DynamicWidth)
                {
                    this.Width = width + this.MarginLeft + this.MarginRight;
                }
                if (this.DynamicHeight)
                {
                    this.Height = height + this.MarginBottom;
                }
            }
            else
            {
                this.Height = 0;
            }
        }