EngineEditor の初期化

ToolbarControlに追加・削除を繰り返す際はEngineEditorはシングルトン クラスを都度開始・終了処理する必要がある。オペレーションスタックがうまく動作しない

//---------------------------------------------------------------------
/// <summary>
/// エディタエクステンションを開始する
/// </summary>
//---------------------------------------------------------------------
protected void startupEngineEditor()
{
    IEngineEditor pEngineEditor;
    IExtension pExtention;
    object pToolbarObject;

    if (pEngineToolbar.CommandPool == null)
    {
        pEngineToolbar.CommandPool = new CommandPoolClass();
    }

    if (pEngineToolbar.OperationStack == null)
    {
        pEngineToolbar.OperationStack = new ControlsOperationStackClass();
    }
    
    System.Type t = Type.GetTypeFromProgID("esriControls.EngineEditor");
    pEngineEditor = CType(Activator.CreateInstance(t), IEngineEditor);

    // ツールバーのUndo,Redoを有効にする
    pEngineEditor.EnableUndoRedo(true);

    // エディタエクステンションの開始
    pToolbarObject = (object)pEngineToolbar;
    pExtention = (IExtension)pEngineEditor;
    pExtention.Startup(ref pToolbarObject);

}


//---------------------------------------------------------------------
/// <summary>
/// エディタエクステンションを終了する
/// </summary>
//---------------------------------------------------------------------
protected void shutdownEngineEditor()
{
    IEngineEditor pEngineEditor;
    IExtension pExtention;

    System.Type t = Type.GetTypeFromProgID("esriControls.EngineEditor");
    pEngineEditor = CType(Activator.CreateInstance(t), IEngineEditor);

    pExtention = (IExtension)pEngineEditor;
    pExtention.Shutdown();
}
'---------------------------------------------------------------------
''' <summary>
''' エディタエクステンションを開始する
''' </summary>
'---------------------------------------------------------------------
Protected Sub startupEngineEditor()
    Dim pEngineEditor As IEngineEditor
    Dim pExtention As IExtension
    Dim pToolbarObject As Object
    
    If pEngineToolbar.CommandPool Is Nothing Then
        pEngineToolbar.CommandPool = New CommandPoolClass()
    End If
    
    If pEngineToolbar.OperationStack Is Nothing Then
        pEngineToolbar.OperationStack = New ControlsOperationStackClass()
    End If
    
    'pEngineEditor = New EngineEditorClass()
    Dim t as System.Type = Type.GetTypeFromProgID("esriControls.EngineEditor")
    pEngineEditor = CType(Activator.CreateInstance(t), IEngineEditor)
    
    ' ツールバーのUndo,Redoを有効にする
    pEngineEditor.EnableUndoRedo(True)
    
    ' エディタエクステンションの開始
    pToolbarObject = DirectCast(pEngineToolbar, Object)
    pExtention = DirectCast(pEngineEditor, IExtension)
    pExtention.Startup(pToolbarObject)
End Sub


'---------------------------------------------------------------------
''' <summary>
''' エディタエクステンションを終了する
''' </summary>
'---------------------------------------------------------------------
Protected Sub shutdownEngineEditor()
    Dim pEngineEditor As IEngineEditor
    Dim pExtention As IExtension
    
    pEngineEditor = New EngineEditorClass()
    
    pExtention = DirectCast(pEngineEditor, IExtension)
    pExtention.Shutdown()
End Sub