void LoadFlightLog()
        {
            int           year    = Int32.MaxValue;
            Section       section = null;
            FlightElement element;

            foreach (var flight in LogBook.GetAllFlights())
            {
                if (flight.Date.Year != year)
                {
                    year    = flight.Date.Year;
                    section = new YearSection(year);
                    Root.Add(section);
                }

                element          = new FlightElement(flight);
                element.Changed += OnFlightElementChanged;
                section.Add(element);
            }

            LogBook.FlightAdded += OnFlightAdded;
        }
        YearSection GetSectionForYear(int year)
        {
            int         lo = 0, hi = Root.Count;
            YearSection section;
            int         mid = 0;

            if (hi > 0)
            {
                do
                {
                    mid = lo + (hi - lo) / 2;

                    section = Root[mid] as YearSection;

                    if (year == section.Year)
                    {
                        return(section);
                    }

                    // Note: Sections are in reverse chronological order
                    if (year < section.Year)
                    {
                        lo = mid + 1;
                        mid++;
                    }
                    else
                    {
                        hi = mid;
                    }
                } while (lo < hi);
            }

            section = new YearSection(year);
            Root.Insert(mid, UITableViewRowAnimation.Automatic, section);

            return(section);
        }
        void LoadFlightLog()
        {
            int year = Int32.MaxValue;
            Section section = null;
            FlightElement element;

            foreach (var flight in LogBook.GetAllFlights ()) {
                if (flight.Date.Year != year) {
                    year = flight.Date.Year;
                    section = new YearSection (year);
                    Root.Add (section);
                }

                element = new FlightElement (flight);
                element.Changed += OnFlightElementChanged;
                section.Add (element);
            }

            LogBook.FlightAdded += OnFlightAdded;
        }
        YearSection GetSectionForYear(int year)
        {
            int lo = 0, hi = Root.Count;
            YearSection section;
            int mid = 0;

            if (hi > 0) {
                do {
                    mid = lo + (hi - lo) / 2;

                    section = Root[mid] as YearSection;

                    if (year == section.Year)
                        return section;

                    // Note: Sections are in reverse chronological order
                    if (year < section.Year) {
                        lo = mid + 1;
                        mid++;
                    } else {
                        hi = mid;
                    }
                } while (lo < hi);
            }

            section = new YearSection (year);
            Root.Insert (mid, UITableViewRowAnimation.Automatic, section);

            return section;
        }