//public EventHandler HandleButtonKartTouchUpInside; public HeaderJaktItem (Jakt jakt) : base("HeaderJaktItem", null) { _jakt = jakt; _loggItems = JaktLoggApp.instance.LoggList.Where(x => x.JaktId == _jakt.ID).ToList<Logg>(); _hasGeotaggedItems = _loggItems.Where(x => x.Latitude != "" && x.Longitude != "").ToList<Logg>().Count() > 0; }
// SAVE METHODS public void SaveJaktItem(Jakt item){ if(item.Sted == "") item.Sted = "Jakt " + item.DatoFra.ToNorwegianDateString(); JaktList = JaktList.OrderBy(o => o.ID).ToList<Jakt>(); var itemToUpdate = JaktList.Where(j=>j.ID == item.ID).FirstOrDefault(); if(itemToUpdate == null) { item.ID = JaktList.Count == 0 ? 1 : JaktList.Last().ID + 1; JaktList.Add(item); } else itemToUpdate = item; _repository.SaveJaktList(JaktList); }
public UploadScreen (Jakt _jakt) : base("UploadScreen", null) { jakt = _jakt; }
public JaktItemScreen (Jakt _jakt, Action<JaktItemScreen> callback) : base("JaktItemScreen", null) { jakt = _jakt; JaktLoggApp.instance.CurrentJakt = jakt; }
public JaktItemScreen (Action<JaktItemScreen> callback) : base("JaktItemScreen", null) { jakt = new Jakt(); IsNewItem = true; }
public void DeleteJakt(Jakt item){ var logglist = LoggList.Where(x => x.JaktId == item.ID).ToList<Logg>(); foreach(var logg in logglist){ DeleteLogg(logg); } DeleteFile(Utils.GetPath(item.ImagePath)); JaktList.Remove(item); _repository.SaveJaktList(JaktList); }
public ReportJakt (Jakt j) : base("ReportJakt", null) { jakt = j; }
public HeaderJakt (Jakt jakt) : base ("HeaderJakt", null) { _jakt = jakt; }
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); }