Detect RTSS missing

This commit is contained in:
Kamil Trzciński 2022-11-13 15:51:20 +01:00
parent 10daa36bd6
commit 302dd58551
5 changed files with 50 additions and 33 deletions

View file

@ -15,10 +15,13 @@ namespace PerformanceOverlay
internal class Controller : IDisposable
{
public const String Title = "Performance Overlay";
public readonly String TitleWithVersion = Title + " v" + Application.ProductVersion.ToString();
Container components = new Container();
RTSSSharedMemoryNET.OSD? osd;
ToolStripMenuItem showItem;
System.Windows.Forms.NotifyIcon notifyIcon;
System.Windows.Forms.Timer osdTimer;
Sensors sensors = new Sensors();
StartupManager startupManager = new StartupManager(
Title,
@ -81,13 +84,13 @@ namespace PerformanceOverlay
exitItem.Click += ExitItem_Click;
notifyIcon = new System.Windows.Forms.NotifyIcon(components);
notifyIcon.Icon = Resources.traffic_light_outline1;
notifyIcon.Text = Title;
notifyIcon.Icon = Resources.traffic_light_outline;
notifyIcon.Text = TitleWithVersion;
notifyIcon.Visible = true;
notifyIcon.ContextMenuStrip = contextMenu;
notifyIcon.Click += NotifyIcon_Click;
var osdTimer = new System.Windows.Forms.Timer(components);
osdTimer = new System.Windows.Forms.Timer(components);
osdTimer.Tick += OsdTimer_Tick;
osdTimer.Interval = 250;
osdTimer.Enabled = true;
@ -143,20 +146,26 @@ namespace PerformanceOverlay
{
try
{
notifyIcon.Text = Title + ". RTSS Version: " + OSD.Version;
notifyIcon.Text = TitleWithVersion + ". RTSS Version: " + OSD.Version;
notifyIcon.Icon = Resources.traffic_light_outline;
}
catch
{
notifyIcon.Text = Title + ". RTSS Not Available.";
notifyIcon.Text = TitleWithVersion + ". RTSS Not Available.";
notifyIcon.Icon = Resources.traffic_light_outline_red;
osdReset();
return;
}
if (!showItem.Checked)
{
using (osd) { }
osd = null;
osdTimer.Interval = 1000;
osdReset();
return;
}
osdTimer.Interval = 250;
sensors.Update();
var osdOverlay = Overlays.GetOSD(Settings.Default.OSDModeParsed, sensors);
@ -174,10 +183,34 @@ namespace PerformanceOverlay
}
catch(SystemException)
{
osd = null;
}
}
private void osdReset()
{
try
{
if (osd != null)
osd.Update("");
}
catch (SystemException)
{
}
}
private void osdClose()
{
try
{
if (osd != null)
osd.Dispose();
}
catch (SystemException)
{
}
osd = null;
}
private uint osdEmbedGraph(ref uint offset, ref String osdOverlay, String name, int dwWidth, int dwHeight, int dwMargin, float fltMin, float fltMax, EMBEDDED_OBJECT_GRAPH dwFlags)
{
uint size = osd.EmbedGraph(offset, new float[0], 0, dwWidth, dwHeight, dwMargin, fltMin, fltMax, dwFlags);
@ -195,7 +228,7 @@ namespace PerformanceOverlay
public void Dispose()
{
components.Dispose();
using (osd) { }
osdClose();
using (sensors) { }
}
}

View file

@ -10,22 +10,6 @@ namespace PerformanceOverlay
{
ApplicationConfiguration.Initialize();
try
{
foreach (var entry in RTSSSharedMemoryNET.OSD.GetOSDEntries())
{
Trace.WriteLine("Entry: {0}", entry.Owner);
Trace.WriteLine("\t", entry.Text);
using (var newOSD = new OSD("New OSD"))
{
newOSD.Update(entry.Text);
}
}
}
catch(SystemException)
{ }
using (var controller = new Controller())
{
Application.Run();

View file

@ -61,21 +61,21 @@ namespace PerformanceOverlay {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Bitmap traffic_light_outline {
internal static System.Drawing.Icon traffic_light_outline {
get {
object obj = ResourceManager.GetObject("traffic_light_outline", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon traffic_light_outline1 {
internal static System.Drawing.Icon traffic_light_outline_red {
get {
object obj = ResourceManager.GetObject("traffic_light_outline1", resourceCulture);
object obj = ResourceManager.GetObject("traffic_light_outline_red", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}

View file

@ -119,9 +119,9 @@
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="traffic_light_outline" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\traffic-light-outline.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="traffic_light_outline1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\traffic-light-outline.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="traffic_light_outline_red" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\traffic-light-outline-red.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB