Example #1
0
 private void OnClassificationFormatMappingChanged(object sender, EventArgs e)
 {
     _threadAffinitizedObject.AssertIsForeground();
     if (_format != null)
     {
         _format = null;
         _cache.Clear();
     }
 }
Example #2
0
        static DOC.Run CreateRun(string text, TextFormattingRunProperties defaultProperties, TextFormattingRunProperties?properties, Flags flags)
        {
            var run = new DOC.Run(text);

            if (properties is null)
            {
                return(run);
            }

            if (!properties.BackgroundBrushEmpty)
            {
                run.Background = properties.BackgroundBrush;
            }
            if (!properties.ForegroundBrushEmpty)
            {
                run.Foreground = properties.ForegroundBrush;
            }
            if (!properties.BoldEmpty)
            {
                run.FontWeight = properties.Bold ? FontWeights.Bold : FontWeights.Normal;
            }
            if (!properties.ItalicEmpty)
            {
                run.FontStyle = properties.Italic ? FontStyles.Italic : FontStyles.Normal;
            }
            if (!properties.FontRenderingEmSizeEmpty && (flags & Flags.DisableFontSize) == 0)
            {
                run.FontSize = properties.FontRenderingEmSize;
            }
            if (!properties.TextDecorationsEmpty)
            {
                run.TextDecorations = properties.TextDecorations;
            }
            if (!properties.TextEffectsEmpty)
            {
                run.TextEffects = properties.TextEffects;
            }
            if (!properties.TypefaceEmpty && !IsSameTypeFace(defaultProperties, properties))
            {
                run.FontFamily = properties.Typeface.FontFamily;
            }

            return(run);
        }
Example #3
0
 void ReinitializeCache()
 {
     toClassificationInfo.Clear();
     ClassificationFontUtils.CopyTo(defaultResourceDictionary, editorFormatMap.GetProperties(EditorFormatMapConstants.PlainText));
     defaultTextFormattingRunProperties = ClassificationFontUtils.Create(defaultResourceDictionary);
 }
        /// <summary>
        /// Creates a very long line at the bottom of bounds.
        /// </summary>
        public override GraphicsResult GetGraphics(IWpfTextView view, Geometry bounds, TextFormattingRunProperties?format)
        {
            var border = new Border()
            {
                BorderBrush     = GetBrush(view),
                BorderThickness = new Thickness(0, 0, 0, bottom: 1),
                Height          = 1,
                Width           = view.ViewportWidth
            };

            view.ViewportWidthChanged += ViewportWidthChangedHandler;

            // Subtract rect.Height to ensure that the line separator is drawn
            // at the bottom of the line, rather than immediately below.
            // This makes the line separator line up with the outlining bracket.
            Canvas.SetTop(border, bounds.Bounds.Bottom - border.Height);

            return(new GraphicsResult(border,
                                      () => view.ViewportWidthChanged -= ViewportWidthChangedHandler));

            void ViewportWidthChangedHandler(object s, EventArgs e)
            {
                border.Width = view.ViewportWidth;
            }
        }