private bool HandleLayerMenu(string itemKey) { switch (itemKey) { case MenuKeys.AddWmsLayer: { var model = new WmsCapabilitiesModel(_context.Repository); _context.Container.Run <WmsCapabilitiesPresenter, WmsCapabilitiesModel>(model); return(true); } case MenuKeys.AddDatabaseLayer: var connection = _databaseService.PromptUserForConnection(); if (connection != null) { using (var ds = new VectorDatasource()) { var model = new DatabaseLayersModel(ds, connection); _context.Container.Run <DatabaseLayersPresenter, DatabaseLayersModel>(model); } } return(true); case MenuKeys.AddLayer: _layerService.AddLayer(DataSourceType.All); return(true); case MenuKeys.AddRasterLayer: _layerService.AddLayer(DataSourceType.Raster); return(true); case MenuKeys.AddVectorLayer: _layerService.AddLayer(DataSourceType.Vector); return(true); case MenuKeys.LayerClearSelection: var layer = _context.Legend.SelectedLayer; if (layer != null && layer.FeatureSet != null) { layer.FeatureSet.ClearSelection(); _context.Map.Redraw(); } return(true); case MenuKeys.ClearLayers: if (MessageService.Current.Ask("Do you wan't to remove all layers from the map?")) { _context.Legend.Layers.Clear(); } return(true); } return(false); }
private void OpenLayerClicked() { if (_layerService.AddLayer(DataSourceType.All)) { View.Close(); } }
public override void RunCommand(LegendCommand command) { switch (command) { case LegendCommand.AddGroup: Legend.Groups.Add(); break; case LegendCommand.AddLayer: { int groupHandle = _legendDockPanel.SelectedGroupHandle; if (_layerService.AddLayer(DataSourceType.All) && groupHandle != -1) { int layerHandle = _layerService.LastLayerHandle; Legend.Layers.MoveLayer(layerHandle, groupHandle); } break; } case LegendCommand.GroupProperties: { int groupHandle = _legendDockPanel.SelectedGroupHandle; var group = Legend.Groups.ItemByHandle(groupHandle); if (group != null) { if (_context.Container.Run <LegendGroupPresenter, ILegendGroup>(group)) { Legend.Redraw(); } } break; } case LegendCommand.ZoomToGroup: { var group = Legend.Groups.ItemByHandle(_legendDockPanel.SelectedGroupHandle); if (group != null) { var box = group.Envelope; _context.Map.ZoomToExtents(box); } break; } case LegendCommand.RemoveGroup: { var group = Legend.Groups.ItemByHandle(_legendDockPanel.SelectedGroupHandle); if (group != null) { if (MessageService.Current.Ask("Do you want to remove group: " + group.Text + "?")) { Legend.Groups.Remove(group.Handle); } } break; } case LegendCommand.Labels: { var layer = _context.Legend.Layers.Current; if (layer != null && layer.IsVector) { _broadcaster.BroadcastEvent(p => p.LayerLabelsClicked_, _context.Legend, new LayerEventArgs(layer.Handle)); } } break; case LegendCommand.TableEditor: { var layer = _context.Legend.Layers.Current; if (layer != null && layer.IsVector) { var args = new PluginMessageEventArgs(PluginMessages.ShowAttributeTable); _broadcaster.BroadcastEvent(t => t.MessageBroadcasted_, _context.Legend, args); } } break; case LegendCommand.ZoomToLayer: _context.Map.ZoomToLayer(_context.Legend.SelectedLayerHandle); break; case LegendCommand.RemoveLayer: _layerService.RemoveSelectedLayer(); break; case LegendCommand.Properties: _broadcaster.BroadcastEvent(p => p.LayerDoubleClicked_, Legend, new LayerEventArgs(Legend.SelectedLayerHandle)); break; case LegendCommand.SaveStyle: { var layer = Legend.Layers.Current; if (layer != null) { if (!LayerSerializationHelper.CheckFilename(layer.Filename)) { MessageService.Current.Info("Can not save settings for a non-disk based layer."); return; } LayerSerializationHelper.SaveSettings(layer); } break; } case LegendCommand.LoadStyle: { var layer = Legend.Layers.Current; if (layer != null) { if (!LayerSerializationHelper.CheckFilename(layer.Filename)) { MessageService.Current.Info("Can not load settings for a non-disk based layer."); return; } LayerSerializationHelper.LoadSettings(layer, _broadcaster, false); } _context.Legend.Redraw(LegendRedraw.LegendAndMap); } break; case LegendCommand.OpenFileLocation: { var layer = Legend.Layers.Current; if (layer != null && File.Exists(layer.Filename)) { Shared.PathHelper.OpenFolderWithExplorer(layer.Filename); } else { MessageService.Current.Warn("Failed to find file for the layer."); } break; } } }