Наследование: INotifyPropertyChanged
        public PopUpAirlinerSeatsConfiguration(AirlinerType type, List <AirlinerClass> classes)
        {
            this.FreeClassTypes = new ObservableCollection <AirlinerClass.ClassType>();
            this.Classes        = new ObservableCollection <AirlinerClassMVVM>();
            this.Type           = type;

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

            foreach (AirlinerClass aClass in classes)
            {
                int maxseats             = aClass.Type == AirlinerClass.ClassType.Economy_Class ? aClass.SeatingCapacity : economyClass.RegularSeatingCapacity - 1;
                AirlinerClassMVVM nClass = new AirlinerClassMVVM(aClass.Type, aClass.SeatingCapacity, maxseats, aClass.Type != AirlinerClass.ClassType.Economy_Class);
                this.Classes.Add(nClass);

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

            this.CanAddNewClass = this.Classes.Count < ((AirlinerPassengerType)this.Type).MaxAirlinerClasses;

            if (this.Classes.Count < 3)
            {
                this.FreeClassTypes.Clear();
                this.FreeClassTypes.Add(AirlinerClass.ClassType.Business_Class);
                this.FreeClassTypes.Add(AirlinerClass.ClassType.First_Class);
            }

            InitializeComponent();
        }
Пример #2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            AirlinerClassMVVM aClass = (AirlinerClassMVVM)((Button)sender).Tag;

            this.Classes.Remove(aClass);

            this.Classes.Remove(aClass);

            this.Classes[0].RegularSeating += aClass.RegularSeating;
            this.Classes[0].Seating        += aClass.RegularSeating;

            this.CanAddNewClass = true;

            this.FreeClassTypes.Clear();

            this.FreeClassTypes.Add(AirlinerClass.ClassType.Business_Class);
            this.FreeClassTypes.Add(AirlinerClass.ClassType.First_Class);
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            int seating = Math.Min(5, this.Classes[0].Seating - 1);


            // chs, 2011-11-10 added so seat capacity is correctly calculated
            this.Classes[0].Seating        -= seating;
            this.Classes[0].RegularSeating -= seating;
            this.Classes[0].MaxSeats       -= seating;

            AirlinerClass.ClassType nextType = AirlinerClass.ClassType.Economy_Class;

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

            int maxseats = this.Classes[0].RegularSeating - 1;

            AirlinerClassMVVM newClass = new AirlinerClassMVVM(nextType, seating, maxseats, true);

            this.Classes.Add(newClass);

            this.CanAddNewClass = this.Classes.Count < ((AirlinerPassengerType)this.Type).MaxAirlinerClasses;

            if (this.Classes.Count < 3)
            {
                this.FreeClassTypes.Clear();
                this.FreeClassTypes.Add(AirlinerClass.ClassType.Business_Class);
                this.FreeClassTypes.Add(AirlinerClass.ClassType.First_Class);
            }
            else
            {
                this.FreeClassTypes.Clear();
            }
        }
        private void slSeats_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            AirlinerClassMVVM aClass = (AirlinerClassMVVM)((Slider)sender).Tag;

            if (aClass.Type != AirlinerClass.ClassType.Economy_Class)
            {
                int diff = (int)(e.NewValue - e.OldValue);
                this.Classes[0].RegularSeating -= diff;
                this.Classes[0].Seating        -= diff;

                if (this.Classes.Count == 3)
                {
                    if (this.Classes[1] == aClass)
                    {
                        this.Classes[2].MaxSeats -= diff;
                    }
                    else
                    {
                        this.Classes[1].MaxSeats -= diff;
                    }
                }
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            int seating = Math.Min(5, this.Classes[0].Seating - 1);

            // chs, 2011-11-10 added so seat capacity is correctly calculated
            this.Classes[0].Seating -= seating;
            this.Classes[0].RegularSeating -= seating;

            AirlinerClass.ClassType nextType = AirlinerClass.ClassType.Economy_Class;

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

            int maxseats = this.Classes[0].RegularSeating - 1;

            AirlinerClassMVVM newClass = new AirlinerClassMVVM(nextType, seating,maxseats, true);
            this.Classes.Add(newClass);

            this.CanAddNewClass = this.Classes.Count < ((AirlinerPassengerType)this.Type).MaxAirlinerClasses;

            if (this.Classes.Count < 3)
            {
                this.FreeClassTypes.Clear();
                this.FreeClassTypes.Add(AirlinerClass.ClassType.Business_Class);
                this.FreeClassTypes.Add(AirlinerClass.ClassType.First_Class);

            }
            else
                this.FreeClassTypes.Clear();
        }
        public PopUpAirlinerSeatsConfiguration(AirlinerType type, List<AirlinerClass> classes)
        {
            this.FreeClassTypes = new ObservableCollection<AirlinerClass.ClassType>();
            this.Classes = new ObservableCollection<AirlinerClassMVVM>();
            this.Type = type;

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

            foreach (AirlinerClass aClass in classes)
            {

                int maxseats = aClass.Type == AirlinerClass.ClassType.Economy_Class ? aClass.SeatingCapacity : economyClass.RegularSeatingCapacity - 1;
                AirlinerClassMVVM nClass = new AirlinerClassMVVM(aClass.Type, aClass.SeatingCapacity,maxseats, aClass.Type != AirlinerClass.ClassType.Economy_Class);
                this.Classes.Add(nClass);

                foreach (AirlinerFacility facility in aClass.getFacilities())
                    nClass.Facilities.Where(f=>f.Type == facility.Type).First().SelectedFacility = facility;

            }

            this.CanAddNewClass = this.Classes.Count < ((AirlinerPassengerType)this.Type).MaxAirlinerClasses;

            if (this.Classes.Count < 3)
            {
                this.FreeClassTypes.Clear();
                this.FreeClassTypes.Add(AirlinerClass.ClassType.Business_Class);
                this.FreeClassTypes.Add(AirlinerClass.ClassType.First_Class);

            }

            InitializeComponent();
        }
 public AirlinerClassFacilityMVVM(AirlinerClassMVVM aClass, AirlinerFacility.FacilityType type)
 {
     this.Type = type;
     this.Facilities = new List<AirlinerFacility>();
     this.AClass = aClass;
 }
        public PopUpAirlinerSeatsConfiguration(AirlinerType type, List<AirlinerClass> classes, EngineType engine)
        {
            this.FreeClassTypes = new ObservableCollection<AirlinerClass.ClassType>();
            this.Classes = new ObservableCollection<AirlinerClassMVVM>();
            this.Type = type;
            this.Engines = new List<EngineType>();

            foreach (EngineType e in EngineTypes.GetEngineTypes(type, GameObject.GetInstance().GameTime.Year).OrderBy(t => t.Price))
                this.Engines.Add(e);

            if (this.Engines.Count > 0)
                this.SelectedEngine = engine;

            AirlinerClass economyClass = classes.Find(c => c.Type == AirlinerClass.ClassType.EconomyClass);

            foreach (AirlinerClass aClass in classes)
            {

                int maxseats = aClass.Type == AirlinerClass.ClassType.EconomyClass ? aClass.SeatingCapacity : economyClass.RegularSeatingCapacity - 1;
                AirlinerClassMVVM nClass = new AirlinerClassMVVM(aClass.Type, aClass.SeatingCapacity, maxseats, aClass.Type != AirlinerClass.ClassType.EconomyClass);
                this.Classes.Add(nClass);

                foreach (AirlinerFacility facility in aClass.GetFacilities())
                    nClass.Facilities.Where(f => f.Type == facility.Type).First().SelectedFacility = facility;

            }

            this.CanAddNewClass = this.Classes.Count < ((AirlinerPassengerType)this.Type).MaxAirlinerClasses;

            if (this.Classes.Count < 3)
            {
                this.FreeClassTypes.Clear();
                this.FreeClassTypes.Add(AirlinerClass.ClassType.BusinessClass);
                this.FreeClassTypes.Add(AirlinerClass.ClassType.FirstClass);

            }

            this.Loaded += PopUpAirlinerSeatsConfiguration_Loaded;

            InitializeComponent();
        }