int GetStringWidth(Graphics graphics, string drawText, Font font) { if (drawText.Length == 0) { return(0); } using (GraphicsCache cache = new GraphicsCache(graphics)) { using (StringFormat format = CreateStringFormat()) { format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces; return(LabelInfoHelper.GetElementWidth(LabelInfoHelper.EditorItem(this), drawText, cache, font, format)); } } }
public override void Calculate(Graphics graphics, Font font, int fontHeight, ref int x, ref int y) { if (InfoText.Text == "") { return; } if (IsBreak) { y += (GetLineHeight(font) >> 1); return; } string drawText = InfoText.Text; while (drawText.Length > 0) { string words = GetNextWords(graphics, drawText, font, Width - x, x == LabelInfoViewInfo.TextIndent); if (words == string.Empty) { return; } int wordsWidth = 0; if (LabelInfoHelper.IsActionElement(this.InfoText.Text)) { wordsWidth = LabelInfoHelper.ActionElementWidht; } else { wordsWidth = LabelInfoHelper.GetElementWidth(LabelInfoHelper.EditorItem(this), GetStringWidth(graphics, words, font)); } FilterLabelInfoTextLineViewInfo item = new FilterLabelInfoTextLineViewInfo(words, location.X + x, location.Y + y, wordsWidth, fontHeight); list.Add(item); x += wordsWidth; if (x >= Width) { y += GetLineHeight(font); x = LabelInfoViewInfo.TextIndent; } if (words == drawText) { break; } drawText = drawText.Substring(words.Length, drawText.Length - words.Length); } }