private void InsertFeatures(EditParameters parameter) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } if (parameter == null) { return; } System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = parameter.geometryMap; if (geometryMap != null) { CommandManagerServices.Instance().StartCommand(); FDECommand fDECommand = new FDECommand(true, true); SelectCollection.Instance().Clear(); foreach (DF3DFeatureClass current in geometryMap.Keys) { IFeatureClass featureClass = current.GetFeatureClass(); IRowBufferCollection rowBufferCollection = geometryMap[current]; CommonUtils.Instance().FdeUndoRedoManager.InsertFeatures(featureClass, rowBufferCollection); CommonUtils.Instance().Insert(current, rowBufferCollection, true, false); app.Current3DMapControl.FeatureManager.CreateFeatures(featureClass, rowBufferCollection); } fDECommand.SetSelectionMap(); CommandManagerServices.Instance().CallCommand(fDECommand); app.Workbench.UpdateMenu(); } }
public void StopEdit(bool bSave) { if (this._app == null || this._app.Current3DMapControl == null) { return; } try { if (this._isSpatialQuery) { if (!bSave) { this._geoEditor.CancelEdit(); } else { this._geoEditor.FinishEdit(); } if (this.spatialQueryEditStopEvent != null) { this.spatialQueryEditStopEvent(bSave); } this._isSpatialQuery = false; this._app.Current3DMapControl.InteractMode = this._InteractaMode; } else { if (this._FeatureClass != null && this._row != null) { if (!bSave) { this._geoEditor.CancelEdit(); if (this._renderGeometry != null) { this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } this._app.Current3DMapControl.InteractMode = this._InteractaMode; } else { if (this._geoEditor.IsEditing && bSave) { this._geoEditor.FinishEdit(); } Gvitech.CityMaker.FdeCore.IFeatureClass featureClass = this._FeatureClass.GetFeatureClass(); int position = this._row.FieldIndex(this._FeatureClass.GetFeatureLayer().GeometryFieldName); IGeometry geometry = this._row.GetValue(position) as IGeometry; if (this._geoEditType == gviGeoEditType.gviGeoEditCreator) { ITopologicalOperator2D topologicalOperator2D = geometry as ITopologicalOperator2D; if (topologicalOperator2D == null || !topologicalOperator2D.IsSimple2D()) { XtraMessageBox.Show("创建的对象无效!"); this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } else { CommandManagerServices.Instance().StartCommand(); FDECommand fDECommand = new FDECommand(true, true); SelectCollection.Instance().Clear(); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); rowBufferCollection.Add(this._row); CommonUtils.Instance().FdeUndoRedoManager.InsertFeatures(featureClass, rowBufferCollection); CommonUtils.Instance().Insert(this._FeatureClass, rowBufferCollection, true, true); this._app.Current3DMapControl.FeatureManager.CreateFeature(featureClass, this._row); this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); fDECommand.SetSelectionMap(); CommandManagerServices.Instance().CallCommand(fDECommand); this._app.Workbench.UpdateMenu(); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } } else { CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); CommonUtils.Instance().FdeUndoRedoManager.UpdateFeature(featureClass, this._row); CommandManagerServices.Instance().CallCommand(cmd); this._app.Workbench.UpdateMenu(); } if (this._row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(this._row); this._row = null; } this._app.Current3DMapControl.InteractMode = this._InteractaMode; } } } } catch (System.Runtime.InteropServices.COMException ex) { XtraMessageBox.Show(ex.Message); } catch (System.UnauthorizedAccessException) { XtraMessageBox.Show("拒绝访问"); } catch (System.Exception ex2) { XtraMessageBox.Show(ex2.Message); } }
private void InsertFeatures(object param) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } EditParameters editParameters = (EditParameters)param; if (editParameters == null) { return; } System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = editParameters.geometryMap; if (geometryMap != null) { CommandManagerServices.Instance().StartCommand(); FDECommand fDECommand = new FDECommand(true, true); int nTotalCount = editParameters.nTotalCount; int num = 0; //System.IAsyncResult asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._clearSelection); //MainFrmService.ResultSetPanel.EndInvoke(asyncResult); foreach (DF3DFeatureClass current in geometryMap.Keys) { if (this._bgWorker.CancellationPending) { break; } IFeatureClass featureClass = current.GetFeatureClass(); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); IRowBufferCollection rowBufferCollection2 = geometryMap[current]; int num2 = 0; while (num2 < rowBufferCollection2.Count && !this._bgWorker.CancellationPending) { this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); IRowBuffer value = rowBufferCollection2.Get(num2); rowBufferCollection.Add(value); num++; string userState = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount); int percentProgress = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress, userState); num2++; } if (rowBufferCollection.Count > 0) { CommonUtils.Instance().FdeUndoRedoManager.InsertFeatures(featureClass, rowBufferCollection); //object[] args = new object[] //{ // current, // rowBufferCollection2, // true, // false //}; //asyncResult = MainFrmService.ResultSetPanel.BeginInvoke(this._InsertSelection, args); //MainFrmService.ResultSetPanel.EndInvoke(asyncResult); rowBufferCollection.Clear(); } } fDECommand.SetSelectionMap(); CommandManagerServices.Instance().CallCommand(fDECommand); app.Workbench.UpdateMenu(); } }