0

I am trying to update my custom Ribbon based on the text the user enters in AppointmentItem.Body. I have 2 problems which I cannot resolve: 1.) I can't find an event that reliably is triggered when the user enters text in the Body of the AppointmentItem. I fear that there isn't any event that I can subscribe to. Correct? AppPropertyChange does not work.

2.) I understand that the Ribbon has a link to the ThisAddIn instance. But there should not be a reference from ThisAddIn to the Ribbon in a correct architecture. Therefore even if I managed to find the right event to handle in ThisAddIn I wouldn't be able to call InvalidateUI on the Ribbon because I don't have a link to the Ribbon instance. Correct?

HHeckner
  • 4,722
  • 4
  • 23
  • 33

1 Answers1

0

To your question number 1)

I think there is no event listens to keydown or something else to the AppointmentItem.Body. Can't you better reverse the logic? So that after clicking on the ribbon button you check what's in the appointment?

To your question number 2)

The solution is to get the Ribbon about Globals. Make sure you get access to the ribbon and watch this question on stackoverflow

public partial class ThisAddIn {

  Explorer activeExplorer;

  private void ThisAddIn_Startup(object sender, EventArgs e) {
    this.activeExplorer = this.Application.ActiveExplorer();
    this.activeExplorer.ViewSwitch += new ExplorerEvents_10_ViewSwitchEventHandler(this.ViewSwitch);
  }

  private void ViewSwitch() {
    bool isActive = false;

    try {
      Globals.Ribbons.CalendarRibbon.GroupCalendar.Visible = isActive;
      Globals.Ribbons.CalendarRibbon.ButtonCalendarSync.Visible = isActive;
    } catch (System.Exception ex) {
      // ... catch the exception
    }
  }

}
UfguFugullu
  • 2,107
  • 13
  • 18
  • Reg. Q1: No that is unfortunately not possible. The addin checks whether there are certain keywords contained in the body. And based on that the buttons should be (de-)activated. – HHeckner May 14 '20 at 15:45