private void ExecuteUndoRedo(IUndoRedoResultCollection Coll) { if (Coll != null) { int count = Coll.Count; if (count == 0) { return; } if (app == null || app.Current3DMapControl == null) { return; } app.Current3DMapControl.PauseRendering(false); for (int i = 0; i < count; i++) { IUndoRedoResult undoRedoResult = Coll[i]; if (undoRedoResult != null) { IObjectClass objectClass = undoRedoResult.ObjectClass; IRowBufferCollection rowBuffers = undoRedoResult.RowBuffers; DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(objectClass.GuidString); switch (undoRedoResult.Type) { case gviCommandType.gviCommandInsert: { CommonUtils.Instance().Insert(featureClassInfo, rowBuffers, false, true); app.Current3DMapControl.FeatureManager.CreateFeatures(objectClass as IFeatureClass, rowBuffers); break; } case gviCommandType.gviCommandDelete: { int[] fidArray = undoRedoResult.FidArray; app.Current3DMapControl.FeatureManager.DeleteFeatures(objectClass as IFeatureClass, fidArray); CommonUtils.Instance().Delete(featureClassInfo, fidArray); break; } case gviCommandType.gviCommandUpdate: { CommonUtils.Instance().Update(featureClassInfo, rowBuffers); app.Current3DMapControl.FeatureManager.EditFeatures(objectClass as IFeatureClass, rowBuffers); break; } } if (rowBuffers != null) { rowBuffers.Clear(); System.Runtime.InteropServices.Marshal.ReleaseComObject(rowBuffers); } System.Runtime.InteropServices.Marshal.ReleaseComObject(objectClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(undoRedoResult); } } System.Runtime.InteropServices.Marshal.ReleaseComObject(Coll); RenderControlEditServices.Instance().SetEditorPosition(SelectCollection.Instance().FcRowBuffersMap); app.Current3DMapControl.ResumeRendering(); } }
private void StartEditFeatures() { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } if (this.beforeRowBufferMap == null) { return; } if (app.Current3DMapControl.ObjectEditor.IsEditing) { app.Current3DMapControl.ObjectEditor.FinishEdit(); } foreach (DF3DFeatureClass featureClassInfo in this.beforeRowBufferMap.Keys) { IRowBufferCollection rowBufferCollection = this.beforeRowBufferMap[featureClassInfo] as IRowBufferCollection; if (rowBufferCollection != null && rowBufferCollection.Count >= 1) { IFeatureLayer featureLayer = featureClassInfo.GetFeatureLayer(); app.Current3DMapControl.ObjectEditor.AddMovingFeatures(featureLayer, rowBufferCollection); } } app.Current3DMapControl.ObjectEditor.StartMoveFeatures(CommonUtils.Instance().CurEditDatasetWkt); }
public void InsertFeatures(IObjectClass oc, IRowBufferCollection rows) { if (oc == null || rows == null || rows.Count == 0) { return; } IFdeCursor cursor = null; try { oc.FeatureDataSet.DataSource.StartEditing(); cursor = oc.Insert(); for (int i = 0; i < rows.Count; ++i) { IRowBuffer row = rows.Get(i); cursor.InsertRow(row); int oid = cursor.LastInsertId; row.SetValue(0, oid); } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (cursor != null) { //Marshal.ReleaseComObject(cursor); oc.FeatureDataSet.DataSource.StopEditing(true); } //Marshal.ReleaseComObject(cursor); } }
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(); } }
private void StartEditFeatures() { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } if (this.beforeRowBufferMap == null) { return; } if (app.Current3DMapControl.ObjectEditor.IsEditing) { app.Current3DMapControl.ObjectEditor.FinishEdit(); } foreach (DF3DFeatureClass featureClassInfo in this.beforeRowBufferMap.Keys) { IRowBufferCollection rowBufferCollection = this.beforeRowBufferMap[featureClassInfo] as IRowBufferCollection; if (rowBufferCollection != null && rowBufferCollection.Count == 1) { IFeatureLayer featureLayer = featureClassInfo.GetFeatureLayer(); app.Current3DMapControl.ObjectEditor.StartEditFeatureGeometry(rowBufferCollection.Get(0), featureLayer, gviGeoEditType.gviGeoEditVertex); } } }
private void InsertFeatures(object param) { EditParameters editParameters = (EditParameters)param; if (editParameters == null) { return; } System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = editParameters.geometryMap; if (geometryMap != null) { IDataSource dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSourceByString(editParameters.connectionInfo); IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(editParameters.datasetName); 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 = featureDataSet.OpenFeatureClass(current.GetFeatureClass().Name); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); IRowBufferCollection rowBufferCollection2 = geometryMap[current]; int num2 = 0; while (num2 < rowBufferCollection2.Count && !this._bgWorker.CancellationPending) { this._manualResult.WaitOne(); 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); } //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet); System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource); } }
private System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> ToDictionary() { System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> dictionary = new System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection>(); foreach (DF3DFeatureClass key in this.beforeRowBufferMap.Keys) { IRowBufferCollection value = this.beforeRowBufferMap[key] as IRowBufferCollection; dictionary[key] = value; } return(dictionary); }
private void CmdProperty_PropertyTableSelectionChangedEvent(DataRow dr) { try { if (regexDataList != null) { regexDataList.Clear(); } colName = ""; fids = null; if (dr == null) { return; } colName = (dr["F"] as IFieldInfo).Name; DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc == null) { return; } HashMap hm = SelectCollection.Instance().GetSelectGeometrys(); if (hm != null && hm.Count == 1) { IRowBufferCollection rowBufferCollection = hm[dffc] as IRowBufferCollection; if (rowBufferCollection != null) { List <int> listFids = SelectCollection.Instance().GetOIDList(rowBufferCollection); if (listFids != null) { fids = listFids.ToArray <int>(); if (dr["FV"] == null) { regexDataList = null; } { if (regexDataList == null) { regexDataList = new List <RegexDataStruct>(); } RegexDataStruct rds = new RegexDataStruct(dr["FV"].ToString(), CharactorType.ConstKey); regexDataList.Add(rds); } UpdateDatabase(); } } } } catch (Exception ex) { } }
private void AsyncExecuteUndoRedo(IUndoRedoResultCollection Coll) { if (Coll != null) { int count = Coll.Count; if (count == 0) { return; } for (int i = 0; i < count; i++) { IUndoRedoResult undoRedoResult = Coll[i]; if (undoRedoResult != null) { IObjectClass objectClass = undoRedoResult.ObjectClass; IRowBufferCollection rowBuffers = undoRedoResult.RowBuffers; switch (undoRedoResult.Type) { case gviCommandType.gviCommandInsert: { this.InsertSelection(objectClass, rowBuffers); break; } case gviCommandType.gviCommandDelete: { int[] fidArray = undoRedoResult.FidArray; this.DeleteSelection(objectClass, fidArray); break; } case gviCommandType.gviCommandUpdate: { this.UpdateSelection(objectClass, rowBuffers); break; } } if (rowBuffers != null) { rowBuffers.Clear(); System.Runtime.InteropServices.Marshal.ReleaseComObject(rowBuffers); } System.Runtime.InteropServices.Marshal.ReleaseComObject(objectClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(undoRedoResult); } } System.Runtime.InteropServices.Marshal.ReleaseComObject(Coll); } }
private System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> GetRowBuffers() { System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> dictionary = new System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection>(); HashMap selectGeometrys = SelectCollection.Instance().GetSelectGeometrys(); if (selectGeometrys == null) { return(dictionary); } foreach (DF3DFeatureClass key in selectGeometrys.Keys) { IRowBufferCollection value = selectGeometrys[key] as IRowBufferCollection; dictionary.Add(key, value); } return(dictionary); }
private void SetGeometry(IGeometry geo) { if (geo == null) { return; } if (this.beforeRowBufferMap != null) { foreach (DF3DFeatureClass featureClassInfo in this.beforeRowBufferMap.Keys) { string facName = featureClassInfo.GetFacilityClassName(); IRowBufferCollection rowBufferCollection = this.beforeRowBufferMap[featureClassInfo] as IRowBufferCollection; object arg_51_0 = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo]; for (int i = 0; i < rowBufferCollection.Count; i++) { IRowBuffer rowBuffer = rowBufferCollection.Get(i); if (rowBuffer != null) { #region 管线设施 if (facName == "PipeLine" || facName == "PipeBuild" || facName == "PipeBuild1") { int num3 = rowBuffer.FieldIndex("Shape"); if (num3 != -1) { rowBuffer.SetValue(num3, geo); } int num4 = rowBuffer.FieldIndex("FootPrint"); if (num4 != -1) { rowBuffer.SetValue(num4, geo.Clone2(gviVertexAttribute.gviVertexAttributeNone)); } } #endregion else { int num2 = rowBuffer.FieldIndex(featureClassInfo.GetFeatureLayer().GeometryFieldName); if (num2 != -1) { rowBuffer.SetValue(num2, geo); } } } } } } }
private void InitData() { try { this.cbxFacilityStyle.SelectedIndex = -1; this.listStyles.SelectedIndex = -1; DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc == null) { return; } int count = SelectCollection.Instance().GetCount(false); if (count == 1) { HashMap hm = SelectCollection.Instance().GetSelectGeometrys(); if (hm != null && hm.Count == 1) { IRowBufferCollection rowBufferCollection = hm[dffc] as IRowBufferCollection; if (rowBufferCollection.Count == 1) { IRowBuffer rowBuffer = rowBufferCollection.Get(0); int index = rowBuffer.FieldIndex("StyleId"); if (index != -1 && !rowBuffer.IsNull(index)) { string styleId = rowBuffer.GetValue(index).ToString(); for (int i = 0; i < this.cbxFacilityStyle.Properties.Items.Count; i++) { FacStyleClass fsc = this.cbxFacilityStyle.Properties.Items[i] as FacStyleClass; if (fsc.ObjectId == styleId) { this.cbxFacilityStyle.SelectedIndex = i; this.listStyles.SelectedIndex = i; break; } } } } } } } catch (Exception ex) { } }
private void InitData() { try { foreach (DataRow dr in this._dt.Rows) { dr["FV"] = null; } DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc == null) { return; } int count = SelectCollection.Instance().GetCount(false); if (count == 1) { HashMap hm = SelectCollection.Instance().GetSelectGeometrys(); if (hm != null && hm.Count == 1) { IRowBufferCollection rowBufferCollection = hm[dffc] as IRowBufferCollection; if (rowBufferCollection.Count == 1) { IRowBuffer rowBuffer = rowBufferCollection.Get(0); foreach (DataRow dr in this._dt.Rows) { IFieldInfo fi = dr["F"] as IFieldInfo; if (fi == null) { continue; } int index = rowBuffer.FieldIndex(fi.Name); if (index != -1) { dr["FV"] = rowBuffer.GetValue(index); } } } } } this.gridView1.RefreshData(); } catch (Exception ex) { } }
private int GetTotalCount(IUndoRedoResultCollection Coll) { int num = 0; if (Coll != null) { int count = Coll.Count; if (count == 0) { return(num); } for (int i = 0; i < count; i++) { IUndoRedoResult undoRedoResult = Coll[i]; if (undoRedoResult != null) { switch (undoRedoResult.Type) { case gviCommandType.gviCommandInsert: { IRowBufferCollection rowBuffers = undoRedoResult.RowBuffers; num += rowBuffers.Count; break; } case gviCommandType.gviCommandDelete: { int[] fidArray = undoRedoResult.FidArray; num += fidArray.Length; break; } case gviCommandType.gviCommandUpdate: { IRowBufferCollection rowBuffers2 = undoRedoResult.RowBuffers; num += rowBuffers2.Count; break; } } } } } return(num); }
private void UpdateSelection(IObjectClass oc, IRowBufferCollection rows) { //FeatureClassInfo featureClassInfo = WorkSpaceServices.Instance().GetFeatureClassInfo(oc.Name, true); //if (featureClassInfo == null) //{ // return; //} //if (oc.Type == gviDataSetType.gviDataSetFeatureClassTable) //{ // lock (SelectCollection.Instance().FeatureClassInfoMap) // { // ResultSetInfo resultSetInfo = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo] as ResultSetInfo; // if (resultSetInfo != null) // { // DataTable resultSetTable = resultSetInfo.ResultSetTable; // if (rows != null) // { // for (int i = 0; i < rows.Count; i++) // { // this._nCurIndex++; // IRowBuffer newRow = rows.Get(i); // SelectCollection.Instance().UpdateRecord(oc as IFeatureClass, resultSetTable, newRow); // string userState = string.Format(StringParser.Parse("${res:feature_progress_finished}"), this._nCurIndex, this._nTotalCount); // int percentProgress = this._nCurIndex * 100 / this._nTotalCount; // this._bgWorker.ReportProgress(percentProgress, userState); // } // } // object[] args = new object[] // { // featureClassInfo.FeatureLayerGuidString, // resultSetInfo.TotalCount, // resultSetInfo.ResultSetTable.Rows.Count // }; // MainFrmService.MainFrm.Invoke(this._recordsChanged, args); // HashMap hashMap = MainFrmService.MainFrm.Invoke(this._GetRowbufferMap) as HashMap; // MainFrmService.MainFrm.Invoke(this._setEditorPositionHandel, new object[] // { // hashMap // }); // } // } //} }
private void UpdateGeometry(EditParameters parameter) { try { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } if (parameter != null) { System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = parameter.geometryMap; if (geometryMap != null) { CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); foreach (DF3DFeatureClass current in geometryMap.Keys) { IRowBufferCollection rowBufferCollection = geometryMap[current]; IFeatureClass featureClass = current.GetFeatureClass(); if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { int position = featureClass.GetFields().IndexOf(featureClass.FidFieldName); System.Collections.Generic.Dictionary <int, IRowBuffer> dictionary = new System.Collections.Generic.Dictionary <int, IRowBuffer>(); for (int i = 0; i < rowBufferCollection.Count; i++) { IRowBuffer rowBuffer = rowBufferCollection.Get(i); int key = (int)rowBuffer.GetValue(position); dictionary[key] = rowBuffer; } ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(new TemporalFilterClass { IdsFilter = dictionary.Keys.ToArray <int>() }); while (temporalCursor.MoveNext()) { bool flag = false; int currentId = temporalCursor.CurrentId; ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false); TemporalInstance temporalInstance; while ((temporalInstance = temporalInstances.NextInstance()) != null) { if (temporalInstance.StartDatetime == parameter.TemproalTime) { flag = true; temporalInstances.Update(dictionary[currentId]); break; } } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances); if (!flag) { temporalCursor.Insert(parameter.TemproalTime, dictionary[currentId]); } } app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); } else { CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass, rowBufferCollection); } } CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); } } } catch (System.Runtime.InteropServices.COMException ex) { XtraMessageBox.Show(ex.Message); } catch (System.UnauthorizedAccessException) { XtraMessageBox.Show(StringParser.Parse("${res:Dataset_InsufficientPermission}")); } catch (System.Exception e) { LoggingService.Error(e.Message); } }
private void RotatingModel(double AxisX, double AxisY, double AxisZ, double Angle) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } this.bFinished = false; this.modifyRowbufferMap = SelectCollection.Instance().Clone(this.beginRowbufferMap); if (this.modifyRowbufferMap != null) { foreach (DF3DFeatureClass featureClassInfo in this.modifyRowbufferMap.Keys) { IFeatureClass featureClass = featureClassInfo.GetFeatureClass(); string facName = featureClassInfo.GetFacilityClassName(); IRowBufferCollection rowBufferCollection = this.modifyRowbufferMap[featureClassInfo] as IRowBufferCollection; for (int i = 0; i < rowBufferCollection.Count; i++) { IRowBuffer rowBuffer = rowBufferCollection.Get(i); if (rowBuffer != null) { int num = rowBuffer.FieldIndex(featureClassInfo.GetFeatureLayer().GeometryFieldName); if (num != -1) { IGeometry geometry = rowBuffer.GetValue(num) as IGeometry; if (geometry != null) { ITransform transform = geometry as ITransform; if (geometry.HasZ()) { transform.Rotate3D(AxisX, AxisY, AxisZ, this.centerX, this.centerY, this.centerZ, Angle); } else { if (!geometry.HasZ() && AxisZ > 0.0) { transform.Rotate2D(this.centerX, this.centerY, Angle); } } rowBuffer.SetValue(num, transform); } } #region 管线设施 if (facName == "PipeLine" || facName == "PipeNode" || facName == "PipeBuild" || facName == "PipeBuild1") { int num3 = rowBuffer.FieldIndex("Shape"); if (num3 != -1) { IGeometry geometry = rowBuffer.GetValue(num3) as IGeometry; if (geometry != null) { ITransform transform = geometry as ITransform; if (geometry != null && transform != null) { if (geometry.HasZ()) { transform.Rotate3D(AxisX, AxisY, AxisZ, this.centerX, this.centerY, this.centerZ, Angle); } else { transform.Rotate2D(this.centerX, this.centerY, Angle); } rowBuffer.SetValue(num3, transform); } } } int num4 = rowBuffer.FieldIndex("FootPrint"); if (num4 != -1) { IGeometry geometry = rowBuffer.GetValue(num4) as IGeometry; if (geometry != null) { ITransform transform = geometry as ITransform; if (geometry != null && transform != null) { if (geometry.HasZ()) { transform.Rotate3D(AxisX, AxisY, AxisZ, this.centerX, this.centerY, this.centerZ, Angle); } else { transform.Rotate2D(this.centerX, this.centerY, Angle); } rowBuffer.SetValue(num4, transform); } } } } #endregion } } app.Current3DMapControl.FeatureManager.EditFeatures(featureClass, rowBufferCollection); //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } } }
private void CmdEditFacilityStyle_FacStyleClassChangedEvent(DF3DPipeCreateTool.Class.FacStyleClass style) { try { this.beforeRowBufferMap.Clear(); if (style == null) { return; } DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc == null) { return; } IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return; } FacClassReg reg = FacilityInfoService.GetFacClassRegByFeatureClassID(fc.GuidString); if (reg == null) { return; } TopoClass tc = FacilityInfoService.GetTopoClassByFacClassCode(reg.FacClassCode); if (tc == null) { return; } FacilityClass facc = reg.FacilityType; if (facc == null) { return; } IResourceManager manager = fc.FeatureDataSet as IResourceManager; if (manager == null) { return; } IFieldInfoCollection fields = fc.GetFields(); //int indexGroupid = -1; //int indexClassify = -1; //SubClass sc = null; //MajorClass mc = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(fc.GuidString); //if (mc != null) //{ // indexClassify = fields.IndexOf(mc.ClassifyField); // indexGroupid = fields.IndexOf("GroupId"); //} int index = fields.IndexOf("StyleId"); if (index == -1) { return; } int mnindex = fields.IndexOf("ModelName"); int mpindex = fields.IndexOf("Geometry"); if (mpindex == -1) { return; } HashMap hm = SelectCollection.Instance().GetSelectGeometrys(); if (hm != null && hm.Count == 1) { IRowBufferCollection res = new RowBufferCollection(); IRowBufferCollection rowBufferCollection = hm[dffc] as IRowBufferCollection; if (rowBufferCollection != null) { for (int i = 0; i < rowBufferCollection.Count; i++) { IRowBuffer rowBuffer = rowBufferCollection.Get(i); Fac fac = null; IModelPoint mp = null; IModel finemodel = null; IModel simplemodel = null; string name = ""; switch (facc.Name) { case "PipeNode": fac = new PipeNodeFac(reg, style, rowBuffer, tc); break; case "PipeLine": fac = new PipeLineFac(reg, style, rowBuffer, tc, false, false); break; case "PipeBuild": case "PipeBuild1": fac = new PipeBuildFac(reg, style, rowBuffer); break; } if (UCAuto3DCreate.RebuildModel(fac, style, out mp, out finemodel, out simplemodel, out name)) { if (finemodel == null || mp == null) { continue; } mp.ModelEnvelope = finemodel.Envelope; rowBuffer.SetValue(mpindex, mp); rowBuffer.SetValue(index, style.ObjectId); //if (mc != null) //{ // if (indexClassify != -1 && indexGroupid != -1) // { // } //} bool bRes = false; if (!string.IsNullOrEmpty(mp.ModelName)) { if (!manager.ModelExist(mp.ModelName)) { if (manager.AddModel(mp.ModelName, finemodel, simplemodel)) { bRes = true; } } else { if (manager.UpdateModel(mp.ModelName, finemodel) && manager.UpdateSimplifiedModel(mp.ModelName, simplemodel)) { bRes = true; } } } if (bRes) { res.Add(rowBuffer); } } } } beforeRowBufferMap[dffc] = res; //SelectCollection.Instance().Clear(); UpdateDatabase(); DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } app.Current3DMapControl.FeatureManager.RefreshFeatureClass(fc); } } catch (Exception ex) { } }
public void Update(DF3DFeatureClass fcInfo, IRowBufferCollection Rows) { SelectCollection.Instance().UpdateSelection(fcInfo, Rows); }
private void MovingModel(double X, double Y, double Z) { if (this.beforeRowBufferMap != null) { foreach (DF3DFeatureClass featureClassInfo in this.beforeRowBufferMap.Keys) { string facName = featureClassInfo.GetFacilityClassName(); IRowBufferCollection rowBufferCollection = this.beforeRowBufferMap[featureClassInfo] as IRowBufferCollection; object arg_51_0 = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo]; for (int i = 0; i < rowBufferCollection.Count; i++) { IRowBuffer rowBuffer = rowBufferCollection.Get(i); if (rowBuffer != null) { int num = rowBuffer.FieldIndex(featureClassInfo.GetFeatureClass().FidFieldName); if (num != -1) { int arg_87_0 = (int)rowBuffer.GetValue(num); } int num2 = rowBuffer.FieldIndex(featureClassInfo.GetFeatureLayer().GeometryFieldName); if (num2 != -1) { IGeometry geometry = rowBuffer.GetValue(num2) as IGeometry; if (geometry != null) { ITransform transform = geometry as ITransform; if (geometry != null && transform != null) { if (geometry.HasZ()) { transform.Move3D(X, Y, Z); } else { transform.Move2D(X, Y); } rowBuffer.SetValue(num2, transform); } } } #region 管线设施 if (facName == "PipeLine" || facName == "PipeNode" || facName == "PipeBuild" || facName == "PipeBuild1") { int num3 = rowBuffer.FieldIndex("Shape"); if (num3 != -1) { IGeometry geometry = rowBuffer.GetValue(num3) as IGeometry; if (geometry != null) { ITransform transform = geometry as ITransform; if (geometry != null && transform != null) { if (geometry.HasZ()) { transform.Move3D(X, Y, Z); } else { transform.Move2D(X, Y); } rowBuffer.SetValue(num3, transform); } } } int num4 = rowBuffer.FieldIndex("FootPrint"); if (num4 != -1) { IGeometry geometry = rowBuffer.GetValue(num4) as IGeometry; if (geometry != null) { ITransform transform = geometry as ITransform; if (geometry != null && transform != null) { if (geometry.HasZ()) { transform.Move3D(X, Y, Z); } else { transform.Move2D(X, Y); } rowBuffer.SetValue(num4, transform); } } } } #endregion } } } } }
public void Insert(DF3DFeatureClass fcInfo, IRowBufferCollection Rows, bool bClearAll, bool bSetEditorPosition) { SelectCollection.Instance().InsertSelection(fcInfo, Rows, bClearAll, bSetEditorPosition); }
private void ExecuteUndoRedo(IUndoRedoResultCollection Coll) { if (Coll != null) { int nCount = Coll.Count; if (nCount == 0) return; for (int i = 0; i < nCount; ++i) { IUndoRedoResult result = Coll.Get(i) as IUndoRedoResult; if (result == null) continue; IObjectClass oc = result.ObjectClass; IRowBufferCollection Rows = result.RowBuffers; List<int> insert_updata_Ids = new List<int>(); if (Rows != null) { for (int j = 0; j < Rows.Count;j ++ ) { IRowBuffer row = Rows.Get(j); if (row.IsNull(0)) continue; insert_updata_Ids.Add(Convert.ToInt32(row.GetValue(0))); } } gviCommandType type = result.Type; switch (type) { case gviCommandType.gviCommandInsert: //Insert { this.axRenderControl1.FeatureManager.CreateFeatures(oc as IFeatureClass, Rows); this.axRenderControl1.FeatureManager.UnhighlightAll(); this.axRenderControl1.FeatureManager.HighlightFeatures(oc as IFeatureClass, insert_updata_Ids.ToArray(), System.Drawing.Color.Red); } break; case gviCommandType.gviCommandDelete: //Delete { int[] OidArray = result.FidArray; this.axRenderControl1.FeatureManager.DeleteFeatures(oc as IFeatureClass, OidArray); } break; case gviCommandType.gviCommandUpdate: //Update { this.axRenderControl1.FeatureManager.EditFeatures(oc as IFeatureClass, Rows); this.axRenderControl1.FeatureManager.UnhighlightAll(); this.axRenderControl1.FeatureManager.HighlightFeatures(oc as IFeatureClass, insert_updata_Ids.ToArray(), System.Drawing.Color.Red); } break; } if (Rows != null) { Rows.Clear(); //Marshal.ReleaseComObject(Rows); } //Marshal.ReleaseComObject(oc); //Marshal.ReleaseComObject(result); } //Marshal.ReleaseComObject(Coll); } }
private void UpdateGeometry(object param) { try { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } EditParameters editParameters = (EditParameters)param; if (editParameters != null) { System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> geometryMap = editParameters.geometryMap; if (geometryMap != null) { CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); int nTotalCount = editParameters.nTotalCount; int num = 0; foreach (DF3DFeatureClass current in geometryMap.Keys) { if (this._bgWorker.CancellationPending) { break; } IRowBufferCollection rowBufferCollection = geometryMap[current]; if (current.GetFeatureClass().HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { IConnectionInfo connectionInfo = new ConnectionInfoClass(); connectionInfo.FromConnectionString(current.GetFeatureClass().DataSource.ConnectionInfo.ToConnectionString()); IDataSource dataSource = ((IDataSourceFactory) new DataSourceFactoryClass()).OpenDataSource(connectionInfo); IFeatureDataSet featureDataSet = dataSource.OpenFeatureDataset(CommonUtils.Instance().GetCurrentFeatureDataset().Name); IFeatureClass featureClass = featureDataSet.OpenFeatureClass(current.GetFeatureClass().Name); int position = featureClass.GetFields().IndexOf(featureClass.FidFieldName); System.Collections.Generic.Dictionary <int, IRowBuffer> dictionary = new System.Collections.Generic.Dictionary <int, IRowBuffer>(); for (int i = 0; i < rowBufferCollection.Count; i++) { IRowBuffer rowBuffer = rowBufferCollection.Get(i); int key = (int)rowBuffer.GetValue(position); dictionary[key] = rowBuffer; } ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(new TemporalFilterClass { IdsFilter = dictionary.Keys.ToArray <int>() }); while (temporalCursor.MoveNext() && !this._bgWorker.CancellationPending) { this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); num++; string userState = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount); int percentProgress = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress, userState); bool flag = false; int currentId = temporalCursor.CurrentId; ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false); TemporalInstance temporalInstance; while ((temporalInstance = temporalInstances.NextInstance()) != null) { if (temporalInstance.StartDatetime == editParameters.TemproalTime) { flag = true; temporalInstances.Update(dictionary[currentId]); break; } } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances); if (!flag) { temporalCursor.Insert(editParameters.TemproalTime, dictionary[currentId]); } } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureDataSet); System.Runtime.InteropServices.Marshal.ReleaseComObject(dataSource); } else { IFeatureClass featureClass2 = current.GetFeatureClass(); int num2 = 0; while (num2 < rowBufferCollection.Count && !this._bgWorker.CancellationPending) { this._manualResult.WaitOne(); System.Threading.Thread.Sleep(1); num++; string userState2 = string.Format(StringParser.Parse("${res:feature_progress_finished}"), num, nTotalCount); int percentProgress2 = num * 100 / nTotalCount; this._bgWorker.ReportProgress(percentProgress2, userState2); num2++; } CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass2, rowBufferCollection); } } CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); } } } catch (System.Runtime.InteropServices.COMException ex) { XtraMessageBox.Show(ex.Message); } catch (System.UnauthorizedAccessException) { XtraMessageBox.Show(StringParser.Parse("${res:Dataset_InsufficientPermission}")); } catch (System.Exception e) { LoggingService.Error(e.Message); } }
private void InsertSelection(IObjectClass oc, IRowBufferCollection rows) { //FeatureClassInfo featureClassInfo = WorkSpaceServices.Instance().GetFeatureClassInfo(oc.Name, true); DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(oc.GuidString); if (featureClassInfo == null) { return; } if (oc.Type == gviDataSetType.gviDataSetFeatureClassTable) { lock (SelectCollection.Instance().FeatureClassInfoMap) { ResultSetInfo resultSetInfo = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo] as ResultSetInfo; if (resultSetInfo == null) { object[] args = new object[] { oc, //featureClassInfo.GeometryFieldName featureClassInfo.GetFeatureLayer().GeometryFieldName }; //DataTable dt = MainFrmService.MainFrm.Invoke(this._CreaDataTable, args) as DataTable; //resultSetInfo = new ResultSetInfo(dt, SelectCollection.Instance().GetOIDList(rows)); //resultSetInfo.TotalCount = 0; //SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo] = resultSetInfo; //MainFrmService.MainFrm.Invoke(this._notifySelection); } //DataTable resultSetTable = resultSetInfo.ResultSetTable; //for (int i = 0; i < rows.Count; i++) //{ // this._nCurIndex++; // string userState = string.Format(StringParser.Parse("${res:feature_progress_finished}"), this._nCurIndex, this._nTotalCount); // int percentProgress = this._nCurIndex * 100 / this._nTotalCount; // this._bgWorker.ReportProgress(percentProgress, userState); // object[] args2 = new object[] // { // oc, // resultSetTable, // rows.Get(i) // }; // int num = -1; // int.TryParse(MainFrmService.MainFrm.Invoke(this._InsertRecord, args2).ToString(), out num); // if (resultSetInfo.OidList == null) // { // resultSetInfo.OidList = new System.Collections.Generic.List<int>(); // } // if (num != -1 && !resultSetInfo.OidList.Contains(num)) // { // resultSetInfo.OidList.Add(num); // } //} //if (resultSetInfo.OidList.Count<int>() > 0) //{ // RenderControlServices.Instance().AxRenderControl.FeatureManager.HighlightFeatures(oc as IFeatureClass, resultSetInfo.OidList.ToArray(), 4294901860u); //} //resultSetInfo.TotalCount += rows.Count; //object[] args3 = new object[] //{ // featureClassInfo.FeatureLayerGuidString, // resultSetInfo.TotalCount, // resultSetInfo.ResultSetTable.Rows.Count //}; //MainFrmService.MainFrm.Invoke(this._recordsChanged, args3); //HashMap hashMap = MainFrmService.MainFrm.Invoke(this._GetRowbufferMap) as HashMap; //MainFrmService.MainFrm.Invoke(this._setEditorPositionHandel, new object[] //{ // hashMap //}); } } }
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(); } }
private void RoateSelection() { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } double num = double.Parse(this.spinEditX.EditValue.ToString()); double num2 = double.Parse(this.spinEditY.EditValue.ToString()); double num3 = double.Parse(this.spinEditZ.EditValue.ToString()); if (num == 0.0 && num2 == 0.0 && num3 == 0.0) { return; } num = 3.14 * num / 180.0; num2 = 3.14 * num2 / 180.0; num3 = 3.14 * num3 / 180.0; System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> rowBuffers = this.GetRowBuffers(); if (rowBuffers.Count < 1) { return; } IEnvelope selectEnvelope = SelectCollection.Instance().GetSelectEnvelope(SelectCollection.Instance().FcRowBuffersMap); double centerX = 0.0; double centerY = 0.0; double centerZ = 0.0; if (selectEnvelope != null) { centerX = (selectEnvelope.MinX + selectEnvelope.MaxX) / 2.0; centerY = (selectEnvelope.MinY + selectEnvelope.MaxY) / 2.0; centerZ = (selectEnvelope.MinZ + selectEnvelope.MaxZ) / 2.0; } foreach (DF3DFeatureClass current in rowBuffers.Keys) { Gvitech.CityMaker.FdeCore.IFeatureClass featureClass = current.GetFeatureClass(); IFeatureLayer featureLayer = current.GetFeatureLayer(); IRowBufferCollection rowBufferCollection = rowBuffers[current]; for (int i = 0; i < rowBufferCollection.Count; i++) { Gvitech.CityMaker.FdeCore.IRowBuffer rowBuffer = rowBufferCollection.Get(i); int position = rowBuffer.FieldIndex(featureLayer.GeometryFieldName); IGeometry geometry = rowBuffer.GetValue(position) as IGeometry; ITransform transform = geometry as ITransform; if (geometry != null && transform != null) { if (this._editType == RenderEditorType.RotateCenterType) { IEnvelope envelope = geometry.Envelope; centerX = (envelope.MinX + envelope.MaxX) / 2.0; centerY = (envelope.MinY + envelope.MaxY) / 2.0; centerZ = (envelope.MinZ + envelope.MaxZ) / 2.0; } if (geometry.HasZ()) { transform.Rotate3D(1.0, 0.0, 0.0, centerX, centerY, centerZ, num); transform.Rotate3D(0.0, 1.0, 0.0, centerX, centerY, centerZ, num2); transform.Rotate3D(0.0, 0.0, 1.0, centerX, centerY, centerZ, num3); } else { transform.Rotate2D(centerX, centerY, num3); } rowBuffer.SetValue(position, transform); } } app.Current3DMapControl.FeatureManager.EditFeatures(featureClass, rowBufferCollection); //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } RenderControlEditServices.Instance().SetEditorPosition(SelectCollection.Instance().FcRowBuffersMap); this.UpdateDatabase(rowBuffers); }