Наследование: INotifyPropertyChanged
Пример #1
0
        private void btnPurchaseShares_Click(object sender, RoutedEventArgs e)
        {
            AirlinesMVVM airline = this.SelectedAirline;

            ComboBox cbShares = new ComboBox();

            cbShares.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbShares.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbShares.Width = 200;

            int dValue = Convert.ToInt16(Convert.ToDouble(airline.StocksForSale) / 10);

            for (int i = 0; i <= airline.StocksForSale; i += dValue)
            {
                cbShares.Items.Add(i);
            }

            cbShares.SelectedIndex = 0;

            if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PageAirlinesShares", "1000"), cbShares) == PopUpSingleElement.ButtonSelected.OK && cbShares.SelectedItem != null)
            {
                int numberOfShares = Convert.ToInt32(cbShares.SelectedItem);

                double amount = numberOfShares * airline.StockPrice;

                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -amount);

                airline.addOwnership(GameObject.GetInstance().HumanAirline, numberOfShares);
            }
        }
Пример #2
0
        private void btnBuyAsSubsidiary_Click(object sender, RoutedEventArgs e)
        {
            AirlinesMVVM airline = this.SelectedAirline;

            double buyingPrice = airline.Airline.getValue() * 100000 * 1.10;

            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2113"), string.Format(Translator.GetInstance().GetString("MessageBox", "2113", "message"), airline.Airline.Profile.Name, buyingPrice), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                List <AirlineLogo> oldLogos = airline.Airline.Profile.Logos;
                string             oldColor = airline.Airline.Profile.Color;

                //creates independent airlines for each subsidiary
                while (airline.Airline.Subsidiaries.Count > 0)
                {
                    SubsidiaryAirline subAirline = airline.Airline.Subsidiaries[0];

                    subAirline.Airline = null;

                    airline.Airline.removeSubsidiaryAirline(subAirline);
                }

                if (airline.Airline.License > GameObject.GetInstance().HumanAirline.License)
                {
                    GameObject.GetInstance().HumanAirline.License = airline.Airline.License;
                }

                SubsidiaryAirline sAirline = new SubsidiaryAirline(GameObject.GetInstance().HumanAirline, airline.Airline.Profile, airline.Airline.Mentality, airline.Airline.MarketFocus, airline.Airline.License, airline.Airline.AirlineRouteFocus);

                AirlineHelpers.SwitchAirline(airline.Airline, sAirline);

                GameObject.GetInstance().HumanAirline.addSubsidiaryAirline(sAirline);

                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -buyingPrice);

                Airlines.RemoveAirline(airline.Airline);
                Airlines.AddAirline(sAirline);

                sAirline.Profile.Logos = oldLogos;
                sAirline.Profile.Color = oldColor;

                foreach (AirlinePolicy policy in airline.Airline.Policies)
                {
                    sAirline.addAirlinePolicy(policy);
                }

                sAirline.Money      = airline.Airline.Money;
                sAirline.StartMoney = airline.Airline.Money;

                sAirline.Fees = new AirlineFees();

                PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline));
            }
        }
Пример #3
0
        private void btnBuyAirline_Click(object sender, RoutedEventArgs e)
        {
            AirlinesMVVM airline = this.SelectedAirline;

            double buyingPrice = airline.Airline.getValue() * 100000 * 1.10;

            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2113"), string.Format(Translator.GetInstance().GetString("MessageBox", "2113", "message"), airline.Airline.Profile.Name, buyingPrice), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2114"), string.Format(Translator.GetInstance().GetString("MessageBox", "2114", "message"), airline.Airline.Profile.Name, buyingPrice), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    while (airline.Airline.Subsidiaries.Count > 0)
                    {
                        SubsidiaryAirline subAirline = airline.Airline.Subsidiaries[0];
                        subAirline.Profile.CEO = GameObject.GetInstance().HumanAirline.Profile.CEO;

                        subAirline.Airline = GameObject.GetInstance().HumanAirline;
                        airline.Airline.removeSubsidiaryAirline(subAirline);
                        GameObject.GetInstance().HumanAirline.addSubsidiaryAirline(subAirline);
                    }
                }
                else
                {
                    while (airline.Airline.Subsidiaries.Count > 0)
                    {
                        SubsidiaryAirline subAirline = airline.Airline.Subsidiaries[0];

                        subAirline.Airline = null;

                        airline.Airline.removeSubsidiaryAirline(subAirline);
                    }
                }
                if (airline.Airline.License > GameObject.GetInstance().HumanAirline.License)
                {
                    GameObject.GetInstance().HumanAirline.License = airline.Airline.License;
                }

                AirlineHelpers.SwitchAirline(airline.Airline, GameObject.GetInstance().HumanAirline);

                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -buyingPrice);

                Airlines.RemoveAirline(airline.Airline);

                PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline));
            }
        }
Пример #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();
            }
        }
 private void btnShowAirline_Click(object sender, RoutedEventArgs e)
 {
     this.SelectedAirline = (AirlinesMVVM)((Button)sender).Tag;
 }
Пример #6
0
 private void btnShowAirline_Click(object sender, RoutedEventArgs e)
 {
     this.SelectedAirline = (AirlinesMVVM)((Button)sender).Tag;
 }