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();
        }
示例#2
0
        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);
            }
        }