public async void viewPane_Pressed(MouseObject mousObj) { CalcPoint mousePos = mousObj.currentMousePos; if (GlobalNodeHandler.TabletSelected) { if (!GlobalNodeHandler.typing) { if (GlobalNodeHandler.pick1.BoxContains(mousePos.ToPoint())) { if (GlobalNodeHandler.pick1.ChangeColorTo(mousePos.ToPoint())) { repaint(this, new EventArgs()); } } else { if (GlobalNodeHandler.transforming) { if ((transformnode = GlobalNodeHandler.viewNode.ContainsTRecChild(mousePos.X, mousePos.Y)) != null) { MindNodeAction action = new MindNodeAction(6, "Transform", transformnode); transformStart = mousePos; startWidth = transformnode.width; startHeight = transformnode.height; action.sourceSize.X = startWidth; action.sourceSize.Y = startHeight; action.startpoint.Push(new CalcPoint(transformnode.xpos, transformnode.ypos)); dragView = false; NodeStart = new CalcPoint(transformnode.xpos, transformnode.ypos); if (mousePos.X < transformnode.xpos + transformInBorder) { transformPoint.X = -1; } else if (mousePos.X > transformnode.xpos + transformnode.width - transformInBorder) { transformPoint.X = 1; } if (mousePos.Y < transformnode.ypos + transformInBorder) { transformPoint.Y = -1; } else if (mousePos.Y > transformnode.ypos + transformnode.height - transformInBorder) { transformPoint.Y = 1; } GlobalNodeHandler.actionLog.AddAction(action); } } if (GlobalNodeHandler.connecting) { if (GlobalNodeHandler.clickedNode != null) { GlobalNodeHandler.clickedNode.setSelected(false); } } if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(mousePos.X, mousePos.Y)) == null) { GlobalNodeHandler.clickedLabel = GlobalNodeHandler.viewNode.ContainsChildLabel(mousePos.X, mousePos.Y); GlobalNodeHandler.rightNode = null; mouseStartPoint = mousePos; if (transformnode == null) { dragView = true; } clickstartcount = tickcnt; if (GlobalNodeHandler.coloring) { if (GlobalNodeHandler.clickedLabel != null) { GlobalNodeHandler.clickedLabel.NodeColor = ColorPicker.selectedcolor; GlobalNodeHandler.clickedLabel.updateRepresentation(); repaint(this, new EventArgs());; } } if (GlobalNodeHandler.paste) { await GlobalNodeHandler.settings.RestoreFromClipboard(mousePos.X, mousePos.Y); } } else { if (mousObj.thisButton.Equals(MouseButton.LEFT)) { if (GlobalNodeHandler.coloring) { if (GlobalNodeHandler.clickedNode != null) { GlobalNodeHandler.clickedNode.NodeColor = ColorPicker.selectedcolor; GlobalNodeHandler.clickedNode.updateRepresentation(); repaint(this, new EventArgs());; } } if (GlobalNodeHandler.jumping) { GlobalNodeHandler.JumpInto(GlobalNodeHandler.clickedNode); repaint(this, new EventArgs()); } if (GlobalNodeHandler.copy) { GlobalNodeHandler.settings.CopyToClipboard(GlobalNodeHandler.clickedNode); } else if (GlobalNodeHandler.cut) { GlobalNodeHandler.settings.CopyToClipboard(GlobalNodeHandler.clickedNode); GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(1, "DeleteNode", GlobalNodeHandler.clickedNode)); GlobalNodeHandler.clickedNode.DeleteAllConnections(); GlobalNodeHandler.clickedNode.DeleteNode(); repaint(this, new EventArgs()); } else if (GlobalNodeHandler.connecting) { if (GlobalNodeHandler.rightNode == null) { GlobalNodeHandler.rightNode = GlobalNodeHandler.clickedNode; GlobalNodeHandler.rightNode.setSelected(true); } else if (!GlobalNodeHandler.clickedNode.Equals(GlobalNodeHandler.rightNode)) { GlobalNodeHandler.rightNode.setSelected(false); if (GlobalNodeHandler.rightNode.AddConnection(GlobalNodeHandler.clickedNode)) { GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(3, "ConnectNodes", GlobalNodeHandler.rightNode, GlobalNodeHandler.clickedNode)); } GlobalNodeHandler.rightNode.UpdateBridgesRepresentation(); GlobalNodeHandler.clickedNode = null; GlobalNodeHandler.rightNode = null; } repaint(this, new EventArgs()); } else if (GlobalNodeHandler.disconnecting) { if (GlobalNodeHandler.rightNode == null) { GlobalNodeHandler.rightNode = GlobalNodeHandler.clickedNode; GlobalNodeHandler.rightNode.setSelected(true); } else { GlobalNodeHandler.rightNode.setSelected(false); if (GlobalNodeHandler.rightNode.connNodes.Contains(GlobalNodeHandler.clickedNode)) { GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(4, "DeleteConnections", GlobalNodeHandler.rightNode, GlobalNodeHandler.clickedNode)); } else { GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(4, "DeleteConnections", GlobalNodeHandler.clickedNode, GlobalNodeHandler.rightNode)); } GlobalNodeHandler.rightNode.DeleteConnection(GlobalNodeHandler.clickedNode); GlobalNodeHandler.clickedNode.DeleteConnection(GlobalNodeHandler.rightNode); GlobalNodeHandler.clickedNode = null; GlobalNodeHandler.rightNode = null; } repaint(this, new EventArgs()); } else if (GlobalNodeHandler.deleting) { MindNodeAction action = new MindNodeAction(3, "DeleteConnections"); action.involvedNodes.Push(GlobalNodeHandler.clickedNode); foreach (MindNode m in GlobalNodeHandler.clickedNode.connNodes) { action.involvedNodes.Push(GlobalNodeHandler.clickedNode); action.involvedNodes.Push(m); } foreach (MindNode m in GlobalNodeHandler.clickedNode.backconnNodes) { action.involvedNodes.Push(m); action.involvedNodes.Push(GlobalNodeHandler.clickedNode); } GlobalNodeHandler.actionLog.AddAction(action); GlobalNodeHandler.clickedNode.DeleteAllConnections(); GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(1, "DeleteNode", GlobalNodeHandler.clickedNode)); GlobalNodeHandler.viewNode.DeleteNode(GlobalNodeHandler.clickedNode); repaint(this, new EventArgs()); } else if (GlobalNodeHandler.moving) { if (selectedGroup.Count != 0) { MindNodeAction moveaction = new MindNodeAction(2, "MoveNodes"); foreach (MindNode m in selectedGroup) { diffPoints.Add(new CalcPoint(m.xpos - GlobalNodeHandler.clickedNode.xpos, m.ypos - GlobalNodeHandler.clickedNode.ypos)); moveaction.startpoint.Push(new CalcPoint(m.xpos, m.ypos)); moveaction.involvedNodes.Push(m); } GlobalNodeHandler.actionLog.AddAction(moveaction); } else { MindNodeAction moveaction = new MindNodeAction(2, "MoveNodes", GlobalNodeHandler.clickedNode); moveaction.startpoint.Push(new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos)); GlobalNodeHandler.actionLog.AddAction(moveaction); } dragging = true; } } } if (GlobalNodeHandler.placelabel) { if (GlobalNodeHandler.clickedNode != null) { activetext.Text = GlobalNodeHandler.clickedNode.text; GlobalNodeHandler.ShowTextBox(mousObj.currentMousePos, activetext); GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(5, "ChangeText", GlobalNodeHandler.clickedNode, GlobalNodeHandler.clickedNode.text)); GlobalNodeHandler.typing = true; } else if (GlobalNodeHandler.clickedLabel != null) { activetext.Text = GlobalNodeHandler.clickedLabel.GetText(); GlobalNodeHandler.ShowTextBox(mousObj.currentMousePos, activetext); GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(5, "ChangeText", GlobalNodeHandler.clickedLabel, GlobalNodeHandler.clickedLabel.GetText())); GlobalNodeHandler.typing = true; } } } } } else if (GlobalNodeHandler.mouseSelected) { viewPane_MouseDown(mousObj); } }
public void viewPane_MouseDown(MouseObject mousObj) { CalcPoint mousePos = mousObj.currentMousePos; if (GlobalNodeHandler.pick1.BoxContains(mousePos.ToPoint()) && GlobalNodeHandler.pick1.isVisible) { if (GlobalNodeHandler.pick1.ChangeColorTo(mousePos.ToPoint())) { if (GlobalNodeHandler.typing) { if (GlobalNodeHandler.clickedNode != null) { GlobalNodeHandler.clickedNode.TextColor = ColorPicker.selectedcolor; } if (GlobalNodeHandler.clickedLabel != null) { GlobalNodeHandler.clickedLabel.TextColor = ColorPicker.selectedcolor; } } repaint(this, new EventArgs()); } } else { if (mousObj.thisButton.Equals(MouseButton.LEFT)) { clickstartcount = tickcnt; if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(mousePos.X, mousePos.Y)) == null) { surpressMouseup = false; if (selectedGroup.Count != 0) { foreach (MindNode m in selectedGroup) { m.setHovered(false); } selectedGroup = new List <MindNode>(); diffPoints = new List <CalcPoint>(); surpressMouseup = true; } mouseStartPoint = mousePos; dragRec = true; } } if (mousObj.thisButton.Equals(MouseButton.MIDDLE)) { if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(mousePos.X, mousePos.Y)) != null) { MainPage.status2 += "Middle Chosen" + "\n"; GlobalNodeHandler.clickedNode.NodeColor = ColorPicker.selectedcolor; GlobalNodeHandler.clickedNode.updateRepresentation(); repaint(this, new EventArgs());; } else if ((GlobalNodeHandler.clickedLabel = GlobalNodeHandler.viewNode.ContainsChildLabel(mousePos.X, mousePos.Y)) != null) { GlobalNodeHandler.clickedLabel.NodeColor = ColorPicker.selectedcolor; GlobalNodeHandler.clickedLabel.updateRepresentation(); repaint(this, new EventArgs());; } } if (mousObj.thisButton.Equals(MouseButton.RIGHT)) { if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(mousePos.X, mousePos.Y)) != null) { MainPage.status2 += "IsRight CLicked" + "\n"; MindNodeAction action = new MindNodeAction(GlobalNodeHandler.clickedNode); if (mousePos.X < GlobalNodeHandler.clickedNode.xpos + 5) { transformrecx = -1; transformStart = mousePos; startWidth = GlobalNodeHandler.clickedNode.width; NodeStart = new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos); action.sourceSize.X = startWidth; action.id = 6; action.name = "Transform"; GlobalNodeHandler.actionLog.AddAction(action); } else if (mousePos.X > GlobalNodeHandler.clickedNode.xpos + GlobalNodeHandler.clickedNode.width - 5) { transformrecx = 1; transformStart = mousePos; startWidth = GlobalNodeHandler.clickedNode.width; NodeStart = new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos); action.sourceSize.X = startWidth; action.id = 6; action.name = "Transform"; GlobalNodeHandler.actionLog.AddAction(action); } else if (mousePos.Y < GlobalNodeHandler.clickedNode.ypos + 5) { transformrecy = -1; transformStart = mousePos; startHeight = GlobalNodeHandler.clickedNode.height; NodeStart = new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos); action.sourceSize.Y = startHeight; action.id = 6; action.name = "Transform"; GlobalNodeHandler.actionLog.AddAction(action); } else if (mousePos.Y > GlobalNodeHandler.clickedNode.ypos + GlobalNodeHandler.clickedNode.height - 5) { transformrecy = 1; transformStart = mousePos; startHeight = GlobalNodeHandler.clickedNode.height; NodeStart = new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos); action.sourceSize.Y = startHeight; action.id = 6; action.name = "Transform"; GlobalNodeHandler.actionLog.AddAction(action); } else { if (GlobalNodeHandler.clickedNode.getSelected()) { GlobalNodeHandler.clickedNode.setHovered(false); } if (selectedGroup.Count != 0) { MindNodeAction moveaction = new MindNodeAction(2, "MoveNodes"); foreach (MindNode m in selectedGroup) { diffPoints.Add(new CalcPoint(m.xpos - GlobalNodeHandler.clickedNode.xpos, m.ypos - GlobalNodeHandler.clickedNode.ypos)); moveaction.startpoint.Push(new CalcPoint(m.xpos, m.ypos)); moveaction.involvedNodes.Push(m); } GlobalNodeHandler.actionLog.AddAction(moveaction); } else { MindNodeAction moveaction = new MindNodeAction(2, "MoveNodes", GlobalNodeHandler.clickedNode); moveaction.startpoint.Push(new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos)); GlobalNodeHandler.actionLog.AddAction(moveaction); } dragging = true; } } else { mouseStartPoint = mousePos; dragView = true; } } } }