string errorMessage = await QueuedTask.Run(async () =>
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
if (myParcelFabricLayer == null)
return "Please add a parcel fabric to the map";
try
{
FeatureLayer parcelPolygonLyr = null;
//find the first layer that is a polygon parcel type, is non-historic, and has a selection
bool bFound = false;
var ParcelTypesEnum = await myParcelFabricLayer.GetParcelTypeNamesAsync();
foreach (FeatureLayer mapFeatLyr in MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
{
foreach (string ParcelType in ParcelTypesEnum)
{
var layerEnum = await myParcelFabricLayer.GetParcelPolygonLayerByTypeNameAsync(ParcelType);
foreach (FeatureLayer flyr in layerEnum)
{
if (flyr == mapFeatLyr)
{
bFound = mapFeatLyr.SelectionCount > 0;
parcelPolygonLyr = mapFeatLyr;
break;
}
}
if (bFound) break;
}
if (bFound) break;
}
if (!bFound)
return "Please select parcels to shrink to seeds.";
var editOper = new EditOperation()
{
Name = "Shrink Parcels To Seeds",
ProgressMessage = "Shrink Parcels To Seeds...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = true,
SelectModifiedFeatures = false
};
var ids = new List<long>(parcelPolygonLyr.GetSelection().GetObjectIDs());
var sourceParcelFeatures = new Dictionary<MapMember, List<long>>();
sourceParcelFeatures.Add(parcelPolygonLyr, ids);
editOper.ShrinkParcelsToSeeds(myParcelFabricLayer,SelectionSet.FromDictionary(sourceParcelFeatures));
if (!editOper.Execute())
return editOper.ErrorMessage;
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Shrink Parcels To Seeds.");