Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        public BuildingListView(BuildingViewModel data)
        {
            InitializeComponent();
            DataContext = data;

            IconView bView = new IconView(data);
            Building.Children.Add(bView);

            if (data.Units.Count <= 0)
            {
                UnitBox.Visibility = System.Windows.Visibility.Collapsed;
            }
            foreach(AoAUnitViewModel unit in data.Units){
                IconView view = new IconView(unit);
                UnitsList.AddATile(view);
                //UnitsList.Children.Add(view);
            }

            if (data.Researches.Count <= 0)
            {
                ResearchBox.Visibility = System.Windows.Visibility.Collapsed;
            }
            foreach (AoAResearchViewModel res in data.Researches)
            {
                IconView view = new IconView(res);
                ResearchesList.AddATile(view);
                //ResearchesList.Children.Add(view);
            }
        }
Ejemplo n.º 3
0
 public IconView(BuildingViewModel model)
 {
     InitializeComponent();
     DataContext = model;
     building = model;
     //this.MouseUp += BuildingOpen;
     Tile.Click += BuildingOpen;
 }
Ejemplo n.º 4
0
        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;
            }
        }