This commit is contained in:
Frank Skare
2019-04-08 04:22:09 +02:00
parent 2b5dbfa19f
commit 0836b63439
22 changed files with 1231 additions and 51 deletions

View File

@@ -5,6 +5,8 @@ using System.ComponentModel.Composition.Hosting;
using System.IO;
using System.Windows.Forms;
using VBNET;
namespace mpvnet
{
public class Addon
@@ -38,9 +40,9 @@ namespace mpvnet
CompositionContainer.ComposeParts(this);
}
}
catch (Exception e)
catch (Exception ex)
{
MainForm.Instance.ShowMsgBox(e.ToString(), MessageBoxIcon.Error);
Msg.ShowException(ex);
}
}
}

View File

@@ -6,6 +6,8 @@ using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using VBNET;
namespace mpvnet
{
public class Command
@@ -54,7 +56,7 @@ namespace mpvnet
}));
}
public static void open_config_folder(string[] args)
public static void open_conf_folder(string[] args)
{
Process.Start(mp.mpvConfFolderPath);
}
@@ -76,7 +78,8 @@ namespace mpvnet
if (File.Exists(fp))
Process.Start(fp);
else
if (MainForm.Instance.ShowMsgBox("Create history.txt file in config folder?\n\nmpv.net will write the date, time and filename of opened files to it.", MessageBoxIcon.Question) == DialogResult.OK)
if (Msg.ShowQuestion("Create history.txt file in config folder?",
"mpv.net will write the date, time and filename of opened files to it.") == MsgResult.OK)
File.WriteAllText(fp, "");
}
@@ -105,7 +108,7 @@ namespace mpvnet
else
File.WriteAllText(mp.mpvConfPath, File.ReadAllText(mp.mpvConfPath) + Environment.NewLine + args[0] + " = " + args[1]);
MainForm.Instance.ShowMsgBox("Please restart mpv.net", MessageBoxIcon.Information);
Msg.Show("Changed settings are available on next startup.");
}
public static void show_info(string[] args)

View File

@@ -5,6 +5,9 @@ using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.Linq;
using System.Collections.Generic;
using VBNET;
namespace mpvnet
{
@@ -30,6 +33,8 @@ namespace mpvnet
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.ThreadException += Application_ThreadException;
Msg.SupportURL = "https://github.com/stax76/mpv.net#support";
Instance = this;
Hwnd = Handle;
MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
@@ -45,9 +50,9 @@ namespace mpvnet
ChangeFullscreen(mpvFullscreen);
}
catch (Exception e)
catch (Exception ex)
{
ShowMsgBox(e.ToString(), MessageBoxIcon.Error);
Msg.ShowException(ex);
}
}
@@ -151,32 +156,56 @@ namespace mpvnet
public void BuildMenu()
{
foreach (var i in File.ReadAllText(mp.InputConfPath).Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
string content = File.ReadAllText(mp.InputConfPath);
List<string> lines = null;
Dictionary<string, string> commandInputDic = new Dictionary<string, string>();
if (content.Contains("#menu:"))
lines = content.Split("\r\n".ToCharArray()).ToList();
else
{
lines = Properties.Resources.input_conf.Split("\r\n".ToCharArray()).ToList();
foreach (string i in content.Split("\r\n".ToCharArray()))
{
string line = i.Trim();
if (line.StartsWith("#") || !line.Contains(" ")) continue;
string input = line.Substring(0, line.IndexOf(" ")).Trim();
string command = line.Substring(line.IndexOf(" ") + 1).Trim();
commandInputDic[command] = input;
}
}
foreach (string i in lines)
{
if (!i.Contains("#menu:")) continue;
var left = i.Substring(0, i.IndexOf("#menu:")).Trim();
string left = i.Substring(0, i.IndexOf("#menu:")).Trim();
if (left.StartsWith("#")) continue;
var cmd = left.Substring(left.IndexOf(" ") + 1).Trim();
var menu = i.Substring(i.IndexOf("#menu:") + "#menu:".Length).Trim();
var key = left.Substring(0, left.IndexOf(" "));
if (key == "_") key = "";
if (menu.Contains(";")) key = menu.Substring(0, menu.IndexOf(";")).Trim();
var path = menu.Substring(menu.IndexOf(";") + 1).Trim().Replace("&", "&&");
if (path == "" || cmd == "") continue;
string command = left.Substring(left.IndexOf(" ") + 1).Trim();
string menu = i.Substring(i.IndexOf("#menu:") + "#menu:".Length).Trim();
string input = left.Substring(0, left.IndexOf(" "));
if (input == "_") input = "";
if (menu.Contains(";")) input = menu.Substring(0, menu.IndexOf(";")).Trim();
string path = menu.Substring(menu.IndexOf(";") + 1).Trim().Replace("&", "&&");
if (path == "" || command == "") continue;
if (commandInputDic.Count > 0)
if (commandInputDic.ContainsKey(command))
input = commandInputDic[command];
else
input = "";
var menuItem = CMS.Add(path, () => {
try
{
mp.command_string(cmd);
try {
mp.command_string(command);
}
catch (Exception e)
{
ShowMsgBox(e.ToString(), MessageBoxIcon.Error);
catch (Exception ex) {
Msg.ShowException(ex);
}
});
if (menuItem != null)
menuItem.ShortcutKeyDisplayString = key.Replace("_","") + " ";
menuItem.ShortcutKeyDisplayString = input.Replace("_","") + " ";
}
}
@@ -207,12 +236,12 @@ namespace mpvnet
private void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
ShowMsgBox(e.Exception.ToString(), MessageBoxIcon.Error);
Msg.ShowException(e.Exception);
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
ShowMsgBox(e.ExceptionObject.ToString(), MessageBoxIcon.Error);
Msg.ShowError(e.ExceptionObject.ToString());
}
private void mp_VideoSizeChanged()
@@ -431,7 +460,7 @@ namespace mpvnet
if (clipboard.StartsWith("https://www.youtube.com/watch?") && LastURL != clipboard && Visible)
{
LastURL = clipboard;
if (ShowMsgBox("Play YouTube URL?", MessageBoxIcon.Question) == DialogResult.OK)
if (Msg.ShowQuestion("Play YouTube URL?") == MsgResult.OK)
mp.LoadURL(clipboard);
}
}

View File

@@ -5,6 +5,7 @@ using System.Management.Automation.Runspaces;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using VBNET;
namespace mpvnet
{
@@ -47,12 +48,12 @@ Using namespace System;
throw new Exception();
}
}
catch
catch (Exception ex2)
{
MainForm.Instance.ShowMsgBox("PowerShell Setup Problem\n\nEnsure you have at least PowerShell 5.1 installed.", MessageBoxIcon.Error);
Msg.ShowError("PowerShell Setup Problem\n\nEnsure you have at least PowerShell 5.1 installed.", ex2.ToString());
return null;
}
MainForm.Instance.ShowMsgBox(ex.ToString(), MessageBoxIcon.Error);
Msg.ShowException(ex);
}
}
}

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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.0.0")]
[assembly: AssemblyFileVersion("2.4.0.0")]
[assembly: AssemblyVersion("2.5.0.0")]
[assembly: AssemblyFileVersion("2.5.0.0")]

View File

@@ -3,7 +3,7 @@ using System.Reflection;
using System.Windows.Forms;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
using VBNET;
using PyRT = IronPython.Runtime;
namespace mpvnet
@@ -27,7 +27,7 @@ namespace mpvnet
}
catch (Exception ex)
{
MainForm.Instance.ShowMsgBox(ex.ToString(), MessageBoxIcon.Error);
Msg.ShowException(ex);
}
}
}

View File

@@ -53,6 +53,7 @@
_ ignore #menu: Seek > -
Ctrl+Right no-osd seek 300 #menu: Seek > 5 min forward
Ctrl+Left no-osd seek -300 #menu: Seek > 5 min backward
Ctrl++ add video-zoom 0.1 #menu: Pan & Scan > Increase Size
Ctrl+- add video-zoom -0.1 #menu: Pan & Scan > Decrease Size
_ ignore #menu: Pan & Scan > -
@@ -66,6 +67,7 @@
W add panscan 0.1 #menu: Pan & Scan > Increase Height
_ ignore #menu: Pan & Scan > -
Ctrl+BS set video-zoom 0; set video-pan-x 0; set video-pan-y 0 #menu: Pan & Scan > Reset
Ctrl+1 add contrast -1 #menu: Video > Decrease Contrast
Ctrl+2 add contrast #menu: Video > Increase Contrast
_ ignore #menu: Video > -
@@ -81,10 +83,12 @@
Ctrl+s async screenshot #menu: Video > Take Screenshot
d cycle deinterlace #menu: Video > Toggle Deinterlace
a cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1" #menu: Video > Cycle Aspect Ratio
KP7 cycle audio #menu: Audio > Cycle/Next
_ ignore #menu: Audio > -
KP6 add audio-delay 0.100 #menu: Audio > Delay +0.1
KP9 add audio-delay -0.100 #menu: Audio > Delay -0.1
KP8 cycle sub #menu: Subtitle > Cycle/Next
v cycle sub-visibility #menu: Subtitle > Toggle Visibility
_ ignore #menu: Subtitle > -
@@ -96,10 +100,12 @@
_ ignore #menu: Subtitle > -
_ add sub-scale -0.1 #menu: Subtitle > Decrease Subtitle Font Size
_ add sub-scale 0.1 #menu: Subtitle > Increase Subtitle Font Size
+ add volume 10 #menu: Volume > Up
- add volume -10 #menu: Volume > Down
_ ignore #menu: Volume > -
m cycle mute #menu: Volume > Mute
[ multiply speed 0.9 #menu: Speed > -10%
] multiply speed 1.1 #menu: Speed > +10%
_ ignore #menu: Speed > -
@@ -107,6 +113,7 @@
} multiply speed 2.0 #menu: Speed > Double
_ ignore #menu: Speed > -
BS set speed 1 #menu: Speed > Reset
KP0 script-message rate-file 0 #menu: Addons > Rating > 0stars
KP1 script-message rate-file 1 #menu: Addons > Rating > 1stars
KP2 script-message rate-file 2 #menu: Addons > Rating > 2stars
@@ -124,7 +131,7 @@
_ script-message mpv.net set-setting hwdec no #menu: Settings > Hardware Decoding > Disable
Ctrl+c script-message mpv.net show-conf-editor #menu: Settings > Show Config Editor
Ctrl+i script-message mpv.net show-input-editor #menu: Settings > Show Input Editor
Ctrl+f script-message mpv.net open-config-folder #menu: Settings > Open Config Folder
Ctrl+f script-message mpv.net open-conf-folder #menu: Settings > Open Config Folder
h script-message mpv.net show-history #menu: Tools > Show History
l ab-loop #menu: Tools > Set/clear A-B loop points
@@ -159,4 +166,4 @@
Wheel_Up add volume 10
Wheel_Down add volume -10
Prev playlist-prev
Next playlist-next
Next playlist-next

View File

@@ -10,7 +10,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using VBNET;
using static mpvnet.libmpv;
using static mpvnet.Native;
@@ -216,7 +216,7 @@ namespace mpvnet
{
List<string> names = mpvnet.Command.Commands.Select((item) => item.Name).ToList();
names.Sort();
MainForm.Instance.ShowMsgBox($"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 located at:\n\nhttps://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt", MessageBoxIcon.Error);
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/input.conf.txt default input bindings and menu definition].");
}
}
ClientMessage?.Invoke(args);
@@ -265,7 +265,7 @@ namespace mpvnet
}
catch (Exception ex)
{
MainForm.Instance.ShowMsgBox(ex.ToString(), MessageBoxIcon.Error);
Msg.ShowException(ex);
}
}
}

View File

@@ -193,7 +193,12 @@
<Content Include="screenshot.jpg" />
<Content Include="Resources\input.conf.txt" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\VBNET\VBNET.vbproj">
<Project>{a1d11294-05bf-4d77-b008-aecf1aa93c9f}</Project>
<Name>VBNET</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.