public LoggerTableSource(LoggerScreen controller, List<Logg> logger) { _controller = controller; _logger = logger.OrderByDescending(l => l.Dato).ToList<Logg>(); datelist = (from logg in _logger select new DateTime(JaktLoggApp.instance.CurrentJakt.DatoFra.Year, logg.Dato.Month, logg.Dato.Day, logg.Dato.Hour, logg.Dato.Minute, logg.Dato.Second) .ToNorwegianDateString()).Distinct().ToList<string>(); }
public LoggerTableSource(LoggerScreen controller, List<Logg> logger) { _controller = controller; _logger = logger.OrderByDescending(l => l.Dato).ToList<Logg>(); datelist = (from logg in _logger select new DateTime(JaktLoggApp.instance.CurrentJakt.DatoFra.Year, logg.Dato.Month, logg.Dato.Day, logg.Dato.Hour, logg.Dato.Minute, logg.Dato.Second) .ToLocalDateString()).Distinct().ToList<string>(); foreach(var d in datelist){ headers.Add(new HeaderTableSection(d)); } //for the mapbutton headers.Add(new HeaderTableSection("")); }
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 JaktItemTableSource(JaktItemScreen controller, Jakt j) { _controller = controller; jakt = j; var sectionJakt = new SectionMapping("", ""); var sectionLogg = new SectionMapping("", " "); var sectionDetaljer = new SectionMapping("", ""); var sectionSlett = new SectionMapping("", ""); sectionJakt.Rows.Add(new RowItemMapping { Label = "Jaktsted", GetValue = () => { return jakt.Sted; }, RowSelected = () => { var fieldScreen = new FieldStringScreen("Jaktsted", screen => { jakt.Sted = screen.Value; _controller.Refresh(); }); fieldScreen.Placeholder = "Skriv inn jaktsted"; fieldScreen.Value = jakt.Sted; //autosuggest: var steder = (from x in JaktLoggApp.instance.JaktList where x.Sted != string.Empty select x.Sted.ToUpper()).Distinct(); var autosuggests = new List<ItemCount>(); foreach(var sted in steder){ autosuggests.Add(new ItemCount{ Name = sted, Count = JaktLoggApp.instance.JaktList.Where(y => y.Sted.ToUpper() == sted).Count() }); } fieldScreen.AutoSuggestions = autosuggests.OrderByDescending( o => o.Count ).ToList(); _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/signpost.png" }); sectionJakt.Rows.Add(new RowItemMapping { Label = "Jegere", GetValue = () => { var c = jakt.JegerIds.Count(); return c == 1 ? c + " jeger" : c + " jegere"; }, 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" }); sectionLogg.Rows.Add(new RowItemMapping { Label = "Loggføringer", GetValue = () => { var c = JaktLoggApp.instance.LoggList.Where(l => l.JaktId == jakt.ID).Count(); return c == 1 ? c + " loggføring" : c + " loggføringer"; }, 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 = "Dato fra", GetValue = () => { return jakt.DatoFra.ToNorwegianDateAndYearString(); }, 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 = "Dato"; _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/calendar.png" }); sectionDetaljer.Rows.Add(new RowItemMapping { Label = "Dato til", GetValue = () => { return jakt.DatoTil.ToNorwegianDateAndYearString(); }, 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 = "Dato til"; _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/calendar.png" }); sectionDetaljer.Rows.Add(new RowItemMapping { Label = "Jaktbilde", GetValue = () => { return jakt.ImagePath.Length > 0 ? "Vis / endre" : "Legg til"; }, RowSelected = () => { ShowImageView(); }, ImageFile = "Images/Icons/camera.png" }); sectionDetaljer.Rows.Add(new RowItemMapping { Label = "Notater", GetValue = () => { return jakt.Notes; }, RowSelected = () => { var fieldScreen = new FieldNotesScreen("Notater", screen => { jakt.Notes = screen.Value; _controller.Refresh(); }); fieldScreen.Value = jakt.Notes; _controller.NavigationController.PushViewController(fieldScreen, true); }, ImageFile = "Images/Icons/notepad.png" }); if(jakt.ID > 0){ sectionSlett.Rows.Add(new RowItemMapping { Label = "Slett jakt", GetValue = () => { return ""; } }); } if(sectionJakt.Rows.Count > 0) sections.Add(sectionJakt); if(sectionLogg.Rows.Count > 0) sections.Add(sectionLogg); if(sectionDetaljer.Rows.Count > 0) sections.Add(sectionDetaljer); if(sectionSlett.Rows.Count > 0) sections.Add(sectionSlett); }