ArcGis 10 Sp4 - BaseCommand UpdateBitmap does not change Bitmap on Button

323
1
07-25-2012 10:04 AM
AllenGreaves
New Contributor
Hey,

I've implemented BaseCommand as such (this is just an example class, I'm excluding decorated class attributes)

public class TogglingCommand : BaseCommand
{
    public TogglingCommand()
    {
        m_bitmap = Resources.GenerateCalloutsTrue;
    }

    private bool IsEnabled { get; set; }
    public override void OnClick()
    {
        IsEnabled = !IsEnabled;
        UpdateBitmap( IsEnabled ? Resources.GenerateCalloutsTrue : Resources.GenerateCalloutsFalse );
        base.OnClick();
    }

    public override void OnCreate( object hook )
    {
    }
}


Whenever a click happens then the button's bitmap is supposed to swap to a new bitmap.  However, the bitmap no longer changes.  This functionality worked prior to ArcGis 10.

I re-implemented BaseCommand making my own base class that implements ICommand and I handled updating the bitmap which still did not correct this problem.

Does anyone have any feedback on this issue or has anyone found a work around for it?
0 Kudos
1 Reply
FengZhang2
Occasional Contributor
It looks like a defect. You can try to use the 'ICommandItem.FaceId' method.

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/FaceID_Property/00230000...

In the following code snippet, change the commandBarID to your UID.

      public override void OnClick()
        {           
            IsEnabled = !IsEnabled;

            ICommandBars commandBars = m_application.Document.CommandBars;
            ESRI.ArcGIS.esriSystem.UID commandBarID = new ESRI.ArcGIS.esriSystem.UIDClass();
            commandBarID.Value = "sampleComponent.TogglingCommand";
            ICommandItem commandToolBarItem = commandBars.Find(commandBarID, false, false);
            if (IsEnabled == true)
            {
                commandToolBarItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(Resources.GenerateCalloutsTrue);
            }
            else
            {
                commandToolBarItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(Resources.GenerateCalloutsFalse);
            }
            commandToolBarItem.Refresh();
        }
0 Kudos