public PolygonLineLayerSymbologyForm(LayerPropertyForm parent, MapLayer mapLayer)
 {
     InitializeComponent();
     _parentForm  = parent;
     _mapLayer    = mapLayer;
     _options     = ((Shapefile)_mapLayer.LayerObject).DefaultDrawingOptions;
     _shpFileType = ((Shapefile)_mapLayer.LayerObject).ShapefileType;
     LineWidthFix.FixLineWidth((Shapefile)_mapLayer.LayerObject);
 }
Exemple #2
0
        /// <summary>
        /// handles a shapefile added to the map using file open dialog
        /// </summary>
        /// <param name="sf"></param>
        /// <returns></returns>
        public int AddLayer(Shapefile sf, string layerName = "", bool isVisible = true, bool uniqueLayer = false, fad3MappingMode mappingMode = fad3MappingMode.defaultMode)
        {
            if (uniqueLayer)
            {
                RemoveLayer(layerName);
            }
            var h = _axmap.AddLayer(sf, isVisible);

            if (h >= 0)
            {
                if (layerName.Length == 0)
                {
                    layerName = Path.GetFileName(sf.Filename);
                }
                _axmap.set_LayerName(h, layerName);
                _currentMapLayer             = SetMapLayer(h, layerName, isVisible, true, sf.GeoProjection, "ShapefileClass", sf.Filename);
                _currentMapLayer.MappingMode = mappingMode;

                if (LayerRead != null)
                {
                    LayerEventArg lp = new LayerEventArg(h, layerName, true, true, _currentMapLayer.LayerType);
                    LayerRead(this, lp);
                }
                LineWidthFix.FixLineWidth(sf);
            }
            else
            {
                int reprojectedCount = 0;

                //if(sf.ReprojectInPlace(_axmap.GeoProjection,ref reprojectedCount))
                var sfr = sf.Reproject(_axmap.GeoProjection, reprojectedCount);
                if (reprojectedCount > 0)
                {
                    h = _axmap.AddLayer(sfr, isVisible);
                    if (h > 0)
                    {
                        if (layerName.Length == 0)
                        {
                            layerName = Path.GetFileName(sf.Filename);
                        }
                        _axmap.set_LayerName(h, layerName);
                        _currentMapLayer             = SetMapLayer(h, layerName, isVisible, true, sf.GeoProjection, "ShapefileClass", sf.Filename);
                        _currentMapLayer.MappingMode = mappingMode;

                        if (LayerRead != null)
                        {
                            LayerEventArg lp = new LayerEventArg(h, layerName, true, true, _currentMapLayer.LayerType);
                            LayerRead(this, lp);
                        }
                        LineWidthFix.FixLineWidth(sf);
                    }
                }
            }
            return(h);
        }
        private void GUI2Options(object sender, EventArgs e)
        {
            if (_noEvents)
            {
                return;
            }

            // fill
            _options.FillVisible = chkFill.Checked;
            _options.FillType    = (tkFillType)cboFillType.SelectedIndex;
            _options.FillColor   = Colors.ColorToUInteger(clpFillColor.Color);

            // hatch
            _options.FillHatchStyle    = (tkGDIPlusHatchStyle)icbHatchType.SelectedIndex;
            _options.FillBgTransparent = chkTransparentBackground.Checked;
            _options.FillBgColor       = Colors.ColorToUInteger(clpHatchBack.Color);

            // gradient
            _options.FillGradientType   = (tkGradientType)cboGradientType.SelectedIndex;
            _options.FillColor2         = Colors.ColorToUInteger(clpGradient2.Color);
            _options.FillRotation       = (double)udGradientRotation.Value;
            _options.FillGradientBounds = (tkGradientBounds)cboGradientBounds.SelectedIndex;

            // outline
            _options.LineStipple = (tkDashStyle)icbLineStyle.SelectedIndex;
            _options.LineWidth   = (float)icbLineWidth.SelectedIndex + 1;
            LineWidthFix.FixLineWidth((Shapefile)_mapLayer.LayerObject);

            _options.LineVisible = chkOutline.Checked;
            _options.LineColor   = Colors.ColorToUInteger(clpOutline.Color);

            // vertices
            _options.VerticesVisible     = chkVertices.Checked;
            _options.VerticesFillVisible = chkVerticesFillVisible.Checked;
            _options.VerticesSize        = (int)udVerticesSize.Value;
            _options.VerticesColor       = Colors.ColorToUInteger(clpVertexColor.Color);
            _options.VerticesType        = (tkVertexType)cboVerticesType.SelectedIndex;

            // transparency
            _options.LineTransparency = (float)transpOutline.Value;
            _options.FillTransparency = (float)transpFill.Value;

            btnApply.Enabled = true;

            DrawPreview();
        }
Exemple #4
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);
        }