-
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
###
|
||||
|
||||
- left mouse double click MBTN_LEFT_DBL was not working
|
||||
- remember-height was replaced with start-size, when start-size is set
|
||||
to video the main video starts directly with the native video size,
|
||||
before it was starting with the autofit size first and was only
|
||||
afterwards resized to the native video size
|
||||
|
||||
### 4.6
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace mpvnet
|
||||
public static string[] SubtitleTypes { get; } = "srt ass idx sup ttxt ssa smi".Split(' ');
|
||||
public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" };
|
||||
|
||||
public static bool RememberHeight { get; set; } = true;
|
||||
public static bool DebugMode { get; set; } = false;
|
||||
|
||||
public static bool IsDarkMode {
|
||||
@@ -36,6 +37,9 @@ namespace mpvnet
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
string dummy = mp.ConfFolder;
|
||||
var dummy2 = mp.Conf;
|
||||
|
||||
foreach (var i in Conf)
|
||||
ProcessProperty(i.Key, i.Value);
|
||||
|
||||
@@ -83,6 +87,7 @@ namespace mpvnet
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "start-size": RememberHeight = value == "previous"; break;
|
||||
case "process-instance": ProcessInstance = value; break;
|
||||
case "dark-mode": DarkMode = value; break;
|
||||
case "debug-mode": DebugMode = value == "yes"; break;
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
|
||||
@@ -254,14 +254,6 @@ default = "50%"
|
||||
filter = "Screen"
|
||||
help = "Set the initial window size in percent. Please note that this setting is only partly implemented in mpv.net, accepted are only integer values with percent sign added. Default: 50%"
|
||||
|
||||
[[settings]]
|
||||
name = "remember-height"
|
||||
default = "yes"
|
||||
filter = "Screen"
|
||||
help = "mpv.net specific setting to remember the window height, otherwise the video's native resolution is used."
|
||||
options = [{ name = "yes" },
|
||||
{ name = "no" }]
|
||||
|
||||
[[settings]]
|
||||
name = "keep-open-pause"
|
||||
default = "yes"
|
||||
|
||||
@@ -29,3 +29,11 @@ filter = "General"
|
||||
help = "mpv.net specific setting that writes debug info to a file located on the desktop."
|
||||
options = [{ name = "yes" },
|
||||
{ name = "no" }]
|
||||
|
||||
[[settings]]
|
||||
name = "start-size"
|
||||
default = "previous"
|
||||
filter = "Screen"
|
||||
help = "mpv.net specific setting to remember the window height in the current session, otherwise the video's native resolution is used."
|
||||
options = [{ name = "video", help = "Window size is set to native video resolution" },
|
||||
{ name = "previous", help = "Window size is remembered but only from the current session" }]
|
||||
2
mpv.net/WinForms/MainForm.Designer.cs
generated
2
mpv.net/WinForms/MainForm.Designer.cs
generated
@@ -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(606, 368);
|
||||
this.ClientSize = new System.Drawing.Size(1777, 1109);
|
||||
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);
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -36,7 +37,6 @@ namespace mpvnet
|
||||
WPF.WPF.Init();
|
||||
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
||||
Hwnd = Handle;
|
||||
MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
|
||||
Text += " " + Application.ProductVersion;
|
||||
|
||||
object recent = RegHelp.GetObject(App.RegPath, "Recent");
|
||||
@@ -46,11 +46,31 @@ namespace mpvnet
|
||||
else
|
||||
RecentFiles = new List<string>();
|
||||
|
||||
var dummy = mp.Conf;
|
||||
App.ProcessCommandLineEarly();
|
||||
|
||||
if (mp.Screen == -1) mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
|
||||
SetScreen(mp.Screen);
|
||||
CycleFullscreen(mp.Fullscreen);
|
||||
int targetIndex = mp.Screen;
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
if (targetIndex < 0) targetIndex = 0;
|
||||
if (targetIndex > screens.Length - 1) targetIndex = screens.Length - 1;
|
||||
Screen screen = screens[Array.IndexOf(screens, screens[targetIndex])];
|
||||
Rectangle target = screen.Bounds;
|
||||
Left = target.X + Convert.ToInt32((target.Width - Width) / 2.0);
|
||||
Top = target.Y + Convert.ToInt32((target.Height - Height) / 2.0);
|
||||
|
||||
mp.Shutdown += Shutdown;
|
||||
mp.VideoSizeChanged += VideoSizeChanged;
|
||||
mp.FileLoaded += FileLoaded;
|
||||
mp.Idle += Idle;
|
||||
Task.Run(() => mp.Init());
|
||||
mp.VideoSizeAutoResetEvent.WaitOne(1000);
|
||||
mp.observe_property_bool("fullscreen", PropChangeFullscreen);
|
||||
mp.observe_property_bool("ontop", PropChangeOnTop);
|
||||
mp.observe_property_bool("border", PropChangeBorder);
|
||||
mp.observe_property_string("sid", PropChangeSid);
|
||||
mp.observe_property_string("aid", PropChangeAid);
|
||||
mp.observe_property_string("vid", PropChangeVid);
|
||||
mp.observe_property_int("edition", PropChangeEdition);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -64,7 +84,7 @@ namespace mpvnet
|
||||
|
||||
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
|
||||
|
||||
void VideoSizeChanged() => BeginInvoke(new Action(() => SetFormPosAndSize()));
|
||||
void VideoSizeChanged() => Invoke(new Action(() => SetFormPosAndSize()));
|
||||
|
||||
void Shutdown() => BeginInvoke(new Action(() => Close()));
|
||||
|
||||
@@ -192,40 +212,13 @@ namespace mpvnet
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void SetScreen(int targetIndex)
|
||||
{
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
if (targetIndex < 0) targetIndex = 0;
|
||||
if (targetIndex > screens.Length - 1) targetIndex = screens.Length - 1;
|
||||
SetScreen(screens[Array.IndexOf(screens, screens[targetIndex])]);
|
||||
}
|
||||
|
||||
protected void SetScreen(Screen screen)
|
||||
{
|
||||
Rectangle target = screen.Bounds;
|
||||
Left = target.X + Convert.ToInt32((target.Width - Width) / 2.0);
|
||||
Top = target.Y + Convert.ToInt32((target.Height - Height) / 2.0);
|
||||
SetStartFormPosAndSize();
|
||||
}
|
||||
|
||||
void SetStartFormPosAndSize()
|
||||
{
|
||||
if (IsFullscreen || mp.VideoSize.Width == 0) return;
|
||||
Screen screen = Screen.FromControl(this);
|
||||
int height = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
|
||||
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));
|
||||
NativeHelp.AddWindowBorders(Handle, ref rect);
|
||||
int left = middlePos.X - rect.Width / 2;
|
||||
int top = middlePos.Y - rect.Height / 2;
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||
}
|
||||
|
||||
void SetFormPosAndSize()
|
||||
{
|
||||
if (IsFullscreen)
|
||||
if (mp.Fullscreen)
|
||||
{
|
||||
CycleFullscreen(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Size size = mp.VideoSize;
|
||||
Screen screen = Screen.FromControl(this);
|
||||
@@ -239,7 +232,7 @@ namespace mpvnet
|
||||
|
||||
int height = size.Height;
|
||||
|
||||
if (mp.RememberHeight)
|
||||
if (App.RememberHeight)
|
||||
height = ClientSize.Height;
|
||||
|
||||
if (height > screen.Bounds.Height * 0.9)
|
||||
@@ -251,10 +244,37 @@ namespace mpvnet
|
||||
NativeHelp.AddWindowBorders(Handle, ref rect);
|
||||
int left = middlePos.X - rect.Width / 2;
|
||||
int top = middlePos.Y - rect.Height / 2;
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||
}
|
||||
|
||||
public void CycleFullscreen(bool enabled)
|
||||
{
|
||||
mp.Fullscreen = enabled;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
if (WindowState != FormWindowState.Maximized)
|
||||
{
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WindowState == FormWindowState.Maximized)
|
||||
{
|
||||
WindowState = FormWindowState.Normal;
|
||||
|
||||
if (mp.Border)
|
||||
FormBorderStyle = FormBorderStyle.Sizable;
|
||||
else
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
|
||||
SetFormPosAndSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildMenu()
|
||||
{
|
||||
string content = File.ReadAllText(mp.InputConfPath);
|
||||
@@ -309,29 +329,6 @@ namespace mpvnet
|
||||
Msg.ShowError(e.ExceptionObject.ToString());
|
||||
}
|
||||
|
||||
public void CycleFullscreen(bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
if (WindowState != FormWindowState.Maximized)
|
||||
{
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = FormWindowState.Normal;
|
||||
|
||||
if (mp.Border)
|
||||
FormBorderStyle = FormBorderStyle.Sizable;
|
||||
else
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
|
||||
SetFormPosAndSize();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
//System.Diagnostics.Debug.WriteLine(m);
|
||||
@@ -444,7 +441,7 @@ namespace mpvnet
|
||||
CursorHelp.Hide();
|
||||
}
|
||||
|
||||
void PropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value));
|
||||
void PropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value));
|
||||
|
||||
void PropChangeAid(string value) => mp.Aid = value;
|
||||
|
||||
@@ -468,23 +465,6 @@ namespace mpvnet
|
||||
}));
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
mp.Init();
|
||||
mp.observe_property_bool("fullscreen", PropChangeFullscreen);
|
||||
mp.observe_property_bool("ontop", PropChangeOnTop);
|
||||
mp.observe_property_bool("border", PropChangeBorder);
|
||||
mp.observe_property_string("sid", PropChangeSid);
|
||||
mp.observe_property_string("aid", PropChangeAid);
|
||||
mp.observe_property_string("vid", PropChangeVid);
|
||||
mp.observe_property_int("edition", PropChangeEdition);
|
||||
mp.Shutdown += Shutdown;
|
||||
mp.VideoSizeChanged += VideoSizeChanged;
|
||||
mp.FileLoaded += FileLoaded;
|
||||
mp.Idle += Idle;
|
||||
}
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
@@ -518,7 +498,7 @@ namespace mpvnet
|
||||
RegHelp.SetObject(App.RegPath, "Recent", RecentFiles.ToArray());
|
||||
App.Exit();
|
||||
mp.commandv("quit");
|
||||
mp.AutoResetEvent.WaitOne(3000);
|
||||
mp.ShutdownAutoResetEvent.WaitOne(3000);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
|
||||
@@ -58,9 +58,10 @@ namespace mpvnet
|
||||
public static List<KeyValuePair<string, Action<bool>>> BoolPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<bool>>>();
|
||||
public static List<KeyValuePair<string, Action<int>>> IntPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<int>>>();
|
||||
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>();
|
||||
public static Size VideoSize { get; set; } = new Size(1920, 1080);
|
||||
public static Size VideoSize { get; set; }
|
||||
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
|
||||
public static AutoResetEvent AutoResetEvent { get; set; } = new AutoResetEvent(false);
|
||||
public static AutoResetEvent ShutdownAutoResetEvent { get; set; } = new AutoResetEvent(false);
|
||||
public static AutoResetEvent VideoSizeAutoResetEvent { get; set; } = new AutoResetEvent(false);
|
||||
public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
|
||||
public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
|
||||
|
||||
@@ -72,7 +73,6 @@ namespace mpvnet
|
||||
|
||||
public static bool Fullscreen { get; set; }
|
||||
public static bool Border { get; set; } = true;
|
||||
public static bool RememberHeight { get; set; } = true;
|
||||
|
||||
public static int Screen { get; set; } = -1;
|
||||
public static int Edition { get; set; }
|
||||
@@ -81,7 +81,6 @@ namespace mpvnet
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
string dummy = ConfFolder;
|
||||
LoadLibrary("mpv-1.dll");
|
||||
Handle = mpv_create();
|
||||
set_property_string("osc", "yes");
|
||||
@@ -110,7 +109,6 @@ namespace mpvnet
|
||||
case "fullscreen": Fullscreen = value == "yes"; break;
|
||||
case "border": Border = value == "yes"; break;
|
||||
case "screen": Screen = Convert.ToInt32(value); break;
|
||||
case "remember-height": RememberHeight = value == "yes"; break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +220,7 @@ namespace mpvnet
|
||||
case mpv_event_id.MPV_EVENT_SHUTDOWN:
|
||||
Shutdown?.Invoke();
|
||||
WriteHistory(null);
|
||||
AutoResetEvent.Set();
|
||||
ShutdownAutoResetEvent.Set();
|
||||
return;
|
||||
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
|
||||
LogMessage?.Invoke();
|
||||
@@ -316,6 +314,7 @@ namespace mpvnet
|
||||
if (VideoSize != vidSize && vidSize != Size.Empty)
|
||||
{
|
||||
VideoSize = vidSize;
|
||||
VideoSizeAutoResetEvent.Set();
|
||||
VideoSizeChanged?.Invoke();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user