Ejemplo n.º 1
0
 private void ClearScales()
 {
     _tileSet.RemoveAllScales();
     if (_parent != null)
     {
         _parent.RemoveBaseMap();
     }
     _edSvc.MarkDirty();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes all finite display scales from the Map Definition
        /// </summary>
        /// <param name="map"></param>
        /// <param name="bDetachIfEmpty"></param>
        public static void RemoveAllFiniteDisplayScales(this IMapDefinition map, bool bDetachIfEmpty)
        {
            Check.NotNull(map, "map"); //NOXLATE

            if (map.BaseMap == null)
            {
                return;
            }

            map.BaseMap.RemoveAllScales();
            if (map.BaseMap.GroupCount == 0 && map.BaseMap.ScaleCount == 0 && bDetachIfEmpty)
            {
                map.RemoveBaseMap();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes the specified finite display scale from the Map Definition
        /// </summary>
        /// <param name="map"></param>
        /// <param name="scale"></param>
        /// <param name="bDetachIfEmpty"></param>
        public static void RemoveFiniteDisplayScale(this IMapDefinition map, double scale, bool bDetachIfEmpty)
        {
            Check.ArgumentNotNull(map, nameof(map));

            if (map.BaseMap == null)
            {
                return;
            }

            map.BaseMap.RemoveFiniteDisplayScale(scale);
            if (map.BaseMap.GroupCount == 0 && map.BaseMap.ScaleCount == 0 && bDetachIfEmpty)
            {
                map.RemoveBaseMap();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Removes the given base layer group from the Map Definition
        /// </summary>
        /// <param name="map"></param>
        /// <param name="group"></param>
        /// <param name="bDetachIfEmpty"></param>
        public static void RemoveBaseLayerGroup(this IMapDefinition map, IBaseMapGroup group, bool bDetachIfEmpty)
        {
            Check.NotNull(map, "map"); //NOXLATE
            if (null == group)
            {
                return;
            }

            if (map.BaseMap == null)
            {
                return;
            }

            map.BaseMap.RemoveBaseLayerGroup(group);
            if (map.BaseMap.GroupCount == 0 && map.BaseMap.GroupCount == 0 && bDetachIfEmpty)
            {
                map.RemoveBaseMap();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Updates and replaces the layer/group structure of the specified Map Definition with the
        /// layer/group structure of this Runtime Map
        /// </summary>
        /// <param name="newMdf"></param>
        public void UpdateMapDefinition(IMapDefinition newMdf)
        {
            newMdf.RemoveAllLayers();
            newMdf.RemoveAllGroups();
            newMdf.RemoveBaseMap();

            var baseGroups = new List<RuntimeMapGroup>();

            newMdf.CoordinateSystem = this.CoordinateSystem;
            newMdf.Extents = this.MapExtent;

            //Add dynamic groups
            for (int i = this.Groups.Count - 1; i >= 0; i--)
            {
                //Deal with base groups later
                if (this.Groups[i].Type == RuntimeMapGroup.kBaseMap)
                {
                    baseGroups.Add(this.Groups[i]);
                    continue;
                }

                var rtGroup = this.Groups[i];
                var newGroup = newMdf.AddGroup(rtGroup.Name);
                newGroup.Group = rtGroup.Group;
                newGroup.ExpandInLegend = rtGroup.ExpandInLegend;
                newGroup.LegendLabel = rtGroup.LegendLabel;
                newGroup.ShowInLegend = rtGroup.ShowInLegend;
                newGroup.Visible = rtGroup.Visible;
            }

            var baseLayers = new List<RuntimeMapLayer>();

            //Populate dynamic layers. Loop in reverse order so that they are added in correct draw order
            for (int i = this.Layers.Count - 1; i >= 0; i--)
            {
                //Deal with base layers later
                if (this.Layers[i].Type == RuntimeMapLayer.kBaseMap)
                {
                    baseLayers.Add(this.Layers[i]);
                    continue;
                }

                var rtLayer = this.Layers[i];
                var newLayer = newMdf.AddLayer(rtLayer.Group, rtLayer.Name, rtLayer.LayerDefinitionID);
                newLayer.ExpandInLegend = rtLayer.ExpandInLegend;
                newLayer.LegendLabel = rtLayer.LegendLabel;
                newLayer.Selectable = rtLayer.Selectable;
                newLayer.ShowInLegend = rtLayer.ShowInLegend;
                newLayer.Visible = rtLayer.Visible;
            }

            if (baseLayers.Count > 0 && baseGroups.Count > 0)
            {
                newMdf.InitBaseMap();

                //Add finite scales first
                for (int i = _finiteDisplayScales.Length - 1; i >= 0; i--)
                {
                    newMdf.BaseMap.AddFiniteDisplayScale(_finiteDisplayScales[i]);
                }

                var baseGroupsByName = new Dictionary<string, IBaseMapGroup>();

                //Now groups
                for (int i = baseGroups.Count - 1; i >= 0; i--)
                {
                    var rtGroup = baseGroups[i];
                    var newGroup = newMdf.BaseMap.AddBaseLayerGroup(rtGroup.Name);
                    newGroup.ExpandInLegend = rtGroup.ExpandInLegend;
                    newGroup.LegendLabel = rtGroup.LegendLabel;
                    newGroup.ShowInLegend = rtGroup.ShowInLegend;
                    newGroup.Visible = rtGroup.Visible;

                    baseGroupsByName.Add(newGroup.Name, newGroup);
                }

                //Then layers. Loop in reverse order so that they are added in correct draw order
                for (int i = baseLayers.Count - 1; i >= 0; i--)
                {
                    var rtLayer = baseLayers[i];
                    //Should always happen
                    if (baseGroupsByName.ContainsKey(rtLayer.Group))
                    {
                        var newLayer = baseGroupsByName[rtLayer.Group].AddLayer(rtLayer.Name, rtLayer.LayerDefinitionID);
                        newLayer.ExpandInLegend = rtLayer.ExpandInLegend;
                        newLayer.LegendLabel = rtLayer.LegendLabel;
                        newLayer.Selectable = rtLayer.Selectable;
                        newLayer.ShowInLegend = rtLayer.ShowInLegend;
                    }
                }
            }
        }