예제 #1
0
 public HexPopupSpaceReservationAgent(HexSpaceReservationManager spaceReservationManager, WpfHexView wpfHexView, HexLineSpan lineSpan, VSTA.PopupStyles style, UIElement content)
 {
     if (lineSpan.IsDefault)
     {
         throw new ArgumentException();
     }
     if ((style & (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent)) == (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent))
     {
         throw new ArgumentOutOfRangeException(nameof(style));
     }
     this.spaceReservationManager = spaceReservationManager ?? throw new ArgumentNullException(nameof(spaceReservationManager));
     this.wpfHexView = wpfHexView;
     this.lineSpan   = lineSpan;
     this.style      = style;
     this.content    = content ?? throw new ArgumentNullException(nameof(content));
     popup           = new Popup {
         PlacementTarget     = wpfHexView.VisualElement,
         Placement           = PlacementMode.Relative,
         Visibility          = Visibility.Collapsed,
         IsOpen              = false,
         AllowsTransparency  = true,
         UseLayoutRounding   = true,
         SnapsToDevicePixels = true,
     };
 }
예제 #2
0
        public override void UpdatePopupAgent(HexSpaceReservationAgent agent, HexLineSpan lineSpan, VSTA.PopupStyles styles)
        {
            if (wpfHexView.IsClosed)
            {
                throw new InvalidOperationException();
            }
            if (agent is null)
            {
                throw new ArgumentNullException(nameof(agent));
            }
            if (lineSpan.IsDefault)
            {
                throw new ArgumentException();
            }
            if ((styles & (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent)) == (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent))
            {
                throw new ArgumentOutOfRangeException(nameof(styles));
            }
            if (!spaceReservationAgents.Contains(agent))
            {
                throw new ArgumentOutOfRangeException(nameof(agent));
            }
            var popupAgent = agent as HexPopupSpaceReservationAgent;

            if (popupAgent is null)
            {
                throw new ArgumentException();
            }
            popupAgent.Update(lineSpan, styles);
            UpdateAggregateFocus();
            wpfHexView.QueueSpaceReservationStackRefresh();
        }
예제 #3
0
 /// <summary>
 /// Gets normalized text bounds
 /// </summary>
 /// <param name="lineSpan">Line span</param>
 /// <returns></returns>
 public Collection <VSTF.TextBounds> GetNormalizedTextBounds(HexLineSpan lineSpan)
 {
     if (lineSpan.IsDefault)
     {
         throw new ArgumentException();
     }
     if (lineSpan.IsTextSpan)
     {
         return(GetNormalizedTextBounds(lineSpan.TextSpan.Value));
     }
     return(GetNormalizedTextBounds(lineSpan.BufferSpan, lineSpan.SelectionFlags.Value));
 }
예제 #4
0
 public override void EnsureSpanVisible(HexLineSpan lineSpan, VSTE.EnsureSpanVisibleOptions options)
 {
     if (lineSpan.IsDefault)
     {
         throw new ArgumentException();
     }
     if (lineSpan.BufferSpan.Buffer != hexView.Buffer)
     {
         throw new ArgumentException();
     }
     EnsureSpanVisibleCore(lineSpan, options);
 }
예제 #5
0
 internal void Update(HexLineSpan lineSpan, VSTA.PopupStyles style)
 {
     if (lineSpan.IsDefault)
     {
         throw new ArgumentException();
     }
     if ((style & (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent)) == (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent))
     {
         throw new ArgumentOutOfRangeException(nameof(style));
     }
     this.lineSpan = lineSpan;
     this.style    = style;
     wpfHexView.QueueSpaceReservationStackRefresh();
 }
예제 #6
0
        void EnsureSpanVisibleCore(HexLineSpan lineSpan, VSTE.EnsureSpanVisibleOptions options)
        {
            if (lineSpan.BufferSpan.Buffer != hexView.Buffer)
            {
                throw new ArgumentException();
            }

            if ((hexView.HexViewLines?.Count ?? 0) == 0)
            {
                return;
            }

            EnsureSpanVisibleY(lineSpan.BufferSpan, options);
            EnsureSpanVisibleX(lineSpan, options);
        }
예제 #7
0
 public override HexSpaceReservationAgent CreatePopupAgent(HexLineSpan lineSpan, VSTA.PopupStyles style, UIElement content)
 {
     if (wpfHexView.IsClosed)
     {
         throw new InvalidOperationException();
     }
     if (lineSpan.IsDefault)
     {
         throw new ArgumentException();
     }
     if (content is null)
     {
         throw new ArgumentNullException(nameof(content));
     }
     if ((style & (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent)) == (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent))
     {
         throw new ArgumentOutOfRangeException(nameof(style));
     }
     return(new HexPopupSpaceReservationAgent(this, wpfHexView, lineSpan, style, content));
 }
예제 #8
0
 /// <summary>
 /// Scrolls a span into view
 /// </summary>
 /// <param name="lineSpan">Line span</param>
 /// <param name="options">Options</param>
 public abstract void EnsureSpanVisible(HexLineSpan lineSpan, VSTE.EnsureSpanVisibleOptions options);
예제 #9
0
 /// <summary>
 /// Scrolls a span into view
 /// </summary>
 /// <param name="lineSpan">Line span</param>
 public void EnsureSpanVisible(HexLineSpan lineSpan) => EnsureSpanVisible(lineSpan, VSTE.EnsureSpanVisibleOptions.None);
예제 #10
0
		/// <summary>
		/// Gets normalized text bounds
		/// </summary>
		/// <param name="lineSpan">Line span</param>
		/// <returns></returns>
		public Collection<VSTF.TextBounds> GetNormalizedTextBounds(HexLineSpan lineSpan) {
			if (lineSpan.IsDefault)
				throw new ArgumentException();
			if (lineSpan.IsTextSpan)
				return GetNormalizedTextBounds(lineSpan.TextSpan.Value);
			return GetNormalizedTextBounds(lineSpan.BufferSpan, lineSpan.SelectionFlags.Value);
		}
		/// <summary>
		/// Updates a popup agent
		/// </summary>
		/// <param name="agent">Popup agent created by <see cref="CreatePopupAgent(HexLineSpan, VSTA.PopupStyles, UIElement)"/></param>
		/// <param name="lineSpan">New line span</param>
		/// <param name="styles">New popup style</param>
		public abstract void UpdatePopupAgent(HexSpaceReservationAgent agent, HexLineSpan lineSpan, VSTA.PopupStyles styles);
예제 #12
0
		/// <summary>
		/// Scrolls a span into view
		/// </summary>
		/// <param name="lineSpan">Line span</param>
		public void EnsureSpanVisible(HexLineSpan lineSpan) => EnsureSpanVisible(lineSpan, VSTE.EnsureSpanVisibleOptions.None);
예제 #13
0
 /// <summary>
 /// Updates a popup agent
 /// </summary>
 /// <param name="agent">Popup agent created by <see cref="CreatePopupAgent(HexLineSpan, VSTA.PopupStyles, UIElement)"/></param>
 /// <param name="lineSpan">New line span</param>
 /// <param name="styles">New popup style</param>
 public abstract void UpdatePopupAgent(HexSpaceReservationAgent agent, HexLineSpan lineSpan, VSTA.PopupStyles styles);
예제 #14
0
 /// <summary>
 /// Creates a popup agent
 /// </summary>
 /// <param name="lineSpan">Line span</param>
 /// <param name="style">Popup style</param>
 /// <param name="content">Popup content</param>
 /// <returns></returns>
 public abstract HexSpaceReservationAgent CreatePopupAgent(HexLineSpan lineSpan, VSTA.PopupStyles style, UIElement content);
예제 #15
0
        void EnsureSpanVisibleX(HexLineSpan lineSpan, VSTE.EnsureSpanVisibleOptions options)
        {
            var span = lineSpan.BufferSpan;

            if (hexView.ViewportWidth == 0)
            {
                return;
            }

            var lines = hexView.HexViewLines.GetHexViewLinesIntersectingSpan(span);

            if (lines.Count == 0)
            {
                return;
            }

            var ispan = span.Intersection(hexView.HexViewLines.FormattedSpan);

            if (ispan == null)
            {
                return;
            }
            span = ispan.Value;

            double left = double.PositiveInfinity, right = double.NegativeInfinity;

            for (int i = 0; i < lines.Count; i++)
            {
                var line         = lines[i];
                var intersection = line.BufferSpan.Intersection(span);
                if (intersection == null)
                {
                    continue;
                }

                var bounds = lineSpan.IsTextSpan ?
                             line.GetNormalizedTextBounds(lineSpan.TextSpan.Value) :
                             line.GetNormalizedTextBounds(intersection.Value, lineSpan.SelectionFlags.Value);
                foreach (var b in bounds)
                {
                    if (left > b.Left)
                    {
                        left = b.Left;
                    }
                    if (right < b.Right)
                    {
                        right = b.Right;
                    }
                }
            }
            if (double.IsInfinity(left) || double.IsInfinity(right))
            {
                return;
            }
            Debug.Assert(left <= right);
            if (left > right)
            {
                right = left;
            }
            double width = right - left;

            double       availWidth = Math.Max(0, hexView.ViewportWidth - width);
            double       extraScroll;
            const double EXTRA_WIDTH = 4;

            if (availWidth >= EXTRA_WIDTH)
            {
                extraScroll = EXTRA_WIDTH;
            }
            else
            {
                extraScroll = availWidth / 2;
            }

            if (hexView.ViewportLeft <= right && right <= hexView.ViewportRight)
            {
            }
            else if (right > hexView.ViewportRight)
            {
                hexView.ViewportLeft = right + extraScroll - hexView.ViewportWidth;
            }
            else
            {
                var newLeft = left - extraScroll;
                if (newLeft + hexView.ViewportWidth < right)
                {
                    newLeft = right - hexView.ViewportWidth;
                }
                hexView.ViewportLeft = newLeft;
            }
        }
예제 #16
0
		/// <summary>
		/// Scrolls a span into view
		/// </summary>
		/// <param name="lineSpan">Line span</param>
		/// <param name="options">Options</param>
		public abstract void EnsureSpanVisible(HexLineSpan lineSpan, VSTE.EnsureSpanVisibleOptions options);
		/// <summary>
		/// Creates a popup agent
		/// </summary>
		/// <param name="lineSpan">Line span</param>
		/// <param name="style">Popup style</param>
		/// <param name="content">Popup content</param>
		/// <returns></returns>
		public abstract HexSpaceReservationAgent CreatePopupAgent(HexLineSpan lineSpan, VSTA.PopupStyles style, UIElement content);