AnsweredAssumed Answered

How to set the command group icons for different commands?

Question asked by Laxman Warpe on May 14, 2020
Latest reply on May 18, 2020 by Artem Taturevych

Hi everyone,

I am adding the icons to the menus and toolbars. The single icon is getting repeated in multiple commands for a single command group. The image is attached here

Here is my code snippet:


SW.ICommandGroup cmdGroup = CmdMgr.CreateCommandGroup2(MainCmdGroupId + (count++), title, toolTip, "", -1, ignorePrevious, ref cmdGroupErr);

string ImageDataPath = "E:\\Laxman Programs\\Test Images";
var playPath = ImageDataPath + @"\play.png";
var seekPath = ImageDataPath + @"\SeekStart.png";
var seekEndpath = ImageDataPath + @"\SeekEnd.png";
var partingpath = ImageDataPath + @"\partingline.png";
var pausePath = ImageDataPath + @"\Pause.png";
var warningPath = ImageDataPath + @"\warning.png";
icons[0] = playPath;
icons[1] = seekPath;
icons[2] = seekEndpath;
cmdGroup.IconList = icons;
// cmdGroup.MainIconList = mainIcons;
cmdIndex0 = cmdGroup.AddCommandItem("Create Layout", locationIndex++, "Create Layout", "Create Layout", 0, "CreateLayout", "EnableCommanMenu", 12);
cmdIndex1 = cmdGroup.AddCommandItem("Identify Elements", locationIndex++, "Identify Elements", "Identify Elements", 1, "IdentifyElements", "EnableCommanAxwMenu", 12);

var materialGroup = CmdMgr.CreateCommandGroup2(MainCmdGroupId + (count++), title + "\\Specify Materials", "Specify Materials", "", locationIndex++, ignorePrevious, ref cmdGroupErr);
icons = new string[3];
icons[0] = partingpath;
icons[1] = pausePath;
icons[2] = warningPath;
materialGroup.IconList = icons;
mtrIndex0 = materialGroup.AddCommandItem("Material 1", -1, "Material 1", "Material1", 0, "EditMaterial", "EnableCommanMenu", 12);
mtrIndex1 = materialGroup.AddCommandItem("Material 2", -1, "Material 2", "Material 2", 1, "EditMaterial", "EnableCommanMenu", 12);

 

 

I am not clear about the ImageListIndex in AddcommandItem. From which list we have to set the index.

Here I am just using the hardcoded paths for images. How to use the bit map images from the project Resource

folder? I am trying to access it by using the Properties.Resource.image but it returns the bitmap and the above lists need the icon paths (string).

Outcomes