Example #1
0
        public UIElement GenerateGlyph(IWpfTextViewLine line, GlyphTextMarkerGlyphTag glyphTag)
        {
            if (line == null)
            {
                throw new ArgumentNullException(nameof(line));
            }
            if (glyphTag == null)
            {
                throw new ArgumentNullException(nameof(glyphTag));
            }
            Debug.Assert(glyphTag.ImageReference.Assembly != null && glyphTag.ImageReference.Name != null);
            if (glyphTag.ImageReference.Assembly == null || glyphTag.ImageReference.Name == null)
            {
                return(null);
            }

            var          source = glyphTextMarkerServiceImpl.ImageManager.GetImage(glyphTag.ImageReference, BackgroundType.GlyphMargin);
            const double DEFAULT_IMAGE_LENGTH = 16;
            const double EXTRA_LENGTH         = 2;
            double       imageLength          = Math.Min(DEFAULT_IMAGE_LENGTH, line.Height + EXTRA_LENGTH);
            var          image = new Image {
                Width  = imageLength,
                Height = imageLength,
                Source = source,
            };

            Panel.SetZIndex(image, glyphTag.ZIndex);
            return(image);
        }
        public UIElement GenerateGlyph(IWpfTextViewLine line, GlyphTextMarkerGlyphTag glyphTag)
        {
            if (line == null)
            {
                throw new ArgumentNullException(nameof(line));
            }
            if (glyphTag == null)
            {
                throw new ArgumentNullException(nameof(glyphTag));
            }
            Debug.Assert(!glyphTag.ImageReference.IsDefault);
            if (glyphTag.ImageReference.IsDefault)
            {
                return(null);
            }

            const double DEFAULT_IMAGE_LENGTH = 16;
            const double EXTRA_LENGTH         = 2;
            double       imageLength          = Math.Min(DEFAULT_IMAGE_LENGTH, line.Height + EXTRA_LENGTH);

            var image = new DsImage {
                Width          = imageLength,
                Height         = imageLength,
                ImageReference = glyphTag.ImageReference,
            };

            Panel.SetZIndex(image, glyphTag.ZIndex);
            return(image);
        }