MDH.Displays.Connector
1.0.2
dotnet add package MDH.Displays.Connector --version 1.0.2
NuGet\Install-Package MDH.Displays.Connector -Version 1.0.2
<PackageReference Include="MDH.Displays.Connector" Version="1.0.2" />
<PackageVersion Include="MDH.Displays.Connector" Version="1.0.2" />
<PackageReference Include="MDH.Displays.Connector" />
paket add MDH.Displays.Connector --version 1.0.2
#r "nuget: MDH.Displays.Connector, 1.0.2"
#:package MDH.Displays.Connector@1.0.2
#addin nuget:?package=MDH.Displays.Connector&version=1.0.2
#tool nuget:?package=MDH.Displays.Connector&version=1.0.2
MDH.Displays.Connector
.NET client for MDH Displays. Publish variables to displays and manage the assets they use.
Targets netstandard2.0, net48, net8.0-windows. The WPF status bar item and
settings editor are on the two Windows targets only.
Install
dotnet add package MDH.Displays.Connector
Quick start
var settings = Settings.LoadFromFile(@"C:\ProgramData\YourApp\displays.xml");
if (!settings.IsConfigured)
{
Log(settings.ConfigurationProblem);
return;
}
var connection = new Connection(settings);
connection.OnError += Log;
connection.ConnectionStateChanged += c => UpdateUi(c.IsConnected);
connection.Connect();
connection.Publish(new HeatVariables(heat));
Variable groups
public sealed class HeatVariables : VariableGroup
{
private readonly Heat _heat;
public HeatVariables(Heat heat) => _heat = heat;
public override string Id => "heat";
public override string Name => "Current heat";
protected override void Build(VariableGroupBuilder b)
{
b.AddString("name", _heat.Name)
.AddNumber("stand", _heat.Stand)
.AddBoolean("running", _heat.IsRunning)
.AddDateTime("startedAt", _heat.StartedAt);
}
}
Builder methods: AddString, AddNumber (int or double), AddBoolean,
AddDateTime, AddStruct(name, value, fields).
Idmust be stable across publishes; it identifies the group to the display.- The whole group is rewritten each publish;
Buildmust declare every variable every time. Buildruns on the background loop at serialisation time, not whenPublishreturns. Snapshot mutable data first.- Variable ids derive from
{groupId}:{name}.
API
Connection(Settings settings);
void Connect(); // background, auto-reconnecting; no-op if disabled or running
void Disconnect();
void Publish(VariableGroup group); // non-blocking
Task<string?> UploadAssetAsync(string serverPath, byte[] data, bool overwrite = true);
Task<IReadOnlyList<Asset>> ListAssetsAsync();
Task<string?> DeleteAssetAsync(string serverPath);
Settings Settings { get; }
bool IsEnabled { get; }
bool IsConnected { get; }
event Action<Connection>? ConnectionStateChanged;
event Action<string>? OnError;
Publishes are coalesced per group — only the latest update is sent. All groups are re-flushed after a reconnect.
Settings
| Field | Default | Description |
|---|---|---|
Enabled |
false |
When off, Connect() is a no-op. |
Host |
127.0.0.1 |
MDH Displays server. |
Port |
4222 |
Port used for variables. |
HttpPort |
80 |
Port used for assets. |
Bucket |
vargroups |
Bucket variables are published to. |
ClientName |
MDH Displays Connector |
Identifies this connection on the server. |
IsConfigured / ConfigurationProblem report whether the settings are usable.
LoadFromFile returns defaults if the file is missing; throws if it exists and
cannot be parsed.
Embed in a host's settings tree:
[Category("MDH Displays"), DisplayName("Connection")]
public Settings Displays { get; set; } = new Settings();
Serialises as one XML element (MdhDisplaysSettings) and expands in a
PropertyGrid.
WPF status bar item
<StatusBar>
<displays:DisplaysStatusBarItem x:Name="Item" FontWeight="Bold" />
</StatusBar>
Item.Settings = mySettings;
Item.ConnectRequested += (s, e) => connection.Connect();
Item.DisconnectRequested += (s, e) => connection.Disconnect();
connection.ConnectionStateChanged += c =>
Dispatcher.Invoke(() => Item.IsConnected = c.IsConnected);
Appearance: Label, FontWeight, FontSize, FontFamily, Padding, and one
brush property per state (ConnectedBackground, DisconnectedForeground, …).
Add host-specific menu items to the right-click menu, in XAML or in code. They render between Connect/Disconnect and Properties.
<displays:DisplaysStatusBarItem>
<displays:DisplaysStatusBarItem.HostMenuItems>
<MenuItem Header="Upload Portraits" Click="OnClick" />
</displays:DisplaysStatusBarItem.HostMenuItems>
</displays:DisplaysStatusBarItem>
Item.HostMenuItems.Add(new MenuItem { Header = "Upload Portraits" });
Threading
ConnectionStateChanged and OnError may fire on background threads. Marshal to
the UI thread in your handlers.
Status
Not verified against a live server since the connector moved repositories.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.