- fix: memory leak part 1
This commit is contained in:
20
Nebula.Launcher/Utils/ColorUtils.cs
Normal file
20
Nebula.Launcher/Utils/ColorUtils.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Nebula.Launcher.Utils;
|
||||
|
||||
public static class ColorUtils
|
||||
{
|
||||
public static Color GetColorFromString(string input)
|
||||
{
|
||||
var hash = MD5.HashData(Encoding.UTF8.GetBytes(input));
|
||||
|
||||
var r = byte.Clamp(hash[0], 10, 200);
|
||||
var g = byte.Clamp(hash[1], 10, 100);
|
||||
var b = byte.Clamp(hash[2], 10, 100);
|
||||
|
||||
return Color.FromArgb(Byte.MaxValue, r, g, b);
|
||||
}
|
||||
}
|
||||
33
Nebula.Launcher/Utils/ExplorerUtils.cs
Normal file
33
Nebula.Launcher/Utils/ExplorerUtils.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Nebula.Launcher.Utils;
|
||||
|
||||
|
||||
public static class ExplorerUtils
|
||||
{
|
||||
public static void OpenFolder(string path)
|
||||
{
|
||||
string command;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
command = "explorer.exe";
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
command = "xdg-open";
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
command = "open";
|
||||
else
|
||||
throw new PlatformNotSupportedException("Unsupported OS platform");
|
||||
|
||||
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = command,
|
||||
Arguments = path,
|
||||
UseShellExecute = false
|
||||
};
|
||||
|
||||
Process.Start(startInfo);
|
||||
}
|
||||
}
|
||||
29
Nebula.Launcher/Utils/VCRuntimeDllChecker.cs
Normal file
29
Nebula.Launcher/Utils/VCRuntimeDllChecker.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Nebula.Launcher.Utils;
|
||||
|
||||
public static class VCRuntimeDllChecker
|
||||
{
|
||||
public static bool AreVCRuntimeDllsPresent()
|
||||
{
|
||||
if (!OperatingSystem.IsWindows()) return true;
|
||||
|
||||
string systemDir = Environment.SystemDirectory;
|
||||
string[] requiredDlls = {
|
||||
"msvcp140.dll",
|
||||
"vcruntime140.dll"
|
||||
};
|
||||
|
||||
foreach (var dll in requiredDlls)
|
||||
{
|
||||
var path = Path.Combine(systemDir, dll);
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user