#263 enhancing mpv.net option process-instance
This commit is contained in:
@@ -1,12 +1,9 @@
|
|||||||
|
|
||||||
using System;
|
|
||||||
using System.CodeDom.Compiler;
|
using System.CodeDom.Compiler;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using Microsoft.CSharp;
|
using Microsoft.CSharp;
|
||||||
|
|
||||||
@@ -28,7 +25,7 @@ namespace mpvnet
|
|||||||
static void Execute(string file)
|
static void Execute(string file)
|
||||||
{
|
{
|
||||||
string code = File.ReadAllText(file);
|
string code = File.ReadAllText(file);
|
||||||
string filename = Path.GetFileNameWithoutExtension(file) + " " + GetMD5(code) + ".dll";
|
string filename = Path.GetFileNameWithoutExtension(file) + " " + StringHelp.GetMD5Hash(code) + ".dll";
|
||||||
string outputFile = Path.Combine(Path.GetTempPath(), filename);
|
string outputFile = Path.Combine(Path.GetTempPath(), filename);
|
||||||
|
|
||||||
if (!File.Exists(outputFile))
|
if (!File.Exists(outputFile))
|
||||||
@@ -70,15 +67,5 @@ namespace mpvnet
|
|||||||
if (errors.Count() > 0)
|
if (errors.Count() > 0)
|
||||||
Terminal.WriteError(string.Join(BR2, errors), Path.GetFileName(file));
|
Terminal.WriteError(string.Join(BR2, errors), Path.GetFileName(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
static string GetMD5(string code)
|
|
||||||
{
|
|
||||||
using (MD5 md5 = MD5.Create())
|
|
||||||
{
|
|
||||||
byte[] inputBuffer = Encoding.UTF8.GetBytes(code);
|
|
||||||
byte[] hashBuffer = md5.ComputeHash(inputBuffer);
|
|
||||||
return BitConverter.ToString(md5.ComputeHash(inputBuffer)).Replace("-", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ using System.Diagnostics;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
@@ -12,6 +14,19 @@ using static mpvnet.Global;
|
|||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
|
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("-", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class FileHelp
|
public static class FileHelp
|
||||||
{
|
{
|
||||||
public static void Delete(string path)
|
public static void Delete(string path)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
|
|
||||||
App.Init();
|
App.Init();
|
||||||
Mutex mutex = new Mutex(true, "mpvnetProcessInstance", out bool isFirst);
|
Mutex mutex = new Mutex(true, StringHelp.GetMD5Hash(App.ConfPath), out bool isFirst);
|
||||||
|
|
||||||
if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst)
|
if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -815,7 +815,7 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
else if (Environment.TickCount - LastCursorChanged > 1500 &&
|
else if (Environment.TickCount - LastCursorChanged > 1500 &&
|
||||||
!IsMouseInOSC() && ClientRectangle.Contains(PointToClient(MousePosition)) &&
|
!IsMouseInOSC() && ClientRectangle.Contains(PointToClient(MousePosition)) &&
|
||||||
Form.ActiveForm == this && !ContextMenu.Visible)
|
ActiveForm == this && !ContextMenu.Visible)
|
||||||
|
|
||||||
CursorHelp.Hide();
|
CursorHelp.Hide();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user