/// <summary> /// Removes a layer using layer handle and raises a Layer removed event. /// </summary> /// <param name="layerHandle"></param> public void RemoveLayer(int layerHandle) { try { MapLayerDictionary[layerHandle].Dispose(); MapLayerDictionary.Remove(layerHandle); _axmap.RemoveLayer(layerHandle); _axmap.Redraw(); //fire the layer deleted event if (LayerRemoved != null) { LayerEventArg lp = new LayerEventArg(layerHandle, layerRemoved: true); LayerRemoved(this, lp); } //if the layer removed is the current layer, then make the current layer null if (CurrentMapLayer != null && layerHandle == _currentMapLayer.Handle) { _currentMapLayer = null; } } catch (KeyNotFoundException) { //ignore } catch (Exception ex) { Logger.Log(ex); } }
public void SetAsPointLayerFromDatabase(MapLayer ly) { ly.IsPointDatabaseLayer = true; List <int> forRemove = new List <int>(); foreach (MapLayer ml in MapLayerDictionary.Values) { if (ml.IsPointDatabaseLayer && ml.Handle != ly.Handle) { forRemove.Add(ml.Handle); } } if (forRemove.Count > 0) { foreach (var item in forRemove) { MapLayerDictionary.Remove(item); _axmap.RemoveLayer(item); } RefreshLayers(); } }
public bool RemoveLayerByKey(string layerKey) { if (LayerDictionary.Count > 0) { List <int> layerHandles = new List <int>(); int counter = 0; foreach (var item in LayerDictionary.Values) { if (item.LayerKey == layerKey) { layerHandles.Add(item.Handle); } } foreach (var h in layerHandles) { MapLayerDictionary[h].Dispose(); MapLayerDictionary.Remove(h); _axmap.RemoveLayer(h); if (LayerRemoved != null) { LayerEventArg lp = new LayerEventArg(h, layerRemoved: true); LayerRemoved(this, lp); } counter++; } if (counter > 0) { _axmap.Redraw(); } return(counter > 0); } return(false); }