Listeners of the OnCreate event are not necessarily notified every time an object is created. The event is triggered following a call to IRow.Store, and by default this does not occur when objects or simple features are created using an insert cursor. This can be overridden by setting the IWorkspaceEditControl.SetStoreEventsRequired property to true, or by implementing the optional IObjectClassInfo interface on the class' extension.
void m_Editor_OnStartEditing() { // Check that the workspace being edited is NCGMP-valid. m_EditWorkspace = m_Editor.EditWorkspace; m_DatabaseIsValid = ncgmpChecks.IsWorkspaceMinNCGMPCompliant(m_EditWorkspace); // I have to do this because the topology tool uses an Insert cursor, bypassing the OnCreate event! IWorkspaceEditControl wsEditControl = (IWorkspaceEditControl)m_EditWorkspace; wsEditControl.SetStoreEventsRequired(); }
using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using ESRI.ArcGIS.ADF.CATIDs; using ESRI.ArcGIS.Editor; using ESRI.ArcGIS.Geodatabase; namespace editorExtension { [Guid("7ec485d2-15af-43e1-ae3f-8c55c93e0317")] [ClassInterface(ClassInterfaceType.None)] [ProgId("editorExtension.ncgmpEditorExtension")] public class ncgmpEditorExtension : ESRI.ArcGIS.esriSystem.IExtension, ESRI.ArcGIS.esriSystem.IExtensionConfig { private Editor m_Editor; private IWorkspace m_EditWorkspace; private bool m_DatabaseIsValid = false; private sysInfo m_SysInfo; #region COM Registration Function(s) [ComRegisterFunction()] [ComVisible(false)] static void RegisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryRegistration(registerType); // // TODO: Add any COM registration code here // } [ComUnregisterFunction()] [ComVisible(false)] static void UnregisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryUnregistration(registerType); // // TODO: Add any COM unregistration code here // } #region ArcGIS Component Category Registrar generated code /// <summary> /// Required method for ArcGIS Component Category registration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryRegistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); EditorExtensions.Register(regKey); } /// <summary> /// Required method for ArcGIS Component Category unregistration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryUnregistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); EditorExtensions.Unregister(regKey); } #endregion #endregion #region "IExtension Implementations - Event Handlers setup here" public string Name { get { return "AZGS/NCGMP Extension"; } } public void Shutdown() { // Remove the event handlers m_Editor.OnCreateFeature -= new IEditEvents_OnCreateFeatureEventHandler(m_Editor_OnCreateFeature); m_Editor.OnChangeFeature -= new IEditEvents_OnChangeFeatureEventHandler(m_Editor_OnChangeFeature); m_Editor.OnDeleteFeature -= new IEditEvents_OnDeleteFeatureEventHandler(m_Editor_OnDeleteFeature); m_Editor.OnStartEditing -= new IEditEvents_OnStartEditingEventHandler(m_Editor_OnStartEditing); m_Editor.OnStopEditing -= new IEditEvents_OnStopEditingEventHandler(m_Editor_OnStopEditing); } public void Startup(ref object initializationData) { // InitializationData contains an IEditor reference because of how this class is registered above. // See http://resources.esri.com/help/9.3/arcgisengine/ArcObjects/esriSystem/IExtension_Startup.htm // Grab the editor reference and setup events to capture m_Editor = (Editor)initializationData; m_Editor.OnCreateFeature += new IEditEvents_OnCreateFeatureEventHandler(m_Editor_OnCreateFeature); m_Editor.OnChangeFeature += new IEditEvents_OnChangeFeatureEventHandler(m_Editor_OnChangeFeature); m_Editor.OnDeleteFeature += new IEditEvents_OnDeleteFeatureEventHandler(m_Editor_OnDeleteFeature); m_Editor.OnStartEditing += new IEditEvents_OnStartEditingEventHandler(m_Editor_OnStartEditing); m_Editor.OnStopEditing += new IEditEvents_OnStopEditingEventHandler(m_Editor_OnStopEditing); } #endregion
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.