private void EntryChanged_Event(object sender, System.Windows.RoutedEventArgs e) { object[] entries = e.OriginalSource as object[]; TimelineEntry oldEntry = entries[0] as TimelineEntry; TimelineEntry newEntry = entries[1] as TimelineEntry; RouteTimeTableEntry oEntry = (RouteTimeTableEntry)oldEntry.Source; RouteTimeTable rt = new RouteTimeTable(oEntry.TimeTable.Route); RouteTimeTableEntry nEntry = new RouteTimeTableEntry(rt, (DayOfWeek)newEntry.StartTime.Days, newEntry.StartTime, oEntry.Destination); nEntry.Airliner = this.Airliner; rt.addEntry(nEntry); List <RouteTimeTableEntry> tEntries = new List <RouteTimeTableEntry>(this.Entries); tEntries.Remove(oEntry); if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, tEntries)) { WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2706"), Translator.GetInstance().GetString("MessageBox", "2706", "message"), WPFMessageBoxButtons.Ok); } else { this.Entries.Remove(oEntry); this.Entries.Add(nEntry); } }
//adds entries to the planner private void addEntries(List <DayOfWeek> days) { Route route = (Route)cbHomebound.SelectedItem; Airport origin = (Airport)cbOutbound.SelectedItem; Airport airport = route.Destination1 == origin ? route.Destination2 : route.Destination1; TimeSpan time = new TimeSpan(tpTime.Value.Value.Hour, tpTime.Value.Value.Minute, 0); string flightCode = this.Airliner.Airliner.Airline.Profile.IATACode + txtSchedulerFlightNumber.Text; RouteTimeTable rt = new RouteTimeTable(route); foreach (DayOfWeek dayOfWeek in days) { RouteTimeTableEntry entry = new RouteTimeTableEntry(route.TimeTable, dayOfWeek, time, new RouteEntryDestination(airport, flightCode)); entry.Airliner = this.Airliner; rt.addEntry(entry); } if (!TimeTableHelpers.IsRoutePlannerTimeTableValid(rt, this.Airliner, this.Entries.ToList())) { WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2706"), Translator.GetInstance().GetString("MessageBox", "2706", "message"), WPFMessageBoxButtons.Ok); } else { foreach (RouteTimeTableEntry entry in rt.Entries) { this.Entries.Add(entry); } } setFlightNumbers(); }
private void btnAutoGenerate_Click(object sender, RoutedEventArgs e) { object o = PopUpAutogenerateRoute.ShowPopUp(this.Airliner); if (o != null) { clearTimeTable(); RouteTimeTable timeTable = (RouteTimeTable)o; Route route = timeTable.Route; if (!this.Entries.ContainsKey(route)) { this.Entries.Add(route, new List <RouteTimeTableEntry>()); } foreach (RouteTimeTableEntry entry in timeTable.Entries) { this.Entries[route].Add(entry); } showFlights(); } }
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); } } } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { ComboBoxItem item = (ComboBoxItem)cbDestination.SelectedItem; Route route = (Route)item.Tag; Airport airport = (Airport)item.Content; TimeSpan time = new TimeSpan(tpTime.Value.Value.Hour, tpTime.Value.Value.Minute, 0); string day = cbDay.SelectedItem.ToString(); if (!this.ParentPage.Entries.ContainsKey(route)) { this.ParentPage.Entries.Add(route, new List <RouteTimeTableEntry>()); } string flightCode = cbFlightCode.SelectedItem.ToString(); RouteTimeTable rt = new RouteTimeTable(route); if (day == "Daily") { foreach (DayOfWeek dayOfWeek in Enum.GetValues(typeof(DayOfWeek))) { RouteTimeTableEntry entry = new RouteTimeTableEntry(route.TimeTable, dayOfWeek, time, new RouteEntryDestination(airport, flightCode)); entry.Airliner = this.Airliner; rt.addEntry(entry); } } else { RouteTimeTableEntry entry = new RouteTimeTableEntry(route.TimeTable, (DayOfWeek)cbDay.SelectedItem, time, new RouteEntryDestination(airport, flightCode)); entry.Airliner = this.Airliner; rt.addEntry(entry); } if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, this.ParentPage.Entries)) { WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2706"), Translator.GetInstance().GetString("MessageBox", "2706", "message"), WPFMessageBoxButtons.Ok); } else { this.ParentPage.NewestEntries.Clear(); foreach (RouteTimeTableEntry entry in rt.Entries) { this.ParentPage.Entries[route].Add(entry); this.ParentPage.NewestEntries.Add(entry); } } this.ParentPage.showFlights(); }
public static Boolean IsTimeTableValid(RouteTimeTable timeTable, FleetAirliner airliner, Dictionary <Route, List <RouteTimeTableEntry> > entries, Boolean withSlots = true) { foreach (RouteTimeTableEntry e in timeTable.Entries) { if (!IsRouteEntryValid(e, airliner, entries, new Dictionary <Route, List <RouteTimeTableEntry> >(), withSlots)) { return(false); } } return(true); }
public static Boolean IsRoutePlannerTimeTableValid(RouteTimeTable timeTable, FleetAirliner airliner, List <RouteTimeTableEntry> entries, Boolean withSlots = true) { var tEntries = new List <RouteTimeTableEntry>(); tEntries.AddRange(entries); tEntries.AddRange(timeTable.Entries); foreach (RouteTimeTableEntry e in timeTable.Entries) { var cEntries = new List <RouteTimeTableEntry>(tEntries); cEntries.Remove(e); if (!IsRouteEntryValid(e, airliner, cEntries, withSlots)) { return(false); } } return(true); }