Пример #1
0
 protected virtual bool IsValidCourseMovement(PathElement pe)
 {
     if (this.m_TrainCourse.Count > 0)
     {
         int  num  = 0;
         bool flag = false;
         foreach (TrainCourse course in this.m_TrainCourse)
         {
             if (course.Element == pe)
             {
                 flag = true;
                 break;
             }
             if (num++ > 3)
             {
                 break;
             }
         }
         if (!flag)
         {
             return(false);
         }
     }
     return(true);
 }
Пример #2
0
 public void DrawTrainsRemoveOldAndAssignNew(List <TrainWebData> listTrains)
 {
     foreach (Element element in base.m_alElements)
     {
         if (element is PathElement)
         {
             PathElement element2 = element as PathElement;
             if (element2.Trains().Count > 0)
             {
                 element2.RemoveTrains();
             }
         }
     }
     foreach (TrainWebData data in listTrains)
     {
         Track track = base.GetElement(data.HeadElement) as Track;
         if (track != null)
         {
             Train t = TrainWebData2Train(data);
             t.HeadElement = track;
             t.NextElement = (data.NextElement.Length > 0) ? (base.GetElement(data.NextElement) as PathElement) : null;
             track.AddTrain(t, t.HeadElementArrivedSource);
         }
     }
 }
Пример #3
0
        public void DrawTrainsGetIntersected(out List <Train> intersectedTrains, out Dictionary <Train, List <Train> > train2IntersectedTrains)
        {
            intersectedTrains       = new List <Train>();
            train2IntersectedTrains = new Dictionary <Train, List <Train> >();
            Dictionary <Train, TrainPossiblePlaces> dictionary = new Dictionary <Train, TrainPossiblePlaces>();

            foreach (Element element in base.m_alElements)
            {
                if (element is PathElement)
                {
                    PathElement element2 = element as PathElement;
                    ArrayList   alTrains = element2.Trains();
                    if (alTrains.Count > 0)
                    {
                        foreach (Train train in alTrains)
                        {
                            Rectangle rectangle;
                            ArrayList list2 = new ArrayList {
                                train
                            };
                            Point trainPoint           = element2.GetTrainPoint(list2, train);
                            TrainPossiblePlaces places = new TrainPossiblePlaces();
                            this.DrawTrain(this.g, train, trainPoint, false, false, out rectangle);
                            places.Places.Add(rectangle);
                            trainPoint = element2.GetTrainPoint(alTrains, train);
                            this.DrawTrain(this.g, train, trainPoint, true, false, out rectangle);
                            places.Places.Add(rectangle);
                            dictionary.Add(train, places);
                        }
                    }
                }
            }
            foreach (Train train2 in dictionary.Keys)
            {
                TrainPossiblePlaces places2 = dictionary[train2];
                foreach (Train train3 in dictionary.Keys)
                {
                    if (train2.ID != train3.ID)
                    {
                        TrainPossiblePlaces placesB = dictionary[train3];
                        if (places2.IntersectsWith(placesB))
                        {
                            if (!train2IntersectedTrains.ContainsKey(train2))
                            {
                                train2IntersectedTrains[train2] = new List <Train>();
                            }
                            train2IntersectedTrains[train2].Add(train3);
                            if (!intersectedTrains.Contains(train2))
                            {
                                intersectedTrains.Add(train2);
                            }
                            if (!intersectedTrains.Contains(train3))
                            {
                                intersectedTrains.Add(train3);
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        protected bool FindPath(PathElement peTo, PathElement pePrev, PathElement pe, int nNextElementSource, ArrayList alTrainPath)
        {
            Debug.Assert(pe != null);
            TrainCourse item = new TrainCourse {
                Element       = pe,
                ElementSource = nNextElementSource
            };

            alTrainPath.Add(item);
            if (peTo == pe)
            {
                return(true);
            }
            pePrev = pe;
            PathInfo[] nextPathsThrough = pePrev.GetNextPathsThrough(nNextElementSource);
            if (nextPathsThrough != null)
            {
                foreach (PathInfo info in nextPathsThrough)
                {
                    if (info.ToElement != null)
                    {
                        int count = alTrainPath.Count;
                        if (this.FindPath(peTo, pePrev, info.ToElement, info.ToSource, alTrainPath))
                        {
                            return(true);
                        }
                        while (alTrainPath.Count > count)
                        {
                            alTrainPath.RemoveAt(alTrainPath.Count - 1);
                        }
                    }
                }
            }
            return(false);
        }
Пример #5
0
        public override ArrayList GetPathNeighbors()
        {
            ArrayList list = new ArrayList();

            foreach (Connection connection in base.m_Connections)
            {
                PathElement item = connection.IsConnectedPath(this, 2);
                if (item != null)
                {
                    list.Add(item);
                }
                item = connection.IsConnectedPath(this, 3);
                if (item != null)
                {
                    list.Add(item);
                }
                item = connection.IsConnectedPath(this, 1);
                if (item != null)
                {
                    list.Add(item);
                }
            }
            Debug.Assert((list.Count >= 0) && (list.Count <= 3));
            return(list);
        }
Пример #6
0
 public override bool CanSomeTrainToMoveToNextElement(PathElement pe)
 {
     foreach (TrainBase base2 in this.m_alTrainsPlusToMinus)
     {
         if ((base2.NextElement == pe) && base2.CanMoveToNextElement)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #7
0
 public override void InitAfterLoad(Layout l)
 {
     Debug.Assert(base.m_Connections.Count <= 1);
     if (base.m_Connections.Count == 1)
     {
         Element element;
         (base.m_Connections[0] as Connection).GetConnectedElement(this, out element, out this.TrackSource);
         Debug.Assert(this.TrackSource != -1);
         this.Track        = (PathElement)element;
         this.Track.Perron = this;
     }
     base.InitAfterLoad(l);
 }
Пример #8
0
 public void DrawOnlineTrains(List <TrainWebData> listTrains)
 {
     if (listTrains != null)
     {
         List <Train> list;
         Dictionary <Train, List <Train> > dictionary;
         this.DrawTrainsRemoveOldAndAssignNew(listTrains);
         this.DrawTrainsGetIntersected(out list, out dictionary);
         foreach (Element element in base.m_alElements)
         {
             if (element is PathElement)
             {
                 PathElement element2   = element as PathElement;
                 ArrayList   collection = element2.Trains();
                 if (collection.Count > 0)
                 {
                     foreach (Train train in collection)
                     {
                         Point     trainPoint;
                         Rectangle rectangle;
                         bool      small = list.Contains(train);
                         if (small)
                         {
                             ArrayList alTrains = new ArrayList();
                             alTrains.AddRange(collection);
                             if (dictionary.ContainsKey(train))
                             {
                                 foreach (Train train2 in dictionary[train])
                                 {
                                     if (!alTrains.Contains(train2))
                                     {
                                         alTrains.Add(train2);
                                     }
                                 }
                             }
                             alTrains.Sort(new Comparison <object>(this.SortTrainsForDrawing));
                             trainPoint = element2.GetTrainPoint(alTrains, train);
                         }
                         else
                         {
                             ArrayList list4 = new ArrayList();
                             list4.Add(train);
                             trainPoint = element2.GetTrainPoint(list4, train);
                         }
                         this.DrawTrain(this.g, train, trainPoint, small, true, out rectangle);
                     }
                 }
             }
         }
     }
 }
Пример #9
0
 public PathElement GetConnectedPath(int nMySource, out int nForeignSource)
 {
     nForeignSource = -1;
     foreach (Connection connection in base.m_Connections)
     {
         PathElement element = connection.IsConnectedPath(this, nMySource);
         if (element != null)
         {
             nForeignSource = (connection.Element1 == this) ? connection.Source2 : connection.Source1;
             return(element);
         }
     }
     return(null);
 }
Пример #10
0
        public PathElement IsConnectedPath(Element e, int nSource)
        {
            PathElement element = null;

            element = (PathElement)this.IsConnectedTo(e, nSource, typeof(Track));
            if (element != null)
            {
                return(element);
            }
            element = (PathElement)this.IsConnectedTo(e, nSource, typeof(PointSwitch));
            if (element != null)
            {
                return(element);
            }
            return((PathElement)this.IsConnectedTo(e, nSource, typeof(PointSimple)));
        }
Пример #11
0
 public bool FindPath(PathElement peTo, out ArrayList alTrainPath)
 {
     alTrainPath = new ArrayList();
     int[] sources = this.GetSources();
     foreach (int num2 in sources)
     {
         int num;
         PathElement connectedPath = this.GetConnectedPath(num2, out num);
         alTrainPath.Clear();
         if ((connectedPath != null) && this.FindPath(peTo, this, connectedPath, num, alTrainPath))
         {
             return true;
         }
     }
     return false;
 }
Пример #12
0
 private PathElement FindLastPathElement()
 {
     foreach (object obj2 in this.m_alElements)
     {
         if (obj2 is PathElement)
         {
             PathElement element       = obj2 as PathElement;
             ArrayList   pathNeighbors = element.GetPathNeighbors();
             if ((pathNeighbors != null) && (pathNeighbors.Count == 1))
             {
                 return(element);
             }
         }
     }
     return(null);
 }
Пример #13
0
 public bool FindPath(PathElement peTo, out ArrayList alTrainPath)
 {
     alTrainPath = new ArrayList();
     int[] sources = this.GetSources();
     foreach (int num2 in sources)
     {
         int         num;
         PathElement connectedPath = this.GetConnectedPath(num2, out num);
         alTrainPath.Clear();
         if ((connectedPath != null) && this.FindPath(peTo, this, connectedPath, num, alTrainPath))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #14
0
 public Perron()
 {
     this.m_strStation = "";
     this.m_nTrainHeadStopPositionLatitude = 0M;
     this.m_nTrainHeadStopPositionLongitude = 0M;
     this.m_nDistance = 0;
     this.m_nNumber = 1;
     this.m_nEscapement = 0;
     this.Enabled = true;
     this.TrackSource = -1;
     this.Track = null;
     this.m_Station = null;
     this.Displays = new ArrayList();
     this.Caption = "";
     this.CaptionColor = Colors.get_Black();
     this.Init();
 }
Пример #15
0
 public Perron(string strID) : base(strID)
 {
     this.m_strStation = "";
     this.m_nTrainHeadStopPositionLatitude  = 0M;
     this.m_nTrainHeadStopPositionLongitude = 0M;
     this.m_nDistance   = 0;
     this.m_nNumber     = 1;
     this.m_nEscapement = 0;
     this.Enabled       = true;
     this.TrackSource   = -1;
     this.Track         = null;
     this.m_Station     = null;
     this.Displays      = new ArrayList();
     this.Caption       = "";
     this.CaptionColor  = Colors.get_Black();
     this.Init();
 }
Пример #16
0
 public virtual void ResetTimeTable()
 {
     lock (this)
     {
         this.MoveState = TISMonitor.MoveState.Unknown;
         this.ResetDisplays();
         this.m_TrainCourse.Clear();
         this.m_strLineID     = "";
         this.m_nDirection    = 0;
         this.DateTimetable   = DateTime.MinValue;
         this.m_StationDest   = this.m_StationStart = (Station)(this.m_StationPrev = null);
         this.m_targetElement = null;
         this.Delay           = new TimeSpan(0L);
         this.ShowAtDisplay   = false;
         this.TrainType       = -1;
     }
     this.StopTimerMove();
 }
Пример #17
0
        public bool SetPathElementSegmentState(string strAddress, PathElementPassive.PathState ps)
        {
            bool flag = true;

            if (this.m_htAddress2StateElement.ContainsKey(strAddress))
            {
                ArrayList list = (ArrayList)this.m_htAddress2StateElement[strAddress];
                foreach (StateElement element in list)
                {
                    if (element is PathElement)
                    {
                        PathElement element2 = element as PathElement;
                        element2.Defined = true;
                        flag            &= element2.SetSegmentState(ps);
                    }
                }
                return(flag);
            }
            return(false);
        }
Пример #18
0
 public bool IsOccupiedWith(PathElement pe, bool bCheckMySourceOccupation)
 {
     foreach (Connection connection in base.m_Connections)
     {
         int     num;
         int     num2;
         Element element;
         if (connection.GetConnectedElement(this, out num2, out element, out num) && (pe == element))
         {
             if (!pe.IsSourceFree(num))
             {
                 if (bCheckMySourceOccupation)
                 {
                     return(!this.IsSourceFree(num2));
                 }
                 return(true);
             }
             break;
         }
     }
     return(false);
 }
Пример #19
0
 public override void InitAfterLoad(Layout l)
 {
     Debug.Assert(base.m_Connections.Count <= 1);
     if (base.m_Connections.Count == 1)
     {
         Element element;
         (base.m_Connections[0] as Connection).GetConnectedElement(this, out element, out this.TrackSource);
         Debug.Assert(this.TrackSource != -1);
         this.Track = (PathElement) element;
         this.Track.Perron = this;
     }
     base.InitAfterLoad(l);
 }
Пример #20
0
        private void DrawTrain(Canvas g, Train train, Point pt, bool small, bool allowToDraw, out Rectangle rectangle)
        {
            Color color;
            Color color2;

            rectangle = new Rectangle();
            TrainControl control = new TrainControl(train);

            control.OnTrainProperties += new TrainControl.TrainPropertiesHandler(this.TrainControl_OnTrainProperties);
            Train.GetTrainColors(train, out color, out color2);
            control.BodyColorHi = color2;
            control.BodyColorLo = color;
            Point       connectionSourcePoint = new Point(0.0, 0.0);
            Point       point2      = new Point(0.0, 0.0);
            PathElement headElement = train.HeadElement;

            if ((train.NextElement != null) && (train.NextElement != headElement))
            {
                connectionSourcePoint = train.NextElement.GetConnectionSourcePoint(train.m_nNextElementSource);
                point2 = train.HeadElement.GetConnectionSourcePoint(train.m_nHeadElementArrivedSource);
            }
            else if (train.m_nHeadElementArrivedSource != -1)
            {
                connectionSourcePoint = headElement.GetConnectionSourcePoint(headElement.GetOppositeSource(train.m_nHeadElementArrivedSource));
                point2 = headElement.GetConnectionSourcePoint(train.m_nHeadElementArrivedSource);
            }
            double rotationAngle = 0.0;

            if ((((connectionSourcePoint.get_X() != 0.0) || (connectionSourcePoint.get_Y() != 0.0)) && ((point2.get_X() != 0.0) || (point2.get_Y() != 0.0))) && (point2 != connectionSourcePoint))
            {
                rotationAngle = SilverlightHelper.GetRotationAngle(point2, connectionSourcePoint);
            }
            else if (train.HeadElement != null)
            {
                int[] sources = train.HeadElement.GetSources();
                if ((sources != null) && (sources.Length > 1))
                {
                    point2 = train.HeadElement.GetConnectionSourcePoint(sources[0]);
                    connectionSourcePoint = train.HeadElement.GetConnectionSourcePoint(sources[1]);
                    rotationAngle         = SilverlightHelper.GetRotationAngle(point2, connectionSourcePoint);
                }
            }
            control.ID          = train.ID;
            control.Tooltip     = train.GetToolTipText();
            control.IDToDisplay = train.IDToDisplay;
            control.Small       = small;
            control.Direction   = 1;
            rectangle           = new Rectangle();
            rectangle.X         = (int)pt.get_X();
            rectangle.Y         = (int)pt.get_Y();
            rectangle.Width     = (int)control.WIDTH_ACTUAL;
            rectangle.Height    = (int)control.HEIGHT_ACTUAL;
            if (allowToDraw)
            {
                control.SetValue(Canvas.LeftProperty, (double)rectangle.X);
                control.SetValue(Canvas.TopProperty, (double)rectangle.Y);
                control.SetValue(FrameworkElement.WidthProperty, (double)rectangle.Width);
                control.SetValue(FrameworkElement.HeightProperty, (double)rectangle.Height);
                double num2 = point2.get_X() - connectionSourcePoint.get_X();
                double num3 = point2.get_Y() - connectionSourcePoint.get_Y();
                int[]  textOrientationVectorHor = TextOrientationVectorHor;
                if (train.HeadElement is Track)
                {
                    Track track = train.HeadElement as Track;
                    if (track.PointMinus.get_Y() == track.PointPlus.get_Y())
                    {
                        textOrientationVectorHor = TextOrientationVectorVer;
                    }
                }
                double num4 = SilverlightHelper.GetAngleBetweenVercors((double)textOrientationVectorHor[0], (double)textOrientationVectorHor[1], num2, num3);
                control.Draw(num4 >= 90.0);
                RotateTransform transform = new RotateTransform();
                transform.set_Angle(-rotationAngle);
                control.set_RenderTransform(transform);
                g.get_Children().Add(control);
            }
            rectangle.Width += (int)(2.0 * control.NOSE_LEN);
            rectangle.Height = rectangle.Width = Math.Max(rectangle.Width, rectangle.Height);
        }
Пример #21
0
        public static bool GetOffsettedValue(PathElement peHead, double HeadOffset, int HeadElementArrivedSource, ref Point ptOut)
        {
            Point point = new Point();

            int[] sources = peHead.GetSources();
            Debug.Assert(sources.Length == 2);
            Point connectionSourcePoint = peHead.GetConnectionSourcePoint(sources[0]);
            Point point3 = peHead.GetConnectionSourcePoint(sources[1]);

            if (sources.Length != 2)
            {
                return(false);
            }
            double introduced12 = Math.Pow(connectionSourcePoint.get_X() - point3.get_X(), 2.0);
            double num          = Math.Sqrt(introduced12 + Math.Pow(connectionSourcePoint.get_Y() - point3.get_Y(), 2.0));
            double num2         = (num * HeadOffset) / ((peHead.Length == 0) ? ((double)1) : ((double)peHead.Length));
            double num3         = 1.0;
            double num4         = 0.0;

            if (!(connectionSourcePoint.get_Y() == point3.get_Y()))
            {
                num3 = Math.Abs((double)(point3.get_X() - connectionSourcePoint.get_X())) / num;
                num4 = Math.Abs((double)(point3.get_Y() - connectionSourcePoint.get_Y())) / num;
            }
            double num5 = num2 * num3;
            double num6 = num2 * num4;

            if (HeadElementArrivedSource == sources[0])
            {
                if (connectionSourcePoint.get_X() <= point3.get_X())
                {
                    connectionSourcePoint.set_X(connectionSourcePoint.get_X() + ((int)num5));
                }
                else
                {
                    connectionSourcePoint.set_X(connectionSourcePoint.get_X() - ((int)num5));
                }
                if (connectionSourcePoint.get_Y() <= point3.get_Y())
                {
                    connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() + ((int)num6));
                }
                else
                {
                    connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() - ((int)num6));
                }
                point = connectionSourcePoint;
            }
            else
            {
                if (point3.get_X() <= connectionSourcePoint.get_X())
                {
                    point3.set_X(point3.get_X() + ((int)num5));
                }
                else
                {
                    point3.set_X(point3.get_X() - ((int)num5));
                }
                if (point3.get_Y() <= connectionSourcePoint.get_Y())
                {
                    point3.set_Y(point3.get_Y() + ((int)num6));
                }
                else
                {
                    point3.set_Y(point3.get_Y() - ((int)num6));
                }
                point = point3;
            }
            ptOut = point;
            return(true);
        }
Пример #22
0
 protected bool FindPath(PathElement peTo, PathElement pePrev, PathElement pe, int nNextElementSource, ArrayList alTrainPath)
 {
     Debug.Assert(pe != null);
     TrainCourse item = new TrainCourse {
         Element = pe,
         ElementSource = nNextElementSource
     };
     alTrainPath.Add(item);
     if (peTo == pe)
     {
         return true;
     }
     pePrev = pe;
     PathInfo[] nextPathsThrough = pePrev.GetNextPathsThrough(nNextElementSource);
     if (nextPathsThrough != null)
     {
         foreach (PathInfo info in nextPathsThrough)
         {
             if (info.ToElement != null)
             {
                 int count = alTrainPath.Count;
                 if (this.FindPath(peTo, pePrev, info.ToElement, info.ToSource, alTrainPath))
                 {
                     return true;
                 }
                 while (alTrainPath.Count > count)
                 {
                     alTrainPath.RemoveAt(alTrainPath.Count - 1);
                 }
             }
         }
     }
     return false;
 }
Пример #23
0
 public abstract bool CanSomeTrainToMoveToNextElement(PathElement pe);
Пример #24
0
 public override bool CanSomeTrainToMoveToNextElement(PathElement pe)
 {
     foreach (TrainBase base2 in this.m_alTrainsPeakToSink)
     {
         if ((base2.NextElement == pe) && base2.CanMoveToNextElement)
         {
             return true;
         }
     }
     return false;
 }
Пример #25
0
 public bool IsOccupiedWith(PathElement pe, bool bCheckMySourceOccupation)
 {
     foreach (Connection connection in base.m_Connections)
     {
         int num;
         int num2;
         Element element;
         if (connection.GetConnectedElement(this, out num2, out element, out num) && (pe == element))
         {
             if (!pe.IsSourceFree(num))
             {
                 if (bCheckMySourceOccupation)
                 {
                     return !this.IsSourceFree(num2);
                 }
                 return true;
             }
             break;
         }
     }
     return false;
 }
Пример #26
0
 public static bool GetOffsettedValue(PathElement peHead, double HeadOffset, int HeadElementArrivedSource, ref Point ptOut)
 {
     Point point = new Point();
     int[] sources = peHead.GetSources();
     Debug.Assert(sources.Length == 2);
     Point connectionSourcePoint = peHead.GetConnectionSourcePoint(sources[0]);
     Point point3 = peHead.GetConnectionSourcePoint(sources[1]);
     if (sources.Length != 2)
     {
         return false;
     }
     double introduced12 = Math.Pow(connectionSourcePoint.get_X() - point3.get_X(), 2.0);
     double num = Math.Sqrt(introduced12 + Math.Pow(connectionSourcePoint.get_Y() - point3.get_Y(), 2.0));
     double num2 = (num * HeadOffset) / ((peHead.Length == 0) ? ((double) 1) : ((double) peHead.Length));
     double num3 = 1.0;
     double num4 = 0.0;
     if (!(connectionSourcePoint.get_Y() == point3.get_Y()))
     {
         num3 = Math.Abs((double) (point3.get_X() - connectionSourcePoint.get_X())) / num;
         num4 = Math.Abs((double) (point3.get_Y() - connectionSourcePoint.get_Y())) / num;
     }
     double num5 = num2 * num3;
     double num6 = num2 * num4;
     if (HeadElementArrivedSource == sources[0])
     {
         if (connectionSourcePoint.get_X() <= point3.get_X())
         {
             connectionSourcePoint.set_X(connectionSourcePoint.get_X() + ((int) num5));
         }
         else
         {
             connectionSourcePoint.set_X(connectionSourcePoint.get_X() - ((int) num5));
         }
         if (connectionSourcePoint.get_Y() <= point3.get_Y())
         {
             connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() + ((int) num6));
         }
         else
         {
             connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() - ((int) num6));
         }
         point = connectionSourcePoint;
     }
     else
     {
         if (point3.get_X() <= connectionSourcePoint.get_X())
         {
             point3.set_X(point3.get_X() + ((int) num5));
         }
         else
         {
             point3.set_X(point3.get_X() - ((int) num5));
         }
         if (point3.get_Y() <= connectionSourcePoint.get_Y())
         {
             point3.set_Y(point3.get_Y() + ((int) num6));
         }
         else
         {
             point3.set_Y(point3.get_Y() - ((int) num6));
         }
         point = point3;
     }
     ptOut = point;
     return true;
 }
Пример #27
0
 protected virtual bool IsValidCourseMovement(PathElement pe)
 {
     if (this.m_TrainCourse.Count > 0)
     {
         int num = 0;
         bool flag = false;
         foreach (TrainCourse course in this.m_TrainCourse)
         {
             if (course.Element == pe)
             {
                 flag = true;
                 break;
             }
             if (num++ > 3)
             {
                 break;
             }
         }
         if (!flag)
         {
             return false;
         }
     }
     return true;
 }
Пример #28
0
 public virtual void ResetTimeTable()
 {
     lock (this)
     {
         this.MoveState = TISMonitor.MoveState.Unknown;
         this.ResetDisplays();
         this.m_TrainCourse.Clear();
         this.m_strLineID = "";
         this.m_nDirection = 0;
         this.DateTimetable = DateTime.MinValue;
         this.m_StationDest = this.m_StationStart = (Station) (this.m_StationPrev = null);
         this.m_targetElement = null;
         this.Delay = new TimeSpan(0L);
         this.ShowAtDisplay = false;
         this.TrainType = -1;
     }
     this.StopTimerMove();
 }
Пример #29
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);
        }
Пример #30
0
 public abstract bool CanSomeTrainToMoveToNextElement(PathElement pe);