public void mouseUp(object sender, MouseEventArgs e) { if (mainForm.nodeBeingDragged != null) { Item item = null; switch (mainForm.nodeBeingDragged.Name) { case "nodeAndGate": item = new AndGate(); break; case "nodeOrGate": item = new OrGate(); break; case "nodeNotGate": item = new NotGate(); break; case "nodeNorGate": item = new NorGate(); break; case "nodeXorGate": item = new XorGate(); break; case "nodeXnorGate": item = new XnorGate(); break; case "nodeNandGate": item = new NandGate(); break; case "nodeSwitch": item = new Switch(); break; case "nodeLamp": item = new Lamp(); break; } if (item != null) { Point absoluteCoordinates = viewport.getAbsoluteCoordinates(new Point(e.X, e.Y)); item.Location = absoluteCoordinates; if (mainForm.circuitManager.addItem(item)) { mainForm.unsavedChangesMade = true; } mainForm.nodeBeingDragged = null; mainForm.refresh(); } } if (e.Button == MouseButtons.Right) { if (selectedConnectionDrawing != null) { selectedConnectionDrawing.Disconnect(); mainForm.circuitManager.deleteConnection(selectedConnectionDrawing.Connection); mainForm.refresh(); } } }
private void panelViewport_MouseUp(object sender, MouseEventArgs e) { if (nodeBeingDragged == null) { return; } else { Item item = null; switch (nodeBeingDragged.Name) { case "nodeAndGate": item = new AndGate(); break; case "nodeOrGate": item = new OrGate(); break; case "nodeNotGate": item = new NotGate(); break; case "nodeSwitch": item = new Switch(); break; case "nodeLamp": item = new Lamp(); break; } if (item != null) { Point absoluteCoordinates = canvas.getAbsoluteCoordinates(new Point(e.X, e.Y)); item.Location = absoluteCoordinates; if (circuitManager.addItem(item)) { refresh(); } } } }