Пример #1
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="bufferSpan">Buffer span</param>
		/// <param name="flags">Flags</param>
		public HexLineSpan(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags) {
			if (bufferSpan.IsDefault)
				throw new ArgumentException();
			BufferSpan = bufferSpan;
			SelectionFlags = flags;
			TextSpan = null;
		}
Пример #2
0
		public override void ShowToolTip(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, object toolTipContent, VSTA.PopupStyles style) {
			if (bufferSpan.IsDefault)
				throw new ArgumentException();
			if (toolTipContent == null)
				throw new ArgumentNullException(nameof(toolTipContent));
			if ((style & (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent)) == (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent))
				throw new ArgumentOutOfRangeException(nameof(style));

			ClearToolTip();

			var uiElement = GetUIElement(toolTipContent);
			if (uiElement == null)
				throw new ArgumentException();

			spaceReservationManager.AgentChanged += SpaceReservationManager_AgentChanged;
			toolTipAgent = spaceReservationManager.CreatePopupAgent(bufferSpan, flags, style, uiElement);
			spaceReservationManager.AddAgent(toolTipAgent);
		}
		public override Collection<VSTF.TextBounds> GetNormalizedTextBounds(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags) {
			if (!IsValid)
				throw new ObjectDisposedException(nameof(WpfHexViewLineCollectionImpl));
			if (bufferSpan.Buffer != hexView.Buffer)
				throw new ArgumentException();
			var span = FormattedSpan.Overlap(bufferSpan);
			var list = new List<VSTF.TextBounds>();
			if (span == null)
				return new Collection<VSTF.TextBounds>(list);

			bool found = false;
			for (int i = 0; i < lines.Count; i++) {
				var line = lines[i];
				if (line.IntersectsBufferSpan(span.Value)) {
					found = true;
					list.AddRange(line.GetNormalizedTextBounds(span.Value, flags));
				}
				else if (found)
					break;
			}

			return new Collection<VSTF.TextBounds>(list);
		}
Пример #4
0
 /// <summary>
 /// Gets normalized text bounds
 /// </summary>
 /// <param name="bufferPosition">Position</param>
 /// <param name="flags">Flags</param>
 /// <returns></returns>
 public abstract Collection <VSTF.TextBounds> GetNormalizedTextBounds(HexBufferSpan bufferPosition, HexSpanSelectionFlags flags);
Пример #5
0
		/// <summary>
		/// Shows a tooltip
		/// </summary>
		/// <param name="bufferSpan">Buffer span</param>
		/// <param name="flags">Selection flags</param>
		/// <param name="toolTipContent">Tooltip content</param>
		public void ShowToolTip(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, object toolTipContent) =>
			ShowToolTip(bufferSpan, flags, toolTipContent, VSTA.PopupStyles.None);
Пример #6
0
		/// <summary>
		/// Gets a text span
		/// </summary>
		/// <param name="flags">Flags, only <see cref="HexSpanSelectionFlags.Cell"/> and
		/// <see cref="HexSpanSelectionFlags.Separator"/> are checked</param>
		/// <returns></returns>
		public VST.Span GetSpan(HexSpanSelectionFlags flags) {
			if ((flags & HexSpanSelectionFlags.Cell) == 0) {
				if ((flags & HexSpanSelectionFlags.Separator) != 0)
					throw new ArgumentOutOfRangeException(nameof(flags));
				return TextSpan;
			}
			if ((flags & HexSpanSelectionFlags.Separator) != 0)
				return FullSpan;
			return CellSpan;
		}
Пример #7
0
		IEnumerable<TextAndHexSpan> GetTextAndHexSpans(bool isColumnPresent, HexCellCollection collection, HexBufferSpan span, HexSpanSelectionFlags flags, VST.Span visibleSpan, VST.Span fullSpan) {
			if (span.IsDefault)
				throw new ArgumentException();
			if (span.Buffer != Buffer)
				throw new ArgumentException();

			if (!isColumnPresent)
				yield break;

			var overlapSpan = BufferSpan.Overlap(span);
			if (overlapSpan == null)
				yield break;

			if ((flags & (HexSpanSelectionFlags.Group0 | HexSpanSelectionFlags.Group1)) != 0) {
				bool group0 = (flags & HexSpanSelectionFlags.Group0) != 0;
				bool group1 = (flags & HexSpanSelectionFlags.Group1) != 0;

				IEnumerable<HexCell> cells;
				if ((flags & HexSpanSelectionFlags.AllCells) != 0) {
					cells = collection.GetCells();
					overlapSpan = BufferSpan;
				}
				else if ((flags & HexSpanSelectionFlags.AllVisibleCells) != 0) {
					cells = collection.GetVisibleCells();
					overlapSpan = BufferSpan;
				}
				else
					cells = collection.GetCells(overlapSpan.Value);
				HexCell firstCell = null;
				HexCell lastCell = null;
				foreach (var cell in cells) {
					if (!((cell.GroupIndex == 0 && group0) || (cell.GroupIndex == 1 && group1)))
						continue;
					if (firstCell == null) {
						firstCell = cell;
						lastCell = cell;
					}
					else if (lastCell.Index + 1 == cell.Index && lastCell.GroupIndex == cell.GroupIndex)
						lastCell = cell;
					else {
						yield return Create(collection, firstCell, lastCell, overlapSpan.Value);
						firstCell = lastCell = cell;
					}
				}
				if (firstCell != null)
					yield return Create(collection, firstCell, lastCell, overlapSpan.Value);
				yield break;
			}
			if ((flags & HexSpanSelectionFlags.AllVisibleCells) != 0) {
				yield return new TextAndHexSpan(visibleSpan, BufferSpan);
				yield break;
			}
			if ((flags & HexSpanSelectionFlags.AllCells) != 0) {
				yield return new TextAndHexSpan(fullSpan, BufferSpan);
				yield break;
			}

			if ((flags & HexSpanSelectionFlags.OneValue) != 0) {
				foreach (var cell in collection.GetCells(overlapSpan.Value)) {
					if (!cell.HasData)
						continue;
					var cellSpan = cell.GetSpan(flags);
					yield return new TextAndHexSpan(cellSpan, new HexBufferSpan(Buffer, cell.BufferSpan));
				}
			}
			else {
				int textStart = int.MaxValue;
				int textEnd = int.MinValue;
				var posStart = HexPosition.MaxValue;
				var posEnd = HexPosition.MinValue;
				foreach (var cell in collection.GetCells(overlapSpan.Value)) {
					if (!cell.HasData)
						continue;
					var cellSpan = cell.GetSpan(flags);
					textStart = Math.Min(textStart, cellSpan.Start);
					textEnd = Math.Max(textEnd, cellSpan.End);

					posStart = HexPosition.Min(posStart, cell.BufferStart);
					posEnd = HexPosition.Max(posEnd, cell.BufferEnd);
				}

				if (textStart > textEnd || posStart > posEnd)
					yield break;
				yield return new TextAndHexSpan(VST.Span.FromBounds(textStart, textEnd), new HexBufferSpan(Buffer, HexSpan.FromBounds(posStart, posEnd)));
			}
		}
Пример #8
0
		/// <summary>
		/// Gets ASCII spans
		/// </summary>
		/// <param name="span">Buffer span</param>
		/// <param name="flags">Flags</param>
		/// <returns></returns>
		public IEnumerable<TextAndHexSpan> GetAsciiSpans(HexBufferSpan span, HexSpanSelectionFlags flags) =>
			GetTextAndHexSpans(IsAsciiColumnPresent, AsciiCells, span, flags, GetAsciiSpan(onlyVisibleCells: true), GetAsciiSpan(onlyVisibleCells: false));
Пример #9
0
		/// <summary>
		/// Gets a text marker geometry
		/// </summary>
		/// <param name="bufferSpan">Span</param>
		/// <param name="flags">Flags</param>
		/// <returns></returns>
		public abstract Geometry GetTextMarkerGeometry(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags);
		/// <summary>
		/// Updates a popup agent
		/// </summary>
		/// <param name="agent">Popup agent created by <see cref="CreatePopupAgent(HexLineSpan, VSTA.PopupStyles, UIElement)"/></param>
		/// <param name="bufferSpan">New buffer span</param>
		/// <param name="flags">New selection flags</param>
		/// <param name="styles">New popup style</param>
		public void UpdatePopupAgent(HexSpaceReservationAgent agent, HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, VSTA.PopupStyles styles) =>
			UpdatePopupAgent(agent, new HexLineSpan(bufferSpan, flags), styles);
Пример #11
0
 /// <summary>
 /// Updates a popup agent
 /// </summary>
 /// <param name="agent">Popup agent created by <see cref="CreatePopupAgent(HexLineSpan, VSTA.PopupStyles, UIElement)"/></param>
 /// <param name="bufferSpan">New buffer span</param>
 /// <param name="flags">New selection flags</param>
 /// <param name="styles">New popup style</param>
 public void UpdatePopupAgent(HexSpaceReservationAgent agent, HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, VSTA.PopupStyles styles) =>
 UpdatePopupAgent(agent, new HexLineSpan(bufferSpan, flags), styles);
Пример #12
0
 /// <summary>
 /// Scrolls a span into view
 /// </summary>
 /// <param name="span">Span</param>
 /// <param name="flags">Flags</param>
 /// <param name="options">Options</param>
 public abstract void EnsureSpanVisible(HexBufferSpan span, HexSpanSelectionFlags flags, VSTE.EnsureSpanVisibleOptions options);
Пример #13
0
 /// <summary>
 /// Scrolls a span into view
 /// </summary>
 /// <param name="span">Span</param>
 /// <param name="flags">Flags</param>
 public void EnsureSpanVisible(HexBufferSpan span, HexSpanSelectionFlags flags) =>
 EnsureSpanVisible(span, flags, VSTE.EnsureSpanVisibleOptions.None);
Пример #14
0
		MarkerElement TryCreateMarkerElement(HexBufferSpan span, HexSpanSelectionFlags flags, HexMarkerTag tag) {
			Debug.Assert(tag.Type != null);
			return TryCreateMarkerElementCore(wpfHexView.WpfHexViewLines.GetMarkerGeometry(span, flags), span, tag);
		}
Пример #15
0
		/// <summary>
		/// Scrolls a span into view
		/// </summary>
		/// <param name="span">Span</param>
		/// <param name="flags">Flags</param>
		public void EnsureSpanVisible(HexBufferSpan span, HexSpanSelectionFlags flags) =>
			EnsureSpanVisible(span, flags, VSTE.EnsureSpanVisibleOptions.None);
		/// <summary>
		/// Creates a popup agent
		/// </summary>
		/// <param name="bufferSpan">Buffer span</param>
		/// <param name="flags">Selection flags</param>
		/// <param name="style">Popup style</param>
		/// <param name="content">Popup content</param>
		/// <returns></returns>
		public HexSpaceReservationAgent CreatePopupAgent(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, VSTA.PopupStyles style, UIElement content) =>
			CreatePopupAgent(new HexLineSpan(bufferSpan, flags), style, content);
Пример #17
0
		/// <summary>
		/// Scrolls a span into view
		/// </summary>
		/// <param name="span">Span</param>
		/// <param name="flags">Flags</param>
		/// <param name="options">Options</param>
		public abstract void EnsureSpanVisible(HexBufferSpan span, HexSpanSelectionFlags flags, VSTE.EnsureSpanVisibleOptions options);
		public override Geometry GetTextMarkerGeometry(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags) =>
			GetMarkerGeometry(bufferSpan, flags, false, HexMarkerHelper.TextMarkerPadding, false);
Пример #19
0
		/// <summary>
		/// Gets a text marker geometry
		/// </summary>
		/// <param name="bufferSpan">Span</param>
		/// <param name="flags">Flags</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 GetTextMarkerGeometry(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, bool clipToViewport, Thickness padding);
		public override Geometry GetTextMarkerGeometry(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, bool clipToViewport, Thickness padding) =>
			GetMarkerGeometry(bufferSpan, flags, clipToViewport, padding, false);
Пример #21
0
		/// <summary>
		/// Gets column spans in column order
		/// </summary>
		/// <param name="span">Buffer span</param>
		/// <param name="flags">Flags</param>
		/// <returns></returns>
		public IEnumerable<TextAndHexSpan> GetSpans(HexBufferSpan span, HexSpanSelectionFlags flags) {
			if (span.IsDefault)
				throw new ArgumentException();
			if (span.Buffer != Buffer)
				throw new ArgumentException();

			var overlapSpan = BufferSpan.Overlap(span);
			if (overlapSpan == null)
				yield break;

			foreach (var column in ColumnOrder) {
				switch (column) {
				case HexColumnType.Offset:
					if ((flags & HexSpanSelectionFlags.Offset) != 0 && IsOffsetColumnPresent) {
						if (BufferSpan.Contains(overlapSpan.Value))
							yield return new TextAndHexSpan(GetOffsetSpan(), BufferSpan);
					}
					break;

				case HexColumnType.Values:
					if ((flags & HexSpanSelectionFlags.Values) != 0) {
						foreach (var info in GetValuesSpans(overlapSpan.Value, flags))
							yield return info;
					}
					break;

				case HexColumnType.Ascii:
					if ((flags & HexSpanSelectionFlags.Ascii) != 0) {
						foreach (var info in GetAsciiSpans(overlapSpan.Value, flags))
							yield return info;
					}
					break;

				default:
					throw new InvalidOperationException();
				}
			}
		}
		Geometry GetMarkerGeometry(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, bool clipToViewport, Thickness padding, bool isLineGeometry) {
			if (bufferSpan.Buffer != hexView.Buffer)
				throw new ArgumentException();

			bool createOutlinedPath = false;
			PathGeometry geo = null;
			var textBounds = GetNormalizedTextBounds(bufferSpan, flags);
			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;
		}
Пример #23
0
		/// <summary>
		/// Gets normalized text bounds
		/// </summary>
		/// <param name="bufferPosition">Position</param>
		/// <param name="flags">Flags</param>
		/// <returns></returns>
		public abstract Collection<VSTF.TextBounds> GetNormalizedTextBounds(HexBufferSpan bufferPosition, HexSpanSelectionFlags flags);
		public override Geometry GetMarkerGeometry(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags) {
			if (bufferSpan.Buffer != hexView.Buffer)
				throw new ArgumentException();
			if (HexMarkerHelper.IsMultiLineSpan(hexView, bufferSpan))
				return GetLineMarkerGeometry(bufferSpan, flags);
			return GetTextMarkerGeometry(bufferSpan, flags);
		}
Пример #25
0
		public override void EnsureSpanVisible(HexBufferSpan span, HexSpanSelectionFlags flags, VSTE.EnsureSpanVisibleOptions options) {
			if (span.Buffer != hexView.Buffer)
				throw new ArgumentException();
			EnsureSpanVisibleCore(new HexLineSpan(span, flags), options);
		}
		public override Geometry GetMarkerGeometry(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, bool clipToViewport, Thickness padding) {
			if (bufferSpan.Buffer != hexView.Buffer)
				throw new ArgumentException();
			if (HexMarkerHelper.IsMultiLineSpan(hexView, bufferSpan))
				return GetLineMarkerGeometry(bufferSpan, flags, clipToViewport, padding);
			return GetTextMarkerGeometry(bufferSpan, flags, clipToViewport, padding);
		}
Пример #27
0
		/// <summary>
		/// Shows a tooltip
		/// </summary>
		/// <param name="bufferSpan">Buffer span</param>
		/// <param name="flags">Selection flags</param>
		/// <param name="toolTipContent">Tooltip content</param>
		/// <param name="style">Popup style</param>
		public abstract void ShowToolTip(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, object toolTipContent, VSTA.PopupStyles style);
 /// <summary>
 /// Creates a popup agent
 /// </summary>
 /// <param name="bufferSpan">Buffer span</param>
 /// <param name="flags">Selection flags</param>
 /// <param name="style">Popup style</param>
 /// <param name="content">Popup content</param>
 /// <returns></returns>
 public HexSpaceReservationAgent CreatePopupAgent(HexBufferSpan bufferSpan, HexSpanSelectionFlags flags, VSTA.PopupStyles style, UIElement content) =>
 CreatePopupAgent(new HexLineSpan(bufferSpan, flags), style, content);