Created
December 15, 2017 18:34
-
-
Save stdavis/78012b026f960c92c9578127d525129a to your computer and use it in GitHub Desktop.
SetOnUndone & SetOnRedone - What am I doing wrong?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void AddSelectedToTemp() | |
{ | |
QueuedTask.Run(() => | |
{ | |
using (FeatureClass tempSegsFC = TempSegmentsLayer.GetFeatureClass()) | |
using (RowCursor segmentsCursor = SegmentsLayer.GetSelection().Search((QueryFilter)null, false)) | |
{ | |
EditOperation operation = new EditOperation(); | |
operation.Name = "add selected to temp segments"; | |
bool newPartCreated = false; | |
operation.Callback(context => | |
{ | |
while (segmentsCursor.MoveNext()) | |
{ | |
string id = GetUSNGID_Line(segmentsCursor.Current); | |
RowBuffer tempRowBuf = CopyRowValues(segmentsCursor.Current, tempSegsFC); | |
tempRowBuf["USNG_SEG"] = id; | |
if (tempSegmentIDs.Contains(id)) | |
{ | |
currentPart++; | |
tempSegmentIDs.Clear(); | |
newPartCreated = true; | |
} | |
tempSegmentIDs.Add(id); | |
tempRowBuf["RoutePart"] = currentPart; | |
tempSegsFC.CreateRow(tempRowBuf); | |
tempRowBuf.Dispose(); | |
} | |
context.Invalidate(tempSegsFC); | |
}, tempSegsFC); | |
if (newPartCreated) | |
{ | |
// NOT WORKING ref: https://community.esri.com/message/733381-re-examples-for-setonundone-setonredone-setoncomitted?commentID=733381#comment-733381 | |
operation.SetOnUndone(() => | |
{ | |
currentPart--; | |
}); | |
operation.SetOnRedone(() => | |
{ | |
currentPart++; | |
}); | |
} | |
bool success = operation.Execute(); | |
if (success) | |
{ | |
SegmentsLayer.ClearSelection(); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment