Пример #1
0
        static RuntimeMapGroup CreateGroup(RuntimeMap map, IBaseMapGroup grp)
        {
            var ctor  = typeof(RuntimeMapGroup).GetInternalConstructor(new[] { typeof(RuntimeMap), typeof(IBaseMapGroup) });
            var group = ctor.Invoke(new object[] { map, grp }) as RuntimeMapGroup;

            return(group);
        }
 private void btnAddBaseLayer_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edSvc.CurrentConnection, ResourceTypes.LayerDefinition.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             string        layerId = picker.ResourceID;
             IBaseMapGroup grp     = null;
             var           group   = GetSelectedTiledLayerItem() as BaseLayerGroupItem;
             if (group != null)
             {
                 grp = group.Tag;
             }
             else
             {
                 grp = _tsd.GetFirstGroup();
                 if (grp == null)
                 {
                     grp = _tsd.AddBaseLayerGroup(GenerateBaseGroupName(_tsd));
                 }
             }
             var bl = grp.AddLayer(GenerateBaseLayerName(layerId, _tsd), layerId);
             _tiledLayerModel.Invalidate();
             RestoreBaseLayerSelection(bl);
         }
     }
 }
        public void RemoveBaseLayerGroup(IBaseMapGroup group)
        {
            var grp = group as BaseMapLayerGroupCommonType;

            if (grp != null)
            {
                this.BaseMapLayerGroup.Remove(grp);
            }
        }
Пример #4
0
        /// <summary>
        /// Removes the given base layer group from the Map Definition
        /// </summary>
        /// <param name="map">The map</param>
        /// <param name="group">The group to remove</param>
        public static void RemoveBaseLayerGroup(this ITileSetDefinition map, IBaseMapGroup group)
        {
            Check.ArgumentNotNull(map, nameof(map));
            if (null == group)
            {
                return;
            }

            map.RemoveBaseLayerGroup(group);
        }
Пример #5
0
        internal RuntimeMapGroup(RuntimeMap map, IBaseMapGroup group)
            : this(map, group.Name)
        {
            _disableChangeTracking = true;

            this.ExpandInLegend = group.ExpandInLegend;
            this.LegendLabel    = group.LegendLabel;
            this.ShowInLegend   = group.ShowInLegend;
            this.Visible        = group.Visible;

            this.Type = kBaseMap;

            _disableChangeTracking = false;
        }
        public GroupPropertiesCtrl(ITileSetDefinition map, IBaseMapGroup group)
            : this()
        {
            _init = true;
            try
            {
                _mdf = map;
                _el  = group;
                group.PropertyChanged += WeakEventHandler.Wrap <PropertyChangedEventHandler>(OnGroupChanged, (eh) => group.PropertyChanged -= eh);

                txtName.Text = group.Name;
                TextBoxBinder.BindText(txtLegendLabel, group, nameof(group.LegendLabel));
            }
            finally
            {
                _init = false;
            }
        }
Пример #7
0
        public GroupPropertiesCtrl(IMapDefinition map, IBaseMapGroup group)
            : this()
        {
            _init = true;
            try
            {
                _mdf = map;
                _el = group;
                group.PropertyChanged += new PropertyChangedEventHandler(OnGroupChanged);

                txtName.Text = group.Name;
                TextBoxBinder.BindText(txtLegendLabel, group, "LegendLabel");
            }
            finally
            {
                _init = false;
            }
        }
Пример #8
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();
            }
        }
Пример #9
0
 /// <summary>
 /// Gets whether this base map group has tiled layers
 /// </summary>
 /// <param name="grp">The group</param>
 /// <returns>True if it has tiled layers. False otherwise</returns>
 public static bool HasLayers(this IBaseMapGroup grp)
 {
     Check.ArgumentNotNull(grp, nameof(grp));
     return(new List <IBaseMapLayer>(grp.BaseMapLayer).Count > 0);
 }
        private void trvBaseLayers_DragDrop(object sender, DragEventArgs e)
        {
            var rids = e.Data.GetData(typeof(RepositoryHandle[])) as RepositoryHandle[];
            var data = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];

            if (rids != null && rids.Length > 0)
            {
                int added = 0;
                var node  = trvBaseLayers.GetNodeAt(trvBaseLayers.PointToClient(new Point(e.X, e.Y)));

                IBaseMapGroup group = null;
                if (node != null && node.Tag is BaseLayerGroupItem)
                {
                    group = ((BaseLayerGroupItem)node.Tag).Tag;
                }

                //No group? Let's make one!
                if (group == null)
                {
                    group = _tsd.AddBaseLayerGroup(GenerateBaseGroupName(_tsd));
                }

                IBaseMapLayer focusLayer = null;
                foreach (var rid in rids)
                {
                    if (rid.ResourceId.ResourceType == ResourceTypes.LayerDefinition.ToString())
                    {
                        focusLayer = group.AddLayer(GenerateBaseLayerName(rid.ResourceId.ToString(), _tsd), rid.ResourceId.ToString());
                        added++;
                    }
                }

                if (added > 0)
                {
                    _tiledLayerModel.Invalidate();
                    if (focusLayer != null)
                    {
                        RestoreBaseLayerSelection(focusLayer);
                    }
                }
            }
            else if (data != null && data.Length == 1)
            {
                var li = data[0].Tag as BaseLayerItem;
                if (li != null)
                {
                    IBaseMapLayer sourceLayer = li.Tag;
                    IBaseMapLayer targetLayer = null;
                    IBaseMapGroup targetGroup = null;
                    var           node        = trvBaseLayers.GetNodeAt(trvBaseLayers.PointToClient(new Point(e.X, e.Y)));
                    BaseLayerItem tli         = null;
                    if (node != null)
                    {
                        tli = node.Tag as BaseLayerItem;
                        var tlg = node.Tag as BaseLayerGroupItem;
                        if (tli != null)
                        {
                            targetLayer = tli.Tag;
                        }
                        else if (tlg != null)
                        {
                            targetGroup = tlg.Tag;
                        }
                    }

                    if (sourceLayer != null && targetGroup != null && targetGroup.GetIndex(sourceLayer) < 0) //Dropping to a different base layer group
                    {
                        var srcGroup = _tsd.GetGroupForLayer(sourceLayer);
                        srcGroup.RemoveBaseMapLayer(sourceLayer);
                        targetGroup.InsertLayer(0, sourceLayer);

                        _tiledLayerModel.Invalidate();

                        //Keep group expanded
                        if (tli != null)
                        {
                            RestoreBaseLayerSelection(sourceLayer);
                        }
                    }
                    else if (sourceLayer != null && targetLayer != null && sourceLayer != targetLayer)
                    {
                        var srcGroup = _tsd.GetGroupForLayer(sourceLayer);
                        var dstGroup = _tsd.GetGroupForLayer(targetLayer);

                        if (srcGroup != null)
                        {
                            if (srcGroup == dstGroup)
                            {
                                int idx = srcGroup.GetIndex(targetLayer);
                                if (idx >= 0)
                                {
                                    srcGroup.RemoveBaseMapLayer(sourceLayer);
                                    srcGroup.InsertLayer(idx, sourceLayer);

                                    _tiledLayerModel.Invalidate();

                                    //Keep group expanded
                                    if (tli != null)
                                    {
                                        RestoreBaseLayerSelection(sourceLayer);
                                    }
                                }
                            }
                            else
                            {
                                srcGroup.RemoveBaseMapLayer(sourceLayer);
                                dstGroup.InsertLayer(0, targetLayer);

                                _tiledLayerModel.Invalidate();

                                //Keep group expanded
                                if (tli != null)
                                {
                                    RestoreBaseLayerSelection(targetLayer);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #11
0
 /// <summary>
 /// Gets whether this base map group has tiled layers
 /// </summary>
 /// <param name="grp"></param>
 /// <returns></returns>
 public static bool HasLayers(this IBaseMapGroup grp)
 {
     Check.NotNull(grp, "grp"); //NOXLATE
     return(new List <IBaseMapLayer>(grp.BaseMapLayer).Count > 0);
 }
Пример #12
0
 public BaseLayerItem(IBaseMapLayer layer, IBaseMapGroup parent)
     : base(layer.Name, Properties.Resources.layer, layer)
 {
     layer.PropertyChanged += WeakEventHandler.Wrap <PropertyChangedEventHandler>(OnPropertyChanged, (eh) => layer.PropertyChanged -= eh);
     this.Parent            = parent;
 }
Пример #13
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();
        }
Пример #14
0
        internal RuntimeMapGroup(RuntimeMap map, IBaseMapGroup group)
            : this(map, group.Name)
        {
            _disableChangeTracking = true;

            this.ExpandInLegend = group.ExpandInLegend;
            this.LegendLabel = group.LegendLabel;
            this.ShowInLegend = group.ShowInLegend;
            this.Visible = group.Visible;

            this.Type = kBaseMap;

            _disableChangeTracking = false;
        }