/// <summary> /// Initialize new instance of ElasticTabstopsSizeManager for IWpfTextView /// </summary> private ElasticTabstopsSizeManager(IWpfTextView textView) { _textView = textView; _textMeasureService = TextMeasureService.Create(_textView); InvalidateTabstops(); }
private static TextMeasureService GetOrCreateProperty(IWpfTextView textView) { TextMeasureService tms = textView.Properties.GetOrCreateSingletonProperty(() => new TextMeasureService { _textView = textView, _defaultTextRunProperties = textView.FormattedLineSource.DefaultTextProperties }); return(tms); }
public static TextMeasureService Create(IWpfTextView textView) { TextMeasureService tms = GetOrCreateProperty(textView); //font was changed, refresh cache if (tms._defaultTextRunProperties != textView.FormattedLineSource.DefaultTextProperties) { textView.Properties.RemoveProperty(typeof(TextMeasureService)); tms = GetOrCreateProperty(textView); } return(tms); }