Try to recreate overlay if OSDIndex is 0, or not-0

This commit is contained in:
Kamil Trzciński 2022-11-15 21:10:27 +01:00
parent 4de31ed48c
commit 1eb5067260
2 changed files with 22 additions and 12 deletions

View file

@ -168,7 +168,9 @@ namespace PerformanceOverlay
try
{
osdClose();
// recreate OSD if not index 0
if (osd != null && osd.OSDIndex() != 0)
osdClose();
if (osd == null)
osd = new OSD("PerformanceOverlay");

View file

@ -1,4 +1,4 @@
using CommonHelpers;
using CommonHelpers;
using CommonHelpers.FromLibreHardwareMonitor;
using Microsoft.VisualBasic.Logging;
using PowerControl.External;
@ -243,20 +243,15 @@ namespace PowerControl
{
if (!rootMenu.Visible)
{
try
{
if (osd != null)
osd.Dispose();
osd = null;
}
catch (SystemException)
{
}
osdClose();
return;
}
try
{
// recreate OSD if not index 0
if (osd != null && osd.OSDIndex() == 0)
osdClose();
if (osd == null)
osd = new OSD("Power Control");
osd.Update(rootMenu.Render(null));
@ -274,7 +269,20 @@ namespace PowerControl
public void Dispose()
{
components.Dispose();
hideOSD();
osdClose();
}
private void osdClose()
{
try
{
if (osd != null)
osd.Dispose();
osd = null;
}
catch (SystemException)
{
}
}
}
}