public void AddConnection(ConnectableBase source, ConnectableBase destination, int value, string description)
        {
            Connection updateOldConnection = null;

            if (ArrowManagement.CountConnectionsInArrowManagement(source, destination) == 1)
            {
                updateOldConnection = PnmlNet.PetriNet.Objects
                                      .GetAllConnectionsBetween2Connectables(source, destination).First();
                ArrowManagement.Remove(source, destination);
            }

            Connection newConnection = new Connection(PnmlNet.PetriNet.CreateId(), source.Id, destination.Id, value, description);

            PnmlNet.PetriNet.InitDependency(newConnection);
            PnmlNet.PetriNet.Objects.Add(newConnection);
            PnmlNet.PetriNet.InitDependency(source);
            PnmlNet.PetriNet.InitDependency(destination);
            if (source is Transition trans)
            {
                trans.CalcIsExecutable();
            }
            if (destination is Transition transd)
            {
                transd.CalcIsExecutable();
            }
            newConnection.CalcIsExecutable();

            if (updateOldConnection != null)
            {
                updateOldConnection.UpdateArrows();
            }

            newConnection.UpdateArrows();
        }
        void IDropTarget.Drop(IDropInfo dropInfo)
        {
            double size       = ConnectableBase.SIZE;
            var    sourceItem = dropInfo.Data;

            if (sourceItem is ConnectableBase item)
            {
                item.Position.X = dropInfo.DropPosition.X - size / 2;
                item.Position.Y = dropInfo.DropPosition.Y - size / 2;


                foreach (var connection in item.Output)
                {
                    ArrowManagement.Remove(connection.Source, connection.Destination);
                }
                foreach (var connection in item.Input)
                {
                    ArrowManagement.Remove(connection.Source, connection.Destination);
                }

                foreach (var connection in item.Output)
                {
                    connection.UpdateArrows();
                }
                foreach (var connection in item.Input)
                {
                    connection.UpdateArrows();
                }
            }
        }
 /// <summary>
 /// if the position of a connectable base item changed, all the arrows from
 /// the input and the output have to be updated to the right position
 /// </summary>
 /// <param name="sender">s</param>
 /// <param name="e">e</param>
 internal void PositionChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     foreach (var connection in Output)
     {
         ArrowManagement.Remove(connection.Source, connection.Destination);
     }
     foreach (var connection in Input)
     {
         ArrowManagement.Remove(connection.Source, connection.Destination);
     }
     foreach (var connection in Output)
     {
         connection.UpdateArrows();
     }
     foreach (var connection in Input)
     {
         connection.UpdateArrows();
     }
 }
        public void DeleteComponent(UIPlaceable component)
        {
            PnmlNet.PetriNet.Objects.Remove(component);
            if (component is Connection conn)
            {
                var related = PnmlNet.PetriNet.Objects.GetConnectables().Where(o => o.Id == conn.SourceId || o.Id == conn.DestinationId);
                foreach (var rel in related)
                {
                    PnmlNet.PetriNet.InitDependency(rel);
                }

                ArrowManagement.Remove(conn.Source, conn.Destination);
                var otherConnectionsBetweenRemoved =
                    PnmlNet.PetriNet.Objects.GetAllConnectionsBetween2Connectables(conn.Source, conn.Destination);
                foreach (var c in otherConnectionsBetweenRemoved)
                {
                    c.UpdateArrows();
                }

                conn.Source.Output.Remove(conn);
                conn.Destination.Input.Remove(conn);
                if (conn.Destination is Transition trans)
                {
                    trans.CalcIsExecutable();
                }
            }
            if (component is ConnectableBase connectable)
            {
                //foreach(var outputConn in connectable.Output)
                while (connectable.Output.Count > 0)
                {
                    DeleteComponent(connectable.Output[0]);
                }
                //foreach (var inputConn in connectable.Input)
                while (connectable.Input.Count > 0)
                {
                    DeleteComponent(connectable.Input[0]);
                }
            }
        }