This commit is contained in:
Frank Skare
2019-05-01 09:36:48 +02:00
parent 1d78d4e4e2
commit 867a83f15a
7 changed files with 77 additions and 61 deletions

View File

@@ -122,9 +122,7 @@ Scripting is supported via Python, C#, Lua, JavaScript and PowerShell
Add-ons have to be located at: Add-ons have to be located at:
C:\Users\\<user\>\AppData\Roaming\mpv\Addons\ExampleAddon\ExampleAddon.dll C:\Users\%username%\AppData\Roaming\mpv\Addons\ExampleAddon\ExampleAddon.dll
\<startup\>\Addons\ExampleAddon\ExampleAddon.dll
\<startup\>\portable_config\Addons\ExampleAddon\ExampleAddon.dll \<startup\>\portable_config\Addons\ExampleAddon\ExampleAddon.dll
@@ -204,8 +202,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 - the info command (i key) now works also for URLs
- fix for folder \<startup\>\\scripts not loading C# scripts - CSScriptAddon add-on didn't load cs scripts from \<startup\>\\scripts and it didn't use the task dialog api to show errors
### 3.2 (2019-04-27) ### 3.2 (2019-04-27)

View File

@@ -117,14 +117,14 @@ namespace mpvnet
try try
{ {
string performer, title, album, genre, date, duration, text = ""; string performer, title, album, genre, date, duration, text = "";
int fileSize = 0; long fileSize = 0;
string path = mp.get_property_string("path"); string path = mp.get_property_string("path");
int width = mp.get_property_int("video-params/w"); int width = mp.get_property_int("video-params/w");
int height = mp.get_property_int("video-params/h"); int height = mp.get_property_int("video-params/h");
if (File.Exists(path)) if (File.Exists(path))
{ {
fileSize = (int)(new FileInfo(path).Length); fileSize = new FileInfo(path).Length;
if (FileAssociation.AudioTypes.Contains(Path.GetExtension(path).ToLower().TrimStart('.'))) if (FileAssociation.AudioTypes.Contains(Path.GetExtension(path).ToLower().TrimStart('.')))
{ {
@@ -162,7 +162,7 @@ namespace mpvnet
$"{width} x {height}\n"; $"{width} x {height}\n";
if (fileSize > 0) if (fileSize > 0)
text += Convert.ToInt32(fileSize / 1024 / 1024).ToString() + " MB\n"; text += Convert.ToInt32(fileSize / 1024.0 / 1024.0).ToString() + " MB\n";
text += $"{videoCodec}\n"; text += $"{videoCodec}\n";

View File

@@ -1,6 +1,8 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using Sys;
namespace mpvnet namespace mpvnet
{ {
static class Program static class Program
@@ -26,7 +28,7 @@ namespace mpvnet
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); Msg.ShowException(ex);
} }
} }
} }

View File

@@ -24,30 +24,38 @@ namespace Sys
public static void ShowError(string mainInstruction, string content = null) public static void ShowError(string mainInstruction, string content = null)
{ {
using (TaskDialog<string> td = new TaskDialog<string>()) try
{ {
td.AllowCancel = false; using (TaskDialog<string> td = new TaskDialog<string>())
if (string.IsNullOrEmpty(content))
{ {
if (mainInstruction.Length < 80) td.AllowCancel = false;
td.MainInstruction = mainInstruction;
if (string.IsNullOrEmpty(content))
{
if (mainInstruction.Length < 80)
td.MainInstruction = mainInstruction;
else
td.Content = mainInstruction;
}
else else
td.Content = mainInstruction; {
td.MainInstruction = mainInstruction;
td.Content = content;
}
td.MainIcon = MsgIcon.Error;
td.Footer = "[Copy Message](copymsg)";
if (!string.IsNullOrEmpty(Msg.SupportURL))
td.Footer += $" [Contact Support]({SupportURL})";
td.Show();
} }
else }
{ catch (Exception ex)
td.MainInstruction = mainInstruction; {
td.Content = content; MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
} Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
td.MainIcon = MsgIcon.Error;
td.Footer = "[Copy Message](copymsg)";
if (!string.IsNullOrEmpty(Msg.SupportURL))
td.Footer += $" [Contact Support]({SupportURL})";
td.Show();
} }
} }
@@ -71,7 +79,7 @@ namespace Sys
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.GetType().Name + "\n\n" + e.Message + "\n\n" + e.ToString(), MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
@@ -108,32 +116,40 @@ namespace Sys
MsgButtons buttons, MsgButtons buttons,
MsgResult defaultButton = MsgResult.None) MsgResult defaultButton = MsgResult.None)
{ {
using (TaskDialog<MsgResult> td = new TaskDialog<MsgResult>()) try
{ {
td.AllowCancel = false; using (TaskDialog<MsgResult> td = new TaskDialog<MsgResult>())
td.DefaultButton = defaultButton; {
td.MainIcon = icon; td.AllowCancel = false;
td.DefaultButton = defaultButton;
td.MainIcon = icon;
if (content == null) if (content == null)
{ {
if (mainInstruction.Length < 80) if (mainInstruction.Length < 80)
td.MainInstruction = mainInstruction; td.MainInstruction = mainInstruction;
else
td.Content = mainInstruction;
}
else else
td.Content = mainInstruction; {
td.MainInstruction = mainInstruction;
td.Content = content;
}
if (buttons == MsgButtons.OkCancel)
{
td.AddButton("OK", MsgResult.OK);
td.AddButton("Cancel", MsgResult.Cancel);
}
else
td.CommonButtons = buttons;
return td.Show();
} }
else }
{ catch (Exception ex)
td.MainInstruction = mainInstruction; {
td.Content = content; return (MsgResult)MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
} Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
if (buttons == MsgButtons.OkCancel)
{
td.AddButton("OK", MsgResult.OK);
td.AddButton("Cancel", MsgResult.Cancel);
}
else
td.CommonButtons = buttons;
return td.Show();
} }
} }
} }

View File

@@ -3,14 +3,13 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using DynamicGUI; using DynamicGUI;
using Microsoft.Win32; using Sys;
namespace mpvnet namespace mpvnet
{ {
@@ -154,8 +153,7 @@ namespace mpvnet
WriteToDisk(mp.MpvConfPath, MpvConf, MpvSettingsDefinitions); WriteToDisk(mp.MpvConfPath, MpvConf, MpvSettingsDefinitions);
WriteToDisk(mp.MpvNetConfPath, MpvNetConf, MpvNetSettingsDefinitions); WriteToDisk(mp.MpvNetConfPath, MpvNetConf, MpvNetSettingsDefinitions);
MessageBox.Show("Changes will be available on next mpv.net startup.", Msg.Show("Changes will be available on next mpv.net startup.");
Title, MessageBoxButton.OK, MessageBoxImage.Information);
} }
void WriteToDisk(string filePath, void WriteToDisk(string filePath,

View File

@@ -7,6 +7,8 @@ using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using Sys;
namespace mpvnet namespace mpvnet
{ {
public partial class InputWindow : Window public partial class InputWindow : Window
@@ -32,7 +34,7 @@ namespace mpvnet
CollectionView.Refresh(); CollectionView.Refresh();
if (SearchControl.SearchTextBox.Text == "?") if (SearchControl.SearchTextBox.Text == "?")
MessageBox.Show("Filtering works by searching in the Input, Menu and Command but it's possible to reduce the filter scope to either of Input, Menu or Command by prefixing as follows:\n\ni <input search>\ni: <input search>\n\nm <menu search>\nm: <menu search>\n\nc <command search>\nc: <command search>\n\nIf only one character is entered the search will be performed only in the input.", "Filtering", MessageBoxButton.OK, MessageBoxImage.Information); Msg.Show("Filtering works by searching in the Input, Menu and Command but it's possible to reduce the filter scope to either of Input, Menu or Command by prefixing as follows:\n\ni <input search>\ni: <input search>\n\nm <menu search>\nm: <menu search>\n\nc <command search>\nc: <command search>\n\nIf only one character is entered the search will be performed only in the input.", "Filtering");
} }
bool Filter(CommandItem item) bool Filter(CommandItem item)
@@ -77,7 +79,7 @@ namespace mpvnet
foreach (CommandItem i in CommandItem.Items) foreach (CommandItem i in CommandItem.Items)
if (items.ContainsKey(i.Input) && i.Input != "") if (items.ContainsKey(i.Input) && i.Input != "")
MessageBox.Show($"Duplicate found:\n\n{i.Input}: {i.Path}\n\n{items[i.Input].Input}: {items[i.Input].Path}\n\nPlease note that you can chain multiple commands in the same line by using a semicolon as separator.", "Duplicate Found", MessageBoxButton.OK, MessageBoxImage.Warning); Msg.Show($"Duplicate found:\n\n{i.Input}: {i.Path}\n\n{items[i.Input].Input}: {items[i.Input].Path}\n\nPlease note that you can chain multiple commands in the same line by using a semicolon as separator.", "Duplicate Found");
else else
items[i.Input] = i; items[i.Input] = i;
} }
@@ -110,8 +112,7 @@ namespace mpvnet
{ {
if (InitialInputConfContent == GetInputConfContent()) return; if (InitialInputConfContent == GetInputConfContent()) return;
File.WriteAllText(mp.InputConfPath, GetInputConfContent()); File.WriteAllText(mp.InputConfPath, GetInputConfContent());
MessageBox.Show("Changes will be available on next mpv.net startup.", Msg.Show("Changes will be available on next mpv.net startup.");
Title, MessageBoxButton.OK, MessageBoxImage.Information);
} }
private void DataGrid_PreviewCanExecute(object sender, CanExecuteRoutedEventArgs e) private void DataGrid_PreviewCanExecute(object sender, CanExecuteRoutedEventArgs e)
@@ -119,7 +120,7 @@ namespace mpvnet
DataGrid grid = (DataGrid)sender; DataGrid grid = (DataGrid)sender;
if (e.Command == DataGrid.DeleteCommand) if (e.Command == DataGrid.DeleteCommand)
if (MessageBox.Show($"Confirm to delete: {(grid.SelectedItem as CommandItem).Input} ({(grid.SelectedItem as CommandItem).Path})", "Confirm Delete", MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK) if (Msg.ShowQuestion($"Confirm to delete: {(grid.SelectedItem as CommandItem).Input} ({(grid.SelectedItem as CommandItem).Path})") != MsgResult.OK)
e.Handled = true; e.Handled = true;
} }

View File

@@ -35,6 +35,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup /> <PropertyGroup />
<PropertyGroup /> <PropertyGroup />