コード例 #1
0
        public void DemoteLayer(Layer selectedLayer)
        {
            // Find the collection the layer is in.
            LayerCollection owningCollection;

            if (IncludedLayers.Contains(selectedLayer))
            {
                owningCollection = IncludedLayers;
            }
            else
            {
                owningCollection = ExcludedLayers;
            }

            // Get the current index (position) of the layer.
            int layerIndex = owningCollection.IndexOf(selectedLayer);

            // Skip if the layer can't be moved down because it is already at the bottom.
            if (layerIndex == owningCollection.Count - 1)
            {
                return;
            }

            // Move the layer by removing it and re-adding it at its old position plus 1.
            owningCollection.Remove(selectedLayer);
            owningCollection.Insert(layerIndex + 1, selectedLayer);
        }
コード例 #2
0
 public void MoveLayer(Layer selectedLayer)
 {
     // Remove the layer from the list it is currently in and add it to the other list.
     if (IncludedLayers.Contains(selectedLayer))
     {
         IncludedLayers.Remove(selectedLayer);
         ExcludedLayers.Add(selectedLayer);
     }
     else
     {
         ExcludedLayers.Remove(selectedLayer);
         IncludedLayers.Add(selectedLayer);
     }
 }
        public void MoveLayer(LayerCollection owningCollection, int position)
        {
            // Find the selected layer.
            Layer selectedLayer = owningCollection[position];

            // Move the layer from one list to another by removing it from the source list and adding it to the destination list.
            if (IncludedLayers.Contains(selectedLayer))
            {
                IncludedLayers.Remove(selectedLayer);
                ExcludedLayers.Add(selectedLayer);
            }
            else
            {
                ExcludedLayers.Remove(selectedLayer);
                IncludedLayers.Add(selectedLayer);
            }
        }
コード例 #4
0
        public void PromoteLayer(Layer selectedLayer)
        {
            // Find the collection the layer is in.
            LayerCollection owningCollection = IncludedLayers.Contains(selectedLayer) ? IncludedLayers : ExcludedLayers;

            // Get the current index (position) of the layer.
            int layerIndex = owningCollection.IndexOf(selectedLayer);

            // Skip if the layer can't be moved because it is already at the top.
            if (layerIndex < 1)
            {
                return;
            }

            // Move the layer by removing it and re-adding it at its old position minus 1.
            owningCollection.Remove(selectedLayer);
            owningCollection.Insert(layerIndex - 1, selectedLayer);
        }
        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
        {
            // Commit editing - in this case, editing means insertion or deletion.

            Layer selectedLayer;

            switch (indexPath.Section)
            {
            case 0:
                selectedLayer = IncludedLayers[indexPath.Row];
                IncludedLayers.Remove(selectedLayer);
                ExcludedLayers.Add(selectedLayer);
                break;

            case 1:
                selectedLayer = ExcludedLayers[indexPath.Row];
                ExcludedLayers.Remove(selectedLayer);
                IncludedLayers.Add(selectedLayer);
                break;
            }

            // Force the view to reload its data.
            tableView.ReloadData();
        }