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.
		
		
		
		
		
			
		
			
				
					
					
						
							2215 lines
						
					
					
						
							97 KiB
						
					
					
				
			
		
		
	
	
							2215 lines
						
					
					
						
							97 KiB
						
					
					
				using System; | 
						|
using System.Collections.Generic; | 
						|
using System.Drawing; | 
						|
using System.Data; | 
						|
using System.Windows.Forms; | 
						|
using KGIS.Framework.Views; | 
						|
using ESRI.ArcGIS.Carto; | 
						|
using ESRI.ArcGIS.Geodatabase; | 
						|
using ESRI.ArcGIS.Controls; | 
						|
using KGIS.Framework.Maps; | 
						|
using DevExpress.XtraBars; | 
						|
using DevExpress.XtraGrid.Views.Grid; | 
						|
using KGIS.Framework.Platform; | 
						|
using ESRI.ArcGIS.Geometry; | 
						|
using System.Linq; | 
						|
using KGIS.Framework.Utils; | 
						|
using System.Collections; | 
						|
using KGIS.Framework.Utils.Helper; | 
						|
using KGIS.Framework.Utils.Interface; | 
						|
using DockStyle = KGIS.Framework.Views.DockStyle; | 
						|
using Kingo.PluginServiceInterface; | 
						|
using KGIS.Framework.AE; | 
						|
using KGIS.Framework.ThreadManager; | 
						|
using System.Runtime.InteropServices; | 
						|
using DevExpress.Data; | 
						|
using System.Xml; | 
						|
using KGIS.Framework.Utils.ExtensionMethod; | 
						|
using DevExpress.XtraGrid.Columns; | 
						|
using ESRI.ArcGIS.Geoprocessor; | 
						|
using ESRI.ArcGIS.DataManagementTools; | 
						|
using KUI.Windows; | 
						|
 | 
						|
namespace Kingo.Plugin.MapView.Views | 
						|
{ | 
						|
    public partial class ViewAttrTable : UserControl, IDockPanel2, IAttrTableView | 
						|
    { | 
						|
        #region UCAttribute_Form类全局变量         | 
						|
        /// <summary> | 
						|
        /// 视图选中数量(取消了默认焦点行,该值为零) | 
						|
        /// </summary> | 
						|
        int SelectCount = 0; | 
						|
        /// <summary> | 
						|
        /// 要查询的属性图层 | 
						|
        /// </summary> | 
						|
        private IFeatureLayer _curFeatureLayer; | 
						|
        public IFeatureLayer CurFeatureLayer | 
						|
        { | 
						|
            get { return _curFeatureLayer; } | 
						|
            set { _curFeatureLayer = value; } | 
						|
        } | 
						|
        /// <summary> | 
						|
        /// 要查询的属性图层 | 
						|
        /// </summary> | 
						|
        private IHookHelper _hookHelper; | 
						|
        public IHookHelper M_hookHelper | 
						|
        { | 
						|
            get { return _hookHelper; } | 
						|
            set { _hookHelper = value; } | 
						|
        } | 
						|
        public static bool selectbox = false;//选择 | 
						|
        /// <summary> | 
						|
        /// GridView视图表 | 
						|
        /// </summary> | 
						|
        DataTable Data = new DataTable(); | 
						|
        /// <summary> | 
						|
        /// 视图数据 | 
						|
        /// </summary> | 
						|
        IFeature pFeature = null; | 
						|
        /// <summary> | 
						|
        /// 编辑状态 | 
						|
        /// </summary> | 
						|
        public bool isEngineEditing = true; | 
						|
        /// <summary> | 
						|
        /// 属性表全部的objectid | 
						|
        /// </summary> | 
						|
        List<int> objectids = new List<int>(); | 
						|
        /// <summary> | 
						|
        /// 属性表过滤后全部的OIDs | 
						|
        /// </summary> | 
						|
        List<int> Filteredids = new List<int>(); | 
						|
        /// <summary> | 
						|
        /// 初始化mapService工具 | 
						|
        /// </summary> | 
						|
        IMapService _mapService = null; | 
						|
        private int IndexOID = 1; | 
						|
        private EngineEditor _Edit = null; | 
						|
        public List<ViewAttrTable> AttrTableViewLists = new List<ViewAttrTable>(); | 
						|
 | 
						|
        private bool isShowOnlySelect = false; | 
						|
        #endregion | 
						|
        public ViewAttrTable(object m_hookHelper, List<AttributeViewParameter> pViewParam) | 
						|
        { | 
						|
            InitializeComponent(); | 
						|
            DockAreas = DockStyle.DockRight | DockStyle.DockBottom | DockStyle.DockLeft; | 
						|
            FloatSize = new Size(1030, 660); | 
						|
            DockWidth = 660; | 
						|
            DockHeight = 380; | 
						|
            DefaultArea = DockStyle.DockBottom; | 
						|
            ShowCloseButton = true; | 
						|
            ShowAutoHideButton = false; | 
						|
            IsShowInMap = true; | 
						|
            this.gridView1.PopupMenuShowing += GridView1_PopupMenuShowing; | 
						|
            Platform.Instance.NotifyMsgEven2 += Instance_NotifyMsgEven2; | 
						|
            _hookHelper = m_hookHelper as IHookHelper; | 
						|
            InitView(pViewParam); | 
						|
 | 
						|
            _Edit = new EngineEditorClass(); | 
						|
            _Edit.OnStartEditing += () => | 
						|
            { | 
						|
                // | 
						|
            }; | 
						|
            DeleteSelected.Enabled = false; | 
						|
            this.gridView1.CellValueChanging += gridView1_CellValueChangingEvent; | 
						|
 | 
						|
        } | 
						|
 | 
						|
        public GridView GetGridView() | 
						|
        { | 
						|
            return gridView1; | 
						|
        } | 
						|
 | 
						|
        //属性表图层处于编辑状态 可修改值 | 
						|
        private void gridView1_CellValueChangedEvent(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) | 
						|
        { | 
						|
            EditFeature(e.Column.FieldName, e.Value); | 
						|
        } | 
						|
 | 
						|
        //属性表图层处于编辑状态 可修改值 | 
						|
        private void gridView1_CellValueChangingEvent(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) | 
						|
        { | 
						|
            EditFeature(e.Column.FieldName, e.Value); | 
						|
        } | 
						|
 | 
						|
        public void EditFeature(string ColumnName, object value) | 
						|
        { | 
						|
            IFeature pFeature = null; | 
						|
            IFeatureCursor pFeatureCursor = null; | 
						|
            try | 
						|
            { | 
						|
                int ColumnIndex = _curFeatureLayer.FeatureClass.FindField(ColumnName); | 
						|
                if (gridView1.GetFocusedDataSourceRowIndex() < 0) return; | 
						|
                int OIDValue = (gridView1.DataSource as DataView)[gridView1.GetFocusedDataSourceRowIndex()][KeyIDName].ToInt(); | 
						|
                QueryFilter filter = new QueryFilterClass | 
						|
                { | 
						|
                    WhereClause = $"OBJECTID = {OIDValue}" | 
						|
                }; | 
						|
                pFeatureCursor = _curFeatureLayer.FeatureClass.Update(filter, true); | 
						|
                while ((pFeature = pFeatureCursor.NextFeature()) != null) | 
						|
                { | 
						|
                    if (pFeature.OID == OIDValue) | 
						|
                    { | 
						|
                        pFeature.set_Value(ColumnIndex, value); | 
						|
                        pFeatureCursor.UpdateFeature(pFeature); | 
						|
                        break; | 
						|
                    } | 
						|
                } | 
						|
 | 
						|
                #region 同步修改属性表 | 
						|
                if (!((gridView1.DataSource as DataView).Table is DataTable tempDT)) return; | 
						|
                DataRow dr = tempDT.Rows.Find(OIDValue); | 
						|
                if (dr != null) | 
						|
                { | 
						|
                    dr[ColumnName] = value; | 
						|
                    (gridView1.DataSource as DataView).Table.AcceptChanges(); | 
						|
                } | 
						|
                #endregion | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("属性表编辑更新失败,原因如下:" + ex.Message); | 
						|
                return; | 
						|
            } | 
						|
            finally | 
						|
            { | 
						|
                if (pFeatureCursor != null) | 
						|
                    Marshal.ReleaseComObject(pFeatureCursor); | 
						|
                if (pFeature != null) | 
						|
                    Marshal.ReleaseComObject(pFeature); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void gridView1_ColumnPositionChanged(object sender, EventArgs e) | 
						|
        { | 
						|
            Dictionary<int, string> dic_Name = new Dictionary<int, string>(); | 
						|
            Dictionary<int, string> dic_AliasName = new Dictionary<int, string>(); | 
						|
            try | 
						|
            { | 
						|
                foreach (DevExpress.XtraGrid.Columns.GridColumn g in this.gridView1.Columns) | 
						|
                { | 
						|
                    dic_Name[g.VisibleIndex] = g.FieldName; | 
						|
                    dic_AliasName[g.VisibleIndex] = g.ToString(); | 
						|
                } | 
						|
                dic_Name = dic_Name.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value.ToString()); | 
						|
                dic_AliasName = dic_AliasName.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value.ToString()); | 
						|
 | 
						|
                //xml文件 | 
						|
                string xmlPath = System.IO.Path.Combine((MapsManager.Instance.CurrProjectInfo as ProjectInfo).ProjDir, "RootLayerProperty.xml"); | 
						|
                //string xmlPath = @"D:\Kingo.BuildDB\Kingo.Plugins\Kingo.Plugin.MapView\Views\RootLayerProperty.xml"; | 
						|
                System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); | 
						|
                if (System.IO.File.Exists(xmlPath)) | 
						|
                { | 
						|
                    xmlDocument.Load(xmlPath); | 
						|
                    XmlNode rootNode = xmlDocument.SelectSingleNode("RootLayerProperty"); | 
						|
                    if (rootNode != null) | 
						|
                    { | 
						|
                        XmlNodeList xmlNodeList = xmlDocument.DocumentElement.SelectNodes("Layers"); | 
						|
                        foreach (object obj in xmlNodeList) | 
						|
                        { | 
						|
                            XmlNode xmlNode = (XmlNode)obj; | 
						|
                            XmlAttribute node = xmlNode.Attributes["Name"]; | 
						|
                            if (node.Value == _curFeatureLayer.FeatureClass.AliasName) | 
						|
                            { | 
						|
                                rootNode.RemoveChild(xmlNode); | 
						|
                                xmlDocument.Save(xmlPath); | 
						|
                                break; | 
						|
                            } | 
						|
                        } | 
						|
                    } | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    //创建xml | 
						|
                    CreateProjectXML(xmlPath); | 
						|
                    xmlDocument.Load(xmlPath); | 
						|
                } | 
						|
                //根节点 | 
						|
                XmlNode pXmlRootNode = xmlDocument.SelectSingleNode("RootLayerProperty"); | 
						|
                //创建node | 
						|
                XmlElement FieldElement = xmlDocument.CreateElement("Layers"); | 
						|
                FieldElement.SetAttribute("Name", _curFeatureLayer.FeatureClass.AliasName); | 
						|
                foreach (var item in dic_AliasName) | 
						|
                { | 
						|
                    XmlElement childFieldElement = xmlDocument.CreateElement("FieldCfg"); | 
						|
                    childFieldElement.SetAttribute("Index", item.Key.ToString()); | 
						|
                    childFieldElement.SetAttribute("AliasName", item.Value); | 
						|
                    childFieldElement.SetAttribute("Name", dic_Name[item.Key]); | 
						|
                    FieldElement.AppendChild(childFieldElement); | 
						|
                } | 
						|
                pXmlRootNode.AppendChild(FieldElement); | 
						|
                xmlDocument.Save(xmlPath); | 
						|
 | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("属性表列顺序更新失败,原因如下:" + ex); | 
						|
                return; | 
						|
            } | 
						|
        } | 
						|
        /// <summary> | 
						|
        /// 创建xml工程文件 | 
						|
        /// </summary> | 
						|
        /// <param name="xmlPath"></param> | 
						|
        /// <param name="projectStruct"></param> | 
						|
        public static void CreateProjectXML(string xmlPath) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                XmlDocument pXmlDocument = new XmlDocument(); | 
						|
                XmlDeclaration pXmlDeclaration = pXmlDocument.CreateXmlDeclaration("1.0", "utf-8", null); | 
						|
                pXmlDocument.AppendChild(pXmlDeclaration); | 
						|
                //加入一个根元素 | 
						|
                XmlElement pElement = pXmlDocument.CreateElement("", "RootLayerProperty", ""); | 
						|
                pXmlDocument.AppendChild(pElement); | 
						|
 | 
						|
                pXmlDocument.Save(xmlPath); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("创建配置文件失败!" + ex); | 
						|
                return; | 
						|
            } | 
						|
 | 
						|
        } | 
						|
 | 
						|
        #region 加载数据 | 
						|
        private string queryWhere = string.Empty; | 
						|
        /// <summary> | 
						|
        /// 查询条件 | 
						|
        /// </summary> | 
						|
        public string QueryWhere | 
						|
        { | 
						|
            get { return queryWhere; } | 
						|
            set { queryWhere = value; } | 
						|
        } | 
						|
        private void ConstructColumn(IFields fields) | 
						|
        { | 
						|
            if (fields != null) | 
						|
            { | 
						|
                Data.Clear(); | 
						|
                Data.PrimaryKey = null; | 
						|
                Data.Columns.Clear(); | 
						|
 | 
						|
                Dictionary<int, string> fieldIndex_NameDic = GetFieldIndex_NameDict(); | 
						|
                if (fieldIndex_NameDic == null || fieldIndex_NameDic.Count == 0) | 
						|
                { | 
						|
                    AddInitFieldData(fields); | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    AddInitDictionaryData(fieldIndex_NameDic, fields); | 
						|
                } | 
						|
                string oidField = "OBJECTID"; | 
						|
                if (!Data.Columns.Contains(oidField) && Data.Columns.Contains("FID")) | 
						|
                { | 
						|
                    oidField = "FID"; | 
						|
                } | 
						|
                Data.PrimaryKey = new DataColumn[] { Data.Columns[oidField] }; | 
						|
            } | 
						|
        } | 
						|
        private void AddInitFieldData(IFields fields) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                for (int i = 0; i < fields.FieldCount; i++) | 
						|
                { | 
						|
                    IField field = fields.get_Field(i); | 
						|
                    if (field.Name.ToUpper().EndsWith("SHAPE")) | 
						|
                        continue; | 
						|
                    DataColumn col = new DataColumn(); | 
						|
                    col.ExtendedProperties.Add("index", i); | 
						|
                    col.ColumnName = field.Name; | 
						|
                    col.Caption = field.AliasName; | 
						|
                    switch (field.Type) | 
						|
                    { | 
						|
                        case esriFieldType.esriFieldTypeSmallInteger: | 
						|
                            col.DataType = typeof(short); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeInteger: | 
						|
                            col.DataType = typeof(int); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeSingle: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeDouble: | 
						|
                            col.DataType = typeof(double); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeString: | 
						|
                            col.DataType = typeof(string); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeDate: | 
						|
                            col.DataType = typeof(DateTime); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeOID: | 
						|
                            col.DataType = typeof(Int32); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeGeometry: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeBlob: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeRaster: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeGUID: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeGlobalID: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeXML: | 
						|
                            break; | 
						|
                        default: | 
						|
                            break; | 
						|
                    } | 
						|
                    col.ReadOnly = !field.Editable;//编辑状态启用默认是否可以编辑 | 
						|
                    if (Data.Columns.Contains(col.ColumnName) == false)//不存在则添加 | 
						|
                    { | 
						|
                        Data.Columns.Add(col); | 
						|
                    } | 
						|
                    Marshal.ReleaseComObject(field); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("加载表格数据失败!" + ex); | 
						|
                return; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void AddInitDictionaryData(Dictionary<int, string> fieldIndex_NameDic, IFields fields) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (fields == null || fields.FieldCount == 0) return; | 
						|
                foreach (var item in fieldIndex_NameDic) | 
						|
                { | 
						|
                    int itemIndex = fields.FindField(item.Value); | 
						|
                    if (itemIndex == -1) continue; | 
						|
                    IField field = fields.get_Field(itemIndex); | 
						|
                    if (field.Name.ToUpper().EndsWith("SHAPE")) | 
						|
                        continue; | 
						|
                    DataColumn col = new DataColumn(); | 
						|
                    col.ExtendedProperties.Add("index", item.Key); | 
						|
                    col.ColumnName = field.Name; | 
						|
                    col.Caption = field.AliasName; | 
						|
                    switch (field.Type) | 
						|
                    { | 
						|
                        case esriFieldType.esriFieldTypeSmallInteger: | 
						|
                            col.DataType = typeof(short); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeInteger: | 
						|
                            col.DataType = typeof(int); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeSingle: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeDouble: | 
						|
                            col.DataType = typeof(double); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeString: | 
						|
                            col.DataType = typeof(string); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeDate: | 
						|
                            col.DataType = typeof(DateTime); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeOID: | 
						|
                            col.DataType = typeof(Int32); | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeGeometry: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeBlob: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeRaster: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeGUID: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeGlobalID: | 
						|
                            break; | 
						|
                        case esriFieldType.esriFieldTypeXML: | 
						|
                            break; | 
						|
                        default: | 
						|
                            break; | 
						|
                    } | 
						|
                    col.ReadOnly = !field.Editable;//编辑状态启用默认是否可以编辑 | 
						|
                    if (Data.Columns.Contains(col.ColumnName) == false)//不存在则添加 | 
						|
                    { | 
						|
                        Data.Columns.Add(col); | 
						|
                    } | 
						|
                    Marshal.ReleaseComObject(field); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("加载表格数据失败!" + ex); | 
						|
                return; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private Dictionary<int, string> GetFieldIndex_NameDict() | 
						|
        { | 
						|
            Dictionary<int, string> fieldIndex_NameDic = new Dictionary<int, string>(); | 
						|
            try | 
						|
            { | 
						|
                if (MapsManager.Instance.CurrProjectInfo == null) return null; | 
						|
                string xmlPath = System.IO.Path.Combine((MapsManager.Instance.CurrProjectInfo as ProjectInfo).ProjDir, "RootLayerProperty.xml"); | 
						|
                XmlDocument xmlDocument = new XmlDocument(); | 
						|
                if (System.IO.File.Exists(xmlPath)) | 
						|
                { | 
						|
                    xmlDocument.Load(xmlPath); | 
						|
                    XmlNode rootNode = xmlDocument.SelectSingleNode("RootLayerProperty"); | 
						|
                    if (rootNode != null) | 
						|
                    { | 
						|
                        XmlNodeList xmlNodeList = xmlDocument.DocumentElement.SelectNodes("Layers"); | 
						|
                        foreach (object obj in xmlNodeList) | 
						|
                        { | 
						|
                            XmlNode xmlNode = (XmlNode)obj; | 
						|
                            XmlAttribute node = xmlNode.Attributes["Name"]; | 
						|
                            if (node.Value == _curFeatureLayer.FeatureClass.AliasName) | 
						|
                            { | 
						|
                                foreach (XmlNode item in xmlNode.ChildNodes) | 
						|
                                { | 
						|
                                    fieldIndex_NameDic.Add(int.Parse(item.Attributes["Index"].Value), item.Attributes["Name"].Value); | 
						|
                                } | 
						|
                                break; | 
						|
                            } | 
						|
                        } | 
						|
                    } | 
						|
                } | 
						|
                return fieldIndex_NameDic; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("获取字段信息失败!" + ex); | 
						|
                return fieldIndex_NameDic; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 图层主键字段名称 | 
						|
        /// </summary> | 
						|
        private string KeyIDName = "OBJECTID"; | 
						|
        private bool IsLoadData = false; | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 数据加载 | 
						|
        /// </summary> | 
						|
        /// <param name="IsLaodDefintion">是否默认预查询加载</param> | 
						|
        private void LoadData(bool IsLaodDefintion = true) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (_curFeatureLayer == null || _curFeatureLayer.FeatureClass == null) return; | 
						|
 | 
						|
                KeyIDName = this._curFeatureLayer.FeatureClass.OIDFieldName; | 
						|
                gridView1.Columns.Clear(); | 
						|
                ConstructColumn(this._curFeatureLayer.FeatureClass.Fields); | 
						|
                gridControl1.DataSource = Data.Clone(); | 
						|
                gridControl1.Refresh(); | 
						|
                //清除所有选择 | 
						|
                _mapService.ClearFeatureSelection(_hookHelper.Hook as IMapControlDefault); | 
						|
                string strLayer = GeoDBAPI.SerialzedPersist(_curFeatureLayer); | 
						|
                ThreadManager.Instance.QueueUserWorkItem(new System.Threading.WaitCallback(ThreadLoadData), strLayer, new System.Threading.WaitCallback(LoadDataCompleteCallBack)); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("属性表数据加载失败,原因如下:" + ex.Message); | 
						|
                LogAPI.Debug("属性表数据加载失败,原因如下:" + ex.StackTrace); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void ThreadLoadData(object pParm) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                IsLoadData = true; | 
						|
                string strLayer = pParm.ToString(); | 
						|
                if (!(GeoDBAPI.DeSerialzedPersist(strLayer) is IFeatureLayer pLayer)) return; | 
						|
 | 
						|
                IQueryFilter queryfilter = new QueryFilterClass | 
						|
                { | 
						|
                    WhereClause = queryWhere | 
						|
                }; | 
						|
                IAttributeTable AttrTable = pLayer as IAttributeTable; | 
						|
                ICursor cursor = AttrTable.AttributeTable.Search(queryfilter, true); | 
						|
                int count = AttrTable.AttributeTable.RowCount(queryfilter); | 
						|
                this.BeginInvoke((Action)delegate () | 
						|
                { | 
						|
                    //barEditItem3.EditValue = "(" + gridView1.GetSelectedRows().Length + "/" + count + "已选择)"; | 
						|
                }); | 
						|
                IRow row = null; | 
						|
                DataTable tempDt = Data.Copy(); | 
						|
                tempDt.Rows.Clear(); | 
						|
                bool isExitFeatureXML = JudgeExistsCurrentFeatureXML(); | 
						|
                int columnCount = 0; | 
						|
                int fieldIndex = 0; | 
						|
                while ((row = cursor.NextRow()) != null) | 
						|
                { | 
						|
                    DataRow dr = tempDt.NewRow(); | 
						|
                    if (isExitFeatureXML) columnCount = tempDt.Columns.Count - 1; | 
						|
                    else columnCount = tempDt.Columns.Count; | 
						|
                    for (int i = 0; i < columnCount; i++) | 
						|
                    { | 
						|
                        int FeatureFieldIndex = row.Fields.FindField(tempDt.Columns[i].ColumnName); | 
						|
                        if (isExitFeatureXML && FeatureFieldIndex > columnCount)//末尾字段修改值报错 | 
						|
                            fieldIndex = (int)tempDt.Columns[FeatureFieldIndex - 1].ExtendedProperties["index"] + 1; | 
						|
                        else if (isExitFeatureXML) | 
						|
                            fieldIndex = (int)tempDt.Columns[FeatureFieldIndex].ExtendedProperties["index"]; | 
						|
                        else | 
						|
                            fieldIndex = (int)tempDt.Columns[i].ExtendedProperties["index"]; | 
						|
                        object obj = row.get_Value(fieldIndex); | 
						|
                        if (obj == null) | 
						|
                            continue; | 
						|
                        else | 
						|
                        { | 
						|
                            if (obj.ToString().Contains("1899/12/30 0:00:00")) | 
						|
                                obj = DBNull.Value; | 
						|
                        } | 
						|
                        dr[i] = obj; | 
						|
                    } | 
						|
                    tempDt.Rows.Add(dr); | 
						|
                    if (tempDt.Rows.Count == 10000) | 
						|
                    { | 
						|
                        this.Invoke((Action)delegate () | 
						|
                        { | 
						|
                            Data = tempDt.Copy(); | 
						|
                            gridControl1.DataSource = null; | 
						|
                            gridView1.Columns.Clear(); | 
						|
                            gridControl1.DataSource = Data; | 
						|
                            //OpaqueLayerHelper.HideOpaqueLayer(); | 
						|
                            UpdateViewState(); | 
						|
                            //OpaqueLayerHelper.ShowOpaqueLayer(this, 50, true); | 
						|
                        }); | 
						|
                    } | 
						|
                } | 
						|
                Data = tempDt.Copy(); | 
						|
                Marshal.ReleaseComObject(AttrTable); | 
						|
                Marshal.ReleaseComObject(pLayer); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("属性表数据加载失败,原因如下:" + ex.Message); | 
						|
            } | 
						|
        } | 
						|
        private bool JudgeExistsCurrentFeatureXML() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (MapsManager.Instance.CurrProjectInfo == null) return false; | 
						|
                string xmlPath = System.IO.Path.Combine((MapsManager.Instance.CurrProjectInfo as ProjectInfo).ProjDir, "RootLayerProperty.xml"); | 
						|
                XmlDocument xmlDocument = new XmlDocument(); | 
						|
                if (System.IO.File.Exists(xmlPath)) | 
						|
                { | 
						|
                    xmlDocument.Load(xmlPath); | 
						|
                    XmlNode rootNode = xmlDocument.SelectSingleNode("RootLayerProperty"); | 
						|
                    if (rootNode != null) | 
						|
                    { | 
						|
                        XmlNodeList xmlNodeList = xmlDocument.DocumentElement.SelectNodes("Layers"); | 
						|
                        foreach (object obj in xmlNodeList) | 
						|
                        { | 
						|
                            XmlNode xmlNode = (XmlNode)obj; | 
						|
                            XmlAttribute node = xmlNode.Attributes["Name"]; | 
						|
                            if (node.Value == _curFeatureLayer.FeatureClass.AliasName) | 
						|
                            { | 
						|
                                return true; | 
						|
                            } | 
						|
                        } | 
						|
                    } | 
						|
                } | 
						|
                return false; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("判断是否存在字段配置变失败!" + ex); | 
						|
                return false; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public void LoadDataCompleteCallBack(object obj) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                this.Invoke((Action)delegate () | 
						|
                { | 
						|
                    Platform.Instance.OutputMsg(string.Format("{0}属性表加载完成,共{1}条记录", Title, Data.Rows.Count)); | 
						|
                    //OpaqueLayerHelper.HideOpaqueLayer(); | 
						|
                    gridControl1.DataSource = null; | 
						|
                    gridView1.Columns.Clear(); | 
						|
                    gridControl1.DataSource = Data; | 
						|
                    UpdateViewState(); | 
						|
                    if (Data.Rows.Count == 0) | 
						|
                        barEditItem1.EditValue = 0; | 
						|
                    else | 
						|
                        barEditItem1.EditValue = 1; | 
						|
                    barEditItem3.EditValue = "(" + gridView1.GetSelectedRows().Length + "/" + Data.Rows.Count + "已选择)"; | 
						|
                    IsLoadData = false; | 
						|
                }); | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
                LogAPI.Debug("属性表数据加载this.Invoke执行失败!"); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void UpdateViewState() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                ISelectionSet pSelectionSetes = (_curFeatureLayer as IFeatureSelection).SelectionSet;//获取图层要素已被选择的 | 
						|
                if (pSelectionSetes == null) return;//监测是否有要素被选择 | 
						|
                IEnumIDs enumIDs = pSelectionSetes.IDs; | 
						|
                enumIDs.Reset(); | 
						|
                List<int> selectionOIDs = new List<int>(); | 
						|
                int oid = -1; | 
						|
                DataTable tempDT = (gridView1.DataSource as DataView).Table as DataTable; | 
						|
                if (tempDT == null) return; | 
						|
                gridView1.BeginSelection(); | 
						|
                if (IsLoadData) | 
						|
                    gridView1.ClearSelection(); | 
						|
                while ((oid = enumIDs.Next()) >= 0) | 
						|
                { | 
						|
                    DataRow dr = tempDT.Rows.Find(oid); | 
						|
                    int i = tempDT.Rows.IndexOf(dr); | 
						|
                    int rowHandle = gridView1.GetRowHandle(i); | 
						|
                    gridView1.SelectRow(rowHandle); | 
						|
                    if (selectionOIDs.Count == 0) | 
						|
                    { | 
						|
                        gridView1.FocusedRowHandle = rowHandle; | 
						|
                    } | 
						|
                    selectionOIDs.Add(oid); | 
						|
                } | 
						|
                gridView1.EndSelection(); | 
						|
                barEditItem1.EditValue = gridView1.FocusedRowHandle + 1; | 
						|
                barEditItem3.EditValue = "(" + selectionOIDs.Count + "/" + Data.Rows.Count + "已选择)"; | 
						|
                return; | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
                return; | 
						|
            } | 
						|
        } | 
						|
        #endregion | 
						|
 | 
						|
        private void Instance_NotifyMsgEven2(NotifyMsgPackage msg) | 
						|
        { | 
						|
            switch (msg.MsgType) | 
						|
            { | 
						|
                case "RefreshViewAttrTable": | 
						|
                    if (this.Data != null && this.Data.Rows.Count != 0) | 
						|
                    { | 
						|
                        if (msg.Content is IFeature) | 
						|
                        { | 
						|
                            IFeature feature = msg.Content as IFeature; | 
						|
                            int oidIndex = feature.Fields.FindField("OBJECTID"); | 
						|
                            int oid = Convert.ToInt32(feature.Value[oidIndex]); | 
						|
                            string where = string.Format("OBJECTID={0}", oid); | 
						|
                            IFeatureLayer player = MapsManager.Instance.MapService.GetFeatureLayerByName((feature.Class as FeatureClass).BrowseName); | 
						|
                            if (_curFeatureLayer.Name != player.Name) break; | 
						|
                            //IFeature ChangerF = _curFeatureLayer.FeatureClass.GetFeature(oid); | 
						|
                            IQueryFilter queryFilter = new QueryFilterClass(); | 
						|
                            queryFilter.WhereClause = where; | 
						|
                            IFeatureCursor featureCursor = player.Search(queryFilter, false); | 
						|
                            IFeature ChangerF = featureCursor.NextFeature(); | 
						|
                            DataRow[] newrow = Data.Select(where); | 
						|
                            DataRow row = newrow[0]; | 
						|
                            for (int i = 0; i < feature.Fields.FieldCount; i++) | 
						|
                            { | 
						|
                                string colName = feature.Fields.Field[i].Name; | 
						|
                                if (colName.ToUpper() == "OBJECTID" || colName.ToUpper().Contains("SHAPE")) | 
						|
                                    continue; | 
						|
                                row[colName] = feature.Value[i]; | 
						|
                                ChangerF.Value[i] = feature.Value[i]; | 
						|
                            } | 
						|
                            ChangerF.Store(); | 
						|
                            Marshal.ReleaseComObject(ChangerF); | 
						|
                        } | 
						|
                        else if (msg.Content is DataRow) | 
						|
                        { | 
						|
                            DataRow row = msg.Content as DataRow; | 
						|
                            int oid = Convert.ToInt32(row["OBJECTID"]); | 
						|
                            string where = string.Format("OBJECTID={0}", oid); | 
						|
                            DataRow[] newrow = Data.Select(where); | 
						|
                            for (int i = 0; i < row.Table.Columns.Count; i++) | 
						|
                            { | 
						|
                                string colName = row.Table.Columns[i].ColumnName; | 
						|
                                if (colName.ToUpper() == "OBJECTID" || colName.ToUpper().Contains("SHAPE")) | 
						|
                                    continue; | 
						|
                                if (newrow[0].Table.Columns.Contains(colName)) | 
						|
                                { | 
						|
                                    Type dataType = Data.Columns[colName].DataType; | 
						|
                                    if (dataType.Name == "String" && row[colName] != null && !string.IsNullOrWhiteSpace(row[colName].ToString())) | 
						|
                                    { | 
						|
                                        newrow[0][colName] = row[colName].ToString(); | 
						|
                                    } | 
						|
                                    else if (dataType.Name == "Int32" && row[colName] != null && !string.IsNullOrWhiteSpace(row[colName].ToString())) | 
						|
                                    { | 
						|
                                        newrow[0][colName] = Convert.ToInt32(row[colName]); | 
						|
                                    } | 
						|
                                    else if (dataType.Name == "Int16" && row[colName] != null && !string.IsNullOrWhiteSpace(row[colName].ToString())) | 
						|
                                    { | 
						|
                                        newrow[0][colName] = Convert.ToInt16(row[colName]); | 
						|
                                    } | 
						|
                                    else if (dataType.Name == "Double" && row[colName] != null && !string.IsNullOrWhiteSpace(row[colName].ToString())) | 
						|
                                    { | 
						|
                                        newrow[0][colName] = Convert.ToDouble(row[colName]); | 
						|
                                    } | 
						|
                                    else | 
						|
                                    { | 
						|
                                        if (dataType.Name != "Int32" && dataType.Name != "Int16" && dataType.Name != "Double" && dataType.Name != "Decimal") | 
						|
                                            newrow[0][colName] = row[colName]; | 
						|
                                    } | 
						|
 | 
						|
                                } | 
						|
                            } | 
						|
                        } | 
						|
                        else if (msg.Extend.ToString() == "DelDataByOID")//当前仅仅考虑删除对应OID下的更新数据 | 
						|
                        { | 
						|
                            string where = string.Format("OBJECTID={0}", msg.Content); | 
						|
                            DataRow[] newrow = Data.Select(where); | 
						|
                            if (newrow.Count() == 1) | 
						|
                            { | 
						|
                                DataRow row = newrow[0]; | 
						|
                                Data.Rows.Remove(row); | 
						|
                            } | 
						|
                            else | 
						|
                            { | 
						|
                                break; | 
						|
                            } | 
						|
                        } | 
						|
                        gridControl1.DataSource = Data; | 
						|
                        gridControl1.Refresh(); | 
						|
                    } | 
						|
                    break; | 
						|
                case "ShowDetailView": | 
						|
                    if (msg.Content is IDockPanel2) | 
						|
                    { | 
						|
                        (msg.Content as IDockPanel2).ShowPanel(); | 
						|
                    } | 
						|
                    break; | 
						|
                default: | 
						|
                    break; | 
						|
            } | 
						|
            //检测图斑详情页-上下键 | 
						|
            if (msg.MsgType == "NextDataDetailView") | 
						|
            { | 
						|
                NextItemClick(null, null); | 
						|
            } | 
						|
            else if (msg.MsgType == "PrevDataDetailView") | 
						|
            { | 
						|
                PreItemClick(null, null); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void GridView1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) | 
						|
        { | 
						|
            clickedColumn = e.HitInfo.Column; | 
						|
            if (e.MenuType == GridMenuType.Column) | 
						|
            { | 
						|
                IEnumerable<DevExpress.Utils.Menu.DXMenuItem> cols = e.Menu.Items.Where(f => f.Caption.Contains("分组")); | 
						|
                List<DevExpress.Utils.Menu.DXMenuItem> remoList = new List<DevExpress.Utils.Menu.DXMenuItem>(); | 
						|
                foreach (DevExpress.Utils.Menu.DXMenuItem item in cols) | 
						|
                { | 
						|
                    remoList.Add(item); | 
						|
                } | 
						|
                foreach (var item in remoList) | 
						|
                { | 
						|
                    e.Menu.Items.Remove(item); | 
						|
                } | 
						|
 | 
						|
                //任务31196   添加人员:娄梦洁   需求添加字段计算器 | 
						|
                //需求添加字段计算器,但仅是属性的赋值   故目前暂时使用属性赋值功能,暂时注释,后面可扩展 | 
						|
                //if (clickedColumn.ToString().ToUpper() == "OBJECTID" || clickedColumn.FieldName.ToUpper() == "OBJECTID" | 
						|
                //    || clickedColumn.ToString().ToUpper() == "SHAPE" || clickedColumn.FieldName.ToUpper() == "SHAPE" | 
						|
                //    ) | 
						|
                //{ | 
						|
                //    return; | 
						|
                //} | 
						|
                //if (e.Menu.Items.Where(f => f.Caption == "字段计算器") == null || e.Menu.Items.Where(f => f.Caption == "字段计算器").Count<DevExpress.Utils.Menu.DXMenuItem>() == 0) | 
						|
                //{ | 
						|
                //    DevExpress.Utils.Menu.DXMenuItem customMenuItem = new DevExpress.Utils.Menu.DXMenuItem("字段计算器", OnFieldCalculatorMenuItemClick); | 
						|
                //    e.Menu.Items.Add(customMenuItem); | 
						|
                //} | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        #region 字段计算器 | 
						|
        private GridColumn clickedColumn = null; | 
						|
        private void OnFieldCalculatorMenuItemClick(object sender, EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (clickedColumn == null) | 
						|
                { | 
						|
                    LogAPI.Debug("字段计算器执行异常,未获取到列表名"); | 
						|
                    MessageHelper.ShowTips("未获取到列表名!"); | 
						|
                    return; | 
						|
                } | 
						|
                if (clickedColumn.ToString().ToUpper() == "OBJECTID" || clickedColumn.FieldName.ToUpper() == "OBJECTID" | 
						|
                    || clickedColumn.ToString().ToUpper() == "SHAPE" || clickedColumn.FieldName.ToUpper() == "SHAPE" | 
						|
                    ) | 
						|
                { | 
						|
                    MessageHelper.ShowTips("此字段不可使用字段计算器功能!"); | 
						|
                    return; | 
						|
                } | 
						|
                if (_curFeatureLayer == null || _curFeatureLayer.FeatureClass == null) | 
						|
                { | 
						|
                    MessageHelper.ShowTips("要查询的属性图层为空!"); | 
						|
                    return; | 
						|
                } | 
						|
 | 
						|
                UCFieldCalculator frmFieldCalculator = new UCFieldCalculator(_curFeatureLayer); | 
						|
                frmFieldCalculator.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; | 
						|
                frmFieldCalculator.ShowInMainWindow(true); | 
						|
                if (frmFieldCalculator.DialogResult == true) | 
						|
                { | 
						|
                    if (frmFieldCalculator.expressionFieldCalculator == null || string.IsNullOrEmpty(frmFieldCalculator.expressionFieldCalculator.Field) || string.IsNullOrEmpty(frmFieldCalculator.expressionFieldCalculator.ExpressionText)) | 
						|
                    { | 
						|
                        return; | 
						|
                    } | 
						|
 | 
						|
                    #region 字段计算器 | 
						|
                    //this.ShowLoading($"正在进行字段计算器计算操作...", 0, 0); | 
						|
                    //Geoprocessor gp = new Geoprocessor(); | 
						|
                    //gp.OverwriteOutput = true; | 
						|
                    //CalculateField calc = new CalculateField(); | 
						|
                    //calc.in_table = _curFeatureLayer.FeatureClass; | 
						|
                    //calc.field = frmFieldCalculator.expressionFieldCalculator.Field; | 
						|
                    ////calc.expression = "!shape.geodesicarea!"; | 
						|
                    ////calc.expression_type = "PYTHON"; | 
						|
                    //string expressionText = frmFieldCalculator.expressionFieldCalculator.ExpressionText; | 
						|
                    //if (frmFieldCalculator.expressionFieldCalculator.DataType == DataType.FigureType) | 
						|
                    //{ | 
						|
                    //    if (string.IsNullOrEmpty(expressionText)) | 
						|
                    //    { | 
						|
                    //        MessageHelper.ShowTips("数字类型,字段赋值不允许为空!"); | 
						|
                    //        return; | 
						|
                    //    } | 
						|
                    //    if (expressionText.Contains(".")) | 
						|
                    //        calc.expression = frmFieldCalculator.expressionFieldCalculator.ExpressionText.ToDouble(); | 
						|
                    //    else | 
						|
                    //        calc.expression = frmFieldCalculator.expressionFieldCalculator.ExpressionText.ToInt(); | 
						|
                    //} | 
						|
                    //else if (frmFieldCalculator.expressionFieldCalculator.DataType == DataType.StringType) | 
						|
                    //{ | 
						|
                    //    calc.expression = frmFieldCalculator.expressionFieldCalculator.ExpressionText; | 
						|
                    //} | 
						|
                    //else if (frmFieldCalculator.expressionFieldCalculator.DataType == DataType.DateType) | 
						|
                    //{ | 
						|
                    //    if (string.IsNullOrEmpty(expressionText)) | 
						|
                    //    { | 
						|
                    //        MessageHelper.ShowTips("日期类型,字段赋值不允许为空!"); | 
						|
                    //        return; | 
						|
                    //    } | 
						|
                    //    calc.expression = frmFieldCalculator.expressionFieldCalculator.ExpressionText.ToDateTime(); | 
						|
                    //} | 
						|
                    //calc.expression_type = frmFieldCalculator.expressionFieldCalculator.Type.ToString().ToUpper(); | 
						|
                    //gp.Execute(calc, null); | 
						|
 | 
						|
                    //this.CloseLoading(); | 
						|
                    //MessageHelper.ShowTips("字段计算器计算完成!"); | 
						|
                    #endregion | 
						|
 | 
						|
                    #region 需求目前是直接赋值  字段赋值操作 | 
						|
                    List<int> objectidList = GetSelectRowsOIDS(); | 
						|
                    if (objectidList.Count == 0) | 
						|
                    { | 
						|
                        MessageHelper.ShowTips("当前选择行数为0,请勾选所需赋值的数据!"); | 
						|
                        return; | 
						|
                    } | 
						|
                    if (MessageHelper.ShowYesNoAndTips($"当前选择行数为{objectidList.Count},将会操作赋值此数据,是否继续?") == DialogResult.No) | 
						|
                    { | 
						|
                        return; | 
						|
                    } | 
						|
                    int fieldIndex = _curFeatureLayer.FeatureClass.Fields.FindField(frmFieldCalculator.expressionFieldCalculator.Field); | 
						|
                    if (fieldIndex == -1) | 
						|
                    { | 
						|
                        MessageHelper.ShowTips($"图层中未找到{frmFieldCalculator.expressionFieldCalculator.Field}字段!"); | 
						|
                        return; | 
						|
                    } | 
						|
                    this.ShowLoading($"正在进行字段赋值操作...", 0, 0); | 
						|
                    IField field = _curFeatureLayer.FeatureClass.Fields.get_Field(fieldIndex); | 
						|
                    ITable table = _curFeatureLayer.FeatureClass as ITable; | 
						|
                    IQueryFilter Tempfilter = new QueryFilterClass() { WhereClause = $"OBJECTID in ({string.Join(",", objectidList)}) " }; | 
						|
                    ICursor cursor = table.Update(Tempfilter, true); | 
						|
                    IRow row = cursor.NextRow(); | 
						|
                    string expressionText = frmFieldCalculator.expressionFieldCalculator.ExpressionText; | 
						|
                    //object expression = default; | 
						|
                    object expression = null; | 
						|
                    if (frmFieldCalculator.expressionFieldCalculator.DataType == DataType.FigureType) | 
						|
                    { | 
						|
                        if (string.IsNullOrEmpty(expressionText)) | 
						|
                        { | 
						|
                            MessageHelper.ShowTips("数字类型,字段赋值不允许为空!"); | 
						|
                            return; | 
						|
                        } | 
						|
                        if (expressionText.Contains(".")) | 
						|
                            expression = frmFieldCalculator.expressionFieldCalculator.ExpressionText.ToDouble(); | 
						|
                        else | 
						|
                            expression = frmFieldCalculator.expressionFieldCalculator.ExpressionText.ToInt(); | 
						|
                    } | 
						|
                    else if (frmFieldCalculator.expressionFieldCalculator.DataType == DataType.StringType) | 
						|
                    { | 
						|
                        expression = frmFieldCalculator.expressionFieldCalculator.ExpressionText; | 
						|
                    } | 
						|
                    else if (frmFieldCalculator.expressionFieldCalculator.DataType == DataType.DateType) | 
						|
                    { | 
						|
                        if (string.IsNullOrEmpty(expressionText)) | 
						|
                        { | 
						|
                            MessageHelper.ShowTips("日期类型,字段赋值不允许为空!"); | 
						|
                            return; | 
						|
                        } | 
						|
                        expression = frmFieldCalculator.expressionFieldCalculator.ExpressionText.ToDateTime(); | 
						|
                    } | 
						|
                    while (row != null) | 
						|
                    { | 
						|
                        row.set_Value(fieldIndex, expression); | 
						|
                        cursor.UpdateRow(row); | 
						|
                        row = cursor.NextRow(); | 
						|
                    } | 
						|
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); | 
						|
 | 
						|
                    this.CloseLoading(); | 
						|
                    MessageHelper.ShowTips("字段赋值操作完成!"); | 
						|
                    #endregion | 
						|
 | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                this.CloseLoading(); | 
						|
                MessageHelper.ShowTips("字段计算器异常!" + ex.Message); | 
						|
                LogAPI.Debug("字段计算器异常!" + ex.Message); | 
						|
                LogAPI.Debug("字段计算器异常!" + ex.StackTrace); | 
						|
            } | 
						|
            finally | 
						|
            { | 
						|
                this.CloseLoading(); | 
						|
            } | 
						|
        } | 
						|
        #endregion | 
						|
 | 
						|
        #region 视图与属性表数据同步事件 | 
						|
        private void AxMapControl_OnSelectionChanged(object sender, EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (_curFeatureLayer == null) return; | 
						|
                if (IsRowClick) return; | 
						|
                ISelectionSet pSelectionSetes = (_curFeatureLayer as IFeatureSelection).SelectionSet;//获取图层要素已被选择的 | 
						|
                if (pSelectionSetes == null) return;//监测是否有要素被选择 | 
						|
                IEnumIDs enumIDs = pSelectionSetes.IDs; | 
						|
                enumIDs.Reset(); | 
						|
                List<int> selectionOIDs = new List<int>(); | 
						|
                int oid = -1; | 
						|
                if (gridView1.DataSource == null) return; | 
						|
                DataTable tempDT = (gridView1.DataSource as DataView).Table as DataTable; | 
						|
                gridView1.BeginSelection(); | 
						|
                gridView1.ClearSelection(); | 
						|
                while ((oid = enumIDs.Next()) >= 0) | 
						|
                { | 
						|
                    DataRow dr = tempDT.Rows.Find(oid); | 
						|
                    if (dr == null) | 
						|
                    { | 
						|
                        dr = tempDT.NewRow(); | 
						|
                        dr[tempDT.PrimaryKey[0]] = oid; | 
						|
                        IFeature feature = _curFeatureLayer.FeatureClass.GetFeature(oid); | 
						|
                        for (int i = 1; i < Data.Columns.Count; i++) | 
						|
                        { | 
						|
                            object obj = feature.get_Value((int)Data.Columns[i].ExtendedProperties["index"]); | 
						|
                            if (obj == null) | 
						|
                            { | 
						|
                                continue; | 
						|
                            } | 
						|
                            else | 
						|
                            { | 
						|
                                if (obj.ToString().Contains("1899/12/30 0:00:00")) | 
						|
                                { | 
						|
                                    obj = DBNull.Value; | 
						|
                                } | 
						|
                            } | 
						|
                            dr[i] = obj; | 
						|
                        } | 
						|
                        tempDT.Rows.Add(dr); | 
						|
                        Marshal.ReleaseComObject(feature); | 
						|
                    } | 
						|
                    int j = tempDT.Rows.IndexOf(dr); | 
						|
                    int rowHandle = gridView1.GetRowHandle(j); | 
						|
                    if (!isShowOnlySelect) | 
						|
                    { | 
						|
                        gridView1.SelectRow(rowHandle); | 
						|
                        if (selectionOIDs.Count == 0) | 
						|
                        { | 
						|
                            gridView1.FocusedRowHandle = rowHandle; | 
						|
                        } | 
						|
                        selectionOIDs.Add(oid); | 
						|
                    } | 
						|
                } | 
						|
                gridView1.EndSelection(); | 
						|
                oid = -1; | 
						|
                if (!isShowOnlySelect) | 
						|
                { | 
						|
                    barEditItem1.EditValue = Data.Rows.Count == 0 ? 0 : gridView1.FocusedRowHandle + 1; | 
						|
                    barEditItem3.EditValue = "(" + gridView1.GetSelectedRows().Length + "/" + Data.Rows.Count + "已选择)"; | 
						|
                } | 
						|
 | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
                return; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 获取过滤后数据的全部OID | 
						|
        /// </summary> | 
						|
        private void GetAllFilteredOid() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                string oidFiled = "OBJECTID"; | 
						|
                if (!Data.Columns.Contains("OBJECTID") && Data.Columns.Contains("FID")) | 
						|
                { | 
						|
                    oidFiled = "OBJECTID"; | 
						|
                } | 
						|
                Filteredids.Clear(); | 
						|
                //获取过滤后的所有行数据 | 
						|
                IList filtertests = gridView1.DataController.GetAllFilteredAndSortedRows(); | 
						|
                if (filtertests.Count == 0) return; | 
						|
                foreach (DataRowView item in filtertests) | 
						|
                { | 
						|
                    Filteredids.Add(Convert.ToInt32(item.Row[oidFiled].ToString())); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug(ex.Message); | 
						|
            } | 
						|
        } | 
						|
        #endregion | 
						|
 | 
						|
        #region 窗体事件 | 
						|
        private bool IsRowClick = false; | 
						|
        private void gridView1_RowClick(object sender, RowClickEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (e.Clicks == 2 || _mapService == null) { return; } | 
						|
                int oid = -1; | 
						|
                IsRowClick = true; | 
						|
                //int[] rows = gridView1.GetSelectedRows(); | 
						|
                if (gridView1.DataSource is DataView) | 
						|
                { | 
						|
                    oid = (int)(gridView1.DataSource as DataView)[gridView1.GetFocusedDataSourceRowIndex()][KeyIDName]; | 
						|
                } | 
						|
                if (oid == -1) return; | 
						|
                if (_curFeatureLayer == null) return; | 
						|
                ISelectionSet pSelectionSetes = (_curFeatureLayer as IFeatureSelection).SelectionSet; | 
						|
                if (pSelectionSetes.Count > 0) | 
						|
                { | 
						|
                    if (isShowOnlySelect) | 
						|
                    { | 
						|
                        _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
                        gridView1.SelectAll(); | 
						|
                        if (_curFeatureLayer != null) | 
						|
                            _curFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName); | 
						|
                        if (_curFeatureLayer != null) | 
						|
                        { | 
						|
                            var f = _curFeatureLayer.FeatureClass.GetFeature(oid); | 
						|
                            if(f != null) | 
						|
                            { | 
						|
                                MapsManager.Instance.MapService.DrawGraph(f.ShapeCopy, true, 255, 255, 0); | 
						|
                                MapsManager.Instance.MapService.Zoom(f.ShapeCopy); | 
						|
                                _hookHelper.ActiveView.Refresh(); | 
						|
                                Marshal.ReleaseComObject(pSelectionSetes); | 
						|
                            } | 
						|
                        } | 
						|
                        return; | 
						|
                    } | 
						|
                    else | 
						|
                    { | 
						|
                        pSelectionSetes.RemoveList(GetFeatureSelection(pSelectionSetes).Count, ref GetFeatureSelection(pSelectionSetes).ToArray()[0]); | 
						|
                        M_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, M_hookHelper.ActiveView.Extent); | 
						|
                    } | 
						|
                } | 
						|
                if (IsExistFature(oid)) | 
						|
                { | 
						|
                    if (_curFeatureLayer == null) return; | 
						|
                    _mapService.SelectFeature((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName, oid.ToString()); | 
						|
                } | 
						|
                barEditItem1.EditValue = gridView1.FocusedRowHandle + 1; | 
						|
                barEditItem3.EditValue = "(" + gridView1.GetSelectedRows().Length + "/" + Data.Rows.Count + "已选择)"; | 
						|
                Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "Positioning", Content = _curFeatureLayer.FeatureClass.GetFeature(oid) }); | 
						|
                Marshal.ReleaseComObject(pSelectionSetes); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("行点击改变绑定值:" + ex.Message); | 
						|
            } | 
						|
            finally | 
						|
            { | 
						|
                IsRowClick = false; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void gridView1_RowCellClick(object sender, RowCellClickEventArgs e) | 
						|
        { | 
						|
            if (_Edit == null) return; | 
						|
            //当前属性表处于编辑  可修改 | 
						|
            if (_Edit.EditState != esriEngineEditState.esriEngineStateNotEditing) | 
						|
            { | 
						|
                if ((_Edit as EngineEditorClass).IEngineEditLayers_TargetLayer == _curFeatureLayer) | 
						|
                    this.gridView1.OptionsBehavior.Editable = true; | 
						|
                else | 
						|
                    this.gridView1.OptionsBehavior.Editable = false; | 
						|
            } | 
						|
            else | 
						|
                this.gridView1.OptionsBehavior.Editable = false; | 
						|
        } | 
						|
 | 
						|
 | 
						|
        private void gridView1_SelectionChanged(object sender, SelectionChangedEventArgs e) | 
						|
        { | 
						|
            if (_Edit == null) return;  | 
						|
            if (isShowOnlySelect) | 
						|
                _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
            //当前属性表处于编辑  可修改 | 
						|
            if (_Edit.EditState != esriEngineEditState.esriEngineStateNotEditing) | 
						|
            { | 
						|
                if ((_Edit as EngineEditorClass).IEngineEditLayers_TargetLayer == _curFeatureLayer) | 
						|
                    this.gridView1.OptionsBehavior.Editable = true; | 
						|
                else | 
						|
                    this.gridView1.OptionsBehavior.Editable = false; | 
						|
            } | 
						|
            else | 
						|
                this.gridView1.OptionsBehavior.Editable = false; | 
						|
            if (!isShowOnlySelect) | 
						|
                barEditItem3.EditValue = "(" + gridView1.GetSelectedRows().Length + "/" + Data.Rows.Count + "已选择)"; | 
						|
        } | 
						|
 | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 判断指定OID在要素类中是否存在 | 
						|
        /// </summary> | 
						|
        /// <param name="pOID">指定的OID</param> | 
						|
        /// <param name="IsAllowDelRow">是否允许删除行数据</param> | 
						|
        /// <returns></returns> | 
						|
        private bool IsExistFature(int pOID, bool IsAllowDelRow = true) | 
						|
        { | 
						|
            bool result = true; | 
						|
            try | 
						|
            { | 
						|
                if (_curFeatureLayer == null) return result; | 
						|
                //刷新下当前状态 | 
						|
                _curFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName); | 
						|
                if (_curFeatureLayer == null) return result; | 
						|
                var f = _curFeatureLayer.FeatureClass.GetFeature(pOID); | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
                result = false; | 
						|
                if (!IsAllowDelRow) return result; | 
						|
                if (MessageHelper.ShowYesNoAndTips(string.Format("OID = {0} 的要素不存在,是否从当前列表中移除该记录?", pOID)) == DialogResult.Yes) | 
						|
                { | 
						|
                    int[] rows = gridView1.GetSelectedRows(); | 
						|
                    for (int i = 0; i < rows.Length; i++) | 
						|
                    { | 
						|
                        if (gridView1.DataSource is DataView) | 
						|
                        { | 
						|
                            (gridView1.DataSource as DataView)[rows[i]].Delete(); | 
						|
                            break; | 
						|
                        } | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            return result; | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 行双击事件 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void gridView1_DoubleClick(object sender, EventArgs e) | 
						|
        { | 
						|
 | 
						|
        } | 
						|
 | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 关闭GridControl窗体 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void gridControl1_ControlRemoved(object sender, ControlEventArgs e) | 
						|
        { | 
						|
            //注销选择图层要素时触发的选择改变事件 | 
						|
            MapsManager.Instance.MapService.OnSelectionChanged -= AxMapControl_OnSelectionChanged; | 
						|
        } | 
						|
        /// <summary> | 
						|
        /// 已选择要素同步到视图数据(独立的) | 
						|
        /// </summary> | 
						|
        private void PSelectedSynchronizeGridView() | 
						|
        { | 
						|
            ISelectionSet pSelectionSetes = (_curFeatureLayer as IFeatureSelection).SelectionSet;//获取图层要素已被选择的 | 
						|
            if (pSelectionSetes == null) return;//监测是否有要素被选择 | 
						|
            try | 
						|
            { | 
						|
                if (pSelectionSetes.Count <= 0) | 
						|
                { | 
						|
                    gridView1.ClearSelection(); | 
						|
                    return; | 
						|
                } | 
						|
                IEnumIDs enumIDs = pSelectionSetes.IDs; | 
						|
                enumIDs.Reset(); | 
						|
                int objectid = 0;//与第一行 | 
						|
                while ((objectid = enumIDs.Next()) >= 0) | 
						|
                { | 
						|
                    gridView1.SelectRow(objectids.IndexOf(objectid));//objectid与选择行并不是一一对应的 | 
						|
                    SelectCount++; | 
						|
                } | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
                return; | 
						|
            } | 
						|
            finally | 
						|
            { | 
						|
                barEditItem3.EditValue = "(" + pSelectionSetes.Count + "/" + Data.Rows.Count + "已选择)"; | 
						|
            } | 
						|
        } | 
						|
        #endregion | 
						|
 | 
						|
        #region BarManger顶部事件 | 
						|
        /// <summary> | 
						|
        /// 全选(视图上所有数据) | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void AllSelectClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (isShowOnlySelect) | 
						|
                    _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
                isShowOnlySelect = false; | 
						|
                if (_curFeatureLayer == null) return; | 
						|
                gridControl1.DataSource = Data; | 
						|
                gridControl1.RefreshDataSource(); | 
						|
                //获取高亮对象 | 
						|
                ISelectionSet pSelectionSet = (_curFeatureLayer as IFeatureSelection).SelectionSet; | 
						|
                //是否存在过滤条件 | 
						|
                if (string.IsNullOrEmpty(gridView1.FilterPanelText)) | 
						|
                { | 
						|
                    GetAllObjectid(); | 
						|
                    gridView1.SelectAll(); | 
						|
                    barEditItem3.EditValue = "(" + Data.Rows.Count + "/" + Data.Rows.Count + "已选择)"; | 
						|
                    pSelectionSet.AddList(objectids.Count, ref objectids.ToArray()[0]); | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    GetAllFilteredOid(); | 
						|
                    gridView1.SelectRows(0, Filteredids.Count - 1); | 
						|
                    barEditItem3.EditValue = "(" + Filteredids.Count + "/" + Data.Rows.Count + "已选择)"; | 
						|
                    //获取高亮对象 | 
						|
                    pSelectionSet.AddList(Filteredids.Count, ref Filteredids.ToArray()[0]); | 
						|
                } | 
						|
                //视图部分刷新 | 
						|
                M_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, M_hookHelper.ActiveView.Extent); | 
						|
                Marshal.ReleaseComObject(pSelectionSet); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("全选操作失败:" + ex.Message); | 
						|
                return;//鼠标不在视图数据区点击 | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 切换选择(反选) | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void SwitchSelectClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            //切换选择数据,图层要素选择同步切换             | 
						|
            List<int> SelectedRowsList = new List<int>();//切换之前已选择的数据 | 
						|
            List<int> unSelectedRowsList = new List<int>();//切换之后选择的数据 | 
						|
            ISelectionSet pSelectionSet = (_curFeatureLayer as IFeatureSelection).SelectionSet;//获取图层要素已被选择的 | 
						|
            if (pSelectionSet == null) return;//监测是否有要素被选择 | 
						|
            IEnumIDs enumIDs = pSelectionSet.IDs; | 
						|
            enumIDs.Reset(); | 
						|
            int objectid = 0; | 
						|
            while ((objectid = enumIDs.Next()) >= 0) | 
						|
            { | 
						|
                SelectedRowsList.Add(objectid); | 
						|
            } | 
						|
 | 
						|
            if (SelectedRowsList == null || SelectedRowsList.Count == 0) | 
						|
            { | 
						|
                AllSelectClick(sender, e); | 
						|
                return; | 
						|
            } | 
						|
            else if (SelectedRowsList.Count == Data.Rows.Count) | 
						|
            { | 
						|
                CancelSelectClick(sender, e); | 
						|
                return; | 
						|
            } | 
						|
            if (queryWhere != "1=1") | 
						|
            { | 
						|
                IQueryFilter queryFilter = new QueryFilterClass(); | 
						|
                queryFilter.WhereClause = queryWhere; | 
						|
                IFeatureCursor pFeatureCursor = _curFeatureLayer.Search(queryFilter, true); | 
						|
                while ((pFeature = pFeatureCursor.NextFeature()) != null) | 
						|
                { | 
						|
                    unSelectedRowsList.Add(Convert.ToInt32(pFeature.get_Value(0))); | 
						|
                } | 
						|
                Marshal.ReleaseComObject(pFeatureCursor); | 
						|
            } | 
						|
            else | 
						|
            { | 
						|
                unSelectedRowsList = objectids.Copy(); | 
						|
            } | 
						|
 | 
						|
            for (int i = 0; i < SelectedRowsList.Count; i++) | 
						|
            { | 
						|
                unSelectedRowsList.Remove(SelectedRowsList[i]); | 
						|
            } | 
						|
            M_hookHelper.FocusMap.ClearSelection();//清除图层上要素选择 | 
						|
            //视图部分刷新 | 
						|
            M_hookHelper.ActiveView.Refresh();//刷新当前视图 | 
						|
            try | 
						|
            { | 
						|
                pSelectionSet.AddList(unSelectedRowsList.Count, ref unSelectedRowsList.ToArray()[0]);//要素选择高亮  | 
						|
                for (int i = 0; i < unSelectedRowsList.Count; i++) | 
						|
                { | 
						|
                    gridView1.SelectRow(objectids.IndexOf(unSelectedRowsList[i])); | 
						|
                } | 
						|
                //视图部分刷新 | 
						|
                M_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, M_hookHelper.ActiveView.Extent); | 
						|
                //刷新视图数据源 | 
						|
                //gridControl1.RefreshDataSource(); | 
						|
                //PSelectedSynchronizeGridView(); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("反选操作失败:" + ex.Message); | 
						|
                return;//鼠标不在视图数据区点击 | 
						|
            } | 
						|
        } | 
						|
        /// <summary> | 
						|
        /// 取消选择 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void CancelSelectClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (isShowOnlySelect) | 
						|
                    _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
                isShowOnlySelect = false; | 
						|
                gridControl1.DataSource = Data; | 
						|
                gridControl1.RefreshDataSource(); | 
						|
                gridView1.ClearSelection(); | 
						|
                barEditItem3.EditValue = "(0/" + Data.Rows.Count + "已选择)"; | 
						|
                M_hookHelper.FocusMap.ClearSelection();//清除图层上要素选择 | 
						|
                M_hookHelper.ActiveView.Refresh();//视图部分刷新 | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("取消选择操作失败:" + ex.Message); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 缩放至选中项 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void ZoomSelectedClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (_curFeatureLayer == null) return; | 
						|
                IsRowClick = true; | 
						|
                M_hookHelper.FocusMap.ClearSelection();//清除图层上要素选择 | 
						|
                ISelectionSet pSelectionSet = (_curFeatureLayer as IFeatureSelection).SelectionSet; | 
						|
                List<int> vsTemp = new List<int>(); | 
						|
                int[] SelectR = gridView1.GetSelectedRows(); | 
						|
                int objectid = -1; | 
						|
                foreach (var item in SelectR) | 
						|
                { | 
						|
                    int idx = gridView1.ViewRowHandleToDataSourceIndex(item); | 
						|
                    objectid = Convert.ToInt32(Data.Rows[idx][Data.Columns[0]].ToString()); | 
						|
                    vsTemp.Add(objectid); | 
						|
                } | 
						|
 | 
						|
                pSelectionSet.AddList(vsTemp.Count, ref vsTemp.ToArray()[0]);//要素选择高亮  | 
						|
                if (pSelectionSet.Count == 0) return;//不能为空 | 
						|
                IEnumGeometryBind tEnumGeometryBind = new EnumFeatureGeometryClass();//实例化一个要素边界线绑定框 | 
						|
                tEnumGeometryBind.BindGeometrySource(null, pSelectionSet);//绑定选中数据源 | 
						|
                IEnumGeometry tEnumGeometry = (IEnumGeometry)tEnumGeometryBind;//数据填充过的绑定框 | 
						|
                IGeometryFactory tGeometryFactory = new GeometryEnvironmentClass();//几何工厂指向实例化几何要素类 | 
						|
                IGeometry tGeometry = tGeometryFactory.CreateGeometryFromEnumerator(tEnumGeometry); | 
						|
                //缓冲处理,使处于边界的元素在视图中能够完全显示 | 
						|
                ITopologicalOperator mTopologicalOperator = (ITopologicalOperator)tGeometry;//ITopologicaOperator括扑操作员 | 
						|
                IGeometry mPolygonBuffer = mTopologicalOperator.Buffer(0.1) as IGeometry;//Buffer缓冲区(点线面),大于0向外做缓冲区,小于0向内做缓冲区 | 
						|
                M_hookHelper.ActiveView.Extent = mPolygonBuffer.Envelope;//缓冲区外部边界 | 
						|
                //视图部分刷新 | 
						|
                M_hookHelper.ActiveView.Refresh(); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("缩放至选中项操作失败:" + ex.Message); | 
						|
            } | 
						|
            finally { IsRowClick = false; } | 
						|
        } | 
						|
 | 
						|
        //private ControlsEditingClearCommandClass controlsEditingClearCommandClass = null; | 
						|
        /// <summary> | 
						|
        /// 删除(直接操作图层) | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void DeleteSelectedClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            //if (controlsEditingClearCommandClass == null) | 
						|
            //{ | 
						|
            //    controlsEditingClearCommandClass = new ControlsEditingClearCommandClass(); | 
						|
            //    controlsEditingClearCommandClass.OnCreate(MapsManager.Instance.MapService.Hook); | 
						|
            //} | 
						|
            //controlsEditingClearCommandClass.OnClick(); | 
						|
        } | 
						|
        #endregion | 
						|
 | 
						|
        #region Barmanger底部事件 | 
						|
        #region 数据行定位 | 
						|
        /// <summary> | 
						|
        /// 定位到第一行 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void firstItemClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            if (Data.Rows.Count == 0) return; | 
						|
            gridView1.MoveFirst();//移动到第一行 | 
						|
            if (_curFeatureLayer == null) return; | 
						|
            if (gridView1.DataSource is DataView) | 
						|
            { | 
						|
                int oid = (int)(gridView1.DataSource as DataView)[gridView1.FocusedRowHandle][KeyIDName]; | 
						|
                if (isShowOnlySelect) | 
						|
                { | 
						|
                    _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
                    gridView1.SelectAll(); | 
						|
                    if (_curFeatureLayer != null) | 
						|
                        _curFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName); | 
						|
                    if (_curFeatureLayer != null) | 
						|
                    { | 
						|
                        var f = _curFeatureLayer.FeatureClass.GetFeature(oid); | 
						|
                        if (f != null) | 
						|
                        { | 
						|
                            MapsManager.Instance.MapService.DrawGraph(f.ShapeCopy, true, 255, 255, 0); | 
						|
                            MapsManager.Instance.MapService.Zoom(f.ShapeCopy); | 
						|
                            _hookHelper.ActiveView.Refresh(); | 
						|
                        } | 
						|
                    } | 
						|
                    return; | 
						|
                } | 
						|
                _mapService.SelectFeature((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName, oid.ToString()); | 
						|
                barEditItem1.EditValue = gridView1.FocusedRowHandle + 1; //编辑所在行 | 
						|
            } | 
						|
        } | 
						|
        /// <summary> | 
						|
        /// 定位到上一行 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void PreItemClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (gridView1.FocusedRowHandle == 0) return; | 
						|
                gridView1.MovePrev(); | 
						|
            RePre: | 
						|
                { | 
						|
                    if (gridView1.DataSource is DataView) | 
						|
                    { | 
						|
                        int oid = (int)(gridView1.DataSource as DataView)[gridView1.FocusedRowHandle][KeyIDName]; | 
						|
                        if (!IsExistFature(oid, false)) | 
						|
                        { | 
						|
                            (gridView1.DataSource as DataView)[gridView1.FocusedRowHandle].Delete(); | 
						|
                            goto RePre; | 
						|
                        } | 
						|
                        if (_curFeatureLayer == null) return; | 
						|
                        if (isShowOnlySelect) | 
						|
                        { | 
						|
                            _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
                            gridView1.SelectAll(); | 
						|
                            if (_curFeatureLayer != null) | 
						|
                                _curFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName); | 
						|
                            if (_curFeatureLayer != null) | 
						|
                            { | 
						|
                                var f = _curFeatureLayer.FeatureClass.GetFeature(oid); | 
						|
                                if (f != null) | 
						|
                                { | 
						|
                                    MapsManager.Instance.MapService.DrawGraph(f.ShapeCopy, true, 255, 255, 0); | 
						|
                                    MapsManager.Instance.MapService.Zoom(f.ShapeCopy); | 
						|
                                    _hookHelper.ActiveView.Refresh(); | 
						|
                                } | 
						|
                            } | 
						|
                            return; | 
						|
                        } | 
						|
                        _mapService.SelectFeature((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName, oid.ToString()); | 
						|
                        barEditItem1.EditValue = gridView1.FocusedRowHandle + 1; //编辑所在行 | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug(ex.Message); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 定位到下一行 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void NextItemClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (gridView1.FocusedRowHandle >= gridView1.RowCount) return; | 
						|
                gridView1.MoveNext(); | 
						|
            ReNext: | 
						|
                { | 
						|
                    if (gridView1.DataSource is DataView) | 
						|
                    { | 
						|
                        int oid = (int)(gridView1.DataSource as DataView)[gridView1.FocusedRowHandle][KeyIDName]; | 
						|
                        if (!IsExistFature(oid, false)) | 
						|
                        { | 
						|
                            (gridView1.DataSource as DataView)[gridView1.FocusedRowHandle].Delete(); | 
						|
                            goto ReNext; | 
						|
                        } | 
						|
                        if (_curFeatureLayer == null) return; | 
						|
                        if (isShowOnlySelect) | 
						|
                        { | 
						|
                            _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
                            gridView1.SelectAll(); | 
						|
                            if (_curFeatureLayer != null) | 
						|
                                _curFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName); | 
						|
                            if (_curFeatureLayer != null) | 
						|
                            { | 
						|
                                var f = _curFeatureLayer.FeatureClass.GetFeature(oid); | 
						|
                                if (f != null) | 
						|
                                { | 
						|
                                    MapsManager.Instance.MapService.DrawGraph(f.ShapeCopy, true, 255, 255, 0); | 
						|
                                    MapsManager.Instance.MapService.Zoom(f.ShapeCopy); | 
						|
                                    _hookHelper.ActiveView.Refresh(); | 
						|
                                } | 
						|
                            } | 
						|
                            return; | 
						|
                        } | 
						|
                        _mapService.SelectFeature((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName, oid.ToString()); | 
						|
                        barEditItem1.EditValue = gridView1.FocusedRowHandle + 1; //编辑所在行 | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug(ex.Message); | 
						|
            } | 
						|
        } | 
						|
        /// <summary> | 
						|
        /// 定位到最后一行 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void LastItemClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (Data.Rows.Count == 0) return; | 
						|
                gridView1.MoveLast(); | 
						|
                if (_curFeatureLayer == null) return; | 
						|
                if (gridView1.DataSource is DataView) | 
						|
                { | 
						|
                    int oid = (int)(gridView1.DataSource as DataView)[gridView1.FocusedRowHandle][KeyIDName]; | 
						|
                    if (isShowOnlySelect) | 
						|
                    { | 
						|
                        _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
                        gridView1.SelectAll(); | 
						|
                        if (_curFeatureLayer != null) | 
						|
                            _curFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName); | 
						|
                        if (_curFeatureLayer != null) | 
						|
                        { | 
						|
                            var f = _curFeatureLayer.FeatureClass.GetFeature(oid); | 
						|
                            if (f != null) | 
						|
                            { | 
						|
                                MapsManager.Instance.MapService.DrawGraph(f.ShapeCopy, true, 255, 255, 0); | 
						|
                                MapsManager.Instance.MapService.Zoom(f.ShapeCopy); | 
						|
                                _hookHelper.ActiveView.Refresh(); | 
						|
                            } | 
						|
                        } | 
						|
                        return; | 
						|
                    } | 
						|
                    _mapService.SelectFeature((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName, oid.ToString()); | 
						|
                    barEditItem1.EditValue = gridView1.FocusedRowHandle + 1; //编辑所在行 | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("定位操作失败:" + ex.Message); | 
						|
                return; | 
						|
            } | 
						|
        } | 
						|
        #endregion | 
						|
        /// <summary> | 
						|
        /// 重新加载全部-刷新按钮 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void RefreshingClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (isShowOnlySelect) | 
						|
                    _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
 | 
						|
                gridView1.ClearSelection(); | 
						|
                M_hookHelper.FocusMap.ClearSelection(); | 
						|
                M_hookHelper.ActiveView.Refresh(); | 
						|
 | 
						|
                isShowOnlySelect = false; | 
						|
                if (_curFeatureLayer == null) return; | 
						|
                //刷新重新获取当前图层对象 | 
						|
                _curFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName((_curFeatureLayer.FeatureClass as FeatureClass).BrowseName); | 
						|
                if (_curFeatureLayer == null) return; | 
						|
                if (_curFeatureLayer.FeatureClass.FeatureCount(null) == 0) | 
						|
                { | 
						|
                    gridControl1.DataSource = null; | 
						|
                    ConstructColumn(this._curFeatureLayer.FeatureClass.Fields); | 
						|
                    gridControl1.DataSource = Data.Clone(); | 
						|
                    gridControl1.RefreshDataSource(); | 
						|
                    return; | 
						|
                } | 
						|
                gridView1.Columns.Clear(); | 
						|
                gridControl1.DataSource = null; | 
						|
                //创建列 | 
						|
                ConstructColumn(this._curFeatureLayer.FeatureClass.Fields); | 
						|
                gridControl1.DataSource = Data.Clone(); | 
						|
                //清除所有选择 | 
						|
                //_mapService.ClearFeatureSelection(_hookHelper.Hook as IMapControlDefault); | 
						|
                string strLayer = GeoDBAPI.SerialzedPersist(_curFeatureLayer); | 
						|
                ThreadLoadData(strLayer); | 
						|
                gridControl1.DataSource = Data; | 
						|
                UpdateViewState(); | 
						|
                if (Data.Rows.Count == 0) | 
						|
                    barEditItem1.EditValue = 0; | 
						|
                else | 
						|
                    barEditItem1.EditValue = 1; | 
						|
                //barEditItem3.EditValue = "(" + gridView1.GetSelectedRows().Length + "/" + Data.Rows.Count + "已选择)"; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                MessageHelper.ShowError("加载失败:" + ex.Message); | 
						|
                LogAPI.Debug("加载失败原因:" + ex.Message); | 
						|
            } | 
						|
            finally | 
						|
            { | 
						|
                barEditItem3.EditValue = "(" + gridView1.GetSelectedRows().Length + "/" + Data.Rows.Count + "已选择)"; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 显示所有记录 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void DisplayAllData(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (isShowOnlySelect) | 
						|
                { | 
						|
                    _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
                    M_hookHelper.ActiveView.Refresh(); | 
						|
                } | 
						|
                isShowOnlySelect = false; | 
						|
                List<int> vsTemp = GetSelectRowsOIDS(); | 
						|
                if (vsTemp == null || vsTemp.Count == 0) return; | 
						|
                gridControl1.DataSource = Data; | 
						|
                gridControl1.RefreshDataSource(); | 
						|
 | 
						|
                if (Data.Rows.Count != 0) gridView1.UnselectRow(0); | 
						|
                foreach (var item in vsTemp) | 
						|
                { | 
						|
                    DataRow dr = Data.Rows.Find(item); | 
						|
                    int rowHandle = gridView1.GetRowHandle(Data.Rows.IndexOf(dr)); | 
						|
                    gridView1.SelectRow(rowHandle); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
 | 
						|
                return; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 仅显示所选记录 | 
						|
        /// </summary> | 
						|
        /// <param name="sender"></param> | 
						|
        /// <param name="e"></param> | 
						|
        private void barButtonItem11_ItemClick(object sender, ItemClickEventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (isShowOnlySelect) | 
						|
                    _hookHelper.ActiveView.GraphicsContainer.DeleteAllElements(); | 
						|
                List<int> vsTemp = GetSelectRowsOIDS(); | 
						|
                if (objectids.Count == 0) GetAllObjectid(); | 
						|
                if (vsTemp.Count == 0) | 
						|
                { | 
						|
                    MessageHelper.ShowTips("请勾选所需显示的数据!"); | 
						|
                    return; | 
						|
                } | 
						|
                isShowOnlySelect = true; | 
						|
                //筛选要剔除的数据 | 
						|
                List<int> vs = objectids.Except(vsTemp).ToList(); | 
						|
                DataTable DataTemp = Data.Copy(); | 
						|
                foreach (int item in vs) | 
						|
                { | 
						|
                    DataRow dataRow = DataTemp.Rows.Find(item); | 
						|
                    DataTemp.Rows.Remove(dataRow); | 
						|
                } | 
						|
                gridControl1.DataSource = DataTemp; | 
						|
                gridControl1.RefreshDataSource(); | 
						|
                gridView1.SelectAll(); | 
						|
                M_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, M_hookHelper.ActiveView.Extent); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug(ex.Message); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 获取属性表选择行的OIDs | 
						|
        /// </summary> | 
						|
        /// <returns></returns> | 
						|
        private List<int> GetSelectRowsOIDS() | 
						|
        { | 
						|
            List<int> vsTemp = new List<int>(); | 
						|
            int[] SelectR = gridView1.GetSelectedRows(); | 
						|
            int objectid = -1; | 
						|
            DataTable tempDT = (gridView1.DataSource as DataView).Table as DataTable; | 
						|
            if (tempDT == null) return vsTemp; | 
						|
            foreach (var item in SelectR) | 
						|
            { | 
						|
                int idx = gridView1.ViewRowHandleToDataSourceIndex(item); | 
						|
                objectid = Convert.ToInt32(tempDT.Rows[idx][tempDT.Columns[0]].ToString()); | 
						|
                vsTemp.Add(objectid); | 
						|
            } | 
						|
            return vsTemp; | 
						|
        } | 
						|
        #endregion | 
						|
 | 
						|
        #region ConmonMethod | 
						|
        /// <summary> | 
						|
        /// 获取属性表全部的OBJECTID | 
						|
        /// </summary> | 
						|
        public void GetAllObjectid() | 
						|
        { | 
						|
            if (_curFeatureLayer == null) return; | 
						|
            objectids = new List<int>(); | 
						|
            IQueryFilter queryFilter = new QueryFilterClass(); | 
						|
            queryFilter.WhereClause = queryWhere; | 
						|
            IFeatureCursor pFeatureCursor = _curFeatureLayer.Search(queryFilter, true); | 
						|
            while ((pFeature = pFeatureCursor.NextFeature()) != null) | 
						|
            { | 
						|
                objectids.Add(Convert.ToInt32(pFeature.get_Value(0))); | 
						|
            } | 
						|
            //释放指针(游标) | 
						|
            Marshal.ReleaseComObject(pFeatureCursor); | 
						|
        } | 
						|
 | 
						|
        /// <summary> | 
						|
        /// 返回被选择的要素OID | 
						|
        /// </summary> | 
						|
        /// <returns></returns> | 
						|
        private List<int> GetFeatureSelection(ISelectionSet fSelectionSetes) | 
						|
        { | 
						|
            List<int> selectionOIDs = new List<int>(); | 
						|
            if (fSelectionSetes == null) return null; | 
						|
            IEnumIDs enumIDs = fSelectionSetes.IDs; | 
						|
            enumIDs.Reset(); | 
						|
            int oid = -1; | 
						|
            while ((oid = enumIDs.Next()) >= 0) | 
						|
            { | 
						|
                selectionOIDs.Add(oid); | 
						|
            } | 
						|
            if (selectionOIDs.Count == 0) | 
						|
                return null; | 
						|
            return selectionOIDs; | 
						|
        } | 
						|
 | 
						|
        public event EventHandler CloseViewHandler; | 
						|
        public event CustomCallbackHandler CustomCallBack; | 
						|
        #endregion | 
						|
 | 
						|
        #region 实现IDockPanel接口 | 
						|
        public Guid ID { get; set; } | 
						|
        public DockStyle DockAreas { get; set; } | 
						|
        public 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; } | 
						|
        public bool IsShowInMap { get; set; } | 
						|
        #endregion | 
						|
 | 
						|
 | 
						|
        public void ShowPanel() | 
						|
        { | 
						|
            Platform.Instance.OpenView(this, false); | 
						|
            if (MapsManager.Instance.MapService != null) | 
						|
            { | 
						|
                MapsManager.Instance.MapService.ProjectClosed += MapsService_ProjectClosed; | 
						|
                MapsManager.Instance.MapService.OnSelectionChanged += AxMapControl_OnSelectionChanged; | 
						|
            } | 
						|
            foreach (Bar item in barManager1.Bars) | 
						|
            { | 
						|
                item.Visible = true; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void MapsService_ProjectClosed(object sender, EventArgs e) | 
						|
        { | 
						|
            ClosePanel(); | 
						|
        } | 
						|
 | 
						|
        public void ClosePanel() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                Platform.Instance.CloseView(this); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("关闭属性表面板失败:" + ex); | 
						|
            } | 
						|
            MapsManager.Instance.MapService.OnSelectionChanged -= AxMapControl_OnSelectionChanged; | 
						|
            this.gridView1.CellValueChanging -= gridView1_CellValueChangingEvent; | 
						|
        } | 
						|
 | 
						|
        public void ClosePanelInvoke() | 
						|
        { | 
						|
            Platform.Instance.NotifyMsgEven2 -= Instance_NotifyMsgEven2; | 
						|
            CloseViewHandler?.Invoke(this, null); | 
						|
        } | 
						|
 | 
						|
        //记录之前选择项 | 
						|
        private int SelectedRowIndexByOID = 1; | 
						|
 | 
						|
        public void InitView(List<AttributeViewParameter> pViewParam) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (pViewParam == null) return; | 
						|
                foreach (var ParamItem in pViewParam) | 
						|
                { | 
						|
                    switch (ParamItem.Type) | 
						|
                    { | 
						|
                        case "Combox": | 
						|
                            { | 
						|
                                if (ParamItem.Data is IEnumerable) | 
						|
                                    CreateComboxItem(ParamItem.LableInfo, ParamItem.Data as List<object>, ParamItem); | 
						|
                                break; | 
						|
                            }; | 
						|
                        case "CheckCombox": | 
						|
                            { | 
						|
                                if (ParamItem.Data is IEnumerable) | 
						|
                                    CreatrCheckComboxItem(ParamItem.LableInfo, ParamItem.Data as List<object>, ParamItem); | 
						|
                                break; | 
						|
                            } | 
						|
                        case "RadioCombox": | 
						|
                            { | 
						|
                                if (ParamItem.Data is IFeatureLayer) | 
						|
                                    CreatrRadioComboxItem(ParamItem.LableInfo, ParamItem.Data as List<object>, ParamItem); | 
						|
                                break; | 
						|
                            } | 
						|
                        case "LabCheckBar": | 
						|
                            { | 
						|
                                BarCheckItem baritem = new BarCheckItem(); | 
						|
                                baritem.Caption = ParamItem.LableInfo; | 
						|
                                baritem.PaintStyle = BarItemPaintStyle.Caption; | 
						|
                                baritem.CheckedChanged += (s, e) => | 
						|
                                { | 
						|
                                    if (!(s as BarCheckItem).Checked) return; | 
						|
                                    IndexOID = SelectedRowIndexByOID; | 
						|
                                    if (gridView1.GetSelectedRows().Length >= 0 && _curFeatureLayer != null) | 
						|
                                    { | 
						|
                                        string oidField = _curFeatureLayer.FeatureClass.OIDFieldName; | 
						|
                                        if (gridView1.GetSelectedRows().Count() > 0) | 
						|
                                        { | 
						|
                                            int idx = gridView1.ViewRowHandleToDataSourceIndex(gridView1.GetSelectedRows()[0]); | 
						|
                                            SelectedRowIndexByOID = Convert.ToInt32(Data.Rows[idx][oidField].ToString());//储存 | 
						|
                                        } | 
						|
                                        else | 
						|
                                        { | 
						|
                                            SelectedRowIndexByOID = 1; | 
						|
                                        } | 
						|
                                    } | 
						|
 | 
						|
                                    List<AttributeViewParameter> list = pViewParam.FindAll(f => f.RadioGroupName == ParamItem.RadioGroupName); | 
						|
                                    foreach (var item in list) | 
						|
                                    { | 
						|
                                        if (item.LableInfo == ParamItem.LableInfo) | 
						|
                                            continue; | 
						|
                                        if (item.BarItem is BarCheckItem) | 
						|
                                        { | 
						|
                                            (item.BarItem as BarCheckItem).Checked = false; | 
						|
                                        } | 
						|
                                    } | 
						|
                                    ParamItem.OnCallBack(); | 
						|
                                }; | 
						|
                                ParamItem.BarItem = baritem; | 
						|
                                baritem.Checked = ParamItem.IsChecked; | 
						|
                                if (ParamItem.IsChecked) | 
						|
                                { | 
						|
                                    //LoadData(ParamItem.Data, null); | 
						|
                                } | 
						|
                                bar1.AddItem(baritem); | 
						|
                            } | 
						|
                            break; | 
						|
                        case "ButtonItem": | 
						|
                            { | 
						|
                                BarButtonItem button = new BarButtonItem(); | 
						|
                                button.ItemClick += (s, e) => | 
						|
                                { | 
						|
                                    ParamItem.OnCallBack(); | 
						|
                                }; | 
						|
                                ParamItem.BarItem = button; | 
						|
                                button.Caption = ParamItem.LableInfo; | 
						|
                                bar1.AddItem(button); | 
						|
                                break; | 
						|
                            } | 
						|
                        default: | 
						|
                            break; | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                MessageHelper.Show("初始化属性表时发生错误!"); | 
						|
                LogAPI.Debug("初始化属性表视图时发生异常,异常信息如下:"); | 
						|
                LogAPI.Debug(ex); | 
						|
            } | 
						|
        } | 
						|
        BarItem CreateComboxItem(string pLableText, List<object> pListItem, AttributeViewParameter pParam) | 
						|
        { | 
						|
            BarEditItem barItem = new BarEditItem(); | 
						|
            barItem.Caption = pLableText; | 
						|
            try | 
						|
            { | 
						|
                DevExpress.XtraEditors.Repository.RepositoryItemComboBox comboxEdit = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox(); | 
						|
                if (pListItem == null) | 
						|
                    pListItem = new List<object>(); | 
						|
                foreach (var item in pListItem) | 
						|
                { | 
						|
                    comboxEdit.Items.Add(item); | 
						|
                } | 
						|
                comboxEdit.AutoHeight = true; | 
						|
                comboxEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; | 
						|
                comboxEdit.DropDownRows = 20; | 
						|
                comboxEdit.Tag = pParam; | 
						|
                comboxEdit.SelectedValueChanged += (s, a) => | 
						|
                { | 
						|
                    var sender = (s as DevExpress.XtraEditors.ComboBoxEdit); | 
						|
                    AttributeViewParameter result = barItem.Edit.Tag as AttributeViewParameter; | 
						|
                    result.Value = barItem.EditValue; | 
						|
                    CustomCallBack?.Invoke(pParam); | 
						|
                }; | 
						|
                barItem.EditWidth = 120; | 
						|
                barItem.Edit = comboxEdit; | 
						|
                barItem.PaintStyle = BarItemPaintStyle.CaptionGlyph; | 
						|
                bar1.AddItem(barItem); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("属性表:创建下拉框控件失败:"); | 
						|
                LogAPI.Debug(ex); | 
						|
                return barItem; | 
						|
            } | 
						|
            return barItem; | 
						|
        } | 
						|
 | 
						|
        BarItem CreatrCheckComboxItem(string pLableText, List<object> pListItem, AttributeViewParameter pParam) | 
						|
        { | 
						|
            BarEditItem barItem = new BarEditItem(); | 
						|
            barItem.Caption = pLableText; | 
						|
            try | 
						|
            { | 
						|
                DevExpress.XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit checkComboxEdit = new DevExpress.XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit(); | 
						|
                if (pListItem == null) | 
						|
                    pListItem = new List<object>(); | 
						|
                foreach (var item in pListItem) | 
						|
                { | 
						|
                    checkComboxEdit.Items.Add(item); | 
						|
                } | 
						|
                checkComboxEdit.AutoHeight = true; | 
						|
                checkComboxEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; | 
						|
                checkComboxEdit.DropDownRows = 20; | 
						|
                checkComboxEdit.Tag = pParam; | 
						|
                checkComboxEdit.DataSource = (pParam.Data as Dictionary<string, string>).Values; | 
						|
                checkComboxEdit.EditValueChanged += (s, a) =>//筛选数据 | 
						|
                { | 
						|
                    var sender = s as DevExpress.XtraEditors.CheckedComboBoxEdit; | 
						|
                    AttributeViewParameter result = barItem.Edit.Tag as AttributeViewParameter; | 
						|
                    result.Value = sender.EditValue;//改变值 | 
						|
                    queryWhere = "1=1"; | 
						|
                    if (sender.EditValue.ToString() != "") | 
						|
                    { | 
						|
                        string ZLDM_Temp = string.Empty; | 
						|
                        foreach (string item in sender.EditValue.ToString().Split(',')) | 
						|
                        { | 
						|
                            ZLDM_Temp += string.Format("'{0}' ,", item.Split('_')[0].Trim()); | 
						|
                        } | 
						|
                        if (!string.IsNullOrEmpty(ZLDM_Temp)) | 
						|
                        { | 
						|
                            //if (IsLoadJCTB) | 
						|
                            //    DefinitionQueryWhere += string.Format(" AND (SUBSTRING(ZLDWDM,1,9) in ({0}) AND SFJCTB <>'' ) ", ZLDM_Temp.Trim(',')); | 
						|
                            //else | 
						|
                            //    DefinitionQueryWhere += string.Format(" AND (SUBSTRING(ZLDWDM,1,9) in ({0}) ) ", ZLDM_Temp.Trim(',')); | 
						|
                            pParam.Value = ZLDM_Temp.Trim(','); | 
						|
                            CustomCallBack?.Invoke(pParam); | 
						|
                        } | 
						|
                    } | 
						|
                    CustomCallBack?.Invoke(pParam); | 
						|
                    //InitUI(); | 
						|
                }; | 
						|
                barItem.EditWidth = 180; | 
						|
                barItem.Edit = checkComboxEdit; | 
						|
                barItem.PaintStyle = BarItemPaintStyle.CaptionGlyph; | 
						|
                bar1.AddItem(barItem); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("创建自定义控件失败:" + ex.Message); | 
						|
                throw; | 
						|
            } | 
						|
            return barItem; | 
						|
        } | 
						|
 | 
						|
        BarItem CreatrRadioComboxItem(string pLableText, List<object> pListItem, AttributeViewParameter pParam) | 
						|
        { | 
						|
            BarEditItem barItem = new BarEditItem(); | 
						|
            barItem.Caption = pLableText; | 
						|
            try | 
						|
            { | 
						|
                DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit radioComboxEdit = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit(); | 
						|
                radioComboxEdit.AutoHeight = true; | 
						|
                radioComboxEdit.Tag = pParam; | 
						|
                radioComboxEdit.CheckStateChanged += (s, a) => | 
						|
                { | 
						|
                    //var sender = s as DevExpress.XtraEditors.CheckEdit; | 
						|
                    //if ((pParam.Data as IFeatureLayer).FeatureClass.FindField("SFJCTB") != -1) | 
						|
                    //    IsLoadJCTB = sender.Checked; | 
						|
                    //else | 
						|
                    //    sender.Checked = false; | 
						|
                    //if (DefinitionQueryWhere.Contains("AND") && IsLoadJCTB) | 
						|
                    //    DefinitionQueryWhere = string.Format("({0}) AND SFJCTB <>''", DefinitionQueryWhere); | 
						|
                    //else if (!DefinitionQueryWhere.Contains("AND") && IsLoadJCTB) | 
						|
                    //    DefinitionQueryWhere += " AND SFJCTB <>''"; | 
						|
                    //if (IsLoadJCTB) | 
						|
                    //    InitUI(); | 
						|
                    var sender = s as DevExpress.XtraEditors.CheckEdit; | 
						|
                    if ((pParam.Data as IFeatureLayer).FeatureClass.FindField("SFJCTB") != -1 && sender.Checked) | 
						|
                        pParam.Value = sender.Checked; | 
						|
                    else | 
						|
                        pParam.Value = null; | 
						|
                    CustomCallBack?.Invoke(pParam); | 
						|
                }; | 
						|
                barItem.EditWidth = 20; | 
						|
                barItem.Edit = radioComboxEdit; | 
						|
                barItem.PaintStyle = BarItemPaintStyle.CaptionGlyph; | 
						|
                bar1.AddItem(barItem); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("创建自定义控件失败:" + ex.Message); | 
						|
                throw; | 
						|
            } | 
						|
            return barItem; | 
						|
        } | 
						|
        public void LoadData(object featureLayer, object pDataFilter) | 
						|
        { | 
						|
            if (!(featureLayer is IFeatureLayer)) return; | 
						|
            _curFeatureLayer = featureLayer as IFeatureLayer; | 
						|
            //当前属性表处于编辑  可修改 | 
						|
            if (_Edit.EditState != esriEngineEditState.esriEngineStateNotEditing) | 
						|
            { | 
						|
                if ((_Edit as EngineEditorClass).IEngineEditLayers_TargetLayer == _curFeatureLayer) | 
						|
                    this.gridView1.OptionsBehavior.Editable = true; | 
						|
                else | 
						|
                    this.gridView1.OptionsBehavior.Editable = false; | 
						|
            } | 
						|
            else | 
						|
                this.gridView1.OptionsBehavior.Editable = false; | 
						|
            _mapService = MapsManager.Instance.MapService; | 
						|
            //if (queryWhere == null || string.IsNullOrEmpty(queryWhere)) | 
						|
            //    queryWhere = "1=1"; | 
						|
            //if (!string.IsNullOrWhiteSpace(pDataFilter.ToTrim())) | 
						|
            //    queryWhere += string.Format(" and ({0})", pDataFilter.ToString()); | 
						|
 | 
						|
            if (this.Title == "地类增量图斑更新") | 
						|
            { | 
						|
                RefreshingClick(null, null);//暂-主线程加载测试项 | 
						|
            } | 
						|
            else if (this.Title == "监测图斑") | 
						|
            { | 
						|
                queryWhere = ""; | 
						|
                LoadData(false); | 
						|
            } | 
						|
            else | 
						|
            { | 
						|
                LoadData();//线程加载 | 
						|
            } | 
						|
 | 
						|
            IFeatureClass pFeatureClass = _curFeatureLayer.FeatureClass; | 
						|
            IDataset dataset = pFeatureClass as IDataset; | 
						|
            if (dataset != null && dataset.Name == "DLTBBG" && Platform.Instance.SystemType == SystemTypeEnum.TBBG) | 
						|
            { | 
						|
                Platform.Instance.SendMsg(new NotifyMsgPackage() { Content = "GetTBBGDetail", MsgType = "GetTBBGDetail" }); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public void SelectNextRow() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                NextItemClick(null, null); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("获取当前行失败:" + ex.Message); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public void SelectPrevRow() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                PreItemClick(null, null); | 
						|
            } | 
						|
            catch (Exception) | 
						|
            { | 
						|
                //MessageHelper.ShowTips("当前行不存在!"); | 
						|
                //gridView1.ClearSelection(); | 
						|
                //gridView1.FocusedRowHandle++; | 
						|
                //gridView1.SelectRow(gridView1.FocusedRowHandle); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public ITable AttributeTable => throw new NotImplementedException(); | 
						|
 | 
						|
    } | 
						|
}
 | 
						|
 |