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

Split Port Views and ViewModels #12062

Merged
merged 23 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
aa92395
Separate Port view models and views
saintentropy Sep 24, 2021
c530e65
Use the new ViewModels in Nodes and Annotation
saintentropy Sep 24, 2021
b5fdf8d
Merge branch 'master' into SplitPorts
saintentropy Sep 25, 2021
58ec88a
Remove ProxyPortViewModel wrapper. Add prop
saintentropy Sep 25, 2021
0f6bfb9
Merge conflict fix
saintentropy Sep 25, 2021
de75be8
Remove extra visabliity checks
saintentropy Sep 25, 2021
5c293be
Missing Obsolete tag
saintentropy Sep 25, 2021
381b3f9
Remove inport binding to margin
saintentropy Sep 28, 2021
272e99a
Fix setter for CodeBlock styling
saintentropy Sep 29, 2021
3b4b395
Fix visiblity for outport context menu arrow
saintentropy Sep 29, 2021
874b4f0
Merge branch 'master' into SplitPorts
saintentropy Sep 30, 2021
c9fefc2
Merge branch 'master' into SplitPorts
saintentropy Oct 1, 2021
9675b2b
PR comments on obsolete resource dictionary
saintentropy Oct 1, 2021
80fa830
PR comments: _ removed, nameof, brackets
saintentropy Oct 1, 2021
6151b65
PR comments on spinner background color change
saintentropy Oct 1, 2021
b149eda
missing dispose calls for portViewModel
saintentropy Oct 1, 2021
fb00318
fix bug with nameof properties
saintentropy Oct 1, 2021
018d2de
Merge branch 'master' into SplitPorts
saintentropy Oct 4, 2021
b4c4f02
Remove extra default color
saintentropy Oct 5, 2021
d83b86d
Merge branch 'SplitPorts' of https://github.com/saintentropy/Dynamo i…
saintentropy Oct 5, 2021
1ce8ee8
Merge branch 'master' into SplitPorts
QilongTang Oct 6, 2021
92efcd6
Fix regression
saintentropy Oct 6, 2021
436885d
Merge branch 'master' into SplitPorts
saintentropy Oct 6, 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
10 changes: 10 additions & 0 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@
<Compile Include="ViewModels\Core\DynamoViewModelBranding.cs" />
<Compile Include="ViewModels\Core\GalleryViewModel.cs" />
<Compile Include="ViewModels\Core\HomeWorkspaceViewModel.cs" />
<Compile Include="ViewModels\Core\InPortViewModel.cs" />
<Compile Include="ViewModels\Core\OutPortViewModel.cs" />
<Compile Include="ViewModels\Core\SerializationExtensions.cs" />
<Compile Include="ViewModels\GuidedTour\PopupWindowViewModel.cs" />
<Compile Include="ViewModels\GuidedTour\SurveyPopupViewModel.cs" />
Expand Down Expand Up @@ -475,6 +477,14 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<None Include="UI\Themes\Modern\InPorts.xaml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
</None>
<None Include="UI\Themes\Modern\OutPorts.xaml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Page Include="Views\GuidedTour\RealTimeInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
28 changes: 28 additions & 0 deletions src/DynamoCoreWpf/UI/SharedResourceDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public static class SharedDictionaryManager
private static ResourceDictionary _connectorsDictionary;
private static ResourceDictionary _portsDictionary;
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
private static ResourceDictionary _sidebarGridDictionary;
private static ResourceDictionary _outPortsDictionary;
saintentropy marked this conversation as resolved.
Show resolved Hide resolved
private static ResourceDictionary _inPortsDictionary;

public static string ThemesDirectory
{
Expand Down Expand Up @@ -119,6 +121,16 @@ public static Uri PortsDictionaryUri
get { return new Uri(Path.Combine(ThemesDirectory, "Ports.xaml")); }
}

public static Uri OutPortsDictionaryUri
{
get { return new Uri(Path.Combine(ThemesDirectory, "OutPorts.xaml")); }
}

public static Uri InPortsDictionaryUri
{
get { return new Uri(Path.Combine(ThemesDirectory, "InPorts.xaml")); }
}

public static Uri SidebarGridDictionaryUri
{
get { return new Uri(Path.Combine(ThemesDirectory, "SidebarGridStyleDictionary.xaml")); }
Expand Down Expand Up @@ -195,6 +207,22 @@ public static ResourceDictionary PortsDictionary
}
}

public static ResourceDictionary OutPortsDictionary
{
get
{
return _outPortsDictionary ?? (_outPortsDictionary = new ResourceDictionary() { Source = OutPortsDictionaryUri });
}
}

public static ResourceDictionary InPortsDictionary
{
get
{
return _inPortsDictionary ?? (_inPortsDictionary = new ResourceDictionary() { Source = InPortsDictionaryUri });
}
}

public static ResourceDictionary SidebarGrid
{
get
Expand Down
375 changes: 375 additions & 0 deletions src/DynamoCoreWpf/UI/Themes/Modern/InPorts.xaml

Large diffs are not rendered by default.

339 changes: 339 additions & 0 deletions src/DynamoCoreWpf/UI/Themes/Modern/OutPorts.xaml

Large diffs are not rendered by default.

35 changes: 26 additions & 9 deletions src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public AnnotationViewModel(WorkspaceViewModel workspaceViewModel, AnnotationMode
internal void SetGroupInputPorts()
{
InPorts.Clear();
List<ProxyPortViewModel> newPortViewModels;
List<PortViewModel> newPortViewModels;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you sum this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you asking here @mjkkirschner

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry @saintentropy - why did you make all these changes related to proxy type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of additional type, @saintentropy is using a property on PortViewModel to indicate if it is a proxy.. Given there is no new property in ProxyPortViewModel yet, this should be OK. But in the future if we need to store additional info, this may not scale. But I am fine with it for now, How about you @mjkkirschner?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjkkirschner @QilongTang I maid the change as the purpose of the new wrapper class ProxyPortViewModel was just to provide a type check and did not have a different feature set. Because there are now essentially two base classes for ports it seemed to make more sense to add the proxy status as a property (for the is proxy check) and keep the classes a bit simpler in the code.


if (!AnnotationModel.HasNestedGroups)
{
Expand All @@ -562,7 +562,7 @@ internal void SetGroupInputPorts()
// visually add them to the group but they
// should still reference their NodeModel
// owner
newPortViewModels = CreateProxyPorts(originalInPorts);
newPortViewModels = CreateProxyInPorts(originalInPorts);

if (newPortViewModels == null) return;
InPorts.AddRange(newPortViewModels);
Expand All @@ -586,7 +586,7 @@ internal void SetGroupInputPorts()

originalInPorts = GetGroupInPorts().Concat(groupedGroupsInPorts);

newPortViewModels = CreateProxyPorts(originalInPorts);
newPortViewModels = CreateProxyInPorts(originalInPorts);

if (newPortViewModels == null) return;
InPorts.AddRange(newPortViewModels);
Expand All @@ -599,7 +599,7 @@ internal void SetGroupInputPorts()
internal void SetGroupOutPorts()
{
OutPorts.Clear();
List<ProxyPortViewModel> newPortViewModels;
List<PortViewModel> newPortViewModels;

if (!AnnotationModel.HasNestedGroups)
{
Expand All @@ -612,7 +612,7 @@ internal void SetGroupOutPorts()
// visually add them to the group but they
// should still reference their NodeModel
// owner
newPortViewModels = CreateProxyPorts(originalOutPorts);
newPortViewModels = CreateProxyOutPorts(originalOutPorts);

if (newPortViewModels == null) return;
OutPorts.AddRange(newPortViewModels);
Expand All @@ -635,7 +635,7 @@ internal void SetGroupOutPorts()

originalOutPorts = GetGroupOutPorts().Concat(groupedGroupsOutPorts);

newPortViewModels = CreateProxyPorts(originalOutPorts);
newPortViewModels = CreateProxyOutPorts(originalOutPorts);

if (newPortViewModels == null) return;
OutPorts.AddRange(newPortViewModels);
Expand Down Expand Up @@ -685,14 +685,31 @@ internal IEnumerable<PortModel> GetGroupOutPorts(IEnumerable<NodeModel> ownerNod
);
}

private List<ProxyPortViewModel> CreateProxyPorts(IEnumerable<PortModel> groupPortModels)
private List<PortViewModel> CreateProxyInPorts(IEnumerable<PortModel> groupPortModels)
{
var originalPortViewModels = WorkspaceViewModel.Nodes
.SelectMany(x => x.InPorts.Concat(x.OutPorts))
.SelectMany(x => x.InPorts)
.Where(x => groupPortModels.Contains(x.PortModel))
saintentropy marked this conversation as resolved.
Show resolved Hide resolved
.ToList();

var newPortViewModels = new List<PortViewModel>();
for (int i = 0; i < groupPortModels.Count(); i++)
{
var model = groupPortModels.ElementAt(i);
newPortViewModels.Add(originalPortViewModels[i].CreateProxyPortViewModel(model));
}

return newPortViewModels;
}

private List<PortViewModel> CreateProxyOutPorts(IEnumerable<PortModel> groupPortModels)
saintentropy marked this conversation as resolved.
Show resolved Hide resolved
{
var originalPortViewModels = WorkspaceViewModel.Nodes
.SelectMany(x => x.OutPorts)
.Where(x => groupPortModels.Contains(x.PortModel))
.ToList();

var newPortViewModels = new List<ProxyPortViewModel>();
var newPortViewModels = new List<PortViewModel>();
for (int i = 0; i < groupPortModels.Count(); i++)
{
var model = groupPortModels.ElementAt(i);
Expand Down
Loading