Example #1
0
        public void VisibilityExpression(string expression, VisibilityExpressionTarget expressiontarget)
        {
            if (expressiontarget == VisibilityExpressionTarget.ExpressionTargetLabel)
            {
                _currentMapLayer.LabelsVisibilityExpression = expression;
            }
            else
            {
                _currentMapLayer.ShapesVisibilityExpression = expression;
            }

            if (OnVisibilityExpressionSet != null)
            {
                //fill up the event argument class with the layer item
                LayerEventArg lp = new LayerEventArg(_currentMapLayer.Handle, expressiontarget, expression);
                OnVisibilityExpressionSet(this, lp);
            }
        }
Example #2
0
        /// <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();
        }
Example #3
0
        /// <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);
                    }
                }
            }
        }
Example #4
0
        /// <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);
        }
Example #5
0
        /// <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);
        }
Example #6
0
        /// <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")
                {
                }
            }
        }