Windows

Overview

The Workspaces API is accessible via the io.Workspaces object.

The .NET Workspaces API enables you to determine whether an io.Connect Window is currently in a Workspace, to retrieve snapshots and contexts of Workspaces, and to subscribe for events related to windows participating in Workspaces.

Determining if a Window is in a Workspace

To determine whether a window is in a Workspace, use the IsInWorkspace() method and pass as an argument the IGDWindow object describing the respective window:

bool isInWorkspace = await io.Workspaces.IsInWorkspace(targetWindow);

Workspace Context

To retrieve the context of the Workspace in which a window participates, use the GetWorkspaceContext() method and pass as an argument the IGDWindow object describing the respective window:

IContext context = await io.Workspaces.GetWorkspaceContext(targetWindow);

Workspace Snapshot

To retrieve a snapshot of a Workspace, use the GetWorkspaceSnapshot() method and provide the ID of the respective Workspace:

WorkspaceSnapshot snapshot = await io.Workspaces.GetWorkspaceSnapshot("workspace-id");

Console.WriteLine($"Workspace ID: {snapshot.Id}, Workspace title: {snapshot.Title}.");

The WorkspaceSnapshot object has the following properties:

Property Type Description
FrameId string ID of the Workspaces App in which the Workspace is currently opened.
Id string ID of the Workspace.
IsSelected bool Indicates whether the Workspace tab is currently selected.
LayoutName string Name of the Workspace Layout.
PositionIndex int Indicates the position of the Workspace tab among the other Workspace tabs currently opened in the Workspaces App.
Title string Title of the Workspace.
Windows Item[] List of objects describing the windows participating in the Workspace.
WorkspaceItem Item Object describing the Workspace.

Events

To subscribe for events related to windows participating in Workspaces, use the SubscribeWindowEvent() method and pass a callback function for handling the event. The callback will receive a WorkspaceEvent object as an argument. Use this object to determine the type of the event, the io.Connect Window to which it's related, and the Workspace in which the respective window participates:

IDisposable subscription = await io.Workspaces.SubscribeWindowEvent((е) =>
{
    // Handling a specific event.
    if (е.Action == WorkspaceEvent.Added)
    {
        Console.WriteLine($"Window with ID {е.WindowId} was added to Workspace with ID {е.WorkspaceId}.");
    }
    else
    {
        Console.WriteLine($"Event {е.Action} fired for window with ID {е.WindowId}.");
    };
});

// Closing the subscription.
subscription.Dispose();

Upon successful subscription, the SubscribeWindowEvent() method returns a subscription object of type IDisposable. Use its Dispose() method to stop receiving event notifications.

The WorkspaceEvent object has the following properties:

Property Type Description
Action WindowEventAction Type of the event (e.g., window added, removed, maximized, and more).
Window IGDWindow Object describing the io.Connect Window to which the event is related.
WindowId string ID of the io.Connect Window to which the event is related.
WorkspaceId string ID of the Workspace in which the window participates.

The WindowEventAction enumeration describes the available events and has the following members:

Member Description
Added Indicates the event fired when a window is added to a Workspace.
Loaded Indicates the event fired when a window has finished loading in a Workspace.
LockConfigurationChanged Indicates the event fired when the lock settings for a window in a Workspace are changed.
Maximized Indicates the event fired when a window is maximized in a Workspace.
Removed Indicates the event fired when a window is removed from a Workspace.
Restored Indicates the event fired when a window is restored in a Workspace after being maximized.
Selected Indicates the event fired when the tab of a window is selected. It's important to keep in mind that when this event is fired, this doesn't automatically mean that the window is on focus - e.g., the window may be in a Workspace that's not currently on focus and its tab may have been selected programmatically.