Skip to content

Commit

Permalink
Alt + left click to ungroup target group (#13157)
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongTang authored Aug 3, 2022
1 parent 99215f1 commit 638b8e9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3267,4 +3267,7 @@ You can manage this in Preferences -&gt; Security.</value>
<data name="InvalidDraggingOperationMessgae" xml:space="preserve">
<value>Nothing is being dragged. If you see this message, most likely your recent Dynamo interaction is not recommended.</value>
</data>
<data name="UngroupParentGroupWarning" xml:space="preserve">
<value>Dynamo cannot ungroup when there is no parent group.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3254,4 +3254,7 @@ You can manage this in Preferences -&gt; Security.</value>
<data name="InvalidDraggingOperationMessgae" xml:space="preserve">
<value>Nothing is being dragged. If you see this message, most likely your recent Dynamo interaction is not recommended.</value>
</data>
<data name="UngroupParentGroupWarning" xml:space="preserve">
<value>Dynamo cannot ungroup when there is no parent group.</value>
</data>
</root>
5 changes: 3 additions & 2 deletions src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ private void Popup_StepClosed(string name, Step.StepTypes stepType)
/// </summary>
/// <param name="content">The target content to display.</param>
/// TODO: Make this API out of guide manager to a more generic place
internal void CreateRealTimeInfoWindow(string content)
internal void CreateRealTimeInfoWindow(string content, bool stayOpen = false)
{
//Search a UIElement with the Name "statusBarPanel" inside the Dynamo VisualTree
UIElement hostUIElement = GuideUtilities.FindChild(mainRootElement, "statusBarPanel");
Expand All @@ -552,7 +552,8 @@ internal void CreateRealTimeInfoWindow(string content)
VerticalOffset = ExitTourVerticalOffset,
HorizontalOffset = ExitTourHorizontalOffset,
Placement = PlacementMode.Left,
TextContent = content
TextContent = content,
StaysOpen = stayOpen
};

if (hostUIElement != null)
Expand Down
23 changes: 22 additions & 1 deletion src/DynamoCoreWpf/ViewModels/Core/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ private void InitiateDragSequence()
if (this.currentState != State.None)
throw new InvalidOperationException();

// Before setting the drag state,
// Before setting the drag state on node or note,
// Alt + left click triggers removal of group node or note belongs to
if (Keyboard.IsKeyDown(Key.LeftAlt) && !DynamoSelection.Instance.Selection.OfType<AnnotationModel>().Any())
{
Expand All @@ -1101,6 +1101,27 @@ private void InitiateDragSequence()
}
}

// Before setting the drag state on group
// Alt + left click triggers removal of group from parent group
if (Keyboard.IsKeyDown(Key.LeftAlt) && DynamoSelection.Instance.Selection.OfType<AnnotationModel>().Any())
{
var model = DynamoSelection.Instance.Selection.OfType<AnnotationModel>().FirstOrDefault();
{
var parentGroup = owningWorkspace.Annotations
.Where(x => x.AnnotationModel.ContainsModel(model))
.FirstOrDefault();
if (parentGroup != null)
{
// Only trigger when parent group exist
owningWorkspace.Annotations.Where(x => x.AnnotationModel.GUID == model.GUID).FirstOrDefault().RemoveGroupFromGroupCommand.Execute(null);
}
else
{
owningWorkspace.DynamoViewModel.MainGuideManager.CreateRealTimeInfoWindow(Wpf.Properties.Resources.UngroupParentGroupWarning, true);
}
}
}

SetCurrentState(State.DragSetup);
}

Expand Down

0 comments on commit 638b8e9

Please sign in to comment.