summaryrefslogtreecommitdiff
path: root/Controllers/RibbonController.cs
blob: faf855277a95902a505676c9a2ec66e55998d5af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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();	
	}
}