protected string SafePeekString(int length) { var safeLength = Math.Min(length, FullText.Length - CurrentIndex); if (safeLength == 0) { return(string.Empty); } return(FullText.Substring(CurrentIndex, safeLength)); }
public string GetString() { if (IsComplete()) { return(string.Empty); } int curr = m_curr; m_curr = FullText.Length; return(FullText.Substring(curr).Trim()); }
void setText() { if (FullText == null) { textBlock.Text = ""; return; } if (FullTextSize.Width + AutoPadding <= textBlock.ActualWidth) { textBlock.Padding = new Thickness(AutoPadding, 0, 0, 0); textBlock.Text = FullText; } else if (FullTextSize.Width + 5 <= textBlock.ActualWidth) { textBlock.Padding = new Thickness(textBlock.ActualWidth - (FullTextSize.Width + 5), 0, 0, 0); textBlock.Text = FullText; } else { textBlock.Padding = new Thickness(0, 0, 0, 0); //calculate average length of characters in the string double avgCharLength = FullTextSize.Width / FullText.Length; // length of added dots with a little extra buffer double dotsLength = avgCharLength * 3; // calculate how many characters need to be dropped to fit the string into the available space int nrDroppedChars = (int)Math.Ceiling(((FullTextSize.Width + dotsLength) - textBlock.ActualWidth) / avgCharLength); String text = ""; do { int newLength = FullText.Length - nrDroppedChars; if (newLength <= 0) { text = ""; break; } text = FullText.Substring(0, newLength) + "..."; nrDroppedChars++; } while (MeasureString(text).Width >= textBlock.ActualWidth - errorMargin); textBlock.Text = text; } }
private string FindParseText(string parameter) { string value = string.Empty; int indexStartParameter = FullText.IndexOf(parameter); if (indexStartParameter > 0) { indexStartParameter += parameter.Length + 1; int indexEndParameter = FullText.IndexOf(",", indexStartParameter); value = FullText.Substring(indexStartParameter, indexEndParameter - indexStartParameter); } return(value); }
public override string ToString() { return($"{{{Title} - {FullText.Substring(0, Math.Min(FullText.Length, 200))} }}"); }