This commit is contained in:
Frank Skare
2019-06-17 21:35:14 +02:00
parent 29a0eae3d5
commit 87e3d9ca3e
7 changed files with 35 additions and 26 deletions

View File

@@ -1,4 +1,8 @@
### 4.2 Letting Go ### 4.3
- there was new bug in file association feature
### 4.2
- the help and layout in the config editor was improved - the help and layout in the config editor was improved
- clipboard monitoring for URLs can be disabled in the settings - clipboard monitoring for URLs can be disabled in the settings

View File

@@ -212,14 +212,18 @@ namespace mpvnet
public static void RemoveKey(string path) public static void RemoveKey(string path)
{ {
try {
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false); GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
} catch { }
} }
public static void RemoveValue(string path, string name) public static void RemoveValue(string path, string name)
{ {
try {
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5), true)) using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5), true))
if (!(rk is null)) if (!(rk is null))
rk.DeleteValue(name, false); rk.DeleteValue(name, false);
} catch {}
} }
static RegistryKey GetRootKey(string path) static RegistryKey GetRootKey(string path)

View File

@@ -13,8 +13,6 @@ namespace mpvnet
[STAThread] [STAThread]
static void Main() static void Main()
{ {
Mutex mutex = new Mutex(true, "mpvnetProcessInstance", out bool isFirst);
try try
{ {
string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray(); string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
@@ -27,6 +25,7 @@ namespace mpvnet
return; return;
} }
Mutex mutex = new Mutex(true, "mpvnetProcessInstance", out bool isFirst);
App.Init(); App.Init();
if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst) if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst)
@@ -56,15 +55,12 @@ namespace mpvnet
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm()); Application.Run(new MainForm());
mutex.Dispose();
} }
catch (Exception ex) catch (Exception ex)
{ {
Msg.ShowException(ex); Msg.ShowException(ex);
} }
finally
{
mutex.Dispose();
}
} }
} }
} }

View File

@@ -27,6 +27,9 @@ namespace mpvnet
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll", SetLastError = true)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags); public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
[DllImport("user32.dll")]
public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
[DllImport("user32.dll", EntryPoint = "GetWindowLong")] [DllImport("user32.dll", EntryPoint = "GetWindowLong")]
private static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex); private static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.2.0.0")] [assembly: AssemblyVersion("4.3.0.0")]
[assembly: AssemblyFileVersion("4.2.0.0")] [assembly: AssemblyFileVersion("4.3.0.0")]

View File

@@ -343,6 +343,11 @@ namespace mpvnet
if (mp.WindowHandle != IntPtr.Zero) if (mp.WindowHandle != IntPtr.Zero)
Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam); Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
break; break;
case 0x0200: // WM_MOUSEMOVE
Point pos = PointToClient(Cursor.Position);
mp.command_string($"mouse {pos.X} {pos.Y}");
if (CursorHelp.IsPosDifferent(LastCursorPosChanged)) CursorHelp.Show();
break;
case 0x319: // WM_APPCOMMAND case 0x319: // WM_APPCOMMAND
if (mp.WindowHandle != IntPtr.Zero) if (mp.WindowHandle != IntPtr.Zero)
Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam); Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
@@ -389,7 +394,6 @@ namespace mpvnet
break; break;
case "queue": case "queue":
foreach (string file in files) foreach (string file in files)
if (File.Exists(file))
mp.commandv("loadfile", file, "append"); mp.commandv("loadfile", file, "append");
break; break;
} }
@@ -436,15 +440,6 @@ namespace mpvnet
mp.commandv("quit"); mp.commandv("quit");
} }
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
mp.command_string($"mouse {e.X} {e.Y}");
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
CursorHelp.Show();
}
bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9; bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
void Timer_Tick(object sender, EventArgs e) void Timer_Tick(object sender, EventArgs e)

View File

@@ -193,7 +193,10 @@ namespace mpvnet
mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event)); mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event));
if (WindowHandle == IntPtr.Zero) if (WindowHandle == IntPtr.Zero)
{
WindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null); WindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null);
//Native.EnableWindow(WindowHandle, true);
}
//Debug.WriteLine(evt.event_id.ToString()); //Debug.WriteLine(evt.event_id.ToString());
@@ -563,9 +566,12 @@ namespace mpvnet
HideLogo(); HideLogo();
List<string> fileList = files.ToList(); List<string> fileList = files.ToList();
foreach (string file in files) { foreach (string file in files)
{
string ext = Path.GetExtension(file).TrimStart('.').ToLower(); string ext = Path.GetExtension(file).TrimStart('.').ToLower();
if (App.SubtitleTypes.Contains(ext)) {
if (App.SubtitleTypes.Contains(ext))
{
mp.commandv("sub-add", file); mp.commandv("sub-add", file);
fileList.Remove(file); fileList.Remove(file);
} }
@@ -573,6 +579,7 @@ namespace mpvnet
if (fileList.Count == 0) return; if (fileList.Count == 0) return;
files = fileList.ToArray(); files = fileList.ToArray();
int count = mp.get_property_int("playlist-count"); int count = mp.get_property_int("playlist-count");
foreach (string file in files) foreach (string file in files)