Show/Hide Toolbars

Therefore Programming Interface 3.0

The context menu for the result list in Thereforeā„¢ Navigator can be customized. In addition a further button can be added to the ribbon which will appear in the Add-ins tab. In the example below we simply display a message box with index data for each selected document (result row).

 

Requirements and Assumptions:

bullet AddIn project configured and registered as described in "AddIn Creation in C#" or "Add In Creation in VB .NET".

Visual Basic

Imports System.Runtime.InteropServices

Imports System.IO

Imports System.Windows.Forms

Imports Therefore.API

 

<Guid("F5AAD35E-C2D8-49a1-A026-7140E0D96EBE"), ComVisible(True), ClassInterface(ClassInterfaceType.None)> _

Public Class NavigatorContextMenuAddIn

    Implements ITheAddIn

 

    Public Sub GetHandledEvents(ByVal clientType As TheClientType, ByVal eventSet As TheEventSet) Implements ITheAddIn.GetHandledEvents

        If (clientType = TheClientType.NavigatorClient) Then

            eventSet.Add(TheEventType.InitContextMenu)

            eventSet.Add(TheEventType.ContextMenuClick)

        End If

    End Sub

 

    Public Function HandleEvent(ByVal e As TheEvent) As Integer Implements ITheAddIn.HandleEvent

        Select Case (e.EventType)

            Case TheEventType.InitContextMenu

                ' Insert a new entry into the help menu

                e.Menu.AddSeparator()

                e.Menu.Add("&Show index data message box", 1)

                Return 0

            Case TheEventType.ContextMenuClick

                If (e.Menu.ID = 1) Then

                    For Each ix As TheIndexData In e.IndexDataList

                        MessageBox.Show(ix.ToString)

                    Next

                End If

                Return 0

        End Select

        Return -1 ' This should never happen; returning -1 unregisters the incoming event type

    End Function

 

End Class

C#

using System;

using System.Runtime.InteropServices;

using System.Windows.Forms;

using Therefore.API;

 

namespace AddInSamples

{

    [Guid("F8ABAB84-D2AF-4fde-A0C4-82D8F753CC2E"), ComVisible(true), ClassInterface(ClassInterfaceType.None)]

    public class NavigatorContextMenuAddIn : ITheAddIn

    {

        public void GetHandledEvents(TheClientType clientType, TheEventSet eventSet)

        {

            if (clientType == TheClientType.NavigatorClient)

            {

                eventSet.Add(TheEventType.InitContextMenu);

                eventSet.Add(TheEventType.ContextMenuClick);

            }

        }

 

        public int HandleEvent(TheEvent e)

        {   

            switch (e.EventType)

            {

                case TheEventType.InitContextMenu:

                    // Insert a new entry into the help menu

                    e.Menu.AddSeparator();

                    e.Menu.Add("&Show index data message box"1);

                    return 0;

 

                case TheEventType.ContextMenuClick:

                    if (e.Menu.ID == 1// If our menu item was clicked

                    {

                        foreach (TheIndexData ix in e.IndexDataList)

                            MessageBox.Show(ix.ToString());

                    }

                    return 0;

 

            }

            return -1// This should never happen; returning -1 unregisters the incoming event type

        }

    }

}

 

 

Ā© 2022 Therefore Corporation, all rights reserved.