예제 #1
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);
                            }
                        }
                    }
                }
            }
        }
예제 #2
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);
                     }
                 }
             }
         }
     }
 }