void OnBeforeStopParcelEditing() { if (m_ParcelEditHelperExt.RecordToField) { return; } IParcelConstruction4 pTrav = (IParcelConstruction4)m_pParcEditorMan.ParcelConstruction; IEnumGSLines pGSLines = pTrav.GetLines(false, false); pGSLines.Reset(); IGSLine pGSLine = null; IGSParcel pGSParcel = null; pGSLines.Next(ref pGSParcel, ref pGSLine); while (pGSLine != null) { IGSAttributes pLineAtts = (IGSAttributes)pGSLine; double brgRecord = Convert.ToDouble(pGSLine.Bearing); brgRecord = brgRecord * 180 / Math.PI; pLineAtts.SetProperty(m_ParcelEditHelperExt.FieldName, brgRecord); //pGSParcel.Modified(); pGSLines.Next(ref pGSParcel, ref pGSLine); } pTrav.UpdateGridFromGSLines(true, false); }
object OnGridCellEdit(ref int row, ref int col, ref object inValue) { string m_sFieldName = m_ParcelEditHelperExt.FieldName; bool m_bRecordFieldName = m_ParcelEditHelperExt.RecordToField; object OutValue = inValue; if (col == 2 && m_bRecordFieldName)//this is the bearing field { IParcelConstruction pTrav = (IParcelConstruction)m_pParcEditorMan.ParcelConstruction; IGSLine pGSLine = null; bool IsCompleteLine = (pTrav.GetLine(row, ref pGSLine)); //true means it's a complete line //false means it's a partial line //note that the type of the inValue must be honoured when returning the value from this function, in this case we are rebuilding the string for the same value, unaltered. //however the other relevant work done is to set the record field to the same value to capture what was entered prior to resequencing and potential bearing changes. //this happens either for a complete line or a partial one //The logic could be changed to be more conservative and only capture the record for a partial line (IsCompleteLine==false), since that would only record the first time it's cogo'd, //compared to this code that records edits of completed lines *as well as* partial lines IAngularConverter pAngConv = new AngularConverterClass(); string sBear = Convert.ToString(inValue); sBear = sBear.Replace("°", "-"); sBear = sBear.Replace("'", "-"); sBear = sBear.Replace("\"", ""); if (!pAngConv.SetString(sBear, esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds)) //TODO: base this on Plan properties { return(OutValue); } double brgRecord = pAngConv.GetAngle(esriDirectionType.esriDTNorthAzimuth, esriDirectionUnits.esriDUDecimalDegrees); sBear = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); IParcelConstruction4 pTrav4 = pTrav as IParcelConstruction4; pTrav4.UpdateGridFromGSLines(true, false); sBear = sBear.Replace(" ", ""); sBear = sBear.Insert(sBear.Length - 1, "\""); int i = sBear.LastIndexOf('-'); sBear = sBear.Insert(i, "'"); i = sBear.IndexOf('-'); sBear = sBear.Insert(i, "°"); sBear = sBear.Replace("-", ""); IGSAttributes pLineAtts = (IGSAttributes)pGSLine; pLineAtts.SetProperty(m_sFieldName, sBear); return(sBear); //note that the type of the inValue must be honoured when returning the value from this function. } return(OutValue); }