protected void ConvertTextPartsToToolTip(TextPart[] textParts, out string tipText, out string tipTitle) { StringBuilder tipBuilder = new StringBuilder(); StringBuilder titleBuilder = new StringBuilder(); foreach (TextPart part in textParts) { switch (part.format) { case TextFormat.NewLine: if (tipBuilder.Length > 0) tipBuilder.AppendLine(); tipBuilder.Append(part.text); break; case TextFormat.SameLine: tipBuilder.Append(part.text); break; case TextFormat.Title: titleBuilder.Append(part.text); break; case TextFormat.Header: if (tipBuilder.Length > 0) tipBuilder.AppendLine(); tipBuilder.Append(part.text); tipBuilder.Append(" "); break; default: Debug.Fail("Unexpected part format"); break; } } tipText = tipBuilder.ToString(); tipTitle = titleBuilder.ToString(); }
// Has the selection description changed? bool HasSelectionDescChanged(TextPart[] newSelectionDesc) { if (selectionDesc == null || newSelectionDesc == null) return (selectionDesc != newSelectionDesc); if (selectionDesc.Length != newSelectionDesc.Length) return true; for (int i = 0; i < selectionDesc.Length; ++i) { if (selectionDesc[i].format != newSelectionDesc[i].format || selectionDesc[i].text != newSelectionDesc[i].text) return true; } return false; }