void OnConnectionRemoved(object sender, NodeConnectionEventArgs e)
        {
            MyConnection connToDelete = e.Connection.Tag as MyConnection;

            if (connToDelete != null)
            {
                connToDelete.Disconnect();
            }
        }
        void OnConnectionRemoved(object sender, NodeConnectionEventArgs e)
        {
            MyConnection connToDelete = e.Connection.Tag as MyConnection;

            if (connToDelete != null)
            {
                connToDelete.Disconnect();

                m_mainForm.ProjectStateChanged("Connection removed");
            }

            m_mainForm.RefreshConnections(this);
        }
示例#3
0
 void OnConnectionDoubleClick(object sender, NodeConnectionEventArgs e)
 {
     e.Connection.Name = "Connection " + counter++;
 }
示例#4
0
        private void OnConnectionRemoved(object sender, NodeConnectionEventArgs e)
        {
            var connection = e.Connection.Tag as Connection;

            connection?.Disconnect();
        }
示例#5
0
        public void OnConnectionRemoved()
        {
            //Arrange
            var sourceNodeId = Guid.NewGuid();
            var targetNodeId = Guid.NewGuid();
            var eventArgs = new NodeConnectionEventArgs {SourceNodeId = sourceNodeId, TargetNodeId = targetNodeId};

            //Act
            _form.OnConnectionRemoved(null, eventArgs);

            //Assert
            _mockPresenter.Verify(p => p.RemoveConnection(sourceNodeId, targetNodeId));
        }
示例#6
0
        public void OnConnectionAdded_NewConnection()
        {
            //Arrange
            var sourceNodeId = Guid.NewGuid();
            var targetNodeId = Guid.NewGuid();
            var eventArgs = new NodeConnectionEventArgs { SourceNodeId = sourceNodeId, TargetNodeId = targetNodeId };
            _mockPresenter.Setup(p => p.AddConnection(sourceNodeId, targetNodeId)).Returns(true);

            //Act
            _form.OnConnectionAdded(null, eventArgs);

            //Assert
            _mockFormInteractionHelper.Verify(
                f => f.ShowMessage(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButtons>()), Times.Never());
            _mockMapControl.Verify(m => m.StopNodeConnector());
        }
示例#7
0
        public void OnConnectionAdded_ConnectionAlreadyExists()
        {
            //Arrange
            var sourceNodeId = Guid.NewGuid();
            var targetNodeId = Guid.NewGuid();
            var eventArgs = new NodeConnectionEventArgs {SourceNodeId = sourceNodeId, TargetNodeId = targetNodeId};
            _mockPresenter.Setup(p => p.AddConnection(sourceNodeId, targetNodeId)).Returns(false);

            //Act
            _form.OnConnectionAdded(null, eventArgs);

            //Assert
            _mockFormInteractionHelper.Verify(f => f.ShowMessage("Connection already exists between those nodes.", "Existing Connection", MessageBoxButtons.OK));
            _mockMapControl.Verify(m => m.StopNodeConnector());
        }
示例#8
0
        //TODO: create unit tests
        public void OnNodeConnect(object sender, EventArgs e)
        {
            var nodeControl = (NodeControl) sender;

            if (_CurrentConnector == null)
            {
                _CurrentConnector = new Connector(this);
                _CurrentConnector.Delete += OnConnectorDelete;
                _CurrentConnector.SetSourceNode(nodeControl);
            }
            else
            {
                _CurrentConnector.SetTargetNode(nodeControl);
                Controls.Add(_CurrentConnector);

                if (ConnectionAdded != null)
                {
                    var eventArgs = new NodeConnectionEventArgs
                        {
                            SourceNodeId = _CurrentConnector.SourceNodeId,
                            TargetNodeId = _CurrentConnector.TargetNodeId
                        };

                    ConnectionAdded(this, eventArgs);
                }

                StopNodeConnector();
            }
        }
示例#9
0
        public void OnConnectorDelete(object sender, EventArgs e)
        {
            var connection = (Connector) sender;

            if (ConnectionRemoved != null)
            {
                var eventArgs = new NodeConnectionEventArgs
                    {
                        SourceNodeId = connection.SourceNodeId,
                        TargetNodeId = connection.TargetNodeId
                    };
                ConnectionRemoved(this, eventArgs);
            }

            connection.Dispose();
            Controls.Remove(connection);
        }
示例#10
0
 public void OnConnectionRemoved(object sender, NodeConnectionEventArgs e)
 {
     _presenter.RemoveConnection(e.SourceNodeId, e.TargetNodeId);
 }
示例#11
0
        public void OnConnectionAdded(object sender, NodeConnectionEventArgs e)
        {
            if (!_presenter.AddConnection(e.SourceNodeId, e.TargetNodeId))
            {
                _formInteractionHelper.ShowMessage("Connection already exists between those nodes.",
                                                   "Existing Connection", MessageBoxButtons.OK);
            }

            StopConnector();
        }