Skip to content

Commit

Permalink
DYN-4449 fixed
Browse files Browse the repository at this point in the history
connectors in groups remain collapsed on undo
  • Loading branch information
ivaylo-matov committed Mar 28, 2024
1 parent ec08a19 commit 55e0a6e
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/DynamoCoreWpf/ViewModels/Core/ConnectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public partial class ConnectorViewModel : ViewModelBase
public List<Point[]> BezierControlPoints { get; set; }

/// <summary>
/// Property tracks 'X' location from mouse poisition
/// Property tracks 'X' location from mouse position
/// </summary>
public double PanelX
{
Expand Down Expand Up @@ -119,7 +119,7 @@ public Point MousePosition
}

/// <summary>
/// This WatchHoverViewModel controls the visibility and behaviour of the WatchHoverIcon
/// This WatchHoverViewModel controls the visibility and behavior of the WatchHoverIcon
/// which appears when you hover over this connector.
/// </summary>
public ConnectorAnchorViewModel ConnectorAnchorViewModel
Expand Down Expand Up @@ -537,7 +537,7 @@ public PreviewState PreviewState

/// <summary>
/// Toggle used to turn Connector PreviewState to the correct state when a pin is selected.
/// Modelled after connector preview behaviour when a node is selected.
/// Modelled after connector preview behavior when a node is selected.
/// </summary>
public bool AnyPinSelected
{
Expand Down Expand Up @@ -1371,7 +1371,7 @@ private void HandlePinModelChanged(object sender, NotifyCollectionChangedEventAr
/// <summary>
/// Removes all connectorPinViewModels/ connectorPinModels. This occurs during 'dispose'
/// operation as well as during the 'PlaceWatchNode', where all previous pins corresponding
/// to a connector are cleareed.
/// to a connector are cleared.
/// </summary>
/// <param name="allDeletedModels"> This argument is used when placing a WatchNode from ConnectorAnchorViewModel. A reference
/// to all previous pins is required for undo/redo recorder.</param>
Expand Down Expand Up @@ -1426,9 +1426,24 @@ public void Redraw()
this.Redraw(this.ConnectorModel.End.Center);
}

this.SetCollapsedByNodeViewModel();
RaisePropertyChanged(nameof(ZIndex));
}

/// <summary>
/// Evaluates whether both nodes associated with connector are collapsed, if so, collapses the connector itself.
/// This is to address DYN-4449. Connectors are only recorded in the Undo stack when they are connected.
/// Consequently, if a group is collapsed and then moved, performing an Undo operation will not restore
/// the connector to its state at the time the move was recorded.
/// </summary>
private void SetCollapsedByNodeViewModel()
{
if (this.Nodevm.IsCollapsed && this.NodeEnd.IsCollapsed)
{
this.IsCollapsed = true;
}
}

/// <summary>
/// Recalculate the connector's points given the end point
/// </summary>
Expand Down

0 comments on commit 55e0a6e

Please sign in to comment.