年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

180 lines
7.0 KiB

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using KGIS.Framework.Maps;
using KGIS.Framework.OpenData.Control;
using KGIS.Framework.OpenData.Filter;
using KGIS.Framework.OpenData.InterFace;
using KGIS.Framework.Platform;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.Helper;
using Kingo.Plugin.XZQ_IDG.Helper;
using System;
using System.Collections.Generic;
using System.Windows;
using KUI.Windows;
namespace Kingo.Plugin.XZQ_IDG.View
{
/// <summary>
/// UCExtractDistrict.xaml 的交互逻辑
/// </summary>
public partial class UCExtractDistrict : BaseWindow
{
private Dictionary<string, int> jc_FieldsIndex;
private Dictionary<string, int> gx_FieldsIndex;
private Dictionary<string, int> gxgc_FieldsIndex;
private Dictionary<string, int> tzh_FieldsIndex;
IFeatureLayer jccjdcqLayer = null;
IFeatureLayer jcxzqLayer = null;
IFeatureClass drqCJDCQFc = null;
IFeatureClass drqXZQFc = null;
IFeatureLayer jcgddblayer = null;
public UCExtractDistrict()
{
InitializeComponent();
this.CheckBox_cjdcq.IsChecked = true;
this.CheckBox_xzq.IsChecked = true;
this.CheckBox_gddb.IsChecked = true;
}
/// <summary>
/// 单独图斑提取确定按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOK_Click(object sender, RoutedEventArgs e)
{
try
{
List<DataDicTionary> qsDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM);
if (qsDic == null)
{
MessageHelper.ShowError("请先生成权属单位代码表...");
return;
}
if (this.CheckBox_cjdcq.IsChecked == false && this.CheckBox_gddb.IsChecked == false && this.CheckBox_xzq.IsChecked == false)
{
MessageBox.Show("请最少选择一项内容进行分析");
return;
}
if (CheckBox_gddb.IsChecked == true)
{
jcgddblayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("耕地等别");
if (jcgddblayer == null)
{
MessageHelper.ShowError("未找到耕地等别图层,无法进行耕地等别数据提取...");
return;
}
}
if (CheckBox_cjdcq.IsChecked == true)
{
//村级调查区更新/村级调查区更新过程/基础村级调查区
jccjdcqLayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("村级调查区");
if (jccjdcqLayer == null)
{
MessageHelper.ShowError("未找到村级调查区图层,无法进行村级调查区数据提取...");
return;
}
}
if (CheckBox_xzq.IsChecked == true)
{
//行政区更新/行政区更新过程/基础行政区
jcxzqLayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("行政区");
if (jcxzqLayer == null)
{
MessageHelper.ShowError("未找到基础行政区图层,无法进行行政区数据提取...");
return;
}
}
this.btnOK.IsEnabled = false;//功能按钮禁用
this.btnCancel.IsEnabled = false;
this.btnXZQPath.IsEnabled = false;
this.btnCJDCQPath.IsEnabled = false;
this.ShowLoading("正在进行行政区数据提取,请稍候...", 0, 0);
XZQ_IDGHelper xZQ_IDGHelper = new XZQ_IDGHelper();
xZQ_IDGHelper.Implement(
this.CheckBox_gddb.IsChecked == true,
this.CheckBox_cjdcq.IsChecked == true,
this.cb_ZLDWMCChange.IsChecked == true,
this.CheckBox_xzq.IsChecked == true,
this.cb_XZQDMChange.IsChecked == true,
drqCJDCQFc,
drqXZQFc
);
this.CloseLoading();
MessageHelper.Show("提取完成.");
this.Close();
}
catch (Exception ex)
{
this.btnOK.IsEnabled = true;
this.btnCancel.IsEnabled = true;
this.btnXZQPath.IsEnabled = true;
this.btnCJDCQPath.IsEnabled = true;
MessageHelper.ShowError($"行政区数据提取失败:{ex.Message}");
}
}
/// <summary>
/// 关闭按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void BtnXZQPath_Click(object sender, RoutedEventArgs e)
{
string FcPath = string.Empty;
drqXZQFc = GetSelectionFc(ref FcPath);
btnXZQ.EditValue = FcPath;
}
private void BtnCJDCQPath_Click(object sender, RoutedEventArgs e)
{
string FcPath = string.Empty;
drqCJDCQFc = GetSelectionFc(ref FcPath);
btnCJDCQ.EditValue = FcPath;
}
private IFeatureClass GetSelectionFc(ref string strFcPath)
{
IFeatureClass result = null;
try
{
// 获取源数据
OpenDataDialog pDialog = new OpenDataDialog();
ISpatialDataObjectFilter pOFilter;
pOFilter = new FilterFeatureDatasetsAndFeatureClasses();
pDialog.AddFilter(pOFilter, true);
pDialog.Title = "选择划调整范围数据";
pDialog.AllowMultiSelect = false;
pDialog.RestoreLocation = true;
pDialog.StartLocation = pDialog.FinalLocation;
if (pDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count > 0)
{
List<ISpatialDataObject> distObj = pDialog.Selection;
foreach (var obj in distObj)
{
if (obj.DatasetType == esriDatasetType.esriDTFeatureClass)
{
result = (obj.DatasetName as IName).Open() as IFeatureClass;
strFcPath = obj.FullName;
}
}
}
else
{
return result;
}
}
catch (Exception ex)
{
LogAPI.Debug("选择数据失败:" + ex.Message.ToString());
}
return result;
}
}
}