private void btnSignContract_Click(object sender, RoutedEventArgs e)
        {
            Boolean newContract = true;

            if (GameObject.GetInstance().HumanAirline.Contract != null)
            {
                double terminationFee      = GameObject.GetInstance().HumanAirline.Contract.getTerminationFee();
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2010"), string.Format(Translator.GetInstance().GetString("MessageBox", "2010", "message"), GameObject.GetInstance().HumanAirline.Contract.Manufacturer.Name, terminationFee), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -terminationFee);
                    GameObject.GetInstance().HumanAirline.Contract = null;
                }
                else
                {
                    newContract = false;
                }
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2013"), string.Format(Translator.GetInstance().GetString("MessageBox", "2013", "message"), this.Manufacturer.Name), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.No)
                {
                    newContract = false;
                }
            }

            if (newContract)
            {
                int length = Convert.ToInt16(((ComboBoxItem)cbContractLenth.SelectedItem).Tag);

                double discount = AirlineHelpers.GetAirlineManufactorerDiscountFactor(GameObject.GetInstance().HumanAirline, length, true);

                ManufacturerContract contract = new ManufacturerContract(this.Manufacturer, GameObject.GetInstance().GameTime, length, discount);
                GameObject.GetInstance().HumanAirline.Contract = contract;

                this.Contract.Contracted = contract.Manufacturer;
            }
        }
Beispiel #2
0
        private void btnCreateHub_Click(object sender, RoutedEventArgs e)
        {
            HubType type = HubTypes.GetHubType(HubType.TypeOfHub.Hub);//(HubType)cbHubType.SelectedItem;

            if (AirportHelpers.GetHubPrice(this.Airport.Airport, type) > GameObject.GetInstance().HumanAirline.Money)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2212"), Translator.GetInstance().GetString("MessageBox", "2212", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2213"), string.Format(Translator.GetInstance().GetString("MessageBox", "2213", "message"), AirportHelpers.GetHubPrice(this.Airport.Airport, type)), WPFMessageBoxButtons.YesNo);


                if (result == WPFMessageBoxResult.Yes)
                {
                    this.Airport.addHub(new Hub(GameObject.GetInstance().HumanAirline, type));

                    AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -AirportHelpers.GetHubPrice(this.Airport.Airport, type));
                }
            }
        }
        private void lnkNewGame_Click(object sender, RoutedEventArgs e)
        {
            GameObjectWorker.GetInstance().cancel();

            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "1001"), Translator.GetInstance().GetString("MessageBox", "1001", "message"), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                GameObjectWorker.GetInstance().cancel();

                while (GameObjectWorker.GetInstance().isBusy())
                {
                }
                PageNavigator.NavigateTo(new PageFrontMenu());
                GameObject.RestartInstance();

                Setup.SetupGame();
            }

            //GameObjectWorker.GetInstance().start();
        }
Beispiel #4
0
        private void btnIssueShares_Click(object sender, RoutedEventArgs e)
        {
            int shares = Convert.ToInt32(slShares.Value);

            double price = AirlineHelpers.GetPricePerAirlineShare(GameObject.GetInstance().HumanAirline);

            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2127"), string.Format(Translator.GetInstance().GetString("MessageBox", "2127", "message"), shares, new ValueCurrencyConverter().Convert(price)), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                AirlineHelpers.AddAirlineShares(GameObject.GetInstance().HumanAirline, shares, price);

                AirlinesMVVM humanAirline = this.AllAirlines.First(a => a.Airline == GameObject.GetInstance().HumanAirline);
                humanAirline.StocksForSale += shares;
                humanAirline.Stocks        += shares;

                this.NumberOfSharesToIssue -= shares;

                humanAirline.setOwnershipValues();
            }
        }
Beispiel #5
0
        private void btnBuyTerminal_Click(object sender, RoutedEventArgs e)
        {
            AirportTerminalMVVM terminal = (AirportTerminalMVVM)((Button)sender).Tag;

            long price = terminal.Gates * this.Airport.Airport.getTerminalGatePrice() + this.Airport.Airport.getTerminalPrice();

            if (price > GameObject.GetInstance().HumanAirline.Money)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2205"), Translator.GetInstance().GetString("MessageBox", "2205", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2211"), string.Format(Translator.GetInstance().GetString("MessageBox", "2211", "message"), price), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    terminal.purchaseTerminal(GameObject.GetInstance().HumanAirline);

                    AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -price);
                }
            }
        }
Beispiel #6
0
        private void btnHire_Click(object sender, RoutedEventArgs e)
        {
            Pilot pilot = (Pilot)((Button)sender).Tag;

            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2801"), Translator.GetInstance().GetString("MessageBox", "2801", "message"), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                GameObject.GetInstance().HumanAirline.addPilot(pilot);

                this.AllPilots.Remove(pilot);

                var fleetMissingPilots = GameObject.GetInstance().HumanAirline.Fleet.Where(f => f.Pilots.Count < f.Airliner.Type.CockpitCrew);

                if (fleetMissingPilots.Count() > 0)
                {
                    ComboBox cbAirliners = new ComboBox();
                    cbAirliners.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
                    cbAirliners.Width = 200;
                    cbAirliners.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    cbAirliners.DisplayMemberPath   = "Name";
                    cbAirliners.SelectedValuePath   = "Name";

                    foreach (FleetAirliner airliner in fleetMissingPilots)
                    {
                        cbAirliners.Items.Add(airliner);
                    }

                    cbAirliners.SelectedIndex = 0;

                    if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PagePilots", "1010"), cbAirliners) == PopUpSingleElement.ButtonSelected.OK && cbAirliners.SelectedItem != null)
                    {
                        FleetAirliner airliner = (FleetAirliner)cbAirliners.SelectedItem;

                        airliner.addPilot(pilot);
                    }
                }
            }
        }
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "1003"), Translator.GetInstance().GetString("MessageBox", "1003", "message"), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    this.Close();
                }
            }
            if (e.Key == Key.F8)
            {
                string text = string.Format("Gameobjectworker paused: {0}\n", GameObjectWorker.GetInstance().isPaused());
                text += string.Format("Gameobjectworker finished: {0}\n", GameObjectWorker.GetInstance().IsFinish);
                text += string.Format("Gameobjectworker errored: {0}\n", GameObjectWorker.GetInstance().IsError);

                Console.WriteLine(text);

                WPFMessageBox.Show("Threads states", text, WPFMessageBoxButtons.Ok);
            }
        }
Beispiel #8
0
        private void btnTransferFunds_Click(object sender, RoutedEventArgs e)
        {
            double funds = (double)slMoney.Value;

            Airline airlineFrom = (Airline)cbAirlineFrom.SelectedItem;
            Airline airlineTo   = (Airline)cbAirlineTo.SelectedItem;

            if (airlineFrom == airlineTo || funds > airlineFrom.Money)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2120"), string.Format(Translator.GetInstance().GetString("MessageBox", "2120", "message"), airlineFrom.Profile.Name, airlineTo.Profile.Name), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2121"), string.Format(Translator.GetInstance().GetString("MessageBox", "2121", "message"), funds, airlineFrom.Profile.Name, airlineTo.Profile.Name), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    airlineFrom.Money -= funds;
                    airlineTo.Money   += funds;
                }
            }
        }
        private void btnHire_Click(object sender, RoutedEventArgs e)
        {
            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2801"), Translator.GetInstance().GetString("MessageBox", "2801", "message"), WPFMessageBoxButtons.YesNo);


            if (result == WPFMessageBoxResult.Yes)
            {
                GameObject.GetInstance().HumanAirline.addPilot(this.Pilot);
            }

            TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu");

            if (tab_main != null)
            {
                var matchingItem =
                    tab_main.Items.Cast <TabItem>()
                    .Where(item => item.Tag.ToString() == "Pilots")
                    .FirstOrDefault();

                tab_main.SelectedItem = matchingItem;
            }
        }
Beispiel #10
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            SubsidiaryAirline airline = (SubsidiaryAirline)((Button)sender).Tag;

            if (airline == GameObject.GetInstance().HumanAirline)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2112"), string.Format(Translator.GetInstance().GetString("MessageBox", "2112", "message"), airline.Profile.Name), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2111"), string.Format(Translator.GetInstance().GetString("MessageBox", "2111", "message"), airline.Profile.Name), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    AirlineHelpers.CloseSubsidiaryAirline(airline);

                    showSubsidiaries();

                    this.PageParent.updatePage();
                }
            }
        }
        private void btnHire_Click(object sender, RoutedEventArgs e)
        {
            Boolean isServingCountry = true;// GameObject.GetInstance().HumanAirline.Airports.Exists(a => a.Profile.Country == this.Pilot.Profile.Town.Country);

            if (isServingCountry)
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2801"), Translator.GetInstance().GetString("MessageBox", "2801", "message"), WPFMessageBoxButtons.YesNo);


                if (result == WPFMessageBoxResult.Yes)
                {
                    GameObject.GetInstance().HumanAirline.addPilot(this.Pilot);
                    this.ParentPage.updatePage();

                    this.ParentPage.unloadSideMenu();
                }
            }
            else
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2808"), Translator.GetInstance().GetString("MessageBox", "2808", "message"), WPFMessageBoxButtons.Ok);
            }
        }
        private void btnCreateAndSave_Click(object sender, RoutedEventArgs e)
        {
            string name = txtName.Text.Trim();
            string iata = txtIATA.Text.Trim().ToUpper();

            string pattern = @"^[A-Za-z0-9]+$";
            Regex  regex   = new Regex(pattern);

            if (name.Length > 0 && iata.Length == 2 && regex.IsMatch(iata))
            {
                Airline airline = Airlines.GetAirline(iata);

                if (airline != null)
                {
                    WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2401"), string.Format(Translator.GetInstance().GetString("MessageBox", "2401", "message"), airline.Profile.Name), WPFMessageBoxButtons.YesNo);

                    if (result == WPFMessageBoxResult.Yes)
                    {
                        Airline nAirline = createAirline();
                        saveAirline(nAirline);
                    }
                }
                else
                {
                    WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2402"), Translator.GetInstance().GetString("MessageBox", "2402", "message"), WPFMessageBoxButtons.YesNo);

                    if (result == WPFMessageBoxResult.Yes)
                    {
                        Airline nAirline = createAirline();
                        saveAirline(nAirline);
                    }
                }
            }
            else
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2404"), Translator.GetInstance().GetString("MessageBox", "2404", "message"), WPFMessageBoxButtons.Ok);
            }
        }
Beispiel #13
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            AirlineFacility facility = (AirlineFacility)((Button)sender).Tag;

            if (facility.Price > GameObject.GetInstance().HumanAirline.Money)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2101"), Translator.GetInstance().GetString("MessageBox", "2101", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2102"), string.Format(Translator.GetInstance().GetString("MessageBox", "2102", "message"), facility.Name), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    this.Airline.addFacility(facility);

                    AirlineHelpers.AddAirlineInvoice(this.Airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -facility.Price);


                    showFacilities();
                }
            }
        }
        private void btnDeleteInstructor_Click(object sender, RoutedEventArgs e)
        {
            Instructor instructor = (Instructor)((Button)sender).Tag;

            if (instructor.Students.Count > 0)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2805"), string.Format(Translator.GetInstance().GetString("MessageBox", "2805", "message"), instructor.Profile.Name), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2806"), string.Format(Translator.GetInstance().GetString("MessageBox", "2806", "message"), instructor.Profile.Name), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    this.FlightSchool.removeInstructor(instructor);

                    instructor.FlightSchool = null;
                    showInstructors();

                    this.ParentPage.updatePage();
                }
            }
        }
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            Airline airline = Airlines.GetAirline(txtIATA.Text.Trim().ToUpper());

            if (airline != null)
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2401"), string.Format(Translator.GetInstance().GetString("MessageBox", "2401", "message"), airline.Profile.Name), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    createAirline();
                }
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2402"), Translator.GetInstance().GetString("MessageBox", "2402", "message"), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    createAirline();
                }
            }
        }
        private void btnPayLoan_Click(object sender, RoutedEventArgs e)
        {
            TextBox  txtPay = (TextBox)((Button)sender).Tag;
            LoanMVVM loan   = (LoanMVVM)txtPay.Tag;

            double amount = Convert.ToDouble(txtPay.Text);

            if (amount <= 0 || amount > this.Airline.Money)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2104"), Translator.GetInstance().GetString("MessageBox", "2104", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2105"), string.Format(Translator.GetInstance().GetString("MessageBox", "2105", "message"), amount), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    AirlineHelpers.AddAirlineInvoice(this.Airline.Airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Loans, Math.Max(-amount, -loan.PaymentLeft));

                    loan.payOnLoan(Math.Min(amount, loan.PaymentLeft));
                }
            }
        }
Beispiel #17
0
        private void btnBuyFacility_Click(object sender, RoutedEventArgs e)
        {
            AirportFacility.FacilityType type = (AirportFacility.FacilityType)cbNextFacility.SelectedItem;

            AirlineAirportFacility currentFacility = this.Airport.Airport.getAirlineAirportFacility(GameObject.GetInstance().HumanAirline, type);

            List <AirportFacility> facilities = AirportFacilities.GetFacilities(type);

            facilities = facilities.OrderBy(f => f.TypeLevel).ToList();

            int index = facilities.FindIndex(f => currentFacility.Facility == f);

            AirportFacility facility = facilities[index + 1];

            if (facility.Price > GameObject.GetInstance().HumanAirline.Money)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2201"), Translator.GetInstance().GetString("MessageBox", "2201", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2202"), string.Format(Translator.GetInstance().GetString("MessageBox", "2202", "message"), facility.Name, facility.Price), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    double price = facility.Price;

                    if (this.Airport.Airport.Profile.Country != GameObject.GetInstance().HumanAirline.Profile.Country)
                    {
                        price = price * 1.25;
                    }

                    AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -price);

                    this.Airport.addAirlineFacility(facility);
                }
            }
        }
        private void btnApply_Click(object sender, RoutedEventArgs e)
        {
            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2128"), string.Format(Translator.GetInstance().GetString("MessageBox", "2128", "message")), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                foreach (FleetAirliner airliner in this.Airliners)
                {
                    airliner.Airliner.clearAirlinerClasses();

                    foreach (AirlinerClassMVVM aClass in this.Classes)
                    {
                        AirlinerClass newClass = new AirlinerClass(aClass.Type, aClass.Seating);

                        airliner.Airliner.addAirlinerClass(newClass);

                        foreach (AirlinerFacilityMVVM facility in aClass.Facilities)
                        {
                            newClass.forceSetFacility(facility.SelectedFacility);
                        }
                    }

                    int totalSeats = this.Classes.Sum(c => c.RegularSeatingCapacity);

                    int seatingDiff = ((AirlinerPassengerType)airliner.Airliner.Type).MaxSeatingCapacity - totalSeats;

                    AirlinerClass economyClass = airliner.Airliner.Classes.Find(c => c.Type == AirlinerClass.ClassType.Economy_Class);
                    economyClass.RegularSeatingCapacity += seatingDiff;

                    AirlinerFacility seatingFacility = economyClass.getFacility(AirlinerFacility.FacilityType.Seat);

                    int extraSeats = (int)(seatingDiff / seatingFacility.SeatUses);

                    economyClass.SeatingCapacity += extraSeats;
                }
            }
        }
        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.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.Profile.Logos.Clear();
                    subAirline.Profile.addLogo(new AirlineLogo(logoPath));
                    subAirline.Money = slMoney.Value;

                    this.Airline.addSubsidiaryAirline(subAirline);
                }
            }
            else
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2404"), Translator.GetInstance().GetString("MessageBox", "2404", "message"), WPFMessageBoxButtons.Ok);
            }
        }
Beispiel #20
0
        private void btnSaveChanges_Click(object sender, RoutedEventArgs e)
        {
            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2952"), Translator.GetInstance().GetString("MessageBox", "2952", "message"), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                AppSettings.GetInstance().setLanguage((Language)cbLanguage.SelectedItem);

                Settings.GetInstance().AirportCodeDisplay   = rbIATA.IsChecked.Value ? Settings.AirportCode.IATA : Settings.AirportCode.ICAO;
                Settings.GetInstance().MailsOnLandings      = cbLandings.IsChecked.Value;
                Settings.GetInstance().MailsOnBadWeather    = cbWeather.IsChecked.Value;
                Settings.GetInstance().MailsOnAirlineRoutes = cbAirlineDestinations.IsChecked.Value;
                Settings.GetInstance().CurrencyShorten      = cbShortenCurrency.IsChecked.Value;

                if (this.Options.HourRoundEnabled)
                {
                    Settings.GetInstance().MinutesPerTurn = (int)cbHours.SelectedItem;
                }

                GeneralHelpers.GameSpeedValue gameSpeed = (GeneralHelpers.GameSpeedValue)Enum.ToObject(typeof(GeneralHelpers.GameSpeedValue), (int)slGameSpeed.Value);

                Settings.GetInstance().setGameSpeed(gameSpeed);
            }
        }
        private void btnRemoveContract_Click(object sender, RoutedEventArgs e)
        {
            ContractMVVM tContract = (ContractMVVM)((Button)sender).Tag;

            AirportContract contract = tContract.Contract;

            double penaltyFee = ((contract.YearlyPayment / 12) * contract.MonthsLeft) / 10;

            var contracts = this.Airport.Airport.AirlineContracts.Where(a => a.Airline == GameObject.GetInstance().HumanAirline&& a != contract).ToList();

            if (!AirportHelpers.CanFillRoutesEntries(this.Airport.Airport, GameObject.GetInstance().HumanAirline, contracts, Weather.Season.All_Year) || contracts.Count == 0)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2224"), Translator.GetInstance().GetString("MessageBox", "2224", "message"), WPFMessageBoxButtons.Ok);
            }
            else if (contract.Terminal != null)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2226"), string.Format(Translator.GetInstance().GetString("MessageBox", "2226", "message"), contract.Terminal.Name), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2225"), string.Format(Translator.GetInstance().GetString("MessageBox", "2225", "message"), new ValueCurrencyConverter().Convert(penaltyFee)), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -penaltyFee);

                    this.Airport.removeAirlineContract(tContract);

                    for (int i = 0; i < contract.NumberOfGates; i++)
                    {
                        Gate gate = this.Airport.Airport.Terminals.getGates().Where(g => g.Airline == GameObject.GetInstance().HumanAirline).First();
                        gate.Airline = null;
                    }
                }
            }
        }
        private void btnRemoveContract_Click(object sender, RoutedEventArgs e)
        {
            AirportContract contract = (AirportContract)((Button)sender).Tag;

            //int totalGatesAfter = this.Airport.AirlineContracts.Where(a=>a.Airline == GameObject.GetInstance().HumanAirline).Sum(c => c.NumberOfGates) - contract.NumberOfGates;

            //int routes = AirportHelpers.GetAirportRoutes(this.Airport,GameObject.GetInstance().HumanAirline).Count;

            double penaltyFee = ((contract.YearlyPayment / 12) * contract.MonthsLeft) / 10;

            var contracts = this.Airport.AirlineContracts.Where(a => a.Airline == GameObject.GetInstance().HumanAirline&& a != contract).ToList();

            if (!AirportHelpers.CanFillRoutesEntries(this.Airport, GameObject.GetInstance().HumanAirline, contracts))
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2224"), Translator.GetInstance().GetString("MessageBox", "2224", "message"), WPFMessageBoxButtons.Ok);
            }
            else if (contract.Terminal != null)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2226"), string.Format(Translator.GetInstance().GetString("MessageBox", "2226", "message"), contract.Terminal.Name), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2225"), string.Format(Translator.GetInstance().GetString("MessageBox", "2225", "message"), new ValueCurrencyConverter().Convert(penaltyFee)), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -penaltyFee);

                    this.Airport.removeAirlineContract(contract);

                    showGatesInformation();
                    showContracts();
                    showTerminals();
                }
            }
        }
        // chs, 2011-27-10 added for the possibility of purchasing a terminal
        private void btnRemoveTerminal_Click(object sender, RoutedEventArgs e)
        {
            Terminal terminal = (Terminal)((Button)sender).Tag;

            int totalRentedGates = this.Airport.AirlineContracts.Sum(c => c.NumberOfGates);

            Boolean isTerminalFree = this.Airport.Terminals.getNumberOfGates() - terminal.Gates.NumberOfGates >= totalRentedGates;

            if (isTerminalFree)
            {
                // chs, 2011-31-10 changed for the possibility of having delivered and non-delivered terminals

                string strRemove;
                if (terminal.DeliveryDate > GameObject.GetInstance().GameTime)
                {
                    strRemove = Translator.GetInstance().GetString("MessageBox", "2207", "message");
                }
                else
                {
                    strRemove = string.Format(Translator.GetInstance().GetString("MessageBox", "2208", "message"), terminal.Gates.NumberOfGates);
                }
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2207"), strRemove, WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    this.Airport.removeTerminal(terminal);

                    showTerminals();
                    showGatesInformation();
                }
            }
            else
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2209"), Translator.GetInstance().GetString("MessageBox", "2209", "message"), WPFMessageBoxButtons.Ok);
            }
        }
Beispiel #24
0
        private void btnSellAircraft_Click(object sender, RoutedEventArgs e)
        {
            TrainingAircraft aircraft = (TrainingAircraft)((Button)sender).Tag;

            var aircrafts = new List <TrainingAircraft>(this.FlightSchool.Aircrafts);

            aircrafts.Remove(aircraft);

            Boolean canSellAircraft = aircrafts.Sum(a => a.Type.MaxNumberOfStudents) >= this.FlightSchool.Students.Count;

            if (canSellAircraft)
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2809"), Translator.GetInstance().GetString("MessageBox", "2809", "message"), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    this.FlightSchool.removeTrainingAircraft(aircraft);
                }
            }
            else
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2810"), Translator.GetInstance().GetString("MessageBox", "2810", "message"), WPFMessageBoxButtons.Ok);
            }
        }
        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2602"), string.Format(Translator.GetInstance().GetString("MessageBox", "2602", "message"), this.Alliance.Alliance.Name), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                this.Alliance.removeMember(GameObject.GetInstance().HumanAirline);
            }

            if (this.Alliance.Members.Count == 0 && this.Alliance.PendingMembers.Count == 0)
            {
                Alliances.RemoveAlliance(this.Alliance.Alliance);
            }

            Frame frmContent = UIHelpers.FindChild <Frame>(this.Tag as Page, "frmContent");

            if (frmContent != null)
            {
                frmContent.Navigate(new PageShowAlliances()
                {
                    Tag = this.Tag
                });
            }
        }
        private void ButtonDelete_Click(object sender, RoutedEventArgs e)
        {
            FleetAirliner airliner = (FleetAirliner)((Button)sender).Tag;

            if (airliner.Status != FleetAirliner.AirlinerStatus.Stopped)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2122"), string.Format(Translator.GetInstance().GetString("MessageBox", "2122", "message")), WPFMessageBoxButtons.Ok);
            }
            else
            {
                if (airliner.Purchased == FleetAirliner.PurchasedType.Bought)
                {
                    WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2106"), string.Format(Translator.GetInstance().GetString("MessageBox", "2106", "message"), airliner.Name), WPFMessageBoxButtons.YesNo);

                    if (result == WPFMessageBoxResult.Yes)
                    {
                        if (airliner.HasRoute)
                        {
                            var routes = new List <Route>(airliner.Routes);

                            foreach (Route route in routes)
                            {
                                airliner.removeRoute(route);
                            }
                        }

                        this.Airline.removeAirliner(airliner);

                        AirlineHelpers.AddAirlineInvoice(this.Airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, airliner.Airliner.getPrice());


                        _FleetDelivered.Remove(airliner);

                        foreach (Pilot pilot in airliner.Pilots)
                        {
                            pilot.Airliner = null;
                        }

                        airliner.Pilots.Clear();

                        showFleet();
                    }
                }
                else
                {
                    WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2107"), string.Format(Translator.GetInstance().GetString("MessageBox", "2107", "message"), airliner.Name), WPFMessageBoxButtons.YesNo);

                    if (result == WPFMessageBoxResult.Yes)
                    {
                        if (airliner.HasRoute)
                        {
                            var routes = new List <Route>(airliner.Routes);

                            foreach (Route route in routes)
                            {
                                airliner.removeRoute(route);
                            }
                        }


                        this.Airline.removeAirliner(airliner);

                        _FleetDelivered.Remove(airliner);


                        foreach (Pilot pilot in airliner.Pilots)
                        {
                            pilot.Airliner = null;
                        }

                        airliner.Pilots.Clear();

                        showFleet();
                    }
                }
            }
        }
Beispiel #27
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            Route route = (Route)cbRoute.SelectedItem;

            RouteTimeTable rt;

            int      flightsPerDay  = (int)cbFlightsPerDay.SelectedItem;
            int      flightsPerWeek = (int)cbFlightsPerWeek.SelectedItem;
            int      delayMinutes   = (int)cbDelayMinutes.SelectedItem;
            TimeSpan startTime      = (TimeSpan)cbStartTime.SelectedItem;

            string flightcode1 = cbFlightCode.SelectedItem.ToString();
            string flightcode2 = this.Airliner.Airliner.Airline.getFlightCodes()[this.Airliner.Airliner.Airline.getFlightCodes().IndexOf(flightcode1) + 1];

            if (flightsPerDay > 0)
            {
                if (this.RouteOperations == RouteOperationsType.Business)
                {
                    flightsPerDay = (int)(route.getFlightTime(this.Airliner.Airliner.Type).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(this.Airliner)).TotalMinutes / 2 / maxBusinessRouteTime);
                    rt            = AIHelpers.CreateBusinessRouteTimeTable(route, this.Airliner, Math.Max(1, flightsPerDay), flightcode1, flightcode2);
                }
                else
                {
                    if (this.Interval == FlightInterval.Daily)
                    {
                        rt = AIHelpers.CreateAirlinerRouteTimeTable(route, this.Airliner, flightsPerDay, true, delayMinutes, startTime, flightcode1, flightcode2);
                    }
                    else
                    {
                        rt = AIHelpers.CreateAirlinerRouteTimeTable(route, this.Airliner, flightsPerWeek, false, delayMinutes, startTime, flightcode1, flightcode2);
                    }
                }
            }
            else
            {
                rt = null;
            }

            if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, this.ParentPage.Entries, false))
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2705"), Translator.GetInstance().GetString("MessageBox", "2705", "message"), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    this.ParentPage.NewestEntries.Clear();
                    this.ParentPage.clearTimeTable();

                    if (!this.ParentPage.Entries.ContainsKey(route))
                    {
                        this.ParentPage.Entries.Add(route, new List <RouteTimeTableEntry>());
                    }


                    foreach (RouteTimeTableEntry entry in rt.Entries)
                    {
                        if (!TimeTableHelpers.IsRouteEntryInOccupied(entry, this.Airliner))
                        {
                            this.ParentPage.Entries[route].Add(entry);
                            this.ParentPage.NewestEntries.Add(entry);
                        }
                    }
                }
            }
            else
            {
                if (!this.ParentPage.Entries.ContainsKey(route))
                {
                    this.ParentPage.Entries.Add(route, new List <RouteTimeTableEntry>());
                }

                foreach (RouteTimeTableEntry entry in rt.Entries)
                {
                    if (!TimeTableHelpers.IsRouteEntryInOccupied(entry, this.Airliner))
                    {
                        this.ParentPage.Entries[route].Add(entry);
                        this.ParentPage.NewestEntries.Add(entry);
                    }
                }
            }


            this.ParentPage.showFlights();
        }
        private void btnAddGenerator_Click(object sender, RoutedEventArgs e)
        {
            Route route = (Route)cbRoute.SelectedItem;

            RouteTimeTable rt = null;

            IntervalType intervalType = (IntervalType)cbIntervalType.SelectedItem;
            int          interval     = Convert.ToInt16(cbInterval.SelectedItem);
            OpsType      opsType      = (OpsType)cbSchedule.SelectedItem;
            int          delayMinutes = (int)cbDelayMinutes.SelectedItem;

            double   maxBusinessRouteTime = new TimeSpan(2, 0, 0).TotalMinutes;
            TimeSpan startTime            = (TimeSpan)cbStartTime.SelectedItem;

            string flightcode1 = this.Airliner.Airliner.Airline.Profile.IATACode + txtFlightNumber.Text;

            int indexOf = this.Airliner.Airliner.Airline.getFlightCodes().IndexOf(flightcode1);

            string flightcode2;

            if (indexOf == this.Airliner.Airliner.Airline.getFlightCodes().Count)
            {
                flightcode2 = "";
            }
            else
            {
                flightcode2 = this.Airliner.Airliner.Airline.getFlightCodes()[indexOf + 1];
            }


            if (opsType == OpsType.Business)
            {
                int flightsPerDay = (int)(route.getFlightTime(this.Airliner.Airliner.Type).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(this.Airliner)).TotalMinutes / 2 / maxBusinessRouteTime);
                rt = AIHelpers.CreateBusinessRouteTimeTable(route, this.Airliner, Math.Max(1, flightsPerDay), flightcode1, flightcode2);
            }
            if (intervalType == IntervalType.Day && opsType != OpsType.Business)
            {
                rt = AIHelpers.CreateAirlinerRouteTimeTable(route, this.Airliner, interval, true, delayMinutes, startTime, flightcode1, flightcode2);
            }
            if (intervalType == IntervalType.Week && opsType != OpsType.Business)
            {
                rt = AIHelpers.CreateAirlinerRouteTimeTable(route, this.Airliner, interval, false, delayMinutes, startTime, flightcode1, flightcode2);
            }
            if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, this.Entries.ToList(), false))
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2705"), Translator.GetInstance().GetString("MessageBox", "2705", "message"), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    clearTimeTable();

                    foreach (RouteTimeTableEntry entry in rt.Entries)
                    {
                        if (!TimeTableHelpers.IsRouteEntryInOccupied(entry, this.Airliner))
                        {
                            this.Entries.Add(entry);
                        }
                    }
                }
            }
            else
            {
                foreach (RouteTimeTableEntry entry in rt.Entries)
                {
                    if (!TimeTableHelpers.IsRouteEntryInOccupied(entry, this.Airliner))
                    {
                        this.Entries.Add(entry);
                    }
                }
            }

            setFlightNumbers();
        }
        private void btnOrder_Click(object sender, RoutedEventArgs e)
        {
            Boolean hasHomebases = true;

            foreach (AirlinerOrderMVVM order in this.Orders.Orders)
            {
                if (order.Homebase == null)
                {
                    hasHomebases = false;
                }
            }
            Boolean contractedOrder = false;
            Boolean tryOrder        = true;

            DateTime deliveryDate = this.Orders.getDeliveryDate();

            if (!hasHomebases)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2002"), Translator.GetInstance().GetString("MessageBox", "2002", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                if (GameObject.GetInstance().HumanAirline.Contract != null)
                {
                    if (GameObject.GetInstance().HumanAirline.Contract.Manufacturer == this.Manufacturer)
                    {
                        contractedOrder = true;
                    }
                    else
                    {
                        double terminationFee      = GameObject.GetInstance().HumanAirline.Contract.getTerminationFee();
                        WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2010"), string.Format(Translator.GetInstance().GetString("MessageBox", "2010", "message"), GameObject.GetInstance().HumanAirline.Contract.Manufacturer.Name, terminationFee), WPFMessageBoxButtons.YesNo);

                        if (result == WPFMessageBoxResult.Yes)
                        {
                            AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -terminationFee);
                            GameObject.GetInstance().HumanAirline.Contract = null;

                            this.Contract.Contracted = null;
                        }
                        tryOrder = result == WPFMessageBoxResult.Yes;
                    }
                }

                if (tryOrder)
                {
                    int    totalAmount = this.Orders.Orders.Sum(o => o.Amount);
                    double price       = this.Orders.Orders.Sum(o => o.Type.Price * o.Amount);

                    double totalPrice = price * ((1 - GeneralHelpers.GetAirlinerOrderDiscount(totalAmount)));

                    if (contractedOrder)
                    {
                        totalPrice = totalPrice * ((100 - GameObject.GetInstance().HumanAirline.Contract.Discount) / 100);
                    }

                    double downpaymentPrice = 0;

                    downpaymentPrice = totalPrice * (GameObject.GetInstance().Difficulty.PriceLevel / 10);

                    if (cbDownPayment.IsChecked.Value)
                    {
                        if (downpaymentPrice > GameObject.GetInstance().HumanAirline.Money)
                        {
                            WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2001"), Translator.GetInstance().GetString("MessageBox", "2001", "message"), WPFMessageBoxButtons.Ok);
                        }
                        else
                        {
                            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2009"), string.Format(Translator.GetInstance().GetString("MessageBox", "2009", "message"), totalPrice, downpaymentPrice), WPFMessageBoxButtons.YesNo);

                            if (result == WPFMessageBoxResult.Yes)
                            {
                                foreach (AirlinerOrderMVVM order in this.Orders.Orders)
                                {
                                    for (int i = 0; i < order.Amount; i++)
                                    {
                                        Guid id = Guid.NewGuid();

                                        Airliner airliner = new Airliner(id.ToString(), order.Type, GameObject.GetInstance().HumanAirline.Profile.Country.TailNumbers.getNextTailNumber(), deliveryDate);

                                        airliner.clearAirlinerClasses();

                                        foreach (AirlinerClass aClass in order.Classes)
                                        {
                                            AirlinerClass tClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                                            tClass.RegularSeatingCapacity = aClass.RegularSeatingCapacity;

                                            foreach (AirlinerFacility facility in aClass.getFacilities())
                                            {
                                                tClass.setFacility(GameObject.GetInstance().HumanAirline, facility);
                                            }

                                            airliner.addAirlinerClass(tClass);
                                        }


                                        Model.AirlinerModel.Airliners.AddAirliner(airliner);

                                        FleetAirliner.PurchasedType pType = FleetAirliner.PurchasedType.BoughtDownPayment;
                                        GameObject.GetInstance().HumanAirline.addAirliner(pType, airliner, order.Homebase);
                                    }
                                }
                                if (contractedOrder)
                                {
                                    GameObject.GetInstance().HumanAirline.Contract.PurchasedAirliners += this.Orders.Orders.Sum(o => o.Amount);
                                }
                                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -downpaymentPrice);

                                TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu");

                                if (tab_main != null)
                                {
                                    var matchingItem =
                                        tab_main.Items.Cast <TabItem>()
                                        .Where(item => item.Tag.ToString() == "Order")
                                        .FirstOrDefault();

                                    tab_main.SelectedItem = matchingItem;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (totalPrice > GameObject.GetInstance().HumanAirline.Money)
                        {
                            WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2001"), Translator.GetInstance().GetString("MessageBox", "2001", "message"), WPFMessageBoxButtons.Ok);
                        }
                        else
                        {
                            if (this.Orders.Orders.Sum(o => o.Amount) > 0)
                            {
                                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2008"), string.Format(Translator.GetInstance().GetString("MessageBox", "2008", "message"), totalPrice), WPFMessageBoxButtons.YesNo);

                                if (result == WPFMessageBoxResult.Yes)
                                {
                                    orderAirliners(contractedOrder ? GameObject.GetInstance().HumanAirline.Contract.Discount : 0);

                                    TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu");

                                    if (tab_main != null)
                                    {
                                        var matchingItem =
                                            tab_main.Items.Cast <TabItem>()
                                            .Where(item => item.Tag.ToString() == "Order")
                                            .FirstOrDefault();

                                        tab_main.SelectedItem = matchingItem;
                                    }
                                }

                                if (contractedOrder)
                                {
                                    GameObject.GetInstance().HumanAirline.Contract.PurchasedAirliners += this.Orders.Orders.Sum(o => o.Amount);
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Displays a message box that has a message and that returns a result.
        /// </summary>
        /// <param name="owner">A System.Windows.Window that represents the owner window of the message box.</param>
        /// <param name="messageBoxText">A System.String that specifies the text to display.</param>
        /// <param name="caption">A System.String that specifies the title bar caption to display.</param>
        /// <param name="buttons">A DW.WPFToolkit.Controls.WPFMessageBoxButtons value that specifies which button or buttons to display.</param>
        /// <param name="icon">A DW.WPFToolkit.Controls.WPFMessageBoxImage value that specifies the icon to display.</param>
        /// <param name="defaultButton">A DW.WPFToolkit.Controls.WPFMessageBoxResult value that specifies the default result of the message box.</param>
        /// <param name="options">A DW.WPFToolkit.Controls.WPFMessageBoxOptions value object that specifies the options.</param>
        /// <returns>A DW.WPFToolkit.Controls.WPFMessageBoxResult value that specifies which message box button is clicked by the user.</returns>
        public static WPFMessageBoxResult Show(Window owner, string messageBoxText, string caption, WPFMessageBoxButtons buttons, WPFMessageBoxImage icon, WPFMessageBoxResult defaultButton, WPFMessageBoxOptions options)
        {
            if (options == null)
                throw new ArgumentNullException("options");
            
            var box = new WPFMessageBox
            {
                Owner = owner,
                Message = messageBoxText,
                Title = caption ?? string.Empty,
                Buttons = buttons,
                Image = icon,
                DefaultButton = defaultButton,
                Options = options
            };

            SetWindowOptions(box, options.WindowOptions);

            var dialogResult = box.ShowDialog();
            if (dialogResult != true)
            {
                if (buttons == WPFMessageBoxButtons.OK)
                    return WPFMessageBoxResult.OK;
                return WPFMessageBoxResult.Cancel;
            }
            return box.Result;
        }
 /// <summary>
 /// Displays a message box that has a message and that returns a result.
 /// </summary>
 /// <param name="owner">A System.Windows.Window that represents the owner window of the message box.</param>
 /// <param name="messageBoxText">A System.String that specifies the text to display.</param>
 /// <param name="caption">A System.String that specifies the title bar caption to display.</param>
 /// <param name="buttons">A DW.WPFToolkit.Controls.WPFMessageBoxButtons value that specifies which button or buttons to display.</param>
 /// <param name="icon">A DW.WPFToolkit.Controls.WPFMessageBoxImage value that specifies the icon to display.</param>
 /// <param name="defaultButton">A DW.WPFToolkit.Controls.WPFMessageBoxResult value that specifies the default result of the message box.</param>
 /// <returns>A DW.WPFToolkit.Controls.WPFMessageBoxResult value that specifies which message box button is clicked by the user.</returns>
 public static WPFMessageBoxResult Show(Window owner, string messageBoxText, string caption, WPFMessageBoxButtons buttons, WPFMessageBoxImage icon, WPFMessageBoxResult defaultButton)
 {
     return Show(owner, messageBoxText, caption, buttons, icon, defaultButton, new WPFMessageBoxOptions());
 }
        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();
                    }
                }
            }
        }
 /// <summary>
 /// Displays a message box that has a message and that returns a result.
 /// </summary>
 /// <param name="messageBoxText">A System.String that specifies the text to display.</param>
 /// <param name="caption">A System.String that specifies the title bar caption to display.</param>
 /// <param name="buttons">A DW.WPFToolkit.Controls.WPFMessageBoxButtons value that specifies which button or buttons to display.</param>
 /// <param name="icon">A DW.WPFToolkit.Controls.WPFMessageBoxImage value that specifies the icon to display.</param>
 /// <param name="defaultButton">A DW.WPFToolkit.Controls.WPFMessageBoxResult value that specifies the default result of the message box.</param>
 /// <param name="options">A DW.WPFToolkit.Controls.WPFMessageBoxOptions value object that specifies the options.</param>
 /// <returns>A DW.WPFToolkit.Controls.WPFMessageBoxResult value that specifies which message box button is clicked by the user.</returns>
 public static WPFMessageBoxResult Show(string messageBoxText, string caption, WPFMessageBoxButtons buttons, WPFMessageBoxImage icon, WPFMessageBoxResult defaultButton, WPFMessageBoxOptions options)
 {
     return Show(null, messageBoxText, caption, buttons, icon, defaultButton, options);
 }
 private void bNo_Click(object sender, RoutedEventArgs e)
 {
     this.Result = WPFMessageBoxResult.No;
     Close();
 }