Dynamic text writing animation that identifies when to skip the line or if the writing space is over?

1

I have an animation that writes lines of text in a text box, but when it reaches the end of the text box, the words pop up to the next line in the middle of the animation.

What I want to achieve is that the word skips to the next line before it starts writing on the text box if it does not fit in the remaining space.

The process that I am using for that animation is simply a timer that is placing the next character of the position of the chain.

The second requirement is that the animation identify if the next word to write fits in the visible area of the text box (without producing a scroll bar) and stops if it is not.

This I am doing in c # in WPF

    
asked by Mike 11.12.2017 в 21:56
source

3 answers

0

I would use this strategy:

  • to calculate the width use TextRenderer.MeasureText . width ,
  • to know if a scrollbar would occur, check the differences in ClientSize.Height and ClientSize.Width between the textbox and the textrenderer
  • to prevent the animation from looking strange or jumps, to do the calculations with a hidden textbox or outside the visible field

without an example code it is complicated to give a timely implementation

    
answered by 14.04.2018 / 01:33
source
1

After so much waiting I could not find a code that would handle this efficiently.

so I had to design my own algorithm

1.-Calculate the length of the word
2.-add word length to the total length written in the line
3.-if the total length is less than the width of the text box: continue writing
4.-if the total length is greater than the width of the text box: skip line: continue writing, total length = 0

    
answered by 06.04.2018 в 19:44
1

I think you would not need to calculate the total length written.
1-Calculate the available space of the box.
2-Calculate the length of the word or what you want to add
3-Make the difference and update the space available and if it is less than zero there is no space

    
answered by 14.04.2018 в 01:02