Inheritance: INotifyPropertyChanged
Ejemplo n.º 1
0
        public AirlinerFacilityMVVM(AirlinerFacility.FacilityType type, AirlinerClassMVVM airlinerClass)
        {
            this.Facilities = new ObservableCollection <AirlinerFacility>();

            this.AirlinerClass = airlinerClass;
            this.Type          = type;
        }
        private void slSeats_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            AirlinerClassMVVM aClass = (AirlinerClassMVVM)((Slider)sender).Tag;

            if (aClass.Type != AirlinerClass.ClassType.Economy_Class)
            {
                double diff = (e.NewValue - e.OldValue);// *aClass.Facilities.Find(f => f.Type == AirlinerFacility.FacilityType.Seat).SelectedFacility.SeatUses;

                Console.WriteLine("Class: {0}, Old value: {1}, New value: {2}", aClass.Type, e.OldValue, e.NewValue);

                if (this.Airliner.Classes.Count == 3)
                {
                    if (this.Airliner.Classes[1] == aClass)
                    {
                        // this.Airliner.Classes[2].RegularSeatingCapacity -= Convert.ToInt16(diff);
                        this.Airliner.Classes[2].MaxSeats = Convert.ToInt16(Convert.ToDouble(this.Airliner.Classes[2].RegularSeatingCapacity) / this.Airliner.Classes[2].Facilities.Where(f => f.Type == AirlinerFacility.FacilityType.Seat).First().SelectedFacility.SeatUses);
                    }

                    if (this.Airliner.Classes[2] == aClass)
                    {
                        // this.Airliner.Classes[1].RegularSeatingCapacity -= Convert.ToInt16(diff);
                        this.Airliner.Classes[1].MaxSeats = Convert.ToInt16(Convert.ToDouble(this.Airliner.Classes[1].RegularSeatingCapacity) / this.Airliner.Classes[1].Facilities.Where(f => f.Type == AirlinerFacility.FacilityType.Seat).First().SelectedFacility.SeatUses);
                    }
                }

                AirlinerClassMVVM tClass = this.Airliner.Classes[0];

                tClass.RegularSeatingCapacity -= Convert.ToInt16(diff);

                tClass.Seating = Convert.ToInt16(Convert.ToDouble(tClass.RegularSeatingCapacity) / tClass.Facilities.Where(f => f.Type == AirlinerFacility.FacilityType.Seat).First().SelectedFacility.SeatUses);
            }
        }
        private void btnAddPilot_Click(object sender, RoutedEventArgs e)
        {
            ComboBox cbPilots = new ComboBox();

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

            foreach (Pilot pilot in this.Airliner.Airliner.Airliner.Airline.Pilots.Where(p => p.Airliner == null && p.Aircrafts.Contains(this.Airliner.Airliner.Airliner.Type.AirlinerFamily)))
            {
                cbPilots.Items.Add(pilot);
            }

            cbPilots.SelectedIndex = 0;

            AirlinerClassMVVM tClass = this.Airliner.Classes[0];

            if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PageFleetAirlinerInformation", "1013"), cbPilots) == PopUpSingleElement.ButtonSelected.OK && cbPilots.SelectedItem != null)
            {
                Pilot pilot = (Pilot)cbPilots.SelectedItem;
                this.Airliner.addPilot(pilot);
            }
        }
        private void slSeats_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            AirlinerClassMVVM aClass = (AirlinerClassMVVM)((Slider)sender).Tag;


            if (aClass.Type != AirlinerClass.ClassType.Economy_Class && !aClass.ChangedFacility)
            {
                int diff = (int)(e.NewValue - e.OldValue);

                this.Airliner.Classes[0].RegularSeatingCapacity -= diff;
                this.Airliner.Classes[0].Seating = Convert.ToInt16(Convert.ToDouble(this.Airliner.Classes[0].RegularSeatingCapacity) / this.Airliner.Classes[0].Facilities.Where(f => f.Type == AirlinerFacility.FacilityType.Seat).First().SelectedFacility.SeatUses);

                if (this.Airliner.Classes.Count == 3)
                {
                    if (this.Airliner.Classes[1] == aClass)
                    {
                        //this.Airliner.Classes[2].RegularSeatingCapacity -= diff;
                        this.Airliner.Classes[2].MaxSeats -= Convert.ToInt16(Convert.ToDouble(diff) / this.Airliner.Classes[2].Facilities.Where(f => f.Type == AirlinerFacility.FacilityType.Seat).First().SelectedFacility.SeatUses);
                    }
                    else
                    {
                        //this.Airliner.Classes[1].RegularSeatingCapacity -= diff;
                        this.Airliner.Classes[1].MaxSeats -= Convert.ToInt16(Convert.ToDouble(diff) / this.Airliner.Classes[2].Facilities.Where(f => f.Type == AirlinerFacility.FacilityType.Seat).First().SelectedFacility.SeatUses);
                    }
                }
            }

            /*
             * if (aClass.Type != AirlinerClass.ClassType.Economy_Class)
             * {
             *  double diff = (e.NewValue - e.OldValue);// *aClass.Facilities.Find(f => f.Type == AirlinerFacility.FacilityType.Seat).SelectedFacility.SeatUses;
             *
             *
             *  if (this.Airliner.Classes.Count == 3)
             *  {
             *      if (this.Airliner.Classes[1] == aClass)
             *      {
             *         // this.Airliner.Classes[2].RegularSeatingCapacity -= Convert.ToInt16(diff);
             *          this.Airliner.Classes[2].MaxSeats = Convert.ToInt16(Convert.ToDouble(this.Airliner.Classes[2].RegularSeatingCapacity) / this.Airliner.Classes[2].Facilities.Where(f => f.Type == AirlinerFacility.FacilityType.Seat).First().SelectedFacility.SeatUses);
             *
             *      }
             *
             *      if (this.Airliner.Classes[2] == aClass)
             *      {
             *         // this.Airliner.Classes[1].RegularSeatingCapacity -= Convert.ToInt16(diff);
             *          this.Airliner.Classes[1].MaxSeats = Convert.ToInt16(Convert.ToDouble(this.Airliner.Classes[1].RegularSeatingCapacity) / this.Airliner.Classes[1].Facilities.Where(f => f.Type == AirlinerFacility.FacilityType.Seat).First().SelectedFacility.SeatUses);
             *      }
             *  }
             *
             *  AirlinerClassMVVM tClass = this.Airliner.Classes[0];
             *
             *  tClass.RegularSeatingCapacity -= Convert.ToInt16(diff);
             *
             *  tClass.Seating = Convert.ToInt16(Convert.ToDouble(tClass.RegularSeatingCapacity) / tClass.Facilities.Where(f => f.Type == AirlinerFacility.FacilityType.Seat).First().SelectedFacility.SeatUses);
             * }*/
        }
Ejemplo n.º 5
0
        public FleetAirlinerMVVM(FleetAirliner airliner)
        {
            this.Airliner = airliner;
            this.Classes  = new ObservableCollection <AirlinerClassMVVM>();

            AirlinerClass tClass = this.Airliner.Airliner.Classes[0];

            foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
            {
                int maxCapacity;

                if (airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger)
                {
                    maxCapacity = ((AirlinerPassengerType)airliner.Airliner.Type).MaxSeatingCapacity;
                }
                else
                {
                    maxCapacity = tClass.RegularSeatingCapacity;
                }

                Boolean changeable = this.Airliner.Airliner.Classes.IndexOf(aClass) > 0;

                int maxSeats;

                if (this.Airliner.Airliner.Classes.Count == 3)
                {
                    if (this.Airliner.Airliner.Classes.IndexOf(aClass) == 1)
                    {
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[2].RegularSeatingCapacity;
                    }
                    else
                    {
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[1].RegularSeatingCapacity;
                    }
                }
                else
                {
                    maxSeats = maxCapacity - 1;
                }


                AirlinerClassMVVM amClass = new AirlinerClassMVVM(aClass.Type, aClass.SeatingCapacity, aClass.RegularSeatingCapacity, maxSeats, changeable);
                this.Classes.Add(amClass);
            }

            this.AMaintenanceInterval = this.Airliner.AMaintenanceInterval;
            this.BMaintenanceInterval = this.Airliner.BMaintenanceInterval;
            this.CMaintenanceInterval = this.Airliner.CMaintenanceInterval;
            this.DMaintenanceInterval = this.Airliner.DMaintenanceInterval;

            this.SchedCMaintenance = this.Airliner.SchedCMaintenance;
            this.SchedDMaintenance = this.Airliner.SchedDMaintenance;
        }
        public PageAirlineEditAirliners(List<FleetAirliner> airliners)
        {
            this.Airliners = airliners;

            this.Loaded += PageAirlineEditAirliners_Loaded;

            this.DataContext = this.Airliners;

            this.Classes = new ObservableCollection<AirlinerClassMVVM>();
            this.Airliner = getMinimumAirliner();

            foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
            {
                int maxCapacity;

                if (this.Airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger)
                    maxCapacity = ((AirlinerPassengerType)this.Airliner.Airliner.Type).MaxSeatingCapacity;
                else
                    maxCapacity = 100;

                Boolean changeable = this.Airliner.Airliner.Classes.IndexOf(aClass) > 0;

                int maxSeats;

                if (this.Airliner.Airliner.Classes.Count == 3)
                {
                    if (this.Airliner.Airliner.Classes.IndexOf(aClass) == 1)
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[2].RegularSeatingCapacity;
                    else
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[1].RegularSeatingCapacity;
                }
                else
                    maxSeats = maxCapacity - 1;

                AirlinerClassMVVM amClass = new AirlinerClassMVVM(aClass, aClass.SeatingCapacity, aClass.RegularSeatingCapacity, maxSeats, changeable);
                this.Classes.Add(amClass);
            }

            InitializeComponent();
        }
Ejemplo n.º 7
0
        public FleetAirlinerMVVM(FleetAirliner airliner)
        {
            this.Airliner = airliner;
            this.Classes = new ObservableCollection<AirlinerClassMVVM>();

            AirlinerClass tClass = this.Airliner.Airliner.Classes[0];

            foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
            {
                int maxCapacity;

                if (airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger)
                    maxCapacity = ((AirlinerPassengerType)airliner.Airliner.Type).MaxSeatingCapacity;
                else
                    maxCapacity = tClass.RegularSeatingCapacity;

                Boolean changeable = this.Airliner.Airliner.Classes.IndexOf(aClass) > 0;

                int maxSeats;

                if (this.Airliner.Airliner.Classes.Count == 3)
                {
                    if (this.Airliner.Airliner.Classes.IndexOf(aClass) == 1)
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[2].RegularSeatingCapacity;
                    else
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[1].RegularSeatingCapacity;
                }
                else
                    maxSeats =maxCapacity -1;

                AirlinerClassMVVM amClass = new AirlinerClassMVVM(aClass.Type, aClass.SeatingCapacity, aClass.RegularSeatingCapacity, maxSeats, changeable);
                this.Classes.Add(amClass);
            }

            this.AMaintenanceInterval = this.Airliner.AMaintenanceInterval;
            this.BMaintenanceInterval = this.Airliner.BMaintenanceInterval;
            this.CMaintenanceInterval = this.Airliner.CMaintenanceInterval;
            this.DMaintenanceInterval = this.Airliner.DMaintenanceInterval;

            this.SchedCMaintenance = this.Airliner.SchedCMaintenance;
            this.SchedDMaintenance = this.Airliner.SchedDMaintenance;
        }
Ejemplo n.º 8
0
        public AirlinerFacilityMVVM(AirlinerFacility.FacilityType type,AirlinerClassMVVM airlinerClass)
        {
            this.Facilities = new ObservableCollection<AirlinerFacility>();

            this.AirlinerClass = airlinerClass;
            this.Type = type;
        }
        public AirlinerFacilityMVVM(AirlinerFacility.FacilityType type,AirlinerClassMVVM airlinerClass)
        {
            this.Facilities = new List<AirlinerFacility>();

            this.AirlinerClass = airlinerClass;
            this.Type = type;
        }
Ejemplo n.º 10
0
        public FleetAirlinerMVVM(FleetAirliner airliner)
        {
            this.Airliner = airliner;
            this.Homebase = this.Airliner.Homebase;
            this.Classes  = new ObservableCollection <AirlinerClassMVVM>();

            AirlinerClass tClass;

            if (this.Airliner.Airliner.Classes.Count == 0)
            {
                tClass = null;
            }
            else
            {
                tClass = this.Airliner.Airliner.Classes[0];
            }

            foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
            {
                int maxCapacity;

                if (airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger)
                {
                    maxCapacity = ((AirlinerPassengerType)airliner.Airliner.Type).MaxSeatingCapacity;
                }
                else
                {
                    maxCapacity = tClass.RegularSeatingCapacity;
                }

                Boolean changeable = this.Airliner.Airliner.Classes.IndexOf(aClass) > 0;

                int maxSeats;

                if (this.Airliner.Airliner.Classes.Count == 3)
                {
                    if (this.Airliner.Airliner.Classes.IndexOf(aClass) == 1)
                    {
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[2].RegularSeatingCapacity;
                    }
                    else
                    {
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[1].RegularSeatingCapacity;
                    }
                }
                else
                {
                    maxSeats = maxCapacity - 1;
                }


                AirlinerClassMVVM amClass = new AirlinerClassMVVM(aClass, aClass.SeatingCapacity, aClass.RegularSeatingCapacity, maxSeats, changeable);
                this.Classes.Add(amClass);
            }

            this.Pilots = new ObservableCollection <Pilot>();

            foreach (Pilot pilot in this.Airliner.Pilots)
            {
                this.Pilots.Add(pilot);
            }

            this.IsMissingPilots = this.Airliner.Airliner.Type.CockpitCrew > this.Pilots.Count;

            this.AMaintenanceInterval = this.Airliner.AMaintenanceInterval;
            this.BMaintenanceInterval = this.Airliner.BMaintenanceInterval;
            this.CMaintenanceInterval = this.Airliner.CMaintenanceInterval;
            this.DMaintenanceInterval = this.Airliner.DMaintenanceInterval;

            this.SchedCMaintenance = this.Airliner.SchedCMaintenance;
            this.SchedDMaintenance = this.Airliner.SchedDMaintenance;

            this.IsBuyable     = this.Airliner.Airliner.Airline.IsHuman && this.Airliner.Purchased == FleetAirliner.PurchasedType.Leased;
            this.IsConvertable = this.Airliner.Airliner.Airline.IsHuman && this.Airliner.Status == FleetAirliner.AirlinerStatus.Stopped && !this.Airliner.HasRoute && this.Airliner.Purchased == FleetAirliner.PurchasedType.Bought && this.Airliner.Airliner.Type.IsConvertable;
        }
Ejemplo n.º 11
0
        public FleetAirlinerMVVM(FleetAirliner airliner)
        {
            this.Airliner = airliner;
            this.Homebase = this.Airliner.Homebase;
            this.Classes = new ObservableCollection<AirlinerClassMVVM>();

            AirlinerClass tClass;

            if (this.Airliner.Airliner.Classes.Count == 0)
                tClass = null;
            else
                tClass = this.Airliner.Airliner.Classes[0];

            foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
            {
                int maxCapacity;

                if (airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger)
                    maxCapacity = ((AirlinerPassengerType)airliner.Airliner.Type).MaxSeatingCapacity;
                else
                    maxCapacity = tClass.RegularSeatingCapacity;

                Boolean changeable = this.Airliner.Airliner.Classes.IndexOf(aClass) > 0;

                int maxSeats;

                if (this.Airliner.Airliner.Classes.Count == 3)
                {
                    if (this.Airliner.Airliner.Classes.IndexOf(aClass) == 1)
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[2].RegularSeatingCapacity;
                    else
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[1].RegularSeatingCapacity;
                }
                else
                    maxSeats =maxCapacity -1;

                AirlinerClassMVVM amClass = new AirlinerClassMVVM(aClass, aClass.SeatingCapacity, aClass.RegularSeatingCapacity, maxSeats, changeable);
                this.Classes.Add(amClass);
            }

            this.Pilots = new ObservableCollection<Pilot>();

            foreach (Pilot pilot in this.Airliner.Pilots)
                this.Pilots.Add(pilot);

            this.IsMissingPilots = this.Airliner.Airliner.Type.CockpitCrew > this.Pilots.Count;

            this.AMaintenanceInterval = this.Airliner.AMaintenanceInterval;
            this.BMaintenanceInterval = this.Airliner.BMaintenanceInterval;
            this.CMaintenanceInterval = this.Airliner.CMaintenanceInterval;
            this.DMaintenanceInterval = this.Airliner.DMaintenanceInterval;

            this.SchedCMaintenance = this.Airliner.SchedCMaintenance;
            this.SchedDMaintenance = this.Airliner.SchedDMaintenance;

            this.IsBuyable = this.Airliner.Airliner.Airline.IsHuman && this.Airliner.Purchased == FleetAirliner.PurchasedType.Leased;
            this.IsConvertable = this.Airliner.Airliner.Airline.IsHuman && this.Airliner.Status == FleetAirliner.AirlinerStatus.Stopped && !this.Airliner.HasRoute && this.Airliner.Purchased == FleetAirliner.PurchasedType.Bought && this.Airliner.Airliner.Type.IsConvertable;
        }
        private void btnAddClass_Click(object sender, RoutedEventArgs e)
        {
            ComboBox cbClasses = new ComboBox();

            cbClasses.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbClasses.ItemTemplate        = this.Resources["AirlinerClassItem"] as DataTemplate;
            cbClasses.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbClasses.Width = 200;

            foreach (AirlinerClass.ClassType type in Enum.GetValues(typeof(AirlinerClass.ClassType)))
            {
                Boolean hasClass = this.Airliner.Classes.ToList().Exists(c => c.Type == type);
                if ((int)type <= GameObject.GetInstance().GameTime.Year&& !hasClass)
                {
                    cbClasses.Items.Add(type);
                }
            }

            cbClasses.SelectedIndex = 0;

            AirlinerClassMVVM tClass = this.Airliner.Classes[0];

            if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PageFleetAirlinerInformation", "1011"), cbClasses) == PopUpSingleElement.ButtonSelected.OK && cbClasses.SelectedItem != null)
            {
                int maxseats;

                int maxCapacity;

                if (this.Airliner.Airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger)
                {
                    maxCapacity = ((AirlinerPassengerType)this.Airliner.Airliner.Airliner.Type).MaxSeatingCapacity;
                }
                else
                {
                    maxCapacity = tClass.RegularSeatingCapacity;
                }

                if (this.Airliner.Classes.Count == 2)
                {
                    maxseats = maxCapacity - 1 - this.Airliner.Classes[1].RegularSeatingCapacity;
                }
                else
                {
                    maxseats = maxCapacity - 1;
                }


                AirlinerClassMVVM aClass = new AirlinerClassMVVM(new AirlinerClass((AirlinerClass.ClassType)cbClasses.SelectedItem, 0), 1, 1, maxseats, true);

                foreach (AirlinerFacilityMVVM aFacility in aClass.Facilities)
                {
                    var facility = AirlinerFacilities.GetBasicFacility(aFacility.Type);
                    aFacility.SelectedFacility = facility;
                }

                this.Airliner.Classes.Add(aClass);

                tClass.RegularSeatingCapacity -= aClass.RegularSeatingCapacity;

                tClass.Seating = Convert.ToInt16(Convert.ToDouble(tClass.RegularSeatingCapacity) / tClass.Facilities.Where(f => f.Type == AirlinerFacility.FacilityType.Seat).First().SelectedFacility.SeatUses);
            }
        }
        public FleetAirlinerMVVM(FleetAirliner airliner)
        {
            Airliner = airliner;
            Homebase = Airliner.Homebase;
            Classes = new ObservableCollection<AirlinerClassMVVM>();
            Owner = (Airliner.Airliner.Owner != null && Airliner.Airliner.Airline != Airliner.Airliner.Owner) ? Airliner.Airliner.Owner : null;

            AirlinerClass tClass;

            if (Airliner.Airliner.Classes.Count == 0)
            {
                tClass = null;
            }
            else
            {
                tClass = Airliner.Airliner.Classes[0];
            }

            foreach (AirlinerClass aClass in Airliner.Airliner.Classes)
            {
                int maxCapacity;

                if (airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger)
                {
                    maxCapacity = ((AirlinerPassengerType)airliner.Airliner.Type).MaxSeatingCapacity;
                }
                else
                {
                    maxCapacity = tClass.RegularSeatingCapacity;
                }

                Boolean changeable = Airliner.Airliner.Classes.IndexOf(aClass) > 0;

                int maxSeats;

                if (Airliner.Airliner.Classes.Count == 3)
                {
                    if (Airliner.Airliner.Classes.IndexOf(aClass) == 1)
                    {
                        maxSeats = maxCapacity - 1 - Airliner.Airliner.Classes[2].RegularSeatingCapacity;
                    }
                    else
                    {
                        maxSeats = maxCapacity - 1 - Airliner.Airliner.Classes[1].RegularSeatingCapacity;
                    }
                }
                else
                {
                    maxSeats = maxCapacity - 1;
                }

                var amClass = new AirlinerClassMVVM(
                    aClass,
                    aClass.SeatingCapacity,
                    aClass.RegularSeatingCapacity,
                    maxSeats,
                    changeable);
                Classes.Add(amClass);
            }

            Pilots = new ObservableCollection<Pilot>();

            foreach (Pilot pilot in Airliner.Pilots)
            {
                Pilots.Add(pilot);
            }

            IsMissingPilots = Airliner.Airliner.Type.CockpitCrew > Pilots.Count;

            AMaintenanceInterval = Airliner.AMaintenanceInterval;
            BMaintenanceInterval = Airliner.BMaintenanceInterval;
            CMaintenanceInterval = Airliner.CMaintenanceInterval;
            DMaintenanceInterval = Airliner.DMaintenanceInterval;

            SchedCMaintenance = Airliner.SchedCMaintenance;
            SchedDMaintenance = Airliner.SchedDMaintenance;

            IsBuyable = Airliner.Airliner.Airline.IsHuman
                             && Airliner.Purchased == FleetAirliner.PurchasedType.Leased && Airliner.Airliner.Owner == null;
            IsConvertable = Airliner.Airliner.Airline.IsHuman
                                 && Airliner.Status == FleetAirliner.AirlinerStatus.Stopped
                                 && !Airliner.HasRoute
                                 && (Airliner.Airliner.Owner!=null || Airliner.Airliner.Airline.isHuman())
                                 && Airliner.Purchased == FleetAirliner.PurchasedType.Bought
                                 && Airliner.Airliner.Type.IsConvertable;

            IsOutleasable = Airliner.Airliner.Airline.IsHuman
                && Airliner.Purchased == FleetAirliner.PurchasedType.Bought
                && Airliner.Status == FleetAirliner.AirlinerStatus.Stopped
                && !Airliner.HasRoute;
        }
        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;
            }
        }