This component is a pure C# component which can parse HTML syntax and draw it.
Using the Code
Just drop the component (
mhLabel) on your form, and specify HTML and CSS.
I do not have a list of supported HTML and CSS tags yet. Please check the following if you need a list:
- HTML - Defines.cs (line 129)
- CSS - MiniCss.cs (line 26)
If you wish to develop your own component, you can take a look to Controls \ Label.cs for a sample.
Points of Interest
This component is very simple. HTML syntax is converted to tags. Every tag (e.g. bold) is an object. Each of them can change the environment in some way, like changing the
CurrentState object, allocate space from parent tag.
I port this component from my Delphi component. Because this is my first C# component, I encountered many problems, one of them is that the GDI+'s measure width is very inaccurate. I have to estimate the true width (e.g.
TextWidth - 2) when positioning the texts. Now I know
Graphics.MeasureCharacterRanges, but I still don't understand why they don't make
TextWidth return the true width. (btw,
MeasureCharacterRanges does not support CF).
It's much more accurate now.
- 09-08-2007: Initial release
- 23-08-2007: License update, image link support,
bgcolor support for