|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Controls;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using KGIS.Framework.DBOperator;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using KGIS.Framework.Utils.Interface;
|
|
|
|
|
using KGIS.Framework.Views;
|
|
|
|
|
using Kingo.Plugin.NYYP.Common;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.NYYP.View
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UCNYYPInfo.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class UCNYYPInfo : UserControl, IElementInfo
|
|
|
|
|
{
|
|
|
|
|
public List<DicModel> m_dic = null;
|
|
|
|
|
|
|
|
|
|
public List<TreeData> Items { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<KeyValueData> VirtualTree { get; set; }
|
|
|
|
|
|
|
|
|
|
private EngineEditor editor { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当前图斑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IFeature CurrFeature = null;
|
|
|
|
|
|
|
|
|
|
public PropertyGridDataStruct SFJZStruct { get; set; }
|
|
|
|
|
|
|
|
|
|
public PropertyGridDataStruct NYJYStruct { get; set; }
|
|
|
|
|
|
|
|
|
|
public int SFJZIndex = -1;
|
|
|
|
|
public int NYJYIndex = -1;
|
|
|
|
|
|
|
|
|
|
private bool _needJZ;
|
|
|
|
|
private string _nYBZ;
|
|
|
|
|
public bool NeedJZ
|
|
|
|
|
{
|
|
|
|
|
get => _needJZ;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_needJZ = value;
|
|
|
|
|
if (DLTBBGFC != null && CurrFeature != null && SFJZIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
string v = value ? "1" : "0";
|
|
|
|
|
if (v == CurrFeature.Value[SFJZIndex].ToTrim())
|
|
|
|
|
return;
|
|
|
|
|
CurrFeature = DLTBBGFC.GetFeature(CurrFeature.OID);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
editor.StartOperation();
|
|
|
|
|
CurrFeature.Value[SFJZIndex] = value ? 1 : 0;
|
|
|
|
|
editor.StopOperation("");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
editor.AbortOperation();
|
|
|
|
|
LogAPI.Debug(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public string NYBZ
|
|
|
|
|
{
|
|
|
|
|
get => _nYBZ;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_nYBZ = value;
|
|
|
|
|
if (CurrFeature != null && SFJZIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
editor.StartOperation();
|
|
|
|
|
CurrFeature.Value[NYJYIndex] = value;
|
|
|
|
|
editor.StopOperation("");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
editor.AbortOperation();
|
|
|
|
|
LogAPI.Debug(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private IFeatureClass DLTBBGFC = null;
|
|
|
|
|
#region 继承属性
|
|
|
|
|
public bool IsShow { get; set; }
|
|
|
|
|
public int ShowIndex { get; set; }
|
|
|
|
|
public bool ResetSize { get; set; }
|
|
|
|
|
public bool AllowEdit { get; set; }
|
|
|
|
|
public Guid ID { get; set; }
|
|
|
|
|
public DockStyle DockAreas { get; set; }
|
|
|
|
|
public System.Drawing.Size FloatSize { get; set; }
|
|
|
|
|
public int DockWidth { get; set; }
|
|
|
|
|
public int DockHeight { get; set; }
|
|
|
|
|
public DockStyle DefaultArea { get; set; }
|
|
|
|
|
public bool ShowCloseButton { get; set; }
|
|
|
|
|
public bool ShowAutoHideButton { get; set; }
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public UCNYYPInfo()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
//this.DataContext = this;
|
|
|
|
|
Title = "内业预判";
|
|
|
|
|
DockHeight = 210;
|
|
|
|
|
|
|
|
|
|
this.Loaded += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
if (editor == null)
|
|
|
|
|
editor = new EngineEditorClass();
|
|
|
|
|
editor.OnStopEditing += (x) =>
|
|
|
|
|
{
|
|
|
|
|
AllowEdit = false;
|
|
|
|
|
RefreshView();
|
|
|
|
|
};
|
|
|
|
|
editor.OnStartEditing += () =>
|
|
|
|
|
{
|
|
|
|
|
AllowEdit = true;
|
|
|
|
|
RefreshView();
|
|
|
|
|
};
|
|
|
|
|
DLTBBGFC = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG").FeatureClass;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateVirtualTree(TreeData node)
|
|
|
|
|
{
|
|
|
|
|
node.Items.ForEach(it =>
|
|
|
|
|
{
|
|
|
|
|
var newname = it.Name;
|
|
|
|
|
if (node.Name.StartsWith("--"))
|
|
|
|
|
{
|
|
|
|
|
var jc = node.Name.Count(x => x == '-') + 1;
|
|
|
|
|
for (int i = 0; i < jc; i++)
|
|
|
|
|
{
|
|
|
|
|
newname = "-" + newname;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
newname = "--" + newname;
|
|
|
|
|
}
|
|
|
|
|
VirtualTree.Add(new KeyValueData() { NodeID = it.ID, NodeName = " " + newname });
|
|
|
|
|
CreateVirtualTree(it);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<TreeData> GetDatas(string parentId = "")
|
|
|
|
|
{
|
|
|
|
|
List<TreeData> dataList = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dataList = new List<TreeData>();
|
|
|
|
|
for (int i = 0; i < m_dic.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
TreeData data = new TreeData();
|
|
|
|
|
if (parentId == "")
|
|
|
|
|
{
|
|
|
|
|
if (false == string.IsNullOrEmpty(m_dic[i].PID))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if (string.IsNullOrEmpty(m_dic[i].PID) && string.IsNullOrEmpty(m_dic[i].ID))
|
|
|
|
|
{
|
|
|
|
|
data.ID = "";
|
|
|
|
|
data.Name = "";
|
|
|
|
|
data.Items = null;
|
|
|
|
|
dataList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data.ID = m_dic[i].CODE;
|
|
|
|
|
data.Name = m_dic[i].NAME;
|
|
|
|
|
data.Items = GetDatas(m_dic[i].ID);
|
|
|
|
|
dataList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (parentId.Trim().Equals(m_dic[i].PID.Trim()))
|
|
|
|
|
{
|
|
|
|
|
data.ID = m_dic[i].CODE;
|
|
|
|
|
data.Name = m_dic[i].NAME;
|
|
|
|
|
data.Items = GetDatas(m_dic[i].ID);
|
|
|
|
|
dataList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return dataList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetDicModel()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
m_dic = new List<DicModel>();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string connStr = string.Format(SysConfigsOprator.GetDBConnectionByName("MDBOledbConnection"), (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetDicDataPath());
|
|
|
|
|
object hhj = MapsManager.Instance.MapService;
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper(connStr, DatabaseType.MSAccess);
|
|
|
|
|
if (rdbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("数据库连接打开失败:" + connStr);
|
|
|
|
|
}
|
|
|
|
|
DataTable dt = rdbHelper.ExecuteDatatable("dt", "SELECT * FROM Sys_DicManage where ALIASNAME='" + "DLBM" + "'", true);
|
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
DataTable dt2 = rdbHelper.ExecuteDatatable("dt2", "SELECT * FROM Sys_DicDetail where OWNERDIC='" + dt.Rows[0]["ID"] + "'", true);
|
|
|
|
|
dt2.DefaultView.Sort = "CODE ASC";
|
|
|
|
|
dt2 = dt2.DefaultView.ToTable();
|
|
|
|
|
DicModel d1 = new DicModel
|
|
|
|
|
{
|
|
|
|
|
ID = "",
|
|
|
|
|
PID = "",
|
|
|
|
|
CODE = "",
|
|
|
|
|
NAME = ""
|
|
|
|
|
};
|
|
|
|
|
m_dic.Add(d1);
|
|
|
|
|
foreach (DataRow item in dt2.Rows)
|
|
|
|
|
{
|
|
|
|
|
DicModel d = new DicModel
|
|
|
|
|
{
|
|
|
|
|
ID = item["ID"].ToString(),
|
|
|
|
|
PID = item["PID"].ToString(),
|
|
|
|
|
CODE = item["CODE"].ToString(),
|
|
|
|
|
NAME = item["CODE"].ToString() + "-" + item["NAME"].ToString()
|
|
|
|
|
};
|
|
|
|
|
m_dic.Add(d);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("查询字典失败:" + ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("查询字典失败:" + ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//public void BindData2(object obj)
|
|
|
|
|
//{
|
|
|
|
|
// 初始化地类控件信息
|
|
|
|
|
// if (VirtualTree == null)
|
|
|
|
|
// {
|
|
|
|
|
// GetDicModel();
|
|
|
|
|
// Items = GetDatas();
|
|
|
|
|
// VirtualTree = new List<KeyValueData>();
|
|
|
|
|
// foreach (var node in Items)
|
|
|
|
|
// {
|
|
|
|
|
// if (node.Items != null)
|
|
|
|
|
// {
|
|
|
|
|
// VirtualTree.Add(new KeyValueData() { NodeID = node.ID, NodeName = node.Name });
|
|
|
|
|
// CreateVirtualTree(node);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// this.cmbCtr.ItemsSource = VirtualTree;
|
|
|
|
|
// }
|
|
|
|
|
// if (obj == null)
|
|
|
|
|
// {
|
|
|
|
|
// if (CurrFeature != null)
|
|
|
|
|
// {
|
|
|
|
|
// System.Runtime.InteropServices.Marshal.ReleaseComObject(CurrFeature);
|
|
|
|
|
// CurrFeature = null;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// SFJZStruct = new PropertyGridDataStruct();
|
|
|
|
|
// rbtnWYTrue.IsChecked = false;//举证
|
|
|
|
|
// NeedJZ = false;
|
|
|
|
|
// NYBZ = "";
|
|
|
|
|
// cmbCtr.SelectedItem = null;
|
|
|
|
|
// cmbCtr.Text = "";
|
|
|
|
|
// }
|
|
|
|
|
// 绑定内业信息
|
|
|
|
|
// if (obj != null && obj is IFeature)
|
|
|
|
|
// {
|
|
|
|
|
// CurrFeature = obj as IFeature;
|
|
|
|
|
// IFeatureLayer jcdltbLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG");
|
|
|
|
|
// SFJZIndex = jcdltbLayer.FeatureClass.FindField("SFJZ");
|
|
|
|
|
// NYJYIndex = jcdltbLayer.FeatureClass.FindField("NYJY");
|
|
|
|
|
// int NYYPDLIndex = jcdltbLayer.FeatureClass.FindField("NYYPDL");
|
|
|
|
|
// if (SFJZIndex != -1)
|
|
|
|
|
// {
|
|
|
|
|
// SFJZStruct = new PropertyGridDataStruct();
|
|
|
|
|
// SFJZStruct.Key = "是否举证";
|
|
|
|
|
// SFJZStruct.KeyIndex = SFJZIndex;
|
|
|
|
|
// SFJZStruct.Value = CurrFeature.Value[SFJZIndex].ToTrim();
|
|
|
|
|
// SFJZStruct.PropertyType = enumPropertyType.CheckBox;
|
|
|
|
|
// SFJZStruct.PropertyChanged += SFJZStruct_PropertyChanged;
|
|
|
|
|
// NeedJZ = CurrFeature.Value[SFJZIndex].ToTrim() == "1";
|
|
|
|
|
// if (CurrFeature.Value[SFJZIndex].ToString() == "1")
|
|
|
|
|
// {
|
|
|
|
|
// cbNeedWY.IsChecked = true;//举证
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// cbNeedWY.IsChecked = false;//举证
|
|
|
|
|
// }
|
|
|
|
|
// if (CurrFeature.Value[SFJZIndex].ToString() == "0")
|
|
|
|
|
// {
|
|
|
|
|
// cbNeedWY.IsChecked = true;
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// cbNeedWY.IsChecked = false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (NYJYIndex != -1)
|
|
|
|
|
// {
|
|
|
|
|
// SFJZStruct = new PropertyGridDataStruct();
|
|
|
|
|
// SFJZStruct.Key = "是否举证";
|
|
|
|
|
// SFJZStruct.KeyIndex = NYJYIndex;
|
|
|
|
|
// SFJZStruct.Value = CurrFeature.Value[NYJYIndex].ToTrim();
|
|
|
|
|
// SFJZStruct.PropertyType = enumPropertyType.TextBox;
|
|
|
|
|
// SFJZStruct.PropertyChanged += SFJZStruct_PropertyChanged;
|
|
|
|
|
// NYBZ = CurrFeature.Value[NYJYIndex].ToTrim();
|
|
|
|
|
// NYJYText.Text = CurrFeature.Value[NYJYIndex].ToString();
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// NYJYText.Text = "";
|
|
|
|
|
// }
|
|
|
|
|
// this.DataContext = this;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
private List<PropertyGridDataStruct> Property = null;
|
|
|
|
|
public void BindData(object obj)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (obj is IFeature)
|
|
|
|
|
CurrFeature = obj as IFeature;
|
|
|
|
|
if (Property == null)
|
|
|
|
|
Property = new List<PropertyGridDataStruct>();
|
|
|
|
|
Property.Clear();
|
|
|
|
|
if (obj == null)
|
|
|
|
|
{
|
|
|
|
|
grid.Children.Clear();
|
|
|
|
|
grid.RowDefinitions.Clear();
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
if (obj is IFeature)
|
|
|
|
|
{
|
|
|
|
|
AllowEdit = !(editor.EditState == esriEngineEditState.esriEngineStateNotEditing || (editor.EditWorkspace != null && editor.EditWorkspace.PathName != ((obj as IFeature).Class as FeatureClass).Workspace.PathName));
|
|
|
|
|
IFeature fe = obj as IFeature;
|
|
|
|
|
for (int i = 0; i < fe.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fe.Fields.get_Field(i);
|
|
|
|
|
if (field.Name.ToUpper() == "SHAPE" || field.Name.ToUpper().Contains("_EXTRA") || field.Name == "ErrorMessage" || field.Name == "ErrorShape")
|
|
|
|
|
continue;
|
|
|
|
|
IDomain domain = field.Domain;
|
|
|
|
|
PropertyGridDataStruct p = new PropertyGridDataStruct();
|
|
|
|
|
p.DisplayMemberPath = "DisplayName";
|
|
|
|
|
p.ValuePath = "CODE";
|
|
|
|
|
if (!field.Editable)
|
|
|
|
|
{
|
|
|
|
|
p.IsReadOnly = !field.Editable;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
p.IsReadOnly = editor.EditState == esriEngineEditState.esriEngineStateNotEditing || (editor.EditWorkspace != null && editor.EditWorkspace.PathName != (fe.Class as FeatureClass).Workspace.PathName);
|
|
|
|
|
}
|
|
|
|
|
//是否可以为空
|
|
|
|
|
p.AllowNull = field.IsNullable;
|
|
|
|
|
if (string.IsNullOrWhiteSpace(field.AliasName))
|
|
|
|
|
{
|
|
|
|
|
p.Key = field.Name;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
p.Key = field.AliasName;
|
|
|
|
|
}
|
|
|
|
|
p.FieldName = field.Name;
|
|
|
|
|
if (fe.get_Value(i) is DBNull || fe.get_Value(i) == null)
|
|
|
|
|
{
|
|
|
|
|
p.Value = null;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
p.Value = fe.get_Value(i).ToString().Trim();
|
|
|
|
|
}
|
|
|
|
|
if (p.Key == "是否举证")
|
|
|
|
|
{
|
|
|
|
|
p.PropertyType = enumPropertyType.CheckBox;
|
|
|
|
|
p.Value = fe.get_Value(i).ToString().Trim() == "1" ? "True" : "False";
|
|
|
|
|
}
|
|
|
|
|
else if (p.Key == "举证说明")
|
|
|
|
|
{
|
|
|
|
|
p.PropertyType = enumPropertyType.TextBox;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
p.PropertyChanged += PropertyChangedEvent;
|
|
|
|
|
Property.Add(p);
|
|
|
|
|
}
|
|
|
|
|
RefreshView();
|
|
|
|
|
this.DataContext = Property;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("图斑变更属性编辑失败:" + ex.Message);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void RefreshView()
|
|
|
|
|
{
|
|
|
|
|
#region
|
|
|
|
|
grid.Children.Clear();
|
|
|
|
|
grid.RowDefinitions.Clear();
|
|
|
|
|
Property = Property.OrderBy(o => o.Order).ToList();
|
|
|
|
|
foreach (var item in Property)
|
|
|
|
|
{
|
|
|
|
|
item.Visible = true;
|
|
|
|
|
if (item.Visible)
|
|
|
|
|
{
|
|
|
|
|
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(37, GridUnitType.Pixel) });
|
|
|
|
|
Label lab = new Label();
|
|
|
|
|
lab.Content = item.Key;
|
|
|
|
|
lab.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
|
|
|
|
|
lab.HorizontalContentAlignment = HorizontalAlignment.Right;
|
|
|
|
|
lab.Margin = new Thickness(4);
|
|
|
|
|
grid.Children.Add(lab);
|
|
|
|
|
|
|
|
|
|
Control ctrl = new TextBox();
|
|
|
|
|
ctrl.Height = 27;
|
|
|
|
|
Binding bind = new Binding();
|
|
|
|
|
bind.Path = new PropertyPath("Value");
|
|
|
|
|
bind.Mode = BindingMode.TwoWay;
|
|
|
|
|
switch (item.PropertyType)
|
|
|
|
|
{
|
|
|
|
|
case enumPropertyType.Default:
|
|
|
|
|
case enumPropertyType.TextBox:
|
|
|
|
|
ctrl = new TextBox();
|
|
|
|
|
ctrl.Margin = new Thickness(2);
|
|
|
|
|
ctrl.Height = 27;
|
|
|
|
|
ctrl.DataContext = item;
|
|
|
|
|
bind.UpdateSourceTrigger = UpdateSourceTrigger.LostFocus;
|
|
|
|
|
ctrl.SetBinding(TextBox.TextProperty, bind);
|
|
|
|
|
ctrl.IsEnabled = AllowEdit;
|
|
|
|
|
break;
|
|
|
|
|
case enumPropertyType.CheckBox:
|
|
|
|
|
ctrl = new CheckBox();
|
|
|
|
|
ctrl.Margin = new Thickness(9);
|
|
|
|
|
ctrl.DataContext = item;
|
|
|
|
|
ctrl.SetBinding(CheckBox.IsCheckedProperty, bind);
|
|
|
|
|
ctrl.IsEnabled = AllowEdit;
|
|
|
|
|
break;
|
|
|
|
|
case enumPropertyType.DatePicker:
|
|
|
|
|
ctrl = new DatePicker();
|
|
|
|
|
ctrl.Margin = new Thickness(2);
|
|
|
|
|
ctrl.DataContext = item;
|
|
|
|
|
ctrl.SetBinding(DatePicker.TextProperty, bind);
|
|
|
|
|
ctrl.IsEnabled = AllowEdit;
|
|
|
|
|
break;
|
|
|
|
|
case enumPropertyType.SpinEdit:
|
|
|
|
|
break;
|
|
|
|
|
case enumPropertyType.ButtonEdit:
|
|
|
|
|
break;
|
|
|
|
|
case enumPropertyType.ComboBox:
|
|
|
|
|
case enumPropertyType.AutoCompleteBox:
|
|
|
|
|
//ctrl = new AutoCompleteBox();
|
|
|
|
|
//ctrl.Height = 27;
|
|
|
|
|
//ctrl.DataContext = item;
|
|
|
|
|
//bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
|
|
|
|
|
//ctrl.SetValue(AutoCompleteBox.ItemsSourceProperty, item.DicData);
|
|
|
|
|
//ctrl.SetValue(AutoCompleteBox.ValueMemberPathProperty, item.ValuePath);
|
|
|
|
|
//ctrl.SetValue(AutoCompleteBox.DisplayMemberPathProperty, item.DisplayMemberPath);
|
|
|
|
|
//ctrl.SetBinding(AutoCompleteBox.SelectedValueProperty, bind);
|
|
|
|
|
//ctrl.IsEnabled = AllowEdit;
|
|
|
|
|
//(ctrl as AutoCompleteBox).IsEditable = AllowEdit;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ctrl.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
|
|
|
|
|
ctrl.SetValue(Grid.ColumnProperty, 1);
|
|
|
|
|
ctrl.HorizontalAlignment = HorizontalAlignment.Stretch;
|
|
|
|
|
grid.Children.Add(ctrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grid.RowDefinitions.Add(new RowDefinition());
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PropertyChangedEvent(object sender, PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//if (MyPropertyGrid.ItemsSource == null)
|
|
|
|
|
// return;
|
|
|
|
|
PropertyGridDataStruct property = (PropertyGridDataStruct)sender;
|
|
|
|
|
if (property != null)
|
|
|
|
|
{
|
|
|
|
|
if (!property.Visible) return;
|
|
|
|
|
if (CurrFeature is IFeature)
|
|
|
|
|
{
|
|
|
|
|
int index = (CurrFeature as IFeature).Fields.FindField(property.Key);
|
|
|
|
|
if (index == -1)
|
|
|
|
|
index = (CurrFeature as IFeature).Fields.FindFieldByAliasName(property.Key);
|
|
|
|
|
if (index != -1)
|
|
|
|
|
{
|
|
|
|
|
SetFeatureValue(property);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//MyPropertyGrid.ItemsSource = MyPropertyGrid.ItemsSource;
|
|
|
|
|
}
|
|
|
|
|
IFeature feature = CurrFeature as IFeature;
|
|
|
|
|
Platform.Instance.SendMsg(new NotifyMsgPackage() { Content = feature, MsgType = "RefreshViewAttrTable" });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("属性改变事件期间 属性联动异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("属性改变事件期间 属性联动异常信息结束");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void SetFeatureValue(PropertyGridDataStruct proData)
|
|
|
|
|
{
|
|
|
|
|
if (CurrFeature is IFeature)
|
|
|
|
|
{
|
|
|
|
|
int index = (CurrFeature as IFeature).Fields.FindField(proData.Key);
|
|
|
|
|
if (index == -1)
|
|
|
|
|
index = (CurrFeature as IFeature).Fields.FindFieldByAliasName(proData.Key);
|
|
|
|
|
if (index != -1)
|
|
|
|
|
{
|
|
|
|
|
var val = (CurrFeature as IFeature).get_Value(index);
|
|
|
|
|
if (!val.Equals(proData.Value))
|
|
|
|
|
{
|
|
|
|
|
if (val is DBNull && string.IsNullOrWhiteSpace(proData.Value))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (editor.EditState == esriEngineEditState.esriEngineStateEditing)
|
|
|
|
|
{
|
|
|
|
|
editor.StartOperation();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (proData.Key == "耕地等别" && string.IsNullOrEmpty(proData.Value))
|
|
|
|
|
{
|
|
|
|
|
(CurrFeature as IFeature).set_Value(index, DBNull.Value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string tempVal = proData.Value;
|
|
|
|
|
if (proData.PropertyType == enumPropertyType.CheckBox)
|
|
|
|
|
tempVal = tempVal == "True" ? "1" : "0";
|
|
|
|
|
if ((CurrFeature as IFeature).Fields.get_Field(index).Length < tempVal.Length)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError(proData.Key + ":填写值长度过长!");
|
|
|
|
|
editor.AbortOperation();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
(CurrFeature as IFeature).set_Value(index, tempVal);
|
|
|
|
|
}
|
|
|
|
|
(CurrFeature as IFeature).Store();
|
|
|
|
|
if (proData.Visible)
|
|
|
|
|
RefreshView();
|
|
|
|
|
if (editor.EditState == esriEngineEditState.esriEngineStateEditing)
|
|
|
|
|
{
|
|
|
|
|
editor.StopOperation("Attribute update");
|
|
|
|
|
//ExecuteDataCheck(Data as IFeature);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex2)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("属性改变事件中 结束编辑操作期间 时异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex2);
|
|
|
|
|
LogAPI.Debug("属性改变事件中 结束编辑操作期间 时异常信息结束");
|
|
|
|
|
editor.AbortOperation();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveEdit()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//if (CurrFeature != null)
|
|
|
|
|
//{
|
|
|
|
|
// EngineEditor editor = new EngineEditorClass();
|
|
|
|
|
// IEngineEditLayers pEditLayer = editor as IEngineEditLayers;
|
|
|
|
|
// IFeatureClass jcdltbFC = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG").FeatureClass;
|
|
|
|
|
// int NYYPDLIndex = jcdltbFC.FindField("NYYPDL");
|
|
|
|
|
// bool IsStateEditing = editor.EditState == esriEngineEditState.esriEngineStateEditing ? true : false;
|
|
|
|
|
// CurrFeature = jcdltbFC.GetFeature(CurrFeature.OID);
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// //if (editor.EditState == esriEngineEditState.esriEngineStateEditing)
|
|
|
|
|
// // editor.StartOperation();
|
|
|
|
|
// //else
|
|
|
|
|
// // return;
|
|
|
|
|
// //if (cbNeedWY.IsChecked == true)
|
|
|
|
|
// // CurrFeature.Value[SFJZIndex] = "1";
|
|
|
|
|
// //else
|
|
|
|
|
// // CurrFeature.Value[SFJZIndex] = "0";
|
|
|
|
|
// //CurrFeature.Value[NYJYIndex] = NYJYText.Text;
|
|
|
|
|
// ////CurrFeature.Store();
|
|
|
|
|
// //if (editor.EditState == esriEngineEditState.esriEngineStateEditing)
|
|
|
|
|
// // editor.StopOperation("Attribute update");
|
|
|
|
|
// }
|
|
|
|
|
// catch (Exception e)
|
|
|
|
|
// {
|
|
|
|
|
// LogAPI.Debug("基础信息保存失败:" + e.Message);
|
|
|
|
|
// editor.AbortOperation();
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("基础信息保存失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字典类
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class DicModel
|
|
|
|
|
{
|
|
|
|
|
public string NAME { get; set; }
|
|
|
|
|
public string CODE { get; set; }
|
|
|
|
|
public string ID { get; set; }
|
|
|
|
|
public string PID { get; set; }
|
|
|
|
|
}
|
|
|
|
|
public class PropertyGridDataStruct : IPropertyStruct, INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
public string HeaderToolTip { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性名(键)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Key { get; set; }
|
|
|
|
|
public string FieldName { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string Text { get; set; }
|
|
|
|
|
|
|
|
|
|
private string _SelectText;
|
|
|
|
|
public string SelectText
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _SelectText;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_SelectText = value;
|
|
|
|
|
|
|
|
|
|
//if (PropertyChanged != null)
|
|
|
|
|
// PropertyChanged(this, new PropertyChangedEventArgs("SelectText"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示字体颜色
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string FontColor { get; set; }
|
|
|
|
|
|
|
|
|
|
private string _Value;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性值
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Value
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _Value;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_Value = value;
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs("Value"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int KeyIndex { get; set; }
|
|
|
|
|
public int ValueIndex { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enumPropertyType PropertyType { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字典Code;当PropertyType=ComboBox时必填
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string DicCode { get; set; }
|
|
|
|
|
//private List<DataDicTionary> _DicData;
|
|
|
|
|
//public List<DataDicTionary> DicData
|
|
|
|
|
//{
|
|
|
|
|
// get
|
|
|
|
|
// {
|
|
|
|
|
// return _DicData;
|
|
|
|
|
// }
|
|
|
|
|
// set
|
|
|
|
|
// {
|
|
|
|
|
// _DicData = value;
|
|
|
|
|
// //if (PropertyChanged != null)
|
|
|
|
|
// //{
|
|
|
|
|
// // PropertyChanged(this, new PropertyChangedEventArgs("DicData"));
|
|
|
|
|
// //}
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
private string _DisplayPath;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示字段(初始化字典绑定)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string DisplayMemberPath
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(_DisplayPath))
|
|
|
|
|
return "NAME";
|
|
|
|
|
return _DisplayPath;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_DisplayPath = value;
|
|
|
|
|
//if (PropertyChanged != null)
|
|
|
|
|
//{
|
|
|
|
|
// PropertyChanged(this, new PropertyChangedEventArgs("DisplayMemberPath"));
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string _ValuePath;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 值字段(初始化字典绑定)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ValuePath
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(_ValuePath))
|
|
|
|
|
return "CODE";
|
|
|
|
|
return _ValuePath;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_ValuePath = value;
|
|
|
|
|
//if (PropertyChanged != null)
|
|
|
|
|
//{
|
|
|
|
|
// PropertyChanged(this, new PropertyChangedEventArgs("ValuePath"));
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _IsReadOnly;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否只读
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsReadOnly
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _IsReadOnly;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_IsReadOnly = value;
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs("IsReadOnly"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 允许空值
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool AllowNull { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 表示下拉框是否需要分组(树形)显示
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsGroup { get; set; }
|
|
|
|
|
public bool CheckBoxValue { get; set; }
|
|
|
|
|
public bool Visible { get; set; }
|
|
|
|
|
public int Order { get; set; }
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;// = delegate { };
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public interface IPropertyStruct
|
|
|
|
|
{
|
|
|
|
|
string Key { get; set; }
|
|
|
|
|
string Value { get; set; }
|
|
|
|
|
//List<DataDicTionary> DicData { get; set; }
|
|
|
|
|
string DisplayMemberPath { get; set; }
|
|
|
|
|
string ValuePath { get; set; }
|
|
|
|
|
bool IsReadOnly { get; set; }
|
|
|
|
|
bool Visible { get; set; }
|
|
|
|
|
}
|
|
|
|
|
public enum enumPropertyType
|
|
|
|
|
{
|
|
|
|
|
Default = 0,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 文本框
|
|
|
|
|
/// </summary>
|
|
|
|
|
TextBox = 1,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下拉框
|
|
|
|
|
/// </summary>
|
|
|
|
|
ComboBox = 2,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 复选框
|
|
|
|
|
/// </summary>
|
|
|
|
|
CheckBox = 3,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日期控件
|
|
|
|
|
/// </summary>
|
|
|
|
|
DatePicker = 4,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数字控件
|
|
|
|
|
/// </summary>
|
|
|
|
|
SpinEdit = 5,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 带按钮的文本框
|
|
|
|
|
/// </summary>
|
|
|
|
|
ButtonEdit = 6,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 带下拉框的文本框
|
|
|
|
|
/// </summary>
|
|
|
|
|
AutoCompleteBox = 7
|
|
|
|
|
}
|
|
|
|
|
}
|