Example #1
0
        internal InfoBar(ISpriteBatch spriteBatch, ISpriteFont spriteFont)
        {
            _spriteBatch = spriteBatch;
            _spriteFont = spriteFont;

            FontColor = Color.LightBlue;
        }
Example #2
0
        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);
     }
 }
Example #5
0
 public SpriteFontJob(ISpriteFont spriteFont, string text, Point position, Brush brush)
 {
     this.spriteFont = spriteFont;
     this.text       = text;
     this.position   = position;
     this.brush      = brush;
 }
Example #6
0
 public MultlineTextBox(ISpriteFont font, ITextSplitter splitter, int lineNumber)
 {
     this.lineNumber = lineNumber;
     this.font = font;
     this.splitter = splitter;
     container = new Container();
     container.Layout = new VBoxLayout();
 }
Example #7
0
        public TextBlock(ISpriteFont spriteFont)
        {
            if (spriteFont == null)
            {
                throw new ArgumentNullException("spriteFont");
            }

            this.spriteFont = spriteFont;
        }
Example #8
0
        public TextBlock(ISpriteFont spriteFont)
        {
            if (spriteFont == null)
            {
                throw new ArgumentNullException("spriteFont");
            }

            this.spriteFont = spriteFont;
        }
Example #9
0
        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));
            }
        }
Example #10
0
        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);
        }
Example #11
0
 public TextGraphic(ISpriteFont font)
 {
     this.font = font;
 }
Example #12
0
        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();
        }
Example #13
0
 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));
     }
 }
Example #14
0
 protected virtual ITextGraphicComponent CreateTextComponent(ISpriteFont font)
 {
     return new TextBox(font);
 }
Example #15
0
 public void DrawString(ISpriteFont spriteFont, string text, Vector2 position, Color color)
 {
     SetData(position, spriteFont, text, color);
 }
Example #16
0
 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);
 }
Example #18
0
 public void DrawText(ISpriteFont spriteFont, string text, Point position, Brush brush)
 {
     this.jobs.Add(new SpriteFontJob(spriteFont, text, position, brush));
 }
Example #19
0
 public void SetUp()
 {
     _spriteBatch = Substitute.For<ISpriteBatch>();
     _spriteFont = Substitute.For<ISpriteFont>();
 }
Example #20
0
 public TextBox(ISpriteFont font)
     : this(new TextGraphic(font))
 { }
Example #21
0
 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");
 }
Example #23
0
 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);
 }
Example #24
0
 /// <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);
 }
Example #25
0
 /// <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);
 }
Example #26
0
 public void DrawString(ISpriteFont spriteFont, StringBuilder text, Vector2 position, Color color)
 {
     SetData(position, spriteFont, text.ToString(), color);
 }
Example #27
0
 public void DrawText(ISpriteFont spriteFont, string text, Point position, Brush brush)
 {
     this.jobs.Add(new SpriteFontJob(spriteFont, text, position, brush));
 }
Example #28
0
 private void SetData(Vector2 position, ISpriteFont font, string text, Vector2 scale, Color color)
 {
     DrawnStrings.AddLast(text);
     SetData(position, font.MeasureString(text), scale, color);
 }