Esempio n. 1
0
        private List <IconInfo> CreateIconInfos(IWpfTextViewLine line)
        {
            var icons = new List <IconInfo>();

            try {
                foreach (var mappingSpan in _tagAggregator.GetTags(line.ExtentAsMappingSpan))
                {
                    var tag = mappingSpan.Tag;
                    if (tag == null)
                    {
                        Log.Verbose("Tag is null");
                        continue;
                    }

                    // Fails if someone forgot to Export(typeof(IGlyphFactoryProvider)) with the correct tag types
                    var tagType = tag.GetType();
                    var b       = _glyphFactories.TryGetValue(tag.GetType(), out var factoryInfo);
                    if (!b)
                    {
                        Log.Verbose($"Could not find glyph factory for {tagType}");
                        continue;
                    }

                    foreach (var span in mappingSpan.Span.GetSpans(_wpfTextViewHost.TextView.TextSnapshot))
                    {
                        if (!line.IntersectsBufferSpan(span))
                        {
                            continue;
                        }

                        var elem = factoryInfo.Factory.GenerateGlyph(line, tag);
                        if (elem == null)
                        {
                            continue;
                        }

                        elem.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                        var iconInfo = new IconInfo(factoryInfo.Order, elem);
                        icons.Add(iconInfo);

                        // ActualWidth isn't always valid when we're here so use the constant
                        SetLeft(elem, (DefaultMarginWidth - elem.DesiredSize.Width) / 2);
                        SetTop(elem, iconInfo.BaseTopValue + line.TextTop);
                    }
                }
            }
            catch (ObjectDisposedException ex) {
                Log.Error(ex, nameof(CreateIconInfos) + " " + nameof(ObjectDisposedException) + $" AgentReady={ _sessionService?.IsAgentReady} IsReady={_sessionService?.IsReady} _isDisposed={_isDisposed}");
            }

            catch (Exception ex) {
                Log.Error(ex, nameof(CreateIconInfos));
            }

            return(icons);
        }
Esempio n. 2
0
        List <IconInfo> CreateIconInfos(IWpfTextViewLine line)
        {
            var icons = new List <IconInfo>();

            foreach (var mappingSpan in tagAggregator.GetTags(line.ExtentAsMappingSpan))
            {
                var tag = mappingSpan.Tag;
                Debug.Assert(tag != null);
                if (tag == null)
                {
                    continue;
                }
                GlyphFactoryInfo factoryInfo;
                // Fails if someone forgot to Export(typeof(IGlyphFactoryProvider)) with the correct tag types
                bool b = glyphFactories.TryGetValue(tag.GetType(), out factoryInfo);
                Debug.Assert(b);
                if (!b)
                {
                    continue;
                }
                foreach (var span in mappingSpan.Span.GetSpans(wpfTextViewHost.TextView.TextSnapshot))
                {
                    if (!line.IntersectsBufferSpan(span))
                    {
                        continue;
                    }
                    var elem = factoryInfo.Factory.GenerateGlyph(line, tag);
                    if (elem == null)
                    {
                        continue;
                    }
                    elem.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                    var iconInfo = new IconInfo(factoryInfo.Order, elem);
                    icons.Add(iconInfo);
                    // ActualWidth isn't always valid when we're here so use the constant
                    SetLeft(elem, (MARGIN_WIDTH - elem.DesiredSize.Width) / 2);
                    SetTop(elem, iconInfo.BaseTopValue + line.TextTop);
                }
            }
            return(icons);
        }
Esempio n. 3
0
		List<IconInfo> CreateIconInfos(IWpfTextViewLine line) {
			var icons = new List<IconInfo>();
			foreach (var mappingSpan in tagAggregator.GetTags(line.ExtentAsMappingSpan)) {
				var tag = mappingSpan.Tag;
				Debug.Assert(tag != null);
				if (tag == null)
					continue;
				GlyphFactoryInfo factoryInfo;
				// Fails if someone forgot to Export(typeof(IGlyphFactoryProvider)) with the correct tag types
				bool b = glyphFactories.TryGetValue(tag.GetType(), out factoryInfo);
				Debug.Assert(b);
				if (!b)
					continue;
				foreach (var span in mappingSpan.Span.GetSpans(wpfTextViewHost.TextView.TextSnapshot)) {
					if (!line.IntersectsBufferSpan(span))
						continue;
					var elem = factoryInfo.Factory.GenerateGlyph(line, tag);
					if (elem == null)
						continue;
					elem.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
					var iconInfo = new IconInfo(factoryInfo.Order, elem);
					icons.Add(iconInfo);
					// ActualWidth isn't always valid when we're here so use the constant
					SetLeft(elem, (MARGIN_WIDTH - elem.DesiredSize.Width) / 2);
					SetTop(elem, iconInfo.BaseTopValue + line.TextTop);
				}
			}
			return icons;
		}