コード例 #1
0
ファイル: LayerCollection.cs プロジェクト: zylimit/MapWindow5
        public List <Layer> GetMovingLayers(string movingName)
        {
            List <Layer> movingLayers = null;

            LayerGroup movingGroup = _innerList.FirstOrDefault(elm => elm.Group.Name == movingName);

            if (movingGroup != null)
            {
                //movingLayers = (List<Layer>)(from layers in _innerList
                //where layers.Group == movingGroup.Group
                //select layers);

                Layer      aap  = _innerList[1];
                LayerGroup aap2 = _innerList[1];

                movingLayers = _innerList.FindAll(elm => elm.Group == movingGroup.Group).Cast <Layer>().ToList();
            }
            else
            {
                Layer layer = _innerList.First(elm => elm.Name == movingName);
                movingLayers = new List <Layer>()
                {
                    layer
                };
            }

            return(movingLayers);
        }
コード例 #2
0
ファイル: LayerCollection.cs プロジェクト: zylimit/MapWindow5
        public void Add(Layer item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("Item cannot be nothing.");
            }

            Group group;

            if (_innerList.Count == 0)
            {
                group = GetDefaultGroup();
            }
            else
            {
                // gebruik de group met de hoogste handle
                group = (_innerList.First(l2 => l2.Group.Handle == _innerList.Min(elm => elm.Group.Handle))).Group;
            }

            LayerGroup layerGroup = LayerGroup.CreateLayerGroup(item, group);

            _innerList.Add(layerGroup);

            Current = layerGroup;
        }
コード例 #3
0
ファイル: LayerCollection.cs プロジェクト: zylimit/MapWindow5
        public void Add(Layer item, Group group)
        {
            if (item == null)
            {
                throw new ArgumentNullException("Item cannot be nothing.");
            }

            if (group == null)
            {
                throw new ArgumentNullException("Group cannot be nothing.");
            }

            Group groupToAdd;

            // controleer of het een nieuwe of al bestaande groep is
            LayerGroup searchLayerGroup = _innerList.FirstOrDefault(elm => elm.Group.Name == group.Name);

            if (searchLayerGroup == null)
            {
                groupToAdd = group;
            }
            else
            {
                groupToAdd = searchLayerGroup.Group;
            }

            LayerGroup layerGroup = LayerGroup.CreateLayerGroup(item, groupToAdd);

            _innerList.Add(layerGroup);

            Current = layerGroup;
        }
コード例 #4
0
ファイル: LayerCollection.cs プロジェクト: zylimit/MapWindow5
        // Switch the postion of the layers
        private void MoveLayer(Group newDestGroup, int newDestPosition, LayerGroup movingLayer)
        {
            if (movingLayer.Position < newDestPosition)
            {
                for (int i = (movingLayer.Position + 1); i <= newDestPosition; i++)
                {
                    var editLayer = _innerList.FirstOrDefault(elm => elm.Position == i);
                    editLayer.Position--;
                }

                movingLayer.Position = newDestPosition;
                movingLayer.Group    = newDestGroup;
            }
            else
            {
                for (int i = (newDestPosition + 1); i < movingLayer.Position; i++)
                {
                    var editLayer = _innerList.FirstOrDefault(elm => elm.Position == i);
                    editLayer.Position++;
                }

                movingLayer.Position = newDestPosition + 1;
                movingLayer.Group    = newDestGroup;
            }
        }
コード例 #5
0
ファイル: LayerCollection.cs プロジェクト: zylimit/MapWindow5
        public bool Move(string newDestination, string movingName)
        {
            try
            {
                int   newDestPosition;
                Group newDestGroup;

                LayerGroup movingGroup = _innerList.FirstOrDefault(elm => elm.Group.Name == movingName);

                LayerGroup destinationGroup = _innerList.FirstOrDefault(elm => elm.Group.Name == newDestination);

                if (movingGroup != null)
                {
                    if (destinationGroup == null)
                    {
                        // A group cannot be moved to a layer
                        return(false);
                    }

                    MoveGroup(movingGroup, destinationGroup);

                    return(true);
                }
                else
                {
                    LayerGroup movingLayer = _innerList.FirstOrDefault(elm => elm.Name == movingName);

                    if (destinationGroup != null)
                    {
                        // Move below a group

                        // Get first layer in group
                        var destLayer = (from layer in _innerList
                                         where layer.Group == destinationGroup.Group
                                         select layer).OrderBy(elm => elm.Position).First();

                        // set new position and new group
                        newDestPosition = destLayer.Position - 1;
                        newDestGroup    = destLayer.Group;
                    }
                    else
                    {
                        // Move below a layer

                        LayerGroup destLayer = _innerList.FirstOrDefault(elm => elm.Name == newDestination);
                        newDestPosition = destLayer.Position;
                        newDestGroup    = destLayer.Group;
                    }

                    MoveLayer(newDestGroup, newDestPosition, movingLayer);
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #6
0
ファイル: LayerCollection.cs プロジェクト: zylimit/MapWindow5
        public bool Remove(Layer item)
        {
            bool retVal = false;

            LayerGroup layerGroup = this.InnerList.FirstOrDefault(c => c.Handle == item.Handle);

            if (layerGroup != null)
            {
                this.InnerList.Remove(layerGroup);
                retVal = true;
            }

            return(retVal);
        }
コード例 #7
0
        internal static LayerGroup CreateLayerGroup(Layer item, Group group)
        {
            LayerGroup layerGroup = new LayerGroup();

            layerGroup.Group           = group;
            layerGroup.Filename        = item.Filename;
            layerGroup.Handle          = item.Handle;
            layerGroup.LayerKey        = item.LayerKey;
            layerGroup.LayerType       = item.LayerType;
            layerGroup.LayerVisible    = item.LayerVisible;
            layerGroup.Name            = item.Name;
            layerGroup.PositionInGroup = item.PositionInGroup;
            layerGroup.Position        = item.Position;

            return(layerGroup);
        }
コード例 #8
0
ファイル: LayerCollection.cs プロジェクト: zylimit/MapWindow5
        private void MoveGroup(LayerGroup movingGroup, LayerGroup destinationGroup)
        {
            // Get all layers in moving group
            var movingLayers            = _innerList.FindAll(elm => elm.Group == movingGroup.Group);
            int maxPostionOfMovingGroup = movingLayers.Max(elm => elm.Position);

            var lastLayerInDestGroup = (from x in _innerList
                                        where x.Group == destinationGroup.Group
                                        select x).Max(elm => elm.Position);

            if (maxPostionOfMovingGroup < lastLayerInDestGroup)
            {
                // move layers down (to higher number)

                for (int i = (maxPostionOfMovingGroup + 1); i <= lastLayerInDestGroup; i++)
                {
                    var editLayer = _innerList.FirstOrDefault(elm => elm.Position == i);
                    editLayer.Position = editLayer.Position - movingLayers.Count;
                }

                int layerPos = 1;
                foreach (var movingLayer in movingLayers)
                {
                    movingLayer.Position = lastLayerInDestGroup - movingLayers.Count + layerPos;
                    layerPos++;
                }
            }
            else
            {
                int minPostionOfMovingGroup = movingLayers.Min(elm => elm.Position);

                for (int i = (minPostionOfMovingGroup - 1); i > lastLayerInDestGroup; i--)
                {
                    var editLayer = _innerList.FirstOrDefault(elm => elm.Position == i);
                    editLayer.Position = editLayer.Position + movingLayers.Count;
                }

                int layerPos = 1;
                foreach (var movingLayer in movingLayers)
                {
                    movingLayer.Position = lastLayerInDestGroup + layerPos;
                    layerPos++;
                }
            }
        }
コード例 #9
0
ファイル: LayerCollection.cs プロジェクト: zylimit/MapWindow5
        public Group GetGroup(string name)
        {
            LayerGroup layerGroup = _innerList.FirstOrDefault(elm => elm.Group.Name == name);

            return(layerGroup != null ? layerGroup.Group : null);
        }