private void listBoxResults_DoubleClick(object sender, EventArgs e) { try { string strKeyword = listBoxResults.SelectedItem.ToString();//选中的结果项目 if (strKeyword != "") { IFeature pFeature; //下面两个变量是用来把指定的元素变成选中状态的设置的,以后可以用这个方法 IFeatureSelection pFeatureSelection = (GetLayerByName(comboBoxLayers.Text) as IFeatureLayer) as IFeatureSelection; pFeatureSelection.Clear();//底下那个oid的方法是在搞不定,只有用这个方法达到目的了 ISelectionSet pSelectionSet = pFeatureSelection.SelectionSet; IEnvelope pEnvelope = new EnvelopeClass(); pFeature = FeatureCursor.NextFeature();//这个featurecursor是全局变量,也就是第一步查找的结果 int index = (GetLayerByName(comboBoxLayers.Text) as IFeatureLayer).FeatureClass.Fields.FindField(comboBoxField.Text); //int oid=0;//如果用户在没有关闭查找窗口的情况下对结果列表做了多次双击,则每次双击都要清除上一次双击背选中的元素 while (pFeature != null) { if (pFeature.get_Value(index).ToString() == strKeyword) { //if (oid != 0) // pSelectionSet.RemoveList(1, ref oid); pSelectionSet.Add(pFeature.OID); //把这个feature加到当前选择集中 //oid = pFeature.OID; if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint || pFeature.Shape.GeometryType == esriGeometryType.esriGeometryMultipoint) { //如果双击的对象是一个点,这样子才能够缩放到该点 pEnvelope.PutCoords(0, 0, 0.3, 0.3);//确定envelope大小 IPoint pPoint = pFeature.Shape as IPoint; pEnvelope.CenterAt(pPoint); } else { pEnvelope = pFeature.Extent; } break; } pFeature = FeatureCursor.NextFeature(); } MainAxMapControl.Extent = pEnvelope; MainAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); } } catch (Exception ex) { MessageBox.Show("缩放到指定元素出错! | " + ex.Message); return; } }
public void SortForVerAnalyseFun(ILayer pLayer) { if (pLayer is IFeatureLayer) { IFeatureLayer featureLayer = pLayer as IFeatureLayer; string aliasName = featureLayer.FeatureClass.AliasName; if (aliasName == this.LayerName) { IFeatureSelection featureSelection = (IFeatureSelection)pLayer; ISelectionSet selectionSet = featureSelection.SelectionSet; selectionSet.IDs.Reset(); for (int i = 0; i < this.Count; i++) { SortInfo sortInfo = (SortInfo)this.m_arrSortInfo[i]; selectionSet.Add(sortInfo.SmID); } } } }
private void method_1(ILayer layer) { if (layer is IFeatureLayer) { IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer.FeatureClass != null) { string aliasName = featureLayer.FeatureClass.AliasName; if (aliasName == this.LayerName) { IFeatureSelection featureSelection = (IFeatureSelection)layer; ISelectionSet selectionSet = featureSelection.SelectionSet; selectionSet.IDs.Reset(); for (int i = 0; i < this.Count; i++) { selectionSet.Add((int)this.arrayList_0[i]); } } } } }
private void btnPipeLineQuery_Click(object sender, EventArgs e) { if (this.cmbPipeLineFields.Text == "") { MessageBox.Show(@"请选择管线层查询字段!"); } else if (this.lstBoxPipeLineValues.Text == "") { MessageBox.Show(@"请指定管线层查询值!"); } else if (this.lstBoxPipeLineValues.Text == "") { MessageBox.Show(@"请指定管点层查询值!"); } else { Splash.Show(); Splash.Status = "状态:关联查询中,请稍候..."; this.Walk(); RelateQueryUI.LayerboxItem layerboxItem = this.cmbPipeLine.SelectedItem as RelateQueryUI.LayerboxItem; IFeatureLayer pPipeLayer = layerboxItem.m_pPipeLayer; IFeatureSelection featureSelection = (IFeatureSelection)pPipeLayer; featureSelection.Clear(); ISelectionSet selectionSet = featureSelection.SelectionSet; selectionSet.IDs.Reset(); int count = this.m_alPipeLine.Count; for (int i = 0; i < count; i++) { IFeature feature = this.m_alPipeLine[i] as IFeature; selectionSet.Add(feature.OID); } IQueryFilter queryFilter = new QueryFilter(); ICursor cursor; selectionSet.Search(queryFilter, false, out cursor); IFeatureCursor pFeatureCursor = cursor as IFeatureCursor; Splash.Close(); _plugin.FireQueryResultChanged(new QueryResultArgs(pFeatureCursor, featureSelection, queryFilter as ISpatialFilter)); } }