/// <summary> /// Checks the block clicked. /// </summary> /// <returns>The block clicked.</returns> /// <param name="touchPos">Touch position.</param> public Block CheckBlockClicked(Position touchPos) { foreach (Block block in this.SelectedField.Blocks) { if (GeoHelper.IsInsideCoords(block.BoundingCoordinates, touchPos)) { return(block); } } return(null); }
/// <summary> /// Checks the field clicked. /// </summary> /// <returns>The field clicked.</returns> /// <param name="touchPos">Touch position.</param> public Field CheckFieldClicked(Position touchPos) { foreach (Field field in this.Fields) { if (GeoHelper.IsInsideCoords(field.BoundingCoordinates, touchPos)) { return(field); } } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="TreeWatch.MapViewModel"/> class. /// </summary> public MapViewModel() { this.fieldHelper = FieldHelper.Instance; this.fieldHelper.MapTapped += this.MapTapped; this.fieldHelper.FieldSelected += this.FieldSelected; this.fieldHelper.BlockSelected += this.BlockSelected; this.Fields = new ObservableCollection <Field>(new DBQuery <Field>(App.Database).GetAll()); this.selectedField = new Field("Dummy", new List <Position>(), new List <Block>()); foreach (Field f in this.Fields) { var whc = GeoHelper.CalculateBoundingBox(f.BoundingCoordinates); double rad = (whc.WidthInMeters > whc.HeightInMeters) ? whc.WidthInMeters : whc.HeightInMeters; rad *= 0.5; CrossGeofence.Current.StartMonitoring(new GeofenceCircularRegion(f.Name, whc.Center.Latitude, whc.Center.Longitude, rad) { NotifyOnStay = false, StayedInThresholdDuration = TimeSpan.FromMinutes(10) }); } }