예제 #1
0
        void OnFlightDeleted(object sender, FlightEventArgs args)
        {
            if (flightTime == -1 || args.Flight.Aircraft != Aircraft.TailNumber)
            {
                return;
            }

            flightTime -= args.Flight.FlightTime;

            var cell = GetActiveCell() as AircraftTableViewCell;

            if (cell != null)
            {
                cell.FlightTime = flightTime;
                EmitChanged();
            }
        }
예제 #2
0
        void OnFlightUpdated(object sender, FlightEventArgs args)
        {
            if (flightTime == -1 || args.Flight.Aircraft != Aircraft.TailNumber)
            {
                return;
            }

            var cell = GetActiveCell() as AircraftTableViewCell;

            if (cell != null)
            {
                flightTime      = GetFlightTime(Aircraft);
                cell.FlightTime = flightTime;
                EmitChanged();
            }
            else
            {
                flightTime = -1;
            }
        }
예제 #3
0
        void OnFlightAdded(object sender, FlightEventArgs added)
        {
            FlightElement element = new FlightElement (added.Flight);

            element.Changed += OnFlightElementChanged;

            InsertFlightElement (element);
        }
예제 #4
0
        void OnFlightUpdated(object sender, FlightEventArgs e)
        {
            if (updating == null)
            {
                // The user probably just saved a flight which doesn't match the search criteria.
                Model.ReloadData();
                TableView.ReloadData();
                return;
            }

            // No matter what, reload the main model.
            Model.ReloadData();

            // Now update the UITableView that is currently being displayed.
            var tableView = CurrentTableView;
            var model     = ModelForTableView(tableView);

            // The date may have changed, which means the position may have changed.
            model.ReloadData();

            // Find the new position of the flight log entry.
            int index = model.IndexOf(e.Flight, this);
            int section, row;

            if (index == -1 || !model.IndexToSectionAndRow(index, out section, out row))
            {
                // The flight no longer exists in this model/view...
                if (loner)
                {
                    // The flight log entry was a 'loner', e.g. it was the only flight in its section.
                    var sections = NSIndexSet.FromIndex(updating.Section);
                    tableView.DeleteSections(sections, UITableViewRowAnimation.Automatic);
                    sections.Dispose();
                }
                else
                {
                    var rows = new NSIndexPath[1];
                    rows[0] = updating;

                    tableView.DeleteRows(rows, UITableViewRowAnimation.Automatic);
                }
            }
            else if (updating.Section != section || updating.Row != row)
            {
                // The flight changed position in the current table view - need to move it.
                var path = NSIndexPath.FromRowSection(row, section);
                tableView.MoveRow(updating, path);
                path.Dispose();
            }
            else
            {
                // Flight is in the same location, just needs to update its values...
                var rows = new NSIndexPath[1];
                rows[0] = updating;

                tableView.ReloadRows(rows, UITableViewRowAnimation.None);
            }

            // If the currently displayed UITableView isn't the main view, reset state of the main tableview.
            if (tableView != TableView)
            {
                TableView.ReloadData();
            }

            updating.Dispose();
            updating = null;
        }
예제 #5
0
        void OnFlightAdded(object sender, FlightEventArgs e)
        {
            var tableView = CurrentTableView;
            var model     = ModelForTableView(tableView);

            DetailsViewController.Flight = e.Flight;
            model.ReloadData();

            int index = model.IndexOf(e.Flight, this);

            if (index == -1)
            {
                // This suggests that we are probably displaying the search view and the
                // newly added flight log entry does not match the search criteria.

                // Just reload the original TableView...
                Model.ReloadData();
                TableView.ReloadData();
                return;
            }

            int section, row;

            if (!model.IndexToSectionAndRow(index, out section, out row))
            {
                // This shouldn't happen...
                model.ReloadData();
                tableView.ReloadData();
                return;
            }

            var path = NSIndexPath.FromRowSection(row, section);

            if (model.GetRowCount(section) == 1)
            {
                // The new flight entry is in a new section...
                var sections = NSIndexSet.FromIndex(section);
                tableView.InsertSections(sections, UITableViewRowAnimation.Automatic);
                sections.Dispose();
            }
            else
            {
                // Add the row for the new flight log entry...
                var rows = new NSIndexPath[1];
                rows[0] = path;

                tableView.InsertRows(rows, UITableViewRowAnimation.Automatic);
            }

            // Select and scroll to the newly added flight log entry...

            // From Apple's documentation:
            //
            // To scroll to the newly selected row with minimum scrolling, select the row using
            // selectRowAtIndexPath:animated:scrollPosition: with UITableViewScrollPositionNone,
            // then call scrollToRowAtIndexPath:atScrollPosition:animated: with
            // UITableViewScrollPositionNone.
            tableView.SelectRow(path, true, UITableViewScrollPosition.None);
            tableView.ScrollToRow(path, UITableViewScrollPosition.None, true);
            path.Dispose();
        }
예제 #6
0
 void FlightChanged(object sender, FlightEventArgs e)
 {
     dirty = true;
 }
예제 #7
0
 void FlightChanged(object sender, FlightEventArgs e)
 {
     dirty = true;
 }
예제 #8
0
        void OnFlightUpdated(object sender, FlightEventArgs args)
        {
            if (flightTime == -1 || args.Flight.Aircraft != Aircraft.TailNumber)
                return;

            var cell = GetActiveCell () as AircraftTableViewCell;
            if (cell != null) {
                flightTime = GetFlightTime (Aircraft);
                cell.FlightTime = flightTime;
                EmitChanged ();
            } else {
                flightTime = -1;
            }
        }
예제 #9
0
        void OnFlightDeleted(object sender, FlightEventArgs args)
        {
            if (flightTime == -1 || args.Flight.Aircraft != Aircraft.TailNumber)
                return;

            flightTime -= args.Flight.FlightTime;

            var cell = GetActiveCell () as AircraftTableViewCell;
            if (cell != null) {
                cell.FlightTime = flightTime;
                EmitChanged ();
            }
        }