public void ReadFromXml(XmlNode node) { if (node.Attributes != null) { _name = node.Attributes["Name"] == null ? "" : node.Attributes["Name"].Value; _aliasName = node.Attributes["AliasName"] == null ? "" : node.Attributes["AliasName"].Value; _visible = node.Attributes["Visible"] == null ? true : (node.Attributes["Visible"].Value.ToUpper().StartsWith("T") ? true : false); _dataType = node.Attributes["DataType"] == null ? enumPipelineDataType.Point : EnumHelper.ConvertDataTypeFromString(node.Attributes["DataType"].Value); _heightType = node.Attributes["HeightType"] == null ? enumPipelineHeightType.Top : EnumHelper.ConvertHeightTypeFromStr(node.Attributes["HeightType"].Value); _validateKeys = node.Attributes["ValidateKeys"] == null ? "" : node.Attributes["ValidateKeys"].Value; _templateName = node.Attributes["TemplateName"] == null ? "" : node.Attributes["TemplateName"].Value; _autoNames = node.Attributes["AutoNames"].Value; } XmlNodeList fieldNodes = node.SelectNodes("Fields/Field"); foreach (XmlNode fieldNode in fieldNodes) { IYTField field = new YTField(fieldNode); //需要检查已有的字段定义中有没有重名的 IYTField findField = _fields.FirstOrDefault(c => c.Name == field.Name); if (findField != null) { _fields.Remove(findField); } _fields.Add(field); } }
public void ReadFromXml(XmlNode xml) { if (xml?.Attributes == null) { return; } _name = xml.Attributes["Name"].Value; _aliasName = xml.Attributes["AliasName"].Value; _visible = Convert.ToBoolean(xml.Attributes["Visible"].Value); _templateName = xml.Attributes["Template"].Value; XmlNodeList nodeList = xml.SelectNodes("/LineAssist/Fields/Field"); if (nodeList != null) { foreach (XmlNode node in nodeList) { IYTField field = new YTField(node); _fields.Add(field); } } _noField = _fields.FirstOrDefault(c => c.TypeName == "NoField"); _sPointField = _fields.FirstOrDefault(c => c.TypeName == "SPointField"); _ePointField = _fields.FirstOrDefault(c => c.TypeName == "EPointField"); _gxlxField = _fields.FirstOrDefault(c => c.TypeName == "GXLXField"); _sslxField = _fields.FirstOrDefault(c => c.TypeName == "SSLXField"); _lineTypeField = _fields.FirstOrDefault(c => c.TypeName == "LineTypeField"); _codeField = _fields.FirstOrDefault(c => c.TypeName == "CodeField"); _roadCodeField = _fields.FirstOrDefault(c => c.TypeName == "RoadCodeField"); _dCodeField = _fields.FirstOrDefault(c => c.TypeName == "DCodeField"); _dDateField = _fields.FirstOrDefault(c => c.TypeName == "DDateField"); _mDateField = _fields.FirstOrDefault(c => c.TypeName == "MDateField"); _remarkField = _fields.FirstOrDefault(c => c.TypeName == "RemarkField"); }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if ((bool)e.Result) { this.pDataSet.Tables.Add(this.stable); this.pDataSet.Tables.Add(this.Geotable); DataRelation relation = new DataRelation("空间表", this.stable.Columns[0], this.Geotable.Columns[0]); this.pDataSet.Relations.Add(relation); this.gridControl1.DataSource = (this.pDataSet.Tables[0]); for (int i = 0; i < this.mainGridView.Columns.Count; i++) { this.mainGridView.Columns[i].BestFit(); this.mainGridView.Columns[i].Width = ((int)((double)this.mainGridView.Columns[i].Width * 1.4)); string key = this.mainGridView.Columns[i].FieldName; if (i == this.OidField) { continue; } if (_layerInfo != null) { IYTField pField = _layerInfo.Fields.FirstOrDefault(c => c.Name == key); if (pField == null) { this.mainGridView.Columns[i].Visible = false; continue; } this.mainGridView.Columns[i].Caption = pField.AliasName; this.mainGridView.Columns[i].Visible = pField.Visible; } } } }
private void InitBrokePoint() { int userClassID; int userID; int userSubID; IFeatureClassContainer featureDataset = (IFeatureClassContainer)this._nearestEdgeInfo.GeometricNetwork.FeatureDataset; IFeatureClass pointClass = null; IFeatureClass lineClass = null; int num3 = 0; pointClass = _pipeLayer.GetLayers(enumPipelineDataType.Point)[0].FeatureClass; lineClass = _pipeLayer.GetLayers(enumPipelineDataType.Line)[0].FeatureClass; this._networkInfo.LayerLine = MapHelper.FindFeatureLayerByFCName(m_iApp.FocusMap as IBasicMap, ((IDataset)lineClass).Name, false) as IFeatureLayer; this._networkInfo.LayerPoint = MapHelper.FindFeatureLayerByFCName(m_iApp.FocusMap as IBasicMap, ((IDataset)pointClass).Name, false) as IFeatureLayer; INetElements network = (INetElements)this._nearestEdgeInfo.GeometricNetwork.Network; network.QueryIDs(this._nearestEdgeInfo.EdgeID, esriElementType.esriETEdge, out userClassID, out userID, out userSubID); this._networkInfo.LineFeature = lineClass.GetFeature(userID); Label label = this.lblPickPipeInfo; string[] name = new string[] { this._networkInfo.LayerLine.Name, ",", lineClass.OIDFieldName, "=", userID.ToString() }; label.Text = string.Concat(name); string.Format("\r\n爆管点位置({0:f2},{1:f2},{2:f2})", this._nearestEdgeInfo.Location.X, this._nearestEdgeInfo.Location.Y, this._nearestEdgeInfo.Location.Z); //初始化下拉菜单 cmbDomainValues.Items.Clear(); IBasicLayerInfo pLayerInfo = _pipeLayer.GetLayers(enumPipelineDataType.Point)[0]; IYTField pField = pLayerInfo.GetField(PipeConfigWordHelper.PointWords.FSW); this.label1.Text = pField.Name; if (!string.IsNullOrEmpty(pField.DomainValues)) { string[] domianValues = pField.DomainValues.Split('/'); foreach (var onePair in domianValues) { cmbDomainValues.Items.Add(onePair); } } if (this.listFieldValues.Items.Count == 0) { this.listFieldValues.Items.Add("阀门"); this.listFieldValues.Items.Add("阀门井"); } }
public IYTField GetSpecialField(string classAliasName, string typeWord) { IBasicLayerInfo layer = GetBasicLayerInfo(classAliasName); if (layer == null) { return(null); } IYTField field = layer.Fields.FirstOrDefault(c => c.TypeName == typeWord); return(field); }
public void ReadFromXml(XmlNode xml) { if (xml?.Attributes == null) { return; } _name = xml.Attributes["Name"].Value; _aliasName = xml.Attributes["AliasName"].Value; _visible = Convert.ToBoolean(xml.Attributes["Visible"].Value); _heightTypeName = xml.Attributes["HeightType"].Value; _heightType = EnumHelper.ConvertHeightTypeFromStr(_heightTypeName); _templateName = xml.Attributes["Template"].Value; XmlNodeList nodeList = xml.SelectNodes("/LineLayer/Fields/Field"); if (nodeList != null) { foreach (XmlNode node in nodeList) { IYTField field = new YTField(node); _fields.Add(field); } } _noField = _fields.FirstOrDefault(c => c.TypeName == "NoField"); _sPointField = _fields.FirstOrDefault(c => c.TypeName == "SPointField"); _ePointField = _fields.FirstOrDefault(c => c.TypeName == "EPointField"); _sDeepField = _fields.FirstOrDefault(c => c.TypeName == "SDeepField"); _eDeepField = _fields.FirstOrDefault(c => c.TypeName == "EDeepField"); _shField = _fields.FirstOrDefault(c => c.TypeName == "SHField"); _ehField = _fields.FirstOrDefault(c => c.TypeName == "EHField"); _codeField = _fields.FirstOrDefault(c => c.TypeName == "CodeField"); _materialField = _fields.FirstOrDefault(c => c.TypeName == "MaterialField"); _dTypeField = _fields.FirstOrDefault(c => c.TypeName == "DTypeField"); _lineStyleField = _fields.FirstOrDefault(c => c.TypeName == "LineStyleField"); _dsField = _fields.FirstOrDefault(c => c.TypeName == "DSField"); _sectionSizeField = _fields.FirstOrDefault(c => c.TypeName == "SectionSizeField"); _pdmField = _fields.FirstOrDefault(c => c.TypeName == "PDMField"); _pipeNatureField = _fields.FirstOrDefault(c => c.TypeName == "PipeNatureField"); _msrqField = _fields.FirstOrDefault(c => c.TypeName == "MSRQField"); _mDateField = _fields.FirstOrDefault(c => c.TypeName == "MDateField"); _useStatusField = _fields.FirstOrDefault(c => c.TypeName == "UseStatusField"); _bCodeField = _fields.FirstOrDefault(c => c.TypeName == "BCodeField"); _roadCodeField = _fields.FirstOrDefault(c => c.TypeName == "RoadCodeField"); _cabCountField = _fields.FirstOrDefault(c => c.TypeName == "CabCountField"); _volPresField = _fields.FirstOrDefault(c => c.TypeName == "VolPresField"); _holeCountField = _fields.FirstOrDefault(c => c.TypeName == "HoleCountField"); _holeUsedField = _fields.FirstOrDefault(c => c.TypeName == "HoleUsedField"); _flowDField = _fields.FirstOrDefault(c => c.TypeName == "FlowDField"); _remarkField = _fields.FirstOrDefault(c => c.TypeName == "RemarkField"); }
public YTField(IYTField pField) { _typeName = pField.TypeName; _name = pField.Name; _aliasName = pField.AliasName; _autoNames = pField.AutoNames; _length = pField.Length; _precision = pField.Precision; _fieldType = pField.FieldType; _allowNull = pField.AllowNull; _domainValues = pField.DomainValues; _visible = pField.Visible; if (string.IsNullOrEmpty(_domainValues)) { DomainValues = pField.DomainValues; } }
private void LoadFieldAutoNames() { for (int i = 0; i < _featureClass.Fields.FieldCount; i++) { IField pField = _featureClass.Fields.Field[i]; IYTField ytField = _fields.FirstOrDefault( c => c.Name == pField.Name || c.AliasName == pField.Name || c.AliasName == pField.AliasName || c.Name == pField.AliasName || c.FixAutoNames.Contains("/" + pField.Name + "/")); if (ytField != null) { ytField.EsriFieldName = pField.Name; ytField.Name = pField.Name; ytField.AliasName = pField.AliasName; continue; } } }
public void ReadFromXml(XmlNode xml) { if (xml?.Attributes == null) { return; } _name = xml.Attributes["Name"].Value; _aliasName = xml.Attributes["AliasName"].Value; _visible = Convert.ToBoolean(xml.Attributes["Visible"].Value); _templateName = xml.Attributes["Template"].Value; XmlNodeList nodeList = xml.SelectNodes("/PointLayer/Fields/Field"); if (nodeList != null) { foreach (XmlNode node in nodeList) { IYTField field = new YTField(node); _fields.Add(field); } } _noField = _fields.FirstOrDefault(c => c.TypeName == "NoField"); _xField = _fields.FirstOrDefault(c => c.TypeName == "XField"); _yField = _fields.FirstOrDefault(c => c.TypeName == "YField"); _zField = _fields.FirstOrDefault(c => c.TypeName == "ZField"); _depthField = _fields.FirstOrDefault(c => c.TypeName == "DepthField"); _featureField = _fields.FirstOrDefault(c => c.TypeName == "FeatureField"); _subsidField = _fields.FirstOrDefault(c => c.TypeName == "SubsidField"); _pStyleField = _fields.FirstOrDefault(c => c.TypeName == "PStyleField"); _pdsField = _fields.FirstOrDefault(c => c.TypeName == "PDSField"); _codeField = _fields.FirstOrDefault(c => c.TypeName == "CodeField"); _mapNoField = _fields.FirstOrDefault(c => c.TypeName == "MapNoField"); _useStatusField = _fields.FirstOrDefault(c => c.TypeName == "UseStatusField"); _bCodeField = _fields.FirstOrDefault(c => c.TypeName == "BCodeField"); _rotangField = _fields.FirstOrDefault(c => c.TypeName == "RotangField"); _roadCodeField = _fields.FirstOrDefault(c => c.TypeName == "RoadCodeField"); _mDateField = _fields.FirstOrDefault(c => c.TypeName == "MDateField"); _pcjhField = _fields.FirstOrDefault(c => c.TypeName == "PCJHField"); _remarkField = _fields.FirstOrDefault(c => c.TypeName == "RemarkField"); }
private void CalButton_Click(object sender, EventArgs e) { Splash.Show(); int count = this.Layerbox.CheckedItems.Count; int num = -1; DataTable dataTable = new DataTable(); dataTable.Columns.Clear(); Splash.Status = "状态: 正在汇总,请稍候..."; if (this.PointRadio.Checked) { if (!dataTable.Columns.Contains("层名")) { dataTable.Columns.Add("层名", typeof(string)); } if (!dataTable.Columns.Contains("点性")) { dataTable.Columns.Add("点性", typeof(string)); } if (!dataTable.Columns.Contains("个数")) { dataTable.Columns.Add("个数", typeof(int)); } if (!dataTable.Columns.Contains("总数")) { dataTable.Columns.Add("总数", typeof(int)); } int num2 = 0; for (int i = 0; i < count; i++) { int num3 = 0; Splash.Status = "状态: 正在汇总" + this.Layerbox.CheckedItems[i] + ",请稍候..."; IFeatureLayer pPipeLayer = ((ClassCollectformsUI.LayerboxItem) this.Layerbox.CheckedItems[i]).m_pPipeLayer; IFields fields = pPipeLayer.FeatureClass.Fields; IYTField fieldInfo = pPipeCfg.GetSpecialField(pPipeLayer.FeatureClass.AliasName, PipeConfigWordHelper.PointWords.TZW); string pointTableFieldName = fieldInfo.Name; int num4 = fields.FindField(pointTableFieldName); if (num4 >= 0) { string name = pPipeLayer.Name; ISpatialFilter spatialFilter = new SpatialFilter(); IFeatureClass featureClass = pPipeLayer.FeatureClass; if (this.GeometrySet.Checked) { if (this.m_ipGeo != null) { spatialFilter.Geometry = (this.m_ipGeo); } spatialFilter.SpatialRel = (esriSpatialRelEnum)(1); } ISelectionSet selectionSet = featureClass.Select(spatialFilter, (esriSelectionType)3, (esriSelectionOption)1, null); ITableSort tableSort = new TableSort(); tableSort.Fields = (pointTableFieldName); tableSort.SelectionSet = (selectionSet); tableSort.Sort(null); ICursor rows = tableSort.Rows; object obj = null; int num5 = 1; for (IRow row = rows.NextRow(); row != null; row = rows.NextRow()) { object obj2 = row.Value[num4]; if (obj == null || !this.ColumnEqual(obj, obj2)) { if (obj == null) { obj = obj2; } else { dataTable.Rows.Add(new object[] { name, obj, num5 }); num3 += num5; obj = obj2; num5 = 1; } } else { num5++; } } num3 += num5; num2 += num3; dataTable.Rows.Add(new object[] { name, obj, num5, num3 }); } } object[] array = new object[4]; array.SetValue("合计", 1); array.SetValue(num2, 3); dataTable.Rows.Add(array); } else { if (!dataTable.Columns.Contains("层名")) { dataTable.Columns.Add("层名", typeof(string)); } if (!dataTable.Columns.Contains("规格")) { dataTable.Columns.Add("规格", typeof(string)); } if (!dataTable.Columns.Contains("材质")) { dataTable.Columns.Add("材质", typeof(string)); } if (!dataTable.Columns.Contains("条数")) { dataTable.Columns.Add("条数", typeof(int)); } if (!dataTable.Columns.Contains("长度")) { dataTable.Columns.Add("长度", typeof(double)); } if (!dataTable.Columns.Contains("总条数")) { dataTable.Columns.Add("总条数", typeof(int)); } if (!dataTable.Columns.Contains("总长度")) { dataTable.Columns.Add("总长度", typeof(double)); } int num6 = 0; double num7 = 0.0; for (int j = 0; j < count; j++) { int num8 = 0; double num9 = 0.0; Splash.Status = "状态: 正在汇总" + this.Layerbox.CheckedItems[j] + ",请稍候..."; IFeatureLayer pPipeLayer = ((ClassCollectformsUI.LayerboxItem) this.Layerbox.CheckedItems[j]).m_pPipeLayer; IFields fields2 = pPipeLayer.FeatureClass.Fields; IBasicLayerInfo layerInfo = pPipeCfg.GetBasicLayerInfo(pPipeLayer.FeatureClass); string lineTableFieldName = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.GJ); int num4 = fields2.FindField(lineTableFieldName); string lineTableFieldName2 = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.DMCC); // this.pPipeCfg.GetLineTableFieldName("断面尺寸"); int num10 = fields2.FindField(lineTableFieldName2); string lineTableFieldName3 = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.GXCZ); // this.pPipeCfg.GetLineTableFieldName("材质"); int num11 = fields2.FindField(lineTableFieldName3); for (int k = 0; k < fields2.FieldCount; k++) { IField field = fields2.Field[k]; if (field.Type == (esriFieldType)7) { num = k; break; } } if (num4 >= 0 || num10 >= 0) { string name = pPipeLayer.Name; ISpatialFilter spatialFilter2 = new SpatialFilter(); IFeatureClass featureClass2 = pPipeLayer.FeatureClass; if (this.GeometrySet.Checked) { if (this.m_ipGeo != null) { spatialFilter2.Geometry = (this.m_ipGeo); } spatialFilter2.SpatialRel = (esriSpatialRelEnum)(1); } ISelectionSet selectionSet2 = featureClass2.Select(spatialFilter2, (esriSelectionType)3, (esriSelectionOption)1, null); ITableSort tableSort2 = new TableSort(); tableSort2.Fields = (string.Concat(new string[] { lineTableFieldName, ",", lineTableFieldName2, ",", lineTableFieldName3 })); tableSort2.SelectionSet = (selectionSet2); tableSort2.Sort(null); ICursor rows2 = tableSort2.Rows; object obj3 = null; object obj4 = null; int num12 = 1; IRow row2 = rows2.NextRow(); double num13 = 0.0; while (row2 != null) { object obj5 = row2.Value[num4]; if (obj5 is DBNull || obj5.ToString() == "0") { obj5 = row2.Value[num10]; } object obj6 = row2.Value[num11]; if (row2.Value[num] is DBNull) { row2 = rows2.NextRow(); } else { IPolyline polyline = (IPolyline)row2.Value[num]; IPointCollection pointCollection = (IPointCollection)polyline; double num14 = 0.0; for (int l = 0; l < pointCollection.PointCount - 1; l++) { IPoint point = pointCollection.Point[l]; IPoint point2 = pointCollection.Point[l + 1]; num14 += Math.Sqrt(Math.Pow(point.X - point2.X, 2.0) + Math.Pow(point.Y - point2.Y, 2.0) + Math.Pow(point.Z - point.M - point2.Z + point2.M, 2.0)); } if (obj3 == null || !this.ColumnEqual(obj3, obj5)) { if (obj3 == null) { obj3 = obj5; num13 += num14; } else { num13 = Math.Round(num13, 3); dataTable.Rows.Add(new object[] { name, obj3, obj4, num12, num13 }); num8 += num12; num9 += num13; obj3 = obj5; obj4 = null; num13 = num14; num12 = 1; } } else if (obj4 == null || !this.ColumnEqual(obj4, obj6)) { if (obj4 == null) { obj4 = obj6; num13 += num14; num12++; } else { num13 = Math.Round(num13, 3); dataTable.Rows.Add(new object[] { name, obj3, obj4, num12, num13 }); num8 += num12; num9 += num13; num13 = num14; obj4 = obj6; num12 = 1; } } else { num13 += num14; num12++; } row2 = rows2.NextRow(); } } num8 += num12; num9 += num13; num6 += num8; num7 += num9; num13 = Math.Round(num13, 3); num9 = Math.Round(num9, 3); dataTable.Rows.Add(new object[] { name, obj3, obj4, num12, num13, num8, num9 }); } } num7 = Math.Round(num7, 3); object[] array2 = new object[7]; array2.SetValue("合计", 1); array2.SetValue(num6, 5); array2.SetValue(num7, 6); dataTable.Rows.Add(array2); } Splash.Close(); ClassCollectResultForm classCollectResultForm = new ClassCollectResultForm(); if (this.PointRadio.Checked) { classCollectResultForm.nType = 0; } else { classCollectResultForm.nType = 1; } classCollectResultForm.ResultTable = dataTable; classCollectResultForm.ShowDialog(); }
public string GetFieldName(string typeWord) { IYTField field = _fields.FirstOrDefault(c => c.TypeName == typeWord); return(field != null ? field.Name : typeWord); }
public IYTField GetField(string typeWord) { IYTField field = _fields.FirstOrDefault(c => c.TypeName == typeWord); return(field); }
public List <IPipelineLayer> ReadLayersFromDatabase() { List <IPipelineLayer> layers = new List <IPipelineLayer>(); ITable pCodeTable = _workspace.OpenTable("YT_PIPE_CODE"); ITableSort tableSort = new TableSortClass(); tableSort.Table = pCodeTable; tableSort.Fields = "Priority"; tableSort.Sort(null); ICursor pCursor = tableSort.Rows; IRow pRow = pCursor.NextRow(); int codeIdx = pCursor.FindField("PipeCode"); int classIdx = pCursor.FindField("ClassCode"); int nameIdx = pCursor.FindField("PipeName"); int autoIdx = pCursor.FindField("AutoNames"); int priIdx = pCursor.FindField("Priority"); while (pRow != null) { IPipelineLayer oneLayer = new PipelineLayer() { Code = pRow.Value[codeIdx].ToString(), Name = pRow.Value[nameIdx].ToString(), AutoNames = pRow.Value[autoIdx].ToString(), Layers = new List <IBasicLayerInfo>(), ClassCode = pRow.Value[classIdx].ToString() }; layers.Add(oneLayer); pRow = pCursor.NextRow(); } Marshal.ReleaseComObject(pCursor); Marshal.ReleaseComObject(tableSort); Marshal.ReleaseComObject(pCodeTable); List <IYTDomain> domains = new List <IYTDomain>(); pCodeTable = _workspace.OpenTable("YT_PIPE_DOMAIN"); pCursor = pCodeTable.Search(null, false); pRow = pCursor.NextRow(); nameIdx = pCursor.FindField("DomainName"); autoIdx = pCursor.FindField("DomainValues"); while (pRow != null) { string domainName = pRow.Value[nameIdx].ToString(); string domainValues = pRow.Value[autoIdx].ToString(); IYTDomain onedomain = new YTDomain(domainName, domainValues); domains.Add(onedomain); pRow = pCursor.NextRow(); } Marshal.ReleaseComObject(pCursor); Marshal.ReleaseComObject(pCodeTable); List <IPipelineTemplate> templates = new List <IPipelineTemplate>(); //! 先读取模板 pCodeTable = _workspace.OpenTable("YT_PIPE_FIELD"); tableSort = new TableSortClass(); tableSort.Table = pCodeTable; tableSort.Fields = "TemplateName"; tableSort.Sort(null); pCursor = tableSort.Rows; string oldTemplate = ""; int[] fieldIndexes = new int[10]; pRow = pCursor.NextRow(); fieldIndexes[0] = pRow.Fields.FindField("TemplateName"); fieldIndexes[1] = pRow.Fields.FindField("TypeName"); fieldIndexes[2] = pRow.Fields.FindField("FieldName"); fieldIndexes[3] = pRow.Fields.FindField("FieldAliasName"); fieldIndexes[4] = pRow.Fields.FindField("FieldType"); fieldIndexes[5] = pRow.Fields.FindField("FieldLength"); fieldIndexes[6] = pRow.Fields.FindField("FieldPrecision"); fieldIndexes[7] = pRow.Fields.FindField("AllowNull"); fieldIndexes[8] = pRow.Fields.FindField("AutoValues"); fieldIndexes[9] = pRow.Fields.FindField("IsKey"); // fieldIndexes[10] = pRow.Fields.FindField("Domains"); IPipelineTemplate oneTemplate = null; while (pRow != null) { string templateName = pRow.Value[fieldIndexes[0]].ToString(); if (!templateName.Equals(oldTemplate)) { if (oneTemplate != null) { templates.Add(oneTemplate); } oneTemplate = new PipelineTemplate() { Name = templateName, Fields = new List <IYTField>() }; oldTemplate = templateName; } IYTField field = new YTField() { TypeName = pRow.Value[fieldIndexes[1]].ToString(), Name = pRow.Value[fieldIndexes[2]].ToString(), AliasName = pRow.Value[fieldIndexes[3]].ToString(), Length = Convert.ToInt32(pRow.Value[fieldIndexes[5]].ToString()), Precision = Convert.ToInt32(pRow.Value[fieldIndexes[6]].ToString()), AllowNull = Convert.ToInt32(pRow.Value[fieldIndexes[7]].ToString()) == -1 ? true : false, AutoNames = pRow.Value[fieldIndexes[8]].ToString(), FieldType = FieldHelper.ConvertFromString(pRow.Value[fieldIndexes[4]].ToString()) }; oneTemplate.Fields.Add(field); pRow = pCursor.NextRow(); } if (oneTemplate != null) { templates.Add(oneTemplate); } Marshal.ReleaseComObject(pCursor); Marshal.ReleaseComObject(tableSort); Marshal.ReleaseComObject(pCodeTable); List <IBasicLayerInfo> basicInfos = new List <IBasicLayerInfo>(); pCodeTable = _workspace.OpenTable("YT_PIPE_LAYER"); tableSort = new TableSortClass(); tableSort.Table = pCodeTable; tableSort.Fields = "Priority,LayerName"; tableSort.Sort(null); pCursor = tableSort.Rows; pRow = pCursor.NextRow(); fieldIndexes = new int[8]; fieldIndexes[0] = pRow.Fields.FindField("PipeCode"); fieldIndexes[1] = pRow.Fields.FindField("BasicName"); fieldIndexes[2] = pRow.Fields.FindField("LayerName"); fieldIndexes[3] = pRow.Fields.FindField("AutoNames"); fieldIndexes[4] = pRow.Fields.FindField("Priority"); fieldIndexes[5] = pRow.Fields.FindField("DataType"); fieldIndexes[6] = pRow.Fields.FindField("Template"); fieldIndexes[7] = pRow.Fields.FindField("Domains"); while (pRow != null) { string pipeCode = pRow.Value[fieldIndexes[0]].ToString(); IPipelineLayer oneLayer = layers.Find(c => c.Code == pipeCode); if (oneLayer == null) { pRow = pCursor.NextRow(); continue; } enumPipelineDataType dataType = Yutai.Pipeline.Config.Helpers.EnumHelper.ConvertDataTypeFromString( pRow.Value[fieldIndexes[5]].ToString().Trim()); IBasicLayerInfo basicLayer = new BasicLayerInfo() { Name = pRow.Value[fieldIndexes[1]].ToString(), AliasName = pRow.Value[fieldIndexes[2]].ToString(), AutoNames = pRow.Value[fieldIndexes[3]].ToString(), DataType = dataType, TemplateName = pRow.Value[fieldIndexes[6]].ToString(), Fields = new List <IYTField>() }; if (pRow.Value[fieldIndexes[6]] != null) { IPipelineTemplate template = templates.Find(c => c.Name == basicLayer.TemplateName); if (template != null) { foreach (IYTField field in template.Fields) { basicLayer.Fields.Add(new YTField(field)); } } } string domainStr = pRow.Value[fieldIndexes[7]] == DBNull.Value ? string.Empty : pRow.Value[fieldIndexes[7]].ToString(); if (!string.IsNullOrEmpty(domainStr)) { //获得Domainzhi值 string[] domainPairs = domainStr.Split('/'); for (int j = 0; j < domainPairs.Length; j++) { string[] domainPair = domainPairs[j].Split(':'); string fieldName = domainPair[0]; string domainName = domainPair[1]; IYTDomain findDomain = domains.FirstOrDefault(c => c.DomainName == domainName); if (findDomain != null) { IYTField pField = basicLayer.Fields.FirstOrDefault(c => c.TypeName == fieldName); if (pField != null) { pField.Domain = new YTDomain(findDomain.DomainName, findDomain.DomainValues); } } } } oneLayer.Layers.Add(basicLayer); pRow = pCursor.NextRow(); } Marshal.ReleaseComObject(pCursor); Marshal.ReleaseComObject(tableSort); Marshal.ReleaseComObject(pCodeTable); return(layers); }
private bool AddItems() { IFeature feature = _cursor?.NextFeature(); if (feature == null) { return(false); } _layerInfo = _plugin.PipeConfig.GetBasicLayerInfo(feature.Class.AliasName); if (_layerInfo == null) { return(false); } IFields fields = this._cursor.Fields; int num = 0; this.OidField = 0; this.stable.Columns.Add("OID", typeof(string)); for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.get_Field(i); string name = field.Name; if (field.Type == esriFieldType.esriFieldTypeGeometry) { num = i; } if (field.Type == esriFieldType.esriFieldTypeOID) { this.OidField = i; } else { if (field.Type == esriFieldType.esriFieldTypeDouble || field.Type == esriFieldType.esriFieldTypeSingle || field.Type == esriFieldType.esriFieldTypeInteger || field.Type == esriFieldType.esriFieldTypeSmallInteger) { this.cmbCalField.Items.Add(field.Name); } this.cmbStatField.Items.Add(field.Name); if (!this.stable.Columns.Contains(fields.Field[i].Name)) { IYTField pField = _layerInfo.Fields.FirstOrDefault(c => c.Name == field.Name); DataColumn dataColumn; switch (field.Type) { case esriFieldType.esriFieldTypeInteger: dataColumn = this.stable.Columns.Add(name, typeof(int)); break; case esriFieldType.esriFieldTypeSingle: dataColumn = this.stable.Columns.Add(name, typeof(float)); break; case esriFieldType.esriFieldTypeDouble: dataColumn = this.stable.Columns.Add(name, typeof(double)); break; case esriFieldType.esriFieldTypeOID: dataColumn = this.stable.Columns.Add(name, typeof(string)); break; default: dataColumn = this.stable.Columns.Add(name, typeof(string)); break; } if (pField != null) { dataColumn.Caption = pField.AliasName; } } } } if (this.cmbCalField.Items.Count > 0) { this.cmbCalField.SelectedIndex = 0; } if (feature.FeatureType == esriFeatureType.esriFTComplexEdge || feature.FeatureType == esriFeatureType.esriFTSimpleEdge) { this.cmbStatWay.Items.Add("统计长度"); } return(true); }
private void UpdateGrid() { this.gridControl1.DataSource = (null); Splash.Show(); Splash.Status = "状态:正在查询,请稍候..."; try { if (this.MakeData()) { this.pDataSet.Tables.Add(this.stable); this.pDataSet.Tables.Add(this.Geotable); DataRelation relation = new DataRelation("空间表", this.stable.Columns[0], this.Geotable.Columns[0]); this.pDataSet.Relations.Add(relation); this.gridControl1.DataSource = (this.pDataSet.Tables[0]); for (int i = 0; i < this.mainGridView.Columns.Count; i++) { this.mainGridView.Columns[i].BestFit(); this.mainGridView.Columns[i].Width = ((int)((double)this.mainGridView.Columns[i].Width * 1.4)); string key = this.mainGridView.Columns[i].FieldName; if (i == this.OidField) { continue; } if (layerInfo != null) { IYTField pField = layerInfo.Fields.FirstOrDefault(c => c.Name == key); if (pField == null) { this.mainGridView.Columns[i].Visible = false; continue; } this.mainGridView.Columns[i].Caption = pField.AliasName; this.mainGridView.Columns[i].Visible = pField.Visible; } //if (key == "管径" || key == "沟截面宽高") //{ // this.mainGridView.Columns[i].Caption = (key + "[毫米]"); //} //else if (key.ToUpper() == "X" || key.ToUpper() == "Y" || key == "地面高程" || key == "起点高程" || key == "终点高程" || key == "起点埋深" || key == "终点埋深") //{ // this.mainGridView.Columns[i].Caption = (key + "[米]"); //} //else if (key == "电压") //{ // this.mainGridView.Columns[i].Caption = ("电压[千伏]"); //} //else if (key == "压力") //{ // this.mainGridView.Columns[i].Caption = ("压力[兆帕]"); //} //Regex regex = new Regex("^[\\u4e00-\\u9fa5]+$"); //if (!regex.IsMatch(key)) //{ // this.mainGridView.Columns[i].Visible = (false); //} } this.FormatCurrencyColumns(); } Splash.Close(); } catch { Splash.Close(); } }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { try { int num = -1; DataTable dataTable = new DataTable(); dataTable.Columns.Clear(); _waitForm.Count = _featureLayers.Count; int i = 0; _waitForm.Worker.ReportProgress(i++, "状态: 正在汇总,请稍候..."); if (_pointRadioChecked) { if (!dataTable.Columns.Contains("层名")) { dataTable.Columns.Add("层名", typeof(string)); } if (!dataTable.Columns.Contains("点性")) { dataTable.Columns.Add("点性", typeof(string)); } if (!dataTable.Columns.Contains("个数")) { dataTable.Columns.Add("个数", typeof(int)); } if (!dataTable.Columns.Contains("总数")) { dataTable.Columns.Add("总数", typeof(int)); } int num2 = 0; foreach (IFeatureLayer featureLayer in _featureLayers) { if (_waitForm.Worker.CancellationPending) { break; } _waitForm.Worker.ReportProgress(i++, "状态: 正在汇总 " + featureLayer.Name + ",请稍候..."); int num3 = 0; IFields fields = featureLayer.FeatureClass.Fields; IYTField fieldInfo = pPipeCfg.GetSpecialField(featureLayer.FeatureClass.AliasName, PipeConfigWordHelper.PointWords.TZW); if (fieldInfo == null) { continue; } string pointTableFieldName = fieldInfo.Name; int num4 = fields.FindField(pointTableFieldName); if (num4 >= 0) { string name = featureLayer.Name; ISpatialFilter spatialFilter = new SpatialFilter(); IFeatureClass featureClass = featureLayer.FeatureClass; if (_isGeometrySet) { if (this.m_ipGeo != null) { spatialFilter.Geometry = (this.m_ipGeo); } spatialFilter.SpatialRel = (esriSpatialRelEnum)(1); } ISelectionSet selectionSet = featureClass.Select(spatialFilter, (esriSelectionType)3, (esriSelectionOption)1, null); ITableSort tableSort = new TableSort(); tableSort.Fields = (pointTableFieldName); tableSort.SelectionSet = (selectionSet); tableSort.Sort(null); ICursor rows = tableSort.Rows; object obj = null; int num5 = 1; IRow row; while ((row = rows.NextRow()) != null) { if (_waitForm.Worker.CancellationPending) { break; } object obj2 = row.Value[num4]; if (obj == null || !this.ColumnEqual(obj, obj2)) { if (obj == null) { obj = obj2; } else { dataTable.Rows.Add(new object[] { name, obj, num5 }); num3 += num5; obj = obj2; num5 = 1; } } else { num5++; } } num3 += num5; num2 += num3; dataTable.Rows.Add(new object[] { name, obj, num5, num3 }); } } object[] array = new object[4]; array.SetValue("合计", 1); array.SetValue(num2, 3); dataTable.Rows.Add(array); } else { if (!dataTable.Columns.Contains("层名")) { dataTable.Columns.Add("层名", typeof(string)); } if (!dataTable.Columns.Contains("规格")) { dataTable.Columns.Add("规格", typeof(string)); } if (!dataTable.Columns.Contains("材质")) { dataTable.Columns.Add("材质", typeof(string)); } if (!dataTable.Columns.Contains("条数")) { dataTable.Columns.Add("条数", typeof(int)); } if (!dataTable.Columns.Contains("长度")) { dataTable.Columns.Add("长度", typeof(double)); } if (!dataTable.Columns.Contains("总条数")) { dataTable.Columns.Add("总条数", typeof(int)); } if (!dataTable.Columns.Contains("总长度")) { dataTable.Columns.Add("总长度", typeof(double)); } int num6 = 0; double num7 = 0.0; foreach (IFeatureLayer featureLayer in _featureLayers) { if (_waitForm.Worker.CancellationPending) { break; } _waitForm.Worker.ReportProgress(i++, "状态: 正在汇总 " + featureLayer.Name + ",请稍候..."); int num8 = 0; double num9 = 0.0; IFields fields2 = featureLayer.FeatureClass.Fields; IBasicLayerInfo layerInfo = pPipeCfg.GetBasicLayerInfo(featureLayer.FeatureClass); string lineTableFieldName = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.GJ); int num4 = fields2.FindField(lineTableFieldName); string lineTableFieldName2 = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.DMCC); // this.pPipeCfg.GetLineTableFieldName("断面尺寸"); int num10 = fields2.FindField(lineTableFieldName2); string lineTableFieldName3 = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.GXCZ); // this.pPipeCfg.GetLineTableFieldName("材质"); int num11 = fields2.FindField(lineTableFieldName3); for (int k = 0; k < fields2.FieldCount; k++) { IField field = fields2.Field[k]; if (field.Type == (esriFieldType)7) { num = k; break; } } if (num4 >= 0 || num10 >= 0) { string name = featureLayer.Name; ISpatialFilter spatialFilter2 = new SpatialFilter(); IFeatureClass featureClass2 = featureLayer.FeatureClass; if (_isGeometrySet) { if (this.m_ipGeo != null) { spatialFilter2.Geometry = (this.m_ipGeo); } spatialFilter2.SpatialRel = (esriSpatialRelEnum)(1); } ISelectionSet selectionSet2 = featureClass2.Select(spatialFilter2, (esriSelectionType)3, (esriSelectionOption)1, null); ITableSort tableSort2 = new TableSort(); tableSort2.Fields = (string.Concat(new string[] { lineTableFieldName, ",", lineTableFieldName2, ",", lineTableFieldName3 })); tableSort2.SelectionSet = (selectionSet2); tableSort2.Sort(null); ICursor rows2 = tableSort2.Rows; object obj3 = null; object obj4 = null; int num12 = 1; IRow row2; double num13 = 0.0; while ((row2 = rows2.NextRow()) != null) { if (_waitForm.Worker.CancellationPending) { break; } object obj5 = row2.Value[num4]; if (obj5 is DBNull || obj5.ToString() == "0") { obj5 = row2.Value[num10]; } object obj6 = row2.Value[num11]; if (row2.Value[num] is DBNull) { continue; } IPolyline polyline = (IPolyline)row2.Value[num]; IPointCollection pointCollection = (IPointCollection)polyline; double num14 = 0.0; for (int l = 0; l < pointCollection.PointCount - 1; l++) { IPoint point = pointCollection.Point[l]; IPoint point2 = pointCollection.Point[l + 1]; num14 += Math.Sqrt(Math.Pow(point.X - point2.X, 2.0) + Math.Pow(point.Y - point2.Y, 2.0) + Math.Pow(point.Z - point.M - point2.Z + point2.M, 2.0)); } if (obj3 == null || !this.ColumnEqual(obj3, obj5)) { if (obj3 == null) { obj3 = obj5; num13 += num14; } else { num13 = Math.Round(num13, 3); dataTable.Rows.Add(new object[] { name, obj3, obj4, num12, num13 }); num8 += num12; num9 += num13; obj3 = obj5; obj4 = null; num13 = num14; num12 = 1; } } else if (obj4 == null || !this.ColumnEqual(obj4, obj6)) { if (obj4 == null) { obj4 = obj6; num13 += num14; num12++; } else { num13 = Math.Round(num13, 3); dataTable.Rows.Add(new object[] { name, obj3, obj4, num12, num13 }); num8 += num12; num9 += num13; num13 = num14; obj4 = obj6; num12 = 1; } } else { num13 += num14; num12++; } } num8 += num12; num9 += num13; num6 += num8; num7 += num9; num13 = Math.Round(num13, 3); num9 = Math.Round(num9, 3); dataTable.Rows.Add(new object[] { name, obj3, obj4, num12, num13, num8, num9 }); } } num7 = Math.Round(num7, 3); object[] array2 = new object[7]; array2.SetValue("合计", 1); array2.SetValue(num6, 5); array2.SetValue(num7, 6); dataTable.Rows.Add(array2); } e.Result = dataTable; } catch (Exception) { throw; } }
private bool MakeData() { Splash.Status = "状态:创建临时表,请稍候..."; this.pDataSet = new DataSet("总表"); this.stable = new DataTable("属性表"); this.Geotable = new DataTable("空间"); this.cmbStatField.Items.Clear(); bool result; if (this._cursor == null) { result = false; return(result); } IFeature feature = this._cursor.NextFeature(); layerInfo = _plugin.PipeConfig.GetBasicLayerInfo(feature.Class as IFeatureClass); IFields fields = this._cursor.Fields; int num = 0; this.OidField = 0; this.stable.Columns.Add("OID", typeof(string)); for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.get_Field(i); string name = field.Name; if (field.Type == esriFieldType.esriFieldTypeGeometry) { num = i; } if (field.Type == esriFieldType.esriFieldTypeOID) { this.OidField = i; } else { //Regex regex = new Regex("^[\\u4e00-\\u9fa5]+$"); //if (regex.IsMatch(field.Name)) //{ // if (field.Type == (esriFieldType)3 || field.Type == (esriFieldType)1 || field.Type == (esriFieldType)2 || field.Type == 0) // { // this.cmbCalField.Items.Add(field.Name); // } // this.cmbStatField.Items.Add(fields.get_Field(i).Name); //} if (field.Type == esriFieldType.esriFieldTypeDouble || field.Type == esriFieldType.esriFieldTypeSingle || field.Type == esriFieldType.esriFieldTypeInteger || field.Type == esriFieldType.esriFieldTypeSmallInteger) { this.cmbCalField.Items.Add(field.Name); } this.cmbStatField.Items.Add(field.Name); if (!this.stable.Columns.Contains(fields.get_Field(i).Name)) { IYTField pField = layerInfo.Fields.FirstOrDefault(c => c.Name == field.Name); DataColumn dataColumn; switch (field.Type) { case esriFieldType.esriFieldTypeInteger: dataColumn = this.stable.Columns.Add(name, typeof(int)); break; case esriFieldType.esriFieldTypeSingle: dataColumn = this.stable.Columns.Add(name, typeof(float)); break; case esriFieldType.esriFieldTypeDouble: dataColumn = this.stable.Columns.Add(name, typeof(double)); break; case esriFieldType.esriFieldTypeOID: dataColumn = this.stable.Columns.Add(name, typeof(string)); break; default: dataColumn = this.stable.Columns.Add(name, typeof(string)); break; } if (pField != null) { dataColumn.Caption = pField.AliasName; } } } } if (this.cmbCalField.Items.Count > 0) { this.cmbCalField.SelectedIndex = 0; } bool flag = false; if (feature == null) { result = false; return(result); } bool isNUsing = false; IMAware mAware = feature.Shape as IMAware; isNUsing = mAware.MAware; if (feature.FeatureType == esriFeatureType.esriFTComplexEdge || feature.FeatureType == esriFeatureType.esriFTSimpleEdge) { this.cmbStatWay.Items.Add("统计长度"); if (!this.stable.Columns.Contains("GD管线长度")) { this.stable.Columns.Add("GD管线长度", typeof(double)); } flag = true; this.nGeoType = 1; } else if (feature.FeatureType == esriFeatureType.esriFTSimpleJunction || feature.FeatureType == esriFeatureType.esriFTComplexJunction) { this.nGeoType = 0; } else if (feature.FeatureType == esriFeatureType.esriFTSimple) { if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { this.nGeoType = 0; } if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPath || feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { this.nGeoType = 3; } if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { this.nGeoType = 2; } if (feature.Shape.GeometryType == esriGeometryType.esriGeometryNull) { this.nGeoType = -1; } } if (feature.FeatureType == esriFeatureType.esriFTAnnotation) { this.nGeoType = 4; } if (this.nGeoType == -1) { result = false; } else { if (this.nGeoType > 0) { if (!this.Geotable.Columns.Contains("LINECODE")) { this.Geotable.Columns.Add("LINECODE", typeof(string)); } if (!this.Geotable.Columns.Contains("序号")) { this.Geotable.Columns.Add("序号", typeof(int)); } if (!this.Geotable.Columns.Contains("X")) { this.Geotable.Columns.Add("X", typeof(double)); } if (!this.Geotable.Columns.Contains("Y")) { this.Geotable.Columns.Add("Y", typeof(double)); } if (!this.Geotable.Columns.Contains("Z")) { this.Geotable.Columns.Add("Z", typeof(double)); } if (!this.Geotable.Columns.Contains("M")) { this.Geotable.Columns.Add("M", typeof(double)); } } else { if (!this.Geotable.Columns.Contains("PONTCODE")) { this.Geotable.Columns.Add("PONTCODE", typeof(string)); } if (!this.Geotable.Columns.Contains("X")) { this.Geotable.Columns.Add("X", typeof(double)); } if (!this.Geotable.Columns.Contains("Y")) { this.Geotable.Columns.Add("Y", typeof(double)); } if (!this.Geotable.Columns.Contains("Z")) { this.Geotable.Columns.Add("Z", typeof(double)); } } object[] array; object[] array2; if (this.nGeoType > 0) { if (this.nGeoType == 1) { array = new object[fields.FieldCount + 1]; } else { array = new object[fields.FieldCount]; } array2 = new object[6]; } else { array = new object[fields.FieldCount]; array2 = new object[4]; } string text = feature.FeatureType.ToString(); this._selection.Clear(); Splash.Status = "状态:填充表单,请稍候..."; int qdgcIdx = -1; int qdmsIdx = -1; int zdgcIdx = -1; int zdmsIdx = -1; if (layerInfo.DataType == enumPipelineDataType.Line) { qdgcIdx = feature.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDGC)); qdmsIdx = feature.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDMS)); zdgcIdx = feature.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDGC)); zdmsIdx = feature.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDMS)); } while (feature != null) { double num2 = 0.0; string text2 = feature.get_Value(this.OidField).ToString(); if (feature.Shape == null || feature.Shape.IsEmpty) { feature = this._cursor.NextFeature(); } else { int j; for (j = 0; j < fields.FieldCount; j++) { if (j == this.OidField) { array[0] = text2; } if (j == num) { if (num > this.OidField) { array[j] = text; } else { array[j + 1] = text; } if (this.nGeoType == 1 || this.nGeoType == 3) { IPolyline polyline = (IPolyline)feature.Shape; IPointCollection pointCollection = (IPointCollection)polyline; IPoint point = null; IPoint point2 = null; if (isNUsing) { for (int k = 0; k < pointCollection.PointCount - 1; k++) { point = pointCollection.get_Point(k); array2[0] = text2; array2[1] = k + 1; array2[2] = point.X; array2[3] = point.Y; if (this.nGeoType == 3) { array2[4] = point.Z; array2[5] = 0; } else { array2[4] = ((float)(point.Z - point.M)).ToString("f3"); array2[5] = point.M.ToString("f3"); } this.Geotable.Rows.Add(array2); point2 = pointCollection.get_Point(k + 1); num2 += Math.Sqrt(Math.Pow(point.X - point2.X, 2.0) + Math.Pow(point.Y - point2.Y, 2.0) + Math.Pow(point.Z - point.M - point2.Z + point2.M, 2.0)); } array2[0] = text2; array2[1] = pointCollection.PointCount; array2[2] = point2.X; array2[3] = point2.Y; if (this.nGeoType == 3) { array2[4] = point2.Z; array2[5] = 0; } else { array2[4] = ((float)(point.Z - point.M)).ToString("f3"); array2[5] = point2.M.ToString("f3"); } this.Geotable.Rows.Add(array2); } else { point = pointCollection.get_Point(0); point2 = pointCollection.get_Point(pointCollection.PointCount - 1); array2[0] = text2; array2[1] = 1; array2[2] = point.X; array2[3] = point.Y; double height; array2[4] = qdgcIdx >= 0 ? GetDoubleValue(feature, qdgcIdx, out height) : 0; array2[5] = qdmsIdx >= 0 ? GetDoubleValue(feature, qdmsIdx, out height) : 0; this.Geotable.Rows.Add(array2); array2[0] = text2; array2[1] = 2; array2[2] = point2.X; array2[3] = point2.Y; array2[4] = zdgcIdx >= 0 ? GetDoubleValue(feature, zdgcIdx, out height) : 0; array2[5] = zdmsIdx >= 0 ? GetDoubleValue(feature, zdmsIdx, out height) : 0; this.Geotable.Rows.Add(array2); } } else if (this.nGeoType == 0) { IPoint point3 = (IPoint)feature.Shape; array2[0] = text2; array2[1] = point3.X; array2[2] = point3.Y; array2[3] = point3.Z; this.Geotable.Rows.Add(array2); } else if (this.nGeoType == 2 || this.nGeoType == 4) { IPolygon polygon = (IPolygon)feature.Shape; IPointCollection pointCollection2 = (IPointCollection)polygon; IPoint point4 = null; if (isNUsing) { for (int l = 0; l < pointCollection2.PointCount - 1; l++) { IPoint point5 = pointCollection2.get_Point(l); array2[0] = text2; array2[1] = l + 1; array2[2] = point5.X; array2[3] = point5.Y; array2[4] = point5.Z; array2[5] = point5.M; this.Geotable.Rows.Add(array2); point4 = pointCollection2.get_Point(l + 1); num2 += Math.Sqrt(Math.Pow(point5.X - point4.X, 2.0) + Math.Pow(point5.Y - point4.Y, 2.0) + Math.Pow(point5.Z - point5.M - point4.Z + point4.M, 2.0)); } array2[0] = text2; array2[1] = pointCollection2.PointCount; array2[2] = point4.X; array2[3] = point4.Y; array2[4] = point4.Z; array2[5] = point4.M; this.Geotable.Rows.Add(array2); } else { IPoint point = pointCollection2.get_Point(0); IPoint point2 = pointCollection2.get_Point(pointCollection2.PointCount - 1); array2[0] = text2; array2[1] = 1; array2[2] = point.X; array2[3] = point.Y; double height; array2[4] = qdgcIdx >= 0 ? GetDoubleValue(feature, qdgcIdx, out height) : 0; array2[5] = qdmsIdx >= 0 ? GetDoubleValue(feature, qdmsIdx, out height) : 0; this.Geotable.Rows.Add(array2); array2[0] = text2; array2[1] = 2; array2[2] = point2.X; array2[3] = point2.Y; array2[4] = zdgcIdx >= 0 ? GetDoubleValue(feature, zdgcIdx, out height) : 0; array2[5] = zdmsIdx >= 0 ? GetDoubleValue(feature, zdmsIdx, out height) : 0; this.Geotable.Rows.Add(array2); } } } else { IField field2 = feature.Fields.get_Field(j); object obj = feature.get_Value(j); if (j < this.OidField) { if (field2.Type == esriFieldType.esriFieldTypeDouble || field2.Type == esriFieldType.esriFieldTypeSingle) { if (obj != DBNull.Value) { array[j + 1] = Math.Round(Convert.ToDouble(obj), 3); } else { array[j + 1] = obj; } feature.get_Value(j).ToString(); } else if (field2.Type == esriFieldType.esriFieldTypeDate) { if (obj != DBNull.Value) { DateTime dateTime = Convert.ToDateTime(obj); array[j + 1] = dateTime.ToShortDateString(); } else { array[j + 1] = ""; } } else { array[j + 1] = obj; } } else if (field2.Type == esriFieldType.esriFieldTypeDouble || field2.Type == esriFieldType.esriFieldTypeSingle) { if (obj != DBNull.Value) { array[j] = Math.Round(Convert.ToDouble(obj), 3); } else { array[j] = obj; } } else if (field2.Type == esriFieldType.esriFieldTypeDate) { if (obj != DBNull.Value) { array[j] = Convert.ToDateTime(obj).ToShortDateString(); } else { array[j] = ""; } } else { array[j] = obj; } } } if (flag) { array[j] = num2.ToString(); } this.stable.Rows.Add(array); this._selection.Add(feature); feature = this._cursor.NextFeature(); } } int count = this._selection.SelectionSet.Count; //this.CountBox.Text = "查询的记录数为:" + count.ToString(); this._selection.SelectionSet.Refresh(); IActiveView activeView = _context.ActiveView; activeView.Refresh(); result = true; } return(result); }