-
This commit is contained in:
@@ -11,18 +11,24 @@ Public Class CSScriptAddon
|
|||||||
Implements IAddon
|
Implements IAddon
|
||||||
|
|
||||||
Sub New()
|
Sub New()
|
||||||
Dim scriptDir = mp.MpvConfFolder + "scripts"
|
Dim scriptFiles As New List(Of String)
|
||||||
If Not Directory.Exists(scriptDir) Then Return
|
|
||||||
Dim csFiles = Directory.GetFiles(scriptDir, "*.cs").ToList
|
If Directory.Exists(mp.MpvConfFolder + "scripts") Then
|
||||||
csFiles.AddRange(Directory.GetFiles(Application.StartupPath + "\\Scripts", "*.cs"))
|
scriptFiles.AddRange(Directory.GetFiles(mp.MpvConfFolder + "scripts", "*.cs"))
|
||||||
If csFiles.Count = 0 Then Return
|
End If
|
||||||
|
|
||||||
|
If Directory.Exists(Application.StartupPath + "\scripts") Then
|
||||||
|
scriptFiles.AddRange(Directory.GetFiles(Application.StartupPath + "\scripts", "*.cs"))
|
||||||
|
End If
|
||||||
|
|
||||||
|
If scriptFiles.Count = 0 Then Return
|
||||||
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom
|
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom
|
||||||
|
|
||||||
For Each i In csFiles
|
For Each i In scriptFiles
|
||||||
Try
|
Try
|
||||||
CSScriptLibrary.CSScript.Evaluator.LoadCode(File.ReadAllText(i))
|
CSScriptLibrary.CSScript.Evaluator.LoadCode(File.ReadAllText(i))
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
MainForm.Instance.ShowMsgBox(ex.ToString(), MessageBoxIcon.Error)
|
Sys.Msg.ShowException(ex)
|
||||||
End Try
|
End Try
|
||||||
Next
|
Next
|
||||||
End Sub
|
End Sub
|
||||||
|
|||||||
@@ -204,6 +204,8 @@ mpv.net bugs and requests: <https://github.com/stax76/mpv.net/issues>
|
|||||||
- all windows (main, conf, input, about, command palette) can now be closed
|
- all windows (main, conf, input, about, command palette) can now be closed
|
||||||
by just pressing the Escape key
|
by just pressing the Escape key
|
||||||
- new feature added to open recent files and URLs with the context menu. [Default Binding](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt#L33)
|
- new feature added to open recent files and URLs with the context menu. [Default Binding](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt#L33)
|
||||||
|
- the info command now works also for URLs
|
||||||
|
- fix for folder \<startup\>\\scripts not loading C# scripts
|
||||||
|
|
||||||
### 3.2 (2019-04-27)
|
### 3.2 (2019-04-27)
|
||||||
|
|
||||||
|
|||||||
@@ -116,22 +116,26 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileInfo fileInfo = new FileInfo(mp.get_property_string("path"));
|
string performer, title, album, genre, date, duration, text = "";
|
||||||
|
int fileSize = 0;
|
||||||
|
string path = mp.get_property_string("path");
|
||||||
|
int width = mp.get_property_int("video-params/w");
|
||||||
|
int height = mp.get_property_int("video-params/h");
|
||||||
|
|
||||||
using (MediaInfo mediaInfo = new MediaInfo(fileInfo.FullName))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
string width = mediaInfo.GetInfo(MediaInfoStreamKind.Video, "Width");
|
fileSize = (int)(new FileInfo(path).Length);
|
||||||
|
|
||||||
if (width == "")
|
if (FileAssociation.AudioTypes.Contains(Path.GetExtension(path).ToLower().TrimStart('.')))
|
||||||
{
|
{
|
||||||
string performer = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Performer");
|
using (MediaInfo mediaInfo = new MediaInfo(path))
|
||||||
string title = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Title");
|
{
|
||||||
string album = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Album");
|
performer = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Performer");
|
||||||
string genre = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Genre");
|
title = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Title");
|
||||||
string date = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Recorded_Date");
|
album = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Album");
|
||||||
string duration = mediaInfo.GetInfo(MediaInfoStreamKind.Audio, "Duration/String");
|
genre = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Genre");
|
||||||
|
date = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Recorded_Date");
|
||||||
string text = "";
|
duration = mediaInfo.GetInfo(MediaInfoStreamKind.Audio, "Duration/String");
|
||||||
|
|
||||||
if (performer != "") text += "Artist: " + performer + "\n";
|
if (performer != "") text += "Artist: " + performer + "\n";
|
||||||
if (title != "") text += "Title: " + title + "\n";
|
if (title != "") text += "Title: " + title + "\n";
|
||||||
@@ -141,37 +145,30 @@ namespace mpvnet
|
|||||||
if (duration != "") text += "Length: " + duration + "\n";
|
if (duration != "") text += "Length: " + duration + "\n";
|
||||||
|
|
||||||
mp.commandv("show-text", text, "5000");
|
mp.commandv("show-text", text, "5000");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
string height = mediaInfo.GetInfo(MediaInfoStreamKind.Video, "Height");
|
|
||||||
TimeSpan position = TimeSpan.FromSeconds(mp.get_property_number("time-pos"));
|
TimeSpan position = TimeSpan.FromSeconds(mp.get_property_number("time-pos"));
|
||||||
TimeSpan duration = TimeSpan.FromSeconds(mp.get_property_number("duration"));
|
TimeSpan duration2 = TimeSpan.FromSeconds(mp.get_property_number("duration"));
|
||||||
string bitrate = mediaInfo.GetInfo(MediaInfoStreamKind.Video, "BitRate");
|
|
||||||
|
|
||||||
if (bitrate == "")
|
|
||||||
bitrate = "0";
|
|
||||||
|
|
||||||
double bitrate2 = Convert.ToDouble(bitrate) / 1000.0 / 1000.0;
|
|
||||||
string videoCodec = mp.get_property_string("video-format").ToUpper();
|
string videoCodec = mp.get_property_string("video-format").ToUpper();
|
||||||
string filename = fileInfo.Name;
|
|
||||||
|
|
||||||
string text = filename + "\n" +
|
text = Path.GetFileName(path) + "\n" +
|
||||||
FormatTime(position.TotalMinutes) + ":" +
|
FormatTime(position.TotalMinutes) + ":" +
|
||||||
FormatTime(position.Seconds) + " / " +
|
FormatTime(position.Seconds) + " / " +
|
||||||
FormatTime(duration.TotalMinutes) + ":" +
|
FormatTime(duration2.TotalMinutes) + ":" +
|
||||||
FormatTime(duration.Seconds) + "\n" +
|
FormatTime(duration2.Seconds) + "\n" +
|
||||||
$"{width} x {height}\n" +
|
$"{width} x {height}\n";
|
||||||
$"{bitrate2.ToString("f1")} Mb/s\n" +
|
|
||||||
Convert.ToInt32(fileInfo.Length / 1024 / 1024).ToString() + " MB\n" +
|
if (fileSize > 0)
|
||||||
$"{videoCodec}\n";
|
text += Convert.ToInt32(fileSize / 1024 / 1024).ToString() + " MB\n";
|
||||||
|
|
||||||
|
text += $"{videoCodec}\n";
|
||||||
|
|
||||||
mp.commandv("show-text", text, "5000");
|
mp.commandv("show-text", text, "5000");
|
||||||
}
|
|
||||||
|
|
||||||
string FormatTime(double value) => ((int)value).ToString("00");
|
string FormatTime(double value) => ((int)value).ToString("00");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -180,8 +177,9 @@ namespace mpvnet
|
|||||||
public static void execute_mpv_command(string[] args)
|
public static void execute_mpv_command(string[] args)
|
||||||
{
|
{
|
||||||
MainForm.Instance.Invoke(new Action(() => {
|
MainForm.Instance.Invoke(new Action(() => {
|
||||||
string command = Microsoft.VisualBasic.Interaction.InputBox("Enter a mpv command to be executed.");
|
string command = Microsoft.VisualBasic.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegistryHelp.GetString("HKCU\\Software\\" + Application.ProductName, "RecentExecutedCommand"));
|
||||||
if (string.IsNullOrEmpty(command)) return;
|
if (string.IsNullOrEmpty(command)) return;
|
||||||
|
RegistryHelp.SetObject("HKCU\\Software\\" + Application.ProductName, "RecentExecutedCommand", command);
|
||||||
mp.command_string(command, false);
|
mp.command_string(command, false);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ namespace mpvnet
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
object recent = RegistryHelp.GetObject("HKCU\\Software\\" + Application.ProductName, "Recent");
|
||||||
|
|
||||||
|
if (recent is string[])
|
||||||
|
RecentFiles = new List<string>((string[])recent);
|
||||||
|
else
|
||||||
|
RecentFiles = new List<string>();
|
||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
Application.ThreadException += Application_ThreadException;
|
Application.ThreadException += Application_ThreadException;
|
||||||
Msg.SupportURL = "https://github.com/stax76/mpv.net#support";
|
Msg.SupportURL = "https://github.com/stax76/mpv.net#support";
|
||||||
@@ -50,12 +57,7 @@ namespace mpvnet
|
|||||||
Hwnd = Handle;
|
Hwnd = Handle;
|
||||||
MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
|
MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
|
||||||
Text += " " + Application.ProductVersion;
|
Text += " " + Application.ProductVersion;
|
||||||
object recent = RegistryHelp.GetObject("HKCU\\Software\\" + Application.ProductName, "Recent");
|
|
||||||
|
|
||||||
if (recent is string[])
|
|
||||||
RecentFiles = new List<string>((string[])recent);
|
|
||||||
else
|
|
||||||
RecentFiles = new List<string>();
|
|
||||||
|
|
||||||
foreach (var i in mp.mpvConf)
|
foreach (var i in mp.mpvConf)
|
||||||
ProcessMpvProperty(i.Key, i.Value);
|
ProcessMpvProperty(i.Key, i.Value);
|
||||||
@@ -530,14 +532,6 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DialogResult ShowMsgBox(string message, MessageBoxIcon icon)
|
|
||||||
{
|
|
||||||
var buttons = MessageBoxButtons.OK;
|
|
||||||
if (icon == MessageBoxIcon.Question) buttons = MessageBoxButtons.OKCancel;
|
|
||||||
var fn = new Func<DialogResult>(() => MessageBox.Show(message, Application.ProductName, buttons, icon));
|
|
||||||
return (DialogResult)Invoke(fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnLoad(EventArgs e)
|
protected override void OnLoad(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnLoad(e);
|
base.OnLoad(e);
|
||||||
|
|||||||
@@ -19,16 +19,15 @@ namespace mpvnet
|
|||||||
if (args[2] == "unregister") FileAssociation.Unregister();
|
if (args[2] == "unregister") FileAssociation.Unregister();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new MainForm());
|
Application.Run(new MainForm());
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,8 +9,6 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using Microsoft.VisualBasic.CompilerServices;
|
|
||||||
|
|
||||||
namespace Sys
|
namespace Sys
|
||||||
{
|
{
|
||||||
public class Msg
|
public class Msg
|
||||||
@@ -44,10 +42,10 @@ namespace Sys
|
|||||||
}
|
}
|
||||||
|
|
||||||
td.MainIcon = MsgIcon.Error;
|
td.MainIcon = MsgIcon.Error;
|
||||||
td.Footer = "[copymsg Copy Message]";
|
td.Footer = "[Copy Message](copymsg)";
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
||||||
td.Footer += $" [{SupportURL} Contact Support]";
|
td.Footer += $" [Contact Support]({SupportURL})";
|
||||||
|
|
||||||
td.Show();
|
td.Show();
|
||||||
}
|
}
|
||||||
@@ -63,10 +61,10 @@ namespace Sys
|
|||||||
td.Content = e.Message;
|
td.Content = e.Message;
|
||||||
td.MainIcon = MsgIcon.Error;
|
td.MainIcon = MsgIcon.Error;
|
||||||
td.ExpandedInformation = e.ToString();
|
td.ExpandedInformation = e.ToString();
|
||||||
td.Footer = "[copymsg Copy Message]";
|
td.Footer = "[Copy Message](copymsg)";
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
||||||
td.Footer += $" [{SupportURL} Contact Support]";
|
td.Footer += $" [Contact Support]({SupportURL})";
|
||||||
|
|
||||||
td.Show();
|
td.Show();
|
||||||
}
|
}
|
||||||
@@ -244,12 +242,12 @@ namespace Sys
|
|||||||
|
|
||||||
public string Content {
|
public string Content {
|
||||||
get => Config.pszContent;
|
get => Config.pszContent;
|
||||||
set => Config.pszContent = ExpandWikiMarkup(value);
|
set => Config.pszContent = ExpandMarkdownMarkup(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ExpandedInformation {
|
public string ExpandedInformation {
|
||||||
get => Config.pszExpandedInformation;
|
get => Config.pszExpandedInformation;
|
||||||
set => Config.pszExpandedInformation = ExpandWikiMarkup(value);
|
set => Config.pszExpandedInformation = ExpandMarkdownMarkup(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string VerificationText {
|
public string VerificationText {
|
||||||
@@ -264,7 +262,7 @@ namespace Sys
|
|||||||
|
|
||||||
public string Footer {
|
public string Footer {
|
||||||
get => Config.pszFooter;
|
get => Config.pszFooter;
|
||||||
set => Config.pszFooter = ExpandWikiMarkup(value);
|
set => Config.pszFooter = ExpandMarkdownMarkup(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MsgIcon MainIcon {
|
public MsgIcon MainIcon {
|
||||||
@@ -329,16 +327,16 @@ namespace Sys
|
|||||||
Buttons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
|
Buttons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ExpandWikiMarkup(string value)
|
public string ExpandMarkdownMarkup(string value)
|
||||||
{
|
{
|
||||||
if (value.Contains("["))
|
if (value.Contains("["))
|
||||||
{
|
{
|
||||||
Regex regex = new Regex("\\[(.*?) (.+?)\\]");
|
Regex regex = new Regex(@"\[(.+)\]\((.+)\)");
|
||||||
|
|
||||||
if (regex.Match(value).Success)
|
if (regex.Match(value).Success)
|
||||||
{
|
{
|
||||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_ENABLE_HYPERLINKS;
|
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_ENABLE_HYPERLINKS;
|
||||||
value = regex.Replace(value, "<a href=\"$1\">$2</a>");
|
value = regex.Replace(value, "<a href=\"$2\">$1</a>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@@ -398,10 +396,9 @@ namespace Sys
|
|||||||
break;
|
break;
|
||||||
case 3: //TDN_HYPERLINK_CLICKED
|
case 3: //TDN_HYPERLINK_CLICKED
|
||||||
string stringUni = Marshal.PtrToStringUni(lParam);
|
string stringUni = Marshal.PtrToStringUni(lParam);
|
||||||
|
|
||||||
if (stringUni.StartsWith("mailto") || stringUni.StartsWith("http"))
|
if (stringUni.StartsWith("mailto") || stringUni.StartsWith("http"))
|
||||||
Process.Start(stringUni);
|
Process.Start(stringUni);
|
||||||
if (Operators.CompareString(stringUni, "copymsg", false) == 0)
|
if (stringUni == "copymsg")
|
||||||
{
|
{
|
||||||
Thread thread = new Thread((ThreadStart)(() => {
|
Thread thread = new Thread((ThreadStart)(() => {
|
||||||
Clipboard.SetText(MainInstruction + "\r\n\r\n" + Content + "\r\n\r\n" + ExpandedInformation);
|
Clipboard.SetText(MainInstruction + "\r\n\r\n" + Content + "\r\n\r\n" + ExpandedInformation);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace mpvnet
|
|||||||
using (TaskDialog<string> td = new TaskDialog<string>())
|
using (TaskDialog<string> td = new TaskDialog<string>())
|
||||||
{
|
{
|
||||||
td.MainInstruction = "Choose a settings folder.";
|
td.MainInstruction = "Choose a settings folder.";
|
||||||
td.Content = "[https://mpv.io/manual/master/#files-on-windows MPV documentation about files on Windows.]";
|
td.Content = "[MPV documentation about files on Windows.](https://mpv.io/manual/master/#files-on-windows)";
|
||||||
td.AddCommandLink("appdata", appdataFolder, appdataFolder);
|
td.AddCommandLink("appdata", appdataFolder, appdataFolder);
|
||||||
td.AddCommandLink("portable", portableFolder, portableFolder);
|
td.AddCommandLink("portable", portableFolder, portableFolder);
|
||||||
td.AllowCancel = false;
|
td.AllowCancel = false;
|
||||||
@@ -278,7 +278,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
List<string> names = mpvnet.Command.Commands.Select((item) => item.Name).ToList();
|
List<string> names = mpvnet.Command.Commands.Select((item) => item.Name).ToList();
|
||||||
names.Sort();
|
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 [https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt default input bindings and menu definition].");
|
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).");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClientMessage?.Invoke(args);
|
ClientMessage?.Invoke(args);
|
||||||
|
|||||||
Reference in New Issue
Block a user