Esempio n. 1
0
        public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
        {
            if (isStopListSection(indexPath.Section))
            {
                //the section with all the stops
                UITableViewCell stopCell;
                BusStop         stop = allStops [indexPath.Row];

                //cells with distance
                if (closestCalculated && myLocation != null)
                {
                    stopCell = tableView.DequeueReusableCell("stopCellWithDistance");
                    double distanceFrom = myLocation.Distancefrom(stop.location);
                    distanceFrom *= 0.0006214;
                    stopCell.DetailTextLabel.Text = "" + Math.Round(distanceFrom, 3) + " mi";

                    //cell without distance
                }
                else
                {
                    stopCell = tableView.DequeueReusableCell("stopCellWithoutDistance");
                }

                //show checkmark on the bus cell if not on current location and this is the default stop
                if (UserPreferences.PreferCurrentLocation == false && stop.stopId == UserPreferences.DefaultStopId)
                {
                    stopCell.Accessory = UITableViewCellAccessory.Checkmark;
                }
                else
                {
                    stopCell.Accessory = UITableViewCellAccessory.None;
                }
                stopCell.TextLabel.Text = stop.name;

                return(stopCell);
            }
            else
            {
                //the section to select the nearest
                UITableViewCell closestCell = tableView.DequeueReusableCell("closestCell");

                //subtitle shows nearest stop
                closestCell.DetailTextLabel.Text = "Currently: " + allStops [0].name;

                //checkmark
                if (UserPreferences.PreferCurrentLocation)
                {
                    closestCell.Accessory = UITableViewCellAccessory.Checkmark;
                }
                else
                {
                    closestCell.Accessory = UITableViewCellAccessory.None;
                }
                return(closestCell);
            }
        }