Show sensor value when adding/editing sensors
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 49s
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 49s
This commit is contained in:
9
StatusWindow/Resources.Designer.cs
generated
9
StatusWindow/Resources.Designer.cs
generated
@@ -169,6 +169,15 @@ namespace HardwareMonitorStatusWindow.StatusWindow {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Current Value.
|
||||
/// </summary>
|
||||
public static string CurrentValueWatermark {
|
||||
get {
|
||||
return ResourceManager.GetString("CurrentValueWatermark", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Delete.
|
||||
/// </summary>
|
||||
|
||||
@@ -248,4 +248,7 @@ Would you like to download and install it now?</value>
|
||||
<data name="ServiceNotStarted" xml:space="preserve">
|
||||
<value>Waiting for service to start...</value>
|
||||
</data>
|
||||
<data name="CurrentValueWatermark" xml:space="preserve">
|
||||
<value>Current Value</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -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">
|
||||
</ComboBox>
|
||||
<TextBox Name="CurrentValueTextBox"
|
||||
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.CurrentValueWatermark}"
|
||||
mah:TextBoxHelper.SelectAllOnFocus="True"
|
||||
IsReadOnly="True" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System;
|
||||
using ChrisKaczor.Wpf.Validation;
|
||||
using HardwareMonitorStatusWindow.Service;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow;
|
||||
|
||||
public partial class SensorWindow
|
||||
{
|
||||
private readonly DispatcherTimer _timer = new();
|
||||
|
||||
public SensorWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -32,9 +37,18 @@ public partial class SensorWindow
|
||||
|
||||
Owner = owner;
|
||||
|
||||
_timer.Interval = TimeSpan.FromSeconds(1);
|
||||
_timer.Tick += TimerOnTick;
|
||||
_timer.Start();
|
||||
|
||||
return ShowDialog();
|
||||
}
|
||||
|
||||
private void TimerOnTick(object? sender, EventArgs e)
|
||||
{
|
||||
UpdateCurrentSensorValue();
|
||||
}
|
||||
|
||||
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!this.IsValid())
|
||||
@@ -95,4 +109,26 @@ public partial class SensorWindow
|
||||
|
||||
SensorComboBox.ItemsSource = hardware.Sensors.Where(s => 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user