Beispiel #1
0
        public void RefreshSize()
        {
            var w = m_Options.Width;
            var h = m_Options.Height;

            h = Math.Max(h, Math.Max((int)IconSpace.Y, m_MessageText == null ? 0 : m_MessageText.BoundingBox.Height) + 32 + 38);

            if (_ProgressBar != null)
            {
                _ProgressBar.Position = new Vector2(_ProgressBar.Position.X, h + 12);
                h += 47;
            }

            if (Buttons.Count > 0)
            {
                h += 58;
            }
            else
            {
                h += 32;
            }

            if (m_Options.TextEntry)
            {
                TextBox.X = 32;
                TextBox.Y = h - 54;
                TextBox.SetSize(w - 64, 25);
                h += 45;
            }

            if (GenericAddition != null)
            {
                var size = GenericAddition.GetBounds();
                GenericAddition.X = (w - size.Width) / 2;
                GenericAddition.Y = h - 54;
                h += size.Height;
            }

            var buttonMaxWidth = (Buttons.Count == 0)? 0 : Buttons.Max(x => x.Width);
            var buttonSpacing  = (Buttons.Count > 2) ? 5 : 50;

            SetSize(w, h);

            var btnX = (w - ((Buttons.Count * buttonMaxWidth) + ((Buttons.Count - 1) * buttonSpacing))) / 2;
            var btnY = h - 58;

            foreach (UIElement button in Buttons)
            {
                button.Y = btnY;
                button.X = btnX;
                btnX    += buttonMaxWidth + buttonSpacing;
            }
        }