mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Windows - Fix crash when clicking on update notification
Meta - Code cleanup
This commit is contained in:
1 parent
cdd814d920
commit
3994b49f08
36 files changed
+201
-193
No files matched your search
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
@@ -27,7 +26,7 @@ public interface ICoreService : IArtemisService, IDisposable
|
||||
/// Gets or sets whether profiles are rendered each frame by calling their Render method
|
||||
/// </summary>
|
||||
bool ProfileRenderingDisabled { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether Artemis is running in an elevated environment (admin permissions)
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
internal class ProcessComparer : IEqualityComparer<Process>
|
||||
{
|
||||
public bool Equals(Process? x, Process? y)
|
||||
{
|
||||
if (x == null && y == null) return true;
|
||||
if (x == null || y == null) return false;
|
||||
return x.Id == y.Id && x.ProcessName == y.ProcessName && x.SessionId == y.SessionId;
|
||||
}
|
||||
|
||||
public int GetHashCode(Process? obj)
|
||||
{
|
||||
if (obj == null) return 0;
|
||||
return obj.Id;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using Artemis.Core.Modules;
|
||||
using Serilog;
|
||||
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
@@ -42,20 +41,4 @@ internal class ProcessMonitorService : IProcessMonitorService
|
||||
{
|
||||
return _lastScannedProcesses;
|
||||
}
|
||||
}
|
||||
|
||||
internal class ProcessComparer : IEqualityComparer<Process>
|
||||
{
|
||||
public bool Equals(Process? x, Process? y)
|
||||
{
|
||||
if (x == null && y == null) return true;
|
||||
if (x == null || y == null) return false;
|
||||
return x.Id == y.Id && x.ProcessName == y.ProcessName && x.SessionId == y.SessionId;
|
||||
}
|
||||
|
||||
public int GetHashCode(Process? obj)
|
||||
{
|
||||
if (obj == null) return 0;
|
||||
return obj.Id;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,24 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
StartWebServer();
|
||||
}
|
||||
|
||||
public event EventHandler? WebServerStopped;
|
||||
public event EventHandler? WebServerStarted;
|
||||
|
||||
protected virtual void OnWebServerStopped()
|
||||
{
|
||||
WebServerStopped?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnWebServerStarting()
|
||||
{
|
||||
WebServerStarting?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnWebServerStarted()
|
||||
{
|
||||
WebServerStarted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void WebServerEnabledSettingOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
StartWebServer();
|
||||
@@ -76,6 +94,7 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
|
||||
public WebServer? Server { get; private set; }
|
||||
public PluginsModule PluginsModule { get; }
|
||||
public event EventHandler? WebServerStarting;
|
||||
|
||||
|
||||
#region Web server managament
|
||||
@@ -129,7 +148,7 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
|
||||
if (!_webServerEnabledSetting.Value)
|
||||
return;
|
||||
|
||||
|
||||
if (Constants.StartupArguments.Contains("--disable-webserver"))
|
||||
{
|
||||
_logger.Warning("Artemis launched with --disable-webserver, not enabling the webserver");
|
||||
@@ -302,27 +321,4 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
protected virtual void OnWebServerStopped()
|
||||
{
|
||||
WebServerStopped?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnWebServerStarting()
|
||||
{
|
||||
WebServerStarting?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnWebServerStarted()
|
||||
{
|
||||
WebServerStarted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event EventHandler? WebServerStopped;
|
||||
public event EventHandler? WebServerStarting;
|
||||
public event EventHandler? WebServerStarted;
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user