Ejemplo n.º 1
0
		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 "";
					}
				});
			}
		}
Ejemplo n.º 2
0
		public UploadScreenTableSource(UploadScreen controller)
		{
			_controller = controller;
			
			var section1 = new SectionMapping("Tittel", "");
			var section2 = new SectionMapping("Velg mottakere", " ");
			var section3 = new SectionMapping("", " ");
			
			sections.Add(section1);
			sections.Add(section2);
			sections.Add(section3);
			
			section1.Rows.Add(new RowItemMapping {
				Label = "Undertittel på jaktboka",
				GetValue = () => {
					return "";
				},
				RowSelected = () => {
					var fieldScreen = new FieldStringScreen("Undertittel", screen => {
						//jakt.Sted = screen.Value;
						_controller.Refresh();
					});
					fieldScreen.Placeholder = "Undertittel";
					//fieldScreen.Value = jakt.Sted;
					_controller.NavigationController.PushViewController(fieldScreen, true);
				}
			});

			section3.Rows.Add(new RowItemMapping {
				Label = "Last opp data",
				GetValue = () => {
					return "";
				},
				RowSelected = () => {
					
					LoadingView.Show("Laster opp data...");
					//var response = UploadJakt();
					LoadingView.Hide();
					MessageBox.Show("Data lastet opp", "http://jaktloggen.no/Jaktbok/?jaktid="+_controller.jakt.ID);
					/*
					JaktLoggApp.instance.InitializeAllData(() => {
						InvokeOnMainThread(() => {
							
						});
					});*/
							
					
				}
			});
		}
Ejemplo n.º 3
0
		public JegerItemTableSource(JegerScreen controller, Jeger j)
		{
			_controller = controller;
			_jeger = j;
			
			var sectionJeger = new SectionMapping("", "");
			var sectionSlett = new SectionMapping("", "");
			
			sections.Add(sectionJeger);
			sections.Add(sectionSlett);
			
			sectionJeger.Rows.Add(new RowItemMapping {
				Label = "Fornavn",
				GetValue = () => {
					return _jeger.Fornavn;
				},
				RowSelected = () => {
					var fieldScreen = new FieldStringScreen("Fornavn", screen => {
						_jeger.Fornavn = Utils.UppercaseFirst(screen.Value);
						_controller.Refresh();
					}); 
					fieldScreen.Value = _jeger.Fornavn;
					_controller.NavigationController.PushViewController(fieldScreen, true);
				}
			});
			
			sectionJeger.Rows.Add(new RowItemMapping {
				Label = "Etternavn",
				GetValue = () => {
					return _jeger.Etternavn;
				},
				RowSelected = () => {
					var fieldScreen = new FieldStringScreen("Etternavn", 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 = "Profilbilde",
				GetValue = () => {
					return _jeger.ImagePath.Length > 0 ? "Vis / endre" : "Legg til";
				},
				RowSelected = () => {
					ShowImageView();
				},
				ImageFile = "Images/Icons/camera.png"
			});
			
			sectionJeger.Rows.Add(new RowItemMapping {
				Label = "E-post",
				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 = "Slett jeger",
					GetValue = () => {
						return "";
					}
				});
			}
		}
Ejemplo n.º 4
0
		private void ShowStedView(){
			var fieldScreen = new FieldStringScreen(Utils.Translate("jakt.location"), screen => {
				jakt.Sted = screen.Value;
				_controller.Refresh();
			});
			fieldScreen.Placeholder = Utils.Translate("jakt.setlocationname");
			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);
		}
Ejemplo n.º 5
0
		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 "";
					}
				});
			}
		}
Ejemplo n.º 6
0
		public LoggItemTableSource(LoggItemScreen controller)
		{
			var jeger = new Jeger();
			if(JaktLoggApp.instance.CurrentJakt.JegerIds.Count > 0)
				jeger = JaktLoggApp.instance.GetJeger(JaktLoggApp.instance.CurrentJakt.JegerIds[0]);
			
			_controller = controller;
			
			var section1 = new SectionMapping("", "");
			var section2 = new SectionMapping("", "");
			var section3 = new SectionMapping("Ekstra felter", "");
			var sectionSlett = new SectionMapping("", "");
			
			section1.Rows.Add(new RowItemMapping {
				Label = "Felt/sett vilt",
				GetValue = () => {
					var lbl = "";
					if(loggItem.ArtId > 0)
						lbl = loggItem.Treff + " " + JaktLoggApp.instance.GetArt(loggItem.ArtId).Navn + " på " + loggItem.Skudd + " skudd";
					else 
						lbl = loggItem.Skudd + " skudd, " + loggItem.Treff + " treff";
					
					if(loggItem.Sett > 0)
						lbl += ", " + loggItem.Sett + " sett ";
					
					return lbl;
				},
				RowSelected = () => {
					var fieldScreen = new FieldLoggCatch("Felt/sett vilt", 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 = "Posisjon",
				GetValue = () => {
					return string.IsNullOrEmpty(loggItem.Latitude) ? "Ikke satt" : "Se i kart";
				},
				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"
			});
			
			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 = () => {
					var jegerlist = CreateSingleSelectJegerItems();
					var fieldScreen = new FieldSingleChoiceListScreen("Velg jeger", jegerlist, screen => {
						loggItem.JegerId = screen.SelectedKey == "" ? 0 : Int32.Parse(screen.SelectedKey);
						_controller.Refresh();
					});
					fieldScreen.SelectedKey = loggItem.JegerId.ToString();
					_controller.NavigationController.PushViewController(fieldScreen, true);
				},
				ImageFile = "Images/Icons/user.png"
			});
			
			section2.Rows.Add(new RowItemMapping {
				Label = "Tidspunkt",
				GetValue = () => {
					return loggItem.Dato.Day + "/" + loggItem.Dato.Month + " " + loggItem.Dato.Hour +":"+loggItem.Dato.Minute;
				},
				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 = "Tidspunkt";
					_controller.NavigationController.PushViewController(fieldScreen, true);
				},
				ImageFile = "Images/Icons/calendar.png"
			});
			
			section2.Rows.Add(new RowItemMapping {
				Label = "Notater",
				GetValue = () => {
					return loggItem.Notes;
				},
				RowSelected = () => {
					var fieldScreen = new FieldNotesScreen("Notater", 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);
				switch(item.Navn){
					case "Vær":
					
						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 = "Sol" });
								options.Add(new SingleSelectRowItem(){ Key = "Delvis skyet", TextLabel = "Delvis skyet" });
								options.Add(new SingleSelectRowItem(){ Key = "Overskyet", TextLabel = "Overskyet" });
								options.Add(new SingleSelectRowItem(){ Key = "Regn", TextLabel = "Regn" });
								options.Add(new SingleSelectRowItem(){ Key = "Snø", TextLabel = "Snø" });
								var fieldScreen = new FieldSingleChoiceListScreen("Værforhold", options, screen => {
									loggItem.Weather = screen.SelectedKey;
									_controller.Refresh();
								});
							fieldScreen.SelectedKey = loggItem.Weather;
								_controller.NavigationController.PushViewController(fieldScreen, true);
							}
						
						});
					break;
					case "Kjønn":
					
						section3.Rows.Add(new RowItemMapping {
						Label = "Kjønn",
						GetValue = () => {
							return loggItem.Gender;
						},
						RowSelected = () => 
						{
							var options = new List<SingleSelectRowItem>();
							options.Add(new SingleSelectRowItem(){ Key = "Hannkjønn", TextLabel = "Hannkjønn" });
							options.Add(new SingleSelectRowItem(){ Key = "Hunnkjønn", TextLabel = "Hunnkjønn" });
							
							var fieldScreen = new FieldSingleChoiceListScreen("Kjønn", options, screen => {
								loggItem.Gender = screen.SelectedKey;
								_controller.Refresh();
							});
							fieldScreen.SelectedKey = loggItem.Gender;
							_controller.NavigationController.PushViewController(fieldScreen, true);
							}
						
						});
					break;
					
					case "Tagger":
					
						section3.Rows.Add(new RowItemMapping {
						Label = "Tagger på geviret",
						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 = "Antall tagger på gevir";
							fieldScreen.LabelExtension = " tagger";
							
							_controller.NavigationController.PushViewController(fieldScreen, true);
							}
						
						});
					break;
					
					case "Alder":
					
						section3.Rows.Add(new RowItemMapping {
						Label = "Alder",
						GetValue = () => {
							return loggItem.Age;
						},
						RowSelected = () => 
							{
								var options = new List<SingleSelectRowItem>();
								options.Add(new SingleSelectRowItem(){ Key = "Kalv", TextLabel = "Kalv" });
								options.Add(new SingleSelectRowItem(){ Key = "1 1/2 år", TextLabel = "1 1/2 år" });
								options.Add(new SingleSelectRowItem(){ Key = "2 1/2 år og eldre", TextLabel = "2 1/2 år og eldre" });
								
								var fieldScreen = new FieldSingleChoiceListScreen("Alder", options, screen => {
								loggItem.Age = screen.SelectedKey;
								_controller.Refresh();
								});
							fieldScreen.SelectedKey = loggItem.Age;
							controller.NavigationController.PushViewController(fieldScreen, true);
							
							}
						});
					break;
					
					case "Vekt":
					
						section3.Rows.Add(new RowItemMapping {
						Label = "Vekt",
						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 = "Vekt i kilo";
							fieldScreen.LabelExtension = " kg";
							_controller.NavigationController.PushViewController(fieldScreen, true);
							}
						
						});
					break;
					
					case "Slaktevekt":
					
						section3.Rows.Add(new RowItemMapping {
						Label = "Slaktevekt",
						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 = "Slaktevekt i kilo";
							fieldScreen.LabelExtension = " kg";
							_controller.NavigationController.PushViewController(fieldScreen, true);
							}
						
						});
					break;
					
					case "Våpentype":
					
						section3.Rows.Add(new RowItemMapping {
							Label = "Våpentype",
							GetValue = () => {
								return loggItem.WeaponType;
							},
							RowSelected = () => {
								var fieldScreen = new FieldStringScreen("Våpentype", screen => {
									loggItem.WeaponType = screen.Value;
									_controller.Refresh();
								});
								fieldScreen.Placeholder = "Skriv inn våpentype";
								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;
					
					case "Hund":
					
						section3.Rows.Add(new RowItemMapping {
							Label = "Hund",
							GetValue = () => {
								return loggItem.Dog;
							},
							RowSelected = () => {
								var fieldScreen = new FieldStringScreen("Hund", screen => {
									loggItem.Dog = screen.Value;
									_controller.Refresh();
								});
								fieldScreen.Placeholder = "Skriv inn hundenavn";
								fieldScreen.Value = loggItem.Dog;
								//autosuggest:
								var autoitems = (from x in JaktLoggApp.instance.LoggList
								              where x.Dog != string.Empty
											  select x.Dog.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.Dog.ToUpper() == autoitem).Count()
									});
								}
								fieldScreen.AutoSuggestions = autosuggests.OrderByDescending( o => o.Count ).ToList();          
								_controller.NavigationController.PushViewController(fieldScreen, true);
							},
							ImageFile = ""
						});
					
					break;
				}
			}
			
			
			if(!_controller.IsNewItem){
				sectionSlett.Rows.Add(new RowItemMapping {
					Label = "Slett loggføring",
					GetValue = () => {
						return "";
					}
				});
			}
			
			sections.Add(section1);
			sections.Add(section2);
			
			if(section3.Rows.Count > 0)
				sections.Add(section3);
			
			sections.Add(sectionSlett);
			
		}
Ejemplo n.º 7
0
		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));
			}
			
		}
Ejemplo n.º 8
0
		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 "";
					}
				});
			}
		}
Ejemplo n.º 9
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);
			
		}
Ejemplo n.º 10
0
		public FieldStringTableSource (FieldStringScreen tableViewController) 
		{
			_tableViewController = tableViewController;
		}