void OnSyntaxHighlightingChanged(IHighlightingDefinition newValue) { if (colorizer != null) { this.TextArea.TextView.LineTransformers.Remove(colorizer); colorizer = null; } if (newValue != null) { colorizer = CreateColorizer(newValue); this.TextArea.TextView.LineTransformers.Insert(0, colorizer); } }
/// <summary> /// Method is executed when the syntax highlighting defined through dp has changed. /// </summary> /// <param name="newValue"></param> protected virtual void OnSyntaxHighlightingChanged(IHighlightingDefinition newValue) { if (_Colorizer != null) { this.TextArea.TextView.LineTransformers.Remove(_Colorizer); _Colorizer = null; } if (newValue != null) { _Colorizer = CreateColorizer(newValue); if (_Colorizer != null) { this.TextArea.TextView.LineTransformers.Insert(0, _Colorizer); } } }
void OnColorizerChanged(IVisualLineTransformer newValue) { if (newValue != null && this.SyntaxHighlighting != null) { throw new InvalidOperationException("You can only set either 'Colorizer' or 'SyntaxHighlighting'! Attempting to set 'Colorizer' while 'SyntaxHighlighting' has already been set!"); } if (colorizer != null) { this.TextArea.TextView.LineTransformers.Remove(colorizer); colorizer = null; } if (newValue != null) { colorizer = newValue; if (colorizer != null) { this.TextArea.TextView.LineTransformers.Insert(0, colorizer); } } }
void OnSyntaxHighlightingChanged(IHighlightingDefinition newValue) { if (newValue != null && this.Colorizer != null) { throw new InvalidOperationException("You can only set either 'Colorizer' or 'SyntaxHighlighting'! Attempting to set 'SyntaxHighlighting' while 'Colorizer' has already been set!"); } if (colorizer != null) { this.TextArea.TextView.LineTransformers.Remove(colorizer); colorizer = null; } if (newValue != null) { colorizer = CreateColorizer(newValue); if (colorizer != null) { this.TextArea.TextView.LineTransformers.Insert(0, colorizer); } } }
internal void RunTransformers(ITextRunConstructionContext context, IVisualLineTransformer[] transformers) { Debug.Assert(phase == LifetimePhase.Transforming); foreach (IVisualLineTransformer transformer in transformers) { transformer.Transform(context, elements); } // For some strange reason, WPF requires that either all or none of the typography properties are set. if (elements.Any(e => e.TextRunProperties.TypographyProperties != null)) { // Fix typographic properties foreach (VisualLineElement element in elements) { if (element.TextRunProperties.TypographyProperties == null) { element.TextRunProperties.SetTypographyProperties(new DefaultTextRunTypographyProperties()); } } } phase = LifetimePhase.Live; }
internal void RunTransformers(ITextRunConstructionContext context, IVisualLineTransformer[] transformers) { foreach (IVisualLineTransformer transformer in transformers) { transformer.Transform(context, elements); } }
void OnSyntaxHighlightingChanged(IHighlightingDefinition newValue) { if (colorizer != null) { this.TextArea.TextView.LineTransformers.Remove(colorizer); colorizer = null; } if (newValue != null) { colorizer = CreateColorizer(newValue); if (colorizer != null) this.TextArea.TextView.LineTransformers.Insert(0, colorizer); } }
void LineTransformer_Removed(IVisualLineTransformer lineTransformer) { DisconnectFromTextView(lineTransformer); Redraw(); }
void LineTransformer_Added(IVisualLineTransformer lineTransformer) { ConnectToTextView(lineTransformer); Redraw(); }
internal void RunTransformers(ITextRunConstructionContext context, IVisualLineTransformer[] transformers) { //TODO: VisualLine.RunTransformers() throw new NotImplementedException(); }
VisualLine BuildVisualLine(DocumentLine documentLine, TextRunProperties textRunProperties, TextParagraphProperties paragraphProperties, VisualLineElementGenerator[] generators, IVisualLineTransformer[] transformers, Size availableSize) { if (heightTree.GetIsCollapsed(documentLine)) { throw new InvalidOperationException(); } var visualLine = new VisualLine(documentLine); var textSource = new VisualLineTextSource(visualLine) { Document = this.Document, GlobalTextRunProperties = textRunProperties, TextView = this }; visualLine.ConstructVisualElements(textSource, generators); visualLine.RunTransformers(textSource, transformers); int offset = 0; TextLineBreak lineBreak = null; var textLines = new List<TextLine>(); while (offset <= visualLine.VisualLength) { TextLine tl = textFormatter.FormatLine(textSource, offset, availableSize.Width, paragraphProperties, lineBreak); textLines.Add(tl); offset += tl.Length; lineBreak = tl.GetTextLineBreak(); } visualLine.SetTextLines(textLines); heightTree.SetHeight(visualLine.FirstDocumentLine, visualLine.Height); return visualLine; }
internal void RunTransformers(VisualLine line, IVisualLineTransformer[] transformers) { Debug.Assert(phase == LifetimePhase.Transforming); foreach (IVisualLineTransformer transformer in transformers) { transformer.Transform(line, elements); } phase = LifetimePhase.Live; }