/// <summary>
        /// Draws the indicator's glyph in an editor view margin.
        /// </summary>
        /// <param name="context">The <see cref="TextViewDrawContext"/> to use for rendering.</param>
        /// <param name="viewLine">The <see cref="ITextViewLine"/> for which the glyph is rendered.</param>
        /// <param name="tagRange">The <see cref="ITag"/> and the range it covers.</param>
        /// <param name="bounds">The bounds in which the indicator will be rendered.</param>
        public override void DrawGlyph(TextViewDrawContext context, ITextViewLine viewLine, TagSnapshotRange <IIndicatorTag> tagRange, Rect bounds)
        {
            var diameter = Math.Max(8.0, Math.Min(13, Math.Round(Math.Min(bounds.Width, bounds.Height) - 2.0)));
            var x        = bounds.X + (bounds.Width - diameter) / 2.0;
            var y        = bounds.Y + (bounds.Height - diameter) / 2.0;

            context.FillEllipse(new Rect(x, y, diameter, diameter), Color.FromArgb(0xff, 0x8a, 0xf3, 0x82));
            context.DrawEllipse(new Rect(x, y, diameter, diameter), Color.FromArgb(0xff, 0x00, 0x40, 0x00), LineKind.Solid, 1);
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Occurs when the highlight adornment needs to be drawn.
        /// </summary>
        /// <param name="context">The <see cref="TextViewDrawContext"/> to use for rendering.</param>
        /// <param name="adornment">The <see cref="IAdornment"/> to draw.</param>
        private void OnDrawHighlightAdornment(TextViewDrawContext context, IAdornment adornment)
        {
            var tag = adornment.Tag as ColorPreviewTag;

            if (tag != null)
            {
                // Get the adornment bounds within the text area, accounting for scroll state
                var bounds = new Rect(
                    context.TextAreaBounds.X + adornment.Location.X - context.View.ScrollState.HorizontalAmount,
                    context.TextAreaBounds.Y + adornment.Location.Y + adornment.Size.Height - ColorPreviewHeight,
                    adornment.Size.Width,
                    ColorPreviewHeight
                    );

                context.FillRectangle(bounds, tag.Color);
            }
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Draws the margin and its content.
        /// </summary>
        /// <param name="context">The <see cref="TextViewDrawContext"/> to use for rendering.</param>
        public void Draw(TextViewDrawContext context)
        {
            Rect marginBounds = context.Bounds;

            // Loop through all the view lines
            ITextViewLineCollection visibleLines = view.VisibleViewLines;

            foreach (ITextViewLine viewLine in visibleLines)
            {
                // Get bounds relative to this element
                Rect bounds = view.TransformFromTextArea(viewLine.Bounds);

                // Get the number of characters on the line
                string characterCount = viewLine.CharacterCount.ToString(CultureInfo.CurrentCulture) + " chars";

                // Get the foreground
                var foreground = Colors.Black;
                if (viewLine.CharacterCount > 60)
                {
                    foreground = Colors.Red;
                }
                else if (viewLine.CharacterCount > 40)
                {
                    foreground = Colors.DarkGoldenrod;
                }
                else if (viewLine.CharacterCount > 20)
                {
                    foreground = Colors.DarkGreen;
                }

                // Get the line layout
                var firstLayoutLine = context.Canvas.CreateTextLayout(characterCount, 0, this.FontFamily.Source, (float)this.FontSize, foreground).Lines[0];

                // Get x/y
                double x = marginBounds.Right - firstLayoutLine.Width - this.Padding.Right;
                double y = marginBounds.Y + viewLine.TextBounds.Y + (int)Math.Round(viewLine.Baseline - firstLayoutLine.Baseline, MidpointRounding.AwayFromZero);

                // Draw the text
                context.DrawText(new Point(x, y), firstLayoutLine);
            }
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Draws the margin and its content.
        /// </summary>
        /// <param name="context">The <see cref="TextViewDrawContext"/> to use for rendering.</param>
        public void Draw(TextViewDrawContext context)
        {
            // NOTE: This margin is rendered via XAML but could be drawn here instead if desired
        }
        /// <summary>
        /// Occurs when the adornment needs to be drawn.
        /// </summary>
        /// <param name="context">The <see cref="TextViewDrawContext"/> to use for rendering.</param>
        /// <param name="adornment">The <see cref="IAdornment"/> to draw.</param>
        private void OnDrawAdornment(TextViewDrawContext context, IAdornment adornment)
        {
            var color = Color.FromArgb(0x20, 0x80, 0x80, 0x80);

            context.FillRectangle(new Rect(adornment.Location, adornment.Size), color);
        }