public override VisualLineElement ConstructElement(int offset)
        {
            char c = CurrentContext.Document.GetCharAt(offset);

            if (ShowSpaces && c == ' ')
            {
                return(new SpaceTextElement(CurrentContext.TextView.cachedElements.GetTextForNonPrintableCharacter("\u00B7", CurrentContext)));
            }
            else if (ShowTabs && c == '\t')
            {
                return(new TabTextElement(CurrentContext.TextView.cachedElements.GetTextForNonPrintableCharacter("\u00BB", CurrentContext)));
            }
            else if (ShowBoxForControlCharacters && char.IsControl(c))
            {
                var p = new VisualLineElementTextRunProperties(CurrentContext.GlobalTextRunProperties);
                p.SetForegroundBrush(Brushes.White);
                var textFormatter = TextFormatterFactory.Create(CurrentContext.TextView);
                var text          = FormattedTextElement.PrepareText(textFormatter,
                                                                     TextUtilities.GetControlCharacterName(c), p);
                return(new SpecialCharacterBoxElement(text));
            }
            else
            {
                return(null);
            }
        }
        /// <inheritdoc/>
        public override void Render(DrawingContext drawingContext)
        {
            var textView   = TextView;
            var renderSize = Bounds.Size;

            if (textView != null && textView.VisualLinesValid)
            {
                int currentLine = -1;

                if (_editor.SelectionLength == 0 && _editor.CaretOffset >= 0 && _editor.CaretOffset <= _editor.Document.TextLength)
                {
                    currentLine = _editor.Document.GetLineByOffset(_editor.CaretOffset).LineNumber;
                }

                foreach (var line in textView.VisualLines)
                {
                    var lineNumber = line.FirstDocumentLine.LineNumber;

                    var foreground = lineNumber != currentLine ? Foreground : SelectedLineForeground;

                    var text = TextFormatterFactory.CreateFormattedText(
                        this,
                        lineNumber.ToString(CultureInfo.CurrentCulture),
                        Typeface, EmSize, foreground
                        );

                    var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop);
                    drawingContext.DrawText(foreground, new Point(renderSize.Width - text.Measure().Width, y - textView.VerticalOffset),
                                            text);
                }
            }
        }
Beispiel #3
0
        public string Format(string text, FormatterType type)
        {
            var factory   = new TextFormatterFactory();
            var formatter = factory.GetFormatter(type);

            return(formatter.Format(text));
        }
        /// <inheritdoc/>
        protected override void OnRender(DrawingContext drawingContext)
        {
            TextView textView   = this.TextView;
            Size     renderSize = this.RenderSize;

            if (textView != null && textView.VisualLinesValid)
            {
                var foreground = (Brush)GetValue(Control.ForegroundProperty);
                foreach (VisualLine line in textView.VisualLines)
                {
                    int           lineNumber = line.FirstDocumentLine.LineNumber;
                    FormattedText text       = TextFormatterFactory.CreateFormattedText(
                        this,
                        lineNumber.ToString(CultureInfo.CurrentCulture),
                        typeface, emSize, foreground
                        );
                    double y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop);
                    y = y - textView.VerticalOffset;
                    if (this.FlowDirection == FlowDirection.RightToLeft)
                    {
                        MatrixTransform antiMirror = new MatrixTransform(-1, 0, 0, 1, renderSize.Width, 0);
                        drawingContext.PushTransform(antiMirror);
                        drawingContext.DrawText(text, new Point(0, y));
                        drawingContext.Pop();
                    }
                    else
                    {
                        drawingContext.DrawText(text, new Point(renderSize.Width - text.Width, y));
                    }
                }
            }
        }
Beispiel #5
0
        /// <inheritdoc/>
        protected override Size MeasureOverride(Size availableSize)
        {
            Typeface = GetValue(TextBlock.FontFamilyProperty);
            EmSize   = GetValue(TextBlock.FontSizeProperty);

            var text = TextFormatterFactory.CreateFormattedText(
                this,
                new string('9', MaxLineNumberLength),
                Typeface,
                EmSize,
                GetValue(TemplatedControl.ForegroundProperty)
                );

            var textRight = TextFormatterFactory.CreateFormattedText(
                this,
                new string('9', RightMarginChars),
                Typeface,
                EmSize,
                GetValue(TemplatedControl.ForegroundProperty)
                );

            RightMarginSize = textRight.Measure().Width;

            return(new Size(text.Measure().Width + RightMarginSize, 0));
        }
        /// <inheritdoc/>
        public override VisualLineElement ConstructElement(int offset)
        {
            if (foldingManager == null)
            {
                return(null);
            }
            int            foldedUntil    = -1;
            FoldingSection foldingSection = null;

            foreach (FoldingSection fs in foldingManager.GetFoldingsContaining(offset))
            {
                if (fs.IsFolded)
                {
                    if (fs.EndOffset > foldedUntil)
                    {
                        foldedUntil    = fs.EndOffset;
                        foldingSection = fs;
                    }
                }
            }
            if (foldedUntil > offset && foldingSection != null)
            {
                // Handle overlapping foldings: if there's another folded folding
                // (starting within the foldingSection) that continues after the end of the folded section,
                // then we'll extend our fold element to cover that overlapping folding.
                bool foundOverlappingFolding;
                do
                {
                    foundOverlappingFolding = false;
                    foreach (FoldingSection fs in FoldingManager.GetFoldingsContaining(foldedUntil))
                    {
                        if (fs.IsFolded && fs.EndOffset > foldedUntil)
                        {
                            foldedUntil             = fs.EndOffset;
                            foundOverlappingFolding = true;
                        }
                    }
                } while (foundOverlappingFolding);

                string title = foldingSection.Title;
                if (string.IsNullOrEmpty(title))
                {
                    title = "...";
                }
                var p = new VisualLineElementTextRunProperties(CurrentContext.GlobalTextRunProperties);
                p.SetForegroundBrush(textBrush);
                var textFormatter = TextFormatterFactory.Create(CurrentContext.TextView);
                var text          = FormattedTextElement.PrepareText(textFormatter, title, p);
                return(new FoldingLineElement(foldingSection, text, foldedUntil - offset)
                {
                    textBrush = textBrush
                });
            }
            else
            {
                return(null);
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            var typeface = textView.GetValue(TextBlock.FontFamilyProperty);
            var emSize   = textView.GetValue(TextBlock.FontSizeProperty);

            var formattedText = TextFormatterFactory.CreateFormattedText(
                textView,
                "9",
                typeface,
                emSize,
                Brushes.Black
                );

            var charSize  = formattedText.Measure();
            var pixelSize = PixelSnapHelpers.GetPixelSize(textView);

            foreach (var entry in markers)
            {
                var startLine = textView.Document.GetLineByOffset(entry.StartOffset);

                var start = entry.StartOffset;

                var startChar = textView.Document.GetCharAt(startLine.Offset);

                if (char.IsWhiteSpace(startChar))
                {
                    start = TextUtilities.GetNextCaretPosition(textView.Document, startLine.Offset, LogicalDirection.Forward,
                                                               CaretPositioningMode.WordBorder);
                }

                var endLine = textView.Document.GetLineByOffset(entry.EndOffset <= textView.Document.TextLength ? entry.EndOffset : textView.Document.TextLength);

                if (endLine.EndOffset > start && startLine != endLine)
                {
                    var newEntry = new TextSegment()
                    {
                        StartOffset = start, EndOffset = endLine.EndOffset
                    };

                    var rects = BackgroundGeometryBuilder.GetRectsForSegment(textView, newEntry);

                    var rect = GetRectForRange(rects);

                    if (!rect.IsEmpty)
                    {
                        var xPos = charSize.Width * (textView.Document.GetLocation(newEntry.StartOffset).Column - 1);

                        rect = rect.WithX(xPos + (charSize.Width / 2));

                        rect = rect.WithX(PixelSnapHelpers.PixelAlign(rect.X, pixelSize.Width));
                        rect = rect.WithY(PixelSnapHelpers.PixelAlign(rect.Y, pixelSize.Height));

                        drawingContext.DrawLine(_pen, rect.TopLeft, rect.BottomLeft);
                    }
                }
            }
        }
Beispiel #8
0
 /// <inheritdoc/>
 public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
 {
     if (textLine == null)
     {
         var formatter = TextFormatterFactory.Create(context.TextView);
         textLine  = PrepareText(formatter, this.text, this.TextRunProperties);
         this.text = null;
     }
     return(new FormattedTextRun(this, this.TextRunProperties));
 }
        protected override void OnRender(DrawingContext drawingContext)
        {
            TextView textView   = this.TextView;
            Size     renderSize = this.RenderSize;

            if (_DiffView == null)
            {
                return;
            }

            var srcLineDiffs = _DiffView.ItemsSource as IReadOnlyList <IDiffLineInfo>;

            if (srcLineDiffs == null)
            {
                return;
            }

            if (textView != null && textView.VisualLinesValid)
            {
                var foreground = _DiffView.LineNumbersForeground;
                foreach (VisualLine line in textView.VisualLines)
                {
                    // AvalonEdit is 1 based but the collection is of course zero based :-(
                    int lineNumber = line.FirstDocumentLine.LineNumber - 1;

                    if (lineNumber >= srcLineDiffs.Count)
                    {
                        continue;
                    }

                    // Find a diff context for a given line
                    if (srcLineDiffs.Count < lineNumber)
                    {
                        continue;
                    }

                    var srcLineDiff = srcLineDiffs[lineNumber];

                    if (srcLineDiff.ImaginaryLineNumber.HasValue)
                    {
                        // Render displayed numbers in a 1-based format
                        int           imaginaryLineNumber = (int)srcLineDiff.ImaginaryLineNumber + 1;
                        FormattedText text = TextFormatterFactory.CreateFormattedText(
                            this,
                            imaginaryLineNumber.ToString(CultureInfo.CurrentCulture),
                            typeface, emSize, foreground
                            );

                        double y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop);
                        drawingContext.DrawText(text, new Point(renderSize.Width - text.Width, y - textView.VerticalOffset));
                    }
                }
            }
        }
Beispiel #10
0
        /// <inheritdoc/>
        protected override Size MeasureOverride(Size availableSize)
        {
            typeface = this.CreateTypeface();
            emSize   = (double)GetValue(TextBlock.FontSizeProperty);

            var text = TextFormatterFactory.CreateFormattedText(this,
                                                                new string('9', maxLineNumberLength),
                                                                typeface,
                                                                emSize,
                                                                (Brush)GetValue(Control.ForegroundProperty)
                                                                );

            return(new Size(text.Width + 20, 0));
        }
Beispiel #11
0
        void MakeNewText()
        {
            if (fmt == null)
            {
                fmt = TextFormatterFactory.Create(this, provider);
            }

            if (line != null)
            {
                line.Dispose();
            }

            src.UpdateParent(this);
            line = fmt.FormatLine(src.Source, 0, 0, new ParaProps(this), null);
        }
Beispiel #12
0
        protected AbstractGenerator(string filePath, string tableName, string nameSpace, string assemblyName, Table table, ApplicationPreferences appPrefs)
        {
            this.filePath = filePath;

            if (!this.filePath.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                this.filePath = this.filePath + Path.DirectorySeparatorChar;
            }

            this.tableName    = tableName;
            this.nameSpace    = nameSpace;
            this.assemblyName = assemblyName;

            Table     = table;
            Formatter = TextFormatterFactory.GetTextFormatter(appPrefs);
            this.applicationPreferences = appPrefs;
        }
 protected AbstractGenerator(string filePath, string specificFolder, string tableName, string nameSpace, string assemblyName, string sequenceName, Table table, ApplicationPreferences appPrefs)
 {
     this.filePath = filePath;
     if (appPrefs.GenerateInFolders)
     {
         this.filePath = Path.Combine(filePath, specificFolder);
         if (!this.filePath.EndsWith(Path.DirectorySeparatorChar.ToString()))
         {
             this.filePath = this.filePath + Path.DirectorySeparatorChar;
         }
     }
     this.tableName    = tableName;
     this.nameSpace    = nameSpace;
     this.assemblyName = assemblyName;
     this.sequenceName = sequenceName;
     Table             = table;
     Formatter         = TextFormatterFactory.GetTextFormatter(appPrefs);
 }
Beispiel #14
0
        /// <inheritdoc/>
        protected override void OnRender(DrawingContext drawingContext)
        {
            var textView   = TextView;
            var renderSize = RenderSize;

            if (textView != null && textView.VisualLinesValid)
            {
                var foreground = (Brush)GetValue(Control.ForegroundProperty);
                foreach (var line in textView.VisualLines)
                {
                    var lineNumber = line.FirstDocumentLine.LineNumber;
                    var text       = TextFormatterFactory.CreateFormattedText(this, lineNumber.ToString(), typeface, emSize, foreground);
                    var y          = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop);

                    drawingContext.DrawText(text, new Point(renderSize.Width - text.Width, y - textView.VerticalOffset));
                }
            }
        }
Beispiel #15
0
        private void TablesListSelectedIndexChanged(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = string.Empty;
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (tablesListBox.SelectedIndex == -1)
                {
                    dbTableDetailsGridView.DataSource = new List <Column>();
                    return;
                }

                int?lastTableSelectedIndex = LastTableSelected();
                if (lastTableSelectedIndex != null)
                {
                    var table = tablesListBox.Items[lastTableSelectedIndex.Value] as Table;

                    if (table != null)
                    {
                        CaptureApplicationSettings();

                        PopulateTableDetails(table);

                        ToggleColumnsBasedOnAppSettings(applicationSettings);

                        GenerateAndDisplayCode(table);

                        // Display entity name based on formatted table name
                        var appPreferences = GetApplicationPreferences(table, false, applicationSettings);
                        var formatter      = TextFormatterFactory.GetTextFormatter(appPreferences);
                        entityNameTextBox.Text = formatter.FormatText(table.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                toolStripStatusLabel1.Text = ex.Message;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
        /// <inheritdoc/>
        public override VisualLineElement ConstructElement(int offset)
        {
            char c = CurrentContext.Document.GetCharAt(offset);

            if (ShowSpaces && c == ' ')
            {
                FormattedText text = TextFormatterFactory.CreateFormattedText(
                    CurrentContext.TextView,
                    "\u00B7",
                    CurrentContext.GlobalTextRunProperties.Typeface,
                    CurrentContext.GlobalTextRunProperties.FontRenderingEmSize,
                    Brushes.LightGray
                    );
                return(new SpaceTextElement(text));
            }
            else if (ShowTabs && c == '\t')
            {
                FormattedText text = TextFormatterFactory.CreateFormattedText(
                    CurrentContext.TextView,
                    "\u00BB",
                    CurrentContext.GlobalTextRunProperties.Typeface,
                    CurrentContext.GlobalTextRunProperties.FontRenderingEmSize,
                    Brushes.LightGray
                    );
                return(new TabTextElement(text));
            }
            else if (ShowBoxForControlCharacters && char.IsControl(c))
            {
                FormattedText text = TextFormatterFactory.CreateFormattedText(
                    CurrentContext.TextView,
                    TextUtilities.GetControlCharacterName(c),
                    CurrentContext.GlobalTextRunProperties.Typeface,
                    CurrentContext.GlobalTextRunProperties.FontRenderingEmSize * 0.9,
                    Brushes.White
                    );
                return(new SpecialCharacterBoxElement(text));
            }
            else
            {
                return(null);
            }
        }
Beispiel #17
0
        /// <inheritdoc/>
        protected override void OnRender(DrawingContext drawingContext)
        {
            TextView textView = this.TextView;

            System.Windows.Size renderSize = this.RenderSize;// new System.Windows.Size(((FrameworkElement)this).Width, ((FrameworkElement)this).RenderSize.Height);
            drawingContext.DrawRectangle(background, null,
                                         new Rect(0, 0, renderSize.Width, renderSize.Height));

            renderSize = this.RenderSize;

            renderSize = this.RenderSize;
            if (textView != null && textView.VisualLinesValid)
            {
                var foreground = (System.Windows.Media.Brush)GetValue(Control.ForegroundProperty);
                foreach (VisualLine line in textView.VisualLines)
                {
                    if (enableLineExtended == true)
                    {
                        if (line.FirstDocumentLine.obs != null)
                        {
                            continue;
                        }
                    }

                    int lineNumber = line.FirstDocumentLine.LineNumberExtended;

                    if (enableLineExtended == false)
                    {
                        lineNumber = line.FirstDocumentLine.LineNumber;
                    }

                    FormattedText text = TextFormatterFactory.CreateFormattedText(
                        this,
                        lineNumber.ToString(CultureInfo.CurrentCulture),
                        typeface, emSize, foreground
                        );
                    double y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop);

                    drawingContext.DrawText(text, new System.Windows.Point(renderSize.Width - text.Width, y - textView.VerticalOffset));
                }
            }
        }
Beispiel #18
0
 public T2TiERPServiceGen(string filePath, string specificFolder, string tableName, string nameSpace, string assemblyName, string sequenceName, Table table, ApplicationPreferences appPrefs)
 {
     this.filePath = filePath;
     if (appPrefs.GenerateInFolders)
     {
         this.filePath = Path.Combine(filePath, specificFolder);
         if (!this.filePath.EndsWith(Path.DirectorySeparatorChar.ToString()))
         {
             this.filePath = this.filePath + Path.DirectorySeparatorChar;
         }
     }
     this.tableName    = tableName;
     this.nameSpace    = nameSpace;
     this.assemblyName = assemblyName;
     this.sequenceName = sequenceName;
     Table             = table;
     Formatter         = TextFormatterFactory.GetTextFormatter(appPrefs);
     nomeTabela        = Formatter.FormatSingular(tableName);
     tipoDTO           = nomeTabela + "DTO";
 }
Beispiel #19
0
        public TextLine GetTextForNonPrintableCharacter(string text, ITextRunConstructionContext context)
        {
            if (nonPrintableCharacterTexts == null)
            {
                nonPrintableCharacterTexts = new Dictionary <string, TextLine>();
            }
            TextLine textLine;

            if (!nonPrintableCharacterTexts.TryGetValue(text, out textLine))
            {
                var p = new VisualLineElementTextRunProperties(context.GlobalTextRunProperties);
                p.SetForegroundBrush(context.TextView.NonPrintableCharacterBrush);
                if (formatter == null)
                {
                    formatter = TextFormatterFactory.Create(context.TextView);
                }
                textLine = FormattedTextElement.PrepareText(formatter, text, p);
                nonPrintableCharacterTexts[text] = textLine;
            }
            return(textLine);
        }
Beispiel #20
0
        /// <inheritdoc/>
        protected override void OnRender(DrawingContext drawingContext)
        {
            TextView textView   = this.TextView;
            Size     renderSize = this.RenderSize;

            if (textView != null && textView.VisualLinesValid)
            {
                var foreground = (Brush)GetValue(Control.ForegroundProperty);
                foreach (VisualLine line in textView.VisualLines)
                {
                    int           lineNumber = line.FirstDocumentLine.LineNumber;
                    FormattedText text       = TextFormatterFactory.CreateFormattedText(
                        this,
                        lineNumber.ToString(CultureInfo.CurrentCulture),
                        typeface, emSize, foreground
                        );
                    drawingContext.DrawText(text, new Point(renderSize.Width - text.Width,
                                                            line.VisualTop - textView.VerticalOffset));
                }
            }
        }
 /// <inheritdoc/>
 public override void Render(DrawingContext drawingContext)
 {
     var textView = TextView;
     var renderSize = Bounds.Size;
     if (textView != null && textView.VisualLinesValid)
     {
         var foreground = GetValue(TemplatedControl.ForegroundProperty);
         foreach (var line in textView.VisualLines)
         {
             var lineNumber = line.FirstDocumentLine.LineNumber;
             var text = TextFormatterFactory.CreateFormattedText(
                 this,
                 lineNumber.ToString(CultureInfo.CurrentCulture),
                 Typeface, EmSize, foreground
             );
             var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop);
             drawingContext.DrawText(foreground, new Point(renderSize.Width - text.Bounds.Width, y - textView.VerticalOffset),
                 text);
         }
     }
 }
        /// <inheritdoc/>
        public override VisualLineElement ConstructElement(int offset)
        {
            if (FoldingManager == null)
            {
                return(null);
            }
            int    foldedUntil = -1;
            string title       = null;

            foreach (FoldingSection fs in FoldingManager.GetFoldingsAt(offset))
            {
                if (fs.IsFolded)
                {
                    if (fs.EndOffset > foldedUntil)
                    {
                        foldedUntil = fs.EndOffset;
                        title       = fs.Title;
                    }
                }
            }
            if (foldedUntil > offset)
            {
                if (string.IsNullOrEmpty(title))
                {
                    title = "...";
                }
                FormattedText text = TextFormatterFactory.CreateFormattedText(
                    CurrentContext.TextView,
                    title,
                    CurrentContext.GlobalTextRunProperties.Typeface,
                    CurrentContext.GlobalTextRunProperties.FontRenderingEmSize,
                    Brushes.Gray
                    );
                return(new FoldingLineElement(text, foldedUntil - offset));
            }
            else
            {
                return(null);
            }
        }
Beispiel #23
0
        /// <inheritdoc/>
        public override VisualLineElement ConstructElement(int offset)
        {
            string       newlineText;
            DocumentLine lastDocumentLine = CurrentContext.VisualLine.LastDocumentLine;

            if (lastDocumentLine.DelimiterLength == 2)
            {
                newlineText = "\u00B6";
            }
            else if (lastDocumentLine.DelimiterLength == 1)
            {
                char newlineChar = CurrentContext.Document.GetCharAt(lastDocumentLine.Offset + lastDocumentLine.Length);
                if (newlineChar == '\r')
                {
                    newlineText = "\\r";
                }
                else if (newlineChar == '\n')
                {
                    newlineText = "\\n";
                }
                else
                {
                    newlineText = "?";
                }
            }
            else
            {
                return(null);
            }
            FormattedText text = TextFormatterFactory.CreateFormattedText(
                CurrentContext.TextView,
                newlineText,
                CurrentContext.GlobalTextRunProperties.Typeface,
                CurrentContext.GlobalTextRunProperties.FontRenderingEmSize,
                Brushes.LightGray
                );

            return(new NewLineTextElement(text));
        }
Beispiel #24
0
        /// <inheritdoc/>
        protected override void OnRender(DrawingContext drawingContext)
        {
            TextView textView   = this.TextView;
            Size     renderSize = this.RenderSize;

            if (textView != null && textView.VisualLinesValid)
            {
                var foreground = (Brush)GetValue(Control.ForegroundProperty);
                foreach (VisualLine line in textView.VisualLines)
                {
                    // Telerik Authorship
                    string        lineNumber = GetLineNumberAsString(line);
                    FormattedText text       = TextFormatterFactory.CreateFormattedText(
                        this,
                        lineNumber.ToString(CultureInfo.CurrentCulture),
                        typeface, emSize, foreground
                        );
                    double y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop);
                    drawingContext.DrawText(text, new Point(renderSize.Width - text.Width, y - textView.VerticalOffset));
                }
            }
        }
Beispiel #25
0
        private async void TablesListSelectedValueChanged(object sender, EventArgs e)
        {
            toolStripStatusLabel.Text = string.Empty;
            try
            {
                SetBusy(true);

                if (tablesListBox.SelectedIndex == -1)
                {
                    dbTableDetailsGridView.DataSource = new List <Column>();
                    return;
                }

                if (tablesListBox.SelectedItem  is Table table)
                {
                    CaptureApplicationSettings();

                    await PopulateTableDetails(table);

                    ToggleColumnsBasedOnAppSettings(applicationSettings);

                    GenerateAndDisplayCode(table);

                    // Display entity name based on formatted table name
                    UpdateApplicationPreferences(false);
                    var formatter = TextFormatterFactory.GetTextFormatter(applicationSettings);
                    entityNameTextBox.Text = formatter.FormatText(table.Name);
                }
            }
            catch (Exception ex)
            {
                toolStripStatusLabel.Text = ex.Message;
            }
            finally
            {
                SetBusy(false);
            }
        }
        /// <inheritdoc/>
        protected override void OnRender(DrawingContext drawingContext)
        {
            TextView textView   = this.TextView;
            Size     renderSize = this.RenderSize;
            double   w          = renderSize.Width / maxLineNumberLength;

            if (textView != null && textView.VisualLinesValid)
            {
                var foreground = (Brush)GetValue(Control.ForegroundProperty);
                foreach (VisualLine line in textView.VisualLines)
                {
                    int lineNumber = line.FirstDocumentLine.LineNumber;
                    using (var text = TextFormatterFactory.CreateTextLine(
                               this,
                               lineNumber.ToString(CultureInfo.CurrentCulture),
                               typeface, emSize, foreground
                               )) {
                        double y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop);
                        text.Draw(drawingContext, new Point(renderSize.Width - text.Width - w, y - textView.VerticalOffset), InvertAxes.None);
                    }
                }
            }
        }
        public TextLine GetTextForNonPrintableCharacter(string text, ITextRunConstructionContext context)
        {
            if (_nonPrintableCharacterTexts == null)
            {
                _nonPrintableCharacterTexts = new Dictionary <string, TextLine>();
            }

            if (_nonPrintableCharacterTexts.TryGetValue(text, out var textLine))
            {
                return(textLine);
            }

            var properties = context.GlobalTextRunProperties.Clone();

            properties.ForegroundBrush = context.TextView.NonPrintableCharacterBrush;
            if (_formatter == null)
            {
                _formatter = TextFormatterFactory.Create();
            }

            textLine = FormattedTextElement.PrepareText(_formatter, text, properties);
            _nonPrintableCharacterTexts[text] = textLine;
            return(textLine);
        }