public override bool RemoveAgent(HexSpaceReservationAgent agent) { if (agent == null) throw new ArgumentNullException(nameof(agent)); if (!spaceReservationAgents.Remove(agent)) return false; agent.GotFocus -= HexSpaceReservationAgent_GotFocus; agent.LostFocus -= HexSpaceReservationAgent_LostFocus; agent.Hide(); AgentChanged?.Invoke(this, new HexSpaceReservationAgentChangedEventArgs(agent, null)); UpdateAggregateFocus(); wpfHexView.QueueSpaceReservationStackRefresh(); return true; }
public override void AddAgent(HexSpaceReservationAgent agent) { if (wpfHexView.IsClosed) throw new InvalidOperationException(); if (agent == null) throw new ArgumentNullException(nameof(agent)); if (spaceReservationAgents.Contains(agent)) throw new InvalidOperationException(); spaceReservationAgents.Add(agent); agent.GotFocus += HexSpaceReservationAgent_GotFocus; agent.LostFocus += HexSpaceReservationAgent_LostFocus; AgentChanged?.Invoke(this, new HexSpaceReservationAgentChangedEventArgs(null, agent)); UpdateAggregateFocus(); wpfHexView.QueueSpaceReservationStackRefresh(); }
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); }
/// <summary> /// Adds an agent /// </summary> /// <param name="agent">Agent to add</param> public abstract void AddAgent(HexSpaceReservationAgent agent);
public override void UpdatePopupAgent(HexSpaceReservationAgent agent, HexLineSpan lineSpan, VSTA.PopupStyles styles) { if (wpfHexView.IsClosed) throw new InvalidOperationException(); if (agent == 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 == null) throw new ArgumentException(); popupAgent.Update(lineSpan, styles); UpdateAggregateFocus(); wpfHexView.QueueSpaceReservationStackRefresh(); }
/// <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);
/// <summary> /// Constructor /// </summary> /// <param name="oldAgent">Old agent or null</param> /// <param name="newAgent">New agent or null</param> public HexSpaceReservationAgentChangedEventArgs(HexSpaceReservationAgent oldAgent, HexSpaceReservationAgent newAgent) { NewAgent = newAgent; OldAgent = oldAgent; }
/// <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);
/// <summary> /// Updates a popup agent /// </summary> /// <param name="agent">Popup agent created by <see cref="CreatePopupAgent(HexLineSpan, VSTA.PopupStyles, UIElement)"/></param> /// <param name="line">Line</param> /// <param name="span">Line span</param> /// <param name="styles">New popup style</param> public void UpdatePopupAgent(HexSpaceReservationAgent agent, HexBufferLine line, VST.Span span, VSTA.PopupStyles styles) => UpdatePopupAgent(agent, new HexLineSpan(line, span), styles);
void SpaceReservationManager_AgentChanged(object sender, HexSpaceReservationAgentChangedEventArgs e) { if (e.OldAgent == toolTipAgent) { spaceReservationManager.AgentChanged -= SpaceReservationManager_AgentChanged; toolTipAgent = null; } }
/// <summary> /// Updates a popup agent /// </summary> /// <param name="agent">Popup agent created by <see cref="CreatePopupAgent(HexLineSpan, VSTA.PopupStyles, UIElement)"/></param> /// <param name="span">Span and selection flags</param> /// <param name="styles">New popup style</param> public void UpdatePopupAgent(HexSpaceReservationAgent agent, HexBufferSpanSelection span, VSTA.PopupStyles styles) => UpdatePopupAgent(agent, span.BufferSpan, span.SelectionFlags, styles);
/// <summary> /// Constructor /// </summary> /// <param name="oldAgent">Old agent or null</param> /// <param name="newAgent">New agent or null</param> public HexSpaceReservationAgentChangedEventArgs(HexSpaceReservationAgent oldAgent, HexSpaceReservationAgent newAgent) { NewAgent = newAgent; OldAgent = oldAgent; }
/// <summary> /// Adds an agent /// </summary> /// <param name="agent">Agent to add</param> public abstract void AddAgent(HexSpaceReservationAgent agent);
/// <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);
/// <summary> /// Updates a popup agent /// </summary> /// <param name="agent">Popup agent created by <see cref="CreatePopupAgent(HexLineSpan, VSTA.PopupStyles, UIElement)"/></param> /// <param name="line">Line</param> /// <param name="span">Line span</param> /// <param name="styles">New popup style</param> public void UpdatePopupAgent(HexSpaceReservationAgent agent, HexBufferLine line, VST.Span span, VSTA.PopupStyles styles) => UpdatePopupAgent(agent, new HexLineSpan(line, span), styles);
/// <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);
SessionState TryGetSessionState(HexSpaceReservationAgent agent) { foreach (var sessionState in sessionStates) { if (sessionState.SpaceReservationAgent == agent) return sessionState; } return null; }
/// <summary> /// Updates a popup agent /// </summary> /// <param name="agent">Popup agent created by <see cref="CreatePopupAgent(HexLineSpan, VSTA.PopupStyles, UIElement)"/></param> /// <param name="span">Span and selection flags</param> /// <param name="styles">New popup style</param> public void UpdatePopupAgent(HexSpaceReservationAgent agent, HexBufferSpanSelection span, VSTA.PopupStyles styles) => UpdatePopupAgent(agent, span.BufferSpan, span.SelectionFlags, styles);
/// <summary> /// Removes an agent /// </summary> /// <param name="agent">Agent to remove</param> /// <returns></returns> public abstract bool RemoveAgent(HexSpaceReservationAgent agent);
/// <summary> /// Removes an agent /// </summary> /// <param name="agent">Agent to remove</param> /// <returns></returns> public abstract bool RemoveAgent(HexSpaceReservationAgent agent);