Exemplo n.º 1
0
 private void ApplyColorToElement(VisualLineElement element, HighlightingColor color)
 {
     if (color.Foreground != null)
     {
         Brush brush = color.Foreground.GetBrush(base.CurrentContext);
         if (brush != null)
         {
             element.TextRunProperties.SetForegroundBrush(brush);
         }
     }
     if (color.Background != null)
     {
         Brush brush2 = color.Background.GetBrush(base.CurrentContext);
         if (brush2 != null)
         {
             element.TextRunProperties.SetBackgroundBrush(brush2);
         }
     }
     if (color.FontStyle.HasValue || color.FontWeight.HasValue)
     {
         Typeface typeface = element.TextRunProperties.Typeface;
         element.TextRunProperties.SetTypeface(new Typeface(typeface.FontFamily, color.FontStyle ?? typeface.Style, color.FontWeight ?? typeface.Weight, typeface.Stretch));
     }
 }
Exemplo n.º 2
0
        private static void ApplyHighlight(VisualLineElement element, Highlight highlight, double magnify)
        {
            var trp = element.TextRunProperties;

            var foregroundBrush = ColorBrush(highlight.Foreground);

            if (foregroundBrush != null)
            {
                trp.SetForegroundBrush(foregroundBrush);
            }

            var backgroundBrush = ColorBrush(highlight.Background);

            if (backgroundBrush != null)
            {
                trp.SetBackgroundBrush(backgroundBrush);
            }

            if (!string.IsNullOrWhiteSpace(highlight.FontWeight) || !string.IsNullOrWhiteSpace(highlight.FontStyle))
            {
                var tf       = trp.Typeface;
                var weight   = ConvertFontWeight(highlight.FontWeight) ?? tf.Weight;
                var style    = ConvertFontStyle(highlight.FontStyle) ?? tf.Style;
                var typeFace = new Typeface(tf.FontFamily, style, weight, tf.Stretch);
                trp.SetTypeface(typeFace);
            }

            if (highlight.Underline)
            {
                trp.SetTextDecorations(TextDecorations.Underline);
            }
            if (double.IsNaN(magnify) == false)
            {
                trp.SetFontRenderingEmSize(trp.FontRenderingEmSize * magnify);
            }
        }
Exemplo n.º 3
0
        private void ColorizeElement(VisualLineElement element, Token token, bool isAttribute)
        {
            switch (token.Type)
            {
            case TokenType.Comment:
                element.TextRunProperties.SetForegroundBrush(Brushes.ForestGreen);
                break;

            case TokenType.AngularLeft:
            case TokenType.AngularRight:
            case TokenType.TagCloserLeft:
            case TokenType.TagCloserRight:
            case TokenType.PrologClose:
            case TokenType.PrologOpen:
                element.TextRunProperties.SetForegroundBrush(Brushes.Blue);
                break;

            case TokenType.String:
                element.TextRunProperties.SetForegroundBrush(Brushes.Orange);
                break;

            case TokenType.Id:
                var tf = element.TextRunProperties.Typeface;
                element.TextRunProperties.SetTypeface(new Typeface(
                                                          tf.FontFamily, FontStyles.Italic, FontWeights.Bold, FontStretches.Condensed));
                if (!isAttribute)
                {
                    element.TextRunProperties.SetForegroundBrush(Brushes.BlueViolet);
                }
                else
                {
                    element.TextRunProperties.SetForegroundBrush(Brushes.Coral);
                }
                break;
            }
        }
Exemplo n.º 4
0
 void ApplyChanges(VisualLineElement element)
 {
     element.TextRunProperties.SetForegroundBrush(Brushes.Black);
     element.TextRunProperties.SetBackgroundBrush(Brushes.Red);
 }
Exemplo n.º 5
0
 void ApplyChanges(VisualLineElement element)
 {
     // apply changes here
     element.TextRunProperties.SetForegroundBrush(color);
 }
Exemplo n.º 6
0
 void ApplyChanges(VisualLineElement element)
 {
     // This is where you do anything with the line
     element.TextRunProperties.SetForegroundBrush(Brush);
 }
Exemplo n.º 7
0
 void HighlightNamespaceDeclaration(VisualLineElement element)
 {
     element.TextRunProperties.SetForegroundBrush(XamlBindingOptions.NamespaceDeclarationForegroundColor.ToBrush());
     element.TextRunProperties.SetBackgroundBrush(XamlBindingOptions.NamespaceDeclarationBackgroundColor.ToBrush());
 }
Exemplo n.º 8
0
 void ApplyChanges(VisualLineElement element)
 {
     element.TextRunProperties.SetBackgroundBrush(new SolidColorBrush(Color.FromArgb(128, 255, 200, 200)));
     // This is where you do anything with the line
     //element.TextRunProperties.SetForegroundBrush(Brushes.Red);
 }
Exemplo n.º 9
0
 public void Apply(VisualLineElement element, Expression item)
 {
 }
Exemplo n.º 10
0
 void ApplyChanges(VisualLineElement element)
 {
     element.TextRunProperties.SetForegroundBrush(_greenBrush);
 }
Exemplo n.º 11
0
 public void Applyer(VisualLineElement element)
 {
     element.BackgroundBrush = _brush;
 }
Exemplo n.º 12
0
 private void ApplyChangesForUsing(VisualLineElement element)
 {
     element.TextRunProperties.SetForegroundBrush(Brushes.Black);
 }
Exemplo n.º 13
0
 private void ApplyChanges(VisualLineElement element)
 {
     element.TextRunProperties.SetForegroundBrush(Brushes.Gray);
 }
 private void HighlightParticipant(VisualLineElement visualLineElement)
 {
     visualLineElement.TextRunProperties.SetForegroundBrush(Brushes.Green);
 }
Exemplo n.º 15
0
 void visualLineElementAction(VisualLineElement el)
 {
 }
Exemplo n.º 16
0
 protected void ApplyChanges(VisualLineElement element)
 {
     element.BackgroundBrush = Brushes.Gold;
     element.TextRunProperties.SetForegroundBrush(Brushes.Red);
     //element.TextRunProperties.SetBackgroundBrush(Brushes.Gold);
 }
Exemplo n.º 17
0
 void ApplyChanges2(VisualLineElement element)
 {
     element.TextRunProperties.SetBackgroundBrush(Brushes.Transparent);
 }
Exemplo n.º 18
0
 void ApplyChanges(VisualLineElement element)
 {
     element.TextRunProperties.SetTextDecorations(gCollection);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Applies a highlighting color to a visual line element.
 /// </summary>
 protected virtual void ApplyColorToElement(VisualLineElement element, HighlightingColor color)
 {
     element.TextRunProperties = color.Apply(element.TextRunProperties);
 }
Exemplo n.º 20
0
 void HilightSelection(VisualLineElement element)
 {
     element.TextRunProperties.SetBackgroundBrush(Brushes.Yellow);
 }
Exemplo n.º 21
0
 void HighlightIgnored(VisualLineElement element)
 {
     element.TextRunProperties.SetForegroundBrush(XamlBindingOptions.IgnoredForegroundColor.ToBrush());
     element.TextRunProperties.SetBackgroundBrush(XamlBindingOptions.IgnoredBackgroundColor.ToBrush());
 }
Exemplo n.º 22
0
 private void HighlightError(VisualLineElement visualLineElement)
 {
     visualLineElement.TextRunProperties.SetBackgroundBrush(Brushes.PaleVioletRed);
 }
 /// <summary>
 /// Applies a highlighting color to a visual line element.
 /// </summary>
 protected virtual void ApplyColorToElement(VisualLineElement element, HighlightingColor color)
 {
     ApplyColorToElement(element, color, CurrentContext);
 }
 void ApplyChanges(VisualLineElement element)
 {
     // apply changes here
     element.TextRunProperties.SetBackgroundBrush(Brushes.Yellow);
 }