Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin Wire from Right-click Context Menu #13102

Merged
merged 6 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions 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 @@ -3252,4 +3252,7 @@ You can manage this in Preferences -&gt; Security.</value>
<data name="UnableToAccessTrustedDirectory" xml:space="preserve">
<value>Unable To Access Trusted Directory</value>
</data>
<data name="ConnectorContextMenuHeaderPinConnector" xml:space="preserve">
<value>Pin Wire</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 @@ -3239,4 +3239,7 @@ You can manage this in Preferences -&gt; Security.</value>
<data name="UnableToAccessTrustedDirectory" xml:space="preserve">
<value>Unable To Access Directory</value>
</data>
<data name="ConnectorContextMenuHeaderPinConnector" xml:space="preserve">
<value>Pin Wire</value>
</data>
</root>
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Core/ConnectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ private void SelectConnectedCommandExecute(object parameter)
private void PinConnectorCommandExecute(object parameters)
{
MousePosition = new Point(PanelX - ConnectorPinModel.StaticWidth, PanelY - ConnectorPinModel.StaticWidth);
ConnectorAnchorViewModel.CurrentPosition = MousePosition;
if (ConnectorAnchorViewModel != null) ConnectorAnchorViewModel.CurrentPosition = MousePosition;
if (MousePosition == new Point(0, 0)) return;
var connectorPinModel = new ConnectorPinModel(MousePosition.X, MousePosition.Y, Guid.NewGuid(), model.GUID);
ConnectorModel.AddPin(connectorPinModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,24 @@ public override void Dispose()
public DelegateCommand HideConnectorSurrogateCommand { get; set; }

/// <summary>
/// Alerts ConnectorViewModel select connnected nodes.
/// Alerts ConnectorViewModel select connected nodes.
/// </summary>
public DelegateCommand SelectConnectedSurrogateCommand { get; set; }
/// <summary>
/// Alerts ConnectorViewModel to break the current connection.
/// </summary>
public DelegateCommand BreakConnectionsSurrogateCommand { get; set; }
/// <summary>
/// Alerts ConnectorViewModel to pin the connector
/// </summary>
public DelegateCommand PinConnectedSurrogateCommand { get; set; }

private void InitCommands()
{
HideConnectorSurrogateCommand = new DelegateCommand(HideConnectorSurrogateCommandExecute, x => true);
SelectConnectedSurrogateCommand = new DelegateCommand(SelectConnectedSurrogateCommandExecute, x => true);
BreakConnectionsSurrogateCommand = new DelegateCommand(BreakConnectionsSurrogateCommandExecute, x => true);
PinConnectedSurrogateCommand = new DelegateCommand(PinConnectedSurrogateCommandExecute, x => true);
}

/// <summary>
Expand Down Expand Up @@ -140,6 +145,17 @@ private void HideConnectorSurrogateCommandExecute(object obj)
ViewModel.ShowhideConnectorCommand.Execute(null);
}

/// <summary>
/// Request disposal of this viewmodel after command has run.
/// </summary>
/// <param name="obj"></param>
private void PinConnectedSurrogateCommandExecute(object obj)
{
ViewModel.PinConnectorCommand.Execute(null);
// Track pin connected nodes event
Analytics.TrackEvent(Actions.Pin, Categories.ConnectorOperations, "PinWire");
}

#endregion


Expand Down
4 changes: 3 additions & 1 deletion src/DynamoCoreWpf/Views/Core/ConnectorContextMenuView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
Width="170"
MouseLeave="OnMouseLeaveContextMenu"
ContextMenuClosing="OnContextMenuClosing">
<MenuItem x:Name="BreakItem" Header="{x:Static props:Resources.ConnectorContextMenuHeaderBreakConnection}"
<MenuItem x:Name="BreakItem" Header="{x:Static props:Resources.ConnectorContextMenuHeaderBreakConnection}"
Command="{Binding BreakConnectionsSurrogateCommand}"/>
<MenuItem x:Name="SelectItem" Header="{x:Static props:Resources.ConnectorContextMenuHeaderSelectConnected}"
Command="{Binding SelectConnectedSurrogateCommand}"/>
<MenuItem x:Name="PinItem" Header="{x:Static props:Resources.ConnectorContextMenuHeaderPinConnector}"
Command="{Binding PinConnectedSurrogateCommand}"/>
<MenuItem x:Name="HideItem" Command="{Binding HideConnectorSurrogateCommand}">
<MenuItem.Style>
<Style TargetType="MenuItem" BasedOn="{StaticResource ContextMenuItemStyle}">
Expand Down