Esempio n. 1
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            Route route = (Route)cbRoute.SelectedItem;

            int flightsPerDay = (int)cbFlightsPerDay.SelectedItem;

            string flightcode1 = cbFlightCode.SelectedItem.ToString();
            string flightcode2 = this.Airliner.Airliner.Airline.getFlightCodes()[this.Airliner.Airliner.Airline.getFlightCodes().IndexOf(flightcode1) + 1];

            if (flightsPerDay > 0)
            {
                if (cbBusinessRoute.IsChecked.Value)
                {
                    flightsPerDay = (int)(route.getFlightTime(this.Airliner.Airliner.Type).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(this.Airliner)).TotalMinutes / 2 / maxBusinessRouteTime);
                    this.Selected = AIHelpers.CreateBusinessRouteTimeTable(route, this.Airliner, Math.Max(1, flightsPerDay), flightcode1, flightcode2);
                }
                else
                {
                    this.Selected = AIHelpers.CreateAirlinerRouteTimeTable(route, this.Airliner, flightsPerDay, flightcode1, flightcode2);
                }
            }
            else
            {
                this.Selected = null;
            }
            this.Close();
        }
Esempio n. 2
0
        private void btnAddGenerator_Click(object sender, RoutedEventArgs e)
        {
            Route route = (Route)cbRoute.SelectedItem;

            RouteTimeTable rt = null;

            IntervalType intervalType = (IntervalType)cbIntervalType.SelectedItem;
            int          interval     = Convert.ToInt16(cbInterval.SelectedItem);
            OpsType      opsType      = (OpsType)cbSchedule.SelectedItem;
            int          delayMinutes = (int)cbDelayMinutes.SelectedItem;

            double   maxBusinessRouteTime = new TimeSpan(2, 0, 0).TotalMinutes;
            TimeSpan startTime            = (TimeSpan)cbStartTime.SelectedItem;

            string flightcode1 = this.Airliner.Airliner.Airline.Profile.IATACode + txtFlightNumber.Text;
            string flightcode2 = this.Airliner.Airliner.Airline.getFlightCodes()[this.Airliner.Airliner.Airline.getFlightCodes().IndexOf(flightcode1) + 1];

            if (opsType == OpsType.Business)
            {
                int flightsPerDay = (int)(route.getFlightTime(this.Airliner.Airliner.Type).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(this.Airliner)).TotalMinutes / 2 / maxBusinessRouteTime);
                rt = AIHelpers.CreateBusinessRouteTimeTable(route, this.Airliner, Math.Max(1, flightsPerDay), flightcode1, flightcode2);
            }
            if (intervalType == IntervalType.Day && opsType != OpsType.Business)
            {
                rt = AIHelpers.CreateAirlinerRouteTimeTable(route, this.Airliner, interval, true, delayMinutes, startTime, flightcode1, flightcode2);
            }
            if (intervalType == IntervalType.Week && opsType != OpsType.Business)
            {
                rt = AIHelpers.CreateAirlinerRouteTimeTable(route, this.Airliner, interval, false, delayMinutes, startTime, flightcode1, flightcode2);
            }
            if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, this.Entries.ToList(), false))
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2705"), Translator.GetInstance().GetString("MessageBox", "2705", "message"), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    clearTimeTable();

                    foreach (RouteTimeTableEntry entry in rt.Entries)
                    {
                        if (!TimeTableHelpers.IsRouteEntryInOccupied(entry, this.Airliner))
                        {
                            this.Entries.Add(entry);
                        }
                    }
                }
            }
            else
            {
                foreach (RouteTimeTableEntry entry in rt.Entries)
                {
                    if (!TimeTableHelpers.IsRouteEntryInOccupied(entry, this.Airliner))
                    {
                        this.Entries.Add(entry);
                    }
                }
            }
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            Route route = (Route)cbRoute.SelectedItem;

            RouteTimeTable rt;

            int      flightsPerDay  = (int)cbFlightsPerDay.SelectedItem;
            int      flightsPerWeek = (int)cbFlightsPerWeek.SelectedItem;
            int      delayMinutes   = (int)cbDelayMinutes.SelectedItem;
            TimeSpan startTime      = (TimeSpan)cbStartTime.SelectedItem;

            string flightcode1 = cbFlightCode.SelectedItem.ToString();
            string flightcode2 = this.Airliner.Airliner.Airline.getFlightCodes()[this.Airliner.Airliner.Airline.getFlightCodes().IndexOf(flightcode1) + 1];

            if (flightsPerDay > 0)
            {
                if (this.RouteOperations == RouteOperationsType.Business)
                {
                    flightsPerDay = (int)(route.getFlightTime(this.Airliner.Airliner.Type).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(this.Airliner)).TotalMinutes / 2 / maxBusinessRouteTime);
                    rt            = AIHelpers.CreateBusinessRouteTimeTable(route, this.Airliner, Math.Max(1, flightsPerDay), flightcode1, flightcode2);
                }
                else
                {
                    if (this.Interval == FlightInterval.Daily)
                    {
                        rt = AIHelpers.CreateAirlinerRouteTimeTable(route, this.Airliner, flightsPerDay, true, delayMinutes, startTime, flightcode1, flightcode2);
                    }
                    else
                    {
                        rt = AIHelpers.CreateAirlinerRouteTimeTable(route, this.Airliner, flightsPerWeek, false, delayMinutes, startTime, flightcode1, flightcode2);
                    }
                }
            }
            else
            {
                rt = null;
            }

            if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, this.ParentPage.Entries, false))
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2705"), Translator.GetInstance().GetString("MessageBox", "2705", "message"), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    this.ParentPage.NewestEntries.Clear();
                    this.ParentPage.clearTimeTable();

                    if (!this.ParentPage.Entries.ContainsKey(route))
                    {
                        this.ParentPage.Entries.Add(route, new List <RouteTimeTableEntry>());
                    }


                    foreach (RouteTimeTableEntry entry in rt.Entries)
                    {
                        if (!TimeTableHelpers.IsRouteEntryInOccupied(entry, this.Airliner))
                        {
                            this.ParentPage.Entries[route].Add(entry);
                            this.ParentPage.NewestEntries.Add(entry);
                        }
                    }
                }
            }
            else
            {
                if (!this.ParentPage.Entries.ContainsKey(route))
                {
                    this.ParentPage.Entries.Add(route, new List <RouteTimeTableEntry>());
                }

                foreach (RouteTimeTableEntry entry in rt.Entries)
                {
                    if (!TimeTableHelpers.IsRouteEntryInOccupied(entry, this.Airliner))
                    {
                        this.ParentPage.Entries[route].Add(entry);
                        this.ParentPage.NewestEntries.Add(entry);
                    }
                }
            }


            this.ParentPage.showFlights();
        }