replace v6 with experimental v7 code

This commit is contained in:
stax76
2023-10-24 11:17:45 +02:00
parent fb27bb8727
commit 5706d7b66d
212 changed files with 15014 additions and 12173 deletions

View File

@@ -0,0 +1,20 @@

namespace MpvNet.Help;
public static class FileHelp
{
public static void Delete(string path)
{
try
{
if (File.Exists(path))
File.Delete(path);
}
catch (Exception ex)
{
Terminal.WriteError("Failed to delete file:" + BR + path + BR + ex.Message);
}
}
public static string ReadTextFile(string path) => File.Exists(path) ? File.ReadAllText(path) : "";
}

View File

@@ -0,0 +1,26 @@

namespace MpvNet.Help;
public class MpvHelp
{
public static string? WM_APPCOMMAND_to_mpv_key(int value) => value switch
{
5 => "SEARCH", // BROWSER_SEARCH
6 => "FAVORITES", // BROWSER_FAVORITES
7 => "HOMEPAGE", // BROWSER_HOME
15 => "MAIL", // LAUNCH_MAIL
33 => "PRINT", // PRINT
11 => "NEXT", // MEDIA_NEXTTRACK
12 => "PREV", // MEDIA_PREVIOUSTRACK
13 => "STOP", // MEDIA_STOP
14 => "PLAYPAUSE", // MEDIA_PLAY_PAUSE
46 => "PLAY", // MEDIA_PLAY
47 => "PAUSE", // MEDIA_PAUSE
48 => "RECORD", // MEDIA_RECORD
49 => "FORWARD", // MEDIA_FAST_FORWARD
50 => "REWIND", // MEDIA_REWIND
51 => "CHANNEL_UP", // MEDIA_CHANNEL_UP
52 => "CHANNEL_DOWN", // MEDIA_CHANNEL_DOWN
_ => null,
};
}

View File

@@ -0,0 +1,15 @@
namespace MpvNet.Help;
public static class ProcessHelp
{
public static void Execute(string file, string arguments = "", bool shellExecute = false)
{
using Process proc = new Process();
proc.StartInfo.FileName = file;
proc.StartInfo.Arguments = arguments;
proc.StartInfo.UseShellExecute = shellExecute;
proc.Start();
}
public static void ShellExecute(string file, string arguments = "") => Execute(file, arguments, true);
}

View File

@@ -0,0 +1,16 @@

using System.Security.Cryptography;
using System.Text;
namespace MpvNet.Help;
public static class StringHelp
{
public static string GetMD5Hash(string txt)
{
using MD5 md5 = MD5.Create();
byte[] inputBuffer = Encoding.UTF8.GetBytes(txt);
byte[] hashBuffer = md5.ComputeHash(inputBuffer);
return BitConverter.ToString(md5.ComputeHash(inputBuffer)).Replace("-", "");
}
}

View File

@@ -0,0 +1,21 @@

using System.Threading.Tasks;
namespace MpvNet.Help;
public class TaskHelp
{
public static void Run(Action action)
{
Task.Run(() => {
try
{
action.Invoke();
}
catch (Exception e)
{
Terminal.WriteError(e);
}
});
}
}