internal void RefreshFeatureInteractors() { var selectedFeaturesWithLayer = SelectedFeatureInteractors.Select(fe => new { Feature = fe.SourceFeature, fe.Layer }).ToList(); SelectedFeatureInteractors.Clear(); selectedFeaturesWithLayer.ForEach(fl => SelectedFeatureInteractors.Add(GetFeatureInteractor(fl.Layer, fl.Feature))); SynchronizeTrackers(); }
private void UpdateMapControlSelection(bool fireSelectionChangedEvent) { SynchronizeTrackers(); IList <IFeature> selectedFeatures = SelectedFeatureInteractors.Select(t => t.SourceFeature).ToList(); MapControl.SelectedFeatures = selectedFeatures; if (fireSelectionChangedEvent && SelectionChanged != null) { SelectionChanged(this, null); } }
/// TODO: note if no features are selected the selection rectangle maintains visible after mouse up /// ISSUE 2373 private void HandleMultiSelectMouseUp(Coordinate worldPosition) { StopMultiSelect(); List <IFeature> selectedFeatures = null; if (!KeyExtendSelection) { selectedFeatures = new List <IFeature>(SelectedFeatureInteractors.Select(fe => fe.SourceFeature).ToArray()); Clear(false); } var selectionPolygon = CreateSelectionPolygon(worldPosition); if (null != selectionPolygon) { foreach (ILayer layer in Map.GetAllVisibleLayers(false)) { //make sure parent layer is selectable or null var parentLayer = Map.GetGroupLayerContainingLayer(layer); if ((parentLayer == null || parentLayer.IsSelectable) && (layer.IsSelectable) && (layer is VectorLayer)) { // do not use the maptool provider but the datasource of each layer. var vectorLayer = (VectorLayer)layer; var multiFeatures = vectorLayer.GetFeatures(selectionPolygon).Take(5000); foreach (IFeature feature in multiFeatures) { if ((null != selectedFeatures) && (selectedFeatures.Contains(feature))) { continue; } AddSelection(vectorLayer, feature, false); } } } } else { // if mouse hasn't moved handle as single select. A normal multi select uses the envelope // of the geometry and this has as result that unwanted features will be selected. ILayer selectedLayer; var limit = (float)MapHelper.ImageToWorld(Map, 4); var nearest = FindNearestFeature(worldPosition, limit, out selectedLayer, ol => ol.Visible); if (null != nearest) { AddSelection(selectedLayer, nearest, false); } } // synchronize with map selection, possible check if selection is already set; do not remove UpdateMapControlSelection(true); }