Exemple #1
0
 public void AddElement(Element e)
 {
     Debug.Assert(this.m_alElTypes.Contains(e.GetType()));
     this.m_ElToAdd = e;
     this.m_ElToAdd.m_Layout = this.m_Layout;
 }
        public override int CanConnect(Point p, Element e, int nSource, out Point pDest)
        {
            int connectionSourceID = -1;
            pDest = new Point(0.0, 0.0);
            if (e == this)
            {
                return -1;
            }
            connectionSourceID = this.GetConnectionSourceID(p);
            switch (connectionSourceID)
            {
                case 1:
                    pDest = this.PointPeak;
                    break;

                case 2:
                    pDest = this.PointPlus;
                    break;

                case 3:
                    pDest = this.PointMinus;
                    break;

                case -1:
                    return -1;
            }
            if (e is Light)
            {
                foreach (Connection connection in base.m_Connections)
                {
                    if (connection.IsConnectedTo(this, connectionSourceID, e.GetType()) != null)
                    {
                        return -1;
                    }
                }
                return connectionSourceID;
            }
            if ((e is Perron) || (e is TrainNumberField))
            {
                foreach (Connection connection in base.m_Connections)
                {
                    if (connection.HasElement(e.GetType()))
                    {
                        return -1;
                    }
                }
                return connectionSourceID;
            }
            if (!((e is Track) || (e is PointSwitchBase)))
            {
                return -1;
            }
            foreach (Connection connection in base.m_Connections)
            {
                if (connection.IsConnectedPath(this, connectionSourceID) != null)
                {
                    return -1;
                }
            }
            return connectionSourceID;
        }
Exemple #3
0
 public void AddElement(Element e)
 {
     Debug.Assert(this.m_alElTypes.Contains(e.GetType()));
     this.m_ElToAdd          = e;
     this.m_ElToAdd.m_Layout = this.m_Layout;
 }
        public override int CanConnect(Point p, Element e, int nSource, out Point pDest)
        {
            int connectionSourceID = -1;

            pDest = new Point(0.0, 0.0);
            if (e == this)
            {
                return(-1);
            }
            connectionSourceID = this.GetConnectionSourceID(p);
            switch (connectionSourceID)
            {
            case 1:
                pDest = this.PointPeak;
                break;

            case 2:
                pDest = this.PointPlus;
                break;

            case 3:
                pDest = this.PointMinus;
                break;

            case -1:
                return(-1);
            }
            if (e is Light)
            {
                foreach (Connection connection in base.m_Connections)
                {
                    if (connection.IsConnectedTo(this, connectionSourceID, e.GetType()) != null)
                    {
                        return(-1);
                    }
                }
                return(connectionSourceID);
            }
            if ((e is Perron) || (e is TrainNumberField))
            {
                foreach (Connection connection in base.m_Connections)
                {
                    if (connection.HasElement(e.GetType()))
                    {
                        return(-1);
                    }
                }
                return(connectionSourceID);
            }
            if (!((e is Track) || (e is PointSwitchBase)))
            {
                return(-1);
            }
            foreach (Connection connection in base.m_Connections)
            {
                if (connection.IsConnectedPath(this, connectionSourceID) != null)
                {
                    return(-1);
                }
            }
            return(connectionSourceID);
        }