Compare commits

...

16 Commits

Author SHA1 Message Date
stax76
3970d5c0c2 v7.0.0.6 Beta 2024-01-02 09:09:16 +01:00
stax76
4451eafe71 Merge branch 'main' of https://github.com/mpvnet-player/mpv.net 2023-12-28 06:18:10 +01:00
stax76
1c799fd474 hwdec description 2023-12-28 06:17:57 +01:00
stax76
17e25619da Merge pull request #626 from nkh0472/patch-3
change screenshot-tag-colorspace default value to `yes`
2023-12-28 06:16:06 +01:00
stax76
a4376b1492 Merge pull request #627 from nkh0472/patch-4
Detailed description for hwdec
2023-12-28 06:13:37 +01:00
stax76
d41faad9d9 v7.0.0.5 Beta 2023-12-28 06:11:42 +01:00
nkh0472
0e6116b478 Detailed description for hwdec 2023-12-27 22:29:31 +08:00
nkh0472
789127e8ff change screenshot-tag-colorspace default value to yes 2023-12-27 22:17:45 +08:00
stax76
6ef9f32d4f misc 2023-12-26 16:58:12 +01:00
stax76
1048dbed40 New menu item and binding: File > Add files to playlist from clipboard (Ctrl+Shift+v) 2023-12-26 09:22:27 +01:00
stax76
86c823bfde misc 2023-12-24 07:34:12 +01:00
stax76
764f00ed3a misc 2023-12-23 10:20:57 +01:00
stax76
3e4ea03437 Support of the mpv option title-bar 2023-12-22 18:35:07 +01:00
stax76
0ef679e00d argh 2023-12-21 10:01:59 +01:00
stax76
7f2bf2e905 misc 2023-12-20 05:19:50 +01:00
stax76
ab8a8d5a35 Command line parser fix using list options with -add suffix 2023-12-19 12:12:34 +01:00
32 changed files with 2671 additions and 1986 deletions

View File

@@ -1,4 +1,27 @@
# v7.0.0.6 Beta (2023-01-02)
- Improved backward compatibility with input.conf files created by old versions.
# v7.0.0.5 Beta (2023-12-28)
- Fix mpv.net option `language` not working from command line.
- Chinese and German translation updated.
- More libplacebo options added.
- Support of the mpv option `title-bar`.
- Video being less often rendered with black line at the bottom.
- The conf file reader/writer detects if the user prefers space before and after the equal sign.
- The portable download includes like the installer debug symbols.
- Setup questions on startup removed.
- Pressing shift while drag and drop appends instead of replaces
files in the playlist. mpv supports this as well.
- New menu item and binding: `File > Add files to playlist from clipboard` `Ctrl+Shift+v`.
- All list operation suffixes are available on the command line.
- Improved layout in conf editor.
- New zhongfly libmpv build.
# v7.0.0.4 Beta (2023-12-19)
- When mpv.net is started for the first time from a new startup location,

View File

@@ -92,14 +92,14 @@ Before making a support request, please try the newest [beta version](../../../r
Support can be requested here:
Beginner questions:
https://www.reddit.com/r/mpv
mpv.net bug reports, feature requests and advanced questions:
https://github.com/mpvnet-player/mpv.net/issues
Beginner mpv questions:
https://www.reddit.com/r/mpv
Advanced mpv questions:
https://github.com/mpv-player/mpv/issues
@@ -241,10 +241,13 @@ Shows a folder browser dialog to open a DVD or BD folder.
ISO images don't have to be mounted, but instead can be
opened directly with the open-files command.
### open-clipboard
### open-clipboard [\<flags\>]
Opens a single URL or filepath from the clipboard,
or multiple files in the file clipboard format.
**append**
Appends files/URLs to the playlist.
### play-pause
Cycles the pause property. In case the playlist is empty,
the most recent file from the recent files list is loaded.
@@ -267,6 +270,21 @@ Shows available audio devices in a message box.
### show-commands
Shows available [mpv input commands](https://mpv.io/manual/master/#list-of-input-commands).
### show-properties
Shows available [properties](https://mpv.io/manual/master/#properties).
### show-keys
Shows available [input keys](https://mpv.io/manual/master/#options-input-keylist).
### show-protocols
Shows available [protocols](https://mpv.io/manual/master/#options-list-protocols).
### show-decoders
Shows available decoders.
### show-demuxers
Shows available demuxers.
### show-conf-editor
Shows the conf editor.
@@ -603,7 +621,7 @@ visible, even when mpv.net is started from the terminal and music is played.
For mpv.net it's currently not possible to find out where OSC menus are located,
but there are 3 features that require this information, therefore mpv.net
makes the assumption that near the window borders might be OSC menus. As a result
the following three features, work only when invokes from the center of the window:
the following three features, work only when invoked from the center of the window:
1. Window dragging (moving the window with the mouse).
2. Showing the context menu.
@@ -625,6 +643,7 @@ https://mpv.io/manual/master/#window
- [ontop](https://mpv.io/manual/master/#options-ontop)
- [screen](https://mpv.io/manual/master/#options-screen)
- [snap-window](https://mpv.io/manual/master/#options-snap-window)
- [title-bar](https://mpv.io/manual/master/#options-title-bar)
- [title](https://mpv.io/manual/master/#options-title)
- [window-maximized](https://mpv.io/manual/master/#options-window-maximized)
- [window-minimized](https://mpv.io/manual/master/#options-window-minimized)
@@ -655,6 +674,9 @@ x=100 docks the window to the right side.
y=0 docks the window to the top side.
y=100 docks the window to the bottom side.
#### --title-bar=\<yes|no\>
Shows the window title bar. Default: yes
**mpv.net specific window features:**
@@ -731,8 +753,8 @@ Blu-ray and DVD ISO image files are supported.
### Open > Open URL or file path from clipboard
Opens files and URLs from the clipboard. How to open URLs directly
from the browser from sites like YouTube is described in the
Opens files and URLs from the clipboard. Shift key appends to the playlist.
How to open URLs directly from the browser from sites like YouTube is described in the
[External Tools section](#external-tools).

View File

@@ -1,4 +1,6 @@
$ErrorActionPreference = 'Stop'
$PoFiles = Get-ChildItem $PSScriptRoot/po
$ExeFolder = "$PSScriptRoot/../src/MpvNet.Windows/bin/Debug"
@@ -20,15 +22,14 @@ function CreateFolder
foreach ($it in $PoFiles)
{
$folder = "$ExeFolder/Locale/$($it.BaseName)/LC_MESSAGES"
New-Item -ItemType Directory -Path $folder
$moPath = "$folder/mpvnet.mo"
New-Item -ItemType File -Path $moPath
msgfmt --output-file=$moPath $it.FullName
if ($LASTEXITCODE -ne 0)
if (-not (Test-Path $folder))
{
throw
New-Item -ItemType Directory -Path $folder
}
$moPath = "$folder/mpvnet.mo"
msgfmt --output-file=$moPath $it.FullName
if ($LastExitCode) { throw $LastExitCode }
$moPath
}

View File

@@ -3,6 +3,7 @@ D:\Projects\CS\mpv.net\src\MpvNet\AppInfo.cs
D:\Projects\CS\mpv.net\src\MpvNet\Binding.cs
D:\Projects\CS\mpv.net\src\MpvNet\Chapter.cs
D:\Projects\CS\mpv.net\src\MpvNet\Command.cs
D:\Projects\CS\mpv.net\src\MpvNet\CommandLine.cs
D:\Projects\CS\mpv.net\src\MpvNet\ExtensionLoader.cs
D:\Projects\CS\mpv.net\src\MpvNet\FileTypes.cs
D:\Projects\CS\mpv.net\src\MpvNet\Folder.cs
@@ -14,6 +15,7 @@ D:\Projects\CS\mpv.net\src\MpvNet\MediaTrack.cs
D:\Projects\CS\mpv.net\src\MpvNet\MpvClient.cs
D:\Projects\CS\mpv.net\src\MpvNet\Player.cs
D:\Projects\CS\mpv.net\src\MpvNet\Settings.cs
D:\Projects\CS\mpv.net\src\MpvNet\StringPair.cs
D:\Projects\CS\mpv.net\src\MpvNet\Terminal.cs
D:\Projects\CS\mpv.net\src\MpvNet\Translator.cs
D:\Projects\CS\mpv.net\src\MpvNet\ExtensionMethod\ObjectExtension.cs
@@ -35,9 +37,8 @@ D:\Projects\CS\mpv.net\src\MpvNet.Windows\GlobalUsings.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\GuiCommand.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\Program.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\Settings.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\StringPair.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\Help\RegistryHelp.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\Help\WinMpvHelp.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\Help\WinApiHelp.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\Native\StockIcon.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\Native\Taskbar.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\Native\WinApi.cs
@@ -51,6 +52,7 @@ D:\Projects\CS\mpv.net\src\MpvNet.Windows\WinForms\MainForm.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WinForms\MainForm.Designer.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WinForms\SnapManager.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\BindingProxy.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\ComboBoxTemplateSelector.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\ConfWindow.xaml.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\InputWindow.xaml.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\ISettingControl.cs
@@ -59,6 +61,7 @@ D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\MenuHelp.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\Msg.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\WpfApplication.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\WpfTranslator.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\Controls\ComboBoxSettingControl.xaml.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\Controls\CommandPaletteControl.xaml.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\Controls\HyperlinkEx.cs
D:\Projects\CS\mpv.net\src\MpvNet.Windows\WPF\Controls\OptionSettingControl.xaml.cs

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,6 @@
$ErrorActionPreference = 'Stop'
# Write list of .cs files into cs-files.txt file
Get-ChildItem $PSScriptRoot/.. -Recurse -File -Filter '*.cs' |
Where-Object { $_ -notmatch '[/\\]obj[/\\]' } |
@@ -7,6 +9,7 @@ Get-ChildItem $PSScriptRoot/.. -Recurse -File -Filter '*.cs' |
# Create .pot file
xgettext --force-po --from-code=UTF-8 '--language=c#' -o $PSScriptRoot/source.pot --files-from=$PSScriptRoot/cs-files.txt --keyword=_
if ($LastExitCode) { throw $LastExitCode }
# Backup .po files
$BackupTargetFolder = $env:TEMP + '/mpv.net po backup ' + (Get-Date -Format 'yyyy-MM-dd HH_mm_ss')
@@ -16,3 +19,5 @@ Copy-Item $PSScriptRoot/po $BackupTargetFolder -Force -Recurse
# Update .po files
(Get-ChildItem $PSScriptRoot/PO -Filter '*.po').FullName |
ForEach-Object { msgmerge --sort-output --backup=none --update $_ $PSScriptRoot/source.pot }
if ($LastExitCode) { throw $LastExitCode }

View File

@@ -1,5 +1,6 @@

using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Windows.Forms;
@@ -11,9 +12,8 @@ using MpvNet.Windows.WinForms;
using MpvNet.Windows.WPF.Views;
using MpvNet.Windows.WPF;
using MpvNet.Windows.WPF.MsgBox;
using MpvNet.Help;
using System.Text.Json;
using MpvNet.Windows.Help;
using MpvNet.Help;
namespace MpvNet;
@@ -47,27 +47,35 @@ public class GuiCommand
["window-scale"] = args => WindowScaleNet?.Invoke(float.Parse(args[0], CultureInfo.InvariantCulture)),
["show-menu"] = args => ShowMenu?.Invoke(),
["show-bindings"] = args => ShowBindings(),
["show-playlist"] = args => ShowPlaylist(),
["add-to-path"] = args => AddToPath(),
["edit-conf-file"] = EditCongFile,
["show-commands"] = args => ShowCommands(),
["show-properties"] = args => ShowProperties(),
["show-keys"] = args => ShowKeys(),
["show-protocols"] = args => ShowProtocols(),
["show-decoders"] = args => ShowDecoders(),
["show-demuxers"] = args => ShowDemuxers(),
["show-info"] = args => ShowMediaInfo(new[] { "osd" }),
// deprecated
["show-info"] = args => ShowMediaInfo(new[] { "osd" }), // deprecated
["show-recent"] = args => ShowRemoved(), // deprecated
["show-playlist"] = args => ShowPlaylist(), // deprecated
["quick-bookmark"] = args => QuickBookmark(), // deprecated
["show-history"] = args => ShowHistory(), // deprecated
["show-command-palette"] = args => ShowCommandPalette(), // deprecated
["show-audio-tracks"] = args => ShowTracks(), // deprecated
["show-subtitle-tracks"] = args => ShowTracks(), // deprecated
};
public void ShowDialog(Type winType)
void ShowDialog(Type winType)
{
Window? win = Activator.CreateInstance(winType) as Window;
new WindowInteropHelper(win).Owner = MainForm.Instance!.Handle;
win?.ShowDialog();
}
public void LoadSubtitle(IList<string> args)
void LoadSubtitle(IList<string> args)
{
using var dialog = new OpenFileDialog();
string path = Player.GetPropertyString("path");
@@ -82,7 +90,7 @@ public class GuiCommand
Player.CommandV("sub-add", filename);
}
public void OpenFiles(IList<string> args)
void OpenFiles(IList<string> args)
{
bool append = false;
@@ -96,7 +104,7 @@ public class GuiCommand
Player.LoadFiles(dialog.FileNames, true, append);
}
public void Open_DVD_Or_BD_Folder(IList<string> args)
void Open_DVD_Or_BD_Folder(IList<string> args)
{
var dialog = new FolderBrowserDialog();
@@ -104,7 +112,7 @@ public class GuiCommand
Player.LoadDiskFolder(dialog.SelectedPath);
}
public void EditCongFile(IList<string> args)
void EditCongFile(IList<string> args)
{
string file = Player.ConfigFolder + args[0];
@@ -112,7 +120,7 @@ public class GuiCommand
ProcessHelp.ShellExecute(WinApiHelp.GetAppPathForExtension("txt"), "\"" + file + "\"");
}
public static void ShowTextWithEditor(string name, string text)
void ShowTextWithEditor(string name, string text)
{
string file = Path.Combine(Path.GetTempPath(), name + ".txt");
App.TempFiles.Add(file);
@@ -120,7 +128,7 @@ public class GuiCommand
ProcessHelp.ShellExecute(WinApiHelp.GetAppPathForExtension("txt"), "\"" + file + "\"");
}
public static void ShowCommands()
void ShowCommands()
{
string json = Core.GetPropertyString("command-list");
var enumerator = JsonDocument.Parse(json).RootElement.EnumerateArray();
@@ -151,12 +159,32 @@ public class GuiCommand
ShowTextWithEditor("Input Commands", header + sb.ToString());
}
public void OpenFromClipboard(IList<string> args)
void ShowProperties() =>
ShowTextWithEditor("Properties", Core.GetPropertyString("property-list").Replace(",", BR));
void ShowKeys() =>
ShowTextWithEditor("Keys", Core.GetPropertyString("input-key-list").Replace(",", BR));
void ShowProtocols() =>
ShowTextWithEditor("Protocols", Core.GetPropertyString("protocol-list").Replace(",", BR));
void ShowDecoders() =>
ShowTextWithEditor("Decoders", Core.GetPropertyOsdString("decoder-list").Replace(",", BR));
void ShowDemuxers() =>
ShowTextWithEditor("Demuxers", Core.GetPropertyOsdString("demuxer-lavf-list").Replace(",", BR));
void OpenFromClipboard(IList<string> args)
{
bool append = args.Count == 1 && args[0] == "append";
if (System.Windows.Forms.Clipboard.ContainsFileDropList())
{
string[] files = System.Windows.Forms.Clipboard.GetFileDropList().Cast<string>().ToArray();
Player.LoadFiles(files, false, false);
Player.LoadFiles(files, false, append);
if (append)
Player.CommandV("show-text", _("Files/URLs were added to the playlist"));
}
else
{
@@ -169,15 +197,18 @@ public class GuiCommand
if (files.Count == 0)
{
Terminal.WriteError("The clipboard does not contain a valid URL or file.");
Terminal.WriteError(_("The clipboard does not contain a valid URL or file."));
return;
}
Player.LoadFiles(files.ToArray(), false, false);
Player.LoadFiles(files.ToArray(), false, append);
if (append)
Player.CommandV("show-text", _("Files/URLs were added to the playlist"));
}
}
public void LoadAudio(IList<string> args)
void LoadAudio(IList<string> args)
{
using var dialog = new OpenFileDialog();
string path = Player.GetPropertyString("path");
@@ -192,7 +223,7 @@ public class GuiCommand
Player.CommandV("audio-add", i);
}
public void RegisterFileAssociations(IList<string> args)
void RegisterFileAssociations(IList<string> args)
{
string perceivedType = args[0];
string[] extensions = Array.Empty<string>();
@@ -230,7 +261,7 @@ public class GuiCommand
catch { }
}
public void ShowMediaInfo(IList<string> args)
void ShowMediaInfo(IList<string> args)
{
if (Player.PlaylistPos == -1)
return;
@@ -312,17 +343,17 @@ public class GuiCommand
}
}
public static string FormatTime(double value) => ((int)value).ToString("00");
string FormatTime(double value) => ((int)value).ToString("00");
public void ShowBindings() => ShowTextWithEditor("Bindings", Player.UsedInputConfContent);
void ShowBindings() => ShowTextWithEditor("Bindings", Player.UsedInputConfContent);
public void AddToPath()
void AddToPath()
{
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!;
if (path.ToLower().Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar).ToLower()))
{
Msg.ShowWarning("mpv.net is already in Path.");
Msg.ShowWarning(_("mpv.net is already in Path."));
return;
}
@@ -330,56 +361,44 @@ public class GuiCommand
Folder.Startup.TrimEnd(Path.DirectorySeparatorChar) + ";" + path,
EnvironmentVariableTarget.User);
Msg.ShowInfo("mpv.net successfully was added to Path.");
}
public void ShowPlaylist()
{
var count = Player.GetPropertyInt("playlist-count");
if (count < 1)
return;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++)
{
string name = Player.GetPropertyString($"playlist/{i}/title");
if (string.IsNullOrEmpty(name))
name = Player.GetPropertyString($"playlist/{i}/filename").FileName();
sb.AppendLine(name);
}
string header = BR + "For a playlist menu the following user scripts exist:" + BR2 +
"https://github.com/stax76/mpv-scripts#command_palette" + BR +
"https://github.com/stax76/mpv-scripts#search_menu" + BR +
"https://github.com/tomasklaen/uosc" + BR +
"https://github.com/jonniek/mpv-playlistmanager" + BR2;
Msg.ShowInfo(header + sb.ToString().TrimEnd());
Msg.ShowInfo(_("mpv.net was successfully added to Path."));
}
// deprecated
public void QuickBookmark() =>
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
"https://github.com/stax76/mpv-scripts/blob/main/misc.lua");
// deprecated
public void ShowHistory() =>
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
"https://github.com/stax76/mpv-scripts/blob/main/history.lua");
// deprecated
public void ShowCommandPalette() =>
Msg.ShowInfo(
"This feature was removed but is still available in the form of user scripts:" + BR2 +
void ShowTracks() =>
Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 +
"https://github.com/stax76/mpv-scripts#command_palette" + BR +
"https://github.com/stax76/mpv-scripts#search_menu" + BR +
"https://github.com/tomasklaen/uosc");
}
// deprecated
void ShowPlaylist() =>
Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 +
"https://github.com/stax76/mpv-scripts#command_palette" + BR +
"https://github.com/stax76/mpv-scripts#search_menu" + BR +
"https://github.com/tomasklaen/uosc" + BR +
"https://github.com/jonniek/mpv-playlistmanager");
// deprecated
void ShowCommandPalette() =>
Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 +
"https://github.com/stax76/mpv-scripts#command_palette" + BR +
"https://github.com/stax76/mpv-scripts#search_menu" + BR +
"https://github.com/tomasklaen/uosc");
// deprecated
void QuickBookmark() =>
Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 +
"https://github.com/stax76/mpv-scripts/blob/main/misc.lua");
// deprecated
void ShowHistory() =>
Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 +
"https://github.com/stax76/mpv-scripts/blob/main/history.lua");
// deprecated
void ShowRemoved() => Msg.ShowInfo(_("This feature was removed."));
}
//public void ShowCommandPalette()
@@ -389,4 +408,4 @@ public class GuiCommand
// MainForm.Instance.ShowCommandPalette();
// CommandPalette.Instance.SelectFirst();
// });
//}
//}

View File

@@ -7,7 +7,7 @@ using static MpvNet.Windows.Native.WinApi;
namespace MpvNet.Windows.Help;
public class WinApiHelp
public static class WinApiHelp
{
public static Version WindowsTen1607 { get; } = new Version(10, 0, 14393); // Windows 10 1607
@@ -27,31 +27,51 @@ public class WinApiHelp
}
}
public static void SubtractWindowBorders(IntPtr hwnd, ref Rect rc, int dpi)
public static void AdjustWindowRect(IntPtr hwnd, ref RECT rc, int dpi)
{
Rect r = new Rect(0, 0, 0, 0);
AddWindowBorders(hwnd, ref r, dpi);
uint style = (uint)GetWindowLongPtr(hwnd, -16); // GWL_STYLE
uint styleEx = (uint)GetWindowLongPtr(hwnd, -20); // GWL_EXSTYLE
if (Environment.OSVersion.Version >= WindowsTen1607)
AdjustWindowRectExForDpi(ref rc, style, false, styleEx, (uint)dpi);
else
Native.WinApi.AdjustWindowRect(ref rc, style, false);
}
public static void AddWindowBorders(IntPtr hwnd, ref RECT rc, int dpi, bool changeTop)
{
RECT win = rc;
AdjustWindowRect(hwnd, ref rc, dpi);
if (changeTop)
{
int top = rc.Top;
top -= rc.Top - win.Top;
rc = new RECT(rc.Left, top, rc.Right, rc.Bottom);
}
}
public static void SubtractWindowBorders(IntPtr hwnd, ref RECT rc, int dpi, bool changeTop)
{
RECT r = new RECT();
AddWindowBorders(hwnd, ref r, dpi, changeTop);
rc.Left -= r.Left;
rc.Top -= r.Top;
rc.Right -= r.Right;
rc.Bottom -= r.Bottom;
}
public static void AddWindowBorders(IntPtr hwnd, ref Rect rc, int dpi)
public static int GetTitleBarHeight(IntPtr hwnd, int dpi)
{
uint windowStyle = (uint)GetWindowLong(hwnd, -16); // GWL_STYLE
uint windowStyleEx = (uint)GetWindowLong(hwnd, -20); // GWL_EXSTYLE
if (Environment.OSVersion.Version >= WindowsTen1607)
AdjustWindowRectExForDpi(ref rc, windowStyle, false, windowStyleEx, (uint)dpi);
else
AdjustWindowRect(ref rc, windowStyle, false);
RECT rect = new RECT();
AdjustWindowRect(hwnd, ref rect, dpi);
return -rect.Top;
}
public static Rectangle GetWorkingArea(IntPtr handle, Rectangle workingArea)
{
if (handle != IntPtr.Zero && GetDwmWindowRect(handle, out Rect dwmRect) &&
GetWindowRect(handle, out Rect rect))
if (handle != IntPtr.Zero && GetDwmWindowRect(handle, out RECT dwmRect) &&
GetWindowRect(handle, out RECT rect))
{
int left = workingArea.Left;
int top = workingArea.Top;
@@ -69,28 +89,12 @@ public class WinApiHelp
return workingArea;
}
public static bool GetDwmWindowRect(IntPtr handle, out Rect rect)
public static bool GetDwmWindowRect(IntPtr handle, out RECT rect)
{
const uint DWMWA_EXTENDED_FRAME_BOUNDS = 9;
return 0 == DwmGetWindowAttribute(handle, DWMWA_EXTENDED_FRAME_BOUNDS,
out rect, (uint)Marshal.SizeOf<Rect>());
}
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
{
if (IntPtr.Size == 8)
return GetWindowLongPtr(hWnd, nIndex);
else
return GetWindowLong32(hWnd, nIndex);
}
public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong)
{
if (IntPtr.Size == 8)
return SetWindowLongPtr(hWnd, nIndex, dwNewLong);
else
return SetWindowLong32(hWnd, nIndex, dwNewLong);
out rect, (uint)Marshal.SizeOf<RECT>());
}
public static string GetAppPathForExtension(params string[] extensions)

View File

@@ -1,58 +0,0 @@

using System.Windows;
using MpvNet.Windows.WPF;
namespace MpvNet.Windows.Help;
public class WinMpvHelp
{
public static void Setup()
{
string dir = RegistryHelp.GetString("PathEnvVarCheck"); // backward compatibility
if (dir == Folder.Startup)
return;
dir = RegistryHelp.GetString("Setup");
if (dir == Folder.Startup)
return;
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!;
if (!path.ToLower().Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar).ToLower()))
{
var result = Msg.ShowQuestion("Would you like to add mpv.net to the Path environment variable?" + BR2 +
"This will allow using mpv.net in a console/terminal.", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
Environment.SetEnvironmentVariable("Path",
Folder.Startup.TrimEnd(Path.DirectorySeparatorChar) + ";" + path,
EnvironmentVariableTarget.User);
Msg.ShowInfo("mpv.net was added successfully to Path.");
}
else
Msg.ShowInfo("If you want to add mpv.net to the Path environment variable later," + BR +
"you can do so with the context menu (Settings/Setup)");
}
var result2 = Msg.ShowQuestion("Would you like to register video file associations?", MessageBoxButton.YesNo);
if (result2 == MessageBoxResult.Yes)
{
Player.Command("script-message-to mpvnet reg-file-assoc video");
result2 = Msg.ShowQuestion("Would you like to register audio file associations?", MessageBoxButton.YesNo);
if (result2 == MessageBoxResult.Yes)
Player.Command("script-message-to mpvnet reg-file-assoc audio");
}
else
Msg.ShowInfo("If you want to register file associations later," + BR +
"you can do so with the context menu (Settings/Setup)");
RegistryHelp.SetString("Setup", Folder.Startup);
}
}

View File

@@ -11,9 +11,9 @@
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>mpv-icon.ico</ApplicationIcon>
<Product>mpv.net</Product>
<FileVersion>7.0.0.4</FileVersion>
<AssemblyVersion>7.0.0.4</AssemblyVersion>
<InformationalVersion>7.0.0.4</InformationalVersion>
<FileVersion>7.0.0.6</FileVersion>
<AssemblyVersion>7.0.0.6</AssemblyVersion>
<InformationalVersion>7.0.0.6</InformationalVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

View File

@@ -2,6 +2,7 @@
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using static HandyControl.Tools.Interop.InteropValues;
namespace MpvNet.Windows.Native;
@@ -20,7 +21,7 @@ public static class WinApi
public static extern uint ActivateKeyboardLayout(IntPtr hkl, uint flags);
[DllImport("user32.dll")]
public static extern bool GetWindowRect(IntPtr hwnd, out Rect lpRect);
public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindowEx(
@@ -48,28 +49,19 @@ public static class WinApi
public static extern int GetDpiForWindow(IntPtr hwnd);
[DllImport("user32.dll")]
public static extern bool AdjustWindowRect(ref Rect lpRect, uint dwStyle, bool bMenu);
public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu);
[DllImport("user32.dll")]
public static extern bool AdjustWindowRectExForDpi(
ref Rect lpRect, uint dwStyle, bool bMenu, uint dwExStyle, uint dpi);
ref RECT lpRect, uint dwStyle, bool bMenu, uint dwExStyle, uint dpi);
[DllImport("user32.dll")]
public static extern bool SetWindowPos(
IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
public static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
public static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
public static extern IntPtr SetWindowLong32(IntPtr hWnd, int nIndex, uint dwNewLong);
[DllImport("user32.dll")]
public static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, uint dwNewLong);
[DllImport("gdi32.dll")]
public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
@@ -79,17 +71,17 @@ public static class WinApi
[DllImport("dwmapi.dll")]
public static extern int DwmGetWindowAttribute(
IntPtr hwnd, uint dwAttribute, out Rect pvAttribute, uint cbAttribute);
IntPtr hwnd, uint dwAttribute, out RECT pvAttribute, uint cbAttribute);
[StructLayout(LayoutKind.Sequential)]
public struct Rect
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public Rect(Rectangle r)
public RECT(Rectangle r)
{
Left = r.Left;
Top = r.Top;
@@ -97,7 +89,7 @@ public static class WinApi
Bottom = r.Bottom;
}
public Rect(int left, int top, int right, int bottom)
public RECT(int left, int top, int right, int bottom)
{
Left = left;
Top = top;
@@ -110,9 +102,9 @@ public static class WinApi
public int Width => Right - Left;
public int Height => Bottom - Top;
public static Rect FromRectangle(Rectangle rect)
public static RECT FromRectangle(Rectangle rect)
{
return new Rect(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
return new RECT(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
}
public override string ToString()
@@ -121,6 +113,20 @@ public static class WinApi
}
}
[StructLayout(LayoutKind.Sequential)]
public struct NCCALCSIZE_PARAMS
{
public NCCALCSIZE_PARAMS(RECT[] r, WINDOWPOS wp)
{
rgrc = r;
lppos = wp;
}
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public RECT[] rgrc;
public WINDOWPOS lppos;
}
[StructLayout(LayoutKind.Sequential)]
public struct CopyDataStruct
{

View File

@@ -41,7 +41,7 @@ static class Program
Theme.Init();
Mutex mutex = new Mutex(true, StringHelp.GetMD5Hash(App.ConfPath), out bool isFirst);
if (Control.ModifierKeys.HasFlag(Keys.Shift) ||
if (Control.ModifierKeys == Keys.Shift ||
App.CommandLine.Contains("--process-instance=multi") ||
App.CommandLine.Contains("--o="))
{

View File

@@ -17,7 +17,7 @@ name = media-info
file = mpvnet
default = yes
directory = General
help = Usage of the media info library instead of mpv to access media information. (mpv.net option)
help = Usage of the media info library instead of mpv to retrieve media information. (mpv.net option)
option = yes
option = no
@@ -82,7 +82,7 @@ file = mpv
default = no
directory = Video
url = https://mpv.io/manual/master/#options-hwdec
help = Specify the hardware video decoding API that should be used if possible. Whether hardware decoding is actually done depends on the video codec. If hardware decoding is not possible, mpv will fall back on software decoding.\n\nFor more information visit:
help = Specify the hardware video decoding API that should be used if possible. Whether hardware decoding is actually done depends on the video codec. If hardware decoding is not possible, mpv will fall back on software decoding. Hardware decoding is disabled by default to maintain reliability. However, modern hardware should support hardware video decoding, reducing CPU usage and power consumption.\n\nFor more information visit:
option = no always use software decoding
option = auto enable best hw decoder
option = yes exactly the same as auto
@@ -327,6 +327,14 @@ default = no
option = yes
option = no
name = deband_preset
file = libplacebo
directory = Video/libplacebo/Debanding
help = Overrides the value of all options in this section by their default values from the given preset.
default = none
option = none
option = default
name = deband_iterations
file = libplacebo
directory = Video/libplacebo/Debanding
@@ -355,6 +363,14 @@ default = yes
option = yes
option = no
name = sigmoid_preset
file = libplacebo
directory = Video/libplacebo/Sigmoidization
help = Overrides the value of all options in this section by their default values from the given preset.
default = none
option = none
option = default
name = sigmoid_center
file = libplacebo
directory = Video/libplacebo/Sigmoidization
@@ -365,6 +381,355 @@ file = libplacebo
directory = Video/libplacebo/Sigmoidization
help = <1.0..20.0> The slope (steepness) of the sigmoid curve. Defaults to 6.5.
name = color_adjustment
file = libplacebo
directory = Video/libplacebo/Color Adjustment
help = Enables color adjustment.
default = yes
option = yes
option = no
name = color_adjustment_preset
file = libplacebo
directory = Video/libplacebo/Color Adjustment
help = Overrides the value of all options in this section by their default values from the given preset.
default = none
option = none
option = neutral
name = brightness
file = libplacebo
directory = Video/libplacebo/Color Adjustment
help = <-1.0..1.0> Brightness boost. Adds a constant bias onto the source luminance signal. 0.0 = neutral, 1.0 = solid white, -1.0 = solid black. Defaults to 0.0.
name = contrast
file = libplacebo
directory = Video/libplacebo/Color Adjustment
help = <0.0..100.0> Contrast gain. Multiplies the source luminance signal by a constant factor. 1.0 = neutral, 0.0 = solid black. Defaults to 1.0.
name = saturation
file = libplacebo
directory = Video/libplacebo/Color Adjustment
help = <0.0..100.0> Saturation gain. Multiplies the source chromaticity signal by a constant factor. 1.0 = neutral, 0.0 = grayscale. Defaults to 1.0.
name = hue
file = libplacebo
directory = Video/libplacebo/Color Adjustment
help = <angle> Hue shift. Corresponds to a rotation of the UV subvector around the neutral axis. Specified in radians. Defaults to 0.0 (neutral).
name = gamma
file = libplacebo
directory = Video/libplacebo/Color Adjustment
help = <0.0..100.0> Gamma lift. Subjectively brightnes or darkens the scene while preserving overall contrast. 1.0 = neutral, 0.0 = solid black. Defaults to 1.0.
name = temperature
file = libplacebo
directory = Video/libplacebo/Color Adjustment
help = <-1.143..5.286> Color temperature shift. Relative to 6500 K, a value of 0.0 gives you 6500 K (no change), a value of -1.0 gives you 3000 K, and a value of 1.0 gives you 10000 K. Defaults to 0.0.
name = peak_detect
file = libplacebo
directory = Video/libplacebo/HDR Peak Detection
help = Enables HDR peak detection.
default = yes
option = yes
option = no
name = peak_detection_preset
file = libplacebo
directory = Video/libplacebo/HDR Peak Detection
help = Overrides the value of all options in this section by their default values from the given preset. high_quality also enables frame histogram measurement.
default = none
option = none
option = default
option = high_quality
name = peak_smoothing_period
file = libplacebo
directory = Video/libplacebo/HDR Peak Detection
help = <0.0..1000.0> Smoothing coefficient for the detected values.
url = https://libplacebo.org/options/#peak_smoothing_period0010000
name = scene_threshold_low
file = libplacebo
directory = Video/libplacebo/HDR Peak Detection
url = https://libplacebo.org/options/#scene_threshold_low001000-scene_threshold_high001000
name = scene_threshold_high
file = libplacebo
directory = Video/libplacebo/HDR Peak Detection
url = https://libplacebo.org/options/#scene_threshold_low001000-scene_threshold_high001000
name = peak_percentile
file = libplacebo
directory = Video/libplacebo/HDR Peak Detection
help = <0.0..100.0> Which percentile of the input image brightness histogram to consider as the true peak of the scene.
url = https://libplacebo.org/options/#peak_percentile001000
name = black_cutoff
file = libplacebo
directory = Video/libplacebo/HDR Peak Detection
help = <0.0..100.0> Black cutoff strength.
url = https://libplacebo.org/options/#black_cutoff001000
name = allow_delayed_peak
file = libplacebo
directory = Video/libplacebo/HDR Peak Detection
help = Allows the peak detection result to be delayed by up to a single frame, which can sometimes improve throughput, at the cost of introducing the possibility of 1-frame flickers on transitions.
default = no
option = yes
option = no
name = color_map
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Enables the use of these color mapping settings. Disabling this option does not disable color mapping, it just means "use the default options for everything".
default = yes
option = yes
option = no
name = color_map_preset
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Overrides the value of all options in this section by their default values from the given preset. high_quality also enables HDR contrast recovery.
default = none
option = none
option = default
option = high_quality
name = gamut_mapping
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Gamut mapping function to use to handle out-of-gamut colors, including colors which are out-of-gamut as a consequence of tone mapping.
default = perceptual
option = clip
option = perceptual
option = softclip
option = relative
option = saturation
option = absolute
option = desaturate
option = darken
option = highlight
option = linear
name = perceptual_deadzone
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.0..1.0> (Relative) chromaticity protection zone for perceptual mapping. Defaults to 0.30.
name = perceptual_strength
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.0..1.0> Strength of the perceptual saturation mapping component. Defaults to 0.80.
name = colorimetric_gamma
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.0..10.0> I vs C curve gamma to use for colorimetric clipping (relative, absolute and darken). Defaults to 1.80.
name = softclip_knee
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.0..1.0> Knee point to use for soft-clipping methods (perceptual, softclip). Defaults to 0.70.
name = softclip_desat
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.0..1.0> Desaturation strength for softclip. Defaults to 0.35.
name = lut3d_size_I
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0..1024> Gamut mapping 3DLUT size. Setting a dimension to 0 picks the default value. Defaults to 48.
name = lut3d_size_C
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0..1024> Gamut mapping 3DLUT size. Setting a dimension to 0 picks the default value. Defaults to 32.
name = lut3d_size_h
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0..1024> Gamut mapping 3DLUT size. Setting a dimension to 0 picks the default value. Defaults to 256.
name = lut3d_tricubic
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Use higher quality, but slower, tricubic interpolation for gamut mapping 3DLUTs. May substantially improve the 3DLUT gamut mapping accuracy, in particular at smaller 3DLUT sizes. Shouldn't have much effect at the default size.
default = no
option = yes
option = no
name = gamut_expansion
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = If enabled, allows the gamut mapping function to expand the gamut, in cases where the target gamut exceeds that of the source. If disabled, the source gamut will never be enlarged, even when using a gamut mapping function capable of bidirectional mapping.
default = no
option = yes
option = no
name = tone_mapping
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Tone mapping function to use for adapting between difference luminance ranges, including black point adaptation.
default = spline
option = clip
option = spline
option = st2094-40
option = st2094-10
option = bt2390
option = bt2446a
option = reinhard
option = mobius
option = hable
option = gamma
option = linear
option = linearlight
name = knee_adaptation
file = libplacebo
directory = Video/libplacebo/Color Mapping
url = https://libplacebo.org/options/#tone-mapping-constants
name = knee_minimum
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.0..0.5> Configures the knee point minimum as a percentage of the PQ luminance range. Provides a hard limit on the knee point chosen by knee_adaptation. Defaults to 0.1.
name = knee_maximum
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.5..1.0> Configures the knee point maximum as a percentage of the PQ luminance range. Provides a hard limit on the knee point chosen by knee_adaptation. Defaults to 0.8.
name = knee_default
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.0..1.0> Default knee point to use in the absence of source scene average metadata. Normally, this is ignored in favor of picking the knee point as the (relative) source scene average brightness level. Defaults to 0.4.
name = knee_offset
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.5..2.0> Knee point offset (for bt2390 only). Note that a value of 0.5 is the spec-defined default behavior, which differs from the libplacebo default of 1.0.
name = slope_tuning
file = libplacebo
directory = Video/libplacebo/Color Mapping
url = https://libplacebo.org/options/#tone-mapping-constants
name = slope_offset
file = libplacebo
directory = Video/libplacebo/Color Mapping
url = https://libplacebo.org/options/#tone-mapping-constants
name = spline_contrast
file = libplacebo
directory = Video/libplacebo/Color Mapping
url = https://libplacebo.org/options/#tone-mapping-constants
name = reinhard_contrast
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.0..1.0> For the reinhard function, this specifies the local contrast coefficient at the display peak. Essentially, a value of 0.5 implies that the reference white will be about half as bright as when clipping. Defaults to 0.5.
name = linear_knee
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.0..1.0> For legacy functions (mobius, gamma) which operate on linear light, this directly sets the corresponding knee point. Defaults to 0.3.
name = exposure
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0.0..10.0> For linear methods (linear, linearlight), this controls the linear exposure/gain applied to the image. Defaults to 1.0.
name = inverse_tone_mapping
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = If enabled, and supported by the given tone mapping function, will perform inverse tone mapping to expand the dynamic range of a signal. libplacebo is not liable for any HDR-induced eye damage.
default = no
option = yes
option = no
name = tone_map_metadata
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Data source to use when tone-mapping. Setting this to a specific value allows overriding the default metadata preference logic.
default = any
option = any
option = none
option = hdr10
option = hdr10plus
option = cie_y
name = tone_lut_size
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <0..4096> Tone mapping LUT size. Setting 0 picks the default size. Defaults to 256.
name = contrast_recovery
file = libplacebo
directory = Video/libplacebo/Color Mapping
url = https://libplacebo.org/options/#contrast_recovery0020
name = contrast_smoothness
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = <1.0..32.0> HDR contrast recovery lowpass kernel size. Increasing or decreasing this will affect the visual appearance substantially. Defaults to 3.5.
name = force_tone_mapping_lut
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Force the use of a full tone-mapping LUT even for functions that have faster pure GLSL replacements (e.g. clip, linear, saturation). This is a debug option.
default = no
option = yes
option = no
name = visualize_lut
file = libplacebo
directory = Video/libplacebo/Color Mapping
url = https://libplacebo.org/options/#debug-options
default = no
option = yes
option = no
name = visualize_lut_x0
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Controls where to draw the LUt visualization, relative to the rendered video. Defaults to 0.0.
name = visualize_lut_y0
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Controls where to draw the LUt visualization, relative to the rendered video. Defaults to 0.0.
name = visualize_lut_x1
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Controls where to draw the LUt visualization, relative to the rendered video. Defaults to 1.0.
name = visualize_lut_y1
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Controls where to draw the LUt visualization, relative to the rendered video. Defaults to 1.0.
name = visualize_hue
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Controls the rotation of the gamut 3DLUT visualization. Rotates the gamut through hue space (around the I axis), in radians. Defaults to 0.0.
name = visualize_theta
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Controls the rotation of the gamut 3DLUT visualization. The theta parameter vertically rotates the cross section (around the C axis), in radians. Defaults to 0.0.
name = show_clipping
file = libplacebo
directory = Video/libplacebo/Color Mapping
help = Graphically highlight hard-clipped pixels during tone-mapping (i.e. pixels that exceed the claimed source luminance range).
default = no
option = yes
option = no
name = screenshot-directory
file = mpv
width = 500
@@ -382,7 +747,7 @@ option = png
name = screenshot-tag-colorspace
file = mpv
default = no
default = yes
directory = Video/Screenshot
help = Tag screenshots with the appropriate colorspace. Note that not all formats are supported.
option = yes
@@ -459,8 +824,9 @@ name = audio-device
file = mpv
directory = Audio
type = string
width = 400
url = https://mpv.io/manual/master/#options-audio-device
help = <name> Use the given audio device. This consists of the audio output name, e.g. alsa, followed by /, followed by the audio output specific device name. The default value for this option is auto, which tries every audio output in preference order with the default device.
help = <name> Use the given audio device. This consists of the audio output name, e.g. alsa, followed by /, followed by the audio output specific device name. The default value for this option is auto, which tries every audio output in preference order with the default device. To list audio devices in mpv.net use the context menu:\nView > More > Show Audio Devices.
name = slang
file = mpv
@@ -530,6 +896,14 @@ help = Show window with decoration (titlebar, border).
option = yes
option = no
name = title-bar
file = mpv
default = yes
directory = Window
help = Set this to no in order to hide the window title bar.
option = yes
option = no
name = screen
file = mpv
directory = Window
@@ -754,9 +1128,8 @@ url = https://mpv.io/manual/master/#options-input-ipc-server
name = language
file = mpvnet
default = system
directory = UI
help = User interface display language.\nmpv.net must be restarted after a change.\nInterested joining our translation team?:
url = https://app.transifex.com/stax76/teams/
directory = Appearance
help = User interface display language.\nmpv.net must be restarted after a change.
option = system
option = english
option = chinese-china
@@ -765,7 +1138,7 @@ option = german
name = dark-mode
file = mpvnet
default = always
directory = UI
directory = Appearance
help = Changes between a light and dark theme.\nmpv.net must be restarted after a change.\nmpv.net specific option.
option = always
option = system Available on Windows 10 or higher
@@ -773,13 +1146,13 @@ option = never
name = dark-theme
file = mpvnet
directory = UI
directory = Appearance
url = https://github.com/mpvnet-player/mpv.net/blob/main/docs/manual.md#color-theme
help = Color theme used in dark mode.\nmpv.net must be restarted after a change.\nmpv.net specific option. Default: dark
name = light-theme
file = mpvnet
directory = UI
directory = Appearance
url = https://github.com/mpvnet-player/mpv.net/blob/main/docs/manual.md#color-theme
help = Color theme used in light mode.\nmpv.net must be restarted after a change.\nmpv.net specific option. Default: light

View File

@@ -40,7 +40,7 @@
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
@@ -48,6 +48,7 @@
x:Name="SearchControl"
HintText="Find a setting (Ctrl+F)"
Margin="20,20,0,10"
MaxWidth="190"
Text="{Binding SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
/>

View File

@@ -20,13 +20,16 @@ namespace MpvNet.Windows.WPF;
public partial class ConfWindow : Window, INotifyPropertyChanged
{
List<Setting> Settings = Conf.LoadConf(Properties.Resources.editor_conf.TrimEnd());
List<ConfItem> ConfItems = new List<ConfItem>();
public ObservableCollection<string> FilterStrings { get; } = new();
string InitialContent;
string ThemeConf = GetThemeConf();
List<Setting> _settings = Conf.LoadConf(Properties.Resources.editor_conf.TrimEnd());
List<ConfItem> _confItems = new List<ConfItem>();
string _initialContent;
string _themeConf = GetThemeConf();
string? _searchText;
List<NodeViewModel>? _nodes;
bool _shown;
int _useSpace;
int _useNoSpace;
public event PropertyChangedEventHandler? PropertyChanged;
public ConfWindow()
@@ -37,7 +40,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
LoadConf(App.ConfPath);
LoadLibplaceboConf();
LoadSettings();
InitialContent = GetCompareString();
_initialContent = GetCompareString();
if (string.IsNullOrEmpty(App.Settings.ConfigEditorSearch))
SearchText = "General:";
@@ -51,6 +54,8 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
node.IsExpanded = true;
}
public ObservableCollection<string> FilterStrings { get; } = new();
public Theme? Theme => Theme.Current;
public string SearchText
@@ -72,7 +77,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
{
var rootNode = new TreeNode();
foreach (Setting setting in Settings)
foreach (Setting setting in _settings)
AddNode(rootNode.Children, setting.Directory!);
_nodes = new NodeViewModel(rootNode).Children;
@@ -125,14 +130,14 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
void LoadSettings()
{
foreach (Setting setting in Settings)
foreach (Setting setting in _settings)
{
setting.StartValue = setting.Value;
if (!FilterStrings.Contains(setting.Directory!))
FilterStrings.Add(setting.Directory!);
foreach (ConfItem item in ConfItems)
foreach (ConfItem item in _confItems)
{
if (setting.Name == item.Name &&
setting.File == item.File &&
@@ -162,65 +167,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
static string GetThemeConf() => Theme.DarkMode + App.DarkTheme + App.LightTheme;
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
App.Settings.ConfigEditorSearch = SearchText;
if (InitialContent == GetCompareString())
return;
foreach (Setting setting in Settings)
{
if (setting.Name == "libplacebo-opts")
{
setting.Value = GetKeyValueContent("libplacebo");
break;
}
}
File.WriteAllText(Player.ConfPath, GetContent("mpv"));
File.WriteAllText(App.ConfPath, GetContent("mpvnet"));
foreach (Setting it in Settings)
{
if (it.Value != it.StartValue)
{
if (it.File == "mpv")
{
Player.ProcessProperty(it.Name, it.Value);
Player.SetPropertyString(it.Name!, it.Value!);
}
else if (it.File == "mpvnet")
App.ProcessProperty(it.Name ?? "", it.Value ?? "", true);
}
}
Theme.Init();
Theme.UpdateWpfColors();
if (ThemeConf != GetThemeConf())
MessageBox.Show("Changed theme settings require mpv.net being restarted.", "Info");
}
bool _shown;
protected override void OnContentRendered(EventArgs e)
{
base.OnContentRendered(e);
if (_shown)
return;
_shown = true;
Application.Current.Dispatcher.BeginInvoke(() => {
SearchControl.SearchTextBox.SelectAll();
},
DispatcherPriority.Background);
}
string GetCompareString() => string.Join("", Settings.Select(item => item.Name + item.Value).ToArray());
string GetCompareString() => string.Join("", _settings.Select(item => item.Name + item.Value).ToArray());
void LoadConf(string file)
{
@@ -232,9 +179,12 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
bool isSectionItem = false;
foreach (string currentLine in File.ReadAllLines(file))
foreach (string it in File.ReadAllLines(file))
{
string line = currentLine.Trim();
string line = it.Trim();
if (line.StartsWith("-"))
line = line.TrimStart('-');
if (line == "")
comment += "\r\n";
@@ -243,7 +193,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
else if (line.StartsWith("[") && line.Contains(']'))
{
if (!isSectionItem && comment != "" && comment != "\r\n")
ConfItems.Add(new ConfItem() {
_confItems.Add(new ConfItem() {
Comment = comment, File = Path.GetFileNameWithoutExtension(file)});
section = line.Substring(0, line.IndexOf("]") + 1);
@@ -253,7 +203,20 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
else if (line.Contains('=') || Regex.Match(line, "^[\\w-]+$").Success)
{
if (!line.Contains('='))
line += "=yes";
{
if (line.StartsWith("no-"))
{
line = line.Substring(3);
line += "=no";
}
else
line += "=yes";
}
if (line.Contains(" =") || line.Contains("= "))
_useSpace += 1;
else
_useNoSpace += 1;
ConfItem item = new();
item.File = Path.GetFileNameWithoutExtension(file);
@@ -263,7 +226,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
item.Section = section;
section = "";
if (line.Contains('#') && !line.Contains("'") && !line.Contains("\""))
if (line.Contains('#') && !line.Contains('\'') && !line.Contains('"'))
{
item.LineComment = line.Substring(line.IndexOf("#")).Trim();
line = line.Substring(0, line.IndexOf("#")).Trim();
@@ -287,7 +250,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
item.Name = left;
item.Value = right;
ConfItems.Add(item);
_confItems.Add(item);
}
}
}
@@ -296,7 +259,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
{
List<string> pairs = new();
foreach (Setting setting in Settings)
foreach (Setting setting in _settings)
{
if (filename != setting.File)
continue;
@@ -310,7 +273,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
void LoadLibplaceboConf()
{
foreach (ConfItem item in ConfItems.ToArray())
foreach (ConfItem item in _confItems.ToArray())
if (item.Name == "libplacebo-opts")
LoadKeyValueList(item.Value, "libplacebo");
}
@@ -332,7 +295,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
item.Name = left;
item.Value = right;
item.File = file;
ConfItems.Add(item);
_confItems.Add(item);
}
}
@@ -357,8 +320,9 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
{
StringBuilder sb = new StringBuilder();
List<string> namesWritten = new List<string>();
string equalString = _useSpace > _useNoSpace ? " = " : "=";
foreach (ConfItem item in ConfItems)
foreach (ConfItem item in _confItems)
{
if (filename != item.File || item.Section != "" || item.IsSectionItem)
continue;
@@ -370,7 +334,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
{
if (item.Name != "")
{
sb.Append(item.Name + " = " + EscapeValue(item.Value));
sb.Append(item.Name + equalString + EscapeValue(item.Value));
if (item.LineComment != "")
sb.Append(" " + item.LineComment);
@@ -381,7 +345,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
}
else if ((item.SettingBase.Value ?? "") != item.SettingBase.Default)
{
sb.Append(item.Name + " = " + EscapeValue(item.SettingBase.Value!));
sb.Append(item.Name + equalString + EscapeValue(item.SettingBase.Value!));
if (item.LineComment != "")
sb.Append(" " + item.LineComment);
@@ -391,16 +355,16 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
}
}
foreach (Setting setting in Settings)
foreach (Setting setting in _settings)
{
if (filename != setting.File || namesWritten.Contains(setting.Name!))
continue;
if ((setting.Value ?? "") != setting.Default)
sb.AppendLine(setting.Name + " = " + EscapeValue(setting.Value!));
sb.AppendLine(setting.Name + equalString + EscapeValue(setting.Value!));
}
foreach (ConfItem item in ConfItems)
foreach (ConfItem item in _confItems)
{
if (filename != item.File || (item.Section == "" && !item.IsSectionItem))
continue;
@@ -416,7 +380,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
if (item.Comment != "")
sb.Append(item.Comment);
sb.Append(item.Name + " = " + EscapeValue(item.Value));
sb.Append(item.Name + equalString + EscapeValue(item.Value));
if (item.LineComment != "")
sb.Append(" " + item.LineComment);
@@ -466,6 +430,47 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
i.Update();
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
App.Settings.ConfigEditorSearch = SearchText;
if (_initialContent == GetCompareString())
return;
foreach (Setting setting in _settings)
{
if (setting.Name == "libplacebo-opts")
{
setting.Value = GetKeyValueContent("libplacebo");
break;
}
}
File.WriteAllText(Player.ConfPath, GetContent("mpv"));
File.WriteAllText(App.ConfPath, GetContent("mpvnet"));
foreach (Setting it in _settings)
{
if (it.Value != it.StartValue)
{
if (it.File == "mpv")
{
Player.ProcessProperty(it.Name, it.Value);
Player.SetPropertyString(it.Name!, it.Value!);
}
else if (it.File == "mpvnet")
App.ProcessProperty(it.Name ?? "", it.Value ?? "", true);
}
}
Theme.Init();
Theme.UpdateWpfColors();
if (_themeConf != GetThemeConf())
MessageBox.Show("Changed theme settings require mpv.net being restarted.", "Info");
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
@@ -480,9 +485,22 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
}
}
protected void OnPropertyChanged([CallerMemberName] string? name = null)
{
protected void OnPropertyChanged([CallerMemberName] string? name = null) =>
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
protected override void OnContentRendered(EventArgs e)
{
base.OnContentRendered(e);
if (_shown)
return;
_shown = true;
Application.Current.Dispatcher.BeginInvoke(() => {
SearchControl.SearchTextBox.SelectAll();
},
DispatcherPriority.Background);
}
void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)

View File

@@ -92,7 +92,6 @@ public partial class CommandPaletteControl : UserControl
if (item.Binding != null)
{
// TODO: CommandItem.Alias
//if (item.CommandItem.Alias.ContainsEx(filter))
// return true;

View File

@@ -24,7 +24,7 @@
Name="SearchTextBox"
Height="25"
BorderThickness="2"
Padding="2"
Padding="2,2,20,2"
Background="Transparent"
Foreground="{Binding Theme.Foreground}"
CaretBrush="{Binding Theme.Foreground}"

View File

@@ -39,10 +39,16 @@ public partial class SearchControl : UserControl
{
HintTextBlock.Text = string.IsNullOrEmpty(Text) ? HintText : "";
if (string.IsNullOrEmpty(Text) || HideClearButton || Text.Length > 21)
if (string.IsNullOrEmpty(Text) || HideClearButton || Text.Length > 30)
{
SearchTextBox.Padding = new Thickness(2);
SearchClearButton.Visibility = Visibility.Hidden;
}
else
{
SearchTextBox.Padding = new Thickness(2, 2, 20, 2);
SearchClearButton.Visibility = Visibility.Visible;
}
}
public string Text

View File

@@ -33,6 +33,9 @@ public partial class StringSettingControl : UserControl, ISettingControl
if (string.IsNullOrEmpty(stringSetting.URL))
LinkTextBlock.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(stringSetting.Help))
HelpTextBox.Visibility = Visibility.Collapsed;
}
public Theme? Theme => Theme.Current;

View File

@@ -5,7 +5,7 @@ using System.Windows;
namespace HandyControl.Tools.Interop
{
internal class InteropValues
public class InteropValues
{
internal static class ExternDll
{
@@ -290,7 +290,7 @@ namespace HandyControl.Tools.Interop
}
[StructLayout(LayoutKind.Sequential)]
internal class WINDOWPOS
public class WINDOWPOS
{
public IntPtr hwnd;
public IntPtr hwndInsertAfter;

View File

@@ -7,6 +7,8 @@ namespace MpvNet.Windows.WPF;
public class WpfTranslator : ITranslator
{
string _localizerLangauge = "";
static Language[] Languages { get; } = new Language[] {
new("english", "en", "en"),
new("chinese-china", "zh-CN", "zh"), // Chinese (Simplified)
@@ -21,8 +23,11 @@ public class WpfTranslator : ITranslator
void InitNGettextWpf()
{
if (Translation.Localizer == null)
if (Translation.Localizer == null || _localizerLangauge != App.Language)
{
CompositionRoot.Compose("mpvnet", GetCulture(App.Language), Folder.Startup + "Locale");
_localizerLangauge = App.Language;
}
}
string GetSystemLanguage()

View File

@@ -14,12 +14,13 @@ using MpvNet.Help;
using MpvNet.ExtensionMethod;
using MpvNet.MVVM;
using MpvNet.Windows.WPF.MsgBox;
using MpvNet.Windows.Help;
using WpfControls = System.Windows.Controls;
using CommunityToolkit.Mvvm.Messaging;
using static MpvNet.Windows.Native.WinApi;
using MpvNet.Windows.Help;
using static MpvNet.Windows.Help.WinApiHelp;
namespace MpvNet.Windows.WinForms;
@@ -43,13 +44,13 @@ public partial class MainForm : Form
bool _contextMenuIsReady;
bool _wasMaximized;
bool _maxSizeSet;
public MainForm()
{
InitializeComponent();
if (Environment.OSVersion.Version >= new Version(10, 0, 18985) && Theme.DarkMode)
DwmSetWindowAttribute(Handle, 20, new[] { 1 }, 4); // DWMWA_USE_IMMERSIVE_DARK_MODE = 20
UpdateDarkMode();
try
{
@@ -125,6 +126,12 @@ public partial class MainForm : Form
}
}
void UpdateDarkMode()
{
if (Environment.OSVersion.Version >= new Version(10, 0, 18985))
DwmSetWindowAttribute(Handle, 20, new[] { Theme.DarkMode ? 1 : 0 }, 4); // DWMWA_USE_IMMERSIVE_DARK_MODE = 20
}
void Player_ClientMessage(string[] args)
{
if (Command.Current.Commands.ContainsKey(args[0]))
@@ -151,6 +158,7 @@ public partial class MainForm : Form
Player.ObservePropertyBool("fullscreen", PropChangeFullscreen);
Player.ObservePropertyBool("keepaspect-window", value => Player.KeepaspectWindow = value);
Player.ObservePropertyBool("ontop", PropChangeOnTop);
Player.ObservePropertyBool("title-bar", PropChangeTitleBar);
Player.ObservePropertyString("sid", PropChangeSid);
Player.ObservePropertyString("aid", PropChangeAid);
@@ -174,13 +182,13 @@ public partial class MainForm : Form
BeginInvoke(() => {
SetSize(
(int)(Player.VideoSize.Width * scale),
(int)Math.Ceiling(Player.VideoSize.Height * scale),
(int)Math.Floor(Player.VideoSize.Height * scale),
Screen.FromControl(this), false);
});
}
void Player_Shutdown() => BeginInvoke(Close);
void Player_VideoSizeChanged(Size value) => BeginInvoke(() =>
{
if (!KeepSize())
@@ -200,7 +208,7 @@ public partial class MainForm : Form
else
{
w = (int)(ClientSize.Width * scale);
h = (int)Math.Ceiling(w * Player.VideoSize.Height / (double)Player.VideoSize.Width);
h = (int)Math.Floor(w * Player.VideoSize.Height / (double)Player.VideoSize.Width);
}
SetSize(w, h, Screen.FromControl(this), false);
@@ -211,7 +219,7 @@ public partial class MainForm : Form
{
BeginInvoke(() => {
Screen screen = Screen.FromControl(this);
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
switch (direction)
{
@@ -240,7 +248,7 @@ public partial class MainForm : Form
BeginInvoke(() => {
SetSize(
(int)(Player.VideoSize.Width * scale),
(int)Math.Ceiling(Player.VideoSize.Height * scale),
(int)Math.Floor(Player.VideoSize.Height * scale),
Screen.FromControl(this), false);
Player.Command($"show-text \"window-scale {scale.ToString(CultureInfo.InvariantCulture)}\"");
});
@@ -522,7 +530,7 @@ public partial class MainForm : Form
}
Screen screen = Screen.FromControl(this);
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
int autoFitHeight = Convert.ToInt32(workingArea.Height * Player.Autofit);
if (App.AutofitAudio > 1)
@@ -565,12 +573,12 @@ public partial class MainForm : Form
else if (App.StartSize == "height-always" || App.StartSize == "height-session")
{
height = ClientSize.Height;
width = height * videoSize.Width / videoSize.Height;
width = (int)Math.Ceiling(height * videoSize.Width / (double)videoSize.Height);
}
else if (App.StartSize == "width-always" || App.StartSize == "width-session")
{
width = ClientSize.Width;
height = (int)Math.Ceiling(width * videoSize.Height / (double)videoSize.Width);
height = (int)Math.Floor(width * videoSize.Height / (double)videoSize.Width);
}
}
else
@@ -580,22 +588,22 @@ public partial class MainForm : Form
if (App.StartSize == "height-always" && windowSize.Height != 0)
{
height = windowSize.Height;
width = height * videoSize.Width / videoSize.Height;
width = (int)Math.Ceiling(height * videoSize.Width / (double)videoSize.Height);
}
else if (App.StartSize == "height-session" || App.StartSize == "session")
{
height = autoFitHeight;
width = height * videoSize.Width / videoSize.Height;
width = (int)Math.Ceiling(height * videoSize.Width / (double)videoSize.Height);
}
else if(App.StartSize == "width-always" && windowSize.Height != 0)
{
width = windowSize.Width;
height = (int)Math.Ceiling(width * videoSize.Height / (double)videoSize.Width);
height = (int)Math.Floor(width * videoSize.Height / (double)videoSize.Width);
}
else if (App.StartSize == "width-session")
{
width = autoFitHeight / 9 * 16;
height = (int)Math.Ceiling(width * videoSize.Height / (double)videoSize.Width);
height = (int)Math.Floor(width * videoSize.Height / (double)videoSize.Width);
}
else if (App.StartSize == "always" && windowSize.Height != 0)
{
@@ -611,7 +619,7 @@ public partial class MainForm : Form
void SetSize(int width, int height, Screen screen, bool checkAutofit = true, bool load = false)
{
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
int maxHeight = workingArea.Height - (Height - ClientSize.Height) - 2;
int maxWidth = workingArea.Width - (Width - ClientSize.Width);
@@ -623,38 +631,39 @@ public partial class MainForm : Form
{
if (height < maxHeight * Player.AutofitSmaller)
{
height = Convert.ToInt32(maxHeight * Player.AutofitSmaller);
width = Convert.ToInt32(height * startWidth / (double)startHeight);
height = (int)(maxHeight * Player.AutofitSmaller);
width = (int)Math.Ceiling(height * startWidth / (double)startHeight);
}
if (height > maxHeight * Player.AutofitLarger)
{
height = Convert.ToInt32(maxHeight * Player.AutofitLarger);
width = Convert.ToInt32(height * startWidth / (double)startHeight);
height = (int)(maxHeight * Player.AutofitLarger);
width = (int)Math.Ceiling(height * startWidth / (double)startHeight);
}
}
if (width > maxWidth)
{
width = maxWidth;
height = (int)Math.Ceiling(width * startHeight / (double)startWidth);
height = (int)Math.Floor(width * startHeight / (double)startWidth);
}
if (height > maxHeight)
{
height = maxHeight;
width = Convert.ToInt32(height * startWidth / (double)startHeight);
width = (int)Math.Ceiling(height * startWidth / (double)startHeight);
}
if (height < maxHeight * 0.1)
{
height = Convert.ToInt32(maxHeight * 0.1);
width = Convert.ToInt32(height * startWidth / (double)startHeight);
height = (int)(maxHeight * 0.1);
width = (int)Math.Ceiling(height * startWidth / (double)startHeight);
}
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
var rect = new Rect(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
WinApiHelp.AddWindowBorders(Handle, ref rect, GetDpi(Handle));
var rect = new RECT(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
AddWindowBorders(Handle, ref rect, GetDpi(Handle), !Player.TitleBar);
width = rect.Width;
height = rect.Height;
@@ -672,16 +681,16 @@ public partial class MainForm : Form
Screen[] screens = Screen.AllScreens;
int minLeft = screens.Select(val => WinApiHelp.GetWorkingArea(Handle, val.WorkingArea).X).Min();
int maxRight = screens.Select(val => WinApiHelp.GetWorkingArea(Handle, val.WorkingArea).Right).Max();
int minTop = screens.Select(val => WinApiHelp.GetWorkingArea(Handle, val.WorkingArea).Y).Min();
int maxBottom = screens.Select(val => WinApiHelp.GetWorkingArea(Handle, val.WorkingArea).Bottom).Max();
int minLeft = screens.Select(val => GetWorkingArea(Handle, val.WorkingArea).X).Min();
int maxRight = screens.Select(val => GetWorkingArea(Handle, val.WorkingArea).Right).Max();
int minTop = screens.Select(val => GetWorkingArea(Handle, val.WorkingArea).Y).Min();
int maxBottom = screens.Select(val => GetWorkingArea(Handle, val.WorkingArea).Bottom).Max();
if (load && CommandLine.Contains("geometry"))
{
string geometryString = CommandLine.GetValue("geometry");
var geometry = ParseGeometry(geometryString, WinApiHelp.GetWorkingArea(
var geometry = ParseGeometry(geometryString, GetWorkingArea(
Handle, Screen.FromHandle(Handle).WorkingArea), width, height);
if (geometry.x != int.MaxValue)
@@ -771,7 +780,7 @@ public partial class MainForm : Form
public int GetHorizontalLocation(Screen screen)
{
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
Rectangle rect = new Rectangle(Left - workingArea.X, Top - workingArea.Y, Width, Height);
if (workingArea.Width / (float)Width < 1.1)
@@ -788,7 +797,7 @@ public partial class MainForm : Form
public int GetVerticalLocation(Screen screen)
{
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
Rectangle rect = new Rectangle(Left - workingArea.X, Top - workingArea.Y, Width, Height);
if (workingArea.Height / (float)Height < 1.1)
@@ -1007,6 +1016,9 @@ public partial class MainForm : Form
m.Result = SendMessage(MpvWindowHandle, m.Msg, m.WParam, m.LParam);
}
break;
case 0x001A: // WM_SETTINGCHANGE
UpdateDarkMode();
break;
case 0x51: // WM_INPUTLANGCHANGE
ActivateKeyboardLayout(m.LParam, 0x00000100u /*KLF_SETFORPROCESS*/);
break;
@@ -1046,16 +1058,45 @@ public partial class MainForm : Form
if (!WasShown)
break;
Rect rect = Marshal.PtrToStructure<Rect>(m.LParam);
RECT rect = Marshal.PtrToStructure<RECT>(m.LParam);
SetWindowPos(Handle, IntPtr.Zero, rect.Left, rect.Top, rect.Width, rect.Height, 0);
}
break;
case 0x0112: // WM_SYSCOMMAND
{
// with title-bar=no when the window is restored from minimizing the height is too high
if (!Player.TitleBar)
{
int SC_MINIMIZE = 0xF020;
if (m.WParam == (nint)SC_MINIMIZE)
{
MaximumSize = Size;
_maxSizeSet = true;
}
}
}
break;
case 0x0083: // WM_NCCALCSIZE
if ((int)m.WParam == 1 && !Player.TitleBar && !IsFullscreen)
{
var nccalcsize_params = Marshal.PtrToStructure<NCCALCSIZE_PARAMS>(m.LParam);
RECT[] rects = nccalcsize_params.rgrc;
rects[0].Top = rects[0].Top - GetTitleBarHeight(Handle, GetDpi(Handle));
Marshal.StructureToPtr(nccalcsize_params, m.LParam, false);
}
break;
case 0x231: // WM_ENTERSIZEMOVE
case 0x005: // WM_SIZE
if (Player.SnapWindow)
SnapManager.OnSizeAndEnterSizeMove(this);
break;
case 0x214: // WM_SIZING
if (Player.KeepaspectWindow)
{
Rect rc = Marshal.PtrToStructure<Rect>(m.LParam);
Rect r = rc;
WinApiHelp.SubtractWindowBorders(Handle, ref r, GetDpi(Handle));
RECT rc = Marshal.PtrToStructure<RECT>(m.LParam);
RECT r = rc;
SubtractWindowBorders(Handle, ref r, GetDpi(Handle), !Player.TitleBar);
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
Size videoSize = Player.VideoSize;
@@ -1063,48 +1104,25 @@ public partial class MainForm : Form
if (videoSize == Size.Empty)
videoSize = new Size(16, 9);
float aspect = videoSize.Width / (float)videoSize.Height;
int d_w = (int)(c_h * aspect - c_w);
int d_h = (int)(c_w / aspect - c_h);
double aspect = videoSize.Width / (double)videoSize.Height;
int d_w = (int)Math.Ceiling(c_h * aspect - c_w);
int d_h = (int)Math.Floor(c_w / aspect - c_h);
int[] d_corners = { d_w, d_h, -d_w, -d_h };
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
int corner = WinApiHelp.GetResizeBorder(m.WParam.ToInt32());
int corner = GetResizeBorder(m.WParam.ToInt32());
if (corner >= 0)
corners[corner] -= d_corners[corner];
Marshal.StructureToPtr(new Rect(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
Marshal.StructureToPtr(new RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
m.Result = new IntPtr(1);
}
return;
case 0x4A: // WM_COPYDATA
{
var copyData = (CopyDataStruct)m.GetLParam(typeof(CopyDataStruct))!;
string[] args = copyData.lpData.Split('\n');
string mode = args[0];
args = args.Skip(1).ToArray();
switch (mode)
{
case "single":
Player.LoadFiles(args, true, false);
break;
case "queue":
foreach (string file in args)
Player.CommandV("loadfile", file, "append");
break;
case "command":
Player.Command(args[0]);
break;
}
Activate();
}
return;
case 0x84: // WM_NCHITTEST
// resize borderless window
if (!Player.Border && !Player.Fullscreen) {
if ((!Player.Border || !Player.TitleBar) && !Player.Fullscreen)
{
const int HTCLIENT = 1;
const int HTLEFT = 10;
const int HTRIGHT = 11;
@@ -1143,11 +1161,30 @@ public partial class MainForm : Form
return;
}
break;
case 0x231: // WM_ENTERSIZEMOVE
case 0x005: // WM_SIZE
if (Player.SnapWindow)
SnapManager.OnSizeAndEnterSizeMove(this);
break;
case 0x4A: // WM_COPYDATA
{
var copyData = (CopyDataStruct)m.GetLParam(typeof(CopyDataStruct))!;
string[] args = copyData.lpData.Split('\n');
string mode = args[0];
args = args.Skip(1).ToArray();
switch (mode)
{
case "single":
Player.LoadFiles(args, true, false);
break;
case "queue":
foreach (string file in args)
Player.CommandV("loadfile", file, "append");
break;
case "command":
Player.Command(args[0]);
break;
}
Activate();
}
return;
case 0x216: // WM_MOVING
if (Player.SnapWindow)
SnapManager.OnMoving(ref m);
@@ -1165,6 +1202,25 @@ public partial class MainForm : Form
base.WndProc(ref m);
}
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
if (_maxSizeSet)
{
TaskHelp.Run(() => {
Thread.Sleep(200);
BeginInvoke(() => {
if (!IsDisposed && !Disposing)
{
MaximumSize = new Size(int.MaxValue, int.MaxValue);
_maxSizeSet = false;
}
});
});
}
}
void CursorTimer_Tick(object sender, EventArgs e)
{
if (IsCursorPosDifferent(_lastCursorPosition))
@@ -1248,6 +1304,20 @@ public partial class MainForm : Form
});
}
void PropChangeTitleBar(bool enabled)
{
if (enabled == Player.TitleBar)
return;
Player.TitleBar = enabled;
BeginInvoke(() => {
SetSize(ClientSize.Width, ClientSize.Height, Screen.FromControl(this), false);
Height += 1;
Height -= 1;
});
}
void Player_Pause()
{
if (_taskbar != null && Player.TaskbarProgress)
@@ -1282,14 +1352,8 @@ public partial class MainForm : Form
InitAndBuildContextMenu();
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
GlobalHotkey.RegisterGlobalHotkeys(Handle);
WasShown = true;
StrongReferenceMessenger.Default.Send(new MainWindowIsLoadedMessage());
TaskHelp.Run(() => {
System.Windows.Application.Current.Dispatcher.BeginInvoke(() => {
WinMpvHelp.Setup();
}, DispatcherPriority.Background);
});
WasShown = true;
}
void ContextMenu_Closed(object sender, System.Windows.RoutedEventArgs e) => MenuAutoResetEvent.Set();
@@ -1378,10 +1442,12 @@ public partial class MainForm : Form
{
base.OnDragDrop(e);
bool append = ModifierKeys == Keys.Shift;
if (e.Data!.GetDataPresent(DataFormats.FileDrop))
Player.LoadFiles(e.Data.GetData(DataFormats.FileDrop) as string[], true, false);
Player.LoadFiles(e.Data.GetData(DataFormats.FileDrop) as string[], true, append);
else if (e.Data.GetDataPresent(DataFormats.Text))
Player.LoadFiles(new[] { e.Data.GetData(DataFormats.Text)!.ToString()! }, true, false);
Player.LoadFiles(new[] { e.Data.GetData(DataFormats.Text)!.ToString()! }, true, append);
}
protected override void OnKeyDown(KeyEventArgs e)
@@ -1421,7 +1487,7 @@ public partial class MainForm : Form
public static int GetDpi(IntPtr hwnd)
{
if (Environment.OSVersion.Version >= WinApiHelp.WindowsTen1607 && hwnd != IntPtr.Zero)
if (Environment.OSVersion.Version >= WindowsTen1607 && hwnd != IntPtr.Zero)
return GetDpiForWindow(hwnd);
else
using (Graphics gx = Graphics.FromHwnd(hwnd))

View File

@@ -51,7 +51,7 @@ public class SnapManager
if (Handle == IntPtr.Zero)
return;
WinApi.Rect boundsLtrb = Marshal.PtrToStructure<WinApi.Rect>(m.LParam);
WinApi.RECT boundsLtrb = Marshal.PtrToStructure<WinApi.RECT>(m.LParam);
Rectangle bounds = boundsLtrb.ToRectangle();
// This is where the window _would_ be located if snapping
// had not occurred. This prevents the cursor from sliding
@@ -62,7 +62,7 @@ public class SnapManager
bounds.Width,
bounds.Height);
FindSnap(ref effectiveBounds);
WinApi.Rect newLtrb = WinApi.Rect.FromRectangle(effectiveBounds);
WinApi.RECT newLtrb = WinApi.RECT.FromRectangle(effectiveBounds);
Marshal.StructureToPtr(newLtrb, m.LParam, false);
m.Result = new IntPtr(1);
}

View File

@@ -79,7 +79,7 @@ public class AppClass
public static string About => "Copyright (C) 2000-2023 mpv.net/mpv/mplayer\n" +
$"{AppInfo.Product} {AppInfo.Version}" + GetLastWriteTime(Environment.ProcessPath!) + "\n" +
$"{Player.GetPropertyString("mpv-version")}" + GetLastWriteTime(Folder.Startup + "libmpv-2.dll") + "\n" +
$"ffmpeg {Player.GetPropertyString("ffmpeg-version")}\n" + "\nGPL v2 License";
$"ffmpeg {Player.GetPropertyString("ffmpeg-version")}\n" + "GPL v2 License";
static string GetLastWriteTime(string path)
{

View File

@@ -1,7 +1,5 @@

using System.Globalization;
using System.Text;
using System.Text.Json;
using MpvNet.Help;
namespace MpvNet;
@@ -26,13 +24,13 @@ public class Command
// deprecated
["playlist-add"] = args => PlaylistAdd(Convert.ToInt32(args[0])), // deprecated
["show-progress"] = args => ShowProgress(), // deprecated
["show-progress"] = args => Player.Command("show-progress"), // deprecated
["playlist-random"] = args => PlaylistRandom(), // deprecated
};
public string FormatTime(double value) => ((int)value).ToString("00");
string FormatTime(double value) => ((int)value).ToString("00");
public static void PlayPause(IList<string> args)
void PlayPause(IList<string> args)
{
int count = Player.GetPropertyInt("playlist-count");
@@ -66,7 +64,7 @@ public class Command
"}${osd-ass-cc/1}" + text + "\" " + duration);
}
public static void CycleAudio()
void CycleAudio()
{
Player.UpdateExternalTracks();
@@ -94,7 +92,7 @@ public class Command
}
}
public static void CycleSubtitles()
void CycleSubtitles()
{
Player.UpdateExternalTracks();
@@ -126,7 +124,7 @@ public class Command
}
// deprecated
public static void PlaylistAdd(int value)
void PlaylistAdd(int value)
{
int pos = Player.PlaylistPos;
int count = Player.GetPropertyInt("playlist-count");
@@ -145,13 +143,13 @@ public class Command
Player.SetPropertyInt("playlist-pos", pos);
}
public static void PlaylistFirst()
void PlaylistFirst()
{
if (Player.PlaylistPos != 0)
Player.SetPropertyInt("playlist-pos", 0);
}
public static void PlaylistLast()
void PlaylistLast()
{
int count = Player.GetPropertyInt("playlist-count");
@@ -160,14 +158,14 @@ public class Command
}
// deprecated
public static void PlaylistRandom()
void PlaylistRandom()
{
int count = Player.GetPropertyInt("playlist-count");
Player.SetPropertyInt("playlist-pos", new Random().Next(count));
}
// deprecated
public void ShowProgress()
void ShowProgress()
{
TimeSpan position = TimeSpan.FromSeconds(Player.GetPropertyDouble("time-pos"));
TimeSpan duration = TimeSpan.FromSeconds(Player.GetPropertyDouble("duration"));

View File

@@ -1,5 +1,4 @@

using MpvNet.ExtensionMethod;
using MpvNet.Help;
namespace MpvNet;
@@ -15,8 +14,11 @@ public class InputConf
public string Path {
get => _path ?? "";
set {
_path = value;
Content = File.Exists(_path) ? FileHelp.ReadTextFile(_path) : "";
if (_path != value)
{
_path = value;
Content = File.Exists(_path) ? FileHelp.ReadTextFile(_path) : "";
}
}
}
@@ -50,7 +52,29 @@ public class InputConf
public string GetContent()
{
if (HasMenu)
{
try
{
if (App.Settings.MenuUpdateVersion != 1)
{
string updatedContent = UpdateContent(Content);
if (updatedContent != Content)
{
File.Copy(Path, Path + ".backup", true);
File.WriteAllText(Path, Content = updatedContent);
}
App.Settings.MenuUpdateVersion = 1;
}
}
catch (Exception ex)
{
Terminal.WriteError("Failed to update menu." + BR + ex.Message);
}
return Content;
}
else
{
var defaults = InputHelp.GetDefaults();
@@ -73,4 +97,9 @@ public class InputConf
return InputHelp.ConvertToString(defaults);
}
}
static string UpdateContent(string content) => content
.Replace("script-message mpv.net", "script-message-to mpvnet")
.Replace("/docs/Manual.md", "/docs/manual.md")
.Replace("https://github.com/stax76/mpv.net", "https://github.com/mpvnet-player/mpv.net");
}

View File

@@ -17,8 +17,9 @@ public static class InputHelp
new (_("File"), _("Add external subtitle files..."), "script-message-to mpvnet load-sub", "Alt+s"),
new (_("File"), "-"),
new (_("File"), _("Add files to playlist..."), "script-message-to mpvnet open-files append"),
new (_("File"), _("Recent Files")),
new (_("File"), _("Add files/URLs to playlist from clipboard"), "script-message-to mpvnet open-clipboard append", "Ctrl+Shift+v"),
new (_("File"), "-"),
new (_("File"), _("Recent Files")),
new (_("File"), _("Exit"), "quit", "Esc"),
new (_("Playback"), _("Play/Pause"), "script-message-to mpvnet play-pause", "Space"),
@@ -126,6 +127,11 @@ public static class InputHelp
new (_("View") + " > " + _("More"), _("Show Audio Devices"), "script-message-to mpvnet show-audio-devices"),
new (_("View") + " > " + _("More"), _("Show Commands"), "script-message-to mpvnet show-commands", "F2"),
new (_("View") + " > " + _("More"), _("Show Bindings"), "script-message-to mpvnet show-bindings"),
new (_("View") + " > " + _("More"), _("Show Properties"), "script-message-to mpvnet show-properties", "F3"),
new (_("View") + " > " + _("More"), _("Show Keys"), "script-message-to mpvnet show-keys", "Alt+k"),
new (_("View") + " > " + _("More"), _("Show Protocols"), "script-message-to mpvnet show-protocols", "Alt+p"),
new (_("View") + " > " + _("More"), _("Show Decoders"), "script-message-to mpvnet show-decoders", "Alt+d"),
new (_("View") + " > " + _("More"), _("Show Demuxers"), "script-message-to mpvnet show-demuxers"),
new (_("Window"), _("Fullscreen"), "cycle fullscreen", "Enter"),
new (_("Window") + " > " + _("Zoom"), _("Enlarge"), "script-message-to mpvnet scale-window 1.2", "Alt++"),
@@ -284,6 +290,9 @@ public static class InputHelp
if (string.IsNullOrEmpty(content))
return bindings;
if (content.Contains('\t'))
content = content.Replace('\t', ' ');
foreach (string it in content.Split('\n'))
{
string line = it.Trim();
@@ -479,7 +488,7 @@ public static class InputHelp
Binding binding = it.Value;
if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 20 && keys.Count < 2)
if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 15 && keys.Count < 2)
{
keys.Add(binding.Input);
charCount += binding.Input.Length;

View File

@@ -36,6 +36,7 @@ public class MainPlayer : MpvClient
public bool Paused { get; set; }
public bool SnapWindow { get; set; }
public bool TaskbarProgress { get; set; } = true;
public bool TitleBar { get; set; } = true;
public bool WasInitialSizeSet;
public bool WindowMaximized { get; set; }
public bool WindowMinimized { get; set; }
@@ -97,6 +98,7 @@ public class MainPlayer : MpvClient
SetPropertyBool("input-default-bindings", true);
SetPropertyBool("input-builtin-bindings", false);
SetPropertyString("idle", "yes");
SetPropertyString("screenshot-directory", "~~desktop/");
SetPropertyString("osd-playing-msg", "${media-title}");
SetPropertyString("osc", "yes");
@@ -130,10 +132,6 @@ public class MainPlayer : MpvClient
if (err < 0)
throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR);
SetPropertyString("user-data/frontend/name", "mpv.net");
SetPropertyString("user-data/frontend/version", AppInfo.Version.ToString());
SetPropertyString("user-data/frontend/process-path", Environment.ProcessPath!);
string idle = GetPropertyString("idle");
App.Exit = idle == "no" || idle == "once";
@@ -151,6 +149,10 @@ public class MainPlayer : MpvClient
// this means Lua scripts that use idle might not work correctly
SetPropertyString("idle", "yes");
SetPropertyString("user-data/frontend/name", "mpv.net");
SetPropertyString("user-data/frontend/version", AppInfo.Version.ToString());
SetPropertyString("user-data/frontend/process-path", Environment.ProcessPath!);
ObservePropertyBool("pause", value => {
Paused = value;
Pause?.Invoke();
@@ -221,6 +223,7 @@ public class MainPlayer : MpvClient
case "vo": VO = value!; break;
case "window-maximized": WindowMaximized = value == "yes"; break;
case "window-minimized": WindowMinimized = value == "yes"; break;
case "title-bar": TitleBar = value == "yes"; break;
}
if (AutofitLarger > 1)
@@ -417,7 +420,14 @@ public class MainPlayer : MpvClient
{
foreach (var pair in CommandLine.Arguments)
{
if (pair.Name.EndsWith("-add"))
if (pair.Name.EndsWith("-add") ||
pair.Name.EndsWith("-set") ||
pair.Name.EndsWith("-pre") ||
pair.Name.EndsWith("-clr") ||
pair.Name.EndsWith("-append") ||
pair.Name.EndsWith("-remove") ||
pair.Name.EndsWith("-toggle"))
continue;
ProcessProperty(pair.Name, pair.Value);
@@ -432,11 +442,19 @@ public class MainPlayer : MpvClient
foreach (var pair in CommandLine.Arguments)
{
if (pair.Name.EndsWith("-add"))
{
string name = pair.Name[..^4];
string separator = name.Contains("-file") || name.Contains("-path") ? ";" : ",";
SetPropertyString(name, GetPropertyString(name) + separator + pair.Value);
}
CommandV("change-list", pair.Name[..^4], "add", pair.Value);
else if (pair.Name.EndsWith("-set"))
CommandV("change-list", pair.Name[..^4], "set", pair.Value);
else if (pair.Name.EndsWith("-append"))
CommandV("change-list", pair.Name[..^7], "append", pair.Value);
else if (pair.Name.EndsWith("-pre"))
CommandV("change-list", pair.Name[..^4], "pre", pair.Value);
else if (pair.Name.EndsWith("-clr"))
CommandV("change-list", pair.Name[..^4], "clr", "");
else if (pair.Name.EndsWith("-remove"))
CommandV("change-list", pair.Name[..^7], "remove", pair.Value);
else if (pair.Name.EndsWith("-toggle"))
CommandV("change-list", pair.Name[..^7], "toggle", pair.Value);
}
}
@@ -450,7 +468,7 @@ public class MainPlayer : MpvClient
files.Add(arg);
LoadFiles(files.ToArray(), !App.Queue, false || App.Queue);
LoadFiles(files.ToArray(), !App.Queue, App.Queue);
if (App.CommandLine.Contains("--shuffle"))
{

View File

@@ -11,6 +11,7 @@ public class AppSettings
{
public bool InputDefaultBindingsFixApplied;
public bool ShowMenuFixApplied;
public int MenuUpdateVersion;
public int Volume = 70;
public List<string> RecentFiles = new List<string>();
public Point WindowLocation;
@@ -18,6 +19,7 @@ public class AppSettings
public Size WindowSize;
public string ConfigEditorSearch = "Video:";
public string Mute = "no";
public string StartupFolder = "";
}
class SettingsManager

View File

@@ -25,4 +25,4 @@ Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
[Files]
Source: "{#MyAppSourceDir}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppSourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
Source: "{#MyAppSourceDir}\*"; DestDir: "{app}"; Excludes: "win-x64"; Flags: ignoreversion recursesubdirs createallsubdirs;