int GetSessionStateIndex(HexIntellisenseSession session) { for (int i = 0; i < sessionStates.Count; i++) { if (sessionStates[i].Session == session) { return(i); } } return(-1); }
public override HexIntellisensePresenter TryCreateIntellisensePresenter(HexIntellisenseSession session) { var quickInfoSession = session as HexQuickInfoSession; if (quickInfoSession == null) { return(null); } if (quickInfoSession.TrackMouse) { return(new HexQuickInfoPresenter(quickInfoSession)); } return(new HexSpaceReservationQuickInfoPresenter(quickInfoSession)); }
SessionState GetSessionState(HexIntellisenseSession session) { int index = GetSessionStateIndex(session); if (index >= 0) { return(sessionStates[index]); } var sessionState = new SessionState(session); sessionStates.Add(sessionState); return(sessionState); }
public override HexIntellisensePresenter?TryCreateIntellisensePresenter(HexIntellisenseSession session) { if (session is null) { throw new ArgumentNullException(nameof(session)); } foreach (var lz in intellisensePresenterProviders) { var presenter = lz.Value.TryCreateIntellisensePresenter(session); if (!(presenter is null)) { return(presenter); } } return(null); }
void PresenterUpdated(HexIntellisenseSession session) { var sessionState = GetSessionState(session); if (sessionState.SpaceReservationAgent != null) { sessionState.SpaceReservationManager.RemoveAgent(sessionState.SpaceReservationAgent); } Debug.Assert(sessionState.SpaceReservationAgent == null); var presenter = session.Presenter; var popupPresenter = presenter as IHexPopupIntellisensePresenter; if (popupPresenter != null) { if (sessionState.SpaceReservationManager == null) { sessionState.SetSpaceReservationManager(wpfHexView.GetSpaceReservationManager(popupPresenter.SpaceReservationManagerName)); sessionState.SpaceReservationManager.AgentChanged += SpaceReservationManager_AgentChanged; } UnregisterPopupIntellisensePresenterEvents(sessionState.PopupIntellisensePresenter); sessionState.PopupIntellisensePresenter = popupPresenter; RegisterPopupIntellisensePresenterEvents(sessionState.PopupIntellisensePresenter); var presentationSpan = popupPresenter.PresentationSpan; var surfaceElement = popupPresenter.SurfaceElement; if (!presentationSpan.IsDefault && surfaceElement != null) { sessionState.SpaceReservationAgent = sessionState.SpaceReservationManager.CreatePopupAgent(presentationSpan, popupPresenter.PopupStyles, surfaceElement); sessionState.SpaceReservationManager.AddAgent(sessionState.SpaceReservationAgent); } } else { var customPresenter = presenter as IHexCustomIntellisensePresenter; if (customPresenter != null) { customPresenter.Render(); } else { Debug.Assert(presenter == null, $"Unsupported presenter: {presenter?.GetType()}"); } } }
public override void MoveSessionToTop(HexIntellisenseSession session) { if (wpfHexView.IsClosed) { throw new InvalidOperationException(); } if (session == null) { throw new ArgumentNullException(nameof(session)); } int index = sessions.IndexOf(session); if (index < 0) { throw new InvalidOperationException(); } if (index == 0) { return; } sessions.Move(index, 0); }
public override void PushSession(HexIntellisenseSession session) { if (wpfHexView.IsClosed) { throw new InvalidOperationException(); } if (session == null) { throw new ArgumentNullException(nameof(session)); } if (sessions.Contains(session)) { throw new InvalidOperationException(); } if (sessions.Count == 0) { commandTargetFilter.HookKeyboard(); } sessions.Insert(0, session); session.Dismissed += Session_Dismissed; session.PresenterChanged += Session_PresenterChanged; PresenterUpdated(session); }
public abstract HexIntellisensePresenter?TryCreateIntellisensePresenter(HexIntellisenseSession session);
public SessionState(HexIntellisenseSession session) => Session = session;
/// <summary> /// Creates a <see cref="HexIntellisensePresenter"/> or returns null /// </summary> /// <param name="session">Session</param> /// <returns></returns> public abstract HexIntellisensePresenter TryCreateIntellisensePresenter(HexIntellisenseSession session);