static RootElement CreateClassificationElement(AircraftCategory category, RadioGroup classes) { int next = (int)category + Aircraft.CategoryStep; var root = new RootElement("Class", classes); var section = new Section(); foreach (AircraftClassification value in Enum.GetValues(typeof(AircraftClassification))) { if ((int)value < (int)category) { continue; } if ((int)value >= next) { break; } section.Add(new RadioElement(value.ToHumanReadableName(), "AircraftClassification")); } root.Add(section); return(root); }
/// <summary> /// Gets a list of all of the aircraft of the specified category. /// </summary> /// <returns> /// A list of all of the aircraft of the specified category /// </returns> /// <param name='category'> /// The category of aircraft requested. /// </param> public static List <Aircraft> GetAircraft(AircraftCategory category) { AircraftClassification firstClass = (AircraftClassification)(int)category; AircraftClassification lastClass = firstClass + Aircraft.CategoryStep; return(sqlitedb.Query <Aircraft> ("select * from Aircraft where Classification between ? and ?", firstClass, lastClass)); }
void LoadDayAndNightCurrency() { if (LogBook.Pilot.Endorsements.HasFlag(AircraftEndorsement.TailDragger)) { var list = LogBook.GetAircraft(AircraftCategory.Airplane, false); var taildraggers = new List <Aircraft> (); foreach (var aircraft in list) { if (aircraft.IsTailDragger) { taildraggers.Add(aircraft); } } var section = new Section("Taildragger Currency"); AddLandingCurrency(section, taildraggers, false); AddLandingCurrency(section, taildraggers, true); Root.Add(section); } // Day/Night currency is per-AircraftClassification foreach (AircraftClassification @class in Enum.GetValues(typeof(AircraftClassification))) { AircraftCategory category = Aircraft.GetCategoryFromClass(@class); AircraftEndorsement endorsement; if (!Enum.TryParse <AircraftEndorsement> (@class.ToString(), out endorsement)) { continue; } if (!LogBook.Pilot.Endorsements.HasFlag(endorsement)) { continue; } var list = LogBook.GetAircraft(@class, false); string caption; if (category == AircraftCategory.Airplane) { caption = "Airplane " + @class.ToHumanReadableName(); } else { caption = @class.ToHumanReadableName(); } var section = new Section(string.Format("{0} Currency", caption)); AddLandingCurrency(section, list, false); AddLandingCurrency(section, list, true); Root.Add(section); } }
void LoadDayAndNightCurrency() { // Day/Night currency is per-AircraftClassification and TailDragger vs not. foreach (var value in Enum.GetValues(typeof(AircraftClassification))) { AircraftClassification @class = (AircraftClassification)value; List <Aircraft> list = LogBook.GetAircraft(@class, false); if (list == null || list.Count == 0) { continue; } AircraftCategory category = Aircraft.GetCategoryFromClass(@class); Section section; string caption; if (category == AircraftCategory.Airplane) { caption = string.Format("{0} {1}", category.ToHumanReadableName(), @class.ToHumanReadableName()); } else { caption = @class.ToHumanReadableName(); } section = new Section(caption); // Only Airplanes can be tail-draggers if (category == AircraftCategory.Airplane) { List <Aircraft> taildraggers = new List <Aircraft> (); foreach (var aircraft in list) { if (aircraft.IsTailDragger) { taildraggers.Add(aircraft); } } if (taildraggers.Count > 0) { AddLandingCurrency(section, taildraggers, @class, false, true); AddLandingCurrency(section, taildraggers, @class, true, true); } } AddLandingCurrency(section, list, @class, false, false); AddLandingCurrency(section, list, @class, true, false); Root.Add(section); } }
/// <summary> /// Gets a list of all of the aircraft of the specified category. /// </summary> /// <returns> /// A list of all of the aircraft of the specified category /// </returns> /// <param name='category'> /// The category of aircraft requested. /// </param> /// <param name='includeSimulators'> /// Specifies whether or not simulators should be included. /// </param> public static List <Aircraft> GetAircraft(AircraftCategory category, bool includeSimulators) { if (includeSimulators) { return(GetAircraft(category)); } AircraftClassification firstClass = (AircraftClassification)(int)category; AircraftClassification lastClass = firstClass + Aircraft.CategoryStep; return(sqlitedb.Query <Aircraft> ("select * from Aircraft where Classification between ? and ? and IsSimulator = ?", firstClass, lastClass, false)); }
public static AircraftEndorsement GetEndorsementMask(AircraftCategory category) { AircraftEndorsement mask = AircraftEndorsement.None; switch (category) { case AircraftCategory.Airplane: mask |= AircraftEndorsement.SingleEngineLand; mask |= AircraftEndorsement.SingleEngineSea; mask |= AircraftEndorsement.MultiEngineLand; mask |= AircraftEndorsement.MultiEngineSea; mask |= AircraftEndorsement.Complex; mask |= AircraftEndorsement.HighPerformance; mask |= AircraftEndorsement.TailDragger; break; case AircraftCategory.Rotorcraft: mask |= AircraftEndorsement.Helicoptor; mask |= AircraftEndorsement.Gryoplane; break; case AircraftCategory.Glider: mask = AircraftEndorsement.Glider; break; case AircraftCategory.LighterThanAir: mask |= AircraftEndorsement.Airship; mask |= AircraftEndorsement.Balloon; break; case AircraftCategory.PoweredLift: mask = AircraftEndorsement.PoweredLift; break; case AircraftCategory.PoweredParachute: mask |= AircraftEndorsement.PoweredParachuteLand; mask |= AircraftEndorsement.PoweredParachuteSea; break; case AircraftCategory.WeightShiftControl: mask |= AircraftEndorsement.WeightShiftControlLand; mask |= AircraftEndorsement.WeightShiftControlSea; break; default: throw new ArgumentOutOfRangeException(); } return(mask); }
static RootElement CreateCategoryElement(AircraftCategory category) { var root = new RootElement("Category", new RadioGroup("AircraftCategory", 0)); var section = new Section(); foreach (AircraftCategory value in Enum.GetValues(typeof(AircraftCategory))) { section.Add(new RadioElement(value.ToHumanReadableName(), "AircraftCategory")); } root.Add(section); root.RadioSelected = CategoryToIndex(category); return(root); }
void LoadInstrumentCurrency() { // Instrument currency is per-AircraftCategory foreach (var value in Enum.GetValues(typeof(AircraftCategory))) { AircraftCategory category = (AircraftCategory)value; List <Aircraft> list = LogBook.GetAircraft(category, false); if (list == null || list.Count == 0) { continue; } Section section = new Section(category.ToHumanReadableName()); AddInstrumentCurrency(section, list, category); Root.Add(section); } }
void AddInstrumentCurrency(Section section, List<Aircraft> list, AircraftCategory category) { string caption = "Instrument Current"; DateTime oldestApproach = DateTime.Now; int approaches = 0; foreach (var flight in LogBook.GetFlightsForInstrumentCurrencyRequirements (list)) { approaches += flight.InstrumentApproaches; oldestApproach = flight.Date; if (approaches >= 6) { DateTime expires = GetInstrumentCurrencyExipirationDate (oldestApproach); section.Add (new CurrencyElement (caption, expires)); return; } } // currency is out of date section.Add (new CurrencyElement (caption, DateTime.Now)); }
void AddInstrumentCurrency(Section section, List <Aircraft> list, AircraftCategory category) { string caption = "Instrument Current"; DateTime oldestApproach = DateTime.Now; int approaches = 0; foreach (var flight in LogBook.GetFlightsForInstrumentCurrencyRequirements(list)) { approaches += flight.InstrumentApproaches; oldestApproach = flight.Date; if (approaches >= 6) { DateTime expires = GetInstrumentCurrencyExipirationDate(oldestApproach); section.Add(new CurrencyElement(caption, expires)); return; } } // currency is out of date section.Add(new CurrencyElement(caption, DateTime.Now)); }
static int CategoryToIndex(AircraftCategory category) { return(((int)category) / Aircraft.CategoryStep); }
/// <summary> /// Gets a list of all of the aircraft of the specified category. /// </summary> /// <returns> /// A list of all of the aircraft of the specified category /// </returns> /// <param name='category'> /// The category of aircraft requested. /// </param> /// <param name='includeSimulators'> /// Specifies whether or not simulators should be included. /// </param> public static List<Aircraft> GetAircraft(AircraftCategory category, bool includeSimulators) { if (includeSimulators) return GetAircraft (category); AircraftClassification firstClass = (AircraftClassification) (int) category; AircraftClassification lastClass = firstClass + Aircraft.CategoryStep; return sqlitedb.Query<Aircraft> ("select * from Aircraft where Classification between ? and ? and IsSimulator = ?", firstClass, lastClass, false); }
/// <summary> /// Gets a list of all of the aircraft of the specified category. /// </summary> /// <returns> /// A list of all of the aircraft of the specified category /// </returns> /// <param name='category'> /// The category of aircraft requested. /// </param> public static List<Aircraft> GetAircraft(AircraftCategory category) { AircraftClassification firstClass = (AircraftClassification) (int) category; AircraftClassification lastClass = firstClass + Aircraft.CategoryStep; return sqlitedb.Query<Aircraft> ("select * from Aircraft where Classification between ? and ?", firstClass, lastClass); }
RootElement CreateCategoryElement(AircraftCategory category) { RootElement root = new RootElement ("Category", new RadioGroup ("AircraftCategory", 0)); Section section = new Section (); foreach (AircraftCategory value in Enum.GetValues (typeof (AircraftCategory))) section.Add (new RadioElement (value.ToHumanReadableName (), "AircraftCategory")); root.Add (section); root.RadioSelected = CategoryToIndex (category); return root; }
int CategoryToIndex(AircraftCategory category) { return ((int) category) / Aircraft.CategoryStep; }
void LoadFlightTimeTotals() { var totals = new List <Totals> (); var twelveMonthsAgo = GetMonthsAgo(12); var sixMonthsAgo = GetMonthsAgo(6); Dictionary <string, Aircraft> dict; Aircraft aircraft; int time; dict = new Dictionary <string, Aircraft> (); foreach (var craft in LogBook.GetAllAircraft()) { dict.Add(craft.TailNumber, craft); } totals.Add(new Totals("Flight Time Totals", FlightProperty.FlightTime)); totals.Add(new Totals("Pilot-in-Command Totals", FlightProperty.PilotInCommand)); totals.Add(new Totals("Certified Flight Instructor Totals", FlightProperty.CertifiedFlightInstructor)); totals.Add(new Totals("Cross-Country Totals", FlightProperty.CrossCountry)); totals.Add(new Totals("Cross-Country (PIC) Totals", FlightProperty.CrossCountryPIC)); totals.Add(new Totals("Night Totals", FlightProperty.Night)); totals.Add(new Totals("Instrument (Actual) Totals", FlightProperty.InstrumentActual)); totals.Add(new Totals("Instrument (Hood) Totals", FlightProperty.InstrumentHood)); if (LogBook.Pilot.Endorsements.HasFlag(AircraftEndorsement.Complex)) { totals.Add(new Totals("Complex Totals", AircraftProperty.IsComplex)); } if (LogBook.Pilot.Endorsements.HasFlag(AircraftEndorsement.HighPerformance)) { totals.Add(new Totals("High-Performance Totals", AircraftProperty.IsHighPerformance)); } if (LogBook.Pilot.Endorsements.HasFlag(AircraftEndorsement.TailDragger)) { totals.Add(new Totals("Taildragger Totals", AircraftProperty.IsTailDragger)); } foreach (AircraftClassification @class in Enum.GetValues(typeof(AircraftClassification))) { AircraftCategory category = Aircraft.GetCategoryFromClass(@class); string title = @class.ToHumanReadableName() + " Totals"; if (category == AircraftCategory.Airplane) { title = "Airplane " + title; } totals.Add(new Totals(title, @class)); } foreach (var flight in LogBook.GetAllFlights()) { if (!dict.TryGetValue(flight.Aircraft, out aircraft)) { continue; } if (aircraft.IsSimulator) { continue; } foreach (var total in totals) { if (total.Property is FlightProperty) { time = flight.GetFlightTime((FlightProperty)total.Property); } else if (total.Property is AircraftProperty) { if (!((bool)aircraft.GetValue((AircraftProperty)total.Property))) { continue; } time = flight.FlightTime; } else { if (aircraft.Classification != (AircraftClassification)total.Property) { continue; } time = flight.FlightTime; } if (flight.Date >= sixMonthsAgo) { total.Last12Months += time; total.Last6Months += time; } else if (flight.Date >= twelveMonthsAgo) { total.Last12Months += time; } total.Total += time; } } var aircraftTotals = new RootElement("By Aircraft Category..."); var otherTotals = new RootElement("Other Totals"); for (int i = 1; i < totals.Count; i++) { if (totals[i].Total == 0) { continue; } if (totals[i].Property is FlightProperty) { otherTotals.Add(new Section(totals[i].Title) { new StringElement("Total", FlightExtension.FormatFlightTime(totals[i].Total, true)), new StringElement("12 Months", FlightExtension.FormatFlightTime(totals[i].Last12Months, true)), new StringElement("6 Months", FlightExtension.FormatFlightTime(totals[i].Last6Months, true)), }); } else { aircraftTotals.Add(new Section(totals[i].Title) { new StringElement("Total", FlightExtension.FormatFlightTime(totals[i].Total, true)), new StringElement("12 Months", FlightExtension.FormatFlightTime(totals[i].Last12Months, true)), new StringElement("6 Months", FlightExtension.FormatFlightTime(totals[i].Last6Months, true)), }); } } Root.Add(new Section(totals[0].Title) { new StringElement("Total", FlightExtension.FormatFlightTime(totals[0].Total, true)), new StringElement("12 Months", FlightExtension.FormatFlightTime(totals[0].Last12Months, true)), new StringElement("6 Months", FlightExtension.FormatFlightTime(totals[0].Last6Months, true)), aircraftTotals, otherTotals }); }
RootElement CreateClassificationElement(AircraftCategory category) { RootElement root = new RootElement ("Class", classes); int next = (int) category + Aircraft.CategoryStep; Section section = new Section (); foreach (AircraftClassification value in Enum.GetValues (typeof (AircraftClassification))) { if ((int) value < (int) category) continue; if ((int) value >= next) break; section.Add (new RadioElement (value.ToHumanReadableName (), "AircraftClassification")); } root.Add (section); return root; }
public static AircraftEndorsement GetEndorsementMask(AircraftCategory category) { AircraftEndorsement mask = AircraftEndorsement.None; switch (category) { case AircraftCategory.Airplane: mask |= AircraftEndorsement.SingleEngineLand; mask |= AircraftEndorsement.SingleEngineSea; mask |= AircraftEndorsement.MultiEngineLand; mask |= AircraftEndorsement.MultiEngineSea; mask |= AircraftEndorsement.Complex; mask |= AircraftEndorsement.HighPerformance; mask |= AircraftEndorsement.TailDragger; break; case AircraftCategory.Rotorcraft: mask |= AircraftEndorsement.Helicoptor; mask |= AircraftEndorsement.Gryoplane; break; case AircraftCategory.Glider: mask = AircraftEndorsement.Glider; break; case AircraftCategory.LighterThanAir: mask |= AircraftEndorsement.Airship; mask |= AircraftEndorsement.Balloon; break; case AircraftCategory.PoweredLift: mask = AircraftEndorsement.PoweredLift; break; case AircraftCategory.PoweredParachute: mask |= AircraftEndorsement.PoweredParachuteLand; mask |= AircraftEndorsement.PoweredParachuteSea; break; case AircraftCategory.WeightShiftControl: mask |= AircraftEndorsement.WeightShiftControlLand; mask |= AircraftEndorsement.WeightShiftControlSea; break; default: throw new ArgumentOutOfRangeException (); } return mask; }