This commit is contained in:
Frank Skare
2019-03-17 20:56:10 +01:00
parent 91a67c29a7
commit 3fd1285ad8
4 changed files with 29 additions and 24 deletions

View File

@@ -52,7 +52,6 @@
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "mpv.net";
this.Load += new System.EventHandler(this.MainForm_Load);
this.ResumeLayout(false);
}

View File

@@ -4,7 +4,7 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.Diagnostics;
using static mpvnet.StaticUsing;
namespace mpvnet
@@ -16,7 +16,7 @@ namespace mpvnet
private Point LastCursorPosChanged;
private int LastCursorChangedTickCount;
private bool IsCloseRequired = true;
private bool IsClosed;
public ContextMenuStripEx CMS;
@@ -93,7 +93,7 @@ namespace mpvnet
private string LastHistory;
private void mpv_PlaybackRestart()
private void mp_PlaybackRestart()
{
var fn = mp.GetStringProp("filename");
BeginInvoke(new Action(() => { Text = fn + " - mpv.net " + Application.ProductVersion; }));
@@ -121,14 +121,14 @@ namespace mpvnet
MsgError(e.ToString());
}
private void Mpv_VideoSizeChanged()
private void mp_VideoSizeChanged()
{
BeginInvoke(new Action(() => SetFormPosSize()));
}
private void Mpv_AfterShutdown()
private void mp_Shutdown()
{
if (IsCloseRequired)
if (!IsClosed)
Invoke(new Action(() => Close()));
}
@@ -137,7 +137,7 @@ namespace mpvnet
get => WindowState == FormWindowState.Maximized;
}
void MpvChangeFullscreen(bool value)
void mp_ChangeFullscreen(bool value)
{
BeginInvoke(new Action(() => ChangeFullscreen(value)));
}
@@ -263,13 +263,6 @@ namespace mpvnet
CursorHelp.Show();
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
base.OnFormClosed(e);
IsCloseRequired = false;
mp.Command("quit");
}
bool IsMouseInOSC()
{
return PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
@@ -290,13 +283,27 @@ namespace mpvnet
}
}
private void MainForm_Load(object sender, EventArgs ea)
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
mp.Init();
mp.ObserveBoolProp("fullscreen", MpvChangeFullscreen);
mp.Shutdown += Mpv_AfterShutdown;
mp.VideoSizeChanged += Mpv_VideoSizeChanged;
mp.PlaybackRestart += mpv_PlaybackRestart;
mp.ObserveBoolProp("fullscreen", mp_ChangeFullscreen);
mp.Shutdown += mp_Shutdown;
mp.VideoSizeChanged += mp_VideoSizeChanged;
mp.PlaybackRestart += mp_PlaybackRestart;
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
base.OnFormClosed(e);
IsClosed = true;
mp.Command("quit");
for (int i = 0; i < 99; i++)
{
if (mp.IsShutdownComplete) break;
Thread.Sleep(50);
}
}
}
}

View File

@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -61,6 +61,7 @@ namespace mpvnet
public static string InputConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\input.conf";
public static string mpvConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\mpv.conf";
public static List<PyScript> PyScripts { get; } = new List<PyScript>();
public static bool IsShutdownComplete { get; set; }
private static Dictionary<string, string> _mpvConv;
@@ -133,7 +134,6 @@ namespace mpvnet
{
IntPtr ptr = mpv_wait_event(MpvHandle, -1);
mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event));
//Debug.WriteLine(evt.event_id);
if (MpvWindowHandle == IntPtr.Zero)
MpvWindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null);
@@ -142,6 +142,7 @@ namespace mpvnet
{
case mpv_event_id.MPV_EVENT_SHUTDOWN:
Shutdown?.Invoke();
IsShutdownComplete = true;
return;
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
LogMessage?.Invoke();

View File

@@ -3,10 +3,8 @@ $exePath = $scriptDir + "\mpv.net\bin\Debug\mpvnet.exe"
$version = [Diagnostics.FileVersionInfo]::GetVersionInfo($exePath).FileVersion
$desktopDir = [Environment]::GetFolderPath("Desktop")
$targetDir = $desktopDir + "\mpv.net-" + $version
if (Test-Path $targetDir) { rd $targetDir -recurse }
Copy-Item $scriptDir\mpv.net\bin\Debug $targetDir -recurse
$addonDir = $targetDir + "\Addons"
Remove-Item $addonDir -Recurse -Include *mpvnet.exe, *mpvnet.exe.config, *mpvnet.pdb
$7zPath = "C:\Program Files\7-Zip\7z.exe"
$args = "a -t7z -mx9 $targetDir.7z -r $targetDir\*"
Start-Process -FilePath $7zPath -ArgumentList $args