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
DUI: Re-implement logic of getting know ElementType of each node #4190
Conversation
@@ -504,7 +504,7 @@ protected DynamoModel(IStartConfiguration config) | |||
PackageLoader.MessageLogged += LogMessage; | |||
PackageLoader.RequestLoadNodeLibrary += LoadNodeLibrary; | |||
PackageLoader.RequestLoadCustomNodeDirectory += | |||
(dir) => this.CustomNodeManager.AddUninitializedCustomNodesInPath(dir, isTestMode); | |||
(dir) => this.CustomNodeManager.AddUninitializedCustomNodesInPath(dir, isTestMode, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If custom node is loaded with PackageLoader it's package member!
else | ||
return ElementTypeEnum.RegularCategory; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use Any
here instead of All
and not iterate through all the sub elements? Also, the last return
can now be ElementTypes.None
after the above change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @Benglin . I thought about that and had little conversation with @elayabharath .
We can have next situation: in "Core" user adds some custom node or custom dll. But even with new added node/dll Core should remain as regular category... As well as other builtin categories e.g. operators, geometry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so we are going to just return ElementTypes.None
here always?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think next structure:
Core -> ElementTypes.BuiltIn
Core, inside of which added some custom node -> ElementTypes.None
Category with just user's custom nodes -> ElementTypes.CustomNode
Category with just user's imported assembly -> ElementTypes.ZeroTouch
Rhynamo -> ElementTypes.Packaged
I think we can use None for mixed categories...
@@ -795,6 +795,7 @@ private void LoadNodeLibrary(Assembly assem) | |||
{ | |||
NodeFactory.AddTypeFactoryAndLoader(type.Type); | |||
NodeFactory.AddAlsoKnownAs(type.Type, type.AlsoKnownAs); | |||
type.IsPackageMember = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Case for "Interactive" dlls. E.g. Color Range.
return ElementTypes.None; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer this to be done less frequently, I'm imagining this ElementType
to be called each time the UI needs the information to display an icon, then that might be too many evaluation on these collections entries
and subCategories
. If we can do them when these two collection changed, then it's one-time evaluation:
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
// Perform the "entries.Any" and "subCategories.Any" calls here, then set "ElementType"...
if (entries.Any ... && subCategories.Any ...)
ElementType = ElementTypes.BuiltIn;
}
public ElementTypes ElementType { get; private set; }
If you can do a count and see if we get more calls for ElementType.get
or OnCollectionChanged
, then decide which is the best way to go about doing it. Please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @Benglin . |
Thanks @aosyatnik, this looks good. I have two questions:
|
Thanks @Benglin . if (functionDescriptor.IsBuiltIn)
ElementType |= ElementTypes.BuiltIn;
Xaml will be in next PR. |
Thanks for doing this, @aosyatnik! LGTM. |
DUI: Re-implement logic of getting know ElementType of each node
This is the first PR, that is connected to task "Show category type on hover mouse".
Purpose
On hover over the library item, the type of add-on is display to its right. PKG / DLL
If Package contains custom nodes, these custom nodes consider as package members. The same with dlls. (if package contains dll, this dll considers as package member)
Solution
I want to add new property
ElementType
, which can be RegularNode, RegularCategory, CustomNode, CustomDll, Package.Overview
If user imports custom dll, it should be consider as custom dll.
If user opens custom node, it should be consider as custom node.
If user loads package(with custom dlls and custom nodes), they should be consider as package members.
BUT for Dynamo there is no difference, if custom node/dll is part of package or not.
That's why I added new properties
IsPackageMember
andIsBuiltIn
for Custom node and Usual node respectively.Since Dynamo uses the same functions to load custom nodes/dlls during importing Packages and simple importing/opening, the only posibily, to determine is it member of Package or not, is, when we call Package Manager, say to loading method THIS IS Package Member.
Reviewers
@Benglin , please take a look.
Link to YouTrack:
MAGN-5740 DUI: Re-implement logic of getting know ElementType of each node