From 8dbf2faae337f92a0fef49c2b393743348ee10ae Mon Sep 17 00:00:00 2001 From: "J. Schlackman" Date: Mon, 16 Aug 2021 21:38:46 -0400 Subject: [PATCH] Add status indicator in settings - closes #3 The settings UI now displays the number of Luxafor devices connected. --- LuxOnAir/LFRSettings.cs | 30 ++++++++++++++++++++++-------- LuxOnAir/MainWindow.xaml | 2 ++ LuxOnAir/MainWindow.xaml.cs | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/LuxOnAir/LFRSettings.cs b/LuxOnAir/LFRSettings.cs index b8f8003..4d0049f 100644 --- a/LuxOnAir/LFRSettings.cs +++ b/LuxOnAir/LFRSettings.cs @@ -69,25 +69,39 @@ public LFRSettings() /// /// Initilizes the Luxafor hardware /// - /// Debug log message indicating how many devices were found. + /// Text message indicating how many devices were found. public string InitHardware() { - string logMsg; - - // Now create a new device controller + // Create a new device controller devices = new DeviceList(); devices.Scan(); + return ConnectedDeviceDesc(); + } + + /// + /// Gets the number Luxafor devices currently connected. + /// + /// Numerical count of devices connected. + public int ConnectedDeviceCount() + { + return (devices == null ? 0 : devices.Count()); + } + + /// + /// Generates a text description of how many Luxafor devices are currently connected. + /// + /// User-friendly text describing how many Luxafor devices are connected. + public string ConnectedDeviceDesc() + { if (devices.Count() == 0) { - logMsg = "No Luxafor light available."; + return "No Luxafor light connected."; } else { - logMsg = string.Format("{0} Luxafor light{1} ready.", devices.Count().ToString(), (devices.Count() != 1) ? "s" : ""); + return string.Format("{0} Luxafor light{1} connected.", devices.Count().ToString(), (devices.Count() != 1) ? "s" : ""); } - - return logMsg; } /// diff --git a/LuxOnAir/MainWindow.xaml b/LuxOnAir/MainWindow.xaml index e200ec1..a832552 100644 --- a/LuxOnAir/MainWindow.xaml +++ b/LuxOnAir/MainWindow.xaml @@ -48,6 +48,8 @@