Skip to content

IToolbarContext

Interface in Oadm.Sdk.Client · Oadm.Sdk.Client.dll

What a toolbar plugin can see and do: the devices and the selection (with change events), the task plugins, the host pages and dialogs, and the same server access as a task plugin dialog. All members are called and raise their events on the UI thread.

public interface IToolbarContext

Guide: Core plugins and pages

IReadOnlyList<IDeviceInfo> Devices { get; }

All managed devices.

Window? Owner { get; }

The main window, as owner for the plugin’s own dialogs; null before it is shown.

IReadOnlyList<IDeviceInfo> SelectedDevices { get; }

Selected devices of the grid, in selection order.

IReadOnlyList<ToolbarTaskPlugin> TaskPlugins { get; }

Task plugins of the server.

bool CanRunTask(string pluginId)

True when the task plugin can run on every selected device (and something is selected).

string? CannotRunTaskReason(string pluginId)

Default implementation

Why the task plugin cannot run on the selection, in plain language (the context menu tooltip of the greyed entry, e.g. “Needs AXIS OS 11.11 or later: 3 of 5 selected devices”); null when it can or nothing is selected. Default (older hosts): null.

Task<bool> ConfirmAsync(string title, string message, string confirmText)

The host’s confirmation dialog; true when confirmed.

bool Has(string permission)

Default implementation

Whether the user’s role allows permission (“devices.refresh”). Default (older hosts): true.

Task<string?> InvokePluginAsync(string pluginId, string method, string? payloadJson, CancellationToken ct)

Default implementation

Calls a core plugin’s server part (ICorePlugin.InvokeAsync through gRPC PluginService.Invoke), e.g. the backend of a toolbar-only core plugin (ICorePlugin.HasPage false). Failures are Grpc.Core.RpcException (Status.Detail is the message). Hosts without it throw NotSupportedException.

Task OpenAsync(string hostPage)

Opens a host page, see HostPages. Completes when a dialog page closes.

Task<string?> QueryAsync(string pluginId, Guid deviceId, string method, string? payloadJson, CancellationToken ct)

Calls a task plugin’s server-side ITaskPluginQuery.QueryAsync for one device (read-only).

Task RefreshDevicesAsync(IReadOnlyCollection<Guid> deviceIds, CancellationToken ct)

Default implementation

Reads devices again now (full refresh on the server: status, firmware, network settings, API list, certificate); returns when the refresh is queued, the grid updates as the results arrive. Read-only for the devices.

Task RemoveDevicesAsync(IReadOnlyCollection<Guid> deviceIds, CancellationToken ct)

Removes devices from OADM (the devices themselves are not changed). No confirmation.

Task<IReadOnlyList<string>?> RunTaskAsync(string pluginId, CancellationToken ct)

Runs a task plugin on the selection like the context menu does: its dialog first when it has one, then one task per device. Returns the task ids, or null when nothing was started.

Task ShowMessageAsync(string title, string message)

The host’s message dialog.

Task<UploadedFile> UploadAsync(string localPath, IProgress<double>? progress, CancellationToken ct)

Uploads a local file to the server; progress receives 0.0 to 1.0.

event EventHandler? DevicesChanged

A device was added, removed or changed.

event EventHandler? PermissionsChanged

Default implementation

Raised on the UI thread after the user’s role or its permissions changed.

event EventHandler? SelectionChanged

The grid selection changed.

event EventHandler? TaskPluginsChanged

IToolbarContext.TaskPlugins or what they can run on changed.