Exemple #1
0
        public override void Arrange(Rectangle target)
        {
            Bounds = RemoveMargin(target);
            _border.SetBounds(Bounds);

            var borderBounds = Bounds;

            borderBounds.Width  -= _border.FixedBorder.Horizontal;
            borderBounds.Height -= _border.FixedBorder.Vertical;
            borderBounds.X      += _border.FixedBorder.Left;
            borderBounds.Y      += _border.FixedBorder.Top;

            _spriteText.SetTargetRectangle(borderBounds);
        }
        public override void Arrange(Rectangle target)
        {
            Bounds = RemoveMargin(target);

            _normalSprite.SetBounds(Bounds);
            _hoverSprite.SetBounds(Bounds);

            if (Child != null)
            {
                var rectangle = Bounds;
                rectangle.X      += _normalSprite.FixedBorder.Top;
                rectangle.Y      += _normalSprite.FixedBorder.Left;
                rectangle.Width  -= _normalSprite.FixedBorder.Vertical;
                rectangle.Height -= _normalSprite.FixedBorder.Vertical;
                Child.Arrange(rectangle);
            }
        }
Exemple #3
0
        public override void Arrange(Rectangle target)
        {
            Bounds = RemoveMargin(target);

            var headerSize        = GetHeaderSize();
            var childContentSize  = Child == null ? Rectangle.Empty : Child.GetMinSize();
            var topContentPadding = Math.Max(headerSize.Height / 2, _contentBorder.FixedBorder.Top);

            var contentBorderBounds = new Rectangle(Bounds.X, Bounds.Y + headerSize.Height / 2,
                                                    childContentSize.Width + _contentBorder.FixedBorder.Horizontal,
                                                    childContentSize.Height + _contentBorder.FixedBorder.Bottom + topContentPadding);

            var headerBorderBounds = string.IsNullOrEmpty(Title)
                ? contentBorderBounds
                : new Rectangle(contentBorderBounds.X + contentBorderBounds.Width / 2 - headerSize.Width / 2, Bounds.Y, headerSize.Width,
                                headerSize.Height);

            var contentBounds = childContentSize;

            contentBounds.X = contentBorderBounds.X + _contentBorder.FixedBorder.Left;
            contentBounds.Y = contentBorderBounds.Y + topContentPadding;

            var merged   = Rectangle.Union(contentBorderBounds, headerBorderBounds);
            var arranged = ArrangeToAlignments(Bounds, merged);

            var differenceX = arranged.X - merged.X;
            var differenceY = arranged.Y - merged.Y;

            contentBorderBounds = contentBorderBounds.Translate(differenceX, differenceY);
            contentBounds       = contentBounds.Translate(differenceX, differenceY);
            headerBorderBounds  = headerBorderBounds.Translate(differenceX, differenceY);

            _contentBorder.SetBounds(contentBorderBounds);
            if (Child != null)
            {
                Child.Arrange(contentBounds);
            }
            if (!string.IsNullOrEmpty(Title))
            {
                _headerBorder.SetBounds(headerBorderBounds);
            }
        }
Exemple #4
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (string.IsNullOrEmpty(Text))
            {
                return;
            }

            var bounds   = GetBounds();
            var textSize = Resources.NormalFont.MeasureString(Text);

            var position = new Vector2(bounds.X + bounds.Width * 0.5f - textSize.X * 0.5f,
                                       bounds.Y + bounds.Height * 0.5f - textSize.Y * 0.5f).SnapToPixels();

            spriteBatch.DrawString(Resources.NormalFont, Text, position, Color.White);

            if (State == UiState.Focused)
            {
                _currentSprite.SetBounds(bounds);
                _currentSprite.Draw(spriteBatch);
            }
        }