예제 #1
0
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                ChangeVehicleCell cell = tableView.DequeueReusableCell(kCellIdentifier) as ChangeVehicleCell;

                if (cell == null)
                {
                    var views = NSBundle.MainBundle.LoadNib("ChangeVehicleCell", tableView, null);
                    cell = Runtime.GetNSObject(views.ValueAt(0)) as ChangeVehicleCell;
                    //cell.Layer.CornerRadius = 7.5f;
                    cell.Layer.BorderColor = UIColor.White.CGColor;
                    cell.Layer.BorderWidth = 0.5f;
                }

                cell.Tag = indexPath.Row;

                VehicleForDownloadWithImage dv = list [indexPath.Row];

                string imagePath     = dv.vehicle.thumbURL;
                string YearMakeModel = dv.vehicle.Year + " " + dv.vehicle.Make + " " + dv.vehicle.Model;
                string Price         = dv.vehicle.Price.ToString("C0").ToNullableString(string.Empty);

                cell.UpdateCell(YearMakeModel, dv.vehicle.StockNumber, dv.vehicle.VIN, Price);
                if (dv.image == null)
                {
                    dv.image = placeHolder;
                    if (!string.IsNullOrWhiteSpace(imagePath))
                    {
                        BeginDownloadingImage(dv, indexPath);
                    }
                }
                cell.ImageView.Image = dv.image;

                if (controller.selectedVehicleIds.Contains(dv.vehicle.BoostVehicleID))
                {
                    cell.Accessory = UITableViewCellAccessory.Checkmark;
                }
                else
                {
                    cell.Accessory = UITableViewCellAccessory.None;
                }

                return(cell);
            }
예제 #2
0
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                ChangeVehicleCell cell = tableView.DequeueReusableCell(kCellIdentifier) as ChangeVehicleCell;

                if (cell == null)
                {
                    var views = NSBundle.MainBundle.LoadNib("ChangeVehicleCell", tableView, null);
                    cell = Runtime.GetNSObject(views.ValueAt(0)) as ChangeVehicleCell;
                    //cell.Layer.CornerRadius = 7.5f;
                    cell.Layer.BorderColor = UIColor.White.CGColor;
                    cell.Layer.BorderWidth = 0.5f;
                }

                cell.Tag = indexPath.Row;

                VehicleWithImages vehicleWithImages = list [indexPath.Row];
                Vehicle           vehicle           = vehicleWithImages.vehicle;

                string imagePath = Graphics.GetImagePath(vehicle.ID);
                string thumbPath = "";

                foreach (Image img in vehicleWithImages.images.OrderBy(i => i.FileNumber))
                {
                    if (!string.IsNullOrWhiteSpace(img.FileName))
                    {
                        if (img.FileName.StartsWith("https://"))
                        {
                            thumbPath = img.FileName;
                            break;
                        }
                        else
                        {
                            thumbPath = Path.Combine(imagePath, "thumb_" + img.FileNumber + ".jpg");
                            if (File.Exists(thumbPath))
                            {
                                break;
                            }
                        }
                        thumbPath = "";                         //Thumb file does not exist - set to empty variable.
                    }
                }

                string MissingDealershipID = "";

                if (vehicle.DealershipID == null || vehicle.DealershipID == 0)
                {
                    MissingDealershipID = "(**)";
                }
                string YearMakeModel = vehicle.Year + " " + vehicle.Make + " " + vehicle.Model + " " + MissingDealershipID;
                string Price         = (vehicle.Price.HasValue) ? vehicle.Price.Value.ToString("C0").ToNullableString(string.Empty) : string.Empty;

                cell.UpdateCell(YearMakeModel, vehicle.StockNumber, vehicle.VIN, Price);
                if (string.IsNullOrWhiteSpace(thumbPath))
                {
                    cell.ImageView.Image = UIImage.FromBundle("nophoto.png");
                }
                else if (thumbPath.StartsWith("https://"))
                {
                    cell.ImageView.Image = Graphics.FromUrl(thumbPath);
                }
                else
                {
                    cell.ImageView.Image = UIImage.FromFile(thumbPath);
                }

                return(cell);
            }