/// <summary> /// gets the layer in the map and retrieves the corresponding layer item in the dictionary. Fires an event after a layer item is read /// </summary> public void ReadLayers() { for (int n = 0; n < _axmap.NumLayers; n++) { var h = _axmap.get_LayerHandle(n); if (_mapLayerDictionary.ContainsKey(h) && _mapLayerDictionary[h].VisibleInLayersUI) { //if there is a listener to the event if (LayerRead != null) { //get the corresponding layer item in the dictionary var item = _mapLayerDictionary[h]; //fill up the event argument class with the layer item LayerEventArg lp = new LayerEventArg(item.Handle, item.Name, item.Visible, item.VisibleInLayersUI, item.LayerType); LayerRead(this, lp); } } } }
/// <summary> /// handles editing of layer name and layer visibility /// </summary> /// <param name="layerHandle"></param> /// <param name="layerName"></param> /// <param name="visible"></param> /// <param name="isShown"></param> public void EditLayer(int layerHandle, string layerName, bool visible, bool isShown = true) { if (_mapLayerDictionary.ContainsKey(layerHandle)) { var ly = _mapLayerDictionary[layerHandle]; ly.Name = layerName; ly.Visible = visible; ly.VisibleInLayersUI = isShown; } _axmap.set_LayerName(layerHandle, layerName); _axmap.set_LayerVisible(layerHandle, visible); if (OnLayerVisibilityChanged != null) { LayerEventArg lp = new LayerEventArg(layerHandle); lp.LayerVisible = visible; OnLayerVisibilityChanged(this, lp); } _axmap.Redraw(); }
/// <summary> /// handles an image added to the map using file open dialog /// </summary> /// <param name="image"></param> /// <returns></returns> public int AddLayer(MapWinGIS.Image image, string layerName = "", bool isVisible = true) { var h = _axmap.AddLayer(image, isVisible); if (h >= 0) { if (layerName.Length == 0) { layerName = Path.GetFileName(image.Filename); } _axmap.set_LayerName(h, layerName); _currentMapLayer = SetMapLayer(h, layerName, isVisible, true, image.GeoProjection, "ImageClass", image.Filename); if (LayerRead != null) { LayerEventArg lp = new LayerEventArg(h, layerName, true, true, _currentMapLayer.LayerType); LayerRead(this, lp); } } return(h); }
/// <summary> /// handles shapefiles added to the map /// </summary> /// <param name="layer"></param> /// <param name="layerName"></param> /// <param name="visible"></param> /// <param name="showInLayerUI"></param> /// <param name="layerHandle"></param> /// <returns></returns> public int AddLayer(object layer, string layerName, bool visible, bool showInLayerUI, string fileName = "", fad3MappingMode mappingMode = fad3MappingMode.defaultMode) { int h = 0; GeoProjection gp = new GeoProjection(); var layerType = layer.GetType().Name; switch (layerType) { case "ShapefileClass": h = _axmap.AddLayer((Shapefile)layer, visible); gp = ((Shapefile)layer).GeoProjection; LineWidthFix.FixLineWidth((Shapefile)layer); break; case "ImageClass": h = _axmap.AddLayer((MapWinGIS.Image)layer, visible); gp = ((MapWinGIS.Image)layer).GeoProjection; break; case "GridClass": h = _axmap.AddLayer((Grid)layer, visible); gp = _axmap.GeoProjection; break; } _axmap.set_LayerName(h, layerName); _currentMapLayer = SetMapLayer(h, layerName, visible, showInLayerUI, gp, layerType, fileName); _currentMapLayer.MappingMode = mappingMode; if (LayerRead != null) { LayerEventArg lp = new LayerEventArg(h, layerName, visible, showInLayerUI, _currentMapLayer.LayerType); LayerRead(this, lp); } return(h); }
private void OnVisibilityExpression(MapLayersHandler s, LayerEventArg e) { txtVisibilityExpression.Text = e.VisibilityExpression; }
private void OnGrid25LayerSaved(Grid25MajorGrid s, LayerEventArg e) { _savedGridLayers.Add(e); }
private void OnGrid25GridRetrieved(Grid25MajorGrid s, LayerEventArg e) { txtMapTitle.Text = e.MapTitle; }
private void OnGridInPanelCreated(Grid25MajorGrid s, LayerEventArg e) { txtMapTitle.Text = e.LayerName; }
/// <summary> /// Event fired when a layer was selected in the layers form /// </summary> /// <param name="s"></param> /// <param name="e"></param> private void OnCurrentLayer(MapLayersHandler s, LayerEventArg e) { _currentMapLayer = MapInterActionHandler.MapLayersHandler.CurrentMapLayer; DisplayAttributes(); }
private void OnCurrentMapLayer(MapLayersHandler s, LayerEventArg e) { _currentMapLayer = _mapLayersHandler.get_MapLayer(e.LayerHandle); }
private void OnMapLayerRead(MapLayersHandler s, LayerEventArg e) { }
/// <summary> /// Receives the extent made by selection box or a click select to select shapes in a shapefile using intersection. /// Afterwards, a Selection event is raised /// </summary> /// <param name="selectExtents"></param> /// <param name="selectionFromSelectBox"></param> private void Select(Extents selectExtents, bool selectionFromSelectBox = false) { if (_currentMapLayer != null) { _selectedShapeIndexes = null; _selectionFromSelectBox = selectionFromSelectBox; if (_currentMapLayer.LayerType == "ShapefileClass") { var sf = _axMap.get_Shapefile(_currentMapLayer.Handle); if (sf != null) { _currentMapLayer.SelectedIndexes = null; sf.SelectNone(); sf.SelectionAppearance = tkSelectionAppearance.saDrawingOptions; switch (sf.ShapefileType) { case ShpfileType.SHP_POINT: if (sf.Categories.Count > 0) { sf.SelectionAppearance = tkSelectionAppearance.saSelectionColor; } else { sf.SelectionAppearance = tkSelectionAppearance.saDrawingOptions; sf.SelectionDrawingOptions.PointSize = sf.DefaultDrawingOptions.PointSize; sf.SelectionDrawingOptions.PointRotation = sf.DefaultDrawingOptions.PointRotation; sf.SelectionDrawingOptions.PointShape = sf.DefaultDrawingOptions.PointShape; } break; case ShpfileType.SHP_POLYGON: break; case ShpfileType.SHP_POLYLINE: break; } var objSelection = new object(); if (sf.SelectShapes(selectExtents, 0, SelectMode.INTERSECTION, ref objSelection)) { _selectedShapeIndexes = (int[])objSelection; _currentMapLayer.SelectedIndexes = _selectedShapeIndexes; for (int n = 0; n < _selectedShapeIndexes.Length; n++) { sf.ShapeSelected[_selectedShapeIndexes[n]] = true; } if (ShapesSelected != null) { var lyArg = new LayerEventArg(_currentMapLayer.Handle, _selectedShapeIndexes); ShapesSelected(this, lyArg); } } _axMap.Redraw(); EventHandler handler = Selection; if (handler != null) { handler(this, EventArgs.Empty); } } } else if (_currentMapLayer.LayerType == "ImageClass") { } } }
private void OnLayerNameUpdated(MapLayersHandler s, LayerEventArg e) { layerGrid[_layerCol, _layerRow].Value = e.LayerName; }