Document Events |
Scroll |
Requirements and Assumptions: 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("134AE7FE-0BD6-4d06-AE85-CE5D65651D54"), ComVisible(True), ClassInterface(ClassInterfaceType.None)> _ Public Class DocEventAddIn Implements ITheAddIn
Public Sub GetHandledEvents(ByVal client As TheClientType, ByVal eventSet As TheEventSet) Implements ITheAddIn.GetHandledEvents eventSet.Add(TheEventType.RetrieveDocument) eventSet.Add(TheEventType.DocumentRetrieved) End Sub
Public Function HandleEvent(ByVal e As TheEvent) As Integer Implements ITheAddIn.HandleEvent If (e.EventType = TheEventType.RetrieveDocument) Then ' RetrieveDocument occurs BEFORE the document is being retrieved ' Ask the user if he/she really wants to retrieve it Dim result As DialogResult = MessageBox.Show("Do you really want to retrieve the document from Thereforeā¢?", "Retrieve Document", MessageBoxButtons.YesNo) If (result = DialogResult.Yes) Then Return 0 ElseIf (result = DialogResult.No) Then Return 1 End If ElseIf (e.EventType = TheEventType.DocumentRetrieved) Then ' DocumentRetrieved occurs AFTER the document has been retrieved ' Display a success message MessageBox.Show("Document successfully retrieved from Thereforeā¢.") End If Return 0 End Function
End Class C# using System; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; using Therefore.API;
namespace AddInSamples { [Guid("FCEA7BD5-8537-49d2-85ED-FAE09ABF1A64"), ComVisible(true), ClassInterface(ClassInterfaceType.None)] public class DocEventAddIn : ITheAddIn { public void GetHandledEvents(TheClientType client, TheEventSet eventSet) { eventSet.Add(TheEventType.RetrieveDocument); eventSet.Add(TheEventType.DocumentRetrieved); }
public int HandleEvent(TheEvent e) { // RetrieveDocument occurs BEFORE the document is being retrieved // Ask the user if he/she really wants to retrieve it if (e.EventType == TheEventType.RetrieveDocument) { DialogResult result = MessageBox.Show("Do you really want to retrieve the document from Thereforeā¢?", "Retrieve Document", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) return 0; else if (result == DialogResult.No) return 1; } // DocumentRetrieved occurs AFTER the document has been retrieved // Display a success message else if (e.EventType == TheEventType.DocumentRetrieved) { MessageBox.Show("Document successfully retrieved from Thereforeā¢."); }
return 0; } } } |