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 propertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { MyNodeView nodeView = null; foreach (GraphLayoutForm graphView in m_mainForm.GraphViews.Values) { if (graphView.Desktop.FocusElement is MyNodeView && (graphView.Desktop.FocusElement as MyNodeView).Node == propertyGrid.SelectedObject) { nodeView = graphView.Desktop.FocusElement as MyNodeView; nodeView.UpdateView(); } if (propertyGrid.SelectedObject is MyNodeGroup && graphView.Target == propertyGrid.SelectedObject) { graphView.Text = graphView.Target.Name; } graphView.Desktop.Invalidate(); } if (nodeView != null) { if (nodeView.BranchChangeNeeded) { if (nodeView.OutputBranchChangeNeeded) { m_mainForm.CloseObservers(nodeView.Node); } if (nodeView.Node is MyNodeGroup) { m_mainForm.ReloadGraphLayout(nodeView.Node as MyNodeGroup); } (nodeView as MyVariableBranchView).UpdateBranches(); } } propertyGrid.Refresh(); if (Target is MyNode) { UpdateTitleAndButtons(); m_mainForm.MemoryBlocksView.UpdateView(); } if (Target is MyAbstractObserver && m_mainForm.SimulationHandler.State == MySimulationHandler.SimulationState.PAUSED) { m_mainForm.UpdateObserverView(Target as MyAbstractObserver); } }
private void propertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { //TODO: rewrite this, no need to loop all, just topmost foreach (GraphLayoutForm graphView in m_mainForm.GraphViews.Values) { if (graphView.Desktop.FocusElement is MyNodeView) { MyNodeView nodeView = graphView.Desktop.FocusElement as MyNodeView; nodeView.UpdateView(); } graphView.Desktop.Invalidate(); } }
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); } }