replace v6 with experimental v7 code
This commit is contained in:
20
src/MpvNet/Help/FileHelp.cs
Normal file
20
src/MpvNet/Help/FileHelp.cs
Normal 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) : "";
|
||||
}
|
||||
26
src/MpvNet/Help/MpvHelp.cs
Normal file
26
src/MpvNet/Help/MpvHelp.cs
Normal 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,
|
||||
};
|
||||
}
|
||||
15
src/MpvNet/Help/ProcessHelp.cs
Normal file
15
src/MpvNet/Help/ProcessHelp.cs
Normal 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);
|
||||
}
|
||||
16
src/MpvNet/Help/StringHelp.cs
Normal file
16
src/MpvNet/Help/StringHelp.cs
Normal 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("-", "");
|
||||
}
|
||||
}
|
||||
21
src/MpvNet/Help/TaskHelp.cs
Normal file
21
src/MpvNet/Help/TaskHelp.cs
Normal 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user