Esempio n. 1
0
        public object Clone()
        {
            TrainBase base2 = (TrainBase)base.MemberwiseClone();

            if (this.m_RoutePassed != null)
            {
                base2.m_RoutePassed = this.m_RoutePassed.Clone();
            }
            if (this.m_TrainCourse != null)
            {
                base2.m_TrainCourse = this.m_TrainCourse.Clone();
            }
            return(base2);
        }
Esempio n. 2
0
        public override bool CanTrainMoveThruSource(TrainBase t, int nSource)
        {
            int index = this.m_alTrainsPlusToMinus.IndexOf(t);

            if (index == -1)
            {
                Debug.Assert(false);
                return(false);
            }
            ConnectionSource source = (ConnectionSource)nSource;

            if (source == ConnectionSource.Plus)
            {
                return(index == 0);
            }
            return(index == (this.m_alTrainsPlusToMinus.Count - 1));
        }
Esempio n. 3
0
 public static void GetTrainColors(Train train, out Color clrLo, out Color clrHi)
 {
     if (train.Locomotive)
     {
         clrLo = Color.FromArgb(0xff, 0xc0, 0xc0, 0xc0);
         clrHi = Color.FromArgb(0xff, 0x80, 0x80, 0x80);
     }
     else if (!train.TimeTableAssigned())
     {
         AssignBlack(out clrLo, out clrHi);
     }
     else if (train.ID.IndexOf('?') >= 0)
     {
         AssignBlack(out clrLo, out clrHi);
     }
     else
     {
         TrainBase.GetDelayColor(TimeSpan.FromSeconds(train.Delay.TotalSeconds), out clrLo, out clrHi);
     }
 }
Esempio n. 4
0
 public override bool HasTrain(TrainBase t)
 {
     return this.m_alTrainsPeakToSink.Contains(t);
 }
Esempio n. 5
0
 public override void RemoveTrain(TrainBase t)
 {
     this.m_alTrainsPeakToSink.Remove(t);
 }
Esempio n. 6
0
 public override void RemoveTrain(TrainBase t)
 {
     this.m_alTrainsPeakToSink.Remove(t);
 }
Esempio n. 7
0
 public override bool CanTrainMoveThruSource(TrainBase t, int nSource)
 {
     int index = this.m_alTrainsPeakToSink.IndexOf(t);
     if (index == -1)
     {
         Debug.Assert(false);
         return false;
     }
     ConnectionSource source = (ConnectionSource) nSource;
     if (source == ConnectionSource.Peak)
     {
         return (index == 0);
     }
     return (index == (this.m_alTrainsPeakToSink.Count - 1));
 }
Esempio n. 8
0
 public abstract bool CanTrainMoveThruSource(TrainBase t, int nSource);
Esempio n. 9
0
 public override void RemoveTrain(TrainBase t)
 {
     this.m_alTrainsPlusToMinus.Remove(t);
 }
Esempio n. 10
0
 public virtual Point GetTrainPoint(ArrayList alTrains, TrainBase t)
 {
     int index = -1;
     if (alTrains.Count > 1)
     {
         index = alTrains.IndexOf(t);
     }
     Point trainPoint = this.GetTrainPoint();
     PathElement element = this;
     Point point2 = new Point();
     if (t.HeadElementArrivedSource != -1)
     {
         int[] sources = element.GetSources();
         Debug.Assert(sources.Length == 2);
         Point connectionSourcePoint = element.GetConnectionSourcePoint(sources[0]);
         Point point4 = element.GetConnectionSourcePoint(sources[1]);
         if (sources.Length != 2)
         {
             return trainPoint;
         }
         double introduced15 = Math.Pow(connectionSourcePoint.get_X() - point4.get_X(), 2.0);
         double num2 = Math.Sqrt(introduced15 + Math.Pow(connectionSourcePoint.get_Y() - point4.get_Y(), 2.0));
         double num3 = (num2 * t.HeadOffset) / ((element.Length == 0) ? ((double) 1) : ((double) element.Length));
         double num4 = 1.0;
         double num5 = 0.0;
         if (!(connectionSourcePoint.get_Y() == point4.get_Y()))
         {
             num4 = Math.Abs((double) (point4.get_X() - connectionSourcePoint.get_X())) / num2;
             num5 = Math.Abs((double) (point4.get_Y() - connectionSourcePoint.get_Y())) / num2;
         }
         double num6 = num3 * num4;
         double num7 = num3 * num5;
         if (t.HeadElementArrivedSource == sources[0])
         {
             if (connectionSourcePoint.get_X() <= point4.get_X())
             {
                 connectionSourcePoint.set_X(connectionSourcePoint.get_X() + num6);
             }
             else
             {
                 connectionSourcePoint.set_X(connectionSourcePoint.get_X() - num6);
             }
             if (connectionSourcePoint.get_Y() <= point4.get_Y())
             {
                 connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() + num7);
             }
             else
             {
                 connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() - num7);
             }
             point2 = connectionSourcePoint;
         }
         else
         {
             if (point4.get_X() <= connectionSourcePoint.get_X())
             {
                 point4.set_X(point4.get_X() + num6);
             }
             else
             {
                 point4.set_X(point4.get_X() - num6);
             }
             if (point4.get_Y() <= connectionSourcePoint.get_Y())
             {
                 point4.set_Y(point4.get_Y() + num7);
             }
             else
             {
                 point4.set_Y(point4.get_Y() - num7);
             }
             point2 = point4;
         }
         trainPoint = point2;
         if (index != -1)
         {
             if (connectionSourcePoint.get_Y() == point4.get_Y())
             {
                 trainPoint.set_Y(trainPoint.get_Y() - 6.0);
                 trainPoint.set_Y(trainPoint.get_Y() + (13 * index));
             }
             else
             {
                 trainPoint.set_X(trainPoint.get_X() - 6.0);
                 trainPoint.set_X(trainPoint.get_X() + (13 * index));
             }
         }
     }
     return trainPoint;
 }
Esempio n. 11
0
 public override void RemoveTrain(TrainBase t)
 {
     this.m_alTrainsPlusToMinus.Remove(t);
 }
Esempio n. 12
0
        public virtual Point GetTrainPoint(ArrayList alTrains, TrainBase t)
        {
            int index = -1;

            if (alTrains.Count > 1)
            {
                index = alTrains.IndexOf(t);
            }
            Point       trainPoint = this.GetTrainPoint();
            PathElement element    = this;
            Point       point2     = new Point();

            if (t.HeadElementArrivedSource != -1)
            {
                int[] sources = element.GetSources();
                Debug.Assert(sources.Length == 2);
                Point connectionSourcePoint = element.GetConnectionSourcePoint(sources[0]);
                Point point4 = element.GetConnectionSourcePoint(sources[1]);
                if (sources.Length != 2)
                {
                    return(trainPoint);
                }
                double introduced15 = Math.Pow(connectionSourcePoint.get_X() - point4.get_X(), 2.0);
                double num2         = Math.Sqrt(introduced15 + Math.Pow(connectionSourcePoint.get_Y() - point4.get_Y(), 2.0));
                double num3         = (num2 * t.HeadOffset) / ((element.Length == 0) ? ((double)1) : ((double)element.Length));
                double num4         = 1.0;
                double num5         = 0.0;
                if (!(connectionSourcePoint.get_Y() == point4.get_Y()))
                {
                    num4 = Math.Abs((double)(point4.get_X() - connectionSourcePoint.get_X())) / num2;
                    num5 = Math.Abs((double)(point4.get_Y() - connectionSourcePoint.get_Y())) / num2;
                }
                double num6 = num3 * num4;
                double num7 = num3 * num5;
                if (t.HeadElementArrivedSource == sources[0])
                {
                    if (connectionSourcePoint.get_X() <= point4.get_X())
                    {
                        connectionSourcePoint.set_X(connectionSourcePoint.get_X() + num6);
                    }
                    else
                    {
                        connectionSourcePoint.set_X(connectionSourcePoint.get_X() - num6);
                    }
                    if (connectionSourcePoint.get_Y() <= point4.get_Y())
                    {
                        connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() + num7);
                    }
                    else
                    {
                        connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() - num7);
                    }
                    point2 = connectionSourcePoint;
                }
                else
                {
                    if (point4.get_X() <= connectionSourcePoint.get_X())
                    {
                        point4.set_X(point4.get_X() + num6);
                    }
                    else
                    {
                        point4.set_X(point4.get_X() - num6);
                    }
                    if (point4.get_Y() <= connectionSourcePoint.get_Y())
                    {
                        point4.set_Y(point4.get_Y() + num7);
                    }
                    else
                    {
                        point4.set_Y(point4.get_Y() - num7);
                    }
                    point2 = point4;
                }
                trainPoint = point2;
                if (index != -1)
                {
                    if (connectionSourcePoint.get_Y() == point4.get_Y())
                    {
                        trainPoint.set_Y(trainPoint.get_Y() - 6.0);
                        trainPoint.set_Y(trainPoint.get_Y() + (13 * index));
                    }
                    else
                    {
                        trainPoint.set_X(trainPoint.get_X() - 6.0);
                        trainPoint.set_X(trainPoint.get_X() + (13 * index));
                    }
                }
            }
            return(trainPoint);
        }
Esempio n. 13
0
 public abstract bool HasTrain(TrainBase t);
Esempio n. 14
0
 public TrainPropEventArgs(TrainBase t)
 {
     this.Train = t;
 }
Esempio n. 15
0
 public TrainDragDropEventArgs(TrainBase s, TrainBase d)
 {
     this.Source = s;
     this.Destination = d;
 }
Esempio n. 16
0
        public override void AddTrain(TrainBase t, int nSource)
        {
            Debug.Assert(t != null);
            Debug.Assert(!this.m_alTrainsPlusToMinus.Contains(t));
            if (!this.m_alTrainsPlusToMinus.Contains(t))
            {
                switch (((ConnectionSource) nSource))
                {
                    case ConnectionSource.Plus:
                        this.m_alTrainsPlusToMinus.Insert(0, t);
                        break;

                    case ConnectionSource.Minus:
                        this.m_alTrainsPlusToMinus.Add(t);
                        break;

                    default:
                        this.m_alTrainsPlusToMinus.Add(t);
                        break;
                }
                foreach (TrainBase base2 in this.m_alTrainsPlusToMinus)
                {
                    if ((base2 != t) && !base.m_Layout.HasTrain(base2.ID))
                    {
                    }
                }
            }
        }
Esempio n. 17
0
 public TrainDragDropEventArgs(TrainBase s, TrainBase d)
 {
     this.Source      = s;
     this.Destination = d;
 }
Esempio n. 18
0
 public abstract void RemoveTrain(TrainBase t);
Esempio n. 19
0
 public abstract void AddTrain(TrainBase t, int nSource);
Esempio n. 20
0
 public override bool HasTrain(TrainBase t)
 {
     return this.m_alTrainsPlusToMinus.Contains(t);
 }
Esempio n. 21
0
 public abstract bool HasTrain(TrainBase t);
Esempio n. 22
0
 public abstract void RemoveTrain(TrainBase t);
Esempio n. 23
0
 public abstract void AddTrain(TrainBase t, int nSource);
Esempio n. 24
0
 public abstract bool CanTrainMoveThruSource(TrainBase t, int nSource);
Esempio n. 25
0
 public override bool HasTrain(TrainBase t)
 {
     return(this.m_alTrainsPlusToMinus.Contains(t));
 }
Esempio n. 26
0
 public TrainPropEventArgs(TrainBase t)
 {
     this.Train = t;
 }
Esempio n. 27
0
        public override void AddTrain(TrainBase t, int nSource)
        {
            Debug.Assert(t != null);
            Debug.Assert(!this.m_alTrainsPeakToSink.Contains(t));
            if (!this.m_alTrainsPeakToSink.Contains(t))
            {
                switch (((ConnectionSource) nSource))
                {
                    case ConnectionSource.Peak:
                        this.m_alTrainsPeakToSink.Insert(0, t);
                        break;

                    case ConnectionSource.Plus:
                    case ConnectionSource.Minus:
                        this.m_alTrainsPeakToSink.Add(t);
                        break;

                    default:
                        Debug.Assert(this.m_alTrainsPeakToSink.Count == 0);
                        this.m_alTrainsPeakToSink.Add(t);
                        break;
                }
                foreach (TrainBase base2 in this.m_alTrainsPeakToSink)
                {
                    if ((base2 != t) && !base.m_Layout.HasTrain(base2.ID))
                    {
                        base2.DebugTrace("PointSwitchBase.AddTrain: Train does not exist in layout!!!");
                    }
                }
            }
        }
Esempio n. 28
0
 public override bool HasTrain(TrainBase t)
 {
     return(this.m_alTrainsPeakToSink.Contains(t));
 }