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"); }