I'm making a scheduling application which looks similar to Google Calendar, iCalendar, Outlook's calendar, and similar... As you may have seen in such apps, scheduled events are represented in rectangles, which can be very small especially if you're viewing a whole week.
My challenge is to give the user a "meaningful summary" of the event before they click it, using text in the rectangle. The text should be very compact. To that end, I want it to wrap lines in a way that isn't very common, but I suspect .NET is capable of handling it natively.
If a single word is wider than the rectangle, only the beginning of that word should show. But wrapping should still occur upon encountering spaces, if the word which follows would fall partly outside the rectangle. Not every space will cause wrapping to the next line, because if two or more words happen to fit on a line that's fine.
I suspect that the answer lies in the capabilities of StringFormat, StringTrimming, and FormatFlags, but I haven't found the right combination to accomplish the goals.
For example if we have...
Chuck Norris
Dentist Appointment
Due to limited space it might become...
Chuc
Norr
Denti
Appo
I do NOT want it to become:
Chuc
k
Norr
is
Dent
ist
Appo
intme
nt
As you see in this example, if the user already knows who Chuck Norris is, the presence of letter "k" and the letters "is" don't help the user recognize the name. In fact, the presence of those letters may force "Dentist Appointment" to be hidden from view because vertical space is also limited.
I already know how to draw text in a rectangle that wraps in the normal way, and I also know how to get it to avoid drawing any text that falls outside the rectangle. What I DON'T know is how to get it to wrap upon encountering a space (or carriage return) while preventing it from wrapping mid-word if a single word is wider than the rectangle. Any help there?