This commit is contained in:
Frank Skare
2019-04-06 16:03:46 +02:00
parent 39f6f4de0d
commit 4492a423b4
11 changed files with 100 additions and 38 deletions

View File

@@ -70,12 +70,16 @@ https://github.com/stax76/mpv.net/wiki/Scripting-(CSharp,-Python,-JavaScript,-Lu
### Changelog
### 2.4 (2019-0?-??)
### 2.4 (2019-04-06)
- new options added to the conf GUI editor: gpu-context, gpu-api, scale, cscale, dscale, dither-depth, correct-downscaling, sigmoid-upscaling, deband
- the conf edit GUI has a 'Apply' feature added to write the conf to mpv.conf without the need to close the conf edit GUI
- the input edit GUI shows a message box when a duplicate is detected and it has a new feature to narrow the filter scope to eather of input, menu or command and the editor writes always the same help on top of input.conf as it is found in the defaults
- the input edit GUI shows a message box when a duplicate is detected and it has a new feature to reduce the filter scope to eather of input, menu or command and the editor writes always the same help on top of input.conf as it is found in the defaults
- the conf edit GUI was often starting out of working area bounds and is now starting with center screen
- the startup size was reduced and a issue was fixed that when the screen property was defined for a screen that isn't connected the startup size wasn't applied
- added feature to load external audio and subtitle files in the menu under: Open > Load external audio|subtitle files (default binding at: [input.conf](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt))
- previously the conf edit GUI removed settings from the conf file if the setting was set to the default, the new behavior is not to remove anything
- the autofit mpv property was partly implemented, you can use 'autofit = 50%' in mpv.conf or '--autofit=50%' on the command line, WxH isn't implemented and only percent values are accepted. There is a new wiki page explaining limitations compared to the original mpv: <https://github.com/stax76/mpv.net/wiki/Limitations>
### 2.3 (2019-04-04)

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace mpvnet
@@ -187,5 +188,35 @@ namespace mpvnet
mp.LoadURL(command);
}));
}
public static void load_sub(string[] args)
{
MainForm.Instance.BeginInvoke(new Action(() => {
using (var d = new OpenFileDialog())
{
d.InitialDirectory = Path.GetDirectoryName(mp.get_property_string("path", false));
d.Multiselect = true;
if (d.ShowDialog() == DialogResult.OK)
foreach (string i in d.FileNames)
mp.commandv("sub-add", i);
}
}));
}
public static void load_audio(string[] args)
{
MainForm.Instance.BeginInvoke(new Action(() => {
using (var d = new OpenFileDialog())
{
d.InitialDirectory = Path.GetDirectoryName(mp.get_property_string("path", false));
d.Multiselect = true;
if (d.ShowDialog() == DialogResult.OK)
foreach (string i in d.FileNames)
mp.commandv("audio-add", i);
}
}));
}
}
}

View File

@@ -45,7 +45,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(288F, 288F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(1012, 615);
this.ClientSize = new System.Drawing.Size(606, 368);
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);

View File

@@ -14,8 +14,11 @@ namespace mpvnet
public static IntPtr Hwnd;
private Point LastCursorPosChanged;
private int LastCursorChangedTickCount;
private bool IgnoreDpiChanged = true;
private int LastCursorChangedTickCount;
private bool IgnoreDpiChanged = true;
private float mpvAutofit = 0.42f;
private bool mpvFullscreen;
private int mpvScreen = -1;
public ContextMenuStripEx CMS;
@@ -32,15 +35,15 @@ namespace mpvnet
MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
Text += " " + Application.ProductVersion;
if (mp.mpvConf.ContainsKey("screen"))
SetScreen(Convert.ToInt32(mp.mpvConf["screen"]));
else
SetScreen(Screen.PrimaryScreen);
ChangeFullscreen((mp.mpvConf.ContainsKey("fullscreen") && mp.mpvConf["fullscreen"] == "yes") ||
(mp.mpvConf.ContainsKey("fs") && mp.mpvConf["fs"] == "yes"));
foreach (var i in mp.mpvConf)
ProcessMpvProperty(i.Key, i.Value);
ProcessCommandLineEarly();
if (mpvScreen == -1) mpvScreen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
SetScreen(mpvScreen);
ChangeFullscreen(mpvFullscreen);
}
catch (Exception e)
{
@@ -51,7 +54,8 @@ namespace mpvnet
protected void SetScreen(int targetIndex)
{
Screen[] screens = Screen.AllScreens;
if (targetIndex < 0 || targetIndex > screens.Length - 1) return;
if (targetIndex < 0) targetIndex = 0;
if (targetIndex > screens.Length - 1) targetIndex = screens.Length - 1;
SetScreen(screens[Array.IndexOf(screens, screens[targetIndex])]);
}
@@ -67,7 +71,7 @@ namespace mpvnet
{
if (IsFullscreen || mp.VideoSize.Width == 0) return;
Screen screen = Screen.FromControl(this);
int height = Convert.ToInt32(screen.Bounds.Height * 0.6);
int height = Convert.ToInt32(screen.Bounds.Height * mpvAutofit);
int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.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));
@@ -82,7 +86,7 @@ namespace mpvnet
if (IsFullscreen || mp.VideoSize.Width == 0) return;
Screen screen = Screen.FromControl(this);
int height = ClientSize.Height;
if (height > screen.Bounds.Height * 0.8) height = Convert.ToInt32(screen.Bounds.Height * 0.6);
if (height > screen.Bounds.Height * 0.9) height = Convert.ToInt32(screen.Bounds.Height * mpvAutofit);
int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.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));
@@ -108,11 +112,7 @@ namespace mpvnet
{
string left = i.Substring(2, i.IndexOf("=") - 2);
string right = i.Substring(left.Length + 3);
if (left == "screen")
SetScreen(Convert.ToInt32(right));
ChangeFullscreen((left == "fs" || left == "fullscreen") && right == "yes");
ProcessMpvProperty(left, right);
}
else
{
@@ -122,7 +122,7 @@ namespace mpvnet
{
case "fs":
case "fullscreen":
ChangeFullscreen(true);
mpvFullscreen = true;
break;
}
}
@@ -130,6 +130,25 @@ namespace mpvnet
}
}
void ProcessMpvProperty(string name, string value)
{
switch (name)
{
case "autofit":
if (value.Length == 3 && value.EndsWith("%"))
if (int.TryParse(value.Substring(0, 2), out int result))
mpvAutofit = result / 100f;
break;
case "fs":
case "fullscreen":
mpvFullscreen = value == "yes";
break;
case "screen":
mpvScreen = Convert.ToInt32(value);
break;
}
}
public void BuildMenu()
{
foreach (var i in File.ReadAllText(mp.InputConfPath).Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))

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.3.0.0")]
[assembly: AssemblyFileVersion("2.3.0.0")]
[assembly: AssemblyVersion("2.4.0.0")]
[assembly: AssemblyFileVersion("2.4.0.0")]

View File

@@ -26,6 +26,10 @@
o script-message mpv.net open-files #menu: Open > Open Files...
u script-message mpv.net open-url #menu: Open > Open URL...
_ ignore #menu: Open > -
Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files...
Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files...
_ ignore #menu: -
Space cycle pause #menu: Play/Pause
s stop #menu: Stop

View File

@@ -360,15 +360,23 @@ namespace mpvnet
public static string get_property_string(string name, bool throwOnException = false)
{
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, out IntPtr lpBuffer);
try
{
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, out IntPtr lpBuffer);
if (err < 0 && throwOnException)
throw new Exception($"{name}: {(mpv_error)err}");
if (err < 0 && throwOnException)
throw new Exception($"{name}: {(mpv_error)err}");
var ret = StringFromNativeUtf8(lpBuffer);
mpv_free(lpBuffer);
var ret = StringFromNativeUtf8(lpBuffer);
mpv_free(lpBuffer);
return ret;
return ret;
}
catch (Exception ex)
{
if (throwOnException) throw ex;
return "";
}
}
public static int get_property_int(string name, bool throwOnException = false)

View File

@@ -91,14 +91,10 @@ namespace mpvConfEdit
case StringSetting s:
if ((s.Value ?? "") != s.Default)
mpvConf[s.Name] = s.Value;
else
mpvConf.Remove(s.Name);
break;
case OptionSetting s:
if ((s.Value ?? "") != s.Default)
mpvConf[s.Name] = s.Value;
else
mpvConf.Remove(s.Name);
break;
}
}

View File

@@ -14,7 +14,7 @@
<Controls:SearchTextBoxUserControl x:Name="SearchControl" Width="300" Margin="0,20,0,20" Grid.ColumnSpan="2" />
<DataGrid Grid.Row="1" x:Name="DataGrid" CommandManager.PreviewCanExecute="DataGrid_PreviewCanExecute" AutoGenerateColumns="False" CellStyle="{StaticResource DataGrid_Font_Centering}">
<DataGrid.Columns>
<DataGridTextColumn Header="Context Menu" Binding="{Binding Menu}"/>
<DataGridTextColumn Header="Menu" Binding="{Binding Menu}"/>
<DataGridTemplateColumn Header="Input">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>

View File

@@ -37,7 +37,7 @@ namespace mpvInputEdit
string searchText = SearchControl.SearchTextBox.Text.ToLower();
if (searchText == "") return true;
if (searchText.StartsWith("i "))
if (searchText.StartsWith("i ") || searchText.StartsWith("i:"))
{
searchText = searchText.Substring(2).Trim();
@@ -45,9 +45,9 @@ namespace mpvInputEdit
return item.Input.ToLower().Replace("ctrl+", "").Replace("shift+", "").Replace("alt+", "").Contains(searchText);
else
return item.Input.ToLower().Contains(searchText);
} else if (searchText.StartsWith("m "))
} else if (searchText.StartsWith("m ") || searchText.StartsWith("m:"))
return item.Menu.ToLower().Contains(searchText.Substring(2).Trim());
else if (searchText.StartsWith("c "))
else if (searchText.StartsWith("c ") || searchText.StartsWith("c:"))
return item.Command.ToLower().Contains(searchText.Substring(2).Trim());
else if (item.Command.ToLower().Contains(searchText) ||
item.Menu.ToLower().Contains(searchText) ||

View File

@@ -29,7 +29,7 @@ namespace Controls
SearchClearButton.Visibility = Visibility.Visible;
if (SearchTextBox.Text == "?")
MessageBox.Show("Use i, m or c to set the filter scope to Input, Menu or Command.", "Filter", MessageBoxButton.OK, MessageBoxImage.Information);
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>", "Filtering", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}