Beispiel #1
0
        /// <summary>
        /// Sorts the FeatureLayers according to the order of the given collection.
        /// </summary>
        /// <param name="collection">Collection to sort by.</param>
        public void MoveLayers(IMapLayerCollection collection)
        {
            int  reverseI = 0; // position in layers is reverse to position in collection
            bool moved    = false;

            for (int i = collection.Count - 1; i >= 0; i--)
            {
                IFeatureLayer mLayer = collection[i] as IFeatureLayer;
                if (mLayer != null)
                {
                    int index = _layers.FindIndex(f => ReferenceEquals(f.Layer, mLayer));
                    if (index != reverseI)
                    {
                        var layer = _layers[index];
                        _layers.Remove(layer);
                        _layers.Insert(reverseI, layer);
                        moved = true;
                    }

                    reverseI += 1; // non-FeatureLayers get ignored
                }
            }

            if (moved)
            {
                ChangeDataSource();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sorts the FeatureLayers according to the order of the given collection.
        /// </summary>
        /// <param name="collection">Collection to sort by.</param>
        public void MoveLayers(IMapLayerCollection collection)
        {
            int reverseI = 0; //position in layers is reverse to position in collection
            for (int i = collection.Count - 1; i >= 0; i--)
            {
                IFeatureLayer mLayer = collection[i] as IFeatureLayer;
                if (mLayer != null)
                {
                    int index = _layers.FindIndex(f => object.ReferenceEquals(f.Layer, mLayer));

                    if (index != reverseI)
                    {
                        var layer = _layers[index];
                        _layers.Remove(layer);
                        _layers.Insert(reverseI, layer);
                    }
                    reverseI += 1; //non-FeatureLayers get ignored
                }
            }
            ChangeDataSource();
        }
Beispiel #3
0
        public override void Run()
        {
            ILegendItem selectedItem = (GIS.FrameWork.Application.App.Legend as GIS.Common.Dialogs.Legend).SelectedLegendMenuItem;

            if (selectedItem != null && selectedItem is MapFrame)
            {
                //get max extent from maplayercollection
                IMapLayerCollection _layers = GIS.FrameWork.Application.App.Map.Layers;
                Extent         ext          = null;
                IList <ILayer> layers       = _layers.Cast <ILayer>().ToList();
                if (layers != null)
                {
                    foreach (ILayer layer in layers)
                    {
                        if (layer.Extent != null && !layer.Extent.IsEmpty()) // changed by jany (2015-07-17) don't add extents of empty layers, because they cause a wrong overall extent
                        {
                            if (ext == null)
                            {
                                ext = (Extent)layer.Extent.Clone();
                            }
                            else
                            {
                                ext.ExpandToInclude(layer.Extent);
                            }
                        }
                    }
                }
                //calculate expands
                double eps    = 1e-7;
                var    maxExt = ext.Width < eps || ext.Height < eps
                    ? new Extent(ext.MinX - eps, ext.MinY - eps, ext.MaxX + eps, ext.MaxY + eps)
                    : ext;
                maxExt.ExpandBy(maxExt.Width / 10, maxExt.Height / 10);

                GIS.FrameWork.Application.App.Map.ViewExtents = maxExt;
            }
        }
        public static IFeatureLayer GetFeatureLayer(
            IMapLayerCollection pMapLayerCollection,
            FeatureSet pFeatureSet,
            string pName,
            Object pSymbolizer,
            ProjectionInfo pProjection)
        {
            IFeatureLayer mLayer;

            if (pFeatureSet.FeatureType == DotSpatial.Topology.FeatureType.Point)
            {
                mLayer = (PointLayer)pMapLayerCollection.Add(pFeatureSet);
                ((PointLayer)mLayer).Symbolizer = (PointSymbolizer)pSymbolizer;
                ((PointLayer)mLayer).LegendText = pName;
            }
            else if (pFeatureSet.FeatureType == DotSpatial.Topology.FeatureType.Line)
            {
                mLayer = (LineLayer)pMapLayerCollection.Add(pFeatureSet);
                ((LineLayer)mLayer).Symbolizer = (LineSymbolizer)pSymbolizer;
                ((LineLayer)mLayer).LegendText = pName;
            }
            else if (pFeatureSet.FeatureType == DotSpatial.Topology.FeatureType.Polygon)
            {
                mLayer = (PolygonLayer)pMapLayerCollection.Add(pFeatureSet);
                ((PolygonLayer)mLayer).Symbolizer = (PolygonSymbolizer)pSymbolizer;
                ((PolygonLayer)mLayer).LegendText = pName;
            }
            else
            {
                mLayer = null;
            }

            mLayer.Projection = pProjection;

            return(mLayer);
        }