Example #1
0
		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);
			}
		}
Example #2
0
        /// <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);
                }
            }
        }
Example #3
0
 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);
         }
     }
 }
Example #4
0
 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);
         }
     }
 }
Example #5
0
 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;
 }
Example #6
0
 internal void RunTransformers(ITextRunConstructionContext context, IVisualLineTransformer[] transformers)
 {
     foreach (IVisualLineTransformer transformer in transformers) {
         transformer.Transform(context, elements);
     }
 }
Example #7
0
 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);
     }
 }
Example #8
0
 void LineTransformer_Removed(IVisualLineTransformer lineTransformer)
 {
     DisconnectFromTextView(lineTransformer);
     Redraw();
 }
Example #9
0
 void LineTransformer_Added(IVisualLineTransformer lineTransformer)
 {
     ConnectToTextView(lineTransformer);
     Redraw();
 }
Example #10
0
 void LineTransformer_Removed(IVisualLineTransformer lineTransformer)
 {
     DisconnectFromTextView(lineTransformer);
     Redraw();
 }
Example #11
0
 void LineTransformer_Added(IVisualLineTransformer lineTransformer)
 {
     ConnectToTextView(lineTransformer);
     Redraw();
 }
Example #12
0
		internal void RunTransformers(ITextRunConstructionContext context, IVisualLineTransformer[] transformers)
		{ 
			//TODO: VisualLine.RunTransformers()
			throw new NotImplementedException();
		}
Example #13
0
		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;
		}
Example #14
0
 internal void RunTransformers(VisualLine line, IVisualLineTransformer[] transformers)
 {
     Debug.Assert(phase == LifetimePhase.Transforming);
     foreach (IVisualLineTransformer transformer in transformers) {
         transformer.Transform(line, elements);
     }
     phase = LifetimePhase.Live;
 }