Пример #1
0
		public void NewItemClicked(object sender, EventArgs e)
		{
			/*var jakt = new Jakt();
			var fieldScreen = new FieldStringScreen("Navn på jaktsted", screen => {
				jakt.Sted = screen.Value;
				JaktLoggApp.instance.SaveJaktItem(jakt);
				//Redirect user to the new jakt screen:
				var jaktItemScreen = new JaktItemScreen(jakt, screen2 => {
					JaktLoggApp.instance.SaveJaktItem(screen2.jakt);
					Refresh();
				});
				NavigationController.PushViewController(jaktItemScreen, true);
			});
			fieldScreen.Placeholder = "Skriv inn jaktsted";
			this.PresentModalViewController(fieldScreen, true);
			*/
			
			var jaktItemScreen = new JaktItemScreen(screen => {
					JaktLoggApp.instance.SaveJaktItem(screen.jakt);
					Refresh();
				});
			NavigationController.PushViewController(jaktItemScreen, true);
		}
Пример #2
0
		public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
		{
			var row = indexPath.Row;
			var section = indexPath.Section;
			
			var datelist = (from item in JaktList
								select item.DatoFra.Year).Distinct().ToList();
			var currentItems = JaktList.Where(l => l.DatoFra.Year == datelist.ElementAt(section));
			
			var jakt = currentItems.ElementAt(row);
			var jaktItemScreen = new JaktItemScreen(jakt, screen =>{
				_controller.Refresh();
			});
			_controller.NavigationController.PushViewController(jaktItemScreen, true);
		}
Пример #3
0
		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));
			}
		}
Пример #4
0
		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);
			
		}