public ArtTableSource(ArtScreen controller, Art j) { _controller = controller; _art = j; CellDelete = new CellDeleteButton(HandleDeleteButtonTouchUpInside); NSBundle.MainBundle.LoadNib("CellDeleteButton", CellDelete, null); delcell = CellDelete.Cell; var sectionArt = new SectionMapping("", ""); var sectionSlett = new SectionMapping("", ""); sections.Add(sectionArt); sections.Add(sectionSlett); sectionArt.Rows.Add(new RowItemMapping { Label = Utils.Translate("specie.name"), GetValue = () => { return _art.Navn; }, RowSelected = () => { var fieldScreen = new FieldStringScreen(Utils.Translate("specie.name"), screen => { _art.Navn = Utils.UppercaseFirst(screen.Value); _controller.Refresh(); }); fieldScreen.Value = _art.Navn; _controller.NavigationController.PushViewController(fieldScreen, true); } }); sectionArt.Rows.Add(new RowItemMapping { Label = Utils.Translate("specie.wikiword"), GetValue = () => { return _art.Wikinavn; }, RowSelected = () => { var fieldScreen = new FieldStringScreen(Utils.Translate("specie.wikiword"), screen => { _art.Wikinavn = screen.Value; _controller.Refresh(); }); fieldScreen.Value = _art.Wikinavn; _controller.NavigationController.PushViewController(fieldScreen, true); } }); if(!_controller.IsNewItem){ sectionSlett.Rows.Add(new RowItemMapping { Label = Utils.Translate("specie.delete"), GetValue = () => { return ""; } }); } }
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { var cell = tableView.DequeueReusableCell("JegerTableCell"); if(cell == null) cell = new UIJaktTableViewCell(UITableViewCellStyle.Value1, "JegerTableCell"); if(GetCellLabel(indexPath.Section, indexPath.Row) == "Slett jeger") { var CellDelete = new CellDeleteButton(HandleDeleteButtonTouchUpInside); cell = tableView.DequeueReusableCell("CellDeleteButton"); if(cell == null) { NSBundle.MainBundle.LoadNib("CellDeleteButton", CellDelete, null); CellDelete.ButtonText = GetCellLabel(indexPath.Section, indexPath.Row); CellDelete.LoadGUI(); cell = CellDelete.Cell; } tableView.SeparatorStyle = UITableViewCellSeparatorStyle.None; } else { cell.TextLabel.Text = GetCellLabel(indexPath.Section, indexPath.Row); cell.DetailTextLabel.Text = GetCellValue(indexPath.Section, indexPath.Row); cell.Accessory = UITableViewCellAccessory.DisclosureIndicator; string imgpath = GetImageFile(indexPath.Section, indexPath.Row); if(cell.TextLabel.Text == "Profilbilde"){ var picturefile = Utils.GetPath("jeger_"+_jeger.ID+".jpg"); if(File.Exists(picturefile)) imgpath = picturefile; } cell.ImageView.Image = new UIImage(imgpath); } return cell; }
public JegerItemTableSource(JegerScreen controller, Jeger j) { _controller = controller; _jeger = j; CellDelete = new CellDeleteButton(HandleDeleteButtonTouchUpInside); NSBundle.MainBundle.LoadNib("CellDeleteButton", CellDelete, null); delcell = CellDelete.Cell; headerJegerView = new HeaderJeger(_jeger); headerJegerView.HandleButtonImageTouchUpInside = HandleButtonImageTouchUpInside; var sectionJeger = new SectionMapping("", ""); var sectionSlett = new SectionMapping("", ""); sections.Add(sectionJeger); sections.Add(sectionSlett); sectionJeger.Rows.Add(new RowItemMapping { Label = Utils.Translate("jeger.firstname"), GetValue = () => { return _jeger.Fornavn; }, RowSelected = () => { var fieldScreen = new FieldStringScreen(Utils.Translate("jeger.firstname"), screen => { _jeger.Fornavn = Utils.UppercaseFirst(screen.Value); _controller.Refresh(); }); fieldScreen.Value = _jeger.Fornavn; _controller.NavigationController.PushViewController(fieldScreen, true); } }); sectionJeger.Rows.Add(new RowItemMapping { Label = Utils.Translate("jeger.lastname"), GetValue = () => { return _jeger.Etternavn; }, RowSelected = () => { var fieldScreen = new FieldStringScreen(Utils.Translate("jeger.lastname"), screen => { _jeger.Etternavn = Utils.UppercaseFirst(screen.Value); _controller.Refresh(); }); fieldScreen.Value = _jeger.Etternavn; _controller.NavigationController.PushViewController(fieldScreen, true); } }); /* sectionJeger.Rows.Add(new RowItemMapping { Label = "Telefon", GetValue = () => { return _jeger.Phone; }, RowSelected = () => { var fieldScreen = new FieldStringScreen("Telefon", screen => { _jeger.Phone = screen.Value; _controller.Refresh(); }); fieldScreen.Value = _jeger.Phone; fieldScreen.KeyboardType = UIKeyboardType.PhonePad; _controller.NavigationController.PushViewController(fieldScreen, true); } });*/ sectionJeger.Rows.Add(new RowItemMapping { Label = Utils.Translate("jeger.profilepicture"), GetValue = () => { return _jeger.ImagePath.Length > 0 ? Utils.Translate("picture.showimage") : Utils.Translate("picture.addimage"); }, RowSelected = () => { ShowImageView(); }, ImageFile = "Images/Icons/camera.png" }); sectionJeger.Rows.Add(new RowItemMapping { Label = Utils.Translate("jeger.email"), GetValue = () => { return _jeger.Email; }, RowSelected = () => { var fieldScreen = new FieldStringScreen("E-post", screen => { _jeger.Email = screen.Value; _controller.Refresh(); }); fieldScreen.Value = _jeger.Email; fieldScreen.KeyboardType = UIKeyboardType.EmailAddress; _controller.NavigationController.PushViewController(fieldScreen, true); } }); if(!_controller.IsNewItem){ sectionSlett.Rows.Add(new RowItemMapping { Label = Utils.Translate("jeger.delete"), GetValue = () => { return ""; } }); } }
public JaktItemTableSource(JaktItemScreen controller, Jakt j) { _controller = controller; jakt = j; //instanciate views CellDelete = new CellDeleteButton(HandleDeleteButtonTouchUpInside); NSBundle.MainBundle.LoadNib("CellDeleteButton", CellDelete, null); delcell = CellDelete.Cell; headerView = new HeaderJakt(jakt); headerView.HandleButtonImageTouchUpInside = HandleButtonImageTouchUpInside; headerView.HandleButtonStedTouchUpInside = HandleButtonStedTouchUpInside; //sections and cells var sectionJakt = new SectionMapping("", ""); var sectionLogg = new SectionMapping("", " "); var sectionDetaljer = new SectionMapping("", ""); var sectionSlett = new SectionMapping("", ""); #region felter sectionJakt.Rows.Add(new RowItemMapping { Label = Utils.Translate("jakt.location"), GetValue = () => { return jakt.Sted; }, RowSelected = () => { ShowStedView(); }, ImageFile = "Images/Icons/signpost.png" }); sectionJakt.Rows.Add(new RowItemMapping { Label = Utils.Translate("jakt.hunters"), GetValue = () => { var c = jakt.JegerIds.Count(); return c == 1 ? c + " " + Utils.Translate("jakt.hunter").ToLower() : c + " " + Utils.Translate("jakt.hunters").ToLower(); }, RowSelected = () => { var jegerScreen = new JegerPickerScreen(jakt.JegerIds, screen => { jakt.JegerIds = screen.jegerIds; _controller.Refresh(); }); _controller.NavigationController.PushViewController(jegerScreen, true); }, ImageFile = "Images/Icons/Tabs/Jegere.png" }); sectionJakt.Rows.Add(new RowItemMapping { Label = Utils.Translate("jakt.dogs"), GetValue = () => { var c = jakt.DogIds.Count(); return c == 1 ? c + " " + Utils.Translate("jakt.dog").ToLower() : c + " " + Utils.Translate("jakt.dogs"); }, RowSelected = () => { dogScreen = new DogPickerScreen(jakt.DogIds, screen => { jakt.DogIds = screen.dogIds; _controller.Refresh(); }); _controller.NavigationController.PushViewController(dogScreen, true); }, ImageFile = "Images/Icons/Tabs/dog-paw.png" }); sectionLogg.Rows.Add(new RowItemMapping { Label = Utils.Translate("jakt.logs"), GetValue = () => { var c = JaktLoggApp.instance.LoggList.Where(l => l.JaktId == jakt.ID).Count(); return c == 1 ? c + " " + Utils.Translate("jakt.log").ToLower() : c + " " + Utils.Translate("jakt.logs"); }, RowSelected = () => { _controller.Refresh(); var loggerScreen = new LoggerScreen(jakt.ID); _controller.NavigationController.PushViewController(loggerScreen, true); }, ImageFile = "Images/Icons/Tabs/Jaktloggen.png" }); sectionDetaljer.Rows.Add(new RowItemMapping { Label = Utils.Translate("jakt.datefrom"), GetValue = () => { return jakt.DatoFra.ToLocalDateAndYearString(); }, RowSelected = () => { var fieldScreen = new FieldDatePickerScreen(screen => { jakt.DatoFra = screen.Date; if(jakt.DatoTil < jakt.DatoFra) jakt.DatoTil = jakt.DatoFra; _controller.Refresh(); }); fieldScreen.Date = jakt.DatoFra; fieldScreen.Mode = UIDatePickerMode.Date; fieldScreen.Title = Utils.Translate("jakt.datefrom"); _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/calendar.png" }); sectionDetaljer.Rows.Add(new RowItemMapping { Label = Utils.Translate("jakt.dateto"), GetValue = () => { return jakt.DatoTil.ToLocalDateAndYearString(); }, RowSelected = () => { var fieldScreen = new FieldDatePickerScreen(screen => { jakt.DatoTil = screen.Date; if(jakt.DatoFra > jakt.DatoTil) jakt.DatoFra = jakt.DatoTil; _controller.Refresh(); }); fieldScreen.Date = jakt.DatoTil; fieldScreen.Mode = UIDatePickerMode.Date; fieldScreen.Title = Utils.Translate("jakt.dateto"); _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/calendar.png" }); sectionDetaljer.Rows.Add(new RowItemMapping { Label = Utils.Translate("jakt.image"), GetValue = () => { return jakt.ImagePath.Length > 0 ? Utils.Translate("picture.showimage") : Utils.Translate("picture.addimage"); }, RowSelected = () => { ShowImageView(); }, ImageFile = "Images/Icons/camera.png" }); sectionDetaljer.Rows.Add(new RowItemMapping { Label = Utils.Translate("jakt.notes"), GetValue = () => { return jakt.Notes; }, RowSelected = () => { var fieldScreen = new FieldNotesScreen(Utils.Translate("jakt.notes"), screen => { jakt.Notes = screen.Value; _controller.Refresh(); }); fieldScreen.Value = jakt.Notes; _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/notepad.png" }); #endregion if(jakt.ID > 0){ sectionSlett.Rows.Add(new RowItemMapping { Label = Utils.Translate("jakt.delete"), GetValue = () => { return ""; } }); } if(sectionLogg.Rows.Count > 0) sections.Add(sectionLogg); if(sectionJakt.Rows.Count > 0) sections.Add(sectionJakt); if(sectionDetaljer.Rows.Count > 0) sections.Add(sectionDetaljer); if(sectionSlett.Rows.Count > 0) sections.Add(sectionSlett); foreach(var s in sections){ headers.Add(new HeaderTableSection(s.Header)); } }
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { var cell = tableView.DequeueReusableCell("LoggItemCell"); if(cell == null) cell = new UIJaktTableViewCell(UITableViewCellStyle.Value1, "LoggItemCell"); var lbl = GetCellLabel(indexPath.Section, indexPath.Row) ; if(lbl == "Slett loggføring") { var CellDelete = new CellDeleteButton(HandleDeleteButtonTouchUpInside); cell = tableView.DequeueReusableCell("CellDeleteButton"); if(cell == null) { NSBundle.MainBundle.LoadNib("CellDeleteButton", CellDelete, null); CellDelete.ButtonText = GetCellLabel(indexPath.Section, indexPath.Row); CellDelete.LoadGUI(); cell = CellDelete.Cell; } tableView.SeparatorStyle = UITableViewCellSeparatorStyle.None; } else { if(lbl == "Felt/sett vilt"){ cell = new UIJaktTableViewCell(UITableViewCellStyle.Subtitle, "LoggItemCellSubtitle"); } cell.TextLabel.Text = lbl; cell.DetailTextLabel.Text = GetCellValue(indexPath.Section, indexPath.Row); cell.Accessory = UITableViewCellAccessory.DisclosureIndicator; string imgpath = GetImageFile(indexPath.Section, indexPath.Row); if(cell.TextLabel.Text == "Bilde"){ var picturefile = Utils.GetPath("jaktlogg_"+loggItem.ID+".jpg"); if(File.Exists(picturefile)) imgpath = picturefile; } cell.ImageView.Image = new UIImage(imgpath); } return cell; }
public LoggItemTableSource(LoggItemScreen controller, Logg logg) { loggItem = logg; _controller = controller; //views CellDelete = new CellDeleteButton(HandleDeleteButtonTouchUpInside); NSBundle.MainBundle.LoadNib("CellDeleteButton", CellDelete, null); delcell = CellDelete.Cell; headerLoggItemView = new HeaderLoggItem(loggItem); headerLoggItemView.HandleButtonImageTouchUpInside = HandleButtonImageTouchUpInside; headerLoggItemView.HandleButtonDogTouchUpInside = HandleButtonDogTouchUpInside; headerLoggItemView.HandleButtonJegerTouchUpInside = HandleButtonJegerTouchUpInside; //Sections and cells var section1 = new SectionMapping("", ""); var section2 = new SectionMapping("", ""); var section3 = new SectionMapping("", ""); var sectionSlett = new SectionMapping("", ""); #region fields section1.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.results"), GetValue = () => { var lbl = ""; var art = JaktLoggApp.instance.GetArt(loggItem.ArtId); if(art != null) lbl = loggItem.Treff + " " + art.Navn + " / " + loggItem.Skudd + " " + Utils.Translate("shots"); else lbl = loggItem.Skudd + " "+ Utils.Translate("shots") +", " + loggItem.Treff + " "+ Utils.Translate("hits"); if(loggItem.Sett > 0) lbl += ", " + loggItem.Sett + " "+ Utils.Translate("seen") +" "; return lbl; }, RowSelected = () => { var fieldScreen = new FieldLoggCatch(Utils.Translate("log.header.results"), screen => { loggItem.ArtId = screen.CurrentArtId; loggItem.Treff = screen.CurrentHits; loggItem.Skudd = screen.CurrentShots; loggItem.Sett = screen.CurrentSeen; _controller.Refresh(); }); fieldScreen.CurrentArtId = loggItem.ArtId; fieldScreen.CurrentHits = loggItem.Treff; fieldScreen.CurrentShots = loggItem.Skudd; fieldScreen.CurrentSeen = loggItem.Sett; _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/target.png" }); section1.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.position"), GetValue = () => { return string.IsNullOrEmpty(loggItem.Latitude) ? "-" : Utils.Translate("log.viewinmap"); }, RowSelected = () => { var fieldScreen = new FieldLocationScreen(loggItem, screen => { loggItem.Latitude = screen.Latitude; loggItem.Longitude = screen.Longitude; _controller.Refresh(); }); fieldScreen.Latitude = loggItem.Latitude; fieldScreen.Longitude = loggItem.Longitude; _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/pin.png" }); /* * var jeger = new Jeger(); if(JaktLoggApp.instance.CurrentJakt.JegerIds.Count > 0) jeger = JaktLoggApp.instance.GetJeger(JaktLoggApp.instance.CurrentJakt.JegerIds[0]); * section1.Rows.Add(new RowItemMapping { Label = "Jeger", GetValue = () => { if(loggItem.JegerId == 0 && JaktLoggApp.instance.CurrentJakt.JegerIds.Count == 1){ loggItem.JegerId = jeger.ID; _controller.Refresh(); } else if(loggItem.JegerId == 0) return string.Empty; else jeger = JaktLoggApp.instance.GetJeger(loggItem.JegerId); return jeger.Navn; }, RowSelected = () => { ShowJegerView(); }, ImageFile = "Images/Icons/user.png" }); section1.Rows.Add(new RowItemMapping { Label = "Hund", GetValue = () => { if(loggItem.DogId == 0) return string.Empty; return JaktLoggApp.instance.GetDog(loggItem.DogId).Navn; }, RowSelected = () => { ShowDogView(); }, ImageFile = "Images/Icons/Tabs/dog-paw.png" }); */ section2.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.time"), GetValue = () => { return loggItem.Dato.ToLocalDateAndYearString(); }, RowSelected = () => { var fieldScreen = new FieldDatePickerScreen(screen => { loggItem.Dato = screen.Date; _controller.Refresh(); }); fieldScreen.Date = new DateTime(JaktLoggApp.instance.CurrentJakt.DatoFra.Year, loggItem.Dato.Month, loggItem.Dato.Day, loggItem.Dato.Hour, loggItem.Dato.Minute, loggItem.Dato.Second); fieldScreen.Mode = UIDatePickerMode.DateAndTime; fieldScreen.Title = Utils.Translate("log.header.time"); _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/calendar.png" }); section2.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.notes"), GetValue = () => { return loggItem.Notes; }, RowSelected = () => { var fieldScreen = new FieldNotesScreen(Utils.Translate("log.header.notes"), screen => { loggItem.Notes = screen.Value; _controller.Refresh(); }); fieldScreen.Value = loggItem.Notes; _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/notepad.png" }); /* section2.Rows.Add(new RowItemMapping { Label = "Bilde", GetValue = () => { return loggItem != null && loggItem.ImagePath.Length > 0 ? "Vis / endre" : "Legg til"; }, RowSelected = () => { ShowImageView(); }, ImageFile = "Images/Icons/camera.png" }); */ /*section3.Rows.Add(new RowItemMapping { Label = "Værforhold", GetValue = () => { return loggItem.Weather; }, RowSelected = () => { var options = new List<SingleSelectRowItem>(); options.Add(new SingleSelectRowItem(){ Key = "Sol", TextLabel = "Soll" }); options.Add(new SingleSelectRowItem(){ Key = "Overskyet", TextLabel = "Overskyet" }); options.Add(new SingleSelectRowItem(){ Key = "Regn", TextLabel = "Regn" }); var fieldScreen = new FieldSingleChoiceListScreen("Værforhold", options, screen => { loggItem.Weather = screen.SelectedKey; _controller.Refresh(); }); _controller.NavigationController.PushViewController(fieldScreen, true); } });*/ foreach(var selectedLoggTypeId in JaktLoggApp.instance.SelectedLoggTypeIds) { var item = JaktLoggApp.instance.LoggTypeList.SingleOrDefault(i => i.Key == selectedLoggTypeId); if(item == null) continue; switch(item.Key){ case "Weather": section3.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.weather"), GetValue = () => { return loggItem.Weather; }, RowSelected = () => { var fieldScreen = new FieldStringScreen(Utils.Translate("log.header.weather"), screen => { loggItem.Weather = screen.Value; _controller.Refresh(); }); fieldScreen.Placeholder = Utils.Translate("log.header.weather"); fieldScreen.Value = loggItem.Weather; //autosuggest: var autoitems = (from x in JaktLoggApp.instance.LoggList where x.Weather != string.Empty select x.Weather.ToUpper()).Distinct(); var autosuggests = new List<ItemCount>(); foreach(var autoitem in autoitems){ autosuggests.Add(new ItemCount{ Name = autoitem, Count = JaktLoggApp.instance.LoggList.Where(y => y.Weather.ToUpper() == autoitem).Count() }); } fieldScreen.AutoSuggestions = autosuggests.OrderByDescending( o => o.Count ).Take(15).ToList(); _controller.NavigationController.PushViewController(fieldScreen, true); } }); break; case "Gender": section3.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.gender"), GetValue = () => { return loggItem.Gender; }, RowSelected = () => { var options = new List<SingleSelectRowItem>(); options.Add(new SingleSelectRowItem(){ Key = Utils.Translate("log.gender.male"), TextLabel = Utils.Translate("log.gender.male") }); options.Add(new SingleSelectRowItem(){ Key = Utils.Translate("log.gender.female"), TextLabel = Utils.Translate("log.gender.female") }); var fieldScreen = new FieldSingleChoiceListScreen(Utils.Translate("log.header.gender"), options, screen => { loggItem.Gender = screen.SelectedKey; _controller.Refresh(); }); fieldScreen.SelectedKey = loggItem.Gender; _controller.NavigationController.PushViewController(fieldScreen, true); } }); break; case "Tags": section3.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.tags"), GetValue = () => { return loggItem.Tags == 0 ? "" : loggItem.Tags.ToString(); }, RowSelected = () => { var fieldScreen = new FieldNumberPickerScreen(screen => { loggItem.Tags = Int32.Parse(screen.Value); _controller.Refresh(); }); fieldScreen.Value = loggItem.Tags.ToString(); fieldScreen.Title = Utils.Translate("log.header.tags"); fieldScreen.LabelExtension = " " + Utils.Translate("log.tags"); _controller.NavigationController.PushViewController(fieldScreen, true); } }); break; case "Age": section3.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.largeage"), GetValue = () => { return loggItem.Age; }, RowSelected = () => { var options = new List<SingleSelectRowItem>(); options.Add(new SingleSelectRowItem(){ Key = Utils.Translate("log.kalv.name"), TextLabel = Utils.Translate("log.kalv.name") }); options.Add(new SingleSelectRowItem(){ Key = Utils.Translate("log.kalv.age1"), TextLabel = Utils.Translate("log.kalv.age1") }); options.Add(new SingleSelectRowItem(){ Key = Utils.Translate("log.kalv.age2"), TextLabel = Utils.Translate("log.kalv.age2") }); var fieldScreen = new FieldSingleChoiceListScreen(Utils.Translate("log.header.largeage"), options, screen => { loggItem.Age = screen.SelectedKey; _controller.Refresh(); }); fieldScreen.SelectedKey = loggItem.Age; controller.NavigationController.PushViewController(fieldScreen, true); } }); break; case "Weight": section3.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.weight"), GetValue = () => { return loggItem.Weight == 0 ? "" : loggItem.Weight + " kg"; }, RowSelected = () => { var fieldScreen = new FieldNumberPickerScreen(screen => { loggItem.Weight = Int32.Parse(screen.Value); _controller.Refresh(); }); fieldScreen.Value = loggItem.Weight.ToString(); fieldScreen.Title = Utils.Translate("log.header.weight"); fieldScreen.LabelExtension = " kg"; _controller.NavigationController.PushViewController(fieldScreen, true); } }); break; case "ButchWeight": section3.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.butchweight"), GetValue = () => { return loggItem.ButchWeight == 0 ? "" : loggItem.ButchWeight + " kg"; }, RowSelected = () => { var fieldScreen = new FieldNumberPickerScreen(screen => { loggItem.ButchWeight = Int32.Parse(screen.Value); _controller.Refresh(); }); fieldScreen.Value = loggItem.ButchWeight.ToString(); fieldScreen.Title = Utils.Translate("log.header.butchweight"); fieldScreen.LabelExtension = " kg"; _controller.NavigationController.PushViewController(fieldScreen, true); } }); break; case "WeaponType": section3.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.header.weapontype"), GetValue = () => { return loggItem.WeaponType; }, RowSelected = () => { var fieldScreen = new FieldStringScreen(Utils.Translate("log.header.weapontype"), screen => { loggItem.WeaponType = screen.Value; _controller.Refresh(); }); fieldScreen.Placeholder = Utils.Translate("log.writeweapontype"); fieldScreen.Value = loggItem.WeaponType; //autosuggest: var autoitems = (from x in JaktLoggApp.instance.LoggList where x.WeaponType != string.Empty select x.WeaponType.ToUpper()).Distinct(); var autosuggests = new List<ItemCount>(); foreach(var autoitem in autoitems){ autosuggests.Add(new ItemCount{ Name = autoitem, Count = JaktLoggApp.instance.LoggList.Where(y => y.WeaponType.ToUpper() == autoitem).Count() }); } fieldScreen.AutoSuggestions = autosuggests.OrderByDescending( o => o.Count ).ToList(); _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "" }); break; } } #endregion if(!_controller.IsNewItem){ sectionSlett.Rows.Add(new RowItemMapping { Label = Utils.Translate("log.delete"), GetValue = () => { return ""; } }); } sections.Add(section1); sections.Add(section2); if(section3.Rows.Count > 0) sections.Add(section3); sections.Add(sectionSlett); foreach(var s in sections){ headers.Add(new HeaderTableSection(s.Header)); } }
public DogItemTableSource(DogScreen controller, Dog j) { _controller = controller; _dog = j; //instanciate views CellDelete = new CellDeleteButton(HandleDeleteButtonTouchUpInside); NSBundle.MainBundle.LoadNib("CellDeleteButton", CellDelete, null); delcell = CellDelete.Cell; var sectionDog = new SectionMapping("", ""); var sectionSlett = new SectionMapping("", ""); sections.Add(sectionDog); sections.Add(sectionSlett); sectionDog.Rows.Add(new RowItemMapping { Label = Utils.Translate("dog.name"), GetValue = () => { return _dog.Navn; }, RowSelected = () => { var fieldScreen = new FieldStringScreen(Utils.Translate("dog.name"), screen => { _dog.Navn = Utils.UppercaseFirst(screen.Value); _controller.Refresh(); }); fieldScreen.Value = _dog.Navn; _controller.NavigationController.PushViewController(fieldScreen, true); } }); sectionDog.Rows.Add(new RowItemMapping { Label = Utils.Translate("dog.breed"), GetValue = () => { return _dog.Rase; }, RowSelected = () => { var fieldScreen = new FieldStringScreen(Utils.Translate("dog.breed"), screen => { _dog.Rase = Utils.UppercaseFirst(screen.Value); _controller.Refresh(); }); fieldScreen.Value = _dog.Rase; _controller.NavigationController.PushViewController(fieldScreen, true); } }); sectionDog.Rows.Add(new RowItemMapping { Label = Utils.Translate("dog.image"), GetValue = () => { return _dog.ImagePath.Length > 0 ? Utils.Translate("picture.showimage") : Utils.Translate("picture.addimage"); }, RowSelected = () => { ShowImageView(); }, ImageFile = "Images/Icons/camera.png" }); sectionDog.Rows.Add(new RowItemMapping { Label = Utils.Translate("dog.licencenr"), GetValue = () => { return _dog.Lisensnummer; }, RowSelected = () => { var fieldScreen = new FieldStringScreen(Utils.Translate("dog.licencenr"), screen => { _dog.Lisensnummer = screen.Value; _controller.Refresh(); }); fieldScreen.Value = _dog.Lisensnummer; _controller.NavigationController.PushViewController(fieldScreen, true); } }); if(!_controller.IsNewItem){ sectionSlett.Rows.Add(new RowItemMapping { Label = Utils.Translate("dog.delete"), GetValue = () => { return ""; } }); } }