public PagePilots() { this.AllPilots = Pilots.GetUnassignedPilots(); this.Loaded += PagePilots_Loaded; InitializeComponent(); }
//shows the list of pilots private void showPilots() { lbPilots.Items.Clear(); foreach (Pilot pilot in Pilots.GetUnassignedPilots().OrderByDescending(p => p.Profile.Age)) { lbPilots.Items.Add(pilot); } }
public PagePilots() { this.AllPilots = new ObservableCollection <Pilot>(); Pilots.GetUnassignedPilots().ForEach(p => this.AllPilots.Add(p)); this.Loaded += PagePilots_Loaded; InitializeComponent(); }
private void lnkAirline_Click(object sender, RoutedEventArgs e) { FleetAirliner airliner = (FleetAirliner)((Hyperlink)sender).Tag; panelSideMenu.Children.Clear(); if (airliner.NumberOfPilots == airliner.Airliner.Type.CockpitCrew) { PopUpAirlinerAutoRoutes.ShowPopUp(airliner); showFleet(); } else { int missingPilots = airliner.Airliner.Type.CockpitCrew - airliner.NumberOfPilots; if (GameObject.GetInstance().HumanAirline.Pilots.FindAll(p => p.Airliner == null).Count >= missingPilots) { WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2505"), string.Format(Translator.GetInstance().GetString("MessageBox", "2505", "message")), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { var unassignedPilots = GameObject.GetInstance().HumanAirline.Pilots.FindAll(p => p.Airliner == null).ToList(); for (int i = 0; i < missingPilots; i++) { unassignedPilots[i].Airliner = airliner; airliner.addPilot(unassignedPilots[i]); } // PopUpAirlinerRoutes.ShowPopUp(airliner, true); PopUpAirlinerAutoRoutes.ShowPopUp(airliner); showFleet(); } } else { Random rnd = new Random(); WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2506"), string.Format(Translator.GetInstance().GetString("MessageBox", "2506", "message"), missingPilots), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { while (airliner.Airliner.Type.CockpitCrew > airliner.NumberOfPilots) { var pilots = Pilots.GetUnassignedPilots(p => p.Profile.Town.Country == airliner.Airliner.Airline.Profile.Country); if (pilots.Count == 0) { pilots = Pilots.GetUnassignedPilots(p => p.Profile.Town.Country.Region == airliner.Airliner.Airline.Profile.Country.Region); } if (pilots.Count == 0) { pilots = Pilots.GetUnassignedPilots(); } Pilot pilot = pilots.First(); airliner.Airliner.Airline.addPilot(pilot); pilot.Airliner = airliner; airliner.addPilot(pilot); } //PopUpAirlinerRoutes.ShowPopUp(airliner, true); PopUpAirlinerAutoRoutes.ShowPopUp(airliner); showFleet(); } } } }
private void hlAirliner_Click(object sender, RoutedEventArgs e) { FleetAirlinerMVVM airliner = (FleetAirlinerMVVM)((Hyperlink)sender).Tag; TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); Frame frmContent = UIHelpers.FindChild <Frame>(this.Tag as Page, "frmContent"); if (airliner.Airliner.NumberOfPilots == airliner.Airliner.Airliner.Type.CockpitCrew) { if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Airliner") .FirstOrDefault(); //matchingItem.IsSelected = true; matchingItem.Header = airliner.Airliner.Name; matchingItem.Visibility = System.Windows.Visibility.Visible; tab_main.SelectedItem = matchingItem; } if (frmContent != null) { frmContent.Navigate(new PageRoutePlanner(airliner.Airliner) { Tag = this.Tag }); } } else { int missingPilots = airliner.Airliner.Airliner.Type.CockpitCrew - airliner.Airliner.NumberOfPilots; if (GameObject.GetInstance().HumanAirline.Pilots.FindAll(p => p.Airliner == null).Count >= missingPilots) { WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2505"), string.Format(Translator.GetInstance().GetString("MessageBox", "2505", "message")), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { var unassignedPilots = GameObject.GetInstance().HumanAirline.Pilots.FindAll(p => p.Airliner == null).ToList(); for (int i = 0; i < missingPilots; i++) { unassignedPilots[i].Airliner = airliner.Airliner; airliner.Airliner.addPilot(unassignedPilots[i]); } if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Airliner") .FirstOrDefault(); //matchingItem.IsSelected = true; matchingItem.Header = airliner.Airliner.Name; matchingItem.Visibility = System.Windows.Visibility.Visible; tab_main.SelectedItem = matchingItem; } if (frmContent != null) { frmContent.Navigate(new PageRoutePlanner(airliner.Airliner) { Tag = this.Tag }); } } } else { Random rnd = new Random(); WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2506"), string.Format(Translator.GetInstance().GetString("MessageBox", "2506", "message"), missingPilots), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { while (airliner.Airliner.Airliner.Type.CockpitCrew > airliner.Airliner.NumberOfPilots) { var pilots = Pilots.GetUnassignedPilots(p => p.Profile.Town.Country == airliner.Airliner.Airliner.Airline.Profile.Country && p.Aircrafts.Contains(airliner.Airliner.Airliner.Type.AirlinerFamily)); if (pilots.Count == 0) { pilots = Pilots.GetUnassignedPilots(p => p.Profile.Town.Country.Region == airliner.Airliner.Airliner.Airline.Profile.Country.Region && p.Aircrafts.Contains(airliner.Airliner.Airliner.Type.AirlinerFamily)); } if (pilots.Count == 0) { GeneralHelpers.CreatePilots(4, airliner.Airliner.Airliner.Type.AirlinerFamily); pilots = Pilots.GetUnassignedPilots(p => p.Aircrafts.Contains(airliner.Airliner.Airliner.Type.AirlinerFamily)); } if (pilots.Count < 5) { GeneralHelpers.CreatePilots(50); } Pilot pilot = pilots.First(); airliner.Airliner.Airliner.Airline.addPilot(pilot); pilot.Airliner = airliner.Airliner; airliner.Airliner.addPilot(pilot); } if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Airliner") .FirstOrDefault(); //matchingItem.IsSelected = true; matchingItem.Header = airliner.Airliner.Name; matchingItem.Visibility = System.Windows.Visibility.Visible; tab_main.SelectedItem = matchingItem; } if (frmContent != null) { frmContent.Navigate(new PageRoutePlanner(airliner.Airliner) { Tag = this.Tag }); } } } } }