31 lines
901 B
C#
31 lines
901 B
C#
using ExcelDna.Integration.CustomUI;
|
|
using ExcelAddIn.Tools;
|
|
|
|
namespace ExcelAddIn.Controllers;
|
|
|
|
public class RibbonController : ExcelRibbon
|
|
{
|
|
public override string GetCustomUI(string ribbonID)
|
|
{
|
|
return @"<customUI xmlns='http://schemas.microsoft.com/office/2006/01/customui'>
|
|
<ribbon>
|
|
<tabs>
|
|
<tab id='MyAddinTab' label='My Addin Tab'>
|
|
<group id='MyAddinGroup' label='My Addin Group'>
|
|
<button id='Button1' label='Button 1' size='large' imageMso='HappyFace' onAction='OnToolPressed'/>
|
|
<button id='Button2' label='Button 2' size='large' imageMso='SadFace' onAction='OnToolPressed'/>
|
|
<button id='Button3' label='Button 3' size='large' imageMso='Piggy' onAction='OnToolPressed'/>
|
|
</group>
|
|
</tab>
|
|
</tabs>
|
|
</ribbon>
|
|
</customUI>";
|
|
}
|
|
|
|
public void OnToolPressed(IRibbonControl control)
|
|
{
|
|
using var tool = ToolFactory.GetTool(control);
|
|
tool.Execute();
|
|
}
|
|
}
|