年度变更建库软件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.
 
 

130 lines
4.5 KiB

using DevExpress.XtraEditors;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using KGIS.Plugin.LayerProperty.Utils;
using System;
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 FormUniqueRendererFieldMatch : XtraForm
{
private string[] valueFields;
public string[] ValueFields
{
get
{
return this.valueFields;
}
set
{
this.valueFields = value;
}
}
public FormUniqueRendererFieldMatch()
{
InitializeComponent();
}
public void InitForm(IFeatureLayer currentLyer, IUniqueValueRenderer uniqueValueRenderer)
{
try
{
this.groupControl1.Enabled = false;
this.groupControl2.Enabled = false;
this.groupControl3.Enabled = false;
int fieldCount = uniqueValueRenderer.FieldCount;
this.valueFields = new string[]
{
"",
"",
""
};
for (int i = 0; i < fieldCount; i++)
{
if (i == 0)
{
this.lblValueField1.Text = uniqueValueRenderer.get_Field(i);
this.cmbLayerFields1.InitFieldList(currentLyer.FeatureClass.Fields, this.lblValueField1.Text, true, false, false);
this.groupControl1.Enabled = true;
}
if (i == 1)
{
this.lblValueField2.Text = uniqueValueRenderer.get_Field(i);
this.cmbLayerFields2.InitFieldList(currentLyer.FeatureClass.Fields, this.lblValueField2.Text, true, false, false);
this.groupControl2.Enabled = true;
}
if (i == 2)
{
this.lblValueField3.Text = uniqueValueRenderer.get_Field(i);
this.cmbLayerFields3.InitFieldList(currentLyer.FeatureClass.Fields, this.lblValueField3.Text, true, false, false);
this.groupControl3.Enabled = true;
}
}
this.GetValueFields();
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void InitFieldList(IFields fids, ref ComboBoxEdit cmb, string selected)
{
cmb.Properties.Items.Clear();
ItemInfo<IField, string> itemInfo = new ItemInfo<IField, string>(null, "none");
cmb.SelectedItem = itemInfo;
for (int i = 0; i < fids.FieldCount; i++)
{
IField field = fids.get_Field(i);
itemInfo = new ItemInfo<IField, string>(field, (field.AliasName == "") ? field.Name : field.AliasName);
cmb.Properties.Items.Add(itemInfo);
if (field.Name == selected)
{
cmb.SelectedItem = itemInfo;
}
}
}
private void btnOk_Click(object sender, System.EventArgs e)
{
this.GetValueFields();
base.DialogResult = DialogResult.OK;
base.Close();
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
base.DialogResult = DialogResult.Cancel;
base.Close();
}
private void GetValueFields()
{
try
{
IField selectedField = this.cmbLayerFields1.SelectedField;
if (selectedField != null)
{
this.valueFields.SetValue(selectedField.Name, 0);
}
selectedField = this.cmbLayerFields2.SelectedField;
if (selectedField != null)
{
this.valueFields.SetValue(selectedField.Name, 1);
}
selectedField = this.cmbLayerFields3.SelectedField;
if (selectedField != null)
{
this.valueFields.SetValue(selectedField.Name, 2);
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
}
}