public PopUpAirlinerFacility(AirlinerClass airlinerClass, AirlinerFacility.FacilityType type)
        {
            InitializeComponent();

            this.AirlinerClass = airlinerClass;
            this.Type = type;

            this.Title = "Select " + type.ToString().ToLower();

            this.Width = 400;

            this.Height = 120;

            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            StackPanel mainPanel = new StackPanel();
            mainPanel.Margin = new Thickness(10, 10, 10, 10);

            cbFacility = new ComboBox();
            cbFacility.ItemTemplate = this.Resources["AirlinerFacilityItem"] as DataTemplate;
            cbFacility.SetResourceReference(StyleProperty, "ComboBoxTransparentStyle");

            foreach (AirlinerFacility facility in AirlinerFacilities.GetFacilities(this.Type,GameObject.GetInstance().GameTime.Year))
                cbFacility.Items.Add(facility);

            cbFacility.SelectedItem = this.AirlinerClass.GetFacility(this.Type);

            mainPanel.Children.Add(cbFacility);

            mainPanel.Children.Add(createButtonsPanel());

            this.Content = mainPanel;
               // int serviceLevel, double percentOfSeats, double pricePerSeat
        }
        public static object ShowPopUp(AirlinerClass airlinerClass, AirlinerFacility.FacilityType type)
        {
            PopUpWindow window = new PopUpAirlinerFacility(airlinerClass, type);

            window.ShowDialog();

            return window.Selected == null ? null : window.Selected;
        }
 //returns the list of facilities for a specific type
 public static List<AirlinerFacility> GetFacilities(AirlinerFacility.FacilityType type)
 {
     if (Facilities.ContainsKey(type))
     {
         return Facilities[type];
     }
     return new List<AirlinerFacility>();
 }
        public static void AddFacility(AirlinerFacility facility)
        {
            if (!Facilities.ContainsKey(facility.Type))
            {
                Facilities.Add(facility.Type, new List<AirlinerFacility>());
            }

            Facilities[facility.Type].Add(facility);
        }
 public AirlinerFacilityItem( AirlinerClass aClass, AirlinerFacility facility)
 {
     this.AirlinerClass = aClass;
     this.Facility = facility;
 }
 //returns the facility of a specific type
 public AirlinerFacility GetFacility(AirlinerFacility.FacilityType type)
 {
     return Facilities.Find(f => f.Type == type);
 }
 //adds a facility to the configuration
 public void AddFacility(AirlinerFacility facility)
 {
     Facilities.Add(facility);
 }
 public AirlinerClassFacilityMVVM(AirlinerClassMVVM aClass, AirlinerFacility.FacilityType type)
 {
     this.Type = type;
     this.Facilities = new List<AirlinerFacility>();
     this.AClass = aClass;
 }
 private void setSeating(AirlinerFacility oldValue)
 {
     if (Type == AirlinerFacility.FacilityType.Seat && _selectedFacility != null && oldValue != null)
     {
         AirlinerClass.ChangedFacility = true;
         double diff = oldValue.SeatUses / _selectedFacility.SeatUses;
         AirlinerClass.Seating = Convert.ToInt16(Convert.ToDouble(AirlinerClass.Seating) * diff);
         AirlinerClass.MaxSeats = Convert.ToInt16(Convert.ToDouble(AirlinerClass.MaxSeats) * diff);
         AirlinerClass.ChangedFacility = false;
     }
 }
        public AirlinerFacilityMVVM(AirlinerFacility.FacilityType type, AirlinerClassMVVM airlinerClass)
        {
            Facilities = new ObservableCollection<AirlinerFacility>();

            AirlinerClass = airlinerClass;
            Type = type;
        }
 // chs, 2011-13-10 added function to return a specific airliner facility
 //returns a facility based on name and type
 public static AirlinerFacility GetFacility(AirlinerFacility.FacilityType type, string uid)
 {
     return GetFacilities(type).Count > 0 ? GetFacilities(type).Find((f => f.Uid == uid)) : null;
 }
 //returns the list of facilities for a specific type after a specific year
 public static List<AirlinerFacility> GetFacilities(AirlinerFacility.FacilityType type, int year)
 {
     return Facilities.ContainsKey(type) ? Facilities[type].FindAll((f => f.FromYear <= year)) : new List<AirlinerFacility>();
 }
 public static AirlinerFacility GetBasicFacility(AirlinerFacility.FacilityType type)
 {
     return Facilities[type][0];
 }
        public void SetFacility(Airline airline, AirlinerFacility facility)
        {
            Facilities[facility.Type] = facility;

            if (airline != null)
            {
                AirlineHelpers.AddAirlineInvoice(
                    airline,
                    GameObject.GetInstance().GameTime,
                    Invoice.InvoiceType.Purchases,
                    -facility.PricePerSeat*facility.PercentOfSeats/100.0*SeatingCapacity);
            }
        }
 public AirlinerFacility GetFacility(AirlinerFacility.FacilityType type)
 {
     if (Facilities.ContainsKey(type))
     {
         return Facilities[type];
     }
     return null;
 }
 public void ForceSetFacility(AirlinerFacility facility)
 {
     Facilities[facility.Type] = facility;
 }