Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7575a2d736 | ||
|
|
17c198e711 | ||
|
|
1f8635e9c4 | ||
|
|
37e6c198a1 | ||
|
|
751c8779f4 | ||
|
|
9e2bf46636 | ||
|
|
3529323d93 | ||
|
|
ba52c1f8b5 | ||
|
|
bf2070d758 | ||
|
|
7a1de4cf0f | ||
|
|
caf0bee161 |
16
Changelog.md
16
Changelog.md
@@ -1,3 +1,19 @@
|
||||
### 4.6
|
||||
|
||||
- fix for middle mouse button not working
|
||||
- fix of logo overlay using a huge amount of memory (thx for the [ghacks article](https://www.ghacks.net/2019/07/05/a-look-at-mpv-net-a-mpv-frontend-with-everything-integration/))
|
||||
- fix config dialog showing a message about app restart without reason
|
||||
- when multiple files are selected in Windows File Explorer and enter is
|
||||
pressed, the files are opened as selected, the order is random though
|
||||
because Explorer starts multiple mpv.net processes concurrently
|
||||
- libmpv was updated to shinchiro 2019-06-30
|
||||
- the [mpv.conf defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt) were changed to show a larger OSC
|
||||
- in case a file is opened that has a aspect ratio smaller then 1.2 then
|
||||
the window size will use a aspect ratio of 1.8
|
||||
- new JavaScript script osc-visibility.js included in the distribution
|
||||
under startup\scripts. It sets the OSC to be always on for audio files
|
||||
and auto for non audio files
|
||||
|
||||
### 4.5
|
||||
|
||||
- opening a URL manually no longer uses a input box but uses the clipboard directly
|
||||
|
||||
@@ -52,12 +52,13 @@ Table of contents
|
||||
- Searchable command palette to quickly launch commands and look for keys ([Screenshot](#command-palette-screenshot))
|
||||
- Modern UI with dark mode ([Screenshot](#config-editor-screenshot))
|
||||
- Addon/extension API for .NET languages
|
||||
- Scripting API for Python, C#, Lua, JavaScript and PowerShell ([wiki](https://github.com/stax76/mpv.net/wiki/Scripting))
|
||||
- Scripting API for Python, C#, Lua, JavaScript and PowerShell ([Wiki](https://github.com/stax76/mpv.net/wiki/Scripting))
|
||||
- mpv's OSC, IPC and conf files
|
||||
- [Command Line Interface](https://mpv.io/manual/master/#options)
|
||||
- DXVA2 video decoding acceleration
|
||||
- OpenGL based video output capable of features loved by videophiles, such as video scaling with popular high quality algorithms, color management, frame timing, interpolation, HDR, and more
|
||||
- Search feature powered by [Everything](https://www.voidtools.com) to find and play media ([Screenshot](#media-search-screenshot))
|
||||
- Extension to start mpv.net from Google Chrome ([Manual](Manual.md#chrome-extension))
|
||||
|
||||
### Screenshots
|
||||
|
||||
@@ -86,7 +87,7 @@ A searchable key and mouse binding editor.
|
||||
#### Command Palette Screenshot
|
||||
|
||||
Forgot where a command in the menu is located or what shortcut key it has?
|
||||
Just press Ctrl+Shift+P and find it easily in the searchable command palette.
|
||||
Just press F1 and find it easily in the searchable command palette.
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -1752,7 +1752,6 @@ namespace Tommy
|
||||
}
|
||||
else
|
||||
stringBuilder.Append(c);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Interop;
|
||||
|
||||
@@ -13,42 +12,43 @@ namespace mpvnet
|
||||
{
|
||||
public class Command
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Action<string[]> Action { get; set; }
|
||||
|
||||
static List<Command> commands;
|
||||
|
||||
public static List<Command> Commands
|
||||
public static void Execute(string id, string[] args)
|
||||
{
|
||||
get
|
||||
switch (id)
|
||||
{
|
||||
if (commands == null)
|
||||
{
|
||||
commands = new List<Command>();
|
||||
Type type = typeof(Command);
|
||||
MethodInfo[] methods = type.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
|
||||
|
||||
foreach (MethodInfo i in methods)
|
||||
{
|
||||
ParameterInfo[] parameters = i.GetParameters();
|
||||
|
||||
if (parameters == null ||
|
||||
parameters.Length != 1 ||
|
||||
parameters[0].ParameterType != typeof(string[]))
|
||||
continue;
|
||||
|
||||
Command cmd = new Command() {
|
||||
Name = i.Name.Replace("_", "-"),
|
||||
Action = (Action<string[]>)i.CreateDelegate(typeof(Action<string[]>)) };
|
||||
|
||||
commands.Add(cmd);
|
||||
}
|
||||
}
|
||||
return commands;
|
||||
case "manage-file-associations": ManageFileAssociations(); break;
|
||||
case "cycle-audio": CycleAudio(); break;
|
||||
case "load-audio": LoadAudio(); break;
|
||||
case "load-sub": LoadSubtitle(); break;
|
||||
case "open-url": OpenURL(); break;
|
||||
case "execute-mpv-command": ExecuteMpvCommand(); break;
|
||||
case "show-history": ShowHistory(); break;
|
||||
case "show-media-search": ShowDialog(typeof(EverythingWindow)); break;
|
||||
case "show-command-palette": ShowDialog(typeof(CommandPaletteWindow)); break;
|
||||
case "show-about": ShowDialog(typeof(AboutWindow)); break;
|
||||
case "show-conf-editor": ShowDialog(typeof(ConfWindow)); break;
|
||||
case "show-input-editor": ShowDialog(typeof(InputWindow)); break;
|
||||
case "open-conf-folder": Process.Start(mp.ConfFolder); break;
|
||||
case "open-files": OpenFiles(args); break;
|
||||
case "shell-execute": Process.Start(args[0]); break;
|
||||
case "show-info": ShowInfo(); break;
|
||||
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
|
||||
default: Msg.ShowError($"No command '{id}' found."); break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void open_files(string[] args)
|
||||
public static void InvokeOnMainThread(Action action) => MainForm.Instance.Invoke(action);
|
||||
|
||||
public static void ShowDialog(Type winType)
|
||||
{
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
Window win = Activator.CreateInstance(winType) as Window;
|
||||
new WindowInteropHelper(win).Owner = MainForm.Instance.Handle;
|
||||
win.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void OpenFiles(params string[] args)
|
||||
{
|
||||
bool append = Control.ModifierKeys.HasFlag(Keys.Control);
|
||||
bool loadFolder = true;
|
||||
@@ -59,75 +59,14 @@ namespace mpvnet
|
||||
if (arg == "no-folder") loadFolder = false;
|
||||
}
|
||||
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var d = new OpenFileDialog() { Multiselect = true })
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
mp.Load(d.FileNames, loadFolder, append);
|
||||
}));
|
||||
}
|
||||
|
||||
// deprecated in 2019
|
||||
public static void add_files_to_playlist(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
using (var d = new OpenFileDialog() { Multiselect = true })
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
foreach (string file in d.FileNames)
|
||||
mp.commandv("loadfile", file, "append");
|
||||
}));
|
||||
}
|
||||
|
||||
public static void open_conf_folder(string[] args)
|
||||
{
|
||||
Process.Start(mp.ConfFolder);
|
||||
}
|
||||
|
||||
public static void show_input_editor(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
InputWindow w = new InputWindow();
|
||||
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
|
||||
w.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void show_conf_editor(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
ConfWindow w = new ConfWindow();
|
||||
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
|
||||
w.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void show_about(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
AboutWindow w = new AboutWindow();
|
||||
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
|
||||
w.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void show_command_palette(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
var w = new CommandPaletteWindow();
|
||||
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
|
||||
w.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void show_media_search(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
var w = new EverythingWindow();
|
||||
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
|
||||
w.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void show_history(string[] args)
|
||||
public static void ShowHistory()
|
||||
{
|
||||
var fp = mp.ConfFolder + "history.txt";
|
||||
|
||||
@@ -139,9 +78,7 @@ namespace mpvnet
|
||||
File.WriteAllText(fp, "");
|
||||
}
|
||||
|
||||
public static void shell_execute(string[] args) => Process.Start(args[0]);
|
||||
|
||||
public static void show_info(string[] args)
|
||||
public static void ShowInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -205,9 +142,9 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
public static void execute_mpv_command(string[] args)
|
||||
public static void ExecuteMpvCommand()
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegHelp.GetString(App.RegPath, "RecentExecutedCommand"));
|
||||
if (string.IsNullOrEmpty(command)) return;
|
||||
RegHelp.SetObject(App.RegPath, "RecentExecutedCommand", command);
|
||||
@@ -215,22 +152,22 @@ namespace mpvnet
|
||||
}));
|
||||
}
|
||||
|
||||
public static void open_url(string[] args)
|
||||
public static void OpenURL()
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
string clipboard = Clipboard.GetText();
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
string clipboard = System.Windows.Forms.Clipboard.GetText();
|
||||
if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) || clipboard.Contains("\n"))
|
||||
{
|
||||
Msg.ShowError("The clipboard does not contain a valid URL or file, URLs have to contain :// and is not allowed to contain a newline character.");
|
||||
Msg.ShowError("The clipboard does not contain a valid URL or file, URLs have to contain :// and are not allowed to contain a newline character.");
|
||||
return;
|
||||
}
|
||||
mp.Load(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
}));
|
||||
}
|
||||
|
||||
public static void load_sub(string[] args)
|
||||
public static void LoadSubtitle()
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var d = new OpenFileDialog())
|
||||
{
|
||||
d.InitialDirectory = Path.GetDirectoryName(mp.get_property_string("path", false));
|
||||
@@ -242,9 +179,9 @@ namespace mpvnet
|
||||
}));
|
||||
}
|
||||
|
||||
public static void load_audio(string[] args)
|
||||
public static void LoadAudio()
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var d = new OpenFileDialog())
|
||||
{
|
||||
d.InitialDirectory = Path.GetDirectoryName(mp.get_property_string("path", false));
|
||||
@@ -257,7 +194,7 @@ namespace mpvnet
|
||||
}));
|
||||
}
|
||||
|
||||
public static void cycle_audio(string[] args)
|
||||
public static void CycleAudio()
|
||||
{
|
||||
string filePath = mp.get_property_string("path", false);
|
||||
if (!File.Exists(filePath)) return;
|
||||
@@ -274,7 +211,7 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
public static void manage_file_associations(string[] args)
|
||||
public static void ManageFileAssociations()
|
||||
{
|
||||
using (var td = new TaskDialog<string>())
|
||||
{
|
||||
@@ -291,14 +228,10 @@ namespace mpvnet
|
||||
{
|
||||
using (var proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = Application.ExecutablePath;
|
||||
proc.StartInfo.FileName = System.Windows.Forms.Application.ExecutablePath;
|
||||
proc.StartInfo.Arguments = "--reg-file-assoc " + result;
|
||||
proc.StartInfo.Verb = "runas";
|
||||
try {
|
||||
proc.Start();
|
||||
}
|
||||
catch (Exception)
|
||||
{ }
|
||||
try { proc.Start(); } catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,15 +109,9 @@ namespace mpvnet
|
||||
}
|
||||
else
|
||||
{
|
||||
string switchName = i.Substring(2);
|
||||
|
||||
switch (switchName)
|
||||
{
|
||||
case "fs":
|
||||
case "fullscreen":
|
||||
mp.Fullscreen = true;
|
||||
break;
|
||||
}
|
||||
string name = i.Substring(2);
|
||||
mp.ProcessProperty(name, "yes");
|
||||
ProcessProperty(name, "yes");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,6 +222,13 @@ namespace mpvnet
|
||||
return val.ToString();
|
||||
}
|
||||
|
||||
public static int GetInt(string path, string name)
|
||||
{
|
||||
object val = GetObject(path, name);
|
||||
if (val == null || !(val is int)) return 0;
|
||||
return (int)val;
|
||||
}
|
||||
|
||||
public static object GetObject(string path, string name)
|
||||
{
|
||||
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5)))
|
||||
@@ -393,15 +394,4 @@ namespace mpvnet
|
||||
Math.Abs(screenPos.Y - Control.MousePosition.Y) > 10;
|
||||
}
|
||||
}
|
||||
|
||||
public class SingleProcess
|
||||
{
|
||||
public static int Message { get; } = RegisterWindowMessage("mpvnet_IPC");
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
static extern int RegisterWindowMessage(string id);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AllowSetForegroundWindow(int dwProcessId);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -31,24 +32,31 @@ namespace mpvnet
|
||||
if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst)
|
||||
{
|
||||
List<string> files = new List<string>();
|
||||
files.Add(App.ProcessInstance);
|
||||
|
||||
foreach (string arg in args)
|
||||
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") || File.Exists(arg)))
|
||||
files.Add(arg);
|
||||
|
||||
if (files.Count > 0)
|
||||
RegHelp.SetObject(App.RegPath, "ShellFiles", files.ToArray());
|
||||
Process[] procs = Process.GetProcessesByName("mpvnet");
|
||||
|
||||
RegHelp.SetObject(App.RegPath, "ProcessInstanceMode", App.ProcessInstance);
|
||||
|
||||
foreach(Process process in Process.GetProcessesByName("mpvnet"))
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
try {
|
||||
SingleProcess.AllowSetForegroundWindow(process.Id);
|
||||
Native.SendMessage(process.MainWindowHandle, SingleProcess.Message, IntPtr.Zero, IntPtr.Zero);
|
||||
} catch {}
|
||||
foreach (Process proc in procs)
|
||||
{
|
||||
if (proc.MainWindowHandle != IntPtr.Zero)
|
||||
{
|
||||
Native.AllowSetForegroundWindow(proc.Id);
|
||||
var data = new Native.COPYDATASTRUCT();
|
||||
data.lpData = string.Join("\n", files.ToArray());
|
||||
data.cbData = data.lpData.Length * 2 + 1;
|
||||
Native.SendMessage(proc.MainWindowHandle, 0x004A /*WM_COPYDATA*/, IntPtr.Zero, ref data);
|
||||
mutex.Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
|
||||
mutex.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,15 @@ namespace mpvnet
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AllowSetForegroundWindow(int dwProcessId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern void ReleaseCapture();
|
||||
|
||||
@@ -70,5 +76,14 @@ namespace mpvnet
|
||||
public int Width => Right - Left;
|
||||
public int Height => Bottom - Top;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct COPYDATASTRUCT
|
||||
{
|
||||
public IntPtr dwData;
|
||||
public int cbData;
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string lpData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("mpv.net")]
|
||||
[assembly: AssemblyDescription("A modern media player")]
|
||||
[assembly: AssemblyDescription("media player")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Frank Skare (stax76)")]
|
||||
[assembly: AssemblyProduct("mpv.net")]
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("4.5.0.0")]
|
||||
[assembly: AssemblyFileVersion("4.5.0.0")]
|
||||
[assembly: AssemblyVersion("4.6.0.0")]
|
||||
[assembly: AssemblyFileVersion("4.6.0.0")]
|
||||
|
||||
@@ -12,3 +12,4 @@ keep-open-pause = no
|
||||
osd-playing-msg = '${filename}'
|
||||
screenshot-directory = '~~desktop/'
|
||||
input-default-bindings = no
|
||||
script-opts=osc-scalewindowed=1.5
|
||||
@@ -59,7 +59,7 @@ namespace mpvnet
|
||||
if (setting.Name == pair.Key)
|
||||
{
|
||||
setting.Value = pair.Value.Trim('\'', '"');
|
||||
setting.StartValue = pair.Value;
|
||||
setting.StartValue = pair.Value.Trim('\'', '"');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,12 +224,28 @@ namespace mpvnet
|
||||
|
||||
void SetFormPosAndSize()
|
||||
{
|
||||
if (IsFullscreen || mp.VideoSize.Width == 0) return;
|
||||
if (IsFullscreen)
|
||||
return;
|
||||
|
||||
Size size = mp.VideoSize;
|
||||
Screen screen = Screen.FromControl(this);
|
||||
int height = mp.VideoSize.Height;
|
||||
if (mp.RememberHeight) height = ClientSize.Height;
|
||||
if (height > screen.Bounds.Height * 0.9) height = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
|
||||
int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.Height);
|
||||
int fixedHeight = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
|
||||
|
||||
if (size.Height == 0 || size.Width == 0 || size.Width / (float)size.Height < 1.2)
|
||||
{
|
||||
size.Height = fixedHeight;
|
||||
size.Width = (int)(fixedHeight * 1.8);
|
||||
}
|
||||
|
||||
int height = size.Height;
|
||||
|
||||
if (mp.RememberHeight)
|
||||
height = ClientSize.Height;
|
||||
|
||||
if (height > screen.Bounds.Height * 0.9)
|
||||
height = fixedHeight;
|
||||
|
||||
int width = Convert.ToInt32(height * size.Width / (double)size.Height);
|
||||
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
||||
var rect = new Native.RECT(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
|
||||
NativeHelp.AddWindowBorders(Handle, ref rect);
|
||||
@@ -329,6 +345,8 @@ namespace mpvnet
|
||||
case 0x0104: // WM_SYSKEYDOWN
|
||||
case 0x0105: // WM_SYSKEYUP
|
||||
case 0x020A: // WM_MOUSEWHEEL
|
||||
case 0x0207: // WM_MBUTTONDOWN
|
||||
case 0x0208: // WM_MBUTTONUP
|
||||
if (mp.WindowHandle != IntPtr.Zero)
|
||||
Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
@@ -363,22 +381,17 @@ namespace mpvnet
|
||||
int[] d_corners = { d_w, d_h, -d_w, -d_h };
|
||||
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
|
||||
int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32());
|
||||
|
||||
if (corner >= 0)
|
||||
corners[corner] -= d_corners[corner];
|
||||
|
||||
if (corner >= 0) corners[corner] -= d_corners[corner];
|
||||
Marshal.StructureToPtr<Native.RECT>(new Native.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
|
||||
m.Result = new IntPtr(1);
|
||||
return;
|
||||
}
|
||||
case 0x004A: // WM_COPYDATA
|
||||
var copyData = (Native.COPYDATASTRUCT)m.GetLParam(typeof(Native.COPYDATASTRUCT));
|
||||
string[] files = copyData.lpData.Split('\n');
|
||||
string mode = files[0];
|
||||
files = files.Skip(1).ToArray();
|
||||
|
||||
if (m.Msg == SingleProcess.Message)
|
||||
{
|
||||
object filesObject = RegHelp.GetObject(App.RegPath, "ShellFiles");
|
||||
|
||||
if (filesObject is string[] files)
|
||||
{
|
||||
switch (RegHelp.GetString(App.RegPath, "ProcessInstanceMode"))
|
||||
switch (mode)
|
||||
{
|
||||
case "single":
|
||||
mp.Load(files, true, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
@@ -388,9 +401,7 @@ namespace mpvnet
|
||||
mp.commandv("loadfile", file, "append");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RegHelp.RemoveValue(App.RegPath, "ShellFiles");
|
||||
Activate();
|
||||
return;
|
||||
}
|
||||
@@ -479,13 +490,13 @@ namespace mpvnet
|
||||
BuildMenu();
|
||||
ContextMenuStrip = ContextMenu;
|
||||
IgnoreDpiChanged = false;
|
||||
CheckUrlInClipboard();
|
||||
CheckClipboardForURL();
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
{
|
||||
base.OnActivated(e);
|
||||
CheckUrlInClipboard();
|
||||
CheckClipboardForURL();
|
||||
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP
|
||||
Native.SendMessage(Handle, m.Msg, m.WParam, m.LParam);
|
||||
}
|
||||
@@ -528,7 +539,7 @@ namespace mpvnet
|
||||
CursorHelp.Show();
|
||||
}
|
||||
|
||||
void CheckUrlInClipboard()
|
||||
void CheckClipboardForURL()
|
||||
{
|
||||
string clipboard = Clipboard.GetText();
|
||||
|
||||
|
||||
@@ -274,27 +274,8 @@ namespace mpvnet
|
||||
case mpv_event_id.MPV_EVENT_CLIENT_MESSAGE:
|
||||
var client_messageData = (mpv_event_client_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_client_message));
|
||||
string[] args = NativeUtf8StrArray2ManagedStrArray(client_messageData.args, client_messageData.num_args);
|
||||
|
||||
if (args.Length > 1 && args[0] == "mpv.net")
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
foreach (Command i in Command.Commands)
|
||||
{
|
||||
if (args[1] == i.Name)
|
||||
{
|
||||
found = true;
|
||||
i.Action.Invoke(args.Skip(2).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
List<string> names = mpvnet.Command.Commands.Select((item) => item.Name).ToList();
|
||||
names.Sort();
|
||||
Msg.ShowError($"No command '{args[1]}' found.", $"Available commands are:\n\n{string.Join("\n", names)}\n\nHow to bind these commands can be seen in the [default input bindings and menu definition](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt).");
|
||||
}
|
||||
}
|
||||
Command.Execute(args[1], args.Skip(2).ToArray());
|
||||
else if (args.Length > 0)
|
||||
ClientMessage?.Invoke(args);
|
||||
break;
|
||||
@@ -558,11 +539,18 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
static DateTime LastLoad;
|
||||
|
||||
public static void Load(string[] files, bool loadFolder, bool append)
|
||||
{
|
||||
if (files is null || files.Length == 0) return;
|
||||
HideLogo();
|
||||
|
||||
if ((DateTime.Now - LastLoad).TotalMilliseconds < 500)
|
||||
append = true;
|
||||
|
||||
LastLoad = DateTime.Now;
|
||||
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
if (App.SubtitleTypes.Contains(Path.GetExtension(files[i]).TrimStart('.').ToLower()))
|
||||
commandv("sub-add", files[i]);
|
||||
@@ -579,7 +567,7 @@ namespace mpvnet
|
||||
|
||||
public static void LoadFolder()
|
||||
{
|
||||
Thread.Sleep(50); // user reported race condition
|
||||
Thread.Sleep(200); // user reported race condition
|
||||
string path = get_property_string("path");
|
||||
if (!File.Exists(path) || get_property_int("playlist-count") != 1) return;
|
||||
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
|
||||
@@ -660,18 +648,20 @@ namespace mpvnet
|
||||
if (MainForm.Instance is null) return;
|
||||
Rectangle cr = MainForm.Instance.ClientRectangle;
|
||||
if (cr.Width == 0 || cr.Height == 0) return;
|
||||
int len = cr.Height / 5;
|
||||
|
||||
using (Bitmap b = new Bitmap(cr.Width, cr.Height))
|
||||
using (Bitmap b = new Bitmap(len, len))
|
||||
{
|
||||
using (Graphics g = Graphics.FromImage(b))
|
||||
{
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.Clear(Color.Black);
|
||||
int iconWidth = cr.Height / 7;
|
||||
Rectangle r = new Rectangle(cr.Width / 2 - iconWidth / 2, cr.Height / 2 - iconWidth / 2, iconWidth, iconWidth);
|
||||
g.DrawImage(Properties.Resources.mpvnet, r);
|
||||
BitmapData bd = b.LockBits(cr, ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb);
|
||||
commandv("overlay-add", "0", "0", "0", "&" + bd.Scan0.ToInt64().ToString(), "0", "bgra", bd.Width.ToString(), bd.Height.ToString(), bd.Stride.ToString());
|
||||
Rectangle rect = new Rectangle(0, 0, len, len);
|
||||
g.DrawImage(Properties.Resources.mpvnet, rect);
|
||||
BitmapData bd = b.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb);
|
||||
int x = Convert.ToInt32((cr.Width - len) / 2.0);
|
||||
int y = Convert.ToInt32(((cr.Height - len) / 2.0) * 0.9);
|
||||
commandv("overlay-add", "0", $"{x}", $"{y}", "&" + bd.Scan0.ToInt64().ToString(), "0", "bgra", bd.Width.ToString(), bd.Height.ToString(), bd.Stride.ToString());
|
||||
b.UnlockBits(bd);
|
||||
IsLogoVisible = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user