Ejemplo n.º 1
0
        public bool RemoveNodes(IEnumerable<Node> nodes)
        {
            if (nodes == null)
                return false;

            bool modified = false;
            foreach (var node in nodes)
            {
                if (node == null)
                    continue;
                if (NodeRemoving != null)
                {
                    var eventArgs = new AcceptNodeEventArgs(node);
                    NodeRemoving(this, eventArgs);
                    if (eventArgs.Cancel)
                        continue;
                }

                if (HasFocus(node))
                    FocusElement = null;

                DisconnectAll(node);
                graphNodes.Remove(node);
                modified = true;

                if (NodeRemoved != null)
                    NodeRemoved(this, new NodeEventArgs(node));
            }
            if (modified)
                this.Invalidate();
            return modified;
        }
Ejemplo n.º 2
0
        private void Desktop_NodeRemoving(object sender, AcceptNodeEventArgs e)
        {
            e.Cancel = TestIfInsideSimulation();

            MyNodeView nodeView = e.Node as MyNodeView;
            e.Cancel |= nodeView.Node is MyParentInput || nodeView.Node is MyOutput;
        }
Ejemplo n.º 3
0
        public void RemoveNode(Node node)
        {
            if (node == null)
                return;

            if (NodeRemoving != null)
            {
                var eventArgs = new AcceptNodeEventArgs(node);
                NodeRemoving(this, eventArgs);
                if (eventArgs.Cancel)
                    return;
            }
            if (HasFocus(node))
                FocusElement = null;

            DisconnectAll(node);
            graphNodes.Remove(node);
            this.Invalidate();

            if (NodeRemoved != null)
                NodeRemoved(this, new NodeEventArgs(node));
        }
Ejemplo n.º 4
0
        public bool AddNodes(IEnumerable<Node> nodes)
        {
            if (nodes == null)
                return false;

            int		index		= 0;
            bool	modified	= false;
            Node	lastNode	= null;
            foreach (var node in nodes)
            {
                if (node == null)
                    continue;
                if (graphNodes.Contains(node))
                    continue;

                graphNodes.Insert(index, node); index++;

                if (NodeAdded != null)
                {
                    var eventArgs = new AcceptNodeEventArgs(node);
                    NodeAdded(this, eventArgs);
                    if (eventArgs.Cancel)
                    {
                        graphNodes.Remove(node);
                        modified = true;
                    } else
                        lastNode = node;
                } else
                    lastNode = node;
            }
            if (lastNode != null)
            {
                BringElementToFront(lastNode);
                FocusElement = lastNode;
                this.Invalidate();
            }
            return modified;
        }
Ejemplo n.º 5
0
        public bool AddNode(Node node)
        {
            if (node == null ||
                graphNodes.Contains(node))
                return false;

            graphNodes.Insert(0, node);
            if (NodeAdded != null)
            {
                var eventArgs = new AcceptNodeEventArgs(node);
                NodeAdded(this, eventArgs);
                if (eventArgs.Cancel)
                {
                    graphNodes.Remove(node);
                    return false;
                }
            }

            BringElementToFront(node);
            FocusElement = node;
            this.Invalidate();
            return true;
        }
Ejemplo n.º 6
0
        private void Desktop_NodeRemoving(object sender, AcceptNodeEventArgs e)
        {
            e.Cancel = CanChangeGraph();

            // Suppress state saving - connections will get removed which would generate multiple steps.
            m_mainForm.SuppressStateSaving = true;

            MyNodeView nodeView = e.Node as MyNodeView;
            e.Cancel |= nodeView.Node is MyParentInput || nodeView.Node is MyOutput;
        }
Ejemplo n.º 7
0
 private void onNodeAdded(object sender, AcceptNodeEventArgs e)
 {
     List<Node> nodes = (List<Node>)graphCtrl.Nodes;
     if (nodes.Count > 0)
         m_dirty = true;
     graphCtrl.Focus();
 }