workspace sdk shared components - Genetec/DAP GitHub Wiki

About shared components

Shared components are built-in UI surfaces that the Workspace runtime exposes for reuse in custom pages. Each monitor in Security Desk has its own set of shared components: the tile canvas, the dashboard area, and the properties panel. Instead of recreating these surfaces, a custom page retrieves them from the monitor and hosts them directly.

Shared components are only available in Security Desk. The collections exist in Config Tool but are empty.

Use shared components when your custom page needs to include one of Security Desk's core UI areas. Examples include:

  • Building a custom monitoring page that displays tiles alongside a custom side panel
  • Creating a page that embeds the dashboard widget area within a custom layout
  • Adding the properties panel to a custom page so operators see contextual metadata for the selected tile content

How shared components work

  1. Security Desk creates shared component instances during startup, one per monitor for each type
  2. Per-monitor components are stored in Monitor.SharedComponents. Application-wide components are stored in Workspace.SharedComponents. All three built-in types (TileCanvas, DashboardPane, MetadataPane) are per-monitor.
  3. When a page activates, it retrieves a shared component from the monitor's collection by type identifier
  4. The page places the SharedComponent wrapper into a ContentControl in its view
  5. The page calls Connect() to render the shared component inside the host control
  6. When the page deactivates, it calls Disconnect() and clears the host control
  7. The shared component remains in the collection and other pages can retrieve and connect it

The collection is read-only. Modules retrieve and host existing shared components but do not register or unregister them.

SharedComponent

SharedComponent represents a built-in UI surface that can be hosted in a page. Set it as the Content of a ContentControl in your page view, then use these methods:

Member Description
Connect() Renders the shared component inside the host control. If the component is already connected elsewhere, it disconnects from the previous host first.
Disconnect() Removes the shared component from the host control.

SharedComponentCollection

Access shared components through Monitor.SharedComponents for per-monitor components or Workspace.SharedComponents for application-wide components. Use Monitor.SharedComponents for TileCanvas, DashboardPane, and MetadataPane.

Member Type Description
this[Guid type] ReadOnlyCollection<SharedComponent> All shared components of a type.
this[Guid type, Guid id] SharedComponent A specific shared component by type and unique identifier.
Count int The number of shared components in the collection.

Shared component identifiers

The SharedComponents static class in Genetec.Sdk.Workspace.SharedComponents defines the available types:

Identifier Description
SharedComponents.TileCanvas The tile layout area where tiles display video, maps, and other content. Requires TilePage to provide the tile layout.
SharedComponents.DashboardPane The dashboard area where dashboard widgets are displayed.
SharedComponents.MetadataPane The properties panel that appears on the right side of the monitoring view. It displays contextual metadata about the selected tile content. Requires a TilePage with a connected TileCanvas, because it reads from the active tile layout.

Displaying a shared component in a page

Retrieve and connect shared components during page activation. Disconnect during deactivation.

In the page view XAML, define a host control:

<UserControl
    x:Class="SampleTilePageView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>
    <ContentControl x:Name="TilesHost" />
  </Grid>
</UserControl>

In the page class, connect the shared component when the page activates and disconnect when it deactivates. For details on creating pages and views, see About pages.

Important

The TileCanvas shared component requires TilePage as the page base class. TilePage provides the tile layout that the canvas needs to render content. A regular Page cannot supply a tile layout, so the canvas displays nothing.

This example uses TilePage, which provides tile layout management through its Pattern and States properties:

using System.Linq;
using Genetec.Sdk.Workspace.Pages;
using Genetec.Sdk.Workspace.SharedComponents;
using Monitor = Genetec.Sdk.Workspace.Monitors.Monitor;

public class SampleTilePage : TilePage
{
    private SharedComponent m_tileCanvas;
    private SampleTilePageView m_view;

    protected override void OnActivated(Monitor monitor)
    {
        m_tileCanvas = monitor.SharedComponents[SharedComponents.TileCanvas].FirstOrDefault();

        if (m_tileCanvas == null)
            return;

        m_view.TilesHost.Content = m_tileCanvas;
        m_tileCanvas.Connect();
    }

    protected override void OnDeactivated(Monitor monitor)
    {
        m_tileCanvas?.Disconnect();
        m_view.TilesHost.Content = null;
        m_tileCanvas = null;
    }
}

Embedding the dashboard pane

A custom page can host the dashboard widget area. Retrieve SharedComponents.DashboardPane from the monitor and connect it to a host control in your page view.

<UserControl
    x:Class="SampleDashboardPageView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>
    <ContentControl x:Name="DashboardHost" />
  </Grid>
</UserControl>
using System.Linq;
using Genetec.Sdk.Workspace.Pages;
using Genetec.Sdk.Workspace.SharedComponents;
using Monitor = Genetec.Sdk.Workspace.Monitors.Monitor;

public class SampleDashboardPage : Page
{
    private SharedComponent m_dashboard;
    private SampleDashboardPageView m_view;

    protected override void OnActivated(Monitor monitor)
    {
        m_dashboard = monitor.SharedComponents[SharedComponents.DashboardPane].FirstOrDefault();

        if (m_dashboard == null)
            return;

        m_view.DashboardHost.Content = m_dashboard;
        m_dashboard.Connect();
    }

    protected override void OnDeactivated(Monitor monitor)
    {
        m_dashboard?.Disconnect();
        m_view.DashboardHost.Content = null;
        m_dashboard = null;
    }
}

Embedding the metadata pane

A custom page can host the properties panel alongside tiles. Retrieve SharedComponents.MetadataPane from the monitor and connect it to a host control alongside a TileCanvas.

Important

The MetadataPane displays metadata about the selected tile content. It requires a TilePage with a connected TileCanvas because it reads from the active tile layout. Without tiles, the properties panel has no content to display.

<UserControl
    x:Class="SamplePageWithPropertiesView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
      <ColumnDefinition Width="300" />
    </Grid.ColumnDefinitions>
    <ContentControl
        x:Name="TilesHost"
        Grid.Column="0" />
    <ContentControl
        x:Name="PropertiesHost"
        Grid.Column="1" />
  </Grid>
</UserControl>
using System.Linq;
using Genetec.Sdk.Workspace.Pages;
using Genetec.Sdk.Workspace.SharedComponents;
using Monitor = Genetec.Sdk.Workspace.Monitors.Monitor;

public class SamplePageWithProperties : TilePage
{
    private SharedComponent m_tileCanvas;
    private SharedComponent m_metadata;
    private SamplePageWithPropertiesView m_view;

    protected override void OnActivated(Monitor monitor)
    {
        m_tileCanvas = monitor.SharedComponents[SharedComponents.TileCanvas].FirstOrDefault();

        m_metadata = monitor.SharedComponents[SharedComponents.MetadataPane].FirstOrDefault();

        if (m_tileCanvas != null)
        {
            m_view.TilesHost.Content = m_tileCanvas;
            m_tileCanvas.Connect();
        }

        if (m_metadata != null)
        {
            m_view.PropertiesHost.Content = m_metadata;
            m_metadata.Connect();
        }
    }

    protected override void OnDeactivated(Monitor monitor)
    {
        m_tileCanvas?.Disconnect();
        m_view.TilesHost.Content = null;
        m_tileCanvas = null;

        m_metadata?.Disconnect();
        m_view.PropertiesHost.Content = null;
        m_metadata = null;
    }
}

Retrieving a shared component by unique identifier

Each monitor has one instance of each shared component type. The type indexer returns a collection, so use FirstOrDefault() to retrieve the instance. To retrieve a specific instance by its unique identifier, use the two-key indexer:

Guid typeId = SharedComponents.TileCanvas;
Guid componentId = new Guid("COMPONENT-UNIQUE-ID");

SharedComponent component = monitor.SharedComponents[typeId, componentId];
⚠️ **GitHub.com Fallback** ⚠️