new menu items and bindings to open mpv.conf and input.conf with a text editor

This commit is contained in:
stax76
2023-12-14 13:48:23 +01:00
parent 9d4779fd96
commit cd54e67b87
12 changed files with 306 additions and 173 deletions

View File

@@ -29,36 +29,35 @@ partial class MainForm
/// </summary>
void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.CursorTimer = new System.Windows.Forms.Timer(this.components);
this.ProgressTimer = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
CursorTimer = new System.Windows.Forms.Timer(components);
ProgressTimer = new System.Windows.Forms.Timer(components);
SuspendLayout();
//
// CursorTimer
//
this.CursorTimer.Enabled = true;
this.CursorTimer.Interval = 1000;
this.CursorTimer.Tick += new System.EventHandler(this.CursorTimer_Tick);
CursorTimer.Enabled = true;
CursorTimer.Interval = 1000;
CursorTimer.Tick += CursorTimer_Tick;
//
// ProgressTimer
//
this.ProgressTimer.Tick += new System.EventHandler(this.ProgressTimer_Tick);
ProgressTimer.Tick += ProgressTimer_Tick;
//
// MainForm
//
this.AllowDrop = true;
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(857, 444);
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.ResumeLayout(false);
AllowDrop = true;
AutoScaleDimensions = new System.Drawing.SizeF(288F, 288F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
BackColor = System.Drawing.Color.Black;
ClientSize = new System.Drawing.Size(1243, 720);
Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
Name = "MainForm";
StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
ResumeLayout(false);
}
#endregion

View File

@@ -210,7 +210,7 @@ public partial class MainForm : Form
{
BeginInvoke(() => {
Screen screen = Screen.FromControl(this);
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
switch (direction)
{
@@ -521,7 +521,7 @@ public partial class MainForm : Form
}
Screen screen = Screen.FromControl(this);
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
int autoFitHeight = Convert.ToInt32(workingArea.Height * Player.Autofit);
if (App.AutofitAudio > 1)
@@ -610,7 +610,7 @@ public partial class MainForm : Form
void SetSize(int width, int height, Screen screen, bool checkAutofit = true)
{
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
int maxHeight = workingArea.Height - (Height - ClientSize.Height) - 2;
int maxWidth = workingArea.Width - (Width - ClientSize.Width);
@@ -653,7 +653,7 @@ public partial class MainForm : Form
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
var rect = new Rect(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
AddWindowBorders(Handle, ref rect, GetDpi(Handle));
WinApiHelp.AddWindowBorders(Handle, ref rect, GetDpi(Handle));
int left = middlePos.X - rect.Width / 2;
int top = middlePos.Y - rect.Height / 2;
@@ -668,10 +668,10 @@ public partial class MainForm : Form
Screen[] screens = Screen.AllScreens;
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();
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();
if (left < minLeft)
left = minLeft;
@@ -734,7 +734,7 @@ public partial class MainForm : Form
public int GetHorizontalLocation(Screen screen)
{
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
Rectangle rect = new Rectangle(Left - workingArea.X, Top - workingArea.Y, Width, Height);
if (workingArea.Width / (float)Width < 1.1)
@@ -751,7 +751,7 @@ public partial class MainForm : Form
public int GetVerticalLocation(Screen screen)
{
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
Rectangle rect = new Rectangle(Left - workingArea.X, Top - workingArea.Y, Width, Height);
if (workingArea.Height / (float)Height < 1.1)
@@ -1018,7 +1018,7 @@ public partial class MainForm : Form
{
Rect rc = Marshal.PtrToStructure<Rect>(m.LParam);
Rect r = rc;
SubtractWindowBorders(Handle, ref r, GetDpi(Handle));
WinApiHelp.SubtractWindowBorders(Handle, ref r, GetDpi(Handle));
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
Size videoSize = Player.VideoSize;
@@ -1032,7 +1032,7 @@ public partial class MainForm : Form
int[] d_corners = { d_w, d_h, -d_w, -d_h };
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
int corner = GetResizeBorder(m.WParam.ToInt32());
int corner = WinApiHelp.GetResizeBorder(m.WParam.ToInt32());
if (corner >= 0)
corners[corner] -= d_corners[corner];
@@ -1384,7 +1384,7 @@ public partial class MainForm : Form
public static int GetDpi(IntPtr hwnd)
{
if (Environment.OSVersion.Version >= WindowsTen1607 && hwnd != IntPtr.Zero)
if (Environment.OSVersion.Version >= WinApiHelp.WindowsTen1607 && hwnd != IntPtr.Zero)
return GetDpiForWindow(hwnd);
else
using (Graphics gx = Graphics.FromHwnd(hwnd))

View File

@@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">

View File

@@ -2,10 +2,9 @@
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using MpvNet.Windows.Help;
using MpvNet.Windows.Native;
using static MpvNet.Windows.Native.WinApi;
namespace MpvNet.Windows.WinForms;
public class SnapManager
@@ -35,7 +34,7 @@ public class SnapManager
void FindSnap(ref Rectangle effectiveBounds)
{
Screen currentScreen = Screen.FromPoint(effectiveBounds.Location);
Rectangle workingArea = GetWorkingArea(Handle, currentScreen.WorkingArea);
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, currentScreen.WorkingArea);
if (InSnapRange(effectiveBounds.Left, workingArea.Left + AnchorDistance))
effectiveBounds.X = workingArea.Left + AnchorDistance;