private void OnDeleteNode() { foreach (var node in InputSockets.ToArray()) { node.Disconnect(this); } foreach (var node in OutputSockets.ToArray()) { node.Disconnect(this); } InputSockets.Clear(); OutputSockets.Clear(); if (null != root) { root.RemoveNode(this); } }
protected override void OnContentChanged(object oldContent, object newContent) { base.OnContentChanged(oldContent, newContent); contentNode = newContent as INode; if (null == contentNode) { return; } foreach (var connectedOutput in GetConnectedOutputs().Select(x => x.contentNode).Where(x => null != x)) { contentNode.OnOutputConnected(connectedOutput); } foreach (var connectedInput in GetConnectedInputs().Select(x => x.contentNode).Where(x => null != x)) { contentNode.OnOutputConnected(connectedInput); } InputSockets.Clear(); OutputSockets.Clear(); if (null != contentNode.Inputs) { InputSockets.AddRange(contentNode.Inputs .Select(x => { var socket = GetSocket(x); SubscribeInputSocket(socket); return(socket); })); } if (null != contentNode.Outputs) { OutputSockets.AddRange(contentNode.Outputs .Select(x => { var socket = GetSocket(x); SubscribeOutputSocket(socket); return(socket); })); } contentNode.PropertyChanged += ContentNodeOnPropertyChanged; CanAutoAddInputs = contentNode.AutoAddInputs; CanAutoAddOutputs = contentNode.AutoAddOutputs; AddInputSocket(); AddOutputSocket(); }