Skip to content

Commit

Permalink
Clear the selection inside FeatureLayer.RemoveSelectedFeatures so the…
Browse files Browse the repository at this point in the history
… removed features are no longer contained when IFeatureSet.FeatureRemoved is raised
  • Loading branch information
jany-tenaj committed Jul 14, 2017
1 parent 795fbc7 commit aa015fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,5 @@ Be aware that code written for 1.9 will not work out of the box because DotSpati
- Selection Options (#283)
- Legend drag line so it doesn't look as if you can move a layer in between categories (#1008)
- Legend selection to be able to select features of a category (#1008)
- Some errors in SetSelectable plugin (#1008)
- Some errors in SetSelectable plugin (#1008)
- Clear the selection inside FeatureLayer.RemoveSelectedFeatures so the removed features are no longer contained when IFeatureSet.FeatureRemoved is raised
17 changes: 10 additions & 7 deletions Source/DotSpatial.Symbology/FeatureLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,8 @@ public override bool InvertSelection(Envelope tolerant, Envelope strict, Selecti
public void RemoveFeaturesAt(IEnumerable<int> indexValues)
{
DataSet.RemoveShapesAt(indexValues);

// Since the indexing has changed, we need to update the drawn states too.
AssignFastDrawnStates();
}

Expand All @@ -877,20 +879,21 @@ public void RemoveSelectedFeatures()
if (indexSel == null) return;

// Create a list of index values to remove.
List<int> orderedIndex = new List<int>();
foreach (int index in indexSel)
{
orderedIndex.Add(index);
}
List<int> orderedIndex = new List<int>(indexSel);

RemoveFeaturesAt(orderedIndex);
// Clear the selection so the removed features are no longer contained when IFeatureSet.FeatureRemoved is raised
Selection.Clear();

// Since the indexing has changed, we need to update the drawn states too.
RemoveFeaturesAt(orderedIndex);
}
else
{
// This case tracks by IFeature, so we don't need to do a lot else.
List<IFeature> features = Selection.ToFeatureList();

// Clear the selection so the removed features are no longer contained when IFeatureSet.FeatureRemoved is raised
Selection.Clear();

foreach (IFeature feature in features)
{
DataSet.Features.Remove(feature);
Expand Down

0 comments on commit aa015fc

Please sign in to comment.