GetOriginalValue Method (Row)
Gets the original value of a field at the given index.
This method must be called on the MCT. Use QueuedTask.Run.
Determine if Geometry Changed while editing
private static FeatureLayer featureLayer;
private static void DetermineGeometryChange()
{
featureLayer = MapView.Active?.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
if (featureLayer == null)
return;
QueuedTask.Run(() =>
{
//Listen to the RowChangedEvent that occurs when a Row is changed.
ArcGIS.Desktop.Editing.Events.RowChangedEvent.Subscribe(OnRowChangedEvent2, featureLayer.GetTable());
});
}
private static void OnRowChangedEvent2(RowChangedEventArgs args)
{
// RowEvent callbacks are always called on the QueuedTask so there is no need
// to wrap your code within a QueuedTask.Run lambda.
//Get the layer's definition
var lyrDefn = featureLayer.GetFeatureClass().GetDefinition();
//Get the shape field of the feature class
string shapeField = lyrDefn.GetShapeField();
//Index of the shape field
var shapeIndex = lyrDefn.FindField(shapeField);
//Original geometry of the modified row
var geomOrig = args.Row.GetOriginalValue(shapeIndex) as Geometry;
//New geometry of the modified row
var geomNew = args.Row[shapeIndex] as Geometry;
//Compare the two
bool shapeChanged = geomOrig.IsEqual(geomNew);
}
MapSeries_FindPageNumber
//Return the page number that corresponds to the page name field for an index feature
Layout layout = LayoutView.Active.Layout;
//Perform on the worker thread
await QueuedTask.Run(() =>
{
SpatialMapSeries SMS = layout.MapSeries as SpatialMapSeries;
Row msRow = SMS.CurrentRow;
System.Windows.MessageBox.Show(SMS.FindPageNumber(msRow.GetOriginalValue(msRow.FindField("NAME")).ToString()));
});
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.