public void GeometryEditStart(DF3DFeatureClass fcInfo, IRenderGeometry renderGeo, gviGeoEditType editType) { if (this._app == null || this._app.Current3DMapControl == null) { return; } if (this._geoEditor.IsEditing) { this.StopEdit(true); } this.curGeoField = fcInfo.GetFeatureLayer().GeometryFieldName; this._renderGeometry = renderGeo; this._FeatureClass = fcInfo; Gvitech.CityMaker.FdeCore.IFeatureClass featureClass = fcInfo.GetFeatureClass(); this._row = featureClass.CreateRowBuffer(); int num = this._row.FieldIndex(this.curGeoField); if (num != -1 && this._renderGeometry != null) { this._row.SetValue(num, this._renderGeometry.GetFdeGeometry()); } this._geoEditType = editType; this._InteractaMode = this._app.Current3DMapControl.InteractMode; this._app.Current3DMapControl.InteractMode = gviInteractMode.gviInteractEdit; if (!this._geoEditor.StartEditRenderGeometry(renderGeo, editType)) { this._app.Current3DMapControl.InteractMode = this._InteractaMode; XtraMessageBox.Show("暂不支持该类型的编辑"); } //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); }
private void UpdateDatabase() { DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } int count = 1; EditParameters editParameters = new EditParameters(fc.Guid.ToString()); editParameters.connectionInfo = CommonUtils.Instance().GetCurrentFeatureDataset().DataSource.ConnectionInfo.ToConnectionString(); editParameters.datasetName = CommonUtils.Instance().GetCurrentFeatureDataset().Name; editParameters.geometryMap = beforeRowBufferMap; editParameters.nTotalCount = count; editParameters.TemproalTime = this.time; IBatcheEdit batcheEdit = BatchEditFactory.CreateBatchEdit(count); batcheEdit.BeginEdit(); batcheEdit.DoWork(EditType.ET_INSERT_FEATURES, editParameters); batcheEdit.EndEdit(); }
private void UpdateDatabase() { DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } int count = SelectCollection.Instance().GetCount(false); EditParameters editParameters = new EditParameters(fc.Guid.ToString()); editParameters.connectionInfo = CommonUtils.Instance().GetCurrentFeatureDataset().DataSource.ConnectionInfo.ToConnectionString(); editParameters.datasetName = CommonUtils.Instance().GetCurrentFeatureDataset().Name; editParameters.regexDataList = regexDataList; editParameters.colName = colName; editParameters.fidList = fids; editParameters.nTotalCount = count; editParameters.TemproalTime = this.time; IBatcheEdit batcheEdit = BatchEditFactory.CreateBatchEdit(count); batcheEdit.BeginEdit(); batcheEdit.DoWork(EditType.ET_UPDATE_ATTRIBUTE, editParameters); batcheEdit.EndEdit(); }
private void LoadClassify() { try { this.cmbClassify.Properties.Items.Clear(); DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc != null) { IFeatureClass fc = dffc.GetFeatureClass(); if (fc != null) { MajorClass mc = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(fc.GuidString); if (mc != null && mc.SubClasses != null) { this._classifyName = mc.ClassifyField; foreach (SubClass sc in mc.SubClasses) { this.cmbClassify.Properties.Items.Add(sc); } if (this.cmbClassify.Properties.Items.Count > 0) { this.cmbClassify.SelectedIndex = 0; } else { this.cmbClassify.SelectedIndex = -1; } } } } } catch (Exception ex) { } }
public bool IsValid(object caller, ICSharpCode.Core.Condition condition) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return(false); } DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc == null) { return(false); } IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return(false); } IFeatureLayer fl = dffc.GetFeatureLayer(); bool b1 = false; if (fl != null && (fl.GeometryType == gviGeometryColumnType.gviGeometryColumnPolygon || fl.GeometryType == gviGeometryColumnType.gviGeometryColumnPolyline)) { b1 = true; } int count = SelectCollection.Instance().GetCount(false); if (count != 1) { b1 &= false; } return(b1); }
private void query() { if (this.cmbLayer.SelectedItem == null) { return; } DF3DFeatureClass dffc = this.cmbLayer.SelectedItem as DF3DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return; } ISpatialFilter filter = new SpatialFilter(); #region if (this.cmbField.SelectedItem == null) { filter.WhereClause = "1=1"; } else { if (this.cmbField.SelectedItem is DFDataConfig.Class.FieldInfo) { DFDataConfig.Class.FieldInfo fi = this.cmbField.SelectedItem as DFDataConfig.Class.FieldInfo; if (oper == " like ") { filter.WhereClause = fi.Name + " like '%" + this.teFieldValue.Text + "%'"; } else { if (fi.DataType.ToLower() == "decimal") { filter.WhereClause = fi.Name + oper + this.teFieldValue.Text; } else { filter.WhereClause = fi.Name + oper + "'" + this.teFieldValue.Text + "'"; } } } else { filter.WhereClause = "1!=1"; } } #endregion int count = fc.GetCount(filter); if (count == 0) { XtraMessageBox.Show("查询结果为空", "提示"); return; } this._dffc = dffc; this._filter = filter; this._total = count; this.DialogResult = System.Windows.Forms.DialogResult.OK; }
private void LoadProperty() { DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } IFieldInfoCollection fiCol = fc.GetFields(); if (fiCol == null) { return; } for (int i = 0; i < fiCol.Count; i++) { IFieldInfo fi = fiCol.Get(i); if (fi.Name == fc.FidFieldName) { continue; } switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: continue; //case gviFieldType.gviFieldFloat: //case gviFieldType.gviFieldDouble: // break; //case gviFieldType.gviFieldFID: //case gviFieldType.gviFieldUUID: //case gviFieldType.gviFieldInt16: //case gviFieldType.gviFieldInt32: //case gviFieldType.gviFieldInt64: // break; //case gviFieldType.gviFieldString: // break; //case gviFieldType.gviFieldDate: default: DataRow dr = this._dt.NewRow(); dr["FN"] = string.IsNullOrEmpty(fi.Alias) ? fi.Name : fi.Alias; dr["FV"] = null; dr["F"] = fi; this._dt.Rows.Add(dr); break; } } }
private void ClassQuery(MajorClass mc, MajorClass mctemp, ISpatialFilter filter, IGeometry geo) { if (mc == null || filter == null || geo == null) { return; } string[] arrFc3DId = mc.Fc3D.Split(';'); if (arrFc3DId == null) { return; } foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible3D) { continue; } bool bHave = false; foreach (string fc3DId in arrFc3DId) { DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facc == null) { continue; } filter.WhereClause = "GroupId = " + sc.GroupId; int count = fc.GetCount(filter); if (count == 0) { continue; } bHave = true; bHaveRes = true; if (bHave) { break; } } if (bHave) { SubClass sctemp = new SubClass(sc.Name, sc.GroupId, sc.Parent); sctemp.Visible3D = sc.Visible3D; mctemp.SubClasses.Add(sctemp); } } }
private bool ImportOsg(string modelName, string filePath) { try { IImage property = null; IMatrix mat = null; IPropertySet images = null; IModel smodel = null; IModel fmodel = null; bool bRes = this.OpenOsgModel(filePath, out fmodel, out smodel, out images, out mat); if (!bRes) { return(false); } DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc != null) { IFeatureClass fc = dffc.GetFeatureClass(); if (fc != null) { IResourceManager resManager = fc.FeatureDataSet as IResourceManager; if ((images != null) && (images.Count > 0)) { foreach (string str in images.GetAllKeys()) { if (!resManager.ImageExist(str)) { property = images.GetProperty(str) as IImage; bRes = resManager.AddImage(str, property); if (!bRes) { return(false); } } } } bRes = resManager.AddModel(modelName, fmodel, smodel); if (!bRes) { return(false); } } } return(true); } catch (Exception ex) { return(false); } }
private void DeleteFeatures(EditParameters parameters) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } string featureClassGuid = parameters.featureClassGuid; if (string.IsNullOrEmpty(featureClassGuid)) { return; } DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(featureClassGuid); if (featureClassInfo == null) { return; } FDECommand cmd = new FDECommand(false, true); CommandManagerServices.Instance().StartCommand(); IFeatureClass featureClass = featureClassInfo.GetFeatureClass(); if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { System.DateTime temproalTime = parameters.TemproalTime; TemporalFilter temporalFilter = new TemporalFilterClass(); temporalFilter.AddSubField(featureClass.FidFieldName); temporalFilter.IdsFilter = parameters.fidList; ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(temporalFilter); while (temporalCursor.MoveNext()) { temporalCursor.Dead(temproalTime); } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass); } else { CommonUtils.Instance().FdeUndoRedoManager.DeleteFeatures(featureClass, parameters.fidList); app.Current3DMapControl.FeatureManager.DeleteFeatures(featureClass, parameters.fidList); } CommonUtils.Instance().Delete(featureClassInfo, parameters.fidList); CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); }
public override void Run(object sender, System.EventArgs e) { RenderControlEditServices.Instance().StopGeometryEdit(true); System.DateTime temproalTime = System.DateTime.Now; if (CommonUtils.Instance().EnableTemproalEdit) { using (DateSettingDialog dateSettingDialog = new DateSettingDialog()) { if (dateSettingDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } temproalTime = dateSettingDialog.Time; } } DF3DFeatureClass featureClassInfo = null; System.Collections.IEnumerator enumerator = SelectCollection.Instance().FeatureClassInfoMap.Keys.GetEnumerator(); try { if (enumerator.MoveNext()) { DF3DFeatureClass featureClassInfo2 = (DF3DFeatureClass)enumerator.Current; featureClassInfo = featureClassInfo2; } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } if (featureClassInfo == null) { return; } int count = SelectCollection.Instance().GetCount(false); EditParameters editParameters = new EditParameters(featureClassInfo.GetFeatureClass().Guid.ToString()); editParameters.connectionInfo = CommonUtils.Instance().GetCurrentFeatureDataset().DataSource.ConnectionInfo.ToConnectionString(); editParameters.datasetName = CommonUtils.Instance().GetCurrentFeatureDataset().Name; editParameters.TemproalTime = temproalTime; IBatcheEdit batcheEdit = BatchEditFactory.CreateBatchEdit(count); batcheEdit.BeginEdit(); batcheEdit.DoWork(EditType.ET_DELETE_SELCTION, editParameters); batcheEdit.EndEdit(); }
private void UpdateDatabase(System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> rowsMap) { System.Collections.Generic.Dictionary <DF3DFeatureClass, IRowBufferCollection> .Enumerator enumerator = rowsMap.GetEnumerator(); if (!enumerator.MoveNext()) { return; } System.Collections.Generic.KeyValuePair <DF3DFeatureClass, IRowBufferCollection> current = enumerator.Current; DF3DFeatureClass key = current.Key; int count = SelectCollection.Instance().GetCount(false); EditParameters editParameters = new EditParameters(key.GetFeatureClass().GuidString); editParameters.connectionInfo = key.GetFeatureClass().DataSource.ConnectionInfo.ToConnectionString(); editParameters.datasetName = key.GetFeatureClass().FeatureDataSet.Name; editParameters.geometryMap = rowsMap; editParameters.nTotalCount = count; editParameters.TemproalTime = this._time; IBatcheEdit batcheEdit = BatchEditFactory.CreateBatchEdit(count); batcheEdit.BeginEdit(); batcheEdit.DoWork(EditType.ET_UPDATE_GEOMETRY, editParameters); batcheEdit.EndEdit(); }
private void LoadStyle() { try { this.cmbStyle.Properties.Items.Clear(); DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc != null) { IFeatureClass fc = dffc.GetFeatureClass(); if (fc != null) { reg = FacilityInfoService.GetFacClassRegByFeatureClassID(fc.Guid.ToString()); if (reg != null) { tc = FacilityInfoService.GetTopoClassByFacClassCode(reg.FacClassCode); List <FacStyleClass> list1 = FacilityInfoService.GetFacStyleByFacClassCode(reg.FacClassCode); if (list1 != null) { foreach (FacStyleClass fsc in list1) { int imageIndex = this.imageCollection1.Images.Add(fsc.Thumbnail); ImageComboBoxItem item = new ImageComboBoxItem(); item.Value = fsc; item.Description = fsc.ToString(); item.ImageIndex = imageIndex; this.cmbStyle.Properties.Items.Add(item); } for (int i = 0; i < this.cmbStyle.Properties.Items.Count; i++) { this.cmbStyle.Properties.Items[i].ImageIndex = i; } if (this.cmbStyle.Properties.Items.Count > 0) { this.cmbStyle.SelectedIndex = 0; } else { this.cmbStyle.SelectedIndex = -1; } } } } } } catch (Exception ex) { } }
private void btnSearch_Click(object sender, EventArgs e) { RestoreEnv(); this._dt.Rows.Clear(); string str = this.teRoadName.Text.Trim(); object obj = this.cmbFCs.SelectedItem; WaitForm.Start("正在搜索...", "请稍后"); try { if (obj == null) { List <DF3DFeatureClass> list = Dictionary3DTable.Instance.GetFeatureClassByFacilityClassName("Road"); if (list != null && list.Count != 0) { foreach (DF3DFeatureClass dffc in list) { IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass fac = dffc.GetFacilityClass(); if (fc != null && fac != null) { SearchRes(fc, fac.GetFieldInfoNameBySystemName("Name"), str); } } } } else { if (obj is DF3DFeatureClass) { DF3DFeatureClass dffc = obj as DF3DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass fac = dffc.GetFacilityClass(); if (fc != null && fac != null) { SearchRes(fc, fac.GetFieldInfoNameBySystemName("Name"), str); } } } } catch (Exception ex) { } WaitForm.Stop(); }
private void EndRote() { this.bFinished = true; if (this.modifyRowbufferMap != null) { DF3DFeatureClass featureClassInfo = null; System.Collections.IEnumerator enumerator = this.modifyRowbufferMap.Keys.GetEnumerator(); try { if (enumerator.MoveNext()) { DF3DFeatureClass featureClassInfo2 = (DF3DFeatureClass)enumerator.Current; featureClassInfo = featureClassInfo2; } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } if (featureClassInfo == null) { return; } int count = SelectCollection.Instance().GetCount(false); EditParameters editParameters = new EditParameters(featureClassInfo.GetFeatureClass().Guid.ToString()); editParameters.connectionInfo = CommonUtils.Instance().GetCurrentFeatureDataset().DataSource.ConnectionInfo.ToConnectionString(); editParameters.datasetName = CommonUtils.Instance().GetCurrentFeatureDataset().Name; editParameters.geometryMap = this.ToDictionary(); editParameters.nTotalCount = count; editParameters.TemproalTime = this.time; IBatcheEdit batcheEdit = BatchEditFactory.CreateBatchEdit(count); batcheEdit.BeginEdit(); batcheEdit.DoWork(EditType.ET_UPDATE_GEOMETRY, editParameters); batcheEdit.EndEdit(); } this.beginRowbufferMap = this.modifyRowbufferMap; }
public void DeleteGeometry() { DF3DFeatureClass featureClassInfo = null; System.Collections.IEnumerator enumerator = SelectCollection.Instance().FeatureClassInfoMap.Keys.GetEnumerator(); try { if (enumerator.MoveNext()) { DF3DFeatureClass featureClassInfo2 = (DF3DFeatureClass)enumerator.Current; featureClassInfo = featureClassInfo2; } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } if (featureClassInfo == null) { return; } int count = SelectCollection.Instance().GetCount(false); EditParameters editParameters = new EditParameters(featureClassInfo.GetFeatureClass().Guid.ToString()); editParameters.connectionInfo = CommonUtils.Instance().GetCurrentFeatureDataset().DataSource.ConnectionInfo.ToConnectionString(); editParameters.datasetName = CommonUtils.Instance().GetCurrentFeatureDataset().Name; editParameters.TemproalTime = this.time; IBatcheEdit batcheEdit = BatchEditFactory.CreateBatchEdit(count); batcheEdit.BeginEdit(); batcheEdit.DoWork(EditType.ET_DELETE_SELCTION, editParameters); batcheEdit.EndEdit(); }
private void btnSearch_Click(object sender, EventArgs e) { RestoreEnv(); this._dt.Rows.Clear(); string str = this.teName.Text.Trim(); object obj = this.cmbFCs.SelectedItem; WaitForm.Start("正在搜索...", "请稍后"); try { if (obj != null && obj is DF3DFeatureClass) { DF3DFeatureClass dffc = obj as DF3DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass fac = dffc.GetFacilityClass(); if (fc != null && fac != null) { SearchRes(fc, fac.GetFieldInfoNameBySystemName("Name"), str); } } } catch (Exception ex) { } WaitForm.Stop(); }
private void DoQuery() { if (string.IsNullOrEmpty(this._sysFieldName)) { return; } string value = this.teValue.Text.Trim(); if (value.Length > 1) { int lastindex = value.LastIndexOf(';'); if (lastindex == (value.Length - 1)) { value = value.Substring(0, value.Length - 1); } } if (this.treelist.GetAllCheckedNodes() != null) { foreach (TreeListNode node in this.treelist.GetAllCheckedNodes()) { object obj = node.GetValue("NodeObject"); if (obj != null && obj is SubClass) { SubClass sc = obj as SubClass; if (sc.Parent == null) { continue; } string[] arrFc3DId = sc.Parent.Fc3D.Split(';'); if (arrFc3DId == null) { continue; } foreach (string fc3DId in arrFc3DId) { DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facc == null || facc.Name != this._facType) { continue; } DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName(this._sysFieldName); if (fi == null) { continue; } int index = fc.GetFields().IndexOf(fi.Name); if (index == -1) { continue; } IFieldInfo fcfi = fc.GetFields().Get(index); switch (fcfi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: continue; } string[] arr1 = value.Split(';'); if (arr1 == null || arr1.Length == 0) { continue; } string temp1 = "("; foreach (string str1 in arr1) { temp1 += str1 + ","; } if (temp1 == "(") { temp1 = "()"; } else { temp1 = temp1.Substring(0, temp1.Length - 1) + ")"; } string strWhereClause = "GroupId = " + sc.GroupId + " and (" + fi.Name + " in " + temp1 + ")"; _dict.Add(sc, strWhereClause); } } } } }
private void SpatialQuery() { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } try { HashMap hashMap = new HashMap(); IRowBuffer buffer = null; IFdeCursor cursor = null; ISpatialFilter filter = null; IGeometry geo2D = this._drawTool.GetGeo(); if (geo2D != null && geo2D.GeometryType == gviGeometryType.gviGeometryPolygon) { IPolygon polygon = geo2D as IPolygon; if (polygon != null) { DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo != null) { IFeatureClass featureClass = featureClassInfo.GetFeatureClass(); if (featureClass != null) { string typeName = featureClassInfo.GetFacilityClassName(); if (typeName == "PipeLine" || typeName == "PipeNode" || typeName == "PipeBuild" || typeName == "PipeBuild1") { filter = new SpatialFilterClass { GeometryField = "Shape", SpatialRel = gviSpatialRel.gviSpatialRelIntersects, Geometry = polygon.Clone2(gviVertexAttribute.gviVertexAttributeNone) }; } else { filter = new SpatialFilterClass { Geometry = polygon, GeometryField = "Geometry", SpatialRel = gviSpatialRel.gviSpatialRelEnvelope }; } filter.SubFields = featureClass.FidFieldName; cursor = featureClass.Search(filter, true); while ((buffer = cursor.NextRow()) != null) { int featureId = int.Parse(buffer.GetValue(0).ToString()); if (hashMap.Contains(featureClassInfo)) { System.Collections.Generic.List <int> list = hashMap[featureClassInfo] as System.Collections.Generic.List <int>; if (!list.Contains(featureId)) { list.Add(featureId); } } else { System.Collections.Generic.List <int> list2 = new System.Collections.Generic.List <int>(); if (!list2.Contains(featureId)) { list2.Add(featureId); } hashMap[featureClassInfo] = list2; } } } } } SelectCollection.Instance().UpdateSelection(hashMap); RenderControlEditServices.Instance().SetEditorPosition(SelectCollection.Instance().FcRowBuffersMap); this.Clear(); } if (buffer != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(buffer); } if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); } if (filter != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(filter); } } catch (Exception ex) { LoggingService.Error(ex.Message); } }
private void cmbLayer_SelectedIndexChanged(object sender, EventArgs e) { this.cmbField.Properties.Items.Clear(); this.cmbField.SelectedIndex = -1; this.teFieldValue.Text = null; this.lbcFieldValues.Items.Clear(); if (this.cmbLayer.SelectedItem == null) { return; } DF3DFeatureClass dffc = this.cmbLayer.SelectedItem as DF3DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return; } FacilityClass fac = dffc.GetFacilityClass(); if (fac == null) { IFieldInfoCollection fiCol = fc.GetFields(); if (fiCol != null) { for (int i = 0; i < fiCol.Count; i++) { IFieldInfo fi = fiCol.Get(i); if (fi.FieldType == gviFieldType.gviFieldUnknown || fi.FieldType == gviFieldType.gviFieldGeometry || fi.FieldType == gviFieldType.gviFieldBlob) { continue; } string dataType = ""; switch (fi.FieldType) { case gviFieldType.gviFieldDouble: case gviFieldType.gviFieldFID: case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldInt16: case gviFieldType.gviFieldInt32: case gviFieldType.gviFieldInt64: case gviFieldType.gviFieldUUID: dataType = "Decimal"; break; case gviFieldType.gviFieldDate: case gviFieldType.gviFieldString: dataType = "String"; break; default: break; } DFDataConfig.Class.FieldInfo fi1 = new DFDataConfig.Class.FieldInfo(fi.Name, fi.Alias, "", "", true, false, false, dataType); this.cmbField.Properties.Items.Add(fi1); } } } else { List <DFDataConfig.Class.FieldInfo> list = fac.FieldInfoCollection; if (list != null) { foreach (DFDataConfig.Class.FieldInfo fi in list) { if (!fi.CanQuery) { continue; } this.cmbField.Properties.Items.Add(fi); } } } }
private void UpdateAttribute(EditParameters paramter) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } string featureClassGuid = paramter.featureClassGuid; if (string.IsNullOrEmpty(featureClassGuid)) { return; } DF3DFeatureClass featureClassInfo = DF3DFeatureClassManager.Instance.GetFeatureClassByID(featureClassGuid); if (featureClassInfo == null) { return; } IFeatureClass featureClass = featureClassInfo.GetFeatureClass(); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); if (featureClass.HasTemporal() && CommonUtils.Instance().EnableTemproalEdit) { ITemporalManager temporalManager = featureClass.TemporalManager; ITemporalCursor temporalCursor = temporalManager.Search(new TemporalFilterClass { IdsFilter = paramter.fidList }); while (temporalCursor.MoveNext()) { bool flag = false; int currentId = temporalCursor.CurrentId; IRowBuffer row = featureClass.GetRow(currentId); base.UpdateRowBuffer(ref row, paramter.colName, paramter.regexDataList); rowBufferCollection.Add(row); ITemporalInstanceCursor temporalInstances = temporalCursor.GetTemporalInstances(false); TemporalInstance temporalInstance; while ((temporalInstance = temporalInstances.NextInstance()) != null) { if (temporalInstance.StartDatetime == paramter.TemproalTime) { flag = true; temporalInstances.Update(row); break; } } System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalInstances); if (!flag) { temporalCursor.Insert(paramter.TemproalTime, row); } } app.Current3DMapControl.FeatureManager.RefreshFeatureClass(featureClass); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(temporalManager); } else { CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); for (int i = 0; i < paramter.fidList.Length; i++) { int id = paramter.fidList[i]; IRowBuffer row2 = featureClass.GetRow(id); if (row2 != null) { base.UpdateRowBuffer(ref row2, paramter.colName, paramter.regexDataList); rowBufferCollection.Add(row2); } } CommonUtils.Instance().FdeUndoRedoManager.UpdateFeatures(featureClass, rowBufferCollection); app.Current3DMapControl.FeatureManager.EditFeatures(featureClass, rowBufferCollection); CommandManagerServices.Instance().CallCommand(cmd); app.Workbench.UpdateMenu(); } CommonUtils.Instance().Update(featureClassInfo, rowBufferCollection); }
private void cmbField_SelectedIndexChanged(object sender, EventArgs e) { try { this.lbcFieldValues.Items.Clear(); this.teFieldValue.Text = ""; if (this.cmbField.SelectedItem == null) { return; } if (this.cmbLayer.SelectedItem == null) { return; } DF3DFeatureClass dffc = this.cmbLayer.SelectedItem as DF3DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return; } string fieldName = ""; if (this.cmbField.SelectedItem is DFDataConfig.Class.FieldInfo) { fieldName = (this.cmbField.SelectedItem as DFDataConfig.Class.FieldInfo).Name; } if (fieldName == "") { return; } HashSet <string> list = new HashSet <string>(); string cacheType = fc.GuidString + "_3D_" + fieldName; object objCache = CacheHelper.GetCache(cacheType); if (objCache != null && objCache is HashSet <string> ) { HashSet <string> temphs = objCache as HashSet <string>; foreach (string str in temphs) { this.lbcFieldValues.Items.Add(str); } return; } #region IRowBuffer row = null; IFdeCursor cursor = null; try { int index = fc.GetFields().IndexOf(fieldName); bool bString = true; if (index != -1) { IFieldInfo fi = fc.GetFields().Get(index); switch (fi.FieldType) { case gviFieldType.gviFieldDouble: case gviFieldType.gviFieldFID: case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldInt16: case gviFieldType.gviFieldInt32: case gviFieldType.gviFieldInt64: case gviFieldType.gviFieldUUID: bString = false; break; case gviFieldType.gviFieldDate: case gviFieldType.gviFieldString: bString = true; break; default: break; } } IQueryFilter filter = new QueryFilter(); filter.SubFields = fieldName; filter.ResultBeginIndex = 0; filter.ResultLimit = 1; while (true) { string strTempClause = fieldName + " is not null and "; string fClause = strTempClause; foreach (string strtemp in list) { if (bString) { fClause += fieldName + " <> '" + strtemp + "' and "; } else { fClause += fieldName + " <> " + strtemp + " and "; } } fClause = fClause.Substring(0, fClause.Length - 5); filter.WhereClause = fClause; cursor = fc.Search(filter, true); if ((row = cursor.NextRow()) != null) { if (row.IsNull(0)) { break; } object temp = row.GetValue(0); string strtemp = temp.ToString(); if (temp != null) { list.Add(strtemp); if (list.Count > 10) { break;// 列举10个 } } if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } } else { break; } } CacheHelper.SetCache(cacheType, list); } catch (Exception Exception) { } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } #endregion foreach (string str in list) { this.lbcFieldValues.Items.Add(str); } } catch (Exception Exception) { } }
public override void Run(object sender, System.EventArgs e) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } try { Map3DCommandManager.Push(this); RenderControlEditServices.Instance().StopGeometryEdit(true); app.Current3DMapControl.PauseRendering(false); System.Collections.Generic.IList <System.Collections.Generic.KeyValuePair <int, string> > list = new System.Collections.Generic.List <System.Collections.Generic.KeyValuePair <int, string> >(); HashMap featureClassInfoMap = SelectCollection.Instance().FeatureClassInfoMap; DF3DFeatureClass featureClassInfo = null; System.Collections.Generic.IList <int> list2 = new System.Collections.Generic.List <int>(); System.Collections.IEnumerator enumerator = featureClassInfoMap.Keys.GetEnumerator(); try { if (enumerator.MoveNext()) { DF3DFeatureClass featureClassInfo2 = (DF3DFeatureClass)enumerator.Current; featureClassInfo = featureClassInfo2; ResultSetInfo resultSetInfo = featureClassInfoMap[featureClassInfo2] as ResultSetInfo; foreach (DataRow dataRow in resultSetInfo.ResultSetTable.Rows) { int num = int.Parse(dataRow[featureClassInfo.GetFeatureClass().FidFieldName].ToString()); string value = num.ToString(); System.Collections.Generic.KeyValuePair <int, string> item = new System.Collections.Generic.KeyValuePair <int, string>(num, value); list.Add(item); list2.Add(num); } } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } if (featureClassInfo != null) { using (MergeDlg mergeDlg = new MergeDlg(list)) { if (mergeDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (System.Windows.Forms.DialogResult.No != XtraMessageBox.Show("模型合并不支持撤销操作,是否继续?", "提示", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Exclamation)) { int fid = mergeDlg.Fid; using (new WaitDialogForm("", "正在进行模型合并,请稍后...")) { IFeatureClass featureClass = featureClassInfo.GetFeatureClass(); string geometryFieldName = featureClassInfo.GetFeatureLayer().GeometryFieldName; IModelPoint model = this.GetModel(featureClass, geometryFieldName, fid); IResourceManager resourceManager = CommonUtils.Instance().GetCurrentFeatureDataset() as IResourceManager; if (resourceManager != null) { if (!this.MergeModels(featureClass, geometryFieldName, list2.ToArray <int>(), resourceManager, ref model)) { XtraMessageBox.Show("模型合并失败!"); } else { if (list2.Remove(fid)) { featureClass.Delete(new QueryFilterClass { IdsFilter = list2.ToArray <int>() }); CommonUtils.Instance().Delete(featureClassInfo, list2.ToArray <int>()); app.Current3DMapControl.FeatureManager.DeleteFeatures(featureClass, list2.ToArray <int>()); } app.Current3DMapControl.RefreshModel(CommonUtils.Instance().GetCurrentFeatureDataset(), model.ModelName); IFdeCursor fdeCursor = featureClass.Update(new QueryFilterClass { IdsFilter = new int[] { fid } }); IRowBuffer rowBuffer = fdeCursor.NextRow(); if (rowBuffer != null) { int num2 = rowBuffer.FieldIndex(geometryFieldName); if (num2 != -1) { rowBuffer.SetValue(num2, model); } fdeCursor.UpdateRow(rowBuffer); System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor); app.Current3DMapControl.FeatureManager.EditFeature(featureClass, rowBuffer); } //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } } } } } } } } catch (System.Runtime.InteropServices.COMException ex) { XtraMessageBox.Show(ex.Message); } catch (System.UnauthorizedAccessException var_23_389) { XtraMessageBox.Show("拒绝访问"); } catch (System.Exception ex2) { XtraMessageBox.Show(ex2.Message); } finally { app.Current3DMapControl.ResumeRendering(); } }
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) { } }
private void AddRecord() { try { this.beforeRowBufferMap.Clear(); SelectCollection.Instance().Clear(); DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } IFeatureLayer fl = featureClassInfo.GetFeatureLayer(); if (fl == null) { return; } IFieldInfoCollection fields = fc.GetFields(); int indexGeo = fields.IndexOf(fl.GeometryFieldName); if (indexGeo == -1) { return; } IFieldInfo fiGeo = fields.Get(indexGeo); if (fiGeo == null || fiGeo.GeometryDef == null) { return; } IGeometry geo = this._drawTool.GetGeo(); if (geo.GeometryType != gviGeometryType.gviGeometryPolygon) { return; } IPolygon polygon = geo as IPolygon; IPolygon geoOut = this._geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, fiGeo.GeometryDef.VertexAttribute) as IPolygon; for (int i = 0; i < polygon.ExteriorRing.PointCount; i++) { IPoint ptGet = polygon.ExteriorRing.GetPoint(i); IPoint pttemp = ptGet.Clone2(fiGeo.GeometryDef.VertexAttribute) as IPoint; if (fiGeo.GeometryDef.HasZ) { pttemp.SetCoords(ptGet.X, ptGet.Y, ptGet.Z, 0, 0); } else { pttemp.SetCoords(ptGet.X, ptGet.Y, 0, 0, 0); } geoOut.ExteriorRing.AppendPoint(pttemp); } IRowBufferCollection rowCol = new RowBufferCollection(); IRowBufferFactory fac = new RowBufferFactory(); IRowBuffer row = fac.CreateRowBuffer(fields); row.SetValue(indexGeo, geoOut); foreach (DataRow dr in this._dt.Rows) { IFieldInfo fi = dr["F"] as IFieldInfo; if (fi == null) { continue; } string fn = fi.Name; int index = fields.IndexOf(fn); if (index != -1) { if (dr["FV"] == null) { row.SetNull(index); } else { string strobj = dr["FV"].ToString(); bool bRes = false; switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: break; case gviFieldType.gviFieldFloat: float f; bRes = float.TryParse(strobj, out f); if (bRes) { row.SetValue(index, f); } else { row.SetNull(index); } break; case gviFieldType.gviFieldDouble: double d; bRes = double.TryParse(strobj, out d); if (bRes) { row.SetValue(index, d); } else { row.SetNull(index); } break; case gviFieldType.gviFieldFID: case gviFieldType.gviFieldUUID: case gviFieldType.gviFieldInt16: Int16 i16; bRes = Int16.TryParse(strobj, out i16); if (bRes) { row.SetValue(index, i16); } else { row.SetNull(index); } break; case gviFieldType.gviFieldInt32: Int32 i32; bRes = Int32.TryParse(strobj, out i32); if (bRes) { row.SetValue(index, i32); } else { row.SetNull(index); } break; case gviFieldType.gviFieldInt64: Int64 i64; bRes = Int64.TryParse(strobj, out i64); if (bRes) { row.SetValue(index, i64); } else { row.SetNull(index); } break;; case gviFieldType.gviFieldString: row.SetValue(index, strobj); break; case gviFieldType.gviFieldDate: DateTime dt; bRes = DateTime.TryParse(strobj, out dt); if (bRes) { row.SetValue(index, dt); } else { row.SetNull(index); } break; default: break; } } } } rowCol.Add(row); beforeRowBufferMap[featureClassInfo] = rowCol; UpdateDatabase(); } catch (Exception ex) { } }
private void OnFinishedDraw() { try { if (this._drawTool != null && this._drawTool.GetGeo() != null) { switch (this._drawTool.GeoType) { case DrawType.Point: break; case DrawType.Polyline: break; case DrawType.Circle: break; case DrawType.Rectangle: break; case DrawType.Polygon: break; default: return; } IGeometry geo = this._drawTool.GetGeo(); if (geo == null) { return; } IGeometry geoBuffer = (geo as ITopologicalOperator2D).Buffer2D(Convert.ToDouble(this.seBufferDis.Value.ToString()), gviBufferStyle.gviBufferCapround); if (geoBuffer == null) { return; } if (this._drawTool != null) { this._drawTool.OnStartDraw -= new OnStartDraw(this.OnStartDraw); this._drawTool.OnFinishedDraw -= new OnFinishedDraw(this.OnFinishedDraw); this._drawTool.Close(); this._drawTool.End(); } this._3DControl.HighlightHelper.VisibleMask = 1; this._3DControl.HighlightHelper.SetRegion(geoBuffer); if (geoBuffer.GeometryType == gviGeometryType.gviGeometryPolygon) { this._rPolygon = this._3DControl.ObjectManager.CreateRenderPolygon(geoBuffer as IPolygon, this._surfaceSymbol, this._3DControl.ProjectTree.RootID); if (this._3DControl.Terrain.IsRegistered && this._3DControl.Terrain.VisibleMask != gviViewportMask.gviViewNone) { (this._rPolygon as IRenderPolygon).HeightStyle = gviHeightStyle.gviHeightOnTerrain; } else { (this._rPolygon as IRenderPolygon).HeightStyle = gviHeightStyle.gviHeightAbsolute; } } else if (geoBuffer.GeometryType == gviGeometryType.gviGeometryMultiPolygon) { this._rPolygon = this._3DControl.ObjectManager.CreateRenderMultiPolygon(geoBuffer as IMultiPolygon, this._surfaceSymbol, this._3DControl.ProjectTree.RootID); if (this._3DControl.Terrain.IsRegistered && this._3DControl.Terrain.VisibleMask != gviViewportMask.gviViewNone) { (this._rPolygon as IRenderMultiPolygon).HeightStyle = gviHeightStyle.gviHeightOnTerrain; } else { (this._rPolygon as IRenderMultiPolygon).HeightStyle = gviHeightStyle.gviHeightAbsolute; } } else { return; } if (this.cmbLayer.SelectedItem == null) { return; } ISpatialFilter filter = new SpatialFilter(); filter.Geometry = geoBuffer; if (this.cmbSpatialRelation.Text == "包含") { filter.SpatialRel = gviSpatialRel.gviSpatialRelContains; } else { filter.SpatialRel = gviSpatialRel.gviSpatialRelIntersects; } DF3DFeatureClass dffc = this.cmbLayer.SelectedItem as DF3DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return; } IFeatureLayer fl = dffc.GetFeatureLayer(); if (fl == null) { return; } filter.GeometryField = fl.GeometryFieldName; int count = fc.GetCount(filter); if (count == 0) { XtraMessageBox.Show("查询结果为空", "提示"); return; } WaitForm.Start("正在查询...", "请稍后"); this._uPanel = new UIDockPanel("查询结果", "查询结果", this.Location1, this._width, this._height); this._dockPanel = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right); this._dockPanel.Visibility = DockVisibility.Visible; this._dockPanel.FloatSize = new System.Drawing.Size(this._width, this._height); this._dockPanel.Width = this._width; this._dockPanel.Height = this._height; this._uc = new UCPropertyInfo(); this._uc.Init(); this._uc.Dock = System.Windows.Forms.DockStyle.Fill; this._uPanel.RegisterEvent(new PanelClose(this.Close)); this._dockPanel.Controls.Add(this._uc); this._uc.SetInfo(dffc, filter, count); WaitForm.Stop(); } } catch (Exception ex) { } }
private void LoadProperty() { try { DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } IFieldInfoCollection fiCol = fc.GetFields(); if (fiCol == null) { return; } FacilityClass fac = featureClassInfo.GetFacilityClass(); if (fac == null) { for (int i = 0; i < fiCol.Count; i++) { IFieldInfo fi = fiCol.Get(i); if (fi.Name == fc.FidFieldName) { continue; } switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: continue; //case gviFieldType.gviFieldFloat: //case gviFieldType.gviFieldDouble: // break; //case gviFieldType.gviFieldFID: //case gviFieldType.gviFieldUUID: //case gviFieldType.gviFieldInt16: //case gviFieldType.gviFieldInt32: //case gviFieldType.gviFieldInt64: // break; //case gviFieldType.gviFieldString: // break; //case gviFieldType.gviFieldDate: default: DataRow dr = this._dt.NewRow(); dr["FN"] = string.IsNullOrEmpty(fi.Alias) ? fi.Name : fi.Alias; dr["FV"] = null; dr["F"] = fi; this._dt.Rows.Add(dr); break; } } } else { List <DFDataConfig.Class.FieldInfo> list = fac.FieldInfoCollection; if (list != null) { foreach (DFDataConfig.Class.FieldInfo fi1 in list) { if (!fi1.CanQuery) { continue; } int index = fiCol.IndexOf(fi1.Name); if (index == -1) { continue; } IFieldInfo fi = fiCol.Get(index); if (fi == null) { continue; } switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: continue; //case gviFieldType.gviFieldFloat: //case gviFieldType.gviFieldDouble: // break; //case gviFieldType.gviFieldFID: //case gviFieldType.gviFieldUUID: //case gviFieldType.gviFieldInt16: //case gviFieldType.gviFieldInt32: //case gviFieldType.gviFieldInt64: // break; //case gviFieldType.gviFieldString: // break; //case gviFieldType.gviFieldDate: default: DataRow dr = this._dt.NewRow(); dr["FN"] = fi1.ToString(); dr["FV"] = null; dr["F"] = fi; this._dt.Rows.Add(dr); break; } } } } } catch (Exception ex) { } }
public override void Run(object sender, EventArgs e) { try { app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } this._geoFact = new GeometryFactory(); Map3DCommandManager.Push(this); DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc != null) { this._facType = dffc.GetFacilityClassName(); _strGeometryFieldName = ""; if (this._facType == "PipeLine" || this._facType == "PipeNode" || this._facType == "PipeBuild" || this._facType == "PipeBuild1") { _strGeometryFieldName = "Shape"; } else { IFeatureLayer fl = dffc.GetFeatureLayer(); if (fl != null) { _strGeometryFieldName = fl.GeometryFieldName; } } if (!string.IsNullOrEmpty(_strGeometryFieldName)) { IFeatureClass fc = dffc.GetFeatureClass(); if (fc != null) { IFieldInfoCollection fiCol = fc.GetFields(); int index = fiCol.IndexOf(_strGeometryFieldName); if (index != -1) { IFieldInfo fi = fiCol.Get(index); if (fi.GeometryDef != null) { this._geoType = fi.GeometryDef.GeometryColumnType; } } } switch (this._geoType) { case gviGeometryColumnType.gviGeometryColumnModelPoint: //添加方式:1、鼠标添加;2、文件添加 FrmInsertModel dlg = new FrmInsertModel(); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string filePath = dlg.FilePath; string ext = Path.GetExtension(filePath); if (File.Exists(filePath)) { int insertType = dlg.InsertType; if (insertType == 0 && ext.ToLower() == ".osg") { this._drawTool = DrawToolService.Instance.CreateDrawTool(DrawType._3DModel); if (this._drawTool != null) { (this._drawTool as Draw3DModel).Set3DModelFilePath(filePath); this._drawTool.OnStartDraw += new OnStartDraw(this.OnStartDraw); this._drawTool.OnFinishedDraw += new OnFinishedDraw(this.OnFinishedDraw); this._drawTool.Start(); } } else if (insertType == 1 && ext.ToLower() == ".xml") { } } } break; case gviGeometryColumnType.gviGeometryColumnPoint: if (this._facType == "PipeNode") { // 添加附属设施或者管点 } else { // 添加点 this._drawTool = DrawToolService.Instance.CreateDrawTool(DrawType.Point); if (this._drawTool != null) { this._drawTool.OnStartDraw += new OnStartDraw(this.OnStartDraw); this._drawTool.OnFinishedDraw += new OnFinishedDraw(this.OnFinishedDraw); this._drawTool.Start(); } } break; case gviGeometryColumnType.gviGeometryColumnPolyline: if (this._facType == "PipeLine" || this._facType == "PipeBuild" || this._facType == "PipeBuild1") { // 选择管线或辅助样式 } else { // 添加线 this._drawTool = DrawToolService.Instance.CreateDrawTool(DrawType.Polyline); if (this._drawTool != null) { this._drawTool.OnStartDraw += new OnStartDraw(this.OnStartDraw); this._drawTool.OnFinishedDraw += new OnFinishedDraw(this.OnFinishedDraw); this._drawTool.Start(); } } break; case gviGeometryColumnType.gviGeometryColumnPolygon: if (this._facType == "PipeBuild" || this._facType == "PipeBuild1") { // 选择管线辅助样式 } else { // 添加面 this._drawTool = DrawToolService.Instance.CreateDrawTool(DrawType.Polygon); if (this._drawTool != null) { this._drawTool.OnStartDraw += new OnStartDraw(this.OnStartDraw); this._drawTool.OnFinishedDraw += new OnFinishedDraw(this.OnFinishedDraw); this._drawTool.Start(); } } break; default: return; } } } } catch (Exception ex) { } finally { } }
private void AddGeometry() { try { this.beforeRowBufferMap.Clear(); SelectCollection.Instance().Clear(); DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } IFieldInfoCollection fields = fc.GetFields(); int indexGeo = fields.IndexOf(this._strGeometryFieldName); if (indexGeo == -1) { return; } IGeometry geo = this._drawTool.GetGeo(); IGeometry geoOut = null; switch (geo.GeometryType) { case gviGeometryType.gviGeometryModelPoint: geoOut = geo; break; case gviGeometryType.gviGeometryPoint: IPoint pt = geo as IPoint; IPoint pt1 = pt.Clone2(gviVertexAttribute.gviVertexAttributeZM) as IPoint; pt1.SetCoords(pt.X, pt.Y, pt.Z, 0, 0); geoOut = pt1; break; case gviGeometryType.gviGeometryPolyline: IPolyline line = geo as IPolyline; IPolyline line1 = this._geoFact.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZM) as IPolyline; for (int i = 0; i < line.PointCount; i++) { IPoint ptGet = line.GetPoint(i); IPoint pttemp = ptGet.Clone2(gviVertexAttribute.gviVertexAttributeZM) as IPoint; pttemp.SetCoords(ptGet.X, ptGet.Y, ptGet.Z, 0, 0); line1.AppendPoint(pttemp); } geoOut = line1; break; case gviGeometryType.gviGeometryPolygon: IPolygon polygon = geo as IPolygon; IPolygon polygon1 = this._geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZM) as IPolygon; for (int i = 0; i < polygon.ExteriorRing.PointCount; i++) { IPoint ptGet = polygon.ExteriorRing.GetPoint(i); IPoint pttemp = ptGet.Clone2(gviVertexAttribute.gviVertexAttributeZM) as IPoint; pttemp.SetCoords(ptGet.X, ptGet.Y, ptGet.Z, 0, 0); polygon1.ExteriorRing.AppendPoint(pttemp); } geoOut = polygon1; break; } if (geoOut == null) { return; } if (geo.GeometryType == gviGeometryType.gviGeometryModelPoint) { //导入模型到数据库中 string mn = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant(); IModelPoint mp = geoOut as IModelPoint; bool bRes = this.ImportOsg(mn, mp.ModelName); if (!bRes) { return; } mp.ModelName = mn; geoOut = mp; } IRowBufferCollection rowCol = new RowBufferCollection(); IRowBufferFactory fac = new RowBufferFactory(); IRowBuffer row = fac.CreateRowBuffer(fields); row.SetValue(indexGeo, geoOut); rowCol.Add(row); beforeRowBufferMap[featureClassInfo] = rowCol; } catch (Exception ex) { } }
private void treelist_AfterCheckNode(object sender, NodeEventArgs e) { this.teValue.Text = ""; this.listBoxControlValues.Items.Clear(); if (string.IsNullOrEmpty(this._sysFieldName)) { return; } IFdeCursor cursor = null; IRowBuffer row = null; try { WaitForm.Start("正在加载列表...", "请稍后"); HashSet <string> list = new HashSet <string>(); bool bBreak = false; foreach (TreeListNode node in this.treelist.GetAllCheckedNodes()) { object obj = node.GetValue("NodeObject"); if (obj != null && obj is SubClass) { SubClass sc = obj as SubClass; if (sc.Parent == null) { continue; } string cacheType = sc.Parent.Name + "_" + sc.GroupId + "_3D_" + this._sysFieldName; object objCache = CacheHelper.GetCache(cacheType); if (objCache != null && objCache is HashSet <string> ) { HashSet <string> temphs = objCache as HashSet <string>; foreach (string tempstr in temphs) { list.Add(tempstr); } continue; } HashSet <string> listsc = new HashSet <string>(); string[] arrFc3DId = sc.Parent.Fc3D.Split(';'); if (arrFc3DId == null) { continue; } foreach (string fc3DId in arrFc3DId) { DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId); if (dffc == null) { continue; } FacilityClass facClass = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facClass == null || facClass.Name != this._facType) { continue; } DFDataConfig.Class.FieldInfo fi = facClass.GetFieldInfoBySystemName(this._sysFieldName); if (fi == null) { continue; } IFieldInfoCollection fiCol = fc.GetFields(); int index = fiCol.IndexOf(fi.Name); if (index < 0) { continue; } Gvitech.CityMaker.FdeCore.FieldInfo gfi = (Gvitech.CityMaker.FdeCore.FieldInfo)fiCol.Get(index); IQueryFilter filter = new QueryFilter(); filter.SubFields = gfi.Name; filter.ResultBeginIndex = 0; filter.ResultLimit = 1; while (true) { string strTempClause = gfi.Name + " is not null and "; string fClause = strTempClause; foreach (string strtemp in listsc) { fClause += gfi.Name + " <> " + strtemp + " and "; } fClause = fClause.Substring(0, fClause.Length - 5); filter.WhereClause = "GroupId = " + sc.GroupId + " and " + fClause; cursor = fc.Search(filter, true); if ((row = cursor.NextRow()) != null) { if (row.IsNull(0)) { break; } object temp = row.GetValue(0); string strtemp = ""; switch (gfi.FieldType) { case gviFieldType.gviFieldFID: case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: case gviFieldType.gviFieldInt16: case gviFieldType.gviFieldInt32: case gviFieldType.gviFieldInt64: strtemp = temp.ToString(); break; case gviFieldType.gviFieldDate: case gviFieldType.gviFieldString: case gviFieldType.gviFieldUUID: strtemp = "'" + temp.ToString() + "'"; break; case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: default: continue; } if (temp != null) { list.Add(strtemp); listsc.Add(strtemp); if (list.Count > 10) { bBreak = true; break;// 列举10个 } } } else { break; } } if (bBreak) { break; } } CacheHelper.SetCache(cacheType, listsc); } if (bBreak) { break; } } foreach (string str2 in list) { //if (!(string.IsNullOrEmpty(str2))) //{ this.listBoxControlValues.Items.Add(str2); //} } } catch (Exception ex) { } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } WaitForm.Stop(); } }