private void btnCreateSubsidiary_Click(object sender, RoutedEventArgs e) { string iata = txtIATA.Text.ToUpper().Trim(); string name = txtAirlineName.Text.Trim(); Airport airport = (Airport)cbAirport.SelectedItem; string color = ((PropertyInfo)cbColor.SelectedItem).Name; Route.RouteType focus = rbPassengerType.IsChecked.Value ? Route.RouteType.Passenger : Route.RouteType.Cargo; string pattern = @"^[A-Za-z0-9]+$"; Regex regex = new Regex(pattern); if (name.Length > 0 && iata.Length == 2 && regex.IsMatch(iata) && !Airlines.GetAllAirlines().Exists(a=>a.Profile.IATACode == iata)) { WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2402"), Translator.GetInstance().GetString("MessageBox", "2402", "message"), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { AirlineProfile profile = new AirlineProfile(name, iata, color, GameObject.GetInstance().MainAirline.Profile.CEO, false, GameObject.GetInstance().GameTime.Year, 2199); profile.Logos.Clear(); profile.addLogo(new AirlineLogo(logoPath)); profile.Country = GameObject.GetInstance().MainAirline.Profile.Country; SubsidiaryAirline subAirline = new SubsidiaryAirline(GameObject.GetInstance().MainAirline, profile, Model.AirlineModel.Airline.AirlineMentality.Safe, Model.AirlineModel.Airline.AirlineFocus.Local, Model.AirlineModel.Airline.AirlineLicense.Domestic, focus); subAirline.addAirport(airport); subAirline.Money = slMoney.Value; this.Airline.addSubsidiaryAirline(subAirline); } } else WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2404"), Translator.GetInstance().GetString("MessageBox", "2404", "message"), WPFMessageBoxButtons.Ok); }
private void btnOk_Click(object sender, RoutedEventArgs e) { Airport airport = (Airport)cbAirport.SelectedItem; string color = ((PropertyInfo)cbColor.SelectedItem).Name; AirlineProfile profile = new AirlineProfile(txtAirlineName.Text.Trim(),txtIATA.Text.ToUpper().Trim(),color,GameObject.GetInstance().MainAirline.Profile.CEO,false,GameObject.GetInstance().GameTime.Year,2199); profile.addLogo(new AirlineLogo(logoPath)); profile.Country = GameObject.GetInstance().MainAirline.Profile.Country; SubsidiaryAirline subAirline = new SubsidiaryAirline(GameObject.GetInstance().MainAirline,profile,Airline.AirlineMentality.Safe,Airline.AirlineFocus.Local,Airline.AirlineLicense.Domestic,airlineType); subAirline.addAirport(airport); subAirline.Money = slMoney.Value; this.Selected = subAirline; this.Close(); }