protected override void OnClick() { //first check that we are currently editing if (ArcMap.Editor.EditState != esriEditState.esriStateEditing) { MessageBox.Show("Please start editing and try again.", "Sample Code"); return; } //get the cadastral editor ICadastralEditor pCadEd = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension"); //get the fabric line layers that belong to the target fabric. // **SAMPLE CODE NOTE** //This next function allows for more than 1 fabric lines sublayer in the map document, and uses a line layer array //However, this sample code assumes just one line fabric sub layer, and works with the first found //The function is provided for other expanded uses if needed elsewhere. IArray LineLayerArray; if (!GetFabricSubLayers(ArcMap.Document.ActiveView.FocusMap, esriCadastralFabricTable.esriCFTLines, true, pCadEd.CadastralFabric, out LineLayerArray)) { return; } // get the line selection; this code sample uses first line layer for the target fabric (first element) ISelectionSet2 LineSelection = GetSelectionFromLayer(LineLayerArray.get_Element(0) as ICadastralFabricSubLayer); // check to see if there is only one parcel line selected // **SAMPLE CODE NOTE** //This sample code ensures one line feature, although it can be easily adapted for use on //multiple line selection. if (LineSelection.Count != 1) { MessageBox.Show("Please select only one parcel line from the Target fabric.", "Sample Code"); return; } //Get a search cursor from the line selection to get the parcel id //We need to get an edit lock on the parcel using the parcel id //An edit lock will guarantee the edit will persist in a multi-user environment after a reconcile ILongArray pParcelsToLock = new LongArrayClass(); IFIDSet pFIDSetForParcelRegen = new FIDSet(); ICursor pCur; LineSelection.Search(null, false, out pCur); //this cursor returns the selected lines // **SAMPLE CODE NOTE** //setup for potential use for multiple line selection, even though this sample uses a single line selection //get the field indices for line attributes needed. int idxParcelID = pCur.FindField("parcelid"); int idxToPointID = pCur.FindField("topointid"); int idxFromPointID = pCur.FindField("frompointid"); int idxCenterPtId = pCur.FindField("centerpointid"); int idxDistance = pCur.FindField("distance"); int idxRadius = pCur.FindField("radius"); int idxCategory = pCur.FindField("category"); //also need the fabric point table and fields IFeatureClass pFabricPointsFC = (IFeatureClass)pCadEd.CadastralFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPoints); int idxPointX = pFabricPointsFC.FindField("x"); int idxPointY = pFabricPointsFC.FindField("y"); int idxPointCtrPt = pFabricPointsFC.FindField("centerpoint"); var ListFromToPairsForRadialLines = new List <int[]>(); // **SAMPLE CODE NOTE** //setup for potential use for multiple line selection, even though this sample uses a single line selection //the list declared above is here for potential use in Add-ins that make use of multiple circular arc lines int[] ParcelIdCtrPtIdFromId1FromId2; IRow pRow = pCur.NextRow(); while (pRow != null) { int iParcelID = (int)pRow.get_Value(idxParcelID); pParcelsToLock.Add(iParcelID); //LongArray for the parcel locks pFIDSetForParcelRegen.Add(iParcelID); //FIDSet for the parcel regenerate //now check for a center point id on the line; this is for the case of changing the radius of an existing curve object value = pRow.get_Value(idxCenterPtId); if (value != DBNull.Value) { //collecting information to remove radial lines ParcelIdCtrPtIdFromId1FromId2 = new int[4]; // 4-element array ParcelIdCtrPtIdFromId1FromId2[0] = iParcelID; ParcelIdCtrPtIdFromId1FromId2[1] = (int)value; //center point is always the to point of the radial line ParcelIdCtrPtIdFromId1FromId2[2] = (int)pRow.get_Value(idxFromPointID); ParcelIdCtrPtIdFromId1FromId2[3] = (int)pRow.get_Value(idxToPointID); // **SAMPLE CODE NOTE** //now add the array, to the list to accomodate other add-ins that may use //more than one selected circular arc line ListFromToPairsForRadialLines.Add(ParcelIdCtrPtIdFromId1FromId2); } Marshal.ReleaseComObject(pRow); pRow = pCur.NextRow(); } Marshal.ReleaseComObject(pCur); bool IsFileBasedGDB = (ArcMap.Editor.EditWorkspace.WorkspaceFactory.WorkspaceType != esriWorkspaceType.esriRemoteDatabaseWorkspace); if (!IsFileBasedGDB) { //for file geodatabase creating a job is optional //see if parcel locks can be obtained on the selected parcels. First create a job. string NewJobName = ""; if (!CreateJob(pCadEd.CadastralFabric, "Sample Code change line to curve", out NewJobName)) { return; } if (!TestForEditLocks(pCadEd.CadastralFabric, NewJobName, pParcelsToLock)) { return; } } //if we get this far, an edit lock has been acquired, or this is file geodatabase (no lock required) //prompt the user for a new radius value string sRadius = Interaction.InputBox("Enter a new Radius:", "Radius"); //**SAMPLE CODE NOTE** : // using the Interaction class from the Microsfot Visual Basic library // is a quick and easy way to provide an input dialog in a single line of code for sample purposes, // without neeing to add a windows form, dockable window, or other UI elements into this project. double dRadius = 0; if (!Double.TryParse(sRadius, out dRadius)) { return; } //we have a valid double value, so we can get ready to edit IProgressDialogFactory pProgressorDialogFact = new ProgressDialogFactoryClass(); ITrackCancel pTrackCancel = new CancelTracker(); IStepProgressor pStepProgressor = pProgressorDialogFact.Create(pTrackCancel, ArcMap.Application.hWnd); IProgressDialog2 pProgressorDialog = (IProgressDialog2)pStepProgressor; ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)pCadEd.CadastralFabric; try { //turn off the read-only flag on the lines table and points table pSchemaEd.ReleaseReadOnlyFields(LineSelection.Target, esriCadastralFabricTable.esriCFTLines); //release read-only pSchemaEd.ReleaseReadOnlyFields((ITable)pFabricPointsFC, esriCadastralFabricTable.esriCFTPoints); //release read-only //start an edit operation ArcMap.Editor.StartOperation(); //get an update cursor to make the edit on the line(s) LineSelection.Update(null, false, out pCur); pRow = pCur.NextRow(); int iChangeCount = 0; while (pRow != null) { double dChord = (double)pRow.get_Value(idxDistance); if (Math.Abs(dRadius) <= dChord / 2 && dRadius != 0) //minimum allowable radius is half the chord { Marshal.ReleaseComObject(pRow); pRow = pCur.NextRow(); continue; } //compute a center point location from new radius, unless it's 0 int iNewCtrPtId = 0; if (dRadius != 0) { IFeature pFeat = pRow as IFeature; IPoint pCtrPt = ComputeCenterPointFromRadius(pFeat.Shape as IPolyline, dRadius, true); IFeature pNewPointFeat = pFabricPointsFC.CreateFeature(); //**SAMPLE CODE NOTE** : //if adding a large number of points (more than 20) then createfeature is not the fastest approach, //Instead you would pre-allocate points using an insert cursor... //At this point in the code, the normal geodatabase performance considerations apply iNewCtrPtId = pNewPointFeat.OID; pNewPointFeat.set_Value(idxPointX, pCtrPt.X); pNewPointFeat.set_Value(idxPointY, pCtrPt.Y); pNewPointFeat.set_Value(idxPointCtrPt, 1); //1 = true boolean pNewPointFeat.Shape = pCtrPt; pNewPointFeat.Store(); } //get the initial radius if the line is a curve (radius is being updated) object obj = pRow.get_Value(idxRadius); bool bIsChangingFromCurve = (obj != DBNull.Value); //there is a radius value obj = pRow.get_Value(idxCenterPtId); bIsChangingFromCurve = bIsChangingFromCurve && (obj != DBNull.Value); //radius value and Ctr Pt ID exist int iExistingCtrPtId = 0; if (bIsChangingFromCurve) { iExistingCtrPtId = (int)obj; } if (dRadius == 0) //user entered value is zero meaning convert to straight line { //changing to a straight line so set the center point an radius to null pRow.set_Value(idxRadius, DBNull.Value); pRow.set_Value(idxCenterPtId, DBNull.Value); } else if (!bIsChangingFromCurve) //user entered a new radius, and the existing line is not a curve { //changing to a circular arc so set the radius, and set the center point id to the new point's OID pRow.set_Value(idxRadius, dRadius); pRow.set_Value(idxCenterPtId, iNewCtrPtId); } else if (bIsChangingFromCurve) //user entered a radius, and the existing line is a curve { pCur.UpdateRow(pRow); } iChangeCount++; Marshal.ReleaseComObject(pRow); pRow = pCur.NextRow(); } Marshal.ReleaseComObject(pCur); if (iChangeCount == 0) {//if there are no changes then don't add to the edit operation stack ArcMap.Editor.AbortOperation(); return; } if (ListFromToPairsForRadialLines.Count > 0) { IQueryFilter pQuFilter = new QueryFilter(); string sCat = LineSelection.Target.Fields.get_Field(idxCategory).Name; string sToPt = LineSelection.Target.Fields.get_Field(idxToPointID).Name; string sFromPt = LineSelection.Target.Fields.get_Field(idxFromPointID).Name; string sParcelID = LineSelection.Target.Fields.get_Field(idxParcelID).Name; string sInClauseToPts = "("; string sInClauseFromPts = "("; string sInClauseParcelIds = "("; //**SAMPLE CODE NOTE** : //The following In Clause, when contructed for production environments //should take into account the token limit on Oracle database platforms. (<1000) // the processing of the in clause should be broekn into blocks with the in cluase has no more than 1000 elements foreach (int[] iParcelIdCtrPtIdFromId1FromId2 in ListFromToPairsForRadialLines) { if (sInClauseParcelIds.Length == 1) { sInClauseParcelIds += iParcelIdCtrPtIdFromId1FromId2[0].ToString(); } else { sInClauseParcelIds += "," + iParcelIdCtrPtIdFromId1FromId2[0].ToString(); } if (sInClauseToPts.Length == 1) { sInClauseToPts += iParcelIdCtrPtIdFromId1FromId2[1].ToString(); } else { sInClauseToPts += "," + iParcelIdCtrPtIdFromId1FromId2[1].ToString(); } if (sInClauseFromPts.Length == 1) { sInClauseFromPts += iParcelIdCtrPtIdFromId1FromId2[2].ToString(); sInClauseFromPts += "," + iParcelIdCtrPtIdFromId1FromId2[3].ToString(); } else { sInClauseFromPts += "," + iParcelIdCtrPtIdFromId1FromId2[2].ToString(); sInClauseFromPts += "," + iParcelIdCtrPtIdFromId1FromId2[2].ToString(); } } pQuFilter.WhereClause = sCat + " = 4 AND " + sParcelID + " IN " + sInClauseParcelIds + ") AND " + sFromPt + " IN " + sInClauseFromPts + ") AND " + sToPt + " IN " + sInClauseToPts + ")"; LineSelection.Target.DeleteSearchedRows(pQuFilter); } //with the new information added to the line, the rest of the parcel needs to be updated //regenerate the parcel using the parcel fidset ICadastralFabricRegeneration pRegenFabric = new CadastralFabricRegenerator(); #region regenerator enum // enum esriCadastralRegeneratorSetting // esriCadastralRegenRegenerateGeometries = 1 // esriCadastralRegenRegenerateMissingRadials = 2, // esriCadastralRegenRegenerateMissingPoints = 4, // esriCadastralRegenRemoveOrphanPoints = 8, // esriCadastralRegenRemoveInvalidLinePoints = 16, // esriCadastralRegenSnapLinePoints = 32, // esriCadastralRegenRepairLineSequencing = 64, // esriCadastralRegenRepairPartConnectors = 128 // By default, the bitmask member is 0 which will only regenerate geometries. // (equivalent to passing in regeneratorBitmask = 1) #endregion pRegenFabric.CadastralFabric = pCadEd.CadastralFabric; pRegenFabric.RegeneratorBitmask = 7; pRegenFabric.RegenerateParcels(pFIDSetForParcelRegen, false, pTrackCancel); //15 (enum values of 8 means remove orphan points; this only works when doing entire fabric) //TODO: remove orphaned center points programmatically pStepProgressor.MinRange = 0; pStepProgressor.MaxRange = iChangeCount; pStepProgressor.StepValue = 1; pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral; pRegenFabric.RegenerateParcels(pFIDSetForParcelRegen, false, pTrackCancel); ArcMap.Editor.StopOperation("Change line radius"); } catch (Exception ex) { ArcMap.Editor.AbortOperation(); MessageBox.Show(ex.Message); } finally { if (pSchemaEd != null) { pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTPoints); pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTLines); } pStepProgressor = null; if (!(pProgressorDialog == null)) { pProgressorDialog.HideDialog(); } pProgressorDialog = null; RefreshMap(LineLayerArray); ICadastralExtensionManager pCExMan = (ICadastralExtensionManager)pCadEd; IParcelPropertiesWindow2 pPropW = (IParcelPropertiesWindow2)pCExMan.ParcelPropertiesWindow; pPropW.RefreshAll(); //update the TOC IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)(ArcMap.Application.Document); for (int i = 0; i < mxDocument.ContentsViewCount; i++) { IContentsView pCV = (IContentsView)mxDocument.get_ContentsView(i); pCV.Refresh(null); } } }
//public RegistryFindKey() //{ //// '------------4/2/2012 --------------- ////'first get the service pack info to see if this code needs to run ////Dim sAns As String ////Dim bIsSP4 As Boolean = False ////Dim sErr As String = "" ////sAns = RegValue(RegistryHive.LocalMachine, "SOFTWARE\ESRI\Desktop10.0\CoreRuntime", "InstallVersion", sErr) ////bIsSP4 = (sAns = "10.0.4000") ////'also this workaround does not work in Manual Mode ////'check if there is a Manual Mode "modify" job active =========== //} public void SelectCadastralPropertyPage(ICadastralExtensionManager CadastralExtManager, string PageName) { //Set the property page to the lines grid [th] IParcelPropertiesWindow2 pPPWnd2 = (IParcelPropertiesWindow2)CadastralExtManager.ParcelPropertiesWindow; ICadastralEditorPages pPgs = (ICadastralEditorPages)pPPWnd2; ICadastralEditorPage pPg = null; int lPg = 0; for (lPg = 0; lPg <= (pPPWnd2.PageCount - 1); lPg++) { pPg = pPPWnd2.get_Page(lPg); if (pPg.PageName.ToLower() == PageName.ToLower()) { pPgs.SelectPage(pPg); break; } } }
protected override void OnClick() { ICadastralEditor pCadEd = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension"); IParcelEditManager pParcEditorMan = (IParcelEditManager)pCadEd; ICadastralExtensionManager pCadMan = pCadEd as ICadastralExtensionManager; ICadastralPacketManager pCadPacketMan = (ICadastralPacketManager)pCadEd; //bool bStartedWithPacketOpen = pCadPacketMan.PacketOpen; if (!(pCadMan.ContextItem is IGSLine)) { return; } IGSLine pGSLine = pCadMan.ContextItem as IGSLine; if (pParcEditorMan == null) { return; } IEditor pEd = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor"); if (pEd.EditState == esriEditState.esriStateNotEditing) { MessageBox.Show("Please start editing and try again."); return; } IParcelConstruction pConstr = pParcEditorMan.ParcelConstruction; ICadastralLinePoints2Ex pCadLPsEx = pConstr as ICadastralLinePoints2Ex; ILongArray pLngArrBefore = pCadLPsEx.LinePoints; List <int> lstLPBefore = new List <int>(); for (int i = 0; i < pLngArrBefore.Count; i++) { lstLPBefore.Add(pLngArrBefore.get_Element(i)); } //first get the current set of breakpoints Utilities FabUTILS = new Utilities(); FabUTILS.ExecuteCommand("{9987F18B-8CC4-4548-8C41-7DB51F289BB3}"); //Run COTS Breakline command ILongArray pLngArrAfter = pCadLPsEx.LinePoints; List <int> lstLPAfter = new List <int>(); for (int i = 0; i < pLngArrAfter.Count; i++) { lstLPAfter.Add(pLngArrAfter.get_Element(i)); } List <int> lstNewBreakPoints = lstLPAfter.Except(lstLPBefore).ToList(); if (lstNewBreakPoints.Count == 0) { return; } IParcelConstruction4 pConstr4 = pConstr as IParcelConstruction4; ICadastralPoints pCadastralPts = pConstr4 as ICadastralPoints; IEnumCELines pCELines = new EnumCELinesClass(); IEnumGSLines pEnumGSLines = (IEnumGSLines)pCELines; pCELines.Add(pGSLine); //check if it's a construction line or parent line bool bIsParentLine = true; IEnumGSLines pEnumGSConstructionLines = pConstr4.GetLines(false, false); IGSLine pGSTestLine = null; IGSParcel pGSParc = null; pEnumGSConstructionLines.Reset(); pEnumGSConstructionLines.Next(ref pGSParc, ref pGSTestLine); while (pGSTestLine != null) { if ((pGSLine.FromPoint == pGSTestLine.FromPoint) && (pGSLine.ToPoint == pGSTestLine.ToPoint)) { bIsParentLine = false; break; } pEnumGSConstructionLines.Next(ref pGSParc, ref pGSTestLine); } IParcelLineFunctions3 pParcLineFunctions = new ParcelFunctionsClass(); IEnumGSLines pNewLinesEnum = pParcLineFunctions.BreakLinesAtLinePoints(pEnumGSLines, pCadastralPts, true, false); IGSParcel pGSParcel = null; IGSLine pGSNewLine = null; ICadastralUndoRedo pCadUndoRedo = pConstr as ICadastralUndoRedo; pCadUndoRedo.StartUndoRedoSession("Break-line"); pNewLinesEnum.Reset(); pNewLinesEnum.Next(ref pGSParcel, ref pGSNewLine); while (pGSNewLine != null) { pConstr4.InsertGridRow(-1, pGSNewLine, true); pNewLinesEnum.Next(ref pGSParcel, ref pGSNewLine); } ICadastralUnbuildableLines pUnbuildable = pConstr4 as ICadastralUnbuildableLines; if (bIsParentLine) { pUnbuildable.AddLine(pGSLine); } else { pConstr4.Planarize(0.001); //delete the original construction line } pCadUndoRedo.WriteUndoRedoSession(true); }
protected override void OnClick() { IEditor m_pEd = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor"); ICadastralEditor pCadEd = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension"); if (m_pEd.EditState == esriEditState.esriStateNotEditing) { MessageBox.Show("Please start editing first, and try again.", "Start Editing", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } IArray PolygonLyrArr; IMap pMap = m_pEd.Map; ICadastralFabric pCadFabric = null; //if we're in an edit session then grab the target fabric if (m_pEd.EditState == esriEditState.esriStateEditing) { pCadFabric = pCadEd.CadastralFabric; } if (pCadFabric == null) {//find the first fabric in the map MessageBox.Show ("No Parcel Fabric found in the workspace you're editing.\r\nPlease re-start editing on a workspace with a fabric, and try again.", "No Fabric found", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Utilities Utils = new Utilities(); if (!Utils.GetFabricSubLayers(pMap, esriCadastralFabricTable.esriCFTParcels, out PolygonLyrArr)) { return; } //check if there is a Manual Mode "modify" job active =========== ICadastralPacketManager pCadPacMan = (ICadastralPacketManager)pCadEd; if (pCadPacMan.PacketOpen) { MessageBox.Show("The Area Calculation does not work when the parcel is open.\r\nPlease close the parcel and try again.", "Calculate Stated Area", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } IActiveView pActiveView = ArcMap.Document.ActiveView; CalcStatedAreaDLG CalcStatedArea = new CalcStatedAreaDLG(); bool bIsFileBasedGDB = false; bool bIsUnVersioned = false; bool bUseNonVersionedEdit = false; IWorkspace pWS = null; ITable pParcelsTable = null; IProgressDialog2 pProgressorDialog = null; IMouseCursor pMouseCursor = new MouseCursorClass(); pMouseCursor.SetCursor(2); var pTool = ArcMap.Application.CurrentTool; try { IFeatureLayer pFL = (IFeatureLayer)PolygonLyrArr.get_Element(0); IDataset pDS = (IDataset)pFL.FeatureClass; pWS = pDS.Workspace; if (!Utils.SetupEditEnvironment(pWS, pCadFabric, m_pEd, out bIsFileBasedGDB, out bIsUnVersioned, out bUseNonVersionedEdit)) { return; } ICadastralSelection pCadaSel = (ICadastralSelection)pCadEd; IEnumGSParcels pEnumGSParcels = pCadaSel.SelectedParcels;// need to get the parcels before trying to get the parcel count: BUG workaround IFeatureSelection pFeatSel = (IFeatureSelection)pFL; ISelectionSet2 pSelSet = (ISelectionSet2)pFeatSel.SelectionSet; if (pCadaSel.SelectedParcelCount == 0 && pSelSet.Count == 0) { MessageBox.Show("Please select some fabric parcels and try again.", "No Selection", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ArcMap.Application.CurrentTool = null; //Display the dialog DialogResult pDialogResult = CalcStatedArea.ShowDialog(); if (pDialogResult != DialogResult.OK) { return; } m_bShowProgressor = (pSelSet.Count > 10) || pCadaSel.SelectedParcelCount > 10; if (m_bShowProgressor) { m_pProgressorDialogFact = new ProgressDialogFactoryClass(); m_pTrackCancel = new CancelTrackerClass(); m_pStepProgressor = m_pProgressorDialogFact.Create(m_pTrackCancel, ArcMap.Application.hWnd); pProgressorDialog = (IProgressDialog2)m_pStepProgressor; m_pStepProgressor.MinRange = 1; m_pStepProgressor.MaxRange = pCadaSel.SelectedParcelCount * 3; //(3 runs through the selection) m_pStepProgressor.StepValue = 1; pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral; } m_pQF = new QueryFilterClass(); string sPref; string sSuff; ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS; sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix); sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix); //====== need to do this for all the parcel sublayers in the map that are part of the target fabric //pEnumGSParcels should take care of this automatically //but need to do this for line sublayer if (m_bShowProgressor) { pProgressorDialog.ShowDialog(); m_pStepProgressor.Message = "Collecting parcel data..."; } //Add the OIDs of all the selected parcels into a new feature IDSet int tokenLimit = 995; List <int> oidList = new List <int>(); Dictionary <int, string> dict_ParcelSelection2CalculatedArea = new Dictionary <int, string>(); pParcelsTable = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTParcels); pEnumGSParcels.Reset(); IGSParcel pGSParcel = pEnumGSParcels.Next(); while (pGSParcel != null) { //Check if the cancel button was pressed. If so, stop process if (m_bShowProgressor) { if (!m_pTrackCancel.Continue()) { break; } } int iDBId = pGSParcel.DatabaseId; if (!oidList.Contains(iDBId)) { oidList.Add(iDBId); } Marshal.ReleaseComObject(pGSParcel); //garbage collection pGSParcel = pEnumGSParcels.Next(); if (m_bShowProgressor) { if (m_pStepProgressor.Position < m_pStepProgressor.MaxRange) { m_pStepProgressor.Step(); } } } Marshal.ReleaseComObject(pEnumGSParcels); //garbage collection if (m_bShowProgressor) { if (!m_pTrackCancel.Continue()) { return; } } string sSuffixUnit = CalcStatedArea.txtSuffix.Text; int iAreaPrec = (int)CalcStatedArea.numDecPlaces.Value; double dSqMPerUnit = 1; if (CalcStatedArea.cboAreaUnit.FindStringExact("Acres") == CalcStatedArea.cboAreaUnit.SelectedIndex) { dSqMPerUnit = 4046.86; } if (CalcStatedArea.cboAreaUnit.FindStringExact("Hectares") == CalcStatedArea.cboAreaUnit.SelectedIndex) { dSqMPerUnit = 10000; } if (CalcStatedArea.cboAreaUnit.FindStringExact("Square Feet") == CalcStatedArea.cboAreaUnit.SelectedIndex) { dSqMPerUnit = 0.09290304; } if (CalcStatedArea.cboAreaUnit.FindStringExact("Square Feet US") == CalcStatedArea.cboAreaUnit.SelectedIndex) { dSqMPerUnit = 0.09290341; } if (m_bShowProgressor) { pProgressorDialog.ShowDialog(); m_pStepProgressor.Message = "Computing areas..."; } List <string> sInClauseList0 = null; m_pQF = new QueryFilterClass(); if (oidList.Count() > 0) { sInClauseList0 = Utils.InClauseFromOIDsList(oidList, tokenLimit); foreach (string sInClause in sInClauseList0) { m_pQF.WhereClause = pParcelsTable.OIDFieldName + " IN (" + sInClause + ")"; CalculateStatedArea(m_pQF, pParcelsTable, pCadEd, m_pEd.Map.SpatialReference, dSqMPerUnit, sSuffixUnit, iAreaPrec, ref dict_ParcelSelection2CalculatedArea, m_pTrackCancel); if (m_bShowProgressor) { if (!m_pTrackCancel.Continue()) { return; } } } } else { return; } if (m_bShowProgressor) { if (!m_pTrackCancel.Continue()) { return; } } #region Create Cadastral Job //string sTime = ""; //if (!bIsUnVersioned && !bIsFileBasedGDB) //{ // //see if parcel locks can be obtained on the selected parcels. First create a job. // DateTime localNow = DateTime.Now; // sTime = Convert.ToString(localNow); // ICadastralJob pJob = new CadastralJobClass(); // pJob.Name = sTime; // pJob.Owner = System.Windows.Forms.SystemInformation.UserName; // pJob.Description = "Interpolate Z values on selected features"; // try // { // Int32 jobId = pCadFabric.CreateJob(pJob); // } // catch (COMException ex) // { // if (ex.ErrorCode == (int)fdoError.FDO_E_CADASTRAL_FABRIC_JOB_ALREADY_EXISTS) // { // MessageBox.Show("Job named: '" + pJob.Name + "', already exists"); // } // else // { // MessageBox.Show(ex.Message); // } // return; // } //} #endregion //ILongArray pTempParcelsLongArray = new LongArrayClass(); //List<int> lstParcelChanges = Utils.FIDsetToLongArray(m_pFIDSetParcels, ref pTempParcelsLongArray, ref pParcelIds, m_pStepProgressor); if (m_pEd.EditState == esriEditState.esriStateEditing) { try { m_pEd.StartOperation(); } catch { m_pEd.AbortOperation();//abort any open edit operations and try again m_pEd.StartOperation(); } } if (bUseNonVersionedEdit) { if (!Utils.StartEditing(pWS, bIsUnVersioned)) { return; } } //ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)pCadFabric; //pSchemaEd.ReleaseReadOnlyFields(pParcelsTable, esriCadastralFabricTable.esriCFTParcels); int idxParcelStatedArea = pParcelsTable.FindField("STATEDAREA"); string ParcelStatedAreaFieldName = pParcelsTable.Fields.get_Field(idxParcelStatedArea).Name; if (m_bShowProgressor) { // pProgressorDialog.ShowDialog(); m_pStepProgressor.Message = "Updating parcel areas..."; } IRow pTheFeatRow = null; ICursor pUpdateCursor = null; foreach (string sInClause in sInClauseList0) { m_pQF.WhereClause = pParcelsTable.OIDFieldName + " IN (" + sInClause + ")"; if (bUseNonVersionedEdit) { ITableWrite pTableWr = (ITableWrite)pParcelsTable; //used for unversioned table pUpdateCursor = pTableWr.UpdateRows(m_pQF, false); } else { pUpdateCursor = pParcelsTable.Update(m_pQF, false); } pTheFeatRow = pUpdateCursor.NextRow(); while (pTheFeatRow != null) { string sAreaString = dict_ParcelSelection2CalculatedArea[pTheFeatRow.OID]; pTheFeatRow.set_Value(idxParcelStatedArea, sAreaString); pTheFeatRow.Store(); Marshal.ReleaseComObject(pTheFeatRow); //garbage collection if (m_bShowProgressor) { if (!m_pTrackCancel.Continue()) { break; } } pTheFeatRow = pUpdateCursor.NextRow(); } Marshal.ReleaseComObject(pUpdateCursor); //garbage collection if (m_bShowProgressor) { if (!m_pTrackCancel.Continue()) { break; } } } m_pEd.StopOperation("Calculate Stated Area"); //pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTParcels);//set fields back to read-only } catch (Exception ex) { if (m_pEd != null) { AbortEdits(bIsUnVersioned, m_pEd, pWS); } MessageBox.Show(ex.Message); } finally { ArcMap.Application.CurrentTool = pTool; m_pStepProgressor = null; m_pTrackCancel = null; if (pProgressorDialog != null) { pProgressorDialog.HideDialog(); } RefreshMap(pActiveView, PolygonLyrArr); ICadastralExtensionManager pCExMan = (ICadastralExtensionManager)pCadEd; IParcelPropertiesWindow2 pPropW = (IParcelPropertiesWindow2)pCExMan.ParcelPropertiesWindow; pPropW.RefreshAll(); //update the TOC IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)(ArcMap.Application.Document); for (int i = 0; i < mxDocument.ContentsViewCount; i++) { IContentsView pCV = (IContentsView)mxDocument.get_ContentsView(i); pCV.Refresh(null); } // refresh the attributes dialog ISelectionEvents pSelEvents = (ISelectionEvents)m_pEd.Map; pSelEvents.SelectionChanged(); if (bUseNonVersionedEdit) { pCadEd.CadastralFabricLayer = null; PolygonLyrArr = null; } if (pMouseCursor != null) { pMouseCursor.SetCursor(0); } } }