Skip to content

DevicePickerWindow

Class in Oadm.Sdk.Client.Controls · Oadm.Sdk.Client.dll

The shared device picker of every dialog that needs a set of devices (host and plugins, one window, never a copy): title bar, one card with the count and a search, Select all / Select none for the devices the search shows, and a virtualized list with a check box per device (address, model; a device that cannot be chosen is greyed with the reason), then Cancel / OK. With DevicePickerOptions a column on the left offers the device of the event, All devices, or Chosen devices and tags with the tag list (devices of a chosen tag show checked with the tag). The device group editor (DevicePickerOptions.Group) shows Sites and Tags on the left, the devices they cover checked and locked with Except / Include per row, and a form of the host above (name, description), with DevicePickerWindow.Accept deciding whether the main button closes the window. Open it with DevicePickerWindow.ShowAsync; the view model is DevicePickerViewModel.

public sealed class DevicePickerWindow : Window

Inherits Window

Guide: UI kit

DevicePickerWindow(DevicePickerViewModel viewModel)

The window for viewModel; usually opened through the static ShowAsync methods.

DevicePickerWindow(DevicePickerViewModel viewModel, Control? form)

The window for viewModel with form (the host’s fields, e.g. a device group’s name and description) on top of the card.

Func<Task<bool>>? Accept { get; set; }

Runs when the main button is clicked: the window closes with true only when it returns true (e.g. the host saved and the server accepted). Null: the button closes the window at once.

Button AcceptButton { get; }

The main button of the footer (“OK”): the host may change its text and bind it (e.g. “Save”, disabled with a reason).

string? Heading { get; set; }

The window title (title bar and task switcher).

bool IsAccepting { get; private set; }

DevicePickerWindow.Accept runs (the host saves): the window cannot be cancelled or closed meanwhile.

bool IsPickerVisible { get; set; }

The device part shows (default). False: only the host’s form above it (e.g. a policy kind without devices); the window is then as high as the form. Changes while the window is open.

DevicePickerViewModel ViewModel { get; }

Its view model.

static Task<IReadOnlyList<Guid>?> ShowAsync(Window owner, IEnumerable<IDeviceInfo> devices, IEnumerable<Guid>? selected = null, Func<IDeviceInfo, string?>? unavailableReason = null, string heading = "Choose devices")

Shows the picker over owner; returns the chosen devices (in list order), or null when cancelled.

static Task<DeviceChoice?> ShowChoiceAsync(Window owner, IEnumerable<IDeviceInfo> devices, DeviceChoice initial, DevicePickerOptions options, string heading = "Choose devices")

Shows the picker with all devices, tags and (with DevicePickerOptions.EventDeviceText) the device of the event; returns the choice, or null when cancelled.

static Task<Guid?> ShowOneAsync(Window owner, IEnumerable<IDeviceInfo> devices, Guid? selected = null, Func<IDeviceInfo, string?>? unavailableReason = null, string heading = "Choose a device")

Shows the picker for exactly one device (DevicePickerOptions.SingleDevice) over owner; returns its id, or null when cancelled or none was chosen.