private void NodeOnMouseDown(object sender, MouseButtonEventArgs e) { var node = sender as Node; if (node == null) { return; } if (e.ClickCount == 2) { // Allow this just for the Composed Nodes if (node.GetType() == typeof(ComposedNode)) { composedNode = node as ComposedNode; if (composedNode != null) { _subVplControl = new ExtendedVplControl.Controls.ExtendedSubVplControl(composedNode.portMap); var subWin = new Window { Height = 500, Width = 500, WindowStartupLocation = WindowStartupLocation.CenterOwner, Content = _subVplControl, WindowStyle = WindowStyle.ToolWindow, Title = "Composition Node" }; subWin.Loaded += SubWinOnLoaded; subWin.Closing += SubWinOnClosing; subWin.ShowDialog(); // Forward the node ... _subVplControl.ApplyChanges(node as ComposedNode); } e.Handled = true; } } }
public void ApplyChanges(ComposedNode node) { // Serialize the processing var path = @"C:\Users\Cornelius\Desktop\Test.vplxml"; SerializeNetwork(path); foreach (var item in _extendedPortMap) { if (node.portMap.ContainsKey(item.Key)) { continue; } if (item.Value.PortType == PortTypes.Output) { if (item.Value.DataType == typeof(int)) { node.AddInputPortToNode("Integer", typeof(int)); node.InputPorts[node.InputPorts.Count - 1].Data = item.Value.Data; } else if (item.Value.DataType == typeof(double)) { node.AddInputPortToNode("Double", typeof(double)); node.InputPorts[node.InputPorts.Count - 1].Data = item.Value.Data; } else if (item.Value.DataType == typeof(string)) { node.AddInputPortToNode("String", typeof(string)); node.InputPorts[node.InputPorts.Count - 1].Data = item.Value.Data; } else if (item.Value.DataType == typeof(object)) { node.AddInputPortToNode("Object", typeof(object)); node.InputPorts[node.InputPorts.Count - 1].Data = item.Value.Data; } } else if (item.Value.PortType == PortTypes.Input) { if (item.Value.DataType == typeof(int)) { node.AddOutputPortToNode("Integer", typeof(int)); node.OutputPorts[node.OutputPorts.Count - 1].Data = item.Value.Data; } else if (item.Value.DataType == typeof(double)) { node.AddOutputPortToNode("Double", typeof(double)); node.OutputPorts[node.OutputPorts.Count - 1].Data = item.Value.Data; } else if (item.Value.DataType == typeof(string)) { node.AddOutputPortToNode("String", typeof(string)); node.OutputPorts[node.OutputPorts.Count - 1].Data = item.Value.Data; } else if (item.Value.DataType == typeof(object)) { node.AddOutputPortToNode("Object", typeof(object)); node.OutputPorts[node.OutputPorts.Count - 1].Data = item.Value.Data; } } } }