public EditFlightDetailsViewController(Flight flight, bool exists)
     : base(UITableViewStyle.Grouped, new RootElement (null))
 {
     certification = LogBook.Pilot.Certification;
     this.exists = exists;
     Flight = flight;
 }
Esempio n. 2
0
 public FlightElement(Flight flight)
     : base(null)
 {
     flight.Updated += OnFlightUpdated;
     date = flight.Date;
     Flight = flight;
 }
 static string GetFlightFlightTime(Flight flight)
 {
     return flight != null ? FormatFlightTime (flight.FlightTime, true) : string.Empty;
 }
 static string GetFlightInstrumentHood(Flight flight)
 {
     return flight != null ? FormatFlightTime (flight.InstrumentHood, false) : null;
 }
 static string GetFlightCertifiedFlightInstructor(Flight flight)
 {
     return flight != null ? FormatFlightTime (flight.CertifiedFlightInstructor, false) : null;
 }
 static string GetFlightDate(Flight flight)
 {
     return flight != null ? flight.Date.ToLongDateString () : string.Empty;
 }
Esempio n. 7
0
        static void OnFlightWillUpdate(Flight flight)
        {
            var handler = FlightWillUpdate;

            if (handler != null)
                handler (null, new FlightEventArgs (flight));
        }
 static string GetFlightAircraft(Flight flight)
 {
     return(flight != null ? flight.Aircraft : string.Empty);
 }
 static string GetFlightCrossCountry(Flight flight)
 {
     return(flight != null?FormatFlightTime(flight.CrossCountry, false) : null);
 }
Esempio n. 10
0
        /// <summary>
        /// Add the specified Flight entry.
        /// </summary>
        /// <param name='flight'>
        /// The Flight entry to add.
        /// </param>
        public static bool Add(Flight flight)
        {
            if (sqlitedb.Insert (flight) > 0) {
                OnFlightAdded (flight);
                return true;
            }

            return false;
        }
 static string GetFlightDualReceived(Flight flight)
 {
     return(flight != null?FormatFlightTime(flight.DualReceived, false) : null);
 }
 static string GetFlightSecondInCommand(Flight flight)
 {
     return(flight != null?FormatFlightTime(flight.SecondInCommand, false) : null);
 }
 static string GetFlightCertifiedFlightInstructor(Flight flight)
 {
     return(flight != null?FormatFlightTime(flight.CertifiedFlightInstructor, false) : null);
 }
 static string GetFlightFlightTime(Flight flight)
 {
     return(flight != null?FormatFlightTime(flight.FlightTime, true) : string.Empty);
 }
 static string GetFlightAirportArrived(Flight flight)
 {
     return(flight != null ? flight.AirportArrived : string.Empty);
 }
 static string GetFlightNight(Flight flight)
 {
     return flight != null ? FormatFlightTime (flight.Night, false) : null;
 }
 static string GetFlightNight(Flight flight)
 {
     return(flight != null?FormatFlightTime(flight.Night, false) : null);
 }
 static string GetFlightSecondInCommand(Flight flight)
 {
     return flight != null ? FormatFlightTime (flight.SecondInCommand, false) : null;
 }
Esempio n. 19
0
 public FlightEventArgs(Flight flight)
 {
     Flight = flight;
 }
Esempio n. 20
0
        /// <summary>
        /// Update the specified Flight entry.
        /// </summary>
        /// <param name='entry'>
        /// The Flight entry to update.
        /// </param>
        public static bool Update(Flight flight)
        {
            OnFlightWillUpdate (flight);

            if (sqlitedb.Update (flight) > 0) {
                OnFlightUpdated (flight);
                flight.OnUpdated ();
                return true;
            } else {
                OnFlightUpdateFailed (flight);
            }

            return false;
        }
 static string GetFlightAirportDeparted(Flight flight)
 {
     return flight != null ? flight.AirportDeparted : string.Empty;
 }
 static string GetFlightDayLandings(Flight flight)
 {
     return(flight != null && flight.DayLandings > 0 ? flight.DayLandings.ToString() : null);
 }
 static string GetFlightDate(Flight flight)
 {
     return(flight != null?flight.Date.ToLongDateString() : string.Empty);
 }
 static string GetFlightAircraft(Flight flight)
 {
     return flight != null ? flight.Aircraft : string.Empty;
 }
 static string GetFlightInstrumentHood(Flight flight)
 {
     return(flight != null?FormatFlightTime(flight.InstrumentHood, false) : null);
 }
        static string GetFlightAirportVisited(Flight flight)
        {
            if (flight == null)
                return null;

            List<string> visited = new List<string> ();
            if (flight.AirportVisited1 != null && flight.AirportVisited1.Length > 0)
                visited.Add (flight.AirportVisited1);
            if (flight.AirportVisited2 != null && flight.AirportVisited2.Length > 0)
                visited.Add (flight.AirportVisited2);
            if (flight.AirportVisited3 != null && flight.AirportVisited3.Length > 0)
                visited.Add (flight.AirportVisited3);

            if (visited.Count == 0)
                return null;

            return string.Join (", ", visited.ToArray ());
        }
 static string GetFlightInstrumentSimulator(Flight flight)
 {
     return(flight != null?FormatFlightTime(flight.InstrumentSimulator, false) : null);
 }
 static string GetFlightCrossCountry(Flight flight)
 {
     return flight != null ? FormatFlightTime (flight.CrossCountry, false) : null;
 }
 static string GetFlightInstrumentApproaches(Flight flight)
 {
     return(flight != null && flight.InstrumentApproaches > 0 ? flight.InstrumentApproaches.ToString() : null);
 }
 static string GetFlightDualReceived(Flight flight)
 {
     return flight != null ? FormatFlightTime (flight.DualReceived, false) : null;
 }
 bool HasInstrumentExperience(Flight flight)
 {
     return(flight.InstrumentActual > 0 || flight.InstrumentHood > 0 || flight.InstrumentSimulator > 0 || flight.InstrumentApproaches > 0);
 }
 static string GetFlightInstrumentApproaches(Flight flight)
 {
     return flight != null && flight.InstrumentApproaches > 0 ? flight.InstrumentApproaches.ToString () : null;
 }
Esempio n. 33
0
        public static string ToString(this Flight flight, FlightProperty property)
        {
            switch (property)
            {
            case FlightProperty.Date:
                return(flight != null?flight.Date.ToLongDateString() : string.Empty);

            case FlightProperty.Aircraft:
                return(flight != null ? flight.Aircraft : string.Empty);

            case FlightProperty.AirportDeparted:
                return(flight != null ? flight.AirportDeparted : string.Empty);

            case FlightProperty.AirportVisited:
                return(flight != null ? flight.AirportVisited : null);

            case FlightProperty.AirportArrived:
                return(flight != null ? flight.AirportArrived : string.Empty);

            case FlightProperty.FlightTime:
                return(flight != null?FormatFlightTime(flight.FlightTime, true) : string.Empty);

            case FlightProperty.CrossCountry:
                return(flight != null?FormatFlightTime(flight.CrossCountry, false) : null);

            case FlightProperty.CertifiedFlightInstructor:
                return(flight != null?FormatFlightTime(flight.CertifiedFlightInstructor, false) : null);

            case FlightProperty.DualReceived:
                return(flight != null?FormatFlightTime(flight.DualReceived, false) : null);

            case FlightProperty.PilotInCommand:
                return(flight != null?FormatFlightTime(flight.PilotInCommand, false) : null);

            case FlightProperty.SecondInCommand:
                return(flight != null?FormatFlightTime(flight.SecondInCommand, false) : null);

            case FlightProperty.Day:
                return(flight != null?FormatFlightTime(flight.Day, false) : null);

            case FlightProperty.Night:
                return(flight != null?FormatFlightTime(flight.Night, false) : null);

            case FlightProperty.DayLandings:
                return(flight != null && flight.DayLandings > 0 ? flight.DayLandings.ToString() : null);

            case FlightProperty.NightLandings:
                return(flight != null && flight.NightLandings > 0 ? flight.NightLandings.ToString() : null);

            case FlightProperty.InstrumentActual:
                return(flight != null?FormatFlightTime(flight.InstrumentActual, false) : null);

            case FlightProperty.InstrumentHood:
                return(flight != null?FormatFlightTime(flight.InstrumentHood, false) : null);

            case FlightProperty.InstrumentSimulator:
                return(flight != null?FormatFlightTime(flight.InstrumentSimulator, false) : null);

            case FlightProperty.InstrumentApproaches:
                return(flight != null && flight.InstrumentApproaches > 0 ? flight.InstrumentApproaches.ToString() : null);

            case FlightProperty.InstrumentHoldingProcedures:
                return(flight != null && flight.InstrumentHoldingProcedures > 0 ? flight.InstrumentHoldingProcedures.ToString() : null);

            case FlightProperty.InstrumentSafetyPilot:
                return(flight != null && !string.IsNullOrEmpty(flight.InstrumentSafetyPilot) ? flight.InstrumentSafetyPilot : null);

            case FlightProperty.Remarks:
                return(flight != null && !string.IsNullOrEmpty(flight.Remarks) ? flight.Remarks : null);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 static string GetFlightInstrumentSimulator(Flight flight)
 {
     return flight != null ? FormatFlightTime (flight.InstrumentSimulator, false) : null;
 }
        public void Edit(Flight flight, bool exists)
        {
            if (masterPopoverController != null)
                masterPopoverController.Dismiss (true);

            editor = new EditFlightDetailsViewController (flight, exists);
            editor.EditorClosed += OnEditorClosed;

            NavigationController.PushViewController (editor, true);
        }
 static string GetFlightNightLandings(Flight flight)
 {
     return flight != null && flight.NightLandings > 0 ? flight.NightLandings.ToString () : null;
 }
        static bool FlightsEqual(Flight flight1, Flight flight2)
        {
            if (flight1 == flight2)
                return true;

            if (flight1 != null && flight2 != null)
                return flight1.Id == flight2.Id;

            return false;
        }
 bool HasInstrumentExperience(Flight flight)
 {
     return flight.InstrumentActual > 0 || flight.InstrumentHood > 0 || flight.InstrumentSimulator > 0 || flight.InstrumentApproaches > 0;
 }
Esempio n. 39
0
 void OnFlightSelected(Flight flight)
 {
     details.Flight = flight;
 }
Esempio n. 40
0
        /// <summary>
        /// Delete the specified Flight entry.
        /// </summary>
        /// <param name='flight'>
        /// The Flight entry to delete.
        /// </param>
        public static bool Delete(Flight flight)
        {
            if (sqlitedb.Delete<Flight> (flight) > 0) {
                OnFlightDeleted (flight);
                return true;
            }

            return false;
        }
Esempio n. 41
0
        protected override void Dispose(bool disposing)
        {
            if (Flight != null) {
                Flight.Updated -= OnFlightUpdated;
                Flight = null;
            }

            base.Dispose (disposing);
        }
Esempio n. 42
0
        static void OnFlightUpdateFailed(Flight flight)
        {
            var handler = FlightUpdateFailed;

            if (handler != null)
                handler (null, new FlightEventArgs (flight));
        }
Esempio n. 43
0
        public FlightTableViewCell(Flight flight, NSString key)
            : base(UITableViewCellStyle.Default, key)
        {
            SelectionStyle = UITableViewCellSelectionStyle.Blue;
            Accessory = UITableViewCellAccessory.None;
            ContentMode = UIViewContentMode.Left;
            ContentView.ClipsToBounds = true;
            view = new FlightCellView ();
            view.Flight = flight;

            ContentView.Add (view);
        }
 public EditFlightDetailsViewController(Flight flight, bool exists)
     : base(UITableViewStyle.Grouped, new RootElement (null))
 {
     this.exists = exists;
     Flight = flight;
 }
Esempio n. 45
0
        void UpdateDetails()
        {
            Title = string.Format("{0} to {1} on {2}", Flight.AirportDeparted,
                                  Flight.AirportArrived, Flight.Date.ToShortDateString());

            List <List <FlightProperty> > newSections = new List <List <FlightProperty> > ();
            List <SectionTitle>           newTitles   = new List <SectionTitle> ();

            // Create a new list of sections & properties
            for (int i = 0; i < PropertySections.Count; i++)
            {
                List <FlightProperty> section = null;

                foreach (var property in PropertySections[i])
                {
                    if (Flight.ToString(property) != null)
                    {
                        if (section == null)
                        {
                            section = new List <FlightProperty> ();
                        }
                        section.Add(property);
                    }
                }

                if (section != null)
                {
                    newTitles.Add((SectionTitle)i);
                    newSections.Add(section);
                }
            }

#if ATTEMPT_TO_DO_FANCY_ANIMATIONS
            // Update sections & titles to match newSections and newTitles
            List <NSIndexPath> reload = new List <NSIndexPath> ();
            bool needEndUpdates       = false;
            bool reloadRemarks        = false;

            // Remove old rows and sections...
            for (int section = PropertySections.Count - 1; section >= 0; section--)
            {
                SectionTitle title      = (SectionTitle)section;
                int          oldSection = titles.IndexOf(title);

                if (oldSection == -1)
                {
                    continue;
                }

                int newSection = newTitles.IndexOf(title);
                if (newSection != -1 && title != SectionTitle.Remarks)
                {
                    // Remove old rows...
                    List <NSIndexPath> rows = new List <NSIndexPath> ();

                    for (int row = PropertySections[section].Count - 1; row >= 0; row--)
                    {
                        var property = PropertySections[section][row];
                        int oldRow   = sections[oldSection].IndexOf(property);

                        if (oldRow == -1)
                        {
                            continue;
                        }

                        int newRow = newSections[newSection].IndexOf(property);
                        if (newRow != -1)
                        {
                            continue;
                        }

                        //Console.WriteLine ("Removing {0} (row = {1}) from {2} (section = {3})", property, oldRow, title, oldSection);
                        rows.Add(NSIndexPath.FromRowSection(oldRow, oldSection));
                        sections[oldSection].RemoveAt(oldRow);
                    }

                    if (rows.Count > 0)
                    {
                        if (!needEndUpdates)
                        {
                            TableView.BeginUpdates();
                            needEndUpdates = true;
                        }

                        TableView.DeleteRows(rows.ToArray(), UITableViewRowAnimation.Automatic);
                        foreach (var row in rows)
                        {
                            row.Dispose();
                        }
                    }
                }
                else if (newSection == -1)
                {
                    // Remove the entire section...
                    //Console.WriteLine ("Removing {0} @ {1}", title, oldSection);
                    if (!needEndUpdates)
                    {
                        TableView.BeginUpdates();
                        needEndUpdates = true;
                    }

                    var idx = NSIndexSet.FromIndex(oldSection);
                    TableView.DeleteSections(idx, UITableViewRowAnimation.Automatic);
                    sections.RemoveAt(oldSection);
                    titles.RemoveAt(oldSection);
                    idx.Dispose();
                }
            }

            // Add new rows and sections while maintaining a list of rows which need to be reloaded
            for (int section = 0; section < PropertySections.Count; section++)
            {
                SectionTitle title      = (SectionTitle)section;
                int          newSection = newTitles.IndexOf(title);

                if (newSection == -1)
                {
                    continue;
                }

                int oldSection = titles.IndexOf(title);
                if (oldSection != -1 && title != SectionTitle.Remarks)
                {
                    // Add new rows...
                    List <NSIndexPath> rows = new List <NSIndexPath> ();

                    for (int row = 0; row < PropertySections[section].Count; row++)
                    {
                        var property = PropertySections[section][row];
                        int newRow   = newSections[newSection].IndexOf(property);

                        if (newRow == -1)
                        {
                            continue;
                        }

                        int oldRow = sections[oldSection].IndexOf(property);
                        if (oldRow != -1)
                        {
                            reload.Add(NSIndexPath.FromRowSection(newRow, newSection));
                            continue;
                        }

                        //Console.WriteLine ("Inserting {0} (row = {1}) into {2} (section = {3})", property, newRow, title, oldSection);
                        rows.Add(NSIndexPath.FromRowSection(newRow, oldSection));
                        sections[oldSection].Insert(newRow, property);
                    }

                    if (rows.Count > 0)
                    {
                        if (!needEndUpdates)
                        {
                            TableView.BeginUpdates();
                            needEndUpdates = true;
                        }

                        TableView.InsertRows(rows.ToArray(), UITableViewRowAnimation.Automatic);
                        foreach (var row in rows)
                        {
                            row.Dispose();
                        }
                    }
                }
                else if (oldSection == -1)
                {
                    // Add the entire section...
                    if (!needEndUpdates)
                    {
                        TableView.BeginUpdates();
                        needEndUpdates = true;
                    }

                    //Console.WriteLine ("Inserting {0} @ {1}", title, newSection);
                    var idx = NSIndexSet.FromIndex(newSection);
                    TableView.InsertSections(idx, UITableViewRowAnimation.Automatic);
                    sections.Insert(newSection, newSections[newSection]);
                    titles.Insert(newSection, title);
                    idx.Dispose();
                }
                else if (title == SectionTitle.Remarks)
                {
                    reloadRemarks = true;
                }
            }

            if (needEndUpdates)
            {
                TableView.EndUpdates();
            }

            if (reload.Count > 0)
            {
                TableView.ReloadRows(reload.ToArray(), UITableViewRowAnimation.None);
                foreach (var row in reload)
                {
                    row.Dispose();
                }
            }

            if (reloadRemarks)
            {
                var remarks = NSIndexSet.FromIndex(sections.Count - 1);
                TableView.ReloadSections(remarks, UITableViewRowAnimation.None);
                remarks.Dispose();
            }
#else
            sections = newSections;
            titles   = newTitles;

            TableView.ReloadData();
#endif
        }