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); }
public override HexIntellisensePresenter TryCreateIntellisensePresenter(HexIntellisenseSession session) { if (session == null) throw new ArgumentNullException(nameof(session)); foreach (var lz in intellisensePresenterProviders) { var presenter = lz.Value.TryCreateIntellisensePresenter(session); if (presenter != null) return presenter; } return null; }
/// <summary> /// Moves a session to the top of the stack /// </summary> /// <param name="session">Session</param> public abstract void MoveSessionToTop(HexIntellisenseSession session);
/// <summary> /// Adds a session to the top of the stack /// </summary> /// <param name="session">Session</param> public abstract void PushSession(HexIntellisenseSession session);
public abstract HexIntellisensePresenter TryCreateIntellisensePresenter(HexIntellisenseSession session);
public SessionState(HexIntellisenseSession session) { Session = session; }
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()}"); } }
SessionState GetSessionState(HexIntellisenseSession session) { int index = GetSessionStateIndex(session); if (index >= 0) return sessionStates[index]; var sessionState = new SessionState(session); sessionStates.Add(sessionState); return sessionState; }
int GetSessionStateIndex(HexIntellisenseSession session) { for (int i = 0; i < sessionStates.Count; i++) { if (sessionStates[i].Session == session) return i; } return -1; }
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); }