About the Configure a command for a specific locale Sample
[C#]
CultureMenu.cs
using ESRI.ArcGIS.ADF.CATIDs;
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Resources;
using System.Reflection;
namespace VBCSharpCultureSample
{
[Guid("37259af4-14ce-4579-b0e4-6a264cd4a6ef")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("VBCSharpCultureSample.CultureMenu")]
public class CultureMenu : ESRI.ArcGIS.SystemUI.IMenuDef
{
#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);
ControlsMenus.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);
ControlsMenus.Unregister(regKey);
}
#endregion
#endregion
#region "IMenuDef Implementations"
public string Caption
{
get
{
//The Caption is set from the 'MenuCaption' string
//stored in the Resource File. The ResourceManager acquires the appropriate
//Resource file according to the UI Culture of the current thread
//system.Windows.Forms.MessageBox.Show(My.Resources.Culture.
ResourceManager rm = new ResourceManager("VBCSharpCultureSample.Resources", Assembly.GetExecutingAssembly());
string m_Resource_str;
m_Resource_str = (string)rm.GetString("MenuCaption");
return (string)m_Resource_str;
}
}
public void GetItemInfo(int pos, ESRI.ArcGIS.SystemUI.IItemDef itemDef)
{
//Adding the Items to the Menu
switch (pos)
{
case 0 :
// Set the item in the menu to the ClassID of multiItem above
itemDef.ID = "esriControlToolsPageLayout.ControlsPageZoomInFixedCommand";
itemDef.Group = false;
break;
case 1 :
//Set the item in the menu to the ClassID of multiItem above
itemDef.ID = "esriControlToolsPageLayout.ControlsPageZoomOutFixedCommand";
itemDef.Group = false;
break;
case 2 :
//Set the item in the menu to the ClassID of multiItem above
itemDef.ID = "esriControlToolsPageLayout.ControlsPageZoomWholePageCommand";
itemDef.Group = false;
break;
case 3 :
//Set the item in the menu to the ClassID of multiItem above
itemDef.ID = "esriControlToolsPageLayout.ControlsPageZoomPageToLastExtentBackCommand";
itemDef.Group = false;
break;
case 4 :
//Set the item in the menu to the ClassID of multiItem above
itemDef.ID = "esriControlToolsPageLayout.ControlsPageZoomPageToLastExtentForwardCommand";
itemDef.Group = false;
break;
}
}
public int ItemCount
{
get
{
return 5;
}
}
public string Name
{
get
{
return "CustomCommands_CultureMenu";
}
}
#endregion
}
}
[Visual Basic .NET]
CultureMenu.vb
Imports System.Runtime.InteropServices
Imports ESRI.ArcGIS.ADF.CATIDs
<ComClass(CultureMenu.ClassId, CultureMenu.InterfaceId, CultureMenu.EventsId)> _
Public NotInheritable Class CultureMenu
Implements ESRI.ArcGIS.SystemUI.IMenuDef
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "ef63d296-6c09-4d74-9475-612083133e3f"
Public Const InterfaceId As String = "18460aa4-c6fc-4176-b1a1-91cd7de5982d"
Public Const EventsId As String = "538eb995-e58d-46df-8774-a0b9dfd5255d"
#End Region
#Region "COM Registration Function(s)"
<ComRegisterFunction(), ComVisibleAttribute(False)> _
Public Shared Sub RegisterFunction(ByVal registerType As Type)
' Required for ArcGIS Component Category Registrar support
ArcGISCategoryRegistration(registerType)
'Add any COM registration code after the ArcGISCategoryRegistration() call
End Sub
<ComUnregisterFunction(), ComVisibleAttribute(False)> _
Public Shared Sub UnregisterFunction(ByVal registerType As Type)
' Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType)
'Add any COM unregistration code after the ArcGISCategoryUnregistration() call
End Sub
#End Region
#Region "ArcGIS Component Category Registrar generated code"
Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type)
Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
ControlsMenus.Register(regKey)
End Sub
Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type)
Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
ControlsMenus.Unregister(regKey)
End Sub
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
Public ReadOnly Property Caption() As String Implements ESRI.ArcGIS.SystemUI.IMenuDef.Caption
Get
'The Caption is set from the 'MenuCaption' string
'stored in the Resource File. The ResourceManager acquires the appropriate
'Resource file according to the UI Culture of the current thread
'system.Windows.Forms.MessageBox.Show(My.Resources.Culture.
Dim pResourceManager As New System.Resources.ResourceManager("VBDotNetCultureSample.Resources", Me.GetType().Assembly)
Dim pResource_str As String
pResource_str = CType(pResourceManager.GetObject("MenuCaption"), String)
Return pResource_str
End Get
End Property
Public Sub GetItemInfo(ByVal pos As Integer, ByVal itemDef As ESRI.ArcGIS.SystemUI.IItemDef) Implements ESRI.ArcGIS.SystemUI.IMenuDef.GetItemInfo
'Adding the Items to the Menu
Select Case pos
Case 0
' Set the item in the menu to the ClassID of multiItem above
itemDef.ID = "esriControlToolsPageLayout.ControlsPageZoomInFixedCommand"
itemDef.Group = False
Case 1
' Set the item in the menu to the ClassID of multiItem above
itemDef.ID = "esriControlToolsPageLayout.ControlsPageZoomOutFixedCommand"
itemDef.Group = False
Case 2
' Set the item in the menu to the ClassID of multiItem above
itemDef.ID = "esriControlToolsPageLayout.ControlsPageZoomWholePageCommand"
itemDef.Group = False
Case 3
' Set the item in the menu to the ClassID of multiItem above
itemDef.ID = "esriControlToolsPageLayout.ControlsPageZoomPageToLastExtentBackCommand"
itemDef.Group = False
Case 4
' Set the item in the menu to the ClassID of multiItem above
itemDef.ID = "esriControlToolsPageLayout.ControlsPageZoomPageToLastExtentForwardCommand"
itemDef.Group = False
End Select
End Sub
Public ReadOnly Property ItemCount() As Integer Implements ESRI.ArcGIS.SystemUI.IMenuDef.ItemCount
Get
'States the number of items in the menu described in GetItemInfo
Return 5
End Get
End Property
Public ReadOnly Property Name() As String Implements ESRI.ArcGIS.SystemUI.IMenuDef.Name
Get
Return "CustomCommands_CultureMenu"
End Get
End Property
End Class