예제 #1
0
        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;
        }
예제 #2
0
        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);
        }
예제 #3
0
        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;
        }
예제 #4
0
        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;
        }