private void OnMenuClick(object sender, RoutedEventArgs e) { switch (((MenuItem)sender).Name) { case "menuAOIZoom": if (_aoi != null) { MapWindowManager.ZoomToShapeFileExtent(_aoi.ShapeFile); } break; case "menuAOIEditExtent": if (_aoi != null) { _editingAOI = true; AOIManager.Edit(_aoi); buttonOk.IsEnabled = true; } break; case "menuAOIRemove": if (_aoi != null) { MapWindowManager.MapLayersHandler.RemoveLayer(_aoi.MapLayerHandle); } break; } }
private void OnMenuClick(object sender, RoutedEventArgs e) { switch (((MenuItem)sender).Name) { case "menuAOIDelete": break; case "menuFormatMap": bool proceed = false; foreach (var aoi in Entities.AOIViewModel.GetAllAOI()) { if (aoi.GridIsLoaded && aoi.GridMapping.HasGriddedData) { proceed = true; break; } } if (!proceed) { MessageBox.Show("There is no gridded map", "GPXC Manager", MessageBoxButton.OK, MessageBoxImage.Information); } else { FormatGridMapWindow fmw = FormatGridMapWindow.GetInstance(_aoi); if (fmw.Visibility == Visibility.Visible) { fmw.BringIntoView(); } else { fmw.Owner = this; fmw.Show(); } } break; case "menuEditGrid": MakeGrid(); menuEditGrid.IsEnabled = false; menuShowGrid.IsEnabled = false; menuRemoveGrid.IsEnabled = true; break; case "menuGridMapping": ShowGridMappingWindow(); break; case "menuAOIZoom": if (_aoi != null) { MapWindowManager.ZoomToShapeFileExtent(_aoi.ShapeFile); } break; case "menuAOIEditExtent": if (_aoi != null) { _editingAOI = true; AOIManager.Edit(_aoi); buttonOk.IsEnabled = true; } break; case "menuRemoveGrid": if (_aoi != null) { //MapWindowManager.MapLayersHandler.RemoveLayer(_aoi.MapLayerHandle); MapWindowManager.MapLayersHandler.RemoveLayer(_aoi.GridLayerName); _aoi.GridIsLoaded = false; menuRemoveGrid.IsEnabled = false; menuShowGrid.IsEnabled = !_aoi.GridIsLoaded; menuEditGrid.IsEnabled = !_aoi.GridIsLoaded; SetDataGridContext(); } break; case "menuShowGrid": if (_aoi.GridFileName != null && _aoi.GridFileName.Length > 0 && File.Exists(_aoi.GridFileName)) { var files = Entities.AOIViewModel.GetAOISubGridFileNames(_aoi); if (files.Count > 1) { var selectedFile = ""; SelectGridFileWindow sgw = new SelectGridFileWindow(); sgw.GridFiles = files; if ((bool)sgw.ShowDialog()) { selectedFile = sgw.SelectedFile; menuGridMapping.IsEnabled = _aoi.CreateGridFromFileName(selectedFile); } } else { menuGridMapping.IsEnabled = _aoi.CreateGridFromFileName(_aoi.GridFileName); } } else { MakeGrid(); } SetDataGridContext(); menuShowGrid.IsEnabled = !_aoi.GridIsLoaded; menuEditGrid.IsEnabled = menuShowGrid.IsEnabled; menuRemoveGrid.IsEnabled = _aoi.GridIsLoaded; break; } }