I'm using the inventor APi and I would like to add a custom ribbon button (ribbon item ) to my ribbon Panel , once the user clicks on the button , it should be pressed , and when click on another button it should be pressed and the first button should be released.
How can I achieve this?
private void CreateButtonRibbonPanel(RibbonPanel ribbonPanel, List<CommadProperties> commandButtonPropList)
{
if (ribbonPanel != null && commandButtonPropList.Count > 0)
{
for (int i = 0; i < commandButtonPropList.Count; i++)
{
BtnIndex++;
commandButtonPropList[i].SetProperties();
CreateButtonToSamePanel(ribbonPanel.CommandControls, commandButtonPropList[i].CommandImage, commandButtonPropList[i].CommandName, commandButtonPropList[i].CommandClientId);
}
}
}
private void CreateButtonToSamePanel(CommandControls CmdCtrlsForOnePanel, string ImageName, string DisplayName, string ClientID)
{
if (m_CommandMgr == null || m_CtrlDefs == null || CmdCtrlsForOnePanel == null)
return;
stdole.IPictureDisp standardIconIPictureDisp = null;
if (ImageName.CompareTo("") != 0)
{
string Rooticon = Path.Combine(ResourcesDir, ImageName);
Bitmap standardbitmap = new Bitmap(Rooticon);
standardIconIPictureDisp = PictureDispConverter.ToIPictureDisp(standardbitmap);
}
else
{
standardIconIPictureDisp = null;
}
object vtAddInId = ClientID;
ButtonDef = null;
string InternalName = DisplayName + BtnIndex.ToString();
ButtonDef = m_CtrlDefs.AddButtonDefinition(DisplayName, InternalName, CommandTypesEnum.kQueryOnlyCmdType, vtAddInId, DisplayName, DisplayName,
standardIconIPictureDisp, standardIconIPictureDisp, ButtonDisplayEnum.kDisplayTextInLearningMode);
if (ButtonDef != null)
{
_ButtonDefEvents = new ButtonDefEvents(this, BtnIndex);
CommandControl CmdCtrl = CmdCtrlsForOnePanel.AddButton(ButtonDef, true, true, "", false);
if (CmdCtrl != null)
{
}
}
}
I'm using the inventor APi and I would like to add a custom ribbon button (ribbon item ) to my ribbon Panel , once the user clicks on the button , it should be pressed , and when click on another button it should be pressed and the first button should be released.
How can I achieve this?
private void CreateButtonRibbonPanel(RibbonPanel ribbonPanel, List<CommadProperties> commandButtonPropList)
{
if (ribbonPanel != null && commandButtonPropList.Count > 0)
{
for (int i = 0; i < commandButtonPropList.Count; i++)
{
BtnIndex++;
commandButtonPropList[i].SetProperties();
CreateButtonToSamePanel(ribbonPanel.CommandControls, commandButtonPropList[i].CommandImage, commandButtonPropList[i].CommandName, commandButtonPropList[i].CommandClientId);
}
}
}
private void CreateButtonToSamePanel(CommandControls CmdCtrlsForOnePanel, string ImageName, string DisplayName, string ClientID)
{
if (m_CommandMgr == null || m_CtrlDefs == null || CmdCtrlsForOnePanel == null)
return;
stdole.IPictureDisp standardIconIPictureDisp = null;
if (ImageName.CompareTo("") != 0)
{
string Rooticon = Path.Combine(ResourcesDir, ImageName);
Bitmap standardbitmap = new Bitmap(Rooticon);
standardIconIPictureDisp = PictureDispConverter.ToIPictureDisp(standardbitmap);
}
else
{
standardIconIPictureDisp = null;
}
object vtAddInId = ClientID;
ButtonDef = null;
string InternalName = DisplayName + BtnIndex.ToString();
ButtonDef = m_CtrlDefs.AddButtonDefinition(DisplayName, InternalName, CommandTypesEnum.kQueryOnlyCmdType, vtAddInId, DisplayName, DisplayName,
standardIconIPictureDisp, standardIconIPictureDisp, ButtonDisplayEnum.kDisplayTextInLearningMode);
if (ButtonDef != null)
{
_ButtonDefEvents = new ButtonDefEvents(this, BtnIndex);
CommandControl CmdCtrl = CmdCtrlsForOnePanel.AddButton(ButtonDef, true, true, "", false);
if (CmdCtrl != null)
{
}
}
}
ButtonDefinition.Pressed is your property.
ButtonDefinition.Pressed is your property.
You should manage the property in the buttonDefinition.OnExecute event. With a global variable to store the previous button to unpressed.
If you do not have a OnExecute handler you could try to set the Pressed property in the UserInputEvents.OnActivateCommand event.
You should manage the property in the buttonDefinition.OnExecute event. With a global variable to store the previous button to unpressed.
If you do not have a OnExecute handler you could try to set the Pressed property in the UserInputEvents.OnActivateCommand event.
That's what I did after adding other codes with the using of ButtonDefs OnExecute event, but I'm just search for another solution that is integrated with the Inventor API , what I'm talking about is something like this :
I mean that ribbon buttons will be ribbon items , and it will be have the same behavior of items , Datagrid row ...
That's what I did after adding other codes with the using of ButtonDefs OnExecute event, but I'm just search for another solution that is integrated with the Inventor API , what I'm talking about is something like this :
I mean that ribbon buttons will be ribbon items , and it will be have the same behavior of items , Datagrid row ...
Can't find what you're looking for? Ask the community or share your knowledge.