Ejemplo n.º 1
0
        public override bool AddAdornment(VSTE.AdornmentPositioningBehavior behavior, HexBufferSpan?visualSpan, object?tag, UIElement adornment, VSTE.AdornmentRemovedCallback?removedCallback)
        {
            if (adornment is null)
            {
                throw new ArgumentNullException(nameof(adornment));
            }
            if (visualSpan is not null && visualSpan.Value.IsDefault)
            {
                throw new ArgumentException();
            }
            if (visualSpan is null && behavior == VSTE.AdornmentPositioningBehavior.TextRelative)
            {
                throw new ArgumentNullException(nameof(visualSpan));
            }
            if ((uint)behavior > (uint)VSTE.AdornmentPositioningBehavior.TextRelative)
            {
                throw new ArgumentOutOfRangeException(nameof(behavior));
            }
            if (layerKind != HexLayerKind.Normal)
            {
                if (behavior != VSTE.AdornmentPositioningBehavior.OwnerControlled)
                {
                    throw new ArgumentOutOfRangeException(nameof(behavior), "Special layers must use AdornmentPositioningBehavior.OwnerControlled");
                }
                if (visualSpan is not null)
                {
                    throw new ArgumentOutOfRangeException(nameof(visualSpan), "Special layers must use a null visual span");
                }
            }
            bool canAdd = visualSpan is null || HexView.HexViewLines.IntersectsBufferSpan(visualSpan.Value);

            if (canAdd)
            {
                var layerElem = new HexAdornmentLayerElementImpl(behavior, visualSpan, tag, adornment, removedCallback);
                canvas.Children.Add(layerElem.Adornment);
                adornmentLayerElements.Add(layerElem);
            }
            return(canAdd);
        }
Ejemplo n.º 2
0
		public override bool AddAdornment(VSTE.AdornmentPositioningBehavior behavior, HexBufferSpan? visualSpan, object tag, UIElement adornment, VSTE.AdornmentRemovedCallback removedCallback) {
			if (adornment == null)
				throw new ArgumentNullException(nameof(adornment));
			if (visualSpan != null && visualSpan.Value.IsDefault)
				throw new ArgumentException();
			if (visualSpan == null && behavior == VSTE.AdornmentPositioningBehavior.TextRelative)
				throw new ArgumentNullException(nameof(visualSpan));
			if ((uint)behavior > (uint)VSTE.AdornmentPositioningBehavior.TextRelative)
				throw new ArgumentOutOfRangeException(nameof(behavior));
			if (layerKind != HexLayerKind.Normal) {
				if (behavior != VSTE.AdornmentPositioningBehavior.OwnerControlled)
					throw new ArgumentOutOfRangeException(nameof(behavior), "Special layers must use AdornmentPositioningBehavior.OwnerControlled");
				if (visualSpan != null)
					throw new ArgumentOutOfRangeException(nameof(visualSpan), "Special layers must use a null visual span");
			}
			bool canAdd = visualSpan == null || HexView.HexViewLines.IntersectsBufferSpan(visualSpan.Value);
			if (canAdd) {
				var layerElem = new HexAdornmentLayerElementImpl(behavior, visualSpan, tag, adornment, removedCallback);
				canvas.Children.Add(layerElem.Adornment);
				adornmentLayerElements.Add(layerElem);
			}
			return canAdd;
		}