public PageShowAlliances() { this.AllAlliances = Alliances.GetAlliances(); InitializeComponent(); this.Loaded += PageShowAlliances_Loaded; }
public PageAlliances() { this.HumanAlliances = GameObject.GetInstance().HumanAirline.Alliances; var alliances = Alliances.GetAlliances().OrderBy(a => a.Members.Sum(m => m.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year - 1, StatisticsTypes.GetStatisticsType("Passengers")))).ToList(); this.LargestAlliances = alliances.Take(Math.Min(5, alliances.Count)).ToList(); this.Loaded += PageAlliances_Loaded; InitializeComponent(); }
public override void updatePage() { panelSideMenu.Content = null; lbAlliances.Items.Refresh(); lbRequests.Items.Clear(); foreach (PendingAllianceMember member in from a in Alliances.GetAlliances() where a.PendingMembers.ToList().Find(p => p.Airline == GameObject.GetInstance().HumanAirline) != null select a.PendingMembers.ToList().Find(p => p.Airline == GameObject.GetInstance().HumanAirline)) { lbRequests.Items.Add(member); } }
public PageShowAlliances() { this.AllAlliances = Alliances.GetAlliances(); this.AllCodesharings = new ObservableCollection <CodeshareAgreementMVVM>(); var codesharings = Airlines.GetAllAirlines().SelectMany(a => a.Codeshares).Distinct(); foreach (CodeshareAgreement agreement in codesharings) { this.AllCodesharings.Add(new CodeshareAgreementMVVM(agreement)); } InitializeComponent(); this.Loaded += PageShowAlliances_Loaded; }
//saves a game public static void SaveGame(string name) { //Pause the game so we can save without the clock running :) GameObjectWorker.GetInstance().pause(); string fileName = AppSettings.getCommonApplicationDataPath() + "\\saves\\" + name + ".sav"; Stopwatch sw = new Stopwatch(); sw.Start(); SaveObject so = new SaveObject(); Parallel.Invoke(() => { so.airportsList = new List <Airport>(); so.airportsList.AddRange(Airports.GetAllAirports()); }, () => { so.airlinesList = new List <Airline>(); so.airlinesList.AddRange(Airlines.GetAllAirlines()); }, () => { so.airlinersList = new List <Airliner>(); so.airlinersList.AddRange(Airliners.GetAllAirliners()); }, () => { so.calendaritemsList = new List <CalendarItem>(); so.calendaritemsList.AddRange(CalendarItems.GetCalendarItems()); }, () => { so.configurationList = new List <Configuration>(); so.configurationList.AddRange(Configurations.GetConfigurations()); }, () => { so.eventsList = new List <RandomEvent>(); so.eventsList.AddRange(RandomEvents.GetEvents()); }, () => { so.allianceList = new List <Alliance>(); so.allianceList.AddRange(Alliances.GetAlliances()); }, () => { so.Airportfacilitieslist = new List <AirportFacility>(); so.Airportfacilitieslist.AddRange(AirportFacilities.GetFacilities()); }, () => { so.instance = GameObject.GetInstance(); }); DataContractSerializer serializer = new DataContractSerializer(typeof(SaveObject), null, Int32.MaxValue, false, true, null); using (Stream stream = new FileStream(fileName, FileMode.Create)) { using (DeflateStream compress = new DeflateStream(stream, CompressionMode.Compress)) { serializer.WriteObject(compress, so); } } sw.Stop(); }
//saves a game public static void SaveGame(string name) { Stopwatch sw = new Stopwatch(); sw.Start(); SaveObject so = new SaveObject(); Parallel.Invoke(() => { so.airportsList = new List <Airport>(); so.airportsfromstringList = new List <string>(); var airportsInUse = Airports.GetAllAirports().Where(a => Airlines.GetAllAirlines().Exists(al => al.Airports.Contains(a)) || a.hasAirlineFacility()); so.airportsList.AddRange(airportsInUse); foreach (Airport airport in Airports.GetAirports(a => !airportsInUse.Contains(a))) { so.airportsfromstringList.Add(airport.Profile.IATACode); } }, () => { so.airlinesList = new List <Airline>(); so.airlinesList.AddRange(Airlines.GetAllAirlines()); }, () => { so.airlinersList = new List <Airliner>(); so.airlinersList.AddRange(Airliners.GetAllAirliners().Where(a => a.Airline != null)); }, () => { so.calendaritemsList = new List <CalendarItem>(); so.calendaritemsList.AddRange(CalendarItems.GetCalendarItems()); }, () => { so.configurationList = new List <Configuration>(); so.configurationList.AddRange(Configurations.GetConfigurations()); }, () => { so.eventsList = new List <RandomEvent>(); so.eventsList.AddRange(RandomEvents.GetEvents()); }, () => { so.allianceList = new List <Alliance>(); so.allianceList.AddRange(Alliances.GetAlliances()); }, () => { so.Airportfacilitieslist = new List <AirportFacility>(); so.Airportfacilitieslist.AddRange(AirportFacilities.GetFacilities()); }, () => { so.feeTypeslist = new List <FeeType>(); so.feeTypeslist.AddRange(FeeTypes.GetTypes()); }, () => { so.advertisementTypeslist = new List <AdvertisementType>(); so.advertisementTypeslist.AddRange(AdvertisementTypes.GetTypes()); }, () => { so.airlinerfacilitieslist = new List <AirlinerFacility>(); so.airlinerfacilitieslist.AddRange(AirlinerFacilities.GetAllFacilities()); }, () => { so.routefacilitieslist = new List <RouteFacility>(); so.routefacilitieslist.AddRange(RouteFacilities.GetAllFacilities()); }, () => { so.instance = GameObject.GetInstance(); so.settings = Settings.GetInstance(); }, () => { so.airlinefacilitieslist = new List <AirlineFacility>(); so.airlinefacilitieslist.AddRange(AirlineFacilities.GetFacilities()); }); string fileName = AppSettings.getCommonApplicationDataPath() + "\\saves\\" + name + ".sav"; FileSerializer.Serialize(fileName, so); sw.Stop(); Console.WriteLine("Saving: {0} ms", sw.ElapsedMilliseconds); //Clearing stats because there is no need for saving those. if (name != "autosave") { Airports.GetAllAirports().ForEach(a => a.clearDestinationPassengerStatistics()); Airports.GetAllAirports().ForEach(a => a.clearDestinationCargoStatistics()); AirlineHelpers.ClearRoutesStatistics(); AirlineHelpers.ClearAirlinesStatistics(); AirportHelpers.ClearAirportStatistics(); } /* * SaveObject so = new SaveObject(); * Parallel.Invoke(() => * { * so.airportsList = new List<Airport>(); * so.airportsList.AddRange(Airports.GetAllAirports()); * }, () => * { * so.airlinesList = new List<Airline>(); * so.airlinesList.AddRange(Airlines.GetAllAirlines()); * }, () => * { * so.airlinersList = new List<Airliner>(); * so.airlinersList.AddRange(Airliners.GetAllAirliners()); * }, () => * { * so.calendaritemsList = new List<CalendarItem>(); * so.calendaritemsList.AddRange(CalendarItems.GetCalendarItems()); * }, () => * { * so.configurationList = new List<Configuration>(); * so.configurationList.AddRange(Configurations.GetConfigurations()); * }, () => * { * so.eventsList = new List<RandomEvent>(); * so.eventsList.AddRange(RandomEvents.GetEvents()); * }, () => * { * so.allianceList = new List<Alliance>(); * so.allianceList.AddRange(Alliances.GetAlliances()); * }, () => * { * so.Airportfacilitieslist = new List<AirportFacility>(); * so.Airportfacilitieslist.AddRange(AirportFacilities.GetFacilities()); * }, () => * { * so.feeTypeslist = new List<FeeType>(); * so.feeTypeslist.AddRange(FeeTypes.GetTypes()); * }, () => * { * so.advertisementTypeslist = new List<AdvertisementType>(); * so.advertisementTypeslist.AddRange(AdvertisementTypes.GetTypes()); * }, () => * { * so.airlinerfacilitieslist = new List<AirlinerFacility>(); * so.airlinerfacilitieslist.AddRange(AirlinerFacilities.GetAllFacilities()); * }, () => * { * so.routefacilitieslist = new List<RouteFacility>(); * so.routefacilitieslist.AddRange(RouteFacilities.GetAllFacilities()); * }, () => * { * so.instance = GameObject.GetInstance(); * so.settings = Settings.GetInstance(); * so.savetype = "039"; * so.saveversionnumber = 1; * }); */ /* * DataContractSerializer serializer = new DataContractSerializer(typeof(SaveObject), null, Int32.MaxValue, false, true, null); * * using (Stream stream = new FileStream(fileName, FileMode.Create)) * { * using (DeflateStream compress = new DeflateStream(stream, CompressionLevel.Fastest)) * { * serializer.WriteObject(compress, so); * } * } */ }
public PageAlliances() { InitializeComponent(); this.Uid = "1000"; //ask for alliance + _CreateDelegate alliance + statistics? StackPanel alliancesPanel = new StackPanel(); alliancesPanel.Margin = new Thickness(10, 0, 10, 0); ContentControl txtHeader = new ContentControl(); txtHeader.ContentTemplate = this.Resources["AlliancesHeader"] as DataTemplate; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; alliancesPanel.Children.Add(txtHeader); lbAlliances = new ListBox(); lbAlliances.ItemTemplate = this.Resources["AllianceItem"] as DataTemplate; lbAlliances.MaxHeight = GraphicsHelpers.GetContentHeight() / 2; lbAlliances.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbAlliances.ItemsSource = Alliances.GetAlliances(); alliancesPanel.Children.Add(lbAlliances); alliancesPanel.Children.Add(createButtonsPanel()); ContentControl txtRequests = new ContentControl(); txtRequests.ContentTemplate = this.Resources["RequestsHeader"] as DataTemplate; txtRequests.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtRequests.Margin = new Thickness(0, 5, 0, 0); alliancesPanel.Children.Add(txtRequests); lbRequests = new ListBox(); lbRequests.ItemTemplate = this.Resources["RequestItem"] as DataTemplate; lbRequests.MaxHeight = GraphicsHelpers.GetContentHeight() / 4; lbRequests.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); foreach (PendingAllianceMember member in from a in Alliances.GetAlliances() where a.PendingMembers.ToList().Find(p => p.Airline == GameObject.GetInstance().HumanAirline) != null select a.PendingMembers.ToList().Find(p => p.Airline == GameObject.GetInstance().HumanAirline)) { lbRequests.Items.Add(member); } alliancesPanel.Children.Add(lbRequests); StandardContentPanel panelContent = new StandardContentPanel(); panelContent.setContentPage(alliancesPanel, StandardContentPanel.ContentLocation.Left); panelSideMenu = new Frame(); panelContent.setContentPage(panelSideMenu, StandardContentPanel.ContentLocation.Right); base.setContent(panelContent); base.setHeaderContent("Airline Alliances"); showPage(this); }
private void txtAllianceName_TextChanged(object sender, TextChangedEventArgs e) { btnCreate.IsEnabled = txtAllianceName.Text.Trim().Length > 0 && !Alliances.GetAlliances().Exists(a => a.Name.ToUpper() == txtAllianceName.Text.Trim().ToUpper()); }