|
@@ -108,10 +108,34 @@ internal class NodeGraphViewModel : ViewModelBase, INodeGraphHandler, IDisposabl
|
|
|
connection.OutputProperty.ConnectedInputs.Add(connection.InputProperty);
|
|
|
|
|
|
Connections.Add(connection);
|
|
|
+
|
|
|
+ AddToFramesPartOf(connection.InputNode);
|
|
|
+ AddToFramesPartOf(connection.OutputNode);
|
|
|
|
|
|
StructureTree.Update(this);
|
|
|
}
|
|
|
|
|
|
+ private void AddToFramesPartOf(INodeHandler node)
|
|
|
+ {
|
|
|
+ node.TraverseBackwards(x =>
|
|
|
+ {
|
|
|
+ if (x is IPairNodeEndViewModel)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ if (x is not IPairNodeStartViewModel)
|
|
|
+ return true;
|
|
|
+
|
|
|
+ var zone = Frames
|
|
|
+ .OfType<NodeZoneViewModel>()
|
|
|
+ .First(z => z.Start == x);
|
|
|
+
|
|
|
+ if (!zone.Nodes.Contains(node))
|
|
|
+ zone.Nodes.Add(node);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
public void RemoveConnection(Guid nodeId, string property)
|
|
|
{
|
|
|
var connection = Connections.FirstOrDefault(x =>
|
|
@@ -123,6 +147,9 @@ internal class NodeGraphViewModel : ViewModelBase, INodeGraphHandler, IDisposabl
|
|
|
Connections.Remove(connection);
|
|
|
}
|
|
|
|
|
|
+ RemoveFromFramesNotPartOf(connection.InputNode);
|
|
|
+ RemoveFromFramesNotPartOf(connection.OutputNode);
|
|
|
+
|
|
|
var node = AllNodes.FirstOrDefault(x => x.Id == nodeId);
|
|
|
if (node != null)
|
|
|
{
|
|
@@ -136,6 +163,33 @@ internal class NodeGraphViewModel : ViewModelBase, INodeGraphHandler, IDisposabl
|
|
|
StructureTree.Update(this);
|
|
|
}
|
|
|
|
|
|
+ private void RemoveFromFramesNotPartOf(INodeHandler node)
|
|
|
+ {
|
|
|
+ var framesPartOf =
|
|
|
+ Frames.OfType<NodeZoneViewModel>().Where(x => x.Nodes.Contains(node));
|
|
|
+
|
|
|
+ foreach (var frame in framesPartOf)
|
|
|
+ {
|
|
|
+ var stillConnected = false;
|
|
|
+
|
|
|
+ node.TraverseBackwards(x =>
|
|
|
+ {
|
|
|
+ if (x is not IPairNodeStartViewModel || frame.Start != x)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ stillConnected = true;
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!stillConnected)
|
|
|
+ {
|
|
|
+ frame.Nodes.Remove(node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void RemoveConnections(Guid nodeId)
|
|
|
{
|
|
|
var connections = Connections
|