Hide IEditor.AbortOperation() message box

725
2
01-31-2012 06:01 AM
StefanOffermann
Occasional Contributor II
I am developing an editor extension for ArcMap. The extension should forbid changes to features, which have a attribute value "deny" in a column to restrict any change to the feature. Therefore I check on every OnChangeFeature event if the feature has the attribute value "deny". If this is the case, the change has to be aborted. But when I call IEditor.AbortOperation(), a message box is displayed, for example "The feature(s) could not be moved. Failed to move related features [FeatureClass]" when moving a feature. Is there a way to get rid of that massage box or at least to customize the text?

#region IExtension Implementations

        public void Shutdown()
        {
            _editor = null;
            _editEvents = null;
        }

        public string Name
        {
            get { return "ValidateFeatures_Extension"; }
        }

        public void Startup(ref object initializationData)
        {
            if (initializationData != null && initializationData is IEditor)
            {
                _editor = (IEditor)initializationData;

                //Wire editor events.
                _editEvents = (IEditEvents_Event)_editor;
                _editEvents.OnStartEditing += EditEventsOnStartEditing;
            }
        }

        #endregion

        #region Editor event notification implementation

        private void EditEventsOnStartEditing()
        {
            if (_editor.EditWorkspace.Type == esriWorkspaceType.esriFileSystemWorkspace)
            {
                return;
            }
            _editEvents.OnChangeFeature += EditEventsOnChangeFeature;
            _editEvents.OnCreateFeature += EditEventsOnCreateFeature;
        }


        private void EditEventsOnChangeFeature(IObject obj)
        {
            Validate(obj as IFeature);
        }

        private void EditEventsOnCreateFeature(IObject obj)
        {
            Validate(obj as IFeature);
        }

        #endregion

        private void Validate(IFeature inFeature)
        {
            var fieldIndex = inFeature.Fields.FindField("DENYCHANGES");
            if (fieldIndex < 0)
            {
                return;
            }
            if (inFeature.Value[fieldIndex].Equals("deny"))
            {
                _editor.AbortOperation();
            }
        }
0 Kudos
2 Replies
sapnas
by
Occasional Contributor III
if it is an exception then you could add try/catch block to bypass the message.
0 Kudos
StefanOffermann
Occasional Contributor II
if it is an exception then you could add try/catch block to bypass the message.


It is not an exception. The message box appears, after my code of the "OnChangeFeature" event handler "EditEventsOnChangeFeature" is fully executed. This is why I am not in the control flow anymore.
0 Kudos