//creates the holidays for a year public static void CreateHolidays(int startYear) { HolidayYear.Clear(); int endYear = startYear + 5; for (int i = startYear; i < endYear; i++) { foreach (Holiday holiday in Holidays.GetHolidays()) { if (holiday.Type == Holiday.HolidayType.Fixed_Date) { HolidayYear.AddHoliday(new HolidayYearEvent(new DateTime(startYear, holiday.Date.Month, holiday.Date.Day), holiday, 1)); } if (holiday.Type == Holiday.HolidayType.Fixed_Month) { HolidayYearEvent eHoliday = new HolidayYearEvent(new DateTime(startYear, holiday.Month, 1), holiday, DateTime.DaysInMonth(startYear, holiday.Month)); HolidayYear.AddHoliday(eHoliday); } if (holiday.Type == Holiday.HolidayType.Fixed_Week) { HolidayYear.AddHoliday(new HolidayYearEvent(MathHelpers.GetFirstDateOfWeek(startYear, holiday.Week), holiday, 7)); } if (holiday.Type == Holiday.HolidayType.Non_Fixed_Date) { HolidayYear.AddHoliday(new HolidayYearEvent(MathHelpers.GetNthWeekdayOfMonth(startYear, holiday.Month, holiday.Day, holiday.Week), holiday, 1)); } } } }
private void lnkTest_Click(object sender, RoutedEventArgs e) { //PageNavigator.NavigateTo(new PageTest()); //SerializedLoadSaveHelpers.SaveGame("Dugan"); SerializedLoadSaveHelpers.LoadGame("Dugan"); PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline)); HolidayYear.Clear(); GeneralHelpers.CreateHolidays(GameObject.GetInstance().GameTime.Year); Setup.SetupMergers(); }
private void btnLoadGame_Click(object sender, RoutedEventArgs e) { GameObjectWorker.GetInstance().cancel(); while (GameObjectWorker.GetInstance().isBusy()) { } string file = (string)lbSaves.SelectedItem; WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "1002"), Translator.GetInstance().GetString("MessageBox", "1002", "message"), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { if (file != null) { SplashControl scLoading = UIHelpers.FindChild <SplashControl>(this, "scLoading"); scLoading.Visibility = System.Windows.Visibility.Visible; BackgroundWorker bgWorker = new BackgroundWorker(); bgWorker.DoWork += (s, x) => { SerializedLoadSaveHelpers.LoadGame(file); }; bgWorker.RunWorkerCompleted += (s, x) => { scLoading.Visibility = System.Windows.Visibility.Collapsed; HolidayYear.Clear(); GeneralHelpers.CreateHolidays(GameObject.GetInstance().GameTime.Year); Setup.SetupMergers(); GameObjectWorker.GetInstance().pause(); PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline)); }; bgWorker.RunWorkerAsync(); } } }
private void lnkLoadGame_Click(object sender, RoutedEventArgs e) { Popup popUpSplash = new Popup(); popUpSplash.Child = createSplashWindow("Loading....."); popUpSplash.Placement = PlacementMode.Center; popUpSplash.PlacementTarget = PageNavigator.MainWindow; popUpSplash.IsOpen = false; GameObjectWorker.GetInstance().cancel(); while (GameObjectWorker.GetInstance().isBusy()) { } WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "1002"), Translator.GetInstance().GetString("MessageBox", "1002", "message"), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { String file = (String)PopUpLoad.ShowPopUp(); if (file != null) { popUpSplash.IsOpen = true; DoEvents(); LoadSaveHelpers.LoadGame(file); PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline)); HolidayYear.Clear(); GeneralHelpers.CreateHolidays(GameObject.GetInstance().GameTime.Year); Setup.SetupMergers(); popUpSplash.IsOpen = false; } } GameObjectWorker.GetInstance().start(); }
private void btnLoadGame_Click(object sender, RoutedEventArgs e) { String file = (String)PopUpLoad.ShowPopUp(); if (file != null) { Setup.SetupGame(); //LoadSaveHelpers.LoadGame(file); SerializedLoadSaveHelpers.LoadGame(file); HolidayYear.Clear(); GeneralHelpers.CreateHolidays(GameObject.GetInstance().GameTime.Year); GameObjectWorker.GetInstance().start(); PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline)); Action action = () => { PassengerHelpers.CreateDestinationDemand(); var airports = Airports.GetAllAirports(); int count = airports.Count; //var airports = Airports.GetAirports(a => a != airport && a.Profile.Town != airport.Profile.Town && MathHelpers.GetDistance(a.Profile.Coordinates, airport.Profile.Coordinates) > 50); Parallel.For(0, count - 1, i => { Parallel.For(i + 1, count, j => { airports[j].Statics.addDistance(airports[i], MathHelpers.GetDistance(airports[j], airports[i])); }); }); }; Task.Factory.StartNew(action); } }