Ejemplo n.º 1
0
        public PageRoutePlanner(FleetAirliner airliner)
        {
            this.ShowSeason = Weather.Season.All_Year;

            this.Airliner = airliner;
            this.Entries = new ObservableCollection<RouteTimeTableEntry>();
            this.Entries.CollectionChanged += Entries_CollectionChanged;

            this.ViewEntries = new ObservableCollection<RouteTimeTableEntry>();
            this.ViewEntries.CollectionChanged += ViewEntries_CollectionChanged;

            this.IsLongRoute = false;

            this.AllRoutes = new List<RoutePlannerItemMVVM>();
            this.Intervals = new ObservableCollection<int>() { 1, 2, 3, 4, 5, 6 };

            this.Routes = new ObservableCollection<Route>();

            Route.RouteType routeType = (Route.RouteType)Enum.Parse(typeof(Route.RouteType),this.Airliner.Airliner.Type.TypeAirliner.ToString(), true); ;

            foreach (Route route in this.Airliner.Airliner.Airline.Routes.Where(r => r.getDistance() <= this.Airliner.Airliner.Type.Range && r.Type == routeType))
                this.Routes.Add(route);

            this.AllRegions = new List<Region>();
            this.AllRegions.Add(Regions.GetRegion("100"));

            var routeRegions = this.Routes.Select(r => r.Destination1.Profile.Country.Region).ToList();
            routeRegions.AddRange(this.Routes.Select(r => r.Destination2.Profile.Country.Region));

            foreach (Region region in routeRegions.Distinct())
                this.AllRegions.Add(region);

            foreach (Route route in this.Airliner.Airliner.Airline.Routes.Where(r=>r.getDistance()<= this.Airliner.Airliner.Type.Range && r.Type == routeType))
                this.AllRoutes.Add(new RoutePlannerItemMVVM(route, this.Airliner.Airliner.Type));

            this.OutboundAirports = new List<Airport>();
            var routeAirports = this.Routes.Select(r => r.Destination1).ToList();
            routeAirports.AddRange(this.Routes.Select(r => r.Destination2));

            foreach (Airport airport in routeAirports.Distinct())
                this.OutboundAirports.Add(airport);

            this.StartTimes = new ObservableCollection<TimeSpan>();

            for (int i = 0; i < 20; i++)
                this.StartTimes.Add(new TimeSpan(6, i * 15, 0));

            this.StopoverMinutes = new List<int>() { 45, 60, 75, 90, 105, 120 };

            setCanTransferSchedule();

            this.Loaded += PageRoutePlanner_Loaded;

            InitializeComponent();
        }
Ejemplo n.º 2
0
        //returns all entries for a specific day
        public List <RouteTimeTableEntry> getEntries(DayOfWeek day, Boolean useSeason = true)
        {
            Weather.Season season = GeneralHelpers.GetSeason(GameObject.GetInstance().GameTime);

            if (useSeason)
            {
                return(this.Entries.FindAll(e => e.Day == day && (e.TimeTable.Route.Season == Weather.Season.All_Year || e.TimeTable.Route.Season == season)));
            }
            else
            {
                return(this.Entries.FindAll(e => e.Day == day));
            }
        }
Ejemplo n.º 3
0
        private void rbSeason_Checked(object sender, RoutedEventArgs e)
        {
            string season = (string)((RadioButton)sender).Tag;

            if (season == "Winter")
            {
                this.ShowSeason = Weather.Season.Winter;
            }

            if (season == "Summer")
            {
                this.ShowSeason = Weather.Season.Summer;
            }

            if (season == "AllYear")
            {
                this.ShowSeason = Weather.Season.All_Year;
            }

            setViewEntries();
        }
Ejemplo n.º 4
0
        public PageRoutePlanner(FleetAirliner airliner)
        {
            this.ShowSeason = Weather.Season.All_Year;

            this.Airliner = airliner;
            this.Entries  = new ObservableCollection <RouteTimeTableEntry>();
            this.Entries.CollectionChanged += Entries_CollectionChanged;

            this.ViewEntries = new ObservableCollection <RouteTimeTableEntry>();
            this.ViewEntries.CollectionChanged += ViewEntries_CollectionChanged;

            this.IsLongRoute = false;

            this.AllRoutes = new List <RoutePlannerItemMVVM>();
            this.Intervals = new ObservableCollection <int>()
            {
                1, 2, 3, 4, 5, 6
            };

            this.Routes = new ObservableCollection <Route>();

            Route.RouteType routeType = (Route.RouteType)Enum.Parse(typeof(Route.RouteType), this.Airliner.Airliner.Type.TypeAirliner.ToString(), true);;

            foreach (Route route in this.Airliner.Airliner.Airline.Routes.Where(r => r.getDistance() <= this.Airliner.Airliner.Type.Range && r.Type == routeType))
            {
                this.Routes.Add(route);
            }

            this.AllRegions = new List <Region>();
            this.AllRegions.Add(Regions.GetRegion("100"));

            var routeRegions = this.Routes.Select(r => r.Destination1.Profile.Country.Region).ToList();

            routeRegions.AddRange(this.Routes.Select(r => r.Destination2.Profile.Country.Region));

            foreach (Region region in routeRegions.Distinct())
            {
                this.AllRegions.Add(region);
            }

            foreach (Route route in this.Airliner.Airliner.Airline.Routes.Where(r => r.getDistance() <= this.Airliner.Airliner.Type.Range && r.Type == routeType))
            {
                this.AllRoutes.Add(new RoutePlannerItemMVVM(route, this.Airliner.Airliner.Type));
            }

            this.OutboundAirports = new List <Airport>();
            var routeAirports = this.Routes.Select(r => r.Destination1).ToList();

            routeAirports.AddRange(this.Routes.Select(r => r.Destination2));

            foreach (Airport airport in routeAirports.Distinct())
            {
                this.OutboundAirports.Add(airport);
            }

            this.StartTimes = new ObservableCollection <TimeSpan>();

            for (int i = 0; i < 20; i++)
            {
                this.StartTimes.Add(new TimeSpan(6, i * 15, 0));
            }

            this.StopoverMinutes = new List <int>()
            {
                45, 60, 75, 90, 105, 120
            };

            setCanTransferSchedule();

            this.Loaded += PageRoutePlanner_Loaded;

            InitializeComponent();
        }
        public PageRoutePlanner(FleetAirliner airliner)
        {
            ShowSeason = Weather.Season.AllYear;

            Airliner = airliner;
            Entries = new ObservableCollection<RouteTimeTableEntry>();
            Entries.CollectionChanged += Entries_CollectionChanged;

            ViewEntries = new ObservableCollection<RouteTimeTableEntry>();
            ViewEntries.CollectionChanged += ViewEntries_CollectionChanged;

            IsLongRoute = false;

            AllRoutes = new List<RoutePlannerItemMVVM>();
            Intervals = new ObservableCollection<int> { 1, 2, 3, 4, 5, 6 };

            Routes = new ObservableCollection<Route>();

            var routeType =
                (Route.RouteType)
                    Enum.Parse(typeof(Route.RouteType), Airliner.Airliner.Type.TypeAirliner.ToString(), true);
            ;

            foreach (
                Route route in
                    Airliner.Airliner.Airline.Routes.Where(
                        r => r.GetDistance() <= Airliner.Airliner.Range && r.Type == routeType))
            {
                Routes.Add(route);
            }

            AllRegions = new List<Region>();
            AllRegions.Add(Regions.GetRegion("100"));

            List<Region> routeRegions = Routes.Select(r => r.Destination1.Profile.Country.Region).ToList();
            routeRegions.AddRange(Routes.Select(r => r.Destination2.Profile.Country.Region));

            foreach (Region region in routeRegions.Distinct())
            {
                AllRegions.Add(region);
            }

            foreach (
                Route route in
                    Airliner.Airliner.Airline.Routes.Where(
                        r => r.GetDistance() <= Airliner.Airliner.Range && r.Type == routeType))
            {
                AllRoutes.Add(new RoutePlannerItemMVVM(route, Airliner.Airliner.Type));
            }

            OutboundAirports = new List<Airport>();
            List<Airport> routeAirports = Routes.Select(r => r.Destination1).ToList();
            routeAirports.AddRange(Routes.Select(r => r.Destination2));

            foreach (Airport airport in routeAirports.Distinct())
            {
                OutboundAirports.Add(airport);
            }

            StartTimes = new ObservableCollection<TimeSpan>();

            for (int i = 0; i < 20; i++)
            {
                StartTimes.Add(new TimeSpan(6, i * 15, 0));
            }

            StopoverMinutes = new List<int> { 45, 60, 75, 90, 105, 120 };

            setCanTransferSchedule();

            SpecialContractRoutes = new List<Route>();

            var humanSpecialRoutes = GameObject.GetInstance().HumanAirline.SpecialContracts.Where(s => !s.Type.IsFixedDate).SelectMany(s => s.Routes.Where(r=>!r.HasAirliner));

            foreach (Route sRoute in humanSpecialRoutes)
                SpecialContractRoutes.Add(sRoute);

            Loaded += PageRoutePlanner_Loaded;

            InitializeComponent();
        }
        //adds entries to the planner
        private void rbSeason_Checked(object sender, RoutedEventArgs e)
        {
            var season = (string)((RadioButton)sender).Tag;

            if (season == "Winter")
            {
                ShowSeason = Weather.Season.Winter;
            }

            if (season == "Summer")
            {
                ShowSeason = Weather.Season.Summer;
            }

            if (season == "AllYear")
            {
                ShowSeason = Weather.Season.AllYear;
            }

            setViewEntries();
        }
Ejemplo n.º 7
0
        public AirportProfile(string name, string code, string icaocode, AirportType type, Period <DateTime> period, Town town, TimeSpan offsetGMT, TimeSpan offsetDST, Coordinates coordinates, GeneralHelpers.Size cargo, double cargovolume, Weather.Season season)
        {
            this.PaxValues = new List <PaxValue>();

            this.Name               = name;
            this.Period             = period;
            this.IATACode           = code;
            this.ICAOCode           = icaocode;
            this.Type               = type;
            this.Town               = town;
            this.Coordinates        = coordinates;
            this.CargoVolume        = cargovolume;
            this.MajorDestionations = new Dictionary <string, int>();
            this.Cargo              = cargo;
            this.Logo               = "";
            this.OffsetDST          = offsetDST;
            this.OffsetGMT          = offsetGMT;
            this.Season             = season;
            this.ID = string.Format("{0:00}-{1:00}-{2:00}-{3:00}-{4:00}-{5:00}", char.ConvertToUtf32(this.IATACode, 0), char.ConvertToUtf32(this.IATACode, 1), char.ConvertToUtf32(this.IATACode, 2), name.Length, char.ConvertToUtf32(this.Name, this.Name.Length / 2), (int)this.Cargo);
        }
Ejemplo n.º 8
0
        //returns if an airline has enough free slots at an airport
        public static Boolean CanFillRoutesEntries(Airport airport, Airline airline, List <AirportContract> contracts, Weather.Season season)
        {
            int numberOfOccupiedSlots = GetOccupiedSlotTimes(airport, airline, contracts, season).GroupBy(s => s.Ticks).Where(x => x.Count() > 1).Count();

            return(numberOfOccupiedSlots == 0);
        }
Ejemplo n.º 9
0
 public static List <TimeSpan> GetOccupiedSlotTimes(Airport airport, Airline airline, Weather.Season season)
 {
     return(GetOccupiedSlotTimes(airport, airline, airport.AirlineContracts.Where(c => c.Airline == airline).ToList(), season));
 }
Ejemplo n.º 10
0
        //returns all occupied slot times for an airline at an airport (15 minutes slots)
        public static List <TimeSpan> GetOccupiedSlotTimes(Airport airport, Airline airline, List <AirportContract> contracts, Weather.Season season)
        {
            List <KeyValuePair <Route, TimeSpan> > occupiedSlots = new List <KeyValuePair <Route, TimeSpan> >();

            TimeSpan gateTimeBefore = new TimeSpan(0, 15, 0);
            TimeSpan gateTimeAfter  = new TimeSpan(0, 15, 0);

            int gates = contracts.Sum(c => c.NumberOfGates);

            var routes = new List <Route>(GetAirportRoutes(airport, airline));

            var entries = new List <RouteTimeTableEntry>(routes.Where(r => season == Weather.Season.All_Year || season == r.Season).SelectMany(r => r.TimeTable.Entries));


            foreach (var entry in entries)
            {
                TimeSpan entryTakeoffTime = new TimeSpan((int)entry.Day, entry.Time.Hours, entry.Time.Minutes, entry.Time.Seconds);
                TimeSpan entryLandingTime = entryTakeoffTime.Add(entry.TimeTable.Route.getFlightTime(entry.Airliner.Airliner.Type));

                if (entryLandingTime.Days > 6)
                {
                    entryLandingTime = new TimeSpan(0, entryLandingTime.Hours, entryLandingTime.Minutes, entryLandingTime.Seconds);
                }

                if (entry.DepartureAirport == airport)
                {
                    TimeSpan entryStartTakeoffTime = entryTakeoffTime.Subtract(gateTimeBefore);
                    TimeSpan entryEndTakeoffTime   = entryTakeoffTime.Add(gateTimeAfter);

                    TimeSpan tTakeoffTime = new TimeSpan(entryStartTakeoffTime.Days, entryStartTakeoffTime.Hours, (entryStartTakeoffTime.Minutes / 15) * 15, 0);

                    while (tTakeoffTime < entryEndTakeoffTime)
                    {
                        if (!occupiedSlots.Exists(s => s.Key == entry.TimeTable.Route && s.Value == tTakeoffTime))
                        {
                            occupiedSlots.Add(new KeyValuePair <Route, TimeSpan>(entry.TimeTable.Route, tTakeoffTime));
                        }
                        tTakeoffTime = tTakeoffTime.Add(new TimeSpan(0, 15, 0));
                    }
                }

                if (entry.DepartureAirport != airport)
                {
                    TimeSpan entryStartLandingTime = entryLandingTime.Subtract(gateTimeBefore);
                    TimeSpan entryEndLandingTime   = entryLandingTime.Add(gateTimeAfter);

                    TimeSpan tLandingTime = new TimeSpan(entryStartLandingTime.Days, entryStartLandingTime.Hours, (entryStartLandingTime.Minutes / 15) * 15, 0);

                    while (tLandingTime < entryEndLandingTime)
                    {
                        if (!occupiedSlots.Exists(s => s.Key == entry.TimeTable.Route && s.Value == tLandingTime))
                        {
                            occupiedSlots.Add(new KeyValuePair <Route, TimeSpan>(entry.TimeTable.Route, tLandingTime));
                        }
                        tLandingTime = tLandingTime.Add(new TimeSpan(0, 15, 0));
                    }
                }
            }

            var slots = (from s in occupiedSlots
                         group s.Value by s.Value into g
                         select new { Time = g.Key, Slots = g });

            return(slots.Where(s => s.Slots.Count() >= gates).SelectMany(s => s.Slots).ToList());
        }
Ejemplo n.º 11
0
        //creates a route and returns if success
        private Boolean createRoute()
        {
            Route    route        = null;
            Airport  destination1 = (Airport)cbDestination1.SelectedItem;
            Airport  destination2 = (Airport)cbDestination2.SelectedItem;
            Airport  stopover1    = (Airport)cbStopover1.SelectedItem;
            Airport  stopover2    = cbStopover2.Visibility == System.Windows.Visibility.Visible ? (Airport)cbStopover2.SelectedItem : null;
            DateTime startDate    = dpStartDate.IsEnabled && dpStartDate.SelectedDate.HasValue ? dpStartDate.SelectedDate.Value : GameObject.GetInstance().GameTime;

            Weather.Season season = rbSeasonAll.IsChecked.Value ? Weather.Season.All_Year : Weather.Season.Winter;
            season = rbSeasonSummer.IsChecked.Value ? Weather.Season.Summer : season;
            season = rbSeasonWinter.IsChecked.Value ? Weather.Season.Winter : season;

            try
            {
                if (AirlineHelpers.IsRouteDestinationsOk(GameObject.GetInstance().HumanAirline, destination1, destination2, this.RouteType, stopover1, stopover2))
                {
                    Guid id = Guid.NewGuid();

                    //passenger route
                    if (this.RouteType == Route.RouteType.Passenger)
                    {
                        //Vis på showroute
                        route = new PassengerRoute(id.ToString(), destination1, destination2, startDate, 0);

                        foreach (MVVMRouteClass rac in this.Classes)
                        {
                            ((PassengerRoute)route).getRouteAirlinerClass(rac.Type).FarePrice = rac.FarePrice;

                            foreach (MVVMRouteFacility facility in rac.Facilities)
                            {
                                ((PassengerRoute)route).getRouteAirlinerClass(rac.Type).addFacility(facility.SelectedFacility);
                            }
                        }
                    }
                    //cargo route
                    else if (this.RouteType == Route.RouteType.Cargo)
                    {
                        double cargoPrice = Convert.ToDouble(txtCargoPrice.Text);
                        route = new CargoRoute(id.ToString(), destination1, destination2, startDate, cargoPrice);
                    }
                    else if (this.RouteType == Route.RouteType.Mixed)
                    {
                        double cargoPrice = Convert.ToDouble(txtCargoPrice.Text);

                        route = new CombiRoute(id.ToString(), destination1, destination2, startDate, 0, cargoPrice);

                        foreach (MVVMRouteClass rac in this.Classes)
                        {
                            ((PassengerRoute)route).getRouteAirlinerClass(rac.Type).FarePrice = rac.FarePrice;

                            foreach (MVVMRouteFacility facility in rac.Facilities)
                            {
                                ((PassengerRoute)route).getRouteAirlinerClass(rac.Type).addFacility(facility.SelectedFacility);
                            }
                        }
                    }

                    FleetAirlinerHelpers.CreateStopoverRoute(route, stopover1, stopover2);

                    route.Season = season;

                    GameObject.GetInstance().HumanAirline.addRoute(route);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", ex.Message), Translator.GetInstance().GetString("MessageBox", ex.Message, "message"), WPFMessageBoxButtons.Ok);

                return(false);
            }

            return(false);
        }