internal InfoBar(ISpriteBatch spriteBatch, ISpriteFont spriteFont) { _spriteBatch = spriteBatch; _spriteFont = spriteFont; FontColor = Color.LightBlue; }
private static string WrapText(ISpriteFont font, string text, double maxLineWidth) { const string Space = " "; var stringBuilder = new StringBuilder(); string[] words = WhiteSpaceRegEx.Split(text); double lineWidth = 0; double spaceWidth = font.MeasureString(Space).Width; foreach (string word in words) { Size size = font.MeasureString(word); if (lineWidth + size.Width < maxLineWidth) { stringBuilder.AppendFormat("{0}{1}", lineWidth == 0 ? string.Empty : Space, word); lineWidth += size.Width + spaceWidth; } else { stringBuilder.AppendFormat("\n{0}", word); lineWidth = size.Width + spaceWidth; } } return(stringBuilder.ToString()); }
protected override ITextGraphicComponent CreateTextComponent(ISpriteFont font) { var component = new TextGraphicComponentMock(); CreatedComponents.Add(component); return component; }
public void DrawString(ISpriteFont spriteFont, string text, Vector2 position, Color color) { if (spriteFont != null) { _spriteBatch.DrawString(spriteFont.SpriteFont, text, position, color); } }
public SpriteFontJob(ISpriteFont spriteFont, string text, Point position, Brush brush) { this.spriteFont = spriteFont; this.text = text; this.position = position; this.brush = brush; }
public MultlineTextBox(ISpriteFont font, ITextSplitter splitter, int lineNumber) { this.lineNumber = lineNumber; this.font = font; this.splitter = splitter; container = new Container(); container.Layout = new VBoxLayout(); }
public TextBlock(ISpriteFont spriteFont) { if (spriteFont == null) { throw new ArgumentNullException("spriteFont"); } this.spriteFont = spriteFont; }
public void DrawString(ISpriteFont spriteFont, string text, Point position, Color color) { var spriteFontAdapter = spriteFont as SpriteFontAdapter; if (spriteFontAdapter != null && spriteFontAdapter.Value != null) { this.spriteBatch.DrawString( spriteFontAdapter.Value, text ?? string.Empty, new Vector2((int)position.X, (int)position.Y), new Microsoft.Xna.Framework.Color(color.R, color.G, color.B, color.A)); } }
public TextBox(ISpriteFont spriteFont) { _textBlock = new TextBlock(spriteFont) { Margin = new Thickness(3, 6), Foreground = new SolidColorBrush(Colors.Black), }; _textBlock.Bind(TextBlock.TextProperty, BindingFactory.CreateOneWay(this, TextProperty)); Content = new Border() { Background = new SolidColorBrush(Colors.Gray), BorderThickness = new Thickness(1), Child = _textBlock, }; _clickSubscription = Gestures .Where(gesture => gesture.Type == GestureType.LeftButtonDown) .Subscribe(HandleClick); }
public TextGraphic(ISpriteFont font) { this.font = font; }
private static string WrapText(ISpriteFont font, string text, double maxLineWidth) { const string Space = " "; var stringBuilder = new StringBuilder(); string[] words = WhiteSpaceRegEx.Split(text); double lineWidth = 0; double spaceWidth = font.MeasureString(Space).Width; foreach (string word in words) { Size size = font.MeasureString(word); if (lineWidth + size.Width < maxLineWidth) { stringBuilder.AppendFormat("{0}{1}", lineWidth == 0 ? string.Empty : Space, word); lineWidth += size.Width + spaceWidth; } else { stringBuilder.AppendFormat("\n{0}", word); lineWidth = size.Width + spaceWidth; } } return stringBuilder.ToString(); }
protected virtual ITextGraphicComponent CreateTextComponent(ISpriteFont font) { return new TextBox(font); }
public void DrawString(ISpriteFont spriteFont, string text, Vector2 position, Color color) { SetData(position, spriteFont, text, color); }
private void SetData(Vector2 position, ISpriteFont font, string text, Color color) { SetData(position, font, text, Vector2.One, color); }
public void DrawString(ISpriteFont spriteFont, StringBuilder text, Vector2 position, Color color) { DrawString(spriteFont.Unwrapped, text, position, color); }
public void DrawText(ISpriteFont spriteFont, string text, Point position, Brush brush) { this.jobs.Add(new SpriteFontJob(spriteFont, text, position, brush)); }
public void SetUp() { _spriteBatch = Substitute.For<ISpriteBatch>(); _spriteFont = Substitute.For<ISpriteFont>(); }
public TextBox(ISpriteFont font) : this(new TextGraphic(font)) { }
public void DrawString(ISpriteFont spriteFont, string text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { SetData(position, spriteFont, text, new Vector2(scale), color); }
public ScoreBoard(IContentManager content) { _font = content.LoadSpriteFont("Fonts/Score"); }
public void DrawString(ISpriteFont spriteFont, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) { SetData(position, spriteFont, text.ToString(), scale, color); }
/// <see cref="Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawString(SpriteFont, string, Vector2, Color)"/> public void DrawString(ISpriteFont spriteFont, string text, Vector2 position, Color color) { DrawString(spriteFont.SpriteFont, text, position, color); }
/// <see cref="Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawString(SpriteFont, string, Vector2, Color, float, Vector2, float, SpriteEffects, float)"/> public void DrawString(ISpriteFont spriteFont, string text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { DrawString(spriteFont.SpriteFont, text, position, color, rotation, origin, scale, effects, layerDepth); }
public void DrawString(ISpriteFont spriteFont, StringBuilder text, Vector2 position, Color color) { SetData(position, spriteFont, text.ToString(), color); }
private void SetData(Vector2 position, ISpriteFont font, string text, Vector2 scale, Color color) { DrawnStrings.AddLast(text); SetData(position, font.MeasureString(text), scale, color); }