private void RemoveNode_Click(object sender, EventArgs e) { foreach (var a in NodeSelectPanel.Controls) { if (a is UIelements.NodePanel) { UIelements.NodePanel panel = (a as UIelements.NodePanel); if (panel.Selected) { panel.NodeUnselect(); selectedNode = null; NodeSelectPanel.Controls.Remove(panel); panel.Node.OnThresholdReached(panel.Node, new EventArgs()); RemoveNode.Enabled = false; CoordXInput.Enabled = false; CoordYInput.Enabled = false; CoordXInput.Value = 0; CoordYInput.Value = 0; } } } if (NodeSelectPanel.Controls.Count < 1) { RemoveNode.Enabled = false; } }
private void AddNodeButton_Click(object sender, EventArgs e) { if (NodeSelectPanel.Controls.Count < 20) { ODMRPelements.Node newNode = new ODMRPelements.Node(NodeSelectPanel.Controls) { CoordinateX = 0, CoordinateY = 0 }; UIelements.NodePanel newPanel = new UIelements.NodePanel(newNode); newPanel.Click += NewPanel_Click; NodeSelectPanel.Controls.Add(newPanel); NewPanel_Click(newPanel, new EventArgs()); newNode.OnThresholdReached(newNode, new EventArgs()); } if (NodeSelectPanel.Controls.Count > 0) { RemoveNode.Enabled = true; } }