private void btnDeleteGame_Click(object sender, RoutedEventArgs e) { string file = (string)lbSaves.SelectedItem; WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "1009"), Translator.GetInstance().GetString("MessageBox", "1009", "message"), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { SerializedLoadSaveHelpers.DeleteSavedGame(file); Saves.Remove(file); } }
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 btnSaveGame_Click(object sender, RoutedEventArgs e) { Boolean gameworkerPaused = GameObjectWorker.GetInstance().isPaused(); GameObjectWorker.GetInstance().cancel(); string name = txtName.Text.Trim(); Boolean doSave = true; if (SerializedLoadSaveHelpers.SaveGameExists(name)) { WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "1007"), Translator.GetInstance().GetString("MessageBox", "1007", "message"), WPFMessageBoxButtons.YesNo); doSave = result == WPFMessageBoxResult.Yes; if (doSave) { SerializedLoadSaveHelpers.DeleteSavedGame(name); } } if (doSave) { SplashControl scSaving = UIHelpers.FindChild <SplashControl>(this, "scSaving"); scSaving.Visibility = System.Windows.Visibility.Visible; BackgroundWorker bgWorker = new BackgroundWorker(); bgWorker.DoWork += (s, x) => { GameObject.GetInstance().Name = name; SerializedLoadSaveHelpers.SaveGame(name); }; bgWorker.RunWorkerCompleted += (s, x) => { if (!gameworkerPaused) { GameObjectWorker.GetInstance().start(); } scSaving.Visibility = System.Windows.Visibility.Collapsed; }; bgWorker.RunWorkerAsync(); } }
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 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); } }
private void lnkSaveGame_Click(object sender, RoutedEventArgs e) { Boolean gameworkerPaused = GameObjectWorker.GetInstance().isPaused(); GameObjectWorker.GetInstance().cancel(); Popup popUpSplash = new Popup(); popUpSplash.Child = createSplashWindow("Saving......"); popUpSplash.Placement = PlacementMode.Center; popUpSplash.PlacementTarget = PageNavigator.MainWindow; popUpSplash.IsOpen = false; String name = (String)PopUpSave.ShowPopUp(); Boolean doSave = name != null; if (doSave) { if (SerializedLoadSaveHelpers.SaveGameExists(name)) { WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "1007"), Translator.GetInstance().GetString("MessageBox", "1007", "message"), WPFMessageBoxButtons.YesNo); doSave = result == WPFMessageBoxResult.Yes; } if (doSave) { popUpSplash.IsOpen = true; DoEvents(); GameObject.GetInstance().Name = name; /* * string fileName; * * var saves = LoadSaveHelpers.GetSavedGames(); * * * KeyValuePair<string,string>? f = LoadSaveHelpers.GetSavedGames().Find(fs=>fs.Key == name); * * if (!f.HasValue || f.Value.Key == null) * { * Guid file = Guid.NewGuid(); * * fileName = file.ToString(); * * LoadSaveHelpers.AppendSavedFile(name, fileName); * * } * else * { * fileName = f.Value.Value; * } */ //LoadSaveHelpers.SaveGame(fileName); SerializedLoadSaveHelpers.SaveGame(name); popUpSplash.IsOpen = false; } } if (!gameworkerPaused) { GameObjectWorker.GetInstance().start(); } }