i've noticed that when i drag and drop an item from the symbol palette to the diagram
that the id will be modified and some random text gets added to the id. Due the reason that i'm generating the ids by my own i'd like to prevent this.
|
By default, the “Id” property is unique for all diagram elements such as nodes/connectors and it couldn’t be changed at run time. |
I also noticed that the constructor for the item gets not called when i drop it to the diagram.
Which could be the reason for this behavior.
|
When we drag and drop the item from palette onto the diagram, the constructor for that item will be called in the source level. Could you please share us more details such as exact scenario of an issue with the screenshot or video? |
Each node class specifies it's type, style, dimensions and also generates the identifier.
As you can see, i'm adding the type of the node to the id which is
my current solution to validate the connectors, because not all nodes are allowed to connect to each other. On the other hand i'm subscribing to some diagram events (i.e. OnSelectionChanged)
where i'd like to check what type of node the current select shape is.
In this case i'm casting the DiagramNode to my base class (NodeBase)
to access the Type property (Enum). Or for events like OnUserHandleMouseDown to provide shortcuts that are able to create new type safe nodes and connectors at runtime. Which does not work at the moment (see my other thread).
|
We suggest you to use Node’s “AddInfo” property to set the node information on this property and also you can use that property to access the node in events.
Code example:
public void OnSelectionChange(IBlazorSelectionChangeEventArgs args)
{
if (args.NewValue != null && args.NewValue.Nodes.Count >= 0)
{
NodeModel node = args.NewValue.Nodes[0] as NodeModel;
Dictionary<string, object> addinfo = JsonConvert.DeserializeObject<Dictionary<string, object>>(node.AddInfo.ToString());
CommandNode commandNode = null;
foreach(DiagramNode node1 in diagram.Nodes)
{
if(node1.Id.Contains(addinfo["id"].ToString()))
{
commandNode = node1 as CommandNode;
break;
}
}
}
}
|
So, from my point of view this makes it much more comfortable
to work with the anonym shapes and from C# perspective this should work well,
because the observable Node and Connector collections, that are bound to the Diagram, contains the correct instances (types). But from my experience
with this Diagram Component so far, there seems to be a wrapper available, that translates my blazor side type safe implementation into something else. And it seems to be, that the forth and backwards transformation between
the diagram component and my implementation loses information for some reason. |
To construct an interactive blazor component, JS was required so this is the optimal way to create a diagram like interactive components. So we could not say this as wrapper component.
|
Regarding IBlazorDragEnterEventArgs args, |
We are able to reproduce the reported issue at our end and we have logged this as an issue with “Need to change evtargs node/conenctor type as DiagramNode/DiagramConnector in Blazor”. The fix for the issue will be included on our weekly nuget release which will be available on 24th February 2020.
|
await diagram.Select(new ObservableCollection<DiagramNode>() { diagram.Nodes[1] }, null); |