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

Connector context menu lazy load #12091

Merged
merged 37 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fb342f0
Polyline + thick outline removed.
M-JULIANI Sep 27, 2021
095af46
Removed 'ConnectorType` menu from view->connectors.
M-JULIANI Sep 27, 2021
0c815b7
Updated connector styles.
M-JULIANI Sep 27, 2021
389947b
New resources added/old ones removed. Minor UI updates to reflect moc…
M-JULIANI Sep 27, 2021
41e0b9e
Merge branch 'master' into WireConnector-UI-Modifications
M-JULIANI Sep 29, 2021
85a5bba
First commit.
M-JULIANI Sep 29, 2021
2fcf08b
Cleanup. On-the-fly ContextMenu working.
M-JULIANI Sep 29, 2021
81b3c95
Applying ContextMenu styling.
M-JULIANI Sep 29, 2021
648da3e
Added (stole) ContextMenu styling.
M-JULIANI Sep 29, 2021
1d855eb
Added resource strings to ContextMenu control.
M-JULIANI Sep 29, 2021
4f46d9d
Update AssemblySharedInfo.cs
M-JULIANI Sep 29, 2021
7fbf5e8
Unused ref removal.
M-JULIANI Sep 30, 2021
e738d94
Cleanup.
M-JULIANI Sep 30, 2021
55e752f
Merge branch 'master' into Connector-ContextMenu-LazyLoad
M-JULIANI Sep 30, 2021
41ac6a4
Fixes.
M-JULIANI Sep 30, 2021
4f18a29
First commit.
M-JULIANI Sep 29, 2021
1e35f5d
Cleanup. On-the-fly ContextMenu working.
M-JULIANI Sep 29, 2021
2251ef1
Applying ContextMenu styling.
M-JULIANI Sep 29, 2021
c74cd1b
Added (stole) ContextMenu styling.
M-JULIANI Sep 29, 2021
4111fba
Added resource strings to ContextMenu control.
M-JULIANI Sep 29, 2021
ffc4e5b
Update AssemblySharedInfo.cs
M-JULIANI Sep 29, 2021
fa913c9
Cleanup.
M-JULIANI Sep 30, 2021
e39e683
Adding 10 to margin (#12076)
filipeotero Sep 29, 2021
385cdb8
Update AnnotationModel.cs (#12086)
SHKnudsen Sep 29, 2021
909027b
Crash Fix. Add visibility trigger to empty tooltip strings. (#12069)
saintentropy Sep 29, 2021
ae1c5c0
DYN-3992: Upgrade LibG (#12060)
sm6srw Sep 29, 2021
555fe6e
mark test as failure temporarily to fix build issues (#12090)
aparajit-pratap Sep 29, 2021
fb9edf2
add pins to groups (#12070)
SHKnudsen Sep 30, 2021
11a1dff
Remove outdated logic (#12081)
sm6srw Sep 30, 2021
662fad9
Wire connector UI modifications (#12072)
M-JULIANI Sep 30, 2021
dd00cfb
[DYN-4105] Make sure nodes gets added to parent group (#12084)
SHKnudsen Sep 30, 2021
de4f580
Updates resource strings from Remove to Delete (#12088)
OliverEGreen Sep 30, 2021
9fc77e5
Improved ContextMenu behaviour.
M-JULIANI Sep 30, 2021
ce80adc
Merge branch 'Connector-ContextMenu-LazyLoad' of https://github.com/M…
M-JULIANI Sep 30, 2021
cda0280
PR fix.
M-JULIANI Oct 1, 2021
4f700f8
Removed unnecessary refs.
M-JULIANI Oct 1, 2021
1ca8cf9
Added unit tests for ConnectorContextMenu construction/disposal/comma…
M-JULIANI Oct 1, 2021
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
8 changes: 8 additions & 0 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
<Compile Include="ViewModels\PackageManager\PackagePathViewModel.cs" />
<Compile Include="ViewModels\Preview\CompactBubbleViewModel.cs" />
<Compile Include="ViewModels\Preview\ConnectorAnchorViewModel.cs" />
<Compile Include="ViewModels\Preview\ConnectorContextMenuViewModel.cs" />
<Compile Include="ViewModels\RunSettingsViewModel.cs" />
<Compile Include="ViewModels\Search\BrowserInternalElementViewModel.cs" />
<Compile Include="ViewModels\Search\BrowserItemViewModel.cs" />
Expand Down Expand Up @@ -335,6 +336,9 @@
<Compile Include="Views\Core\ConnectorAnchorView.xaml.cs">
<DependentUpon>ConnectorAnchorView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Core\ConnectorContextMenuView.xaml.cs">
<DependentUpon>ConnectorContextMenuView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Core\DynamoOpenFileDialog.cs" />
<Compile Include="Views\Core\ConnectorPinView.xaml.cs">
<DependentUpon>ConnectorPinView.xaml</DependentUpon>
Expand Down Expand Up @@ -475,6 +479,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Core\ConnectorContextMenuView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\GuidedTour\RealTimeInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
15 changes: 12 additions & 3 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

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

11 changes: 7 additions & 4 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2319,8 +2319,8 @@ Uninstall the following packages: {0}?</value>
<data name="ConnectorContextMenuHeaderBreakConnections" xml:space="preserve">
<value>Break Connections</value>
</data>
<data name="ConnectorContextMenuHeaderPinConnector" xml:space="preserve">
<value>Pin Wire</value>
<data name="ConnectorContextMenuHeaderShowConnector" xml:space="preserve">
<value>Show Wire</value>
M-JULIANI marked this conversation as resolved.
Show resolved Hide resolved
</data>
<data name="ConnectorContextMenuHeaderSelectConnected" xml:space="preserve">
<value>Select Connected</value>
Expand Down Expand Up @@ -2681,10 +2681,13 @@ Delete the following packages: {2}?
</data>
<data name="PackageManagerPackageUpdated" xml:space="preserve">
<value>Updated</value>
<comment>Displays next to the package name in the Package Search window if the package has been updated in the last 30 days.</comment>
<comment>Displays next to the package name in the Package Search window if the package has been updated in the last 30 days.</comment>
</data>
<data name="PackageManagerPackageNew" xml:space="preserve">
<value>New</value>
<comment>Displays next to the package name in the Package Search window if the package has been added in the last 30 days.</comment>
</data>
</root>
<data name="ConnectorContextMenuHeaderHideConnector" xml:space="preserve">
<value>Hide Wire</value>
</data>
</root>
9 changes: 6 additions & 3 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ You will get a chance to save your work.</value>
</data>
<data name="PackageManagerPackageUpdated" xml:space="preserve">
<value>Updated</value>
<comment>Displays next to the package name in the Package Search window if the package has been updated in the last 30 days.</comment>
<comment>Displays next to the package name in the Package Search window if the package has been updated in the last 30 days.</comment>
</data>
<data name="PackageManagerPackageNew" xml:space="preserve">
<value>New</value>
Expand Down Expand Up @@ -2373,8 +2373,8 @@ Uninstall the following packages: {0}?</value>
<data name="ConnectorContextMenuHeaderBreakConnections" xml:space="preserve">
<value>Break Connections</value>
</data>
<data name="ConnectorContextMenuHeaderPinConnector" xml:space="preserve">
<value>Pin Wire</value>
<data name="ConnectorContextMenuHeaderShowConnector" xml:space="preserve">
<value>Show Wire</value>
</data>
<data name="ConnectorContextMenuHeaderSelectConnected" xml:space="preserve">
<value>Select Connected</value>
Expand Down Expand Up @@ -2684,4 +2684,7 @@ Delete the following packages: {2}?
<data name="NodeAutoCompleteNotAvailableForCollapsedGroups" xml:space="preserve">
<value>Node AutoComplete is not available on ports belonging to collapsed groups.</value>
</data>
<data name="ConnectorContextMenuHeaderHideConnector" xml:space="preserve">
<value>Hide Wire</value>
</data>
</root>
44 changes: 11 additions & 33 deletions src/DynamoCoreWpf/UI/Themes/Modern/Connectors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewModels="clr-namespace:Dynamo.ViewModels;assembly=DynamoCoreWpf"
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf"
xmlns:converters="clr-namespace:Dynamo.Controls;assembly=DynamoCoreWpf"
xmlns:props="clr-namespace:Dynamo.Wpf.Properties;assembly=DynamoCoreWpf"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:views="clr-namespace:Dynamo.Controls;assembly=DynamoCoreWpf"
xmlns:nodes="clr-namespace:Dynamo.Nodes;assembly=DynamoCoreWpf"
Expand All @@ -12,6 +10,9 @@
<ResourceDictionary.MergedDictionaries>
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoConvertersDictionaryUri}" />
</ResourceDictionary.MergedDictionaries>
<DataTemplate DataType="{x:Type viewModels:ConnectorContextMenuViewModel}">
<views:ConnectorContextMenuView DataContext="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type viewModels:ConnectorAnchorViewModel}">
<views:ConnectorAnchorView DataContext="{Binding}" />
</DataTemplate>
Expand Down Expand Up @@ -90,36 +91,11 @@
<DataTemplate DataType="{x:Type viewModels:ConnectorViewModel}">
<Grid x:Name="MainGrid"
Visibility="Visible">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static props:Resources.ConnectorContextMenuHeaderBreakConnections}" Command="{Binding BreakConnectionCommand}"/>
<MenuItem Header="{x:Static props:Resources.ConnectorContextMenuHeaderSelectConnected}" Command="{Binding SelectConnectedCommand}"/>
<MenuItem Command="{Binding HideConnectorCommand}">
<MenuItem.Style>
<Style TargetType="MenuItem">
<Setter Property="IsChecked" Value="False"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsCollapsed}" Value="False">
<Setter Property="Header" Value="Hide Wire"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsCollapsed}" Value="True">
<Setter Property="Header" Value="Show Wire"/>
</DataTrigger>
</Style.Triggers>
</Style>
</MenuItem.Style>
</MenuItem>
<!--Added for action at right click (contextmenu)-->
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<i:InvokeCommandAction Command="{Binding ConnectorSelectionCommand}"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<i:InvokeCommandAction Command="{Binding ConnectorSelectionCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ContextMenu>
</Grid.ContextMenu>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseRightButtonDown">
<i:InvokeCommandAction Command="{Binding InstantiateContextMenuCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid.Resources>
<SolidColorBrush x:Key="BConnectorSelection"
Color="{Binding PreviewState, Converter={StaticResource ConnectionStateToColorConverter}, UpdateSourceTrigger=PropertyChanged}">
Expand Down Expand Up @@ -151,10 +127,12 @@
</i:EventTrigger>
</i:Interaction.Triggers>
</Path>
<ContentControl Content="{Binding ConnectorContextMenuViewModel}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>
<ContentControl Content="{Binding ConnectorAnchorViewModel}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>

<ContentControl Content="{Binding ConnectorPinViewCollection}"
ContentTemplate="{StaticResource ShowPinCollection}"/>
</Grid>
Expand Down
6 changes: 3 additions & 3 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2498,7 +2498,7 @@
</Setter>
</Style>

<Style x:Key="ContextMenuStyle" TargetType="{x:Type ContextMenu}">
<Style x:Key="NodeContextMenuStyle" TargetType="{x:Type ContextMenu}">
M-JULIANI marked this conversation as resolved.
Show resolved Hide resolved
<Setter Property="Placement" Value="MousePoint" />
<Setter Property="Foreground" Value="{StaticResource NodeContextMenuForeground}" />
<Setter Property="FontSize" Value="13px" />
Expand All @@ -2510,9 +2510,9 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border x:Name="Border"
Background="{TemplateBinding Background}"
Background="{StaticResource NodeContextMenuBackground}"
BorderThickness="0px">
<StackPanel Margin="0,5"
<StackPanel Margin="0,10"
ClipToBounds="True"
IsItemsHost="True"
Orientation="Vertical" />
Expand Down
3 changes: 0 additions & 3 deletions src/DynamoCoreWpf/ViewModels/Core/ConnectorPinViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Linq;
using Dynamo.Configuration;
using Dynamo.Graph;
using Dynamo.Selection;
using Dynamo.UI.Commands;
using Dynamo.Wpf.ViewModels.Core;
using Newtonsoft.Json;

namespace Dynamo.ViewModels
Expand Down
54 changes: 50 additions & 4 deletions src/DynamoCoreWpf/ViewModels/Core/ConnectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public partial class ConnectorViewModel : ViewModelBase
private double panelY;
private Point mousePosition;
private ConnectorAnchorViewModel connectorAnchorViewModel;
private ConnectorContextMenuViewModel connectorContextMenuViewModel;
private readonly WorkspaceViewModel workspaceViewModel;
private PortModel activeStartPort;
private ConnectorModel model;
Expand Down Expand Up @@ -123,9 +124,18 @@ public ConnectorAnchorViewModel ConnectorAnchorViewModel
get { return connectorAnchorViewModel; }
private set { connectorAnchorViewModel = value; RaisePropertyChanged(nameof(ConnectorAnchorViewModel)); }
}
/// <summary>
/// Used to point to the active start port corresponding to this connector
/// </summary>

/// <summary>
/// Instantiates the context menu when required.
/// </summary>
public ConnectorContextMenuViewModel ConnectorContextMenuViewModel
{
get { return connectorContextMenuViewModel; }
private set { connectorContextMenuViewModel = value; RaisePropertyChanged(nameof(ConnectorContextMenuViewModel)); }
}
/// <summary>
/// Used to point to the active start port corresponding to this connector
/// </summary>
public PortModel ActiveStartPort { get { return activeStartPort; } internal set { activeStartPort = value; } }

/// <summary>
Expand Down Expand Up @@ -608,7 +618,14 @@ model.Start.Owner is null||
/// Delegate command to run when 'Pin Wire' item is clicked on this connector ContextMenu.
/// </summary>
public DelegateCommand PinConnectorCommand { get; set; }
/// <summary>
/// Delegate command to trigger a construction of a ContextMenu.
/// </summary>
public DelegateCommand InstantiateContextMenuCommand { get; set; }

/// <summary>
/// Delegate command run to capture right click of connector.
/// </summary>
public DelegateCommand ConnectorSelectionCommand { get; set; }

/// <summary>
Expand Down Expand Up @@ -661,6 +678,23 @@ private void DisposeAnchor(object arg1, EventArgs arg2)
ConnectorAnchorViewModel = null;
}

internal void CreateContextMenu()
{
ConnectorContextMenuViewModel = new ConnectorContextMenuViewModel(this)
{
CurrentPosition = MousePosition,
IsCollapsed = this.IsCollapsed
};
ConnectorContextMenuViewModel.RequestDispose += DisposeContextMenu;
}

private void DisposeContextMenu(object arg1, EventArgs arg2)
{
ConnectorContextMenuViewModel.RequestDispose -= DisposeContextMenu;
ConnectorContextMenuViewModel = null;
ConnectorSelectionCommand.Execute(null);
}

/// <summary>
/// If hover == true, then after the timer is up something will appear.
/// IF set to false, the object in question will disappear.
Expand Down Expand Up @@ -774,6 +808,17 @@ private void PinConnectorCommandExecute(object parameters)
workspaceViewModel.Model.HasUnsavedChanges = true;
}

/// <summary>
/// Instantiates this connector's ContextMenu.
/// </summary>
/// <param name="parameters"></param>
private void InstantiateContextMenuCommandExecute(object parameters)
{
//Updates PreviewState of connector.
ConnectorSelectionCommand.Execute(null);
CreateContextMenu();
}

/// <summary>
/// Helper function ssed for placing (re-placing) connector
/// pins when a WatchNode is placed in the center of a connector.
Expand Down Expand Up @@ -813,7 +858,8 @@ private void InitializeCommands()
MouseHoverCommand = new DelegateCommand(MouseHoverCommandExecute, CanRunMouseHover);
MouseUnhoverCommand = new DelegateCommand(MouseUnhoverCommandExecute, CanRunMouseUnhover);
PinConnectorCommand = new DelegateCommand(PinConnectorCommandExecute, x => true);
ConnectorSelectionCommand = new DelegateCommand(ConnectorSelectionCommandExecute, x => true);
InstantiateContextMenuCommand = new DelegateCommand(InstantiateContextMenuCommandExecute, x => !IsConnecting);
ConnectorSelectionCommand = new DelegateCommand(ConnectorSelectionCommandExecute, x => !IsConnecting);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using CoreNodeModels;
using Dynamo.UI.Commands;
using System;
using Dynamo.Graph;

namespace Dynamo.ViewModels
{
Expand Down
Loading