Skip to content

Working with EventLogger

harborsiem edited this page Apr 29, 2024 · 6 revisions

Working with EventLogger

!Note:
Only available since Windows 8.

Since Windows 8 the Windows Ribbon framework provides developers an event logging mechanism.

How to use

From an instance of the Ribbon class you can get an instance of the EventLogger class which implements the COM IUIEventLogger Interface (Property EventLogger). If you want to use the EventLogger, you have to call EventLogger.Attach() and connect to the EventLogger.LogEvent. If you don't want the logging anymore, then you have to call EventLogger.Detach(). See also Listening for Ribbon Events.

EventLogger Class

Methods

Name Description
Attach() Attach to an IUIEventLogger and IUIEventingManager objects events
Detach() Detach the log events

Events

Name Description
LogEvent Occurs when a new Log Event is delivered by the Ribbon Framework

In your EventHandler for the LogEvent you get the EventLoggerEventArgs class.

EventLoggerEventArgs Class

Properties

Name Description
CommandID The ID of the Command directly related to the event, which is specified in the markup resource file (Type: UInt32).
CommandName The Command name that is associated with CommandId (Type: string).
EventType Identifies the types of events associated with a Ribbon (Type: EventType).
Modes The application modes. Only used when a EventType ApplicationModeSwitched has been fired.
In all other cases it is set to 0. (Type: Int32)
Location Identifies the locations where events associated with a Ribbon control can originate. (Type: EventLocation)
ParentCommandID The ID for the parent of the Command, which is specified in the markup resource file.(Type: UInt32)
ParentCommandName The Command name of the parent that is associated with CommandId.(Type: string)
SelectionIndex SelectionIndex is used only when a EventType CommandExecuted has been fired in response to the user selecting an item within a ComboBox or item gallery.
In those cases, SelectionIndex contains the index of the selected item. In all other cases, it is set to 0. (Type: UInt32)


Example:

Ribbon.EventLogger.LogEvent += DiagnosticLog;
Ribbon.EventLogger.Attach();
...
...
Ribbon.EventLogger.Detach();
Ribbon.EventLogger.LogEvent -= DiagnosticLog;

private void DiagnosticLog(object sender, EventLoggerEventArgs e)
{
switch (e.EventType){
    case EventType.CommandExecuted:
        uint id = e.CommandID;
        ...
        break;
    case EventType.TabActivated:
        ...
        break;
}
}

Table of contents

Clone this wiki locally