Willcraftia.Xna.Framework.Diagnostics.DebugLayout.Arrange C# (CSharp) Method

Arrange() public method

設定されたフィールドの情報に基づき、ArrangedBounds フィールドを計算します。
public Arrange ( ) : void
return void
        public void Arrange()
        {
            switch (HorizontalAlignment)
            {
                case DebugHorizontalAlignment.Left:
                    {
                        ArrangedBounds.X = ContainerBounds.X + HorizontalMargin;
                        break;
                    }
                case DebugHorizontalAlignment.Right:
                    {
                        ArrangedBounds.X = ContainerBounds.X + ContainerBounds.Width - HorizontalMargin - Width;
                        break;
                    }
                case DebugHorizontalAlignment.Center:
                default:
                    {
                        ArrangedBounds.X = ContainerBounds.X + (ContainerBounds.Width - Width) / 2;
                        break;
                    }
            }

            switch (VerticalAlignment)
            {
                case DebugVerticalAlignment.Top:
                    {
                        ArrangedBounds.Y = ContainerBounds.Y + VerticalMargin;
                        break;
                    }
                case DebugVerticalAlignment.Bottom:
                    {
                        ArrangedBounds.Y = ContainerBounds.Y + ContainerBounds.Height - VerticalMargin - Height;
                        break;
                    }
                case DebugVerticalAlignment.Center:
                default:
                    {
                        ArrangedBounds.Y = ContainerBounds.Y + (ContainerBounds.Height - Height) / 2;
                        break;
                    }
            }

            ArrangedBounds.Width = Width;
            ArrangedBounds.Height = Height;
        }

Usage Example

Beispiel #1
0
        protected override void LoadContent()
        {
            var titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea;

            // 表示幅を TitleSafeArea から余白を考慮した値に設定。
            width = titleSafeArea.Width - 16;

            // 表示位置を計算。
            // 高さはバーの数で変動するため、Bottom 合わせで固定し、Bottom ラインをベースに描画時に調整。
            var layout = new DebugLayout()
            {
                ContainerBounds     = titleSafeArea,
                Width               = width,
                Height              = 0,
                HorizontalMargin    = 8,
                VerticalMargin      = 8,
                HorizontalAlignment = DebugHorizontalAlignment.Center,
                VerticalAlignment   = DebugVerticalAlignment.Bottom
            };

            layout.Arrange();

            offsetX = layout.ArrangedBounds.X;
            offsetY = layout.ArrangedBounds.Y;

            spriteBatch = new SpriteBatch(GraphicsDevice);
            fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice);
            spriteFont  = Game.Content.Load <SpriteFont>(fontAssetName);

            base.LoadContent();
        }
All Usage Examples Of Willcraftia.Xna.Framework.Diagnostics.DebugLayout::Arrange
DebugLayout