|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using DevExpress.XtraGrid.Columns;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
|
|
|
|
|
namespace KGIS.Plugin.LayerProperty.View.UC_Controls
|
|
|
|
|
{
|
|
|
|
|
public partial class UCFieldsList : UserControl
|
|
|
|
|
{
|
|
|
|
|
public UCFieldsList()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void InitUC(IFields fields)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DataTable dataTable = this.CreateDataTable();
|
|
|
|
|
if (fields != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fields.get_Field(i);
|
|
|
|
|
this.CreateDataRow(field, dataTable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.SetDataSource(dataTable);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//RdbUtil.AddException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private DataTable CreateDataTable()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DataTable dataTable = new DataTable();
|
|
|
|
|
DataColumn dataColumn = new DataColumn("name", Type.GetType("System.String"));
|
|
|
|
|
dataColumn.Caption = "名称";
|
|
|
|
|
dataTable.Columns.Add(dataColumn);
|
|
|
|
|
dataColumn = new DataColumn("alias", Type.GetType("System.String"));
|
|
|
|
|
dataColumn.Caption = "别名";
|
|
|
|
|
dataTable.Columns.Add(dataColumn);
|
|
|
|
|
dataColumn = new DataColumn("datatype", Type.GetType("System.String"));
|
|
|
|
|
dataColumn.Caption = "类型";
|
|
|
|
|
dataTable.Columns.Add(dataColumn);
|
|
|
|
|
dataColumn = new DataColumn("length", Type.GetType("System.Int32"));
|
|
|
|
|
dataColumn.Caption = "长度";
|
|
|
|
|
dataTable.Columns.Add(dataColumn);
|
|
|
|
|
dataColumn = new DataColumn("precision", Type.GetType("System.Int32"));
|
|
|
|
|
dataColumn.Caption = "精度";
|
|
|
|
|
dataTable.Columns.Add(dataColumn);
|
|
|
|
|
dataColumn = new DataColumn("scale", Type.GetType("System.Int32"));
|
|
|
|
|
dataColumn.Caption = "数值范围";
|
|
|
|
|
dataTable.Columns.Add(dataColumn);
|
|
|
|
|
dataColumn = new DataColumn("numberformat", Type.GetType("System.String"));
|
|
|
|
|
dataColumn.Caption = "数字格式";
|
|
|
|
|
dataTable.Columns.Add(dataColumn);
|
|
|
|
|
return dataTable;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//RdbUtil.AddException(ex);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
private void CreateDataRow(IField field, DataTable dt)
|
|
|
|
|
{
|
|
|
|
|
DataRow dataRow = dt.NewRow();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dataRow["name"] = field.Name;
|
|
|
|
|
dataRow["alias"] = field.AliasName;
|
|
|
|
|
string value = field.Type.ToString().Substring(13);
|
|
|
|
|
dataRow["datatype"] = value;
|
|
|
|
|
dataRow["length"] = field.Length;
|
|
|
|
|
dataRow["precision"] = field.Precision;
|
|
|
|
|
dataRow["scale"] = field.Scale;
|
|
|
|
|
dt.Rows.Add(dataRow);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//RdbUtil.AddException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void SetDataSource(DataTable source)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.gridViewMain.BeginDataUpdate();
|
|
|
|
|
this.gridViewMain.Columns.Clear();
|
|
|
|
|
this.gridViewMain.OptionsView.ColumnAutoWidth = false;
|
|
|
|
|
this.gridMainCtrl.DataSource = source;
|
|
|
|
|
this.gridMainCtrl.RefreshDataSource();
|
|
|
|
|
this.gridViewMain.PopulateColumns();
|
|
|
|
|
foreach (GridColumn gridColumn in this.gridViewMain.Columns)
|
|
|
|
|
{
|
|
|
|
|
gridColumn.Caption = source.Columns[gridColumn.FieldName].Caption;
|
|
|
|
|
}
|
|
|
|
|
this.gridViewMain.OptionsBehavior.Editable = false;
|
|
|
|
|
this.gridViewMain.OptionsView.ColumnAutoWidth = false;
|
|
|
|
|
this.gridViewMain.BestFitColumns();
|
|
|
|
|
this.gridViewMain.EndDataUpdate();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//TraceEvent.AddException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|