From f8aa7c91187e0104e1ab1848b8c7af98ca591cdb Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Fri, 27 Feb 2026 14:34:43 -0500 Subject: [PATCH] Show sensor value when adding/editing sensors --- StatusWindow/Resources.Designer.cs | 9 +++++ StatusWindow/Resources.resx | 3 ++ StatusWindow/SettingsWindow/SensorWindow.xaml | 8 +++- .../SettingsWindow/SensorWindow.xaml.cs | 40 ++++++++++++++++++- 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/StatusWindow/Resources.Designer.cs b/StatusWindow/Resources.Designer.cs index 0b49e09..7a44705 100644 --- a/StatusWindow/Resources.Designer.cs +++ b/StatusWindow/Resources.Designer.cs @@ -169,6 +169,15 @@ namespace HardwareMonitorStatusWindow.StatusWindow { } } + /// + /// Looks up a localized string similar to Current Value. + /// + public static string CurrentValueWatermark { + get { + return ResourceManager.GetString("CurrentValueWatermark", resourceCulture); + } + } + /// /// Looks up a localized string similar to Delete. /// diff --git a/StatusWindow/Resources.resx b/StatusWindow/Resources.resx index 51acf95..4848aad 100644 --- a/StatusWindow/Resources.resx +++ b/StatusWindow/Resources.resx @@ -248,4 +248,7 @@ Would you like to download and install it now? Waiting for service to start... + + Current Value + \ No newline at end of file diff --git a/StatusWindow/SettingsWindow/SensorWindow.xaml b/StatusWindow/SettingsWindow/SensorWindow.xaml index d696f40..7fd7eae 100644 --- a/StatusWindow/SettingsWindow/SensorWindow.xaml +++ b/StatusWindow/SettingsWindow/SensorWindow.xaml @@ -68,8 +68,14 @@ DisplayMemberPath="Name" VirtualizingPanel.IsVirtualizing="False" mah:TextBoxHelper.UseFloatingWatermark="True" - mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.SensorWatermark}"> + mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.SensorWatermark}" + SelectionChanged="SensorComboBox_SelectionChanged"> + s.Type == sensorType.Value); } + + private void SensorComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) + { + UpdateCurrentSensorValue(); + } + + private void UpdateCurrentSensorValue() + { + var sensor = (Sensor)SensorComboBox.SelectedItem; + + if (sensor?.Value == null) + { + CurrentValueTextBox.Text = string.Empty; + return; + } + + var hardware = (Hardware)HardwareComboBox.SelectedItem; + + var displaySensorEntry = new SensorEntry { HardwareId = hardware.Identifier, SensorId = sensor.Identifier }; + + CurrentValueTextBox.Text = string.Format(displaySensorEntry.SensorValueFormat, displaySensorEntry.Sensor!.Value); + } } \ No newline at end of file