Create C# class with Visual Studio
- Open your project in Visual Studio
- Select your project and click on
- Add -> New Item...
- Select Visual C# Items -> Class
- Rename your class here with MyCommandWithRibbonControl
Click OK.
Create a new Ribbon button Command
To create a new command, derive your MyCommandWithRibbonControl class from the AbstractRibbonCommand interface.
To use these interfaces see the Add-in sample in C# with a specialized library. sample.
public class MyCommandWithRibbonControl : AbstractRibbonCommand
{
public override string CommandName => "MySuperCommandWithRibbonControl";
protected override string RibbonTabSelector => "MyRibbonTab";
protected override string RibbonGroupSelector => "MyRibbonGroup";
protected override string ControlCaption => "MyCommand";
protected override string ControlImagePath => EmbeddedResourceExtractor.ExtractResourceFileInApplicationTemp("Sample.Resources.myImage.ico");
public override EwErrorCode execute(EwCommandContextX commandContextX)
{
AddinContainer.Get<Logger>()?.Info()
.Message("Called from command with ribbon control")
.Write();
}
public override string getDescription(out
EwErrorCode errorCode)
{
return "My description";
}
}
- Note
- mEwApplicationX: application object previously created.