int IBaseMapGroup.MoveDown(IBaseMapLayer layer)
        {
            var lyr = layer as BaseMapLayerType;

            if (lyr != null)
            {
                int isrc = this.BaseMapLayer.IndexOf(lyr);
                if (isrc < this.BaseMapLayer.Count - 1)
                {
                    int idst = isrc + 1;
                    var src  = this.BaseMapLayer[isrc];
                    var dst  = this.BaseMapLayer[idst];

                    //swap
                    this.BaseMapLayer[isrc] = dst;
                    this.BaseMapLayer[idst] = src;

                    OnPropertyChanged(nameof(BaseMapLayer));

                    return(idst);
                }
            }

            return(-1);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="source"></param>
 /// <param name="ldf"></param>
 /// <param name="suppressErrors"></param>
 protected internal RuntimeMapLayer(RuntimeMap parent, IBaseMapLayer source, ILayerDefinition ldf, bool suppressErrors)
     : this(parent, ldf, suppressErrors)
 {
     Check.ArgumentNotNull(source, nameof(source));
     Check.ArgumentNotNull(ldf, nameof(ldf));
     Check.ThatPreconditionIsMet(source.ResourceId == ldf.ResourceID, $"{nameof(source)}.{nameof(source.ResourceId)} == {nameof(ldf)}.{nameof(ldf.ResourceID)}");
 }
        public void InsertLayer(int index, IBaseMapLayer layer)
        {
            var bl = layer as BaseMapLayerType;

            if (bl != null)
            {
                this.BaseMapLayer.Insert(index, bl);
            }
        }
        public void RemoveBaseMapLayer(IBaseMapLayer layer)
        {
            var lyr = layer as BaseMapLayerType;

            if (lyr != null)
            {
                this.BaseMapLayer.Remove(lyr);
                OnPropertyChanged(nameof(BaseMapLayer));
            }
        }
        public int GetIndex(IBaseMapLayer layer)
        {
            var bl = layer as BaseMapLayerType;

            if (bl != null)
            {
                return(this.BaseMapLayer.IndexOf(bl));
            }
            return(-1);
        }
Пример #6
0
        public LayerPropertiesCtrl(IBaseMapLayer layer, IEditorService edSvc)
            : this()
        {
            layer.PropertyChanged += WeakEventHandler.Wrap <PropertyChangedEventHandler>(OnLayerChanged, (eh) => layer.PropertyChanged -= eh);
            _edSvc = edSvc;

            TextBoxBinder.BindText(txtResourceId, layer, nameof(layer.ResourceId));
            TextBoxBinder.BindText(txtName, layer, nameof(layer.Name));
            TextBoxBinder.BindText(txtLegendLabel, layer, nameof(layer.LegendLabel));
        }
        private void RestoreBaseLayerSelection(IBaseMapLayer layer)
        {
            //The node tag will probably be different, but the wrapped
            //instance is what we're checking for
            var it = RestoreSelection <BaseLayerItem>(trvBaseLayers, (tag) => { return(tag.Tag == layer); });

            if (it != null)
            {
                OnBaseLayerItemSelected(it);
            }
        }
Пример #8
0
        public LayerPropertiesCtrl(IBaseMapLayer layer, IResourceService resSvc, IEditorService edSvc)
            : this()
        {
            layer.PropertyChanged += new PropertyChangedEventHandler(OnLayerChanged);
            _resSvc = resSvc;
            _edSvc = edSvc;

            TextBoxBinder.BindText(txtResourceId, layer, "ResourceId");
            TextBoxBinder.BindText(txtName, layer, "Name");
            TextBoxBinder.BindText(txtLegendLabel, layer, "LegendLabel");
        }
Пример #9
0
 /// <summary>
 /// Gets the parent group for the specified layer
 /// </summary>
 /// <param name="map">The map</param>
 /// <param name="layer">The layer</param>
 /// <returns>The parent group</returns>
 public static IBaseMapGroup GetGroupForLayer(this ITileSetAbstract map, IBaseMapLayer layer)
 {
     Check.ArgumentNotNull(map, nameof(map));
     foreach (var group in map.BaseMapLayerGroups)
     {
         foreach (var tl in group.BaseMapLayer)
         {
             if (tl == layer)
             {
                 return(group);
             }
         }
     }
     return(null);
 }
Пример #10
0
 /// <summary>
 /// Gets the parent group for the specified layer
 /// </summary>
 /// <param name="map"></param>
 /// <param name="layer"></param>
 /// <returns></returns>
 public static IBaseMapGroup GetGroupForLayer(this IBaseMapDefinition map, IBaseMapLayer layer)
 {
     Check.NotNull(map, "map"); //NOXLATE
     foreach (var group in map.BaseMapLayerGroup)
     {
         foreach (var tl in group.BaseMapLayer)
         {
             if (tl == layer)
             {
                 return(group);
             }
         }
     }
     return(null);
 }
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #12
0
 /// <summary>
 /// Initializes a new instance
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="source"></param>
 /// <param name="ldf"></param>
 /// <param name="suppressErrors"></param>
 protected internal RuntimeMapLayer(RuntimeMap parent, IBaseMapLayer source, ILayerDefinition ldf, bool suppressErrors)
     : this(parent, ldf, suppressErrors)
 {
     Check.NotNull(source, "source"); //NOXLATE
     Check.NotNull(ldf, "ldf"); //NOXLATE
     Check.Precondition(source.ResourceId == ldf.ResourceID, "source.ResourceId == ldf.ResourceID"); //NOXLATE
 }
Пример #13
0
 /// <summary>
 /// Gets the parent group for the specified layer
 /// </summary>
 /// <param name="map"></param>
 /// <param name="layer"></param>
 /// <returns></returns>
 public static IBaseMapGroup GetGroupForLayer(this IBaseMapDefinition map, IBaseMapLayer layer)
 {
     Check.NotNull(map, "map"); //NOXLATE
     foreach (var group in map.BaseMapLayerGroup)
     {
         foreach (var tl in group.BaseMapLayer)
         {
             if (tl == layer)
                 return group;
         }
     }
     return null;
 }