private void BindNodesCountToForm(frmMain form) { form.OnInputNodesValueChanged += (newValue) => { if (newValue > InputNodes.Count) { for (int i = newValue - InputNodes.Count; i > 0; i--) { var inNode = new InputNode(this, "Schema", "DataLocation"); AddInputNode(inNode); } } else if (newValue < InputNodes.Count) { for (int i = InputNodes.Count - newValue; i > 0; i--) { RemoveNode(InputNodes.Last()); } } }; form.OnOutputNodesValueChanged += (newValue) => { if (newValue > OutputNodes.Count) { for (int i = newValue - OutputNodes.Count; i > 0; i--) { var outNode = new OutputNode(this, "Schema", "DataLocation"); outNode.State = new ModuleState(); AddOutputNode(outNode); } } else if (newValue < OutputNodes.Count) { for (int i = OutputNodes.Count - newValue; i > 0; i--) { RemoveNode(OutputNodes.Last()); } } }; }