ArcObjects Library Reference  

AcmeMenu

About the Applying user interface customizations at startup Sample

[C#]

AcmeMenu.cs

using System;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.ADF.CATIDs;

namespace ACME.GIS.SampleExt
{
  [Guid("A7198661-605D-4683-A282-221C154450A1")]
  [ClassInterface(ClassInterfaceType.None)]
  [ProgId("ACME.MainMenu")]
  public class AcmeMenu : IMenuDef, IRootLevelMenu
  {
    #region IMenuDef Members

    public string Caption
    {
      get
      {
        return "ACME";
      }
    }

    public void GetItemInfo(int pos, IItemDef itemDef)
    {
      // Add some commands to the menu (don't really exists for simplicity sake)
      switch (pos)
      {
        case 0:
          itemDef.ID = "ACME.SomeCmd";
          itemDef.Group = false;
          break;
        case 1:
          itemDef.ID = "ACME.SomeCmd2";
          itemDef.Group = true;
          break;
      }
    }

    public int ItemCount
    {
      get { return 2; }
    }

    public string Name
    {
      get { return "ACME Main Menu"; }
    }

    #endregion
  }
}

[Visual Basic .NET]

AcmeMenu.vb

Imports System 
Imports System.Runtime.InteropServices 
Imports ESRI.ArcGIS.Framework 
Imports ESRI.ArcGIS.SystemUI 
Imports ESRI.ArcGIS.ADF.CATIDs 

Namespace ACME.GIS.SampleExt
  <Guid("527C02BC-2AFB-477d-A5F3-B178F4F7C633")> _
  <ClassInterface(ClassInterfaceType.None)> _
  <ProgId("ACME.MainMenuVB")> _
  Public Class AcmeMenu
    Implements IMenuDef
    Implements IRootLevelMenu
#Region "IMenuDef Members"

    Public ReadOnly Property Caption() As String Implements IMenuDef.Caption
      Get
        Return "ACME"
      End Get
    End Property

    Public Sub GetItemInfo(ByVal pos As Integer, ByVal itemDef As IItemDef) Implements IMenuDef.GetItemInfo
      ' Add some commands to the menu (don't really exists for simplicity sake) 
      Select Case pos
        Case 0
          itemDef.ID = "ACME.SomeCmd"
          itemDef.Group = False
          Exit Select
        Case 1
          itemDef.ID = "ACME.SomeCmd2"
          itemDef.Group = True
          Exit Select
      End Select
    End Sub

    Public ReadOnly Property ItemCount() As Integer Implements IMenuDef.ItemCount
      Get
        Return 2
      End Get
    End Property

    Public ReadOnly Property Name() As String Implements IMenuDef.Name
      Get
        Return "ACME Main Menu"
      End Get
    End Property

#End Region
  End Class
End Namespace