diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2023-06-14 15:23:33 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2023-06-14 15:23:33 +0300 |
commit | 7905d3af4d32405ef041de897bf2d23ee7d6d08e (patch) | |
tree | a51153a14fc394e1c37a3cc7839cf57ac692bb68 /Controllers | |
parent | c29849b19d444956f002a65377610f639c0873e1 (diff) |
Add custom panel and tools
Diffstat (limited to 'Controllers')
-rw-r--r-- | Controllers/RibbonController.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Controllers/RibbonController.cs b/Controllers/RibbonController.cs new file mode 100644 index 0000000..faf8552 --- /dev/null +++ b/Controllers/RibbonController.cs @@ -0,0 +1,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(); + } +} |