public void OnAction(NetOffice.OfficeApi.IRibbonControl control) { try { switch (control.Id) { case "customButton1": MessageBox.Show("This is the first sample button.", "ExtendedAccessCS2.Addin"); break; case "customButton2": MessageBox.Show("This is the second sample button.", "ExtendedAccessCS2.Addin"); break; default: MessageBox.Show("Unkown Control Id: " + control.Id, "ExtendedAccessCS2.Addinn"); break; } } catch (Exception throwedException) { string details = string.Format("{1}{1}Details:{1}{1}{0}", throwedException.Message, Environment.NewLine); MessageBox.Show("An error occured in OnAction." + details, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// The GetContent callback function is called when a DynamicMenu menu is dropped /// </summary> /// <param name="control"> /// The ribbon control that invokes the callback /// </param> /// <returns> /// ribbon XML containing the controls /// </returns> public string GetContent(NetOffice.OfficeApi.IRibbonControl control) { logger.Trace("{0} GetContent", control.Id); try { var content = this.FluentRibbonManager.GetContent(control.Id, control.Tag); return(content); } catch (Exception ex) { logger.Log(LogLevel.Error, ex); } return(string.Empty); }
/// <summary> /// Executes the OnAction callback that is invoked from the <see cref="Office.IRibbonControl"/> /// </summary> /// <param name="control"> /// The ribbon control that invokes the callback /// </param> public async void OnAction(NetOffice.OfficeApi.IRibbonControl control) { logger.Trace("{0} OnAction", control.Id); try { await this.FluentRibbonManager.OnAction(control.Id, control.Tag); } catch (Exception ex) { logger.Log(LogLevel.Error, ex); } if (this.RibbonUI != null) { this.RibbonUI.Invalidate(); } else { logger.Warn("The RibbonUI is null and cannot be invalidated"); } }
/// <summary> /// Executes the GetImage callback that is invoked from the <see cref="Office.IRibbonControl"/> /// </summary> /// <param name="control"> /// The ribbon control that invokes the callback /// </param> /// <returns> /// an image if found, null otherwise /// </returns> public Image GetImage(NetOffice.OfficeApi.IRibbonControl control) { logger.Trace("{0} GetImage", control.Id); return(this.FluentRibbonManager.GetImage(control.Id, control.Tag)); }
/// <summary> /// Executes the GetEnabled callback that is invoked from a Toggle control on the <see cref="Office.IRibbonControl"/> /// </summary> /// <param name="control"> /// The ribbon control that invokes the callback /// </param> /// <returns> /// true if pressed, false if not pressed /// </returns> public bool GetPressed(NetOffice.OfficeApi.IRibbonControl control) { logger.Trace("{0} GetPressed", control.Id); return(this.FluentRibbonManager.GetPressed(control.Id, control.Tag)); }
/// <summary> /// Executes the GetLabel callback that is invoked from the <see cref="Office.IRibbonControl"/> /// </summary> /// <param name="control"> /// The ribbon control that invokes the callback /// </param> /// <returns> /// a string with the content of the label /// </returns> public string GetLabel(NetOffice.OfficeApi.IRibbonControl control) { logger.Trace("{0} GetLabel", control.Id); return(this.FluentRibbonManager.GetLabel(control.Id, control.Tag)); }