TextFormatFlags 枚举中的 EndEllipsis 和 WordEllipsis 有什么区别?

What's the Difference between EndEllipsis and WordEllipsis in TextFormatFlags enum?

根据我对 documentation 的理解,当使用 TextFormatFlags.EndEllipsis 时,文本应该 trim 适合显示矩形并替换为省略号:

EndEllipsis   |   Removes the end of trimmed lines, and replaces them with an ellipsis.

使用 TextFormatFlags.WordEllipsis 时,文本应 trim 到适合显示矩形的最后一个单词,并添加一个省略号:

WordEllipsis   |   Trims the line to the nearest word and an ellipsis is placed at the end of a trimmed line.

但是,我似乎找不到这两者之间的任何区别。

这是我的测试控制代码:

public partial class UserControl1 : UserControl
{
    public UserControl1()
    {
        InitializeComponent();
        this.Text = "This it my text. It's long enough to get cut in display.";
    }


    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        var flags = (this.IsWordEllipsis) ? TextFormatFlags.WordEllipsis : TextFormatFlags.EndEllipsis;
        TextRenderer.DrawText(e.Graphics, this.Text, this.Font, e.ClipRectangle, this.ForeColor, flags);
    }

    private bool _IsWordEllipsis;

    public bool IsWordEllipsis
    {
        get { return _IsWordEllipsis; }
        set { _IsWordEllipsis = value; this.Invalidate(); }
    }
}

无论我设置什么值 IsWordEllipsis 属性 - 文本总是呈现为
This it my text. It's long eno....

不应该使用 WordEllipsis 标志 trim 显示的字符串到最后一个完整的单词吗?
(This it my text. It's long ...)

内部 TextRenderer.DrawText 调用 DrawText 函数

对应的标志是:

DT_WORD_ELLIPSIS: Truncates any word that does not fit in the rectangle and adds ellipses.

DT_END_ELLIPSIS For displayed text, if the end of a string does not fit in the rectangle, it is truncated and ellipses are added. If a word that is not at the end of the string goes beyond the limits of the rectangle, it is truncated without ellipses.

我已经以与您相同的方式解释了 WordEllipsis 的 .NET 文档,但上面的句子可能更好地解释了该选项的作用。

如果仍然不清楚,请看一下这个简单的例子,它试图渲染 var quote = "Not every thing that\n can be counted counts,\n and not everything that\n counts can be counted.";