mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Fix crash for gputemp reader
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using GHelper;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -263,6 +264,7 @@ namespace CustomControls
|
||||
|
||||
protected override void OnPaint(PaintEventArgs pevent)
|
||||
{
|
||||
|
||||
base.OnPaint(pevent);
|
||||
|
||||
float ratio = pevent.Graphics.DpiX / 192.0f;
|
||||
@@ -284,6 +286,19 @@ namespace CustomControls
|
||||
pevent.Graphics.DrawPath(penSurface, pathSurface);
|
||||
pevent.Graphics.DrawPath(penBorder, pathBorder);
|
||||
}
|
||||
|
||||
if (!Enabled && ForeColor != SystemColors.ControlText)
|
||||
{
|
||||
var rect = pevent.ClipRectangle;
|
||||
if (Image is not null) {
|
||||
rect.Y += Image.Height;
|
||||
rect.Height -= Image.Height;
|
||||
}
|
||||
TextFormatFlags flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak;
|
||||
TextRenderer.DrawText(pevent.Graphics, this.Text, this.Font, rect, Color.Gray, flags);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,28 +58,36 @@ public static class HardwareMonitor
|
||||
}
|
||||
|
||||
public static void RecreateGpuTemperatureProvider() {
|
||||
try {
|
||||
try
|
||||
{
|
||||
GpuTemperatureProvider?.Dispose();
|
||||
|
||||
// Detect valid GPU temperature provider.
|
||||
// We start with NVIDIA because there's always at least an integrated AMD GPU
|
||||
IGpuTemperatureProvider gpuTemperatureProvider = new NvidiaGpuTemperatureProvider();
|
||||
if (gpuTemperatureProvider.IsValid) {
|
||||
if (gpuTemperatureProvider.IsValid)
|
||||
{
|
||||
GpuTemperatureProvider = gpuTemperatureProvider;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gpuTemperatureProvider.Dispose();
|
||||
gpuTemperatureProvider = new AmdGpuTemperatureProvider();
|
||||
if (gpuTemperatureProvider.IsValid) {
|
||||
if (gpuTemperatureProvider.IsValid)
|
||||
{
|
||||
GpuTemperatureProvider = gpuTemperatureProvider;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gpuTemperatureProvider.Dispose();
|
||||
|
||||
|
||||
GpuTemperatureProvider = null;
|
||||
} finally {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
Logger.WriteLine($"GpuTemperatureProvider: {GpuTemperatureProvider?.GetType().Name}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1205,10 +1205,10 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
public void ButtonEnabled(Button but, bool enabled)
|
||||
public void ButtonEnabled(RButton but, bool enabled)
|
||||
{
|
||||
but.Enabled = enabled;
|
||||
but.BackColor = enabled ? Color.FromArgb(255, but.BackColor) : Color.FromArgb(100, but.BackColor);
|
||||
but.BackColor = but.Enabled ? Color.FromArgb(255, but.BackColor) : Color.FromArgb(100, but.BackColor);
|
||||
}
|
||||
|
||||
public void SetStartupCheck(bool status)
|
||||
|
||||
Reference in New Issue
Block a user