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:
C:\Users\\<user\>\AppData\Roaming\mpv\Addons\ExampleAddon\ExampleAddon.dll
\<startup\>\Addons\ExampleAddon\ExampleAddon.dll
C:\Users\%username%\AppData\Roaming\mpv\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
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)
- the info command now works also for URLs
- fix for folder \<startup\>\\scripts not loading C# scripts
- the info command (i key) now works also for URLs
- 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)

View File

@@ -117,14 +117,14 @@ namespace mpvnet
try
{
string performer, title, album, genre, date, duration, text = "";
int fileSize = 0;
long 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");
if (File.Exists(path))
{
fileSize = (int)(new FileInfo(path).Length);
fileSize = new FileInfo(path).Length;
if (FileAssociation.AudioTypes.Contains(Path.GetExtension(path).ToLower().TrimStart('.')))
{
@@ -162,7 +162,7 @@ namespace mpvnet
$"{width} x {height}\n";
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";

View File

@@ -1,6 +1,8 @@
using System;
using System.Windows.Forms;
using Sys;
namespace mpvnet
{
static class Program
@@ -26,7 +28,7 @@ namespace mpvnet
}
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)
{
using (TaskDialog<string> td = new TaskDialog<string>())
try
{
td.AllowCancel = false;
if (string.IsNullOrEmpty(content))
using (TaskDialog<string> td = new TaskDialog<string>())
{
if (mainInstruction.Length < 80)
td.MainInstruction = mainInstruction;
td.AllowCancel = false;
if (string.IsNullOrEmpty(content))
{
if (mainInstruction.Length < 80)
td.MainInstruction = mainInstruction;
else
td.Content = mainInstruction;
}
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
{
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();
}
catch (Exception ex)
{
MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@@ -71,7 +79,7 @@ namespace Sys
}
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);
}
}
@@ -108,32 +116,40 @@ namespace Sys
MsgButtons buttons,
MsgResult defaultButton = MsgResult.None)
{
using (TaskDialog<MsgResult> td = new TaskDialog<MsgResult>())
try
{
td.AllowCancel = false;
td.DefaultButton = defaultButton;
td.MainIcon = icon;
using (TaskDialog<MsgResult> td = new TaskDialog<MsgResult>())
{
td.AllowCancel = false;
td.DefaultButton = defaultButton;
td.MainIcon = icon;
if (content == null)
{
if (mainInstruction.Length < 80)
td.MainInstruction = mainInstruction;
if (content == null)
{
if (mainInstruction.Length < 80)
td.MainInstruction = mainInstruction;
else
td.Content = mainInstruction;
}
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
{
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();
}
catch (Exception ex)
{
return (MsgResult)MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

View File

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

View File

@@ -7,6 +7,8 @@ using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using Sys;
namespace mpvnet
{
public partial class InputWindow : Window
@@ -32,7 +34,7 @@ namespace mpvnet
CollectionView.Refresh();
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)
@@ -77,7 +79,7 @@ namespace mpvnet
foreach (CommandItem i in CommandItem.Items)
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
items[i.Input] = i;
}
@@ -110,8 +112,7 @@ namespace mpvnet
{
if (InitialInputConfContent == GetInputConfContent()) return;
File.WriteAllText(mp.InputConfPath, GetInputConfContent());
MessageBox.Show("Changes will be available on next mpv.net startup.",
Title, MessageBoxButton.OK, MessageBoxImage.Information);
Msg.Show("Changes will be available on next mpv.net startup.");
}
private void DataGrid_PreviewCanExecute(object sender, CanExecuteRoutedEventArgs e)
@@ -119,7 +120,7 @@ namespace mpvnet
DataGrid grid = (DataGrid)sender;
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;
}

View File

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