98 lines
4.0 KiB
C#
98 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using Esri.ArcGISRuntime.Data;
|
|
|
|
namespace GisDevelop_Exp
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for LocationQueryResultsWindow.xaml
|
|
/// </summary>
|
|
public partial class LocationQueryResultsWindow : Window
|
|
{
|
|
private IReadOnlyList<IdentifyLayerResult> resultCollection;//地图识别操作结果集合
|
|
private bool isClosed;//窗体关闭标记
|
|
private IdentifyLayerResult curSelLayer;//当前选择的图层
|
|
public IReadOnlyList<IdentifyLayerResult> ResultCollection
|
|
{
|
|
get { return resultCollection; }
|
|
set { resultCollection = value; }
|
|
}
|
|
public bool IsClosed
|
|
{
|
|
get { return isClosed; }
|
|
}
|
|
|
|
public LocationQueryResultsWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void LocationQueryResultsWindow_OnActivated(object? sender, EventArgs e)
|
|
{
|
|
if(resultCollection!=null)//查询结果集不为空
|
|
{
|
|
comboBoxLayer.Items.Clear();//清空图层组合框的内容
|
|
foreach (IdentifyLayerResult result in resultCollection)//遍历集合
|
|
{
|
|
comboBoxLayer.Items.Add(result.LayerContent.Name);//添加图层名到图层组合框
|
|
}
|
|
IdentifyLayerResult firstLayerResult = resultCollection.First();//获取第一个集合中第一个图层
|
|
IReadOnlyList<GeoElement> selFeatures = firstLayerResult.GeoElements;//获取图层中所有要素
|
|
comboBoxRecord.Items.Clear();//清空记录组合框的内容
|
|
for(int i = 1; i <= selFeatures.Count; i++)
|
|
{
|
|
comboBoxRecord.Items.Add(i);//遍历要素集合,为记录组合框添加项
|
|
}
|
|
Feature ft = (Feature)selFeatures.First();//取得要素集合中第一个要素
|
|
dataGridContent.AutoGenerateColumns = true;//数据格网对象自动生成列
|
|
dataGridContent.ItemsSource = ft.Attributes;//设置数据格网中项的数据源
|
|
comboBoxLayer.SelectedIndex = 0;
|
|
comboBoxRecord.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
private void LocationQueryResultsWindow_OnClosed(object? sender, EventArgs e)
|
|
{
|
|
isClosed = true;
|
|
}
|
|
|
|
|
|
private void ComboBoxLayer_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
if(comboBoxLayer.SelectedIndex>-1)//索引有效
|
|
{
|
|
curSelLayer = resultCollection[comboBoxLayer.SelectedIndex];//取得索引对应的要素图层
|
|
comboBoxRecord.Items.Clear();//清空记录组合框的 内容
|
|
for(int i = 1; i <= curSelLayer.GeoElements.Count; i++)
|
|
{
|
|
comboBoxRecord.Items.Add(i);//遍历图层记录数,为记录组合框添加项
|
|
}
|
|
Feature ft = (Feature ) curSelLayer.GeoElements.First();//取得记录集中的第一个要素
|
|
dataGridContent.ItemsSource = ft.Attributes;//设置数据格网对象中项的数据源
|
|
comboBoxRecord.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
private void ComboBoxRecord_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
if(curSelLayer !=null && comboBoxRecord.SelectedIndex > -1)//当前图层不为空,所选记录索引有效
|
|
{
|
|
Feature ft = (Feature )
|
|
curSelLayer.GeoElements[comboBoxRecord.SelectedIndex];//获取索引所在要素
|
|
dataGridContent.ItemsSource = ft.Attributes;//设置数据格网对象中项的数据源
|
|
}
|
|
}
|
|
}
|
|
}
|