/// <summary> /// Validate whether the new (temp) geometry can be saved - is it valid? /// </summary> /// <returns>valid/not valid</returns> private bool CanSaveNewGeom() { if (GeometryType == "Punkt") { return(TempCoordinates.Count > 0); } else if (GeometryType == "Linie") { return(TempCoordinates.Count > 1); } else { var isValid = MapModel.CheckValidityOfPolygon(TempCoordinates); if (TempCoordinates.Count <= 3) { CurrentPolygonSelfIntersecting = false; } if (TempCoordinates.Count > 3 && isValid) { CurrentPolygonSelfIntersecting = false; return(true); } else { if (TempCoordinates.Count > 3) { if (!CurrentPolygonSelfIntersecting) //Polyon was not previously self-intersecting { CurrentPolygonSelfIntersecting = true; Device.BeginInvokeOnMainThread(async() => { bool ok = await App.Current.MainPage.DisplayAlert("Das aktuelle Polygon schneidet sich selbst", "Solange es eine ungültige Geometrie hat kann es nicht gespeichert werden", "Weiter zeichnen", "Rückgängig machen"); if (!ok) { try { TempCoordinates.RemoveAt(TempCoordinates.Count - 2); CurrentPolygonSelfIntersecting = false; MessagingCenter.Send <MapPageVM>(this, "ShapeDrawingUndone"); SaveGeomCommand.ChangeCanExecute(); } catch (Exception e) { Console.WriteLine("Had a problem undoing the shape: " + e.Message); } } }); } } return(false); } } }