Esempio n. 1
0
 public static Locomotive GetLocomotiveByName(string name)
 {
     try
     {
         return(Locomotives.Find((e) => { return e.Name == name; }));
     }
     catch (Exception ex)
     {
         Environment.ReportError(ex, AccessManager.AccessKey);
         return(null);
     }
 }
Esempio n. 2
0
        private void FillLocomotives(IRepository repository)
        {
            foreach (var locomotive in repository.Locomotives)
            {
                Locomotives.Add(new LocomotiveViewModel(locomotive));
            }

            // Связываем модель представления локомотивов с локомотивами из модели данных.
            _locomotivesLinker = new ObservableCollectionsConnector <ILocomotive, ILocomotiveViewModel>
                                     (repository.Locomotives, Locomotives, OnNewLocomotiveAdded,
                                     locomotive => Locomotives.FirstOrDefault(e => e.Locomotive == locomotive));
        }
Esempio n. 3
0
        public static void Init()
        {
            try
            {
                Reset();

                foreach (string str in System.IO.Directory.GetDirectories(Application.StartupPath + "\\data\\trains\\resources"))
                {
                    string[] l = System.IO.File.ReadAllLines(str + @"\data.xml", System.Text.Encoding.Default);
                    if (l[0] == @"<locomotive>")
                    {
                        Locomotive loc = new Locomotive();
                        loc.Load(str.Substring(str.LastIndexOf('\\') + 1, str.Length - str.LastIndexOf('\\') - 1));

                        Locomotives.Add(loc);
                        continue;
                    }
                    else if (l[0] == @"<coach>")
                    {
                        Coach car = new Coach();
                        car.Load(str.Substring(str.LastIndexOf('\\') + 1, str.Length - str.LastIndexOf('\\') - 1));

                        Coachs.Add(car);
                        continue;
                    }
                    else if (l[0] == @"<enginecoach>")
                    {
                        EngineCoach lc = new EngineCoach();
                        lc.Load(str.Substring(str.LastIndexOf('\\') + 1, str.Length - str.LastIndexOf('\\') - 1));

                        EngineCoachs.Add(lc);
                        continue;
                    }
                }

                foreach (string str in System.IO.Directory.GetDirectories(".\\data\\trains\\datas"))
                {
                    TrainData train = new TrainData();
                    train.Load(str.Substring(str.LastIndexOf('\\') + 1, str.Length - str.LastIndexOf('\\') - 1));

                    TrainDatas.Add(train);
                }
            }
            catch (Exception e)
            {
                Environment.ReportError(e, AccessManager.AccessKey);
            }
        }
Esempio n. 4
0
 public Station(string name, IEnumerable <Wagon> wagons, IEnumerable <Locomotive> locomotives) : this()
 {
     Name = name;
     Wagons.AddRange(wagons);
     Locomotives.AddRange(locomotives);
 }