I am developing in c# using ArcGIS Engine 10.
I created a BaseCommand
class ZoomCommandTest
using BaseCommand
template in Visual Studio 2010 using .Net Framework 3.5
Following is the ZoomCommandTest
class -
/// <summary>
/// Summary description for ZoomCommandTest.
/// </summary>
[Guid("166e3282-95e4-475a-b301-505a88a0a4bb")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Exercise7B.ZoomCommandTest")]
public sealed class ZoomCommandTest : BaseCommand
{
#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);
ControlsCommands.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);
ControlsCommands.Unregister(regKey);
}
#endregion
#endregion
private IHookHelper m_hookHelper;
public ZoomCommandTest()
{
//
// TODO: Define values for the public properties
//
base.m_category = "Map Navigation"; //localizable text
base.m_caption = "Zoom Command Test"; //localizable text
base.m_message = "Zooms to the extent of Layer currently selected in the TOC"; //localizable text
base.m_toolTip = "Zoom Command Test"; //localizable text
base.m_name = "MapNavigation_ZoomCommandTest"; //unique id, non-localizable (e.g. "MyCategory_MyCommand")
try
{
//
// TODO: change bitmap name if necessary
//
string bitmapResourceName = GetType().Name + ".bmp";
base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
}
}
#region Overridden Class Methods
/// <summary>
/// Occurs when this command is created
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
if (hook == null)
return;
if (m_hookHelper == null)
m_hookHelper = new HookHelperClass();
m_hookHelper.Hook = hook;
// TODO: Add other initialization code
}
/// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
// TODO: Add ZoomCommandTest.OnClick implementation
MessageBox.Show("Zoom Command");
}
#endregion
Now, in my MapControl application, I configured the customize dialog box like this -
private void ConfigureCustomizeDialogBox()
{
m_customizeDlg = new CustomizeDialogClass();
m_customizeDlg.ShowAddFromFile = true;
m_customizeDlg.DialogTitle = "Customize Toolbar Items";
m_customizeDlg.SetDoubleClickDestination(toolBarCtrl);
// Sink Events
ICustomizeDialogEvents_Event custDlgEvents = (ICustomizeDialogEvents_Event)m_customizeDlg;
custDlgEvents.OnStartDialog += new ICustomizeDialogEvents_OnStartDialogEventHandler(custDlgEvents_OnStartDialog);
custDlgEvents.OnCloseDialog += new ICustomizeDialogEvents_OnCloseDialogEventHandler(custDlgEvents_OnCloseDialog);
}
Events -
void custDlgEvents_OnCloseDialog()
{
toolBarCtrl.Customize = false;
button1.Enabled = true;
}
void custDlgEvents_OnStartDialog()
{
toolBarCtrl.Customize = true;
button1.Enabled = false;
//ZoomToLayer tool = new ZoomToLayer();
//toolBarCtrl.AddItem(tool, 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconAndText);
}
On toolbar double click, I popup the customize tool bar like this-
m_customizeDlg.StartDialog(toolBarCtrl.hWnd);
But my BaseCommand
class ZoomCommandTest
never show up in the Map Navigation Category.
Am i doing something wrong in here...??
Hope description is clear enough...
Thanks,