private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            if ((this.Airliner.HasRoute && this.Airliner.Status == FleetAirliner.AirlinerStatus.Stopped) || !this.Airliner.HasRoute)
            {
                AirlinerFacilityItem item = (AirlinerFacilityItem)((Button)sender).Tag;

                AirlinerFacility facility = (AirlinerFacility)PopUpAirlinerFacility.ShowPopUp(item.AirlinerClass, item.Facility.Type);

                if (facility != null && item.AirlinerClass.getFacility(item.Facility.Type) != facility)
                {
                    if (facility.Type == AirlinerFacility.FacilityType.Seat)
                    {
                        item.AirlinerClass.SeatingCapacity = Convert.ToInt16(Convert.ToDouble(item.AirlinerClass.RegularSeatingCapacity) / facility.SeatUses);
                    }

                    item.AirlinerClass.setFacility(GameObject.GetInstance().HumanAirline, facility);

                    showFacilities();
                }
            }
            else
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2301"), Translator.GetInstance().GetString("MessageBox", "2301", "message"), WPFMessageBoxButtons.Ok);
            }
        }
        //shows the facilities
        private void showFacilities()
        {
            panelClassFacilities.Children.Clear();

            foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
            {
                TextBlock txtHeader = new TextBlock();
                txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush");
                txtHeader.FontWeight = FontWeights.Bold;
                txtHeader.Text       = string.Format("{0} ({1} seats)", new TextUnderscoreConverter().Convert(aClass.Type, null, null, null), aClass.SeatingCapacity);

                panelClassFacilities.Children.Add(txtHeader);

                foreach (AirlinerFacility.FacilityType type in Enum.GetValues(typeof(AirlinerFacility.FacilityType)))
                {
                    AirlinerFacility facility = aClass.getFacility(type);

                    ListBox lbFacilities = new ListBox();
                    lbFacilities.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
                    lbFacilities.ItemTemplate = this.Resources["FleetFacilityItem"] as DataTemplate;

                    panelClassFacilities.Children.Add(lbFacilities);

                    lbFacilities.Items.Add(new AirlinerFacilityItem(this.Airliner.Airliner.Airline, aClass, facility));
                }
                panelClassFacilities.Children.Add(new Separator());
            }
        }
Ejemplo n.º 3
0
        public AirlinerClassMVVM(AirlinerClass type, int seating, int regularSeating, int maxseats, Boolean changeableSeats = false)
        {
            this.Type    = type.Type;
            this.Seating = seating;
            this.RegularSeatingCapacity = regularSeating;
            this.ChangeableSeats        = changeableSeats;
            this.MaxSeats         = maxseats;
            this.MaxSeatsCapacity = maxseats;
            this.ChangedFacility  = false;

            this.Facilities = new ObservableCollection <AirlinerFacilityMVVM>();

            foreach (AirlinerFacility.FacilityType facType in Enum.GetValues(typeof(AirlinerFacility.FacilityType)))
            {
                AirlinerFacilityMVVM facility = new AirlinerFacilityMVVM(facType, this);

                foreach (AirlinerFacility fac in AirlinerFacilities.GetFacilities(facType))
                {
                    facility.Facilities.Add(fac);
                }


                AirlinerFacility selectedFacility = type.getFacility(facType) == null?AirlinerFacilities.GetBasicFacility(facType) : type.getFacility(facType);

                facility.SelectedFacility = selectedFacility;

                this.Facilities.Add(facility);
            }
        }
Ejemplo n.º 4
0
        private void link_Click(object sender, RoutedEventArgs e)
        {
            AirlinerType type = this.AirlinersToMaintain[0].Airliner.Type;

            if (this.Classes == null)
            {
                AirlinerClass eClass = new AirlinerClass(AirlinerClass.ClassType.Economy_Class, ((AirlinerPassengerType)type).MaxSeatingCapacity);
                eClass.createBasicFacilities(null);
                this.Classes.Add(eClass);
            }

            AirlinerClass aClass = (AirlinerClass)((Hyperlink)sender).Tag;

            AirlinerClass newClass = (AirlinerClass)PopUpAirlinerClassConfiguration.ShowPopUp(aClass);

            AirlinerClass economyClass = this.Classes.Find(c => c.Type == AirlinerClass.ClassType.Economy_Class);

            if (newClass != null)
            {
                AirlinerClass airlinerClass = new AirlinerClass(newClass.Type, newClass.SeatingCapacity);
                airlinerClass.RegularSeatingCapacity = newClass.RegularSeatingCapacity;

                int seatingDiff = ((AirlinerPassengerType)type).MaxSeatingCapacity;

                economyClass.RegularSeatingCapacity += seatingDiff;

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

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

                economyClass.SeatingCapacity += extraSeats;
            }
        }
        private void btnLoadConfiguration_Click(object sender, RoutedEventArgs e)
        {
            ComboBox cbConfigurations = new ComboBox();

            cbConfigurations.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbConfigurations.SelectedValuePath   = "Name";
            cbConfigurations.DisplayMemberPath   = "Name";
            cbConfigurations.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbConfigurations.Width = 200;

            foreach (AirlinerConfiguration confItem in Configurations.GetConfigurations(Configuration.ConfigurationType.Airliner).Where(a => ((AirlinerConfiguration)a).MinimumSeats <= this.Airliner.Airliner.getTotalSeatCapacity() && ((AirlinerConfiguration)a).Classes.Count <= ((AirlinerPassengerType)this.Airliner.Airliner.Type).MaxAirlinerClasses))
            {
                cbConfigurations.Items.Add(confItem);
            }

            cbConfigurations.SelectedIndex = 0;


            if (TheAirline.GraphicsModel.UserControlModel.PopUpWindowsModel.PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PageAirlineWages", "1013"), cbConfigurations) == TheAirline.GraphicsModel.UserControlModel.PopUpWindowsModel.PopUpSingleElement.ButtonSelected.OK && cbConfigurations.SelectedItem != null)
            {
                this.Classes.Clear();

                AirlinerConfiguration configuration = (AirlinerConfiguration)cbConfigurations.SelectedItem;

                foreach (AirlinerClassConfiguration aClass in configuration.Classes)
                {
                    AirlinerClass     nClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                    AirlinerClassMVVM tClass = new AirlinerClassMVVM(nClass, aClass.SeatingCapacity, aClass.RegularSeatingCapacity, aClass.RegularSeatingCapacity);

                    foreach (AirlinerFacility facility in aClass.getFacilities())
                    {
                        tClass.Facilities.First(f => f.Type == facility.Type).SelectedFacility = facility;
                    }

                    foreach (AirlinerFacility.FacilityType fType in Enum.GetValues(typeof(AirlinerFacility.FacilityType)))
                    {
                        if (!aClass.Facilities.Exists(f => f.Type == fType))
                        {
                            tClass.Facilities.First(f => f.Type == fType).SelectedFacility = AirlinerFacilities.GetBasicFacility(fType);
                        }
                    }

                    this.Classes.Add(tClass);
                }
                int seatingDiff = ((AirlinerPassengerType)this.Airliner.Airliner.Type).MaxSeatingCapacity - configuration.MinimumSeats;

                AirlinerClassMVVM economyClass = this.Classes.First(c => c.Type == AirlinerClass.ClassType.Economy_Class);

                economyClass.RegularSeatingCapacity += seatingDiff;

                AirlinerFacility seatingFacility = economyClass.Facilities.First(f => f.Type == AirlinerFacility.FacilityType.Seat).SelectedFacility;

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

                economyClass.Seating += extraSeats;
            }
        }
Ejemplo n.º 6
0
 private void setSeating(AirlinerFacility oldValue)
 {
     if (this.Type == AirlinerFacility.FacilityType.Seat && _selectedFacility != null && oldValue != null)
     {
         this.AirlinerClass.ChangedFacility = true;
         double diff = oldValue.SeatUses / _selectedFacility.SeatUses;
         this.AirlinerClass.Seating         = Convert.ToInt16(Convert.ToDouble(this.AirlinerClass.Seating) * diff);
         this.AirlinerClass.MaxSeats        = Convert.ToInt16(Convert.ToDouble(this.AirlinerClass.MaxSeats) * diff);
         this.AirlinerClass.ChangedFacility = false;
     }
 }
        private void btnLoadConfiguration_Click(object sender, RoutedEventArgs e)
        {
            AirlinerPassengerType airlinerType = ((AirlinerPassengerType)this.Airliner.Airliner.Type);

            ComboBox cbConfigurations = new ComboBox();

            cbConfigurations.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbConfigurations.SelectedValuePath   = "Name";
            cbConfigurations.DisplayMemberPath   = "Name";
            cbConfigurations.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbConfigurations.Width = 200;

            foreach (AirlinerConfiguration confItem in Configurations.GetConfigurations(Configuration.ConfigurationType.Airliner).FindAll(c => ((AirlinerConfiguration)c).getNumberOfClasses() <= airlinerType.MaxAirlinerClasses && ((AirlinerConfiguration)c).MinimumSeats <= airlinerType.MaxSeatingCapacity))
            {
                cbConfigurations.Items.Add(confItem);
            }

            cbConfigurations.SelectedIndex = 0;

            if (PopUpSingleElement.ShowPopUp("Select configuration", cbConfigurations) == PopUpSingleElement.ButtonSelected.OK && cbConfigurations.SelectedItem != null)
            {
                AirlinerConfiguration configuration = (AirlinerConfiguration)cbConfigurations.SelectedItem;

                this.Airliner.Airliner.clearAirlinerClasses();

                foreach (AirlinerClassConfiguration aClass in configuration.Classes)
                {
                    AirlinerClass airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                    airlinerClass.RegularSeatingCapacity = aClass.RegularSeatingCapacity;

                    foreach (AirlinerFacility facility in aClass.getFacilities())
                    {
                        airlinerClass.setFacility(this.Airliner.Airliner.Airline, facility);
                    }

                    this.Airliner.Airliner.addAirlinerClass(airlinerClass);
                }

                int seatingDiff = airlinerType.MaxSeatingCapacity - configuration.MinimumSeats;

                this.Airliner.Airliner.getAirlinerClass(AirlinerClass.ClassType.Economy_Class).RegularSeatingCapacity += seatingDiff;

                AirlinerFacility seatingFacility = this.Airliner.Airliner.getAirlinerClass(AirlinerClass.ClassType.Economy_Class).getFacility(AirlinerFacility.FacilityType.Seat);

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

                this.Airliner.Airliner.getAirlinerClass(AirlinerClass.ClassType.Economy_Class).SeatingCapacity += extraSeats;

                showFacilities();
            }
        }
        //shows the facilities
        private void showFacilities()
        {
            int i = 0;

            foreach (AirlinerFacility.FacilityType type in Enum.GetValues(typeof(AirlinerFacility.FacilityType)))
            {
                AirlinerFacility facility = this.AirlinerClass.getFacility(type);

                lbFacilities[i].Items.Clear();
                lbFacilities[i].Items.Add(new AirlinerFacilityItem(this.AirlinerClass, facility));

                i++;
            }
        }
        public PopUpAirlinerClassConfiguration(AirlinerClass aClass)
        {
            InitializeComponent();

            this.AirlinerClass = aClass;

            this.Title = new TextUnderscoreConverter().Convert(aClass.Type.ToString()).ToString();

            this.Width = 400;

            this.Height = 200;

            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            StackPanel panelClassFacilities = new StackPanel();

            TextBlock txtHeader = new TextBlock();

            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush");
            txtHeader.FontWeight = FontWeights.Bold;
            txtHeader.Text       = string.Format("{0}", new TextUnderscoreConverter().Convert(aClass.Type, null, null, null));

            panelClassFacilities.Children.Add(txtHeader);

            lbFacilities = new ListBox[Enum.GetValues(typeof(AirlinerFacility.FacilityType)).Length];

            int i = 0;

            foreach (AirlinerFacility.FacilityType type in Enum.GetValues(typeof(AirlinerFacility.FacilityType)))
            {
                AirlinerFacility facility = aClass.getFacility(type);

                lbFacilities[i] = new ListBox();
                lbFacilities[i].ItemContainerStyleSelector = new ListBoxItemStyleSelector();
                lbFacilities[i].ItemTemplate = this.Resources["FleetFacilityItem"] as DataTemplate;

                panelClassFacilities.Children.Add(lbFacilities[i]);

                i++;
            }
            panelClassFacilities.Children.Add(createButtonsPanel());


            this.Content = panelClassFacilities;

            showFacilities();
        }
        private void tcMenu_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (AirlinerClassMVVM aClass in this.Classes)
            {
                foreach (AirlinerFacility.FacilityType facType in Enum.GetValues(typeof(AirlinerFacility.FacilityType)))
                {
                    AirlinerFacility facility = aClass.Facilities.Where(f => f.Type == facType).First().SelectedFacility;

                    if (facility == null)
                    {
                        facility = AirlinerFacilities.GetBasicFacility(facType);
                    }

                    aClass.Facilities.Where(f => f.Type == facType).First().SelectedFacility = facility;
                }
            }
        }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            AirlinerFacilityItem item = (AirlinerFacilityItem)((Button)sender).Tag;

            AirlinerFacility facility = (AirlinerFacility)PopUpAirlinerFacility.ShowPopUp(item.AirlinerClass, item.Facility.Type);

            if (facility != null && item.AirlinerClass.getFacility(item.Facility.Type) != facility)
            {
                if (facility.Type == AirlinerFacility.FacilityType.Seat)
                {
                    item.AirlinerClass.SeatingCapacity = Convert.ToInt16(Convert.ToDouble(item.AirlinerClass.RegularSeatingCapacity) / facility.SeatUses);
                }

                item.AirlinerClass.setFacility(null, facility);

                showFacilities();
            }
        }
        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;
                }
            }
        }
Ejemplo n.º 13
0
        //returns the airliner classes for an airliner
        public static List <AirlinerClass> GetAirlinerClasses(AirlinerType type)
        {
            List <AirlinerClass> classes = new List <AirlinerClass>();

            if (type is AirlinerPassengerType)
            {
                Configuration airlinerTypeConfiguration = Configurations.GetConfigurations(Configuration.ConfigurationType.AirlinerType).Find(c => ((AirlinerTypeConfiguration)c).Airliner == type && ((AirlinerTypeConfiguration)c).Period.From <= GameObject.GetInstance().GameTime&& ((AirlinerTypeConfiguration)c).Period.To > GameObject.GetInstance().GameTime);

                if (airlinerTypeConfiguration == null)
                {
                    AirlinerConfiguration configuration = null;

                    int numOfClasses = rnd.Next(0, ((AirlinerPassengerType)type).MaxAirlinerClasses) + 1;

                    if (GameObject.GetInstance().GameTime.Year >= (int)AirlinerClass.ClassType.Business_Class)
                    {
                        if (numOfClasses == 1)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("200");
                        }
                        if (numOfClasses == 2)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("202");
                        }
                        if (numOfClasses == 3)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("203");
                        }
                    }
                    else
                    {
                        if (numOfClasses == 1)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("200");
                        }
                        if (numOfClasses == 2)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("201");
                        }
                        if (numOfClasses == 3)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("201");
                        }
                    }

                    foreach (AirlinerClassConfiguration aClass in configuration.Classes)
                    {
                        AirlinerClass airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                        airlinerClass.RegularSeatingCapacity = aClass.RegularSeatingCapacity;

                        foreach (AirlinerFacility facility in aClass.getFacilities())
                        {
                            airlinerClass.setFacility(null, facility);
                        }

                        foreach (AirlinerFacility.FacilityType fType in Enum.GetValues(typeof(AirlinerFacility.FacilityType)))
                        {
                            if (!aClass.Facilities.Exists(f => f.Type == fType))
                            {
                                airlinerClass.setFacility(null, AirlinerFacilities.GetBasicFacility(fType));
                            }
                        }

                        airlinerClass.SeatingCapacity = Convert.ToInt16(Convert.ToDouble(airlinerClass.RegularSeatingCapacity) / airlinerClass.getFacility(AirlinerFacility.FacilityType.Seat).SeatUses);

                        classes.Add(airlinerClass);
                    }

                    int seatingDiff = ((AirlinerPassengerType)type).MaxSeatingCapacity - configuration.MinimumSeats;

                    AirlinerClass economyClass = 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;
                }
                else
                {
                    foreach (AirlinerClassConfiguration aClass in ((AirlinerTypeConfiguration)airlinerTypeConfiguration).Classes)
                    {
                        AirlinerClass airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                        airlinerClass.RegularSeatingCapacity = aClass.RegularSeatingCapacity;

                        foreach (AirlinerFacility facility in aClass.getFacilities())
                        {
                            airlinerClass.setFacility(null, facility);
                        }

                        airlinerClass.SeatingCapacity = Convert.ToInt16(Convert.ToDouble(airlinerClass.RegularSeatingCapacity) / airlinerClass.getFacility(AirlinerFacility.FacilityType.Seat).SeatUses);

                        classes.Add(airlinerClass);
                    }
                }
            }
            else if (type is AirlinerCargoType)
            {
                AirlinerClass cargoClass = new AirlinerClass(AirlinerClass.ClassType.Economy_Class, 0);
                classes.Add(cargoClass);
            }

            return(classes);
        }
Ejemplo n.º 14
0
        //creates the airliner classes for an airliner
        public static void CreateAirlinerClasses(Airliner airliner)
        {
            if (airliner.Type is AirlinerPassengerType)
            {
                Configuration airlinerTypeConfiguration = Configurations.GetConfigurations(Configuration.ConfigurationType.AirlinerType).Find(c => ((AirlinerTypeConfiguration)c).Airliner == airliner.Type && ((AirlinerTypeConfiguration)c).Period.From <= airliner.BuiltDate && ((AirlinerTypeConfiguration)c).Period.To > airliner.BuiltDate);

                if (airlinerTypeConfiguration == null)
                {
                    airliner.clearAirlinerClasses();

                    AirlinerConfiguration configuration = null;

                    int classes = rnd.Next(0, ((AirlinerPassengerType)airliner.Type).MaxAirlinerClasses) + 1;

                    if (GameObject.GetInstance().GameTime.Year >= (int)AirlinerClass.ClassType.Business_Class)
                    {
                        if (classes == 1)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("200");
                        }
                        if (classes == 2)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("202");
                        }
                        if (classes == 3)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("203");
                        }
                    }
                    else
                    {
                        if (classes == 1)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("200");
                        }
                        if (classes == 2)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("201");
                        }
                        if (classes == 3)
                        {
                            configuration = (AirlinerConfiguration)Configurations.GetStandardConfiguration("201");
                        }
                    }

                    foreach (AirlinerClassConfiguration aClass in configuration.Classes)
                    {
                        AirlinerClass airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                        airlinerClass.RegularSeatingCapacity = aClass.RegularSeatingCapacity;

                        foreach (AirlinerFacility facility in aClass.getFacilities())
                        {
                            airlinerClass.setFacility(airliner.Airline, facility);
                        }

                        airlinerClass.SeatingCapacity = Convert.ToInt16(Convert.ToDouble(airlinerClass.RegularSeatingCapacity) / airlinerClass.getFacility(AirlinerFacility.FacilityType.Seat).SeatUses);

                        airliner.addAirlinerClass(airlinerClass);
                    }

                    int seatingDiff = ((AirlinerPassengerType)airliner.Type).MaxSeatingCapacity - configuration.MinimumSeats;

                    airliner.getAirlinerClass(AirlinerClass.ClassType.Economy_Class).RegularSeatingCapacity += seatingDiff;

                    AirlinerFacility seatingFacility = airliner.getAirlinerClass(AirlinerClass.ClassType.Economy_Class).getFacility(AirlinerFacility.FacilityType.Seat);

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

                    airliner.getAirlinerClass(AirlinerClass.ClassType.Economy_Class).SeatingCapacity += extraSeats;
                }
                else
                {
                    airliner.clearAirlinerClasses();

                    foreach (AirlinerClassConfiguration aClass in ((AirlinerTypeConfiguration)airlinerTypeConfiguration).Classes)
                    {
                        AirlinerClass airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                        airlinerClass.RegularSeatingCapacity = aClass.RegularSeatingCapacity;

                        foreach (AirlinerFacility facility in aClass.getFacilities())
                        {
                            airlinerClass.setFacility(airliner.Airline, facility);
                        }

                        airlinerClass.SeatingCapacity = Convert.ToInt16(Convert.ToDouble(airlinerClass.RegularSeatingCapacity) / airlinerClass.getFacility(AirlinerFacility.FacilityType.Seat).SeatUses);

                        airliner.addAirlinerClass(airlinerClass);
                    }
                }
            }
            else if (airliner.Type is AirlinerCargoType)
            {
                airliner.clearAirlinerClasses();

                AirlinerClass cargoClass = new AirlinerClass(AirlinerClass.ClassType.Economy_Class, 0);
                airliner.addAirlinerClass(cargoClass);
            }
        }
 public AirlinerFacilityItem(Airline airline, AirlinerClass aClass, AirlinerFacility facility)
 {
     this.Airline       = airline;
     this.AirlinerClass = aClass;
     this.Facility      = facility;
 }
Ejemplo n.º 16
0
        private ComboBox cbAirport;// cbName;
        public PanelUsedAirliner(PageAirliners parent, Airliner airliner)
            : base(parent)
        {
            this.Airliner = airliner;

            StackPanel panelAirliner = new StackPanel();

            panelAirliner.Children.Add(PanelAirliner.createQuickInfoPanel(airliner.Type));

            this.addObject(panelAirliner);

            TextBlock txtHeader = new TextBlock();

            txtHeader.Uid    = "1001";
            txtHeader.Margin = new System.Windows.Thickness(0, 5, 0, 0);
            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeader.FontWeight = FontWeights.Bold;
            txtHeader.Text       = Translator.GetInstance().GetString("PanelUsedAirliner", txtHeader.Uid);

            this.addObject(txtHeader);


            ListBox lbAirlineInfo = new ListBox();

            lbAirlineInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbAirlineInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            this.addObject(lbAirlineInfo);

            lbAirlineInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1002"), UICreator.CreateTextBlock(string.Format("{0} ({1} years old)", this.Airliner.BuiltDate.ToShortDateString(), this.Airliner.Age))));

            WrapPanel panelTailNumber = new WrapPanel();

            TextBlock txtTailNumber = UICreator.CreateTextBlock(this.Airliner.TailNumber);

            txtTailNumber.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            panelTailNumber.Children.Add(txtTailNumber);

            ContentControl ccFlag = new ContentControl();

            ccFlag.SetResourceReference(ContentControl.ContentTemplateProperty, "CountryFlagLongItem");
            ccFlag.Content = new CountryCurrentCountryConverter().Convert(Countries.GetCountryFromTailNumber(this.Airliner.TailNumber));
            ccFlag.Margin  = new Thickness(10, 0, 0, 0);

            panelTailNumber.Children.Add(ccFlag);

            lbAirlineInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1003"), panelTailNumber));
            lbAirlineInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1004"), UICreator.CreateTextBlock(string.Format("{0:0.##} {1}", new NumberToUnitConverter().Convert(this.Airliner.Flown), new StringToLanguageConverter().Convert("km.")))));
            lbAirlineInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1005"), UICreator.CreateTextBlock(string.Format("{0:0.##} {1}", new NumberToUnitConverter().Convert(this.Airliner.LastServiceCheck), new StringToLanguageConverter().Convert("km.")))));

            foreach (AirlinerClass aClass in this.Airliner.Classes)
            {
                TextBlock txtClass = UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(aClass.Type, null, null, null).ToString());
                txtClass.FontWeight = FontWeights.Bold;

                lbAirlineInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1006"), txtClass));

                foreach (AirlinerFacility.FacilityType type in Enum.GetValues(typeof(AirlinerFacility.FacilityType)))
                {
                    AirlinerFacility facility = aClass.getFacility(type);
                    lbAirlineInfo.Items.Add(new QuickInfoValue(string.Format("{0} facilities", type), UICreator.CreateTextBlock(facility.Name)));
                }
            }

            TextBlock txtPriceHeader = new TextBlock();

            txtPriceHeader.Uid = "1101";
            txtPriceHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtPriceHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtPriceHeader.Margin     = new System.Windows.Thickness(0, 5, 0, 0);
            txtPriceHeader.FontWeight = FontWeights.Bold;
            txtPriceHeader.Text       = Translator.GetInstance().GetString("PanelUsedAirliner", txtPriceHeader.Uid);

            this.addObject(txtPriceHeader);


            ListBox lbPriceInfo = new ListBox();

            lbPriceInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbPriceInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            this.addObject(lbPriceInfo);

            /*
             * lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1102"), UICreator.CreateTextBlock(string.Format("{0:c}", this.Airliner.Price))));
             * lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1103"), UICreator.CreateTextBlock(string.Format("{0:c}", this.Airliner.LeasingPrice))));
             * lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1104"), UICreator.CreateTextBlock(string.Format("{0:c}", this.Airliner.Type.getMaintenance()))));
             */

            lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1102"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(Airliner.Price).ToString())));
            lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1103"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.Airliner.LeasingPrice).ToString())));
            lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1104"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.Airliner.Type.getMaintenance()).ToString())));


            cbAirport = new ComboBox();
            cbAirport.SetResourceReference(ComboBox.ItemTemplateProperty, "AirportCountryItem");
            cbAirport.Background = Brushes.Transparent;
            cbAirport.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbAirport.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

            List <Airport> airports = GameObject.GetInstance().HumanAirline.Airports.FindAll(a => a.getCurrentAirportFacility(GameObject.GetInstance().HumanAirline, AirportFacility.FacilityType.Service).TypeLevel > 0 && a.getMaxRunwayLength() >= this.Airliner.Type.MinRunwaylength);

            airports = (from a in airports orderby a.Profile.Name select a).ToList();

            foreach (Airport airport in airports)
            {
                cbAirport.Items.Add(airport);
            }

            cbAirport.SelectedIndex = 0;

            lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1105"), cbAirport));

            WrapPanel panelButtons = new WrapPanel();

            panelButtons.Margin = new Thickness(0, 5, 0, 0);
            this.addObject(panelButtons);

            Button btnBuy = new Button();

            btnBuy.Uid = "200";
            btnBuy.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnBuy.Height  = Double.NaN;
            btnBuy.Width   = Double.NaN;
            btnBuy.Content = Translator.GetInstance().GetString("PanelUsedAirliner", btnBuy.Uid);
            btnBuy.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnBuy.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            btnBuy.Click += new System.Windows.RoutedEventHandler(btnBuy_Click);
            panelButtons.Children.Add(btnBuy);

            Button btnLease = new Button();

            btnLease.Uid = "201";
            btnLease.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnLease.Height  = Double.NaN;
            btnLease.Width   = Double.NaN;
            btnLease.Content = Translator.GetInstance().GetString("PanelUsedAirliner", btnLease.Uid);
            btnLease.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnLease.Margin = new Thickness(5, 0, 0, 0);
            btnLease.Click += new RoutedEventHandler(btnLease_Click);
            panelButtons.Children.Add(btnLease);
        }