Exemple #1
0
        List <IconInfo> CreateIconInfos(WpfHexViewLine line)
        {
            var icons = new List <IconInfo>();

            foreach (var glyphTag in GetGlyphTags(line))
            {
                Debug.Assert(glyphTag != null);
                if (glyphTag == null)
                {
                    continue;
                }
                // Fails if someone forgot to Export(typeof(HexGlyphFactoryProvider)) with the correct tag types
                bool b = glyphFactories.TryGetValue(glyphTag.GetType(), out var factoryInfo);
                Debug.Assert(b);
                if (!b)
                {
                    continue;
                }
                var elem = factoryInfo.Factory.GenerateGlyph(line, glyphTag);
                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
                Canvas.SetLeft(elem, (MARGIN_WIDTH - elem.DesiredSize.Width) / 2);
                Canvas.SetTop(elem, iconInfo.BaseTopValue + line.TextTop);
            }
            return(icons);
        }
Exemple #2
0
        Geometry GetMarkerGeometry(WpfHexViewLine line, VST.Span span, bool clipToViewport, Thickness padding, bool isLineGeometry)
        {
            if (line == null)
            {
                throw new ArgumentNullException(nameof(line));
            }
            if (!lines.Contains(line))
            {
                throw new ArgumentException();
            }

            bool         createOutlinedPath = false;
            PathGeometry geo        = null;
            var          textBounds = line.GetNormalizedTextBounds(span);

            HexMarkerHelper.AddGeometries(hexView, textBounds, isLineGeometry, clipToViewport, padding, 0, ref geo, ref createOutlinedPath);
            if (createOutlinedPath)
            {
                geo = geo.GetOutlinedPathGeometry();
            }
            if (geo != null && geo.CanFreeze)
            {
                geo.Freeze();
            }
            return(geo);
        }
Exemple #3
0
 void Update(WpfHexViewLine line)
 {
     Debug.Assert(line.VisibilityState != VSTF.VisibilityState.Unattached);
     if (!lineInfos.TryGetValue(line.IdentityTag, out var info))
     {
         return;
     }
     lineInfos.Remove(line.IdentityTag);
     foreach (var iconInfo in info.Icons)
     {
         childCanvases[iconInfo.Order].Children.Remove(iconInfo.Element);
     }
     AddLine(lineInfos, line);
 }
Exemple #4
0
        IEnumerable <HexGlyphTag> GetGlyphTags(WpfHexViewLine line)
        {
            foreach (var tagSpan in tagAggregator.GetTags(line.BufferSpan))
            {
                if (line.IntersectsBufferSpan(tagSpan.Span))
                {
                    yield return(tagSpan.Tag);
                }
            }
            var taggerContext = new HexTaggerContext(line.BufferLine, line.BufferLine.TextSpan);

            foreach (var tagSpan in tagAggregator.GetLineTags(taggerContext))
            {
                yield return(tagSpan.Tag);
            }
        }
		public override UIElement GenerateGlyph(WpfHexViewLine line, HexGlyphTag tag) {
			var glyphTag = tag as HexImageReferenceTag;
			if (glyphTag == null)
				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;
		}
        public override UIElement GenerateGlyph(WpfHexViewLine line, HexGlyphTag tag)
        {
            var glyphTag = tag as HexImageReferenceTag;

            if (glyphTag == null)
            {
                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);
        }
 MarkerElement TryCreateMarkerElement(WpfHexViewLine line, VST.Span span, HexMarkerTag tag)
 {
     Debug.Assert(tag.Type != null);
     return(TryCreateMarkerElementCore(wpfHexView.WpfHexViewLines.GetLineMarkerGeometry(line, span), line.BufferSpan, tag));
 }
Exemple #8
0
 /// <summary>
 /// Gets a line marker geometry
 /// </summary>
 /// <param name="line">A line in this collection</param>
 /// <param name="span">Text span</param>
 /// <returns></returns>
 public abstract Geometry GetLineMarkerGeometry(WpfHexViewLine line, VST.Span span);
Exemple #9
0
 /// <summary>
 /// Gets a line marker geometry
 /// </summary>
 /// <param name="line">A line in this collection</param>
 /// <param name="span">Text span</param>
 /// <param name="clipToViewport">true to clip the geometry to the viewport</param>
 /// <param name="padding">Padding to use</param>
 /// <returns></returns>
 public abstract Geometry GetLineMarkerGeometry(WpfHexViewLine line, VST.Span span, bool clipToViewport, Thickness padding);
		/// <summary>
		/// Gets a line marker geometry
		/// </summary>
		/// <param name="line">A line in this collection</param>
		/// <param name="span">Text span</param>
		/// <param name="clipToViewport">true to clip the geometry to the viewport</param>
		/// <param name="padding">Padding to use</param>
		/// <returns></returns>
		public abstract Geometry GetLineMarkerGeometry(WpfHexViewLine line, VST.Span span, bool clipToViewport, Thickness padding);
		/// <summary>
		/// Gets a text marker geometry
		/// </summary>
		/// <param name="line">A line in this collection</param>
		/// <param name="span">Text span</param>
		/// <returns></returns>
		public abstract Geometry GetTextMarkerGeometry(WpfHexViewLine line, VST.Span span);
Exemple #12
0
		void Update(WpfHexViewLine line) {
			Debug.Assert(line.VisibilityState != VSTF.VisibilityState.Unattached);
			LineInfo info;
			if (!lineInfos.TryGetValue(line.IdentityTag, out info))
				return;
			lineInfos.Remove(line.IdentityTag);
			foreach (var iconInfo in info.Icons)
				childCanvases[iconInfo.Order].Children.Remove(iconInfo.Element);
			AddLine(lineInfos, line);
		}
		public override Geometry GetTextMarkerGeometry(WpfHexViewLine line, VST.Span span, bool clipToViewport, Thickness padding) =>
			GetMarkerGeometry(line, span, clipToViewport, padding, false);
Exemple #14
0
 public override Geometry GetTextMarkerGeometry(WpfHexViewLine line, VST.Span span, bool clipToViewport, Thickness padding) =>
 GetMarkerGeometry(line, span, clipToViewport, padding, false);
		public override Geometry GetTextMarkerGeometry(WpfHexViewLine line, VST.Span span) =>
			GetMarkerGeometry(line, span, false, HexMarkerHelper.TextMarkerPadding, false);
Exemple #16
0
 /// <summary>
 /// Generates a glyph or returns null
 /// </summary>
 /// <param name="line">Line</param>
 /// <param name="tag">Tag</param>
 /// <returns></returns>
 public abstract UIElement GenerateGlyph(WpfHexViewLine line, HexGlyphTag tag);
Exemple #17
0
		/// <summary>
		/// Generates a glyph or returns null
		/// </summary>
		/// <param name="line">Line</param>
		/// <param name="tag">Tag</param>
		/// <returns></returns>
		public abstract UIElement GenerateGlyph(WpfHexViewLine line, HexGlyphTag tag);
 public override Geometry?GetLineMarkerGeometry(WpfHexViewLine line, VST.Span span) =>
 GetMarkerGeometry(line, span, false, HexMarkerHelper.LineMarkerPadding, true);
Exemple #19
0
 /// <summary>
 /// Gets a text marker geometry
 /// </summary>
 /// <param name="line">A line in this collection</param>
 /// <param name="span">Text span</param>
 /// <returns></returns>
 public abstract Geometry?GetTextMarkerGeometry(WpfHexViewLine line, VST.Span span);
		Geometry GetMarkerGeometry(WpfHexViewLine line, VST.Span span, bool clipToViewport, Thickness padding, bool isLineGeometry) {
			if (line == null)
				throw new ArgumentNullException(nameof(line));
			if (!lines.Contains(line))
				throw new ArgumentException();

			bool createOutlinedPath = false;
			PathGeometry geo = null;
			var textBounds = line.GetNormalizedTextBounds(span);
			HexMarkerHelper.AddGeometries(hexView, textBounds, isLineGeometry, clipToViewport, padding, 0, ref geo, ref createOutlinedPath);
			if (createOutlinedPath)
				geo = geo.GetOutlinedPathGeometry();
			if (geo != null && geo.CanFreeze)
				geo.Freeze();
			return geo;
		}
Exemple #21
0
 public override Geometry GetTextMarkerGeometry(WpfHexViewLine line, VST.Span span) =>
 GetMarkerGeometry(line, span, false, HexMarkerHelper.TextMarkerPadding, false);
Exemple #22
0
		List<IconInfo> CreateIconInfos(WpfHexViewLine line) {
			var icons = new List<IconInfo>();
			foreach (var glyphTag in GetGlyphTags(line)) {
				Debug.Assert(glyphTag != null);
				if (glyphTag == null)
					continue;
				GlyphFactoryInfo factoryInfo;
				// Fails if someone forgot to Export(typeof(HexGlyphFactoryProvider)) with the correct tag types
				bool b = glyphFactories.TryGetValue(glyphTag.GetType(), out factoryInfo);
				Debug.Assert(b);
				if (!b)
					continue;
				var elem = factoryInfo.Factory.GenerateGlyph(line, glyphTag);
				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
				Canvas.SetLeft(elem, (MARGIN_WIDTH - elem.DesiredSize.Width) / 2);
				Canvas.SetTop(elem, iconInfo.BaseTopValue + line.TextTop);
			}
			return icons;
		}
Exemple #23
0
		IEnumerable<HexGlyphTag> GetGlyphTags(WpfHexViewLine line) {
			foreach (var tagSpan in tagAggregator.GetTags(line.BufferSpan)) {
				if (line.IntersectsBufferSpan(tagSpan.Span))
					yield return tagSpan.Tag;
			}
			var taggerContext = new HexTaggerContext(line.BufferLine, line.BufferLine.TextSpan);
			foreach (var tagSpan in tagAggregator.GetLineTags(taggerContext))
				yield return tagSpan.Tag;
		}
Exemple #24
0
		MarkerElement TryCreateMarkerElement(WpfHexViewLine line, VST.Span span, HexMarkerTag tag) {
			Debug.Assert(tag.Type != null);
			return TryCreateMarkerElementCore(wpfHexView.WpfHexViewLines.GetLineMarkerGeometry(line, span), line.BufferSpan, tag);
		}