public override void Draw(GameTime gameTime) { // Draw 呼び出しをサンプリングします。 sampleFrames++; spriteBatch.Begin(); // 背景領域を計算します。 var layout = new DebugLayout(); layout.ContainerBounds = GraphicsDevice.Viewport.TitleSafeArea; layout.Width = (int) fontSize.X + 4; layout.Height = (int) fontSize.Y + 2; layout.HorizontalMargin = 8; layout.VerticalMargin = 8; layout.HorizontalAlignment = HorizontalAlignment; layout.VerticalAlignment = VerticalAlignment; layout.Arrange(); spriteBatch.Draw(fillTexture, layout.ArrangedBounds, BackgroundColor); // 文字列表示領域を計算します。 layout.ContainerBounds = layout.ArrangedBounds; layout.Width = (int) fontSize.X; layout.Height = (int) fontSize.Y; layout.HorizontalMargin = 2; layout.VerticalMargin = 0; layout.HorizontalAlignment = DebugHorizontalAlignment.Center; layout.VerticalAlignment = DebugVerticalAlignment.Center; layout.Arrange(); // 文字色を決定します。 var color = !gameTime.IsRunningSlowly ? ForegroundColor : RunningSlowlyForegroundColor; spriteBatch.DrawString(font, stringBuilder, new Vector2(layout.ArrangedBounds.X, layout.ArrangedBounds.Y), color); spriteBatch.End(); base.Draw(gameTime); }
void DrawHelp() { spriteBatch.Begin(); var layout = new DebugLayout(); // calculate the background area for information. layout.ContainerBounds = GraphicsDevice.Viewport.TitleSafeArea; layout.Width = (int) informationTextFontSize.X + 4; layout.Height = (int) informationTextFontSize.Y + 2; layout.HorizontalMargin = 8; layout.VerticalMargin = 8; layout.HorizontalAlignment = DebugHorizontalAlignment.Left; layout.VerticalAlignment = DebugVerticalAlignment.Top; layout.Arrange(); // draw the rectangle. spriteBatch.Draw(fillTexture, layout.ArrangedBounds, Color.Black * 0.5f); // calculate the text area for help messages. layout.ContainerBounds = layout.ArrangedBounds; layout.Width = (int) informationTextFontSize.X; layout.Height = (int) informationTextFontSize.Y; layout.HorizontalMargin = 2; layout.VerticalMargin = 0; layout.HorizontalAlignment = DebugHorizontalAlignment.Center; layout.VerticalAlignment = DebugVerticalAlignment.Center; layout.Arrange(); // draw the text. BuildInformationMessage(selection.SelectedNodeCount); spriteBatch.DrawString(font, stringBuilder, new Vector2(layout.ArrangedBounds.X, layout.ArrangedBounds.Y), Color.Yellow); // calculate the background area for help messages. layout.ContainerBounds = GraphicsDevice.Viewport.TitleSafeArea; layout.Width = (int) helpMessageFontSize.X + 4; layout.Height = (int) helpMessageFontSize.Y + 2; layout.HorizontalMargin = 8; layout.VerticalMargin = 8; layout.HorizontalAlignment = DebugHorizontalAlignment.Left; layout.VerticalAlignment = DebugVerticalAlignment.Bottom; layout.Arrange(); // draw the rectangle. spriteBatch.Draw(fillTexture, layout.ArrangedBounds, Color.Black * 0.5f); // calculate the text area for help messages. layout.ContainerBounds = layout.ArrangedBounds; layout.Width = (int) helpMessageFontSize.X; layout.Height = (int) helpMessageFontSize.Y; layout.HorizontalMargin = 2; layout.VerticalMargin = 0; layout.HorizontalAlignment = DebugHorizontalAlignment.Center; layout.VerticalAlignment = DebugVerticalAlignment.Center; layout.Arrange(); // draw the text. spriteBatch.DrawString(font, helpMessage, new Vector2(layout.ArrangedBounds.X, layout.ArrangedBounds.Y), Color.Yellow); spriteBatch.End(); }