|
|
|
|
using DevExpress.XtraEditors;
|
|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace KGIS.Plugin.LayerProperty.View
|
|
|
|
|
{
|
|
|
|
|
public partial class FormAddValue : XtraForm
|
|
|
|
|
{
|
|
|
|
|
public string mFieldValue;
|
|
|
|
|
public ITable mTable;
|
|
|
|
|
public string mFieldName;
|
|
|
|
|
public IFeatureLayer2 mFeatrueLayer;
|
|
|
|
|
public FormAddValue()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
private void btnOk_Click(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.txtValue.Text.Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("请输入数值!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.mFieldValue = this.txtValue.Text.Trim();
|
|
|
|
|
base.DialogResult = DialogResult.OK;
|
|
|
|
|
base.Close();
|
|
|
|
|
}
|
|
|
|
|
private void btnCancel_Click(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.DialogResult = DialogResult.Cancel;
|
|
|
|
|
base.Close();
|
|
|
|
|
}
|
|
|
|
|
private void btnShowAll_Click(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.listValue.Items.Clear();
|
|
|
|
|
ArrayList arrayList = this.AddAllFieldValue(this.mTable, this.mFieldName);
|
|
|
|
|
if (arrayList == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("读取图层字段属性值出错");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.listValue.Items.Clear();
|
|
|
|
|
for (int i = 0; i < arrayList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
this.listValue.Items.Add(arrayList[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private ArrayList AddAllFieldValue(ITable vTable, string vFieldName)
|
|
|
|
|
{
|
|
|
|
|
long num = 0L;
|
|
|
|
|
ArrayList result;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IDataset dataset = (IDataset)vTable;
|
|
|
|
|
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)dataset.Workspace;
|
|
|
|
|
IQueryDef queryDef = featureWorkspace.CreateQueryDef();
|
|
|
|
|
queryDef.Tables = this.GetLayerPhysicalName(this.mFeatrueLayer);
|
|
|
|
|
queryDef.SubFields = "DISTINCT (" + vFieldName + ")";
|
|
|
|
|
ArrayList arrayList = new ArrayList();
|
|
|
|
|
ICursor cursor = queryDef.Evaluate();
|
|
|
|
|
for (IRow row = cursor.NextRow(); row != null; row = cursor.NextRow())
|
|
|
|
|
{
|
|
|
|
|
string text = row.get_Value(0).ToString().Trim();
|
|
|
|
|
if (!text.Equals(""))
|
|
|
|
|
{
|
|
|
|
|
arrayList.Add(text);
|
|
|
|
|
}
|
|
|
|
|
num += 1L;
|
|
|
|
|
if (num == 1000L && MessageHelper.ShowYesNoAndTips("读取到的值已经大于1000个,可能需要花费很长时间,是否继续?") == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result = arrayList;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//RdbUtil.AddException(ex);
|
|
|
|
|
result = null;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
private string GetLayerPhysicalName(IFeatureLayer2 featLyr)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass featureClass = featLyr.FeatureClass;
|
|
|
|
|
IDataset dataset = (IDataset)featureClass;
|
|
|
|
|
return dataset.Name;
|
|
|
|
|
}
|
|
|
|
|
private void listValue_Click(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.listValue.ItemCount == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (this.listValue.SelectedIndex < 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.txtValue.Text = this.listValue.SelectedItem.ToString();
|
|
|
|
|
}
|
|
|
|
|
public void SetValues(int vValueNum)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.txtValue.Text = "";
|
|
|
|
|
string text = this.listValue.Items[0].ToString();
|
|
|
|
|
if (text != null)
|
|
|
|
|
{
|
|
|
|
|
this.txtValue.Text = text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception value)
|
|
|
|
|
{
|
|
|
|
|
Console.Write(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void btnAddNew_Click(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!this.listValue.Items.Contains(this.txtValue.Text))
|
|
|
|
|
{
|
|
|
|
|
this.listValue.Items.Add(this.txtValue.Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void listValue_SelectedValueChanged(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.btnOk.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|