-
This commit is contained in:
@@ -62,12 +62,12 @@ namespace mpvnet
|
||||
|
||||
public static void show_keys(string[] args)
|
||||
{
|
||||
Process.Start(mp.InputConfPath);
|
||||
Process.Start(NativeHelp.GetAssociatedApplication(".txt"), mp.InputConfPath);
|
||||
}
|
||||
|
||||
public static void show_prefs(string[] args)
|
||||
{
|
||||
Process.Start(mp.mpvConfPath);
|
||||
Process.Start(NativeHelp.GetAssociatedApplication(".txt"), mp.mpvConfPath);
|
||||
}
|
||||
|
||||
public static void history(string[] args)
|
||||
@@ -148,7 +148,7 @@ namespace mpvnet
|
||||
bitrate = "0";
|
||||
|
||||
var bitrate2 = Convert.ToDouble(bitrate) / 1000.0 / 1000.0;
|
||||
var format = mp.get_property_string("video-format").ToUpper();
|
||||
var videoCodec = mp.get_property_string("video-format").ToUpper();
|
||||
var filename = fileInfo.Name;
|
||||
|
||||
var text =
|
||||
@@ -157,7 +157,7 @@ namespace mpvnet
|
||||
FormatTime(duration.TotalMinutes) + ":" +
|
||||
FormatTime(duration.Seconds) + "\n" +
|
||||
Convert.ToInt32(fileInfo.Length / 1024 / 1024).ToString() +
|
||||
$" MB - {width} x {height}\n{format} - {bitrate2.ToString("f1")} Mb/s" + "\n" + filename;
|
||||
$" MB - {width} x {height}\n{videoCodec} - {bitrate2.ToString("f1")} Mb/s" + "\n" + filename;
|
||||
|
||||
mp.commandv("show-text", text, "5000");
|
||||
}
|
||||
|
||||
@@ -61,10 +61,10 @@ namespace mpvnet
|
||||
Rectangle target = screen.Bounds;
|
||||
Left = target.X + Convert.ToInt32((target.Width - Width) / 2.0);
|
||||
Top = target.Y + Convert.ToInt32((target.Height - Height) / 2.0);
|
||||
SetFormPositionAndSize();
|
||||
SetStartFormPositionAndSize();
|
||||
}
|
||||
|
||||
void SetFormPositionAndSize()
|
||||
void SetStartFormPositionAndSize()
|
||||
{
|
||||
if (IsFullscreen || mp.VideoSize.Width == 0) return;
|
||||
Screen screen = Screen.FromControl(this);
|
||||
@@ -78,6 +78,30 @@ namespace mpvnet
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||
}
|
||||
|
||||
void SetFormPositionAndSizeKeepHeight()
|
||||
{
|
||||
if (IsFullscreen || mp.VideoSize.Width == 0) return;
|
||||
Screen screen = Screen.FromControl(this);
|
||||
int height = ClientSize.Height;
|
||||
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;
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
|
||||
if (left < screens[0].Bounds.Left)
|
||||
left = screens[0].Bounds.Left;
|
||||
|
||||
int maxLeft = screens[0].Bounds.Left + screens.Select((sc) => sc.Bounds.Width).Sum() - rect.Width - SystemInformation.CaptionHeight;
|
||||
|
||||
if (left > maxLeft)
|
||||
left = maxLeft;
|
||||
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||
}
|
||||
|
||||
protected void ProcessCommandLineEarly()
|
||||
{
|
||||
var args = Environment.GetCommandLineArgs().Skip(1);
|
||||
@@ -186,7 +210,7 @@ namespace mpvnet
|
||||
|
||||
private void mp_VideoSizeChanged()
|
||||
{
|
||||
BeginInvoke(new Action(() => SetFormPositionAndSize()));
|
||||
BeginInvoke(new Action(() => SetFormPositionAndSizeKeepHeight()));
|
||||
}
|
||||
|
||||
private void mp_Shutdown()
|
||||
@@ -218,7 +242,7 @@ namespace mpvnet
|
||||
{
|
||||
WindowState = FormWindowState.Normal;
|
||||
FormBorderStyle = FormBorderStyle.Sizable;
|
||||
SetFormPositionAndSize();
|
||||
SetFormPositionAndSizeKeepHeight();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -30,6 +32,9 @@ namespace mpvnet
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
|
||||
|
||||
[DllImport("Shlwapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern uint AssocQueryString(uint flags, uint str, string pszAssoc, string pszExtra, StringBuilder pszOut, ref uint pcchOut);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -34,5 +36,25 @@ namespace mpvnet
|
||||
{
|
||||
Native.AdjustWindowRect(ref rc, (uint)Native.GetWindowLongPtrW(hwnd, -16 /* GWL_STYLE */), false);
|
||||
}
|
||||
|
||||
public static string GetAssociatedApplication(string ext)
|
||||
{
|
||||
uint returnValue = 0U;
|
||||
// ASSOCF_VERIFY, ASSOCSTR_EXECUTABLE
|
||||
if (1 == Native.AssocQueryString(0x40, 2, ext, null, null, ref returnValue))
|
||||
{
|
||||
if (returnValue > 0)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(Convert.ToInt32(returnValue));
|
||||
// ASSOCF_VERIFY, ASSOCSTR_EXECUTABLE
|
||||
if (0 == Native.AssocQueryString(0x40, 2, ext, null, sb, ref returnValue))
|
||||
{
|
||||
var ret = sb.ToString();
|
||||
if (File.Exists(ret)) return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.6.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.6.0.0")]
|
||||
[assembly: AssemblyVersion("1.7.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.7.0.0")]
|
||||
|
||||
Reference in New Issue
Block a user