Tekla Open API

Detailed and full API reference helps you master Tekla Open API

This is the most recent version of Tekla Open API.
For older versions, please visit Tekla Warehouse.

Events Class

The Events class allows the user to register event listeners for drawing user interface events.
Inheritance Hierarchy

Namespace:  Tekla.Structures.Drawing.UI
Assembly:  Tekla.Structures.Drawing (in Tekla.Structures.Drawing.dll) Version: 2019.0.0.0 (2019.0.0.0)
Syntax
[SerializableAttribute]
public sealed class Events : MarshalByRefObject

The Events type exposes the following members.

Constructors
  Name Description
Public method Events
Constructs a new instance of Events.
Top
Methods
  Name Description
Public method InitializeLifetimeService
Initializes the lifetime service.
(Overrides MarshalByRefObjectInitializeLifetimeService.)
Public method OnInterrupted
Called when uesr interrupts.
Public method Register
Registers the instance to listen to the specified events.
Public method UnRegister
Unregisters the instance from listening to events.
Top
Events
  Name Description
Public event DrawingEditorClosed
The DrawingEditorClosed event is raised when the drawing editor is closed.
Public event DrawingEditorOpened
The DrawingEditorOpened event is raised when the drawing editor is opened.
Public event DrawingListSelectionChanged
The DrawingListSelectionChanged event is raised when selection on the drawing list has changed.
Public event DrawingLoaded
The DrawingLoaded event is raised when a new drawing is opened in the drawing editor.
Public event Interrupted
Occurs when user interrupts.
Public event SelectionChange
The SelectionChange event is raised when the selection is changed in a Tekla Structures drawing.
Top
Remarks
Asynchronous event handling

Registered event handlers are called asynchronously so that many handlers may be running simultaneously. Event handlers are not guaranteed to be run in the same thread where they were registered. The asynchronous nature of the events requires the use of synchronization constructs on objects and data structures that are not defined to be thread safe.

  • Microsoft's documentation about the lock statement: http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx
  • Microsoft's documentation about delegates: http://msdn.microsoft.com/en-us/library/900fyy8e.aspx
  • Microsoft's documentation about managed threading: http://msdn.microsoft.com/en-us/library/1c9txz50.aspx
Examples
The following example shows how to make sure that only one selection event handler is running at a time.
using Tekla.Structures.Drawing;
using Tekla.Structures.Drawing.UI;

public class Example
{
    private Tekla.Structures.Drawing.UI.Events _events = new Tekla.Structures.Drawing.UI.Events();
    private object _selectionEventHandlerLock = new object();

    public void RegisterEventHandler()
    {
        _events.SelectionChange += Events_SelectionChangeEvent;
        _events.Register();
    }

    public void UnRegisterEventHandler()
    {
        _events.UnRegister();
    }

    void Events_SelectionChangeEvent()
    {
        /* Make sure that the inner code block is running synchronously */
        lock(_selectionEventHandlerLock)
        {
            System.Console.WriteLine("Selection changed event received.");
        }
    }
}
See Also