示例#1
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);
            UpdateRevisionIndex();
            if (InvalidateViews != null)
            {
                InvalidateViews(this, EventArgs.Empty);
            }

            if (NodeRemoved != null)
            {
                NodeRemoved(this, new NodeEventArgs(node));
            }
        }
示例#2
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;
            UpdateRevisionIndex();
            if (InvalidateViews != null)
            {
                InvalidateViews(this, EventArgs.Empty);
            }
            return(true);
        }
示例#3
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;
                UpdateRevisionIndex();
                if (InvalidateViews != null)
                {
                    InvalidateViews(this, EventArgs.Empty);
                }
            }
            return(modified);
        }
示例#4
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)
            {
                UpdateRevisionIndex();
                if (InvalidateViews != null)
                {
                    InvalidateViews(this, EventArgs.Empty);
                }
            }
            return(modified);
        }
示例#5
0
 private void OnNodeAdded(object sender, AcceptNodeEventArgs args)
 {
     OnNodesChange();
 }
示例#6
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));
        }
示例#7
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;
        }
示例#8
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;
        }
示例#9
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;
        }
示例#10
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;
            UpdateRevisionIndex();
            if (InvalidateViews != null)
                InvalidateViews(this, EventArgs.Empty);
            return true;
        }
示例#11
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) {
                UpdateRevisionIndex();
                if (InvalidateViews != null) 
                    InvalidateViews(this, EventArgs.Empty);
            }
            return modified;
        }
示例#12
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);
            UpdateRevisionIndex();
            if (InvalidateViews != null) 
                InvalidateViews(this, EventArgs.Empty);

            if (NodeRemoved != null)
                NodeRemoved(this, new NodeEventArgs(node));
        }