private void AddLayerToMap(ILayerItem layer) { if (layer.AddedToMap) { _layerService.RemoveLayer(layer.Identity); } else { if (layer is IDatabaseLayerItem) { var item = layer as IDatabaseLayerItem; if (item.Loading) { MessageService.Current.Info("This layer is being added to the map."); return; } AddLayerToMapAsync(layer as IDatabaseLayerItem); } else { if (_layerService.AddLayerIdentity(layer.Identity)) { int handle = _layerService.LastLayerHandle; _context.Map.ZoomToLayer(handle); } } } }
private bool RestoreLayers(XmlProject project, out int selectedLayerHandle) { selectedLayerHandle = -1; if (!ValidateLayers(project)) { return(false); } var layers = _context.Map.Layers; int step = 0; int count = project.Layers.Count; foreach (var xmlLayer in project.Layers) { step++; FireProgressChanged(step, count, "Loading layer: " + xmlLayer.Name); if (xmlLayer.SkipLoading) { Logger.Current.Info("Layer loading was skipped: " + xmlLayer.Identity); continue; } if (_layerService.AddLayerIdentity(xmlLayer.Identity)) { int handle = _layerService.LastLayerHandle; var layer = layers.ItemByHandle(handle) as ILegendLayer; xmlLayer.RestoreLayer(layer, _broadcaster); if (xmlLayer.Selected) { selectedLayerHandle = handle; } } else if (_layerService.Aborted) { return(false); } } return(true); }