public HeightTree(TextDocument document, double defaultLineHeight) { this.document = document; weakLineTracker = WeakLineTracker.Register(document, this); this.DefaultLineHeight = defaultLineHeight; RebuildDocument(); }
/// <summary> /// Registers the <paramref name="targetTracker"/> as line tracker for the <paramref name="textDocument"/>. /// A weak reference to the target tracker will be used, and the WeakLineTracker will deregister itself /// when the target tracker is garbage collected. /// </summary> public static WeakLineTracker Register(TextDocument textDocument, ILineTracker targetTracker) { if (textDocument == null) throw new ArgumentNullException("textDocument"); if (targetTracker == null) throw new ArgumentNullException("targetTracker"); WeakLineTracker wlt = new WeakLineTracker(textDocument, targetTracker); textDocument.LineTrackers.Add(wlt); return wlt; }
/// <summary> /// Registers the <paramref name="targetTracker"/> as line tracker for the <paramref name="textDocument"/>. /// A weak reference to the target tracker will be used, and the WeakLineTracker will deregister itself /// when the target tracker is garbage collected. /// </summary> public static WeakLineTracker Register(TextDocument textDocument, ILineTracker targetTracker) { if (textDocument == null) { throw new ArgumentNullException("textDocument"); } if (targetTracker == null) { throw new ArgumentNullException("targetTracker"); } WeakLineTracker wlt = new WeakLineTracker(textDocument, targetTracker); textDocument.LineTrackers.Add(wlt); return(wlt); }
public TextLayer(TextView parent, TextDocument textDocument) : base(parent) { Document = textDocument; elementGenerators = new ObserveAddRemoveCollection<VisualLineElementGenerator>(ElementGenerator_Added, ElementGenerator_Removed); lineTransformers = new ObserveAddRemoveCollection<IVisualLineTransformer>(LineTransformer_Added, LineTransformer_Removed); heightTree = new HeightTree(textDocument, 16); //TODO Skin.DefaultFont.Size lines = new Dictionary<DocumentLine, VisualLine>(); GlobalTextRunProperties = new TextRunProperties { Foreground = Color.Black}; lineTransformers = new ObserveAddRemoveCollection<IVisualLineTransformer>(LineTransformer_Added,LineTransformer_Removed); HighlightingDefinition = HighlightingManager.DefaultHighlightingManager.Instance.GetDefinition("C#"); var colorizer = new HighlightingColorizer(highlightingDefinition.MainRuleSet); lineTransformers.Add(colorizer); weakLineTracker = WeakLineTracker.Register(textDocument, this); RebuildDocument(); }
public void Dispose() { if (weakLineTracker != null) weakLineTracker.Deregister(); this.root = null; this.weakLineTracker = null; }