コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: KennyJLam/AoA
        public MainViewModel()
        {
            Init = new InitializationController();
            if (Init.LoadData())
            {
                foreach (AoABuilding b in Init.UsBuildings)
                {
                    BuildingViewModel buioding = new BuildingViewModel(b);
                    _usBuildings.Add(buioding);
                }
                Init.UsBuildings.Clear();

                //Cartel
                foreach (AoABuilding b in Init.CartelBuildings)
                {
                    BuildingViewModel buioding = new BuildingViewModel(b);
                    _cartelBuildings.Add(buioding);
                }
                Init.CartelBuildings.Clear();

                //Chimera
                foreach (AoABuilding b in Init.ChimeraBuildings)
                {
                    BuildingViewModel buioding = new BuildingViewModel(b);
                    _chimBuildings.Add(buioding);
                }
                Init.ChimeraBuildings.Clear();

                FillWithChimera = new FillContainer(_chimBuildings);
                FillWithCartel = new FillContainer(_cartelBuildings);
                FillWithUS = new FillContainer(_usBuildings);
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: KennyJLam/AoA
        public async Task<bool> LoadLastUpdateAndFill(ProgressDialogController controller)
        {
            DateTime start = DateTime.Now;
            InitializationController init = new InitializationController();
            
            await Task.Delay(2000);
            init.OnLoadingUpdate += delegate(object sender, string mess) { controller.SetMessage(mess); };
            if ( init.LoadData())
            {
                this.Dispatcher.Invoke(() =>
                {
                    this.Title += " | Game version = " + init.Version;
                });

                List<BuildingViewModel> usmodels = new List<BuildingViewModel>();
                List<BuildingViewModel> carmodels = new List<BuildingViewModel>();
                List<BuildingViewModel> chimmodels = new List<BuildingViewModel>();
                //Fill the forms
                //US
                foreach (AoABuilding b in init.UsBuildings)
                {
                    BuildingViewModel buioding = new BuildingViewModel(b);
                    usmodels.Add(buioding);
                }
                
                this.Dispatcher.Invoke(() =>
                {
                    FactionBuildingListView Usview = new FactionBuildingListView(new FactionViewModel(usmodels));
                    UsGrid.Children.Clear();
                    UsGrid.Children.Add(Usview);
                });
                init.UsBuildings.Clear();
            
                

                //Cartel
                foreach (AoABuilding b in init.CartelBuildings)
                {
                    BuildingViewModel buioding = new BuildingViewModel(b);
                    carmodels.Add(buioding);
                }
                
                this.Dispatcher.Invoke(() =>
                {
                    FactionBuildingListView cartelview = new FactionBuildingListView(new FactionViewModel(carmodels));
                    CartelGrid.Children.Clear();
                    CartelGrid.Children.Add(cartelview);
                });
                init.CartelBuildings.Clear();
                    
                

                //Chimera
                foreach (AoABuilding b in init.ChimeraBuildings)
                {
                    BuildingViewModel buioding = new BuildingViewModel(b);
                    chimmodels.Add(buioding);
                }
                
                this.Dispatcher.Invoke(() =>
                {
                    FactionBuildingListView chimview = new FactionBuildingListView(new FactionViewModel(chimmodels));
                    ChimeraGrid.Children.Clear();
                    ChimeraGrid.Children.Add(chimview);
                });

                init.ChimeraBuildings.Clear();
                controller.SetMessage("finished, time taken : " + (DateTime.Now - start).TotalSeconds);
                await Task.Delay(2000);
                
                return true;
            }
            else
            {
                init.Clear(); Console.Out.WriteLine(DateTime.Now.ToShortDateString() + " : loading last update failed."); 
                controller.SetMessage("loading failed...");
                await Task.Delay(2000); 
                return false;
            }
        }