Skip to content

Commit 29998d4

Browse files
committed
修复悬浮窗显示中文时标题出现重影的问题。
1 parent 40bca5b commit 29998d4

3 files changed

Lines changed: 45 additions & 28 deletions

File tree

FloatingForm.cs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public FloatingForm(string text, int textSize, string loc, Screen screen = null)
3030
}
3131

3232
private void ApplySupersampling(string text, int textSize) {
33-
// 参数校验,防止 textSize 无效导致 ArgumentException
3433
if (string.IsNullOrEmpty(text) || textSize <= 0)
3534
return;
3635

@@ -48,33 +47,44 @@ private void ApplySupersampling(string text, int textSize) {
4847
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
4948
graphics.Clear(Color.Transparent);
5049

51-
Color customColor = Color.FromArgb(255, 128, 0);
5250
using (Font font = new Font("Calibri", textSize, FontStyle.Bold, GraphicsUnit.World)) {
53-
using (Brush brush = new SolidBrush(Color.FromArgb(255, 128, 0))) {
54-
graphics.DrawString(text, font, brush, new PointF(0, 0));
55-
}
56-
5751
PointF point = new PointF(0, 0);
5852
for (int i = 0; i < lines.Length; i++) {
5953
string[] parts = lines[i].Split(':');
6054
if (parts.Length > 1) {
61-
string title = parts[0].Trim();
62-
customColor = GetColorForTitle(title);
63-
using (Brush brush = new SolidBrush(customColor)) {
64-
for (int j = 1; j <= i; j++)
65-
title = '\n' + title;
66-
graphics.DrawString(title, font, brush, point);
67-
}
55+
string title = parts[0].Trim() + ":";
56+
string value = " " + parts[1].Trim();
57+
Color titleColor = GetColorForTitle(parts[0].Trim());
58+
59+
// 单独绘制标题
60+
string titleWithNewlines = title;
61+
for (int j = 0; j < i; j++)
62+
titleWithNewlines = '\n' + titleWithNewlines;
63+
SizeF titleSize = graphics.MeasureString(titleWithNewlines, font);
64+
using (Brush brush = new SolidBrush(titleColor))
65+
graphics.DrawString(titleWithNewlines, font, brush, point);
66+
67+
// 单独绘制值,紧接标题之后
68+
string valueWithNewlines = value;
69+
for (int j = 0; j < i; j++)
70+
valueWithNewlines = '\n' + valueWithNewlines;
71+
using (Brush brush = new SolidBrush(Color.FromArgb(255, 128, 0)))
72+
graphics.DrawString(valueWithNewlines, font, brush, new PointF(titleSize.Width, point.Y));
73+
} else {
74+
string lineWithNewlines = lines[i];
75+
for (int j = 0; j < i; j++)
76+
lineWithNewlines = '\n' + lineWithNewlines;
77+
using (Brush brush = new SolidBrush(Color.FromArgb(255, 128, 0)))
78+
graphics.DrawString(lineWithNewlines, font, brush, point);
6879
}
6980
}
7081
}
7182
}
7283

73-
// 先释放旧图像,再赋新值
7484
var oldImage = displayPictureBox.Image;
7585
displayPictureBox.Image = newBitmap;
7686
displayPictureBox.Size = newBitmap.Size;
77-
oldImage?.Dispose(); // Dispose 放在赋值之后,避免控件引用悬空
87+
oldImage?.Dispose();
7888

7989
if (IsHandleCreated)
8090
RenderLayered(newBitmap);

HelpForm.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,12 @@ private static string GetHelpHtml_ZH(Version version) {
147147
<h2>📦 OmenSuperHub v{Assembly.GetExecutingAssembly().GetName().Version} 更新说明</h2>
148148
<div class='update-list'>
149149
<p><strong>新增:</strong></p>
150-
<li>✨ 自动转速下,仅CPU监控且获取不到数据时自动启用传感器拟合</a></li>
150+
<li>✨ 识别显卡节能状态,同时不再自动开关GPU监控</a></li>
151151
<p><strong>优化:</strong></p>
152-
<li>⚡ 大幅提升硬件监控启动速度及效率</li>
153-
<li>⚡ 移除AcLoadLine可以超出限制的功能</li>
154-
<li>⚡ 优化本机信息传感器不支持时的显示</li>
152+
<li>⚡ 保存部分机型参数以避免重复初始化</li>
153+
<p><strong>修复:</strong></p>
154+
<li>🐛 修复悬浮窗显示中文时标题出现重影的问题</li>
155+
<li>🐛 修复部分选项英文均为“Normal”导致的混淆</li>
155156
</div>
156157
157158
<p>本项目已开源至 Github:<a href='https://github.com/breadeding/OmenSuperHub'>https://github.com/breadeding/OmenSuperHub</a></p>
@@ -213,11 +214,12 @@ private static string GetHelpHtml_TW(Version version) {
213214
<h2>📦 OmenSuperHub v{Assembly.GetExecutingAssembly().GetName().Version} 更新說明</h2>
214215
<div class='update-list'>
215216
<p><strong>新增:</strong></p>
216-
<li>✨ 自動轉速下,僅CPU監控且取得不到數據時自動啟用感測器擬合 </a></li>
217+
<li>✨ 辨識顯示卡節能狀態,同時不再自動開關GPU監控</a></li>
217218
<p><strong>優化:</strong></p>
218-
<li>⚡ 大幅提升硬體監控啟動速度及效率</li>
219-
<li>⚡ 移除AcLoadLine可以超出限制的功能</li>
220-
<li>⚡ 優化本機資訊感測器不支援時的顯示</li>
219+
<li>⚡ Cache parameters for certain models to avoid redundant initialization</li>
220+
<p><strong>修復:</strong></p>
221+
<li>🐛 修復懸浮窗顯示中文時標題出現重影的問題</li>
222+
<li>🐛 修復部分選項英文皆為「Normal」所造成的混淆</li>
221223
</div>
222224
223225
<p>本專案已開源至 Github:<a href='https://github.com/breadeding/OmenSuperHub'>https://github.com/breadeding/OmenSuperHub</a></p>
@@ -279,11 +281,13 @@ private static string GetHelpHtml_EN(Version version) {
279281
<h2>📦 OmenSuperHub v{Assembly.GetExecutingAssembly().GetName().Version} Changelog</h2>
280282
<div class='update-list'>
281283
<p><strong>New Features:</strong></p>
282-
<li>✨ In auto-speed mode, automatically enable sensor simulation if only the CPU is being monitored and no data is retrieved</li>
284+
<li>✨ Detects the graphics card's power-saving state and no longer automatically toggles GPU monitoring</a></li>
283285
<p><strong>Improvements:</strong></p>
284-
<li>⚡ Significantly improved startup speed and efficiency for hardware monitoring</li>
285-
<li>⚡ Removed the ability for AcLoadLine to exceed limits</li>
286-
<li>⚡ Optimized display when local system sensors are unsupported</li>
286+
<li>⚡ Cache parameters for certain models to avoid redundant initialization</li>
287+
<p><strong>Fixes:</strong></p>
288+
<li>🐛 Fixed an issue where the title appeared to have a ""ghosting"" effect when the floating window displayed Chinese text</li>
289+
<li>🐛 Fixed confusion caused by multiple options being labeled ""Normal"" in English</li>
290+
<li>🐛 Fixed an issue where the title appeared to have a ""ghosting"" effect when the floating window displayed Chinese text</li>
287291
</div>
288292
289293
<p>This project is open-source on Github: <a href='https://github.com/breadeding/OmenSuperHub'>https://github.com/breadeding/OmenSuperHub</a></p>

LibreHardwareMonitor/LibreHardwareMonitorLib/Hardware/Gpu/NvidiaGpu.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ internal sealed class NvidiaGpu : GenericGpu
1111
private readonly NvidiaML.NvmlDevice? _nvmlDevice;
1212
private readonly Sensor _powerUsage;
1313
private readonly Sensor _temperature;
14+
private bool _firstUpdate = true;
1415

1516
public NvidiaGpu(int adapterIndex, NvApi.NvPhysicalGpuHandle handle, NvApi.NvDisplayHandle? displayHandle, ISettings settings)
1617
: base(GetName(handle), new Identifier("gpu-nvidia", adapterIndex.ToString(CultureInfo.InvariantCulture)), settings)
@@ -63,13 +64,15 @@ public override void Update()
6364
{
6465
try
6566
{
66-
if (!IsGpuPowered())
67+
if (!_firstUpdate && !IsGpuPowered())
6768
{
6869
_temperature.Value = null;
6970
if (_powerUsage != null)
7071
_powerUsage.Value = null;
7172
return;
7273
}
74+
else
75+
_firstUpdate = false;
7376

7477
// 温度
7578
var thermalSettings = new NvApi.NvThermalSettings

0 commit comments

Comments
 (0)