void EditPerimeter(Perimeter perimeter)
 {
     try
     {
         var locationGeoRect = (GeoRect)Scenario.Location.GeoRect;
         MapViewModel.EditablePolygonOverlayViewModel.GeoArray = (GeoArray)((GeoArray)perimeter).Closed;
         MapViewModel.EditablePolygonOverlayViewModel.IsVisible = true;
         MapViewModel.EditablePolygonOverlayViewModel.LocationBounds = locationGeoRect;
         MapViewModel.EditablePolygonOverlayViewModel.AreCrossingSegmentsAllowed = false;
         perimeter.RemoveMapLayers();
         foreach (var platform in Scenario.Platforms.Where(platform => (platform.Perimeter!=null && platform.Perimeter.Guid == perimeter.Guid))) platform.RemoveMapLayers();
         Globals.VisualizerService.ShowWindow("CreateOrEditPerimeterView",
                                new CreateOrEditPerimeterViewModel { EditablePolygonOverlayViewModel = MapViewModel.EditablePolygonOverlayViewModel, PerimeterName = perimeter.Name, DialogTitle = "Edit perimeter" },
                                true,
                                (sender, args) =>
                                {
                                    MapViewModel.EditablePolygonOverlayViewModel.IsVisible = false;
                                    var vm = (CreateOrEditPerimeterViewModel)args.State;
                                    if (!vm.IsCanceled)
                                    {
                                        perimeter.SetPerimeterCoordinates(MapViewModel.EditablePolygonOverlayViewModel.GeoArray);
                                        perimeter.Name = vm.PerimeterName;
                                    }
                                    perimeter.UpdateMapLayers();
                                    foreach (var platform in Scenario.Platforms.Where(platform => (platform.Perimeter!=null && platform.Perimeter.Guid == perimeter.Guid))) platform.UpdateMapLayers();
                                });
         OnPropertyChanged("IsSaveScenarioCommandEnabled");
     }
     catch (Exception e) { Globals.MessageBoxService.ShowError(e.Message); }
 }