1 Commits

Author SHA1 Message Date
019781b2f4 Update floating status window lib
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 2m34s
- Pad labels
2026-03-02 18:21:44 -05:00
3 changed files with 13 additions and 11 deletions

View File

@@ -1,11 +1,11 @@
using System;
using HardwareMonitorStatusWindow.Service;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;
using HardwareMonitorStatusWindow.Service;
namespace HardwareMonitorStatusWindow.StatusWindow;
@@ -18,7 +18,7 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
_dataErrorDictionary.ErrorsChanged += DataErrorDictionaryErrorsChanged;
}
public string? Label
public string Label
{
get;
set
@@ -28,7 +28,7 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
SetField(ref field, value);
}
}
} = string.Empty;
public string? HardwareId
{
@@ -51,7 +51,7 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
}
[JsonIgnore]
public Hardware? Hardware => Data.ComputerHardware?.FirstOrDefault(h => h.Identifier.ToString() == HardwareId);
public Hardware? Hardware => Data.ComputerHardware.FirstOrDefault(h => h.Identifier.ToString() == HardwareId);
[JsonIgnore]
public Sensor? Sensor => Hardware?.Sensors.FirstOrDefault(s => s.Identifier.ToString() == SensorId);
@@ -88,17 +88,16 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
private void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
private void SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
if (EqualityComparer<T>.Default.Equals(field, value)) return;
field = value;
OnPropertyChanged(propertyName);
return true;
}
public string SensorValueFormat

View File

@@ -28,7 +28,7 @@
<PackageReference Include="ChrisKaczor.Wpf.Controls.Link" Version="1.0.4" />
<PackageReference Include="ChrisKaczor.Wpf.Validation" Version="1.0.4" />
<PackageReference Include="ChrisKaczor.Wpf.Windows.CategoryWindow" Version="1.0.2" />
<PackageReference Include="ChrisKaczor.Wpf.Windows.FloatingStatusWindow" Version="2.0.0.8" />
<PackageReference Include="ChrisKaczor.Wpf.Windows.FloatingStatusWindow" Version="2.0.0.9" />
<PackageReference Include="gong-wpf-dragdrop" Version="4.0.0" />
<PackageReference Include="PipeMethodCalls" Version="4.0.3" />
<PackageReference Include="Serilog" Version="4.3.1" />

View File

@@ -9,6 +9,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@@ -244,6 +245,8 @@ internal class WindowSource : IWindowSource, IDisposable
Data.RefreshComputer().Wait();
var labelLength = Data.SensorEntries.Max(x => x.Label.Length);
foreach (var sensorEntry in Data.SensorEntries)
{
if (sensorEntry.Sensor == null)
@@ -252,7 +255,7 @@ internal class WindowSource : IWindowSource, IDisposable
if (text.Length > 0)
text.AppendLine();
text.Append($"{sensorEntry.Label}: {string.Format(sensorEntry.SensorValueFormat, sensorEntry.Sensor.Value)}");
text.Append($"{sensorEntry.Label.PadLeft(labelLength)}: {string.Format(sensorEntry.SensorValueFormat, sensorEntry.Sensor.Value)}");
}
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(text.ToString()));