本文整理汇总了C#中FeatureLayer.GetSelection方法的典型用法代码示例。如果您正苦于以下问题:C# FeatureLayer.GetSelection方法的具体用法?C# FeatureLayer.GetSelection怎么用?C# FeatureLayer.GetSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FeatureLayer
的用法示例。
在下文中一共展示了FeatureLayer.GetSelection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSelectedFeatures
private async void GetSelectedFeatures(FeatureLayer selectedFeatureLayer)
{
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null || selectedFeatureLayer == null) return;
await QueuedTask.Run(() =>
{
// Get all selected features for selectedFeatureLayer
// and populate a datatable with data and column headers
var resultTable = new DataTable();
using (var rowCursor = selectedFeatureLayer.GetSelection().Search(null))
{
bool bDefineColumns = true;
while (rowCursor.MoveNext())
{
var anyRow = rowCursor.Current;
if (bDefineColumns)
{
foreach (var fld in anyRow.GetFields().Where(fld => fld.FieldType != FieldType.Geometry))
{
resultTable.Columns.Add(new DataColumn(fld.Name, typeof(string)) { Caption = fld.AliasName });
}
}
var addRow = resultTable.NewRow();
foreach (var fld in anyRow.GetFields().Where(fld => fld.FieldType != FieldType.Geometry))
{
addRow[fld.Name] = (anyRow[fld.Name] == null) ? string.Empty : anyRow[fld.Name].ToString();
}
resultTable.Rows.Add(addRow);
bDefineColumns = false;
}
}
lock (_lockSelectedFeaturesDataTable) _selectedFeaturesDataTable = resultTable;
}).ContinueWith(t =>
{
if (t.Exception != null)
{
var aggException = t.Exception.Flatten();
foreach (var exception in aggException.InnerExceptions)
System.Diagnostics.Debug.WriteLine(exception.Message);
}
});
NotifyPropertyChanged(() => SelectedFeatureDataTable);
}