I'll preface this by saying I've already tried a bunch of ways of achieving my goal and I'm now resting at the "best" solution, but it's still far from what I would consider "great"...so I was hoping to get a suggestion here. This is in C# using Visual Studio 2010.
My program plays audio files that are accompanied by metadata that may include lyrics. When I have the lyrics, the user has the option to have the lyrics either display one phrase at a time, or scrolling along with the audio. This takes place on a one-line Label. It's not karaoke style where you have the entire phrase and it gets colored in or something, literally the lyrics scroll from left to right in time with the music.
I have tried with both DoubleBuffering enabled and disabled. With it enabled, it is better, but still, not perfect.
1) having a Graphics object created at runtime for the label, then a timer would draw directly on to the Label using its Graphics object. I tried both clearing the graphics, and instead just drawing a filled rectangle the size of the graphics to avoid the flicker of clearing. After either of these, the text string is drawn. I've tried 25ms, 50ms, and 100ms with about the same result here.
2) having a Graphics object created at runtime for the label, then a timer would create a bitmap the size of the label, create a graphics object from that bitmap, draw the filled rectangle and draw the string in the graphics object, then copy that to the Label's graphics object, and I have also tried copying the bitmap to the Label.Image field.
3) having no dedicated Graphics object created. instead, have the timer Invalidate the Label. Then on the Label's Paint event, use the e argument's Graphics object to directly draw the filled rectangle and draw the text string.
In all instances, the result is a correctly scrolling text that is jittery and hard to read as it scrolls, but looks perfect when playback is paused. Timing and content of what is drawn is accurate. #3 is the "best" of the many variations I have tried, but as I say, it's still not easy to read the text. Given the timer values have varied between 40FPS and 10FPS, and the result is not very different in legibility, I'm assuming it's coming down to an inefficient way of doing the drawings on my part.
Is there some obvious mistake I'm making or a fundamental lack of foundation that is causing this behavior? I would love some input on how I can improve this. Thanks.