Polyline selected state and condition

45
1
10-22-2018 12:06 PM
Highlighted
New Contributor

Is there a built in state that is set when a polyline is selected? If not, is there a way to create a state that is set automatically when a polyline is selected or de-selected?

0 Kudos
1 Reply
Highlighted
Esri Regular Contributor

Hi

You can create your own state to check this - ProGuide: Code Your Own States and Conditions

If you subscribe to the MapSelectionChangedEvent, you will be able to see when the Selection changed. You can then check if any of the layers selected were of type PolyLine.

//In the module class subscribe to the MapSelection Event.
protected override bool Initialize(){
            MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);
            return base.Initialize();
}

//Event handler checks if the layer selected is a PolyLine.
private void OnMapSelectionChanged(MapSelectionChangedEventArgs obj){
       foreach (var item in obj.Selection)
          {
             var featureLayer = item.Key as FeatureLayer;
             if (featureLayer.ShapeType == esriGeometryType.esriGeometryPolyline)
                 MessageBox.Show($"Polyline feature layer {item.Key.Name} selected");
           }
}

Thanks

Uma

0 Kudos