void axRenderControl1_RcMouseClickSelect_CreateFeature(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { _geoEditor.FinishEdit(); //用于当拾取到基准面时,或者没有正常右键结束连续调用Start时 this.axRenderControl1.FeatureManager.UnhighlightAll(); if (PickResult != null) { switch (PickResult.Type) { case gviObjectType.gviObjectFeatureLayer: { IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult; int fid = flpr.FeatureId; //加载多FeatureClass时要每次重新获取 _featureClass = (IFeatureClass)fcGUIDMap[flpr.FeatureLayer.FeatureClassId]; _featureLayer = flpr.FeatureLayer; IFdeCursor cursor = null; try { _buffer = _featureClass.CreateRowBuffer(); IQueryFilter filter = new QueryFilter(); //filter.AddSubField("oid"); //注意:StartEditFeatureGeometry里必须传入一个完整的rowbuffer,所以这里不能限定字段 filter.WhereClause = "oid =" + fid; cursor = _featureClass.Search(filter, false); IRowBuffer row = null; if ((row = cursor.NextRow()) != null) { _buffer = row as IRowBuffer; int pos = _buffer.FieldIndex("Geometry"); oldfdeGeometry = _buffer.GetValue(pos) as IGeometry; _buffer.SetValue(0, _featureClass.GetCount(null)); //修改fid为不同值,否则不是创建而是编辑 } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { } this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow); resultCode = _geoEditor.StartEditFeatureGeometry(_buffer, _featureLayer, gviGeoEditType.gviGeoEditCreator); if (!resultCode) { MessageBox.Show(this.axRenderControl1.GetLastError().ToString()); } } break; } } }
void EditGeometry() { _geoEditor.FinishEdit(); //用于当拾取到基准面时,或者没有正常右键结束连续调用Start时 if (_buffer != null && _featureLayer != null) { if (this.toolStripComboBoxEdit.SelectedIndex == 1) { resultCode = _geoEditor.StartEditFeatureGeometry(_buffer, _featureLayer, gviGeoEditType.gviGeoEdit3DMove); } else if (this.toolStripComboBoxEdit.SelectedIndex == 2) { resultCode = _geoEditor.StartEditFeatureGeometry(_buffer, _featureLayer, gviGeoEditType.gviGeoEdit3DRotate); } else if (this.toolStripComboBoxEdit.SelectedIndex == 3) { resultCode = _geoEditor.StartEditFeatureGeometry(_buffer, _featureLayer, gviGeoEditType.gviGeoEdit3DScale); } else if (this.toolStripComboBoxEdit.SelectedIndex == 4) { resultCode = _geoEditor.StartEditFeatureGeometry(_buffer, _featureLayer, gviGeoEditType.gviGeoEditVertex); } else if (this.toolStripComboBoxEdit.SelectedIndex == 5) { resultCode = _geoEditor.StartEditFeatureGeometry(_buffer, _featureLayer, gviGeoEditType.gviGeoEditZRotate); } else if (this.toolStripComboBoxEdit.SelectedIndex == 6) { resultCode = _geoEditor.StartEditFeatureGeometry(_buffer, _featureLayer, gviGeoEditType.gviGeoEditZScale); } if (!resultCode) { MessageBox.Show(this.axRenderControl1.GetLastError().ToString()); } } }