async void LoadBuildingsAsync(string bodyID, AccountModel account) { var json = Body.GetBuildings(1, account.SessionID, bodyID); var s = new LacunaExpress.Data.Server(); var response = await s.GetHttpResultAsync(account.Server, Body.url, json); if (response.result != null) { damagedBuildingIDs = BuildingToolsScripts.GetDamagedBuildingIDs(response.result.buildings); damagedBuildings.Text = "Number of damaged buildings: " + damagedBuildingIDs.Count; avgbuildingLevel.Text = "Average Level: " + BuildingToolsScripts.GetAvgBuildingLevel(response.result.buildings); avgbuildingLevel.TextColor = Color.White; buildingCount.Text = "Number of Buildings: " + response.result.buildings.Count; buildingCount.TextColor = Color.White; } }
public BuildingToolsView(AccountModel account, string planetName) { var mainLayout = new StackLayout { BackgroundColor = Color.FromRgb(0, 0, 128), Children = { planetNameLabel, avgbuildingLevel, buildingCount, damagedBuildings, bleeders, repairBuildings, fillWithSpacePorts, queueUpgrades, destroyBleeders } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness(0, 20, 0, 0); } this.Appearing += (sender, e) => { planetID = (from b in account.Colonies where b.Value.Equals(planetName) select b.Key).First(); LoadBuildingsAsync(planetID, account); }; repairBuildings.Clicked += async(sender, e) => { var json = Body.RepairList(1, account.SessionID, planetID, damagedBuildingIDs); var s = new LacunaExpress.Data.Server(); var response = await s.GetHttpResultAsync(account.Server, Body.url, json); if (response.result != null) { damagedBuildingIDs = BuildingToolsScripts.GetDamagedBuildingIDs(response.result.buildings); damagedBuildings.Text = "Number of damaged buildings: " + damagedBuildingIDs.Count; damagedBuildings.TextColor = Color.White; } }; }