public MyClass() { MyEditor.EditStarting += OnEditStarting; MyEditor.EditCompleted += OnEditCompleted; } private void OnEditStarting(object sender, Editor.EditEventArgs e) { if (!IsEditAllowed(e.Graphic)) { e.Cancel = true; } else { ... } } private void OnEditCompleted(object sender, Editor.EditEventArgs e) { ... } private bool IsEditAllowed(Graphic graphic) { ... }
if (MyEditor.CancelActive.CanExecute(null)) MyEditor.CancelActive.Execute(null);
private void FeatureLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e) { bool canEdit = IsEditAllowed(e.Graphic); if (canEdit && MyEditor.EditVertices.CanExecute(e.Graphic)) MyEditor.EditVertices.Execute(e.Graphic); }
If you need to perform check on the graphic before EditVertices command is activated, you can activate EditVertices in code-behind instead.private void FeatureLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e) { bool canEdit = IsEditAllowed(e.Graphic); if (canEdit && MyEditor.EditVertices.CanExecute(e.Graphic)) MyEditor.EditVertices.Execute(e.Graphic); }
If CommandParameter is a graphic, then EditVertices will act only on the specified graphic (Points are not supported in this case).
The only operation you can really do with point geometry is to move them. This is why Editor.EditVertices does not make sense to activate on a graphic with point geometry.
What you can do is only activate EditVertices for polyline and polygon geometries. And handle the move on point geometries by providing offset to its X,Y values using MouseMove and MouseLeftButtonUp events or you can listen to the next MouseClick that sets the new location of the point geometry.