void CreateHandler(ShowTabContentEventArgs e, HexViewDocumentTabContent content, HexPosition? fileOffset, AddressReference addrRef) {
			if (!e.Success)
				return;

			Debug.Assert(e.Tab.Content == content);
			var uiContext = e.Tab.UIContext as HexViewDocumentTabUIContext;
			Debug.Assert(uiContext != null);
			if (uiContext == null || fileOffset == null)
				return;

			var start = fileOffset.Value;
			var end = HexPosition.Min(start + addrRef.Length, HexPosition.MaxEndPosition);
			if (!IsVisible(uiContext.HexView, start, end)) {
				uiContext.HexView.Options.SetOptionValue(DefaultHexViewOptions.StartPositionId, uiContext.HexView.Buffer.Span.Start);
				uiContext.HexView.Options.SetOptionValue(DefaultHexViewOptions.EndPositionId, uiContext.HexView.Buffer.Span.End);
				RedisplayHexLines(uiContext.HexView);
				if (!IsVisible(uiContext.HexView, start, end))
					return;
			}
			if (e.HasMovedCaret)
				return;

			if (!uiContext.HexView.VisualElement.IsLoaded) {
				RoutedEventHandler loaded = null;
				loaded = (s, e2) => {
					uiContext.HexView.VisualElement.Loaded -= loaded;
					InitializeHexView(uiContext.HexView, start, end);
				};
				uiContext.HexView.VisualElement.Loaded += loaded;
			}
			else
				InitializeHexView(uiContext.HexView, start, end);
			e.HasMovedCaret = true;
		}
Exemplo n.º 2
0
		void OnShown(object uiState, Action<ShowTabContentEventArgs> onShownHandler, IShowContext showCtx, ShowTabContentResult result) {
			if (uiState != null)
				RestoreUIState(uiState);
			if (onShownHandler != null || showCtx.OnShown != null) {
				var e = new ShowTabContentEventArgs(result, this);
				onShownHandler?.Invoke(e);
				showCtx.OnShown?.Invoke(e);
			}
		}