private void addNodeButton_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { Type nodeType = (sender as ToolStripItem).Tag as Type; MyNodeView newNodeView = MyNodeView.CreateNodeView(nodeType, Desktop); DragDropEffects result = DoDragDrop(newNodeView, DragDropEffects.Copy); if (result == DragDropEffects.Copy) { MyNode newNode = m_mainForm.Project.CreateNode(nodeType); Target.AddChild(newNode); // TODO: Change to all transforms if (newNode is MyWorkingNode) { (newNode as MyWorkingNode).EnableAllTasks(); } newNodeView.Node = newNode; newNodeView.UpdateView(); newNodeView.OnEndDrag(); GraphLayoutForm_Enter(sender, EventArgs.Empty); } } }
private void addNodeButton_MouseDown(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } Type nodeType = (sender as ToolStripItem).Tag as Type; MyNodeView newNodeView = MyNodeView.CreateNodeView(nodeType, Desktop); var dataObject = new DataObject(); dataObject.SetData(typeof(MyNodeView), newNodeView); // required to get derived types from GetData DragDropEffects result = DoDragDrop(dataObject, DragDropEffects.Copy); if (result != DragDropEffects.Copy) { return; } MyNode newNode = m_mainForm.Project.CreateNode(nodeType); if (!TryAddChildNode(newNode)) { m_mainForm.Project.Network.RemoveChild(newNode); Desktop.RemoveNode(newNodeView); return; } // TODO: Change to all transforms if (newNode is MyWorkingNode) { (newNode as MyWorkingNode).EnableDefaultTasks(); } newNodeView.Node = newNode; newNodeView.UpdateView(); newNodeView.OnEndDrag(); EnterGraphLayout(); OnProjectStateChanged("Node added"); }
private void LoadContentIntoDesktop() { Dictionary <MyNode, MyNodeView> nodeViewTable = new Dictionary <MyNode, MyNodeView>(); //Global i/o for (int i = 0; i < Target.GroupInputNodes.Length; i++) { MyParentInput inputNode = Target.GroupInputNodes[i]; if (inputNode.Location == null) { inputNode.Location = new MyLocation() { X = 50, Y = 150 * i + 100 }; } MyNodeView inputView = MyNodeView.CreateNodeView(inputNode, Desktop); inputView.UpdateView(); Desktop.AddNode(inputView); nodeViewTable[inputNode] = inputView; } for (int i = 0; i < Target.GroupOutputNodes.Length; i++) { MyOutput outputNode = Target.GroupOutputNodes[i]; if (outputNode.Location == null) { outputNode.Location = new MyLocation() { X = 800, Y = 150 * i + 100 }; } MyNodeView outputView = MyNodeView.CreateNodeView(outputNode, Desktop); outputView.UpdateView(); Desktop.AddNode(outputView); nodeViewTable[outputNode] = outputView; } //other nodes foreach (MyNode node in Target.Children) { MyNodeView newNodeView = MyNodeView.CreateNodeView(node, Desktop); newNodeView.UpdateView(); Desktop.AddNode(newNodeView); nodeViewTable[node] = newNodeView; } foreach (MyNode outputNode in Target.GroupOutputNodes) { RestoreConnections(outputNode, nodeViewTable); } //other connections foreach (MyNode node in Target.Children) { RestoreConnections(node, nodeViewTable); } }