Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3c428efd8 | |||
| 019781b2f4 |
@@ -1,11 +1,11 @@
|
|||||||
using System;
|
using HardwareMonitorStatusWindow.Service;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using HardwareMonitorStatusWindow.Service;
|
|
||||||
|
|
||||||
namespace HardwareMonitorStatusWindow.StatusWindow;
|
namespace HardwareMonitorStatusWindow.StatusWindow;
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
|
|||||||
_dataErrorDictionary.ErrorsChanged += DataErrorDictionaryErrorsChanged;
|
_dataErrorDictionary.ErrorsChanged += DataErrorDictionaryErrorsChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? Label
|
public string Label
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set
|
set
|
||||||
@@ -28,7 +28,7 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
|
|||||||
|
|
||||||
SetField(ref field, value);
|
SetField(ref field, value);
|
||||||
}
|
}
|
||||||
}
|
} = string.Empty;
|
||||||
|
|
||||||
public string? HardwareId
|
public string? HardwareId
|
||||||
{
|
{
|
||||||
@@ -51,7 +51,7 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
|
|||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Hardware? Hardware => Data.ComputerHardware?.FirstOrDefault(h => h.Identifier.ToString() == HardwareId);
|
public Hardware? Hardware => Data.ComputerHardware.FirstOrDefault(h => h.Identifier.ToString() == HardwareId);
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Sensor? Sensor => Hardware?.Sensors.FirstOrDefault(s => s.Identifier.ToString() == SensorId);
|
public Sensor? Sensor => Hardware?.Sensors.FirstOrDefault(s => s.Identifier.ToString() == SensorId);
|
||||||
@@ -88,17 +88,16 @@ public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged
|
|||||||
|
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
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));
|
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;
|
field = value;
|
||||||
OnPropertyChanged(propertyName);
|
OnPropertyChanged(propertyName);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SensorValueFormat
|
public string SensorValueFormat
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<PackageReference Include="ChrisKaczor.Wpf.Controls.Link" Version="1.0.4" />
|
<PackageReference Include="ChrisKaczor.Wpf.Controls.Link" Version="1.0.4" />
|
||||||
<PackageReference Include="ChrisKaczor.Wpf.Validation" 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.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="gong-wpf-dragdrop" Version="4.0.0" />
|
||||||
<PackageReference Include="PipeMethodCalls" Version="4.0.3" />
|
<PackageReference Include="PipeMethodCalls" Version="4.0.3" />
|
||||||
<PackageReference Include="Serilog" Version="4.3.1" />
|
<PackageReference Include="Serilog" Version="4.3.1" />
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -244,6 +245,8 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
|
|
||||||
Data.RefreshComputer().Wait();
|
Data.RefreshComputer().Wait();
|
||||||
|
|
||||||
|
var labelLength = Data.SensorEntries.Max(x => x.Label.Length);
|
||||||
|
|
||||||
foreach (var sensorEntry in Data.SensorEntries)
|
foreach (var sensorEntry in Data.SensorEntries)
|
||||||
{
|
{
|
||||||
if (sensorEntry.Sensor == null)
|
if (sensorEntry.Sensor == null)
|
||||||
@@ -252,7 +255,9 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
if (text.Length > 0)
|
if (text.Length > 0)
|
||||||
text.AppendLine();
|
text.AppendLine();
|
||||||
|
|
||||||
text.Append($"{sensorEntry.Label}: {string.Format(sensorEntry.SensorValueFormat, sensorEntry.Sensor.Value)}");
|
var label = $"{sensorEntry.Label}:";
|
||||||
|
|
||||||
|
text.Append($"{label.PadRight(labelLength + 1)} {string.Format(sensorEntry.SensorValueFormat, sensorEntry.Sensor.Value)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(text.ToString()));
|
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(text.ToString()));
|
||||||
|
|||||||
Reference in New Issue
Block a user